[Lilith-devel] SF.net SVN: lilith:[372] trunk/lilith/src/main/java/de/huxhorn/lilith
Brought to you by:
huxhorn
From: <hu...@us...> - 2009-10-12 15:51:26
|
Revision: 372 http://lilith.svn.sourceforge.net/lilith/?rev=372&view=rev Author: huxhorn Date: 2009-10-12 15:51:12 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Fixes ticket #73. Modified Paths: -------------- trunk/lilith/src/main/java/de/huxhorn/lilith/consumers/FileDumpEventConsumer.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/ApplicationPreferences.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/MainFrame.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/GeneralPanel.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/PreferencesDialog.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/SourceFilteringPanel.java trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/StartupShutdownPanel.java Added Paths: ----------- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/WindowsPanel.java Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/consumers/FileDumpEventConsumer.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/consumers/FileDumpEventConsumer.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/consumers/FileDumpEventConsumer.java 2009-10-12 15:51:12 UTC (rev 372) @@ -36,20 +36,35 @@ private final Logger logger = LoggerFactory.getLogger(FileDumpEventConsumer.class); private FileBuffer<EventWrapper<T>> fileBuffer; + private boolean enabled; public FileDumpEventConsumer(SourceIdentifier sourceIdentifier, FileBufferFactory<T> fileBufferFactory) { + enabled = true; fileBuffer = fileBufferFactory.createActiveBuffer(sourceIdentifier); } public void consume(List<EventWrapper<T>> events) { - fileBuffer.addAll(events); - if(logger.isInfoEnabled()) logger.info("Wrote {} events to file.", events.size()); + if(enabled) + { + fileBuffer.addAll(events); + if(logger.isInfoEnabled()) logger.info("Wrote {} events to file.", events.size()); + } } public Buffer<EventWrapper<T>> getBuffer() { return fileBuffer; } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + public boolean isEnabled() + { + return enabled; + } } Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/ApplicationPreferences.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/ApplicationPreferences.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/ApplicationPreferences.java 2009-10-12 15:51:12 UTC (rev 372) @@ -117,6 +117,7 @@ public static final String ASKING_BEFORE_QUIT_PROPERTY = "askingBeforeQuit"; public static final String CURRENT_TIP_OF_THE_DAY_PROPERTY = "currentTipOfTheDay"; public static final String SHOWING_TIP_OF_THE_DAY_PROPERTY = "showingTipOfTheDay"; + public static final String GLOBAL_LOGGING_ENABLED_PROPERTY = "globalLoggingEnabled"; public static final String LOGGING_LAYOUT_GLOBAL_XML_FILENAME = "loggingLayoutGlobal.xml"; public static final String LOGGING_LAYOUT_XML_FILENAME = "loggingLayout.xml"; @@ -1035,6 +1036,19 @@ return PREFERENCES.getBoolean(SHOWING_TIP_OF_THE_DAY_PROPERTY, true); } + public void setGlobalLoggingEnabled(boolean globalLoggingEnabled) + { + Object oldValue = isGlobalLoggingEnabled(); + PREFERENCES.putBoolean(GLOBAL_LOGGING_ENABLED_PROPERTY, globalLoggingEnabled); + Object newValue = isGlobalLoggingEnabled(); + propertyChangeSupport.firePropertyChange(GLOBAL_LOGGING_ENABLED_PROPERTY, oldValue, newValue); + } + + public boolean isGlobalLoggingEnabled() + { + return PREFERENCES.getBoolean(GLOBAL_LOGGING_ENABLED_PROPERTY, true); + } + private void initConditions() { File appPath = getStartupApplicationPath(); @@ -1762,6 +1776,8 @@ } /** + * @param file the properties xml file + * @return the resulting map * @noinspection MismatchedQueryAndUpdateOfCollection */ private Map<String, String> loadPropertiesXml(File file) @@ -1799,12 +1815,16 @@ } /** + * @param file the properties xml file + * @param stringStringMap the map to be written + * @param comment the comment + * @return whether or not the file could be written * @noinspection MismatchedQueryAndUpdateOfCollection */ - private boolean writePropertiesXml(File file, Map<String, String> sourceNames, String comment) + private boolean writePropertiesXml(File file, Map<String, String> stringStringMap, String comment) { Properties output = new Properties(); - for(Map.Entry<String, String> entry : sourceNames.entrySet()) + for(Map.Entry<String, String> entry : stringStringMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/MainFrame.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/MainFrame.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/MainFrame.java 2009-10-12 15:51:12 UTC (rev 372) @@ -205,6 +205,8 @@ private JPanel statusBar; private TipOfTheDayDialog tipOfTheDayDialog; private CheckForUpdateDialog checkForUpdateDialog; + private FileDumpEventConsumer<LoggingEvent> loggingFileDump; + private FileDumpEventConsumer<AccessEvent> accessFileDump; /* * Need to use ConcurrentMap because it's accessed by both the EventDispatchThread and the CleanupThread. @@ -522,10 +524,10 @@ setSplashStatusText("Creating global views."); SourceIdentifier globalSourceIdentifier = new SourceIdentifier("global", null); - FileDumpEventConsumer<LoggingEvent> loggingFileDump = new FileDumpEventConsumer<LoggingEvent>(globalSourceIdentifier, loggingFileBufferFactory); + loggingFileDump = new FileDumpEventConsumer<LoggingEvent>(globalSourceIdentifier, loggingFileBufferFactory); + accessFileDump = new FileDumpEventConsumer<AccessEvent>(globalSourceIdentifier, accessFileBufferFactory); + setGlobalLoggingEnabled(applicationPreferences.isGlobalLoggingEnabled()); - FileDumpEventConsumer<AccessEvent> accessFileDump = new FileDumpEventConsumer<AccessEvent>(globalSourceIdentifier, accessFileBufferFactory); - BlockingCircularBuffer<EventWrapper<LoggingEvent>> loggingEventQueue = new LilithBuffer<LoggingEvent>(applicationPreferences, 1000); BlockingCircularBuffer<EventWrapper<AccessEvent>> accessEventQueue = new LilithBuffer<AccessEvent>(applicationPreferences, 1000); @@ -2225,7 +2227,6 @@ frame.setShowingStatusbar(applicationPreferences.isShowingStatusbar()); frame.setTitle(title); frame.setSize(800, 600); - // XXX Windows.showWindow(frame, null, false); executeScrollToBottom(frame); @@ -2632,6 +2633,12 @@ return; } + if(ApplicationPreferences.GLOBAL_LOGGING_ENABLED_PROPERTY.equals(propName)) + { + setGlobalLoggingEnabled(applicationPreferences.isGlobalLoggingEnabled()); + return; + } + if(ApplicationPreferences.COLORING_WHOLE_ROW_PROPERTY.equals(propName)) { coloringWholeRow = applicationPreferences.isColoringWholeRow(); @@ -2669,6 +2676,12 @@ } } + private void setGlobalLoggingEnabled(boolean globalLoggingEnabled) + { + loggingFileDump.setEnabled(globalLoggingEnabled); + accessFileDump.setEnabled(globalLoggingEnabled); + } + private void setCheckingForUpdate(boolean checkingForUpdate) { preferencesDialog.setCheckingForUpdate(checkingForUpdate); Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/GeneralPanel.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/GeneralPanel.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/GeneralPanel.java 2009-10-12 15:51:12 UTC (rev 372) @@ -37,15 +37,7 @@ private PreferencesDialog preferencesDialog; private ApplicationPreferences applicationPreferences; - // Windows/View - private JCheckBox showingToolbarCheckbox; - private JCheckBox showingStatusbarCheckbox; - private JCheckBox internalFramesCheckbox; - private JCheckBox autoOpenCheckbox; - private JCheckBox autoFocusCheckbox; - private JCheckBox autoCloseCheckbox; - private JCheckBox showIdentifierCheckbox; - + // Views private JCheckBox scrollingToBottomCheckbox; private JCheckBox coloringWholeRowCheckbox; @@ -58,6 +50,8 @@ private JTextField appPathTextField; private JComboBox lookAndFeelCombo; + private JCheckBox globalLoggingEnabledCheckbox; + public GeneralPanel(PreferencesDialog preferencesDialog) { this.preferencesDialog = preferencesDialog; @@ -68,17 +62,12 @@ private void createUI() { // General - showingToolbarCheckbox = new JCheckBox("Show toolbar."); - showingStatusbarCheckbox = new JCheckBox("Show statusbar."); - internalFramesCheckbox = new JCheckBox("Use internal frames."); - showIdentifierCheckbox = new JCheckBox("Show identifier for named sources."); - showFullCallstackCheckbox = new JCheckBox("Show full Callstack."); - showStackTraceCheckbox = new JCheckBox("Show stacktrace of Throwables"); - autoOpenCheckbox = new JCheckBox("Automatically open new views on connection."); - autoCloseCheckbox = new JCheckBox("Automatically close inactive views on disconnection."); - autoFocusCheckbox = new JCheckBox("Automatically focus window of new view."); scrollingToBottomCheckbox = new JCheckBox("Initial 'Scrolling to Bottom' setting"); coloringWholeRowCheckbox = new JCheckBox("Color whole row according to Level or Status"); + + showFullCallstackCheckbox = new JCheckBox("Show full Callstack."); + showStackTraceCheckbox = new JCheckBox("Show stacktrace of Throwables"); + applicationPathFileChooser = new JFileChooser(); applicationPathFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); @@ -109,16 +98,9 @@ } lookAndFeelCombo = new JComboBox(); - JPanel windowPanel = new JPanel(new GridLayout(7, 1)); - windowPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Frames")); - windowPanel.add(showingToolbarCheckbox); - windowPanel.add(showingStatusbarCheckbox); - windowPanel.add(internalFramesCheckbox); - windowPanel.add(autoOpenCheckbox); - windowPanel.add(autoFocusCheckbox); - windowPanel.add(autoCloseCheckbox); - windowPanel.add(showIdentifierCheckbox); + globalLoggingEnabledCheckbox = new JCheckBox("Enable global logs."); + JPanel viewPanel = new JPanel(new GridLayout(2, 1)); viewPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "View")); viewPanel.add(scrollingToBottomCheckbox); @@ -131,6 +113,10 @@ lookAndFeelCombo.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Look & Feel")); + JPanel globalPanel = new JPanel(new GridLayout(1, 1)); + globalPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Global logs")); + globalPanel.add(globalLoggingEnabledCheckbox); + setLayout(new GridBagLayout()); { @@ -138,44 +124,35 @@ gbc.gridwidth = 1; gbc.weightx = 1; + gbc.anchor = GridBagConstraints.FIRST_LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; - add(windowPanel, gbc); + add(viewPanel, gbc); gbc.gridy = 1; - add(viewPanel, gbc); + add(detailsPanel, gbc); gbc.gridy = 2; - add(detailsPanel, gbc); + add(lookAndFeelCombo, gbc); gbc.gridy = 3; - add(lookAndFeelCombo, gbc); + add(appPathPanel, gbc); gbc.gridy = 4; - add(appPathPanel, gbc); + gbc.weighty = 1; + add(globalPanel, gbc); } } public void initUI() { - showingToolbarCheckbox.setSelected(applicationPreferences.isShowingToolbar()); - showingStatusbarCheckbox.setSelected(applicationPreferences.isShowingStatusbar()); - internalFramesCheckbox.setSelected(applicationPreferences.isUsingInternalFrames()); scrollingToBottomCheckbox.setSelected(applicationPreferences.isScrollingToBottom()); coloringWholeRowCheckbox.setSelected(applicationPreferences.isColoringWholeRow()); - String appPath = applicationPreferences.getApplicationPath().getAbsolutePath(); - appPathTextField.setText(appPath); - appPathTextField.setToolTipText(appPath); - - - autoOpenCheckbox.setSelected(applicationPreferences.isAutoOpening()); - autoCloseCheckbox.setSelected(applicationPreferences.isAutoClosing()); - autoFocusCheckbox.setSelected(applicationPreferences.isAutoFocusingWindow()); - showIdentifierCheckbox.setSelected(applicationPreferences.isShowingIdentifier()); showFullCallstackCheckbox.setSelected(applicationPreferences.isShowingFullCallstack()); showStackTraceCheckbox.setSelected(applicationPreferences.isShowingStackTrace()); + ArrayList<String> lookAndFeels = new ArrayList<String>(); for(UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { @@ -203,28 +180,33 @@ } lookAndFeelCombo.setModel(new DefaultComboBoxModel(lookAndFeels.toArray())); lookAndFeelCombo.setSelectedIndex(selectedIndex); + + String appPath = applicationPreferences.getApplicationPath().getAbsolutePath(); + appPathTextField.setText(appPath); + appPathTextField.setToolTipText(appPath); + + globalLoggingEnabledCheckbox.setSelected(applicationPreferences.isGlobalLoggingEnabled()); } public void saveSettings() { - applicationPreferences.setShowingToolbar(showingToolbarCheckbox.isSelected()); - applicationPreferences.setShowingStatusbar(showingStatusbarCheckbox.isSelected()); - applicationPreferences.setUsingInternalFrames(internalFramesCheckbox.isSelected()); applicationPreferences.setScrollingToBottom(scrollingToBottomCheckbox.isSelected()); applicationPreferences.setColoringWholeRow(coloringWholeRowCheckbox.isSelected()); - applicationPreferences.setAutoOpening(autoOpenCheckbox.isSelected()); - applicationPreferences.setAutoClosing(autoCloseCheckbox.isSelected()); - applicationPreferences.setAutoFocusingWindow(autoFocusCheckbox.isSelected()); - applicationPreferences.setApplicationPath(new File(appPathTextField.getText())); - applicationPreferences.setShowingIdentifier(showIdentifierCheckbox.isSelected()); applicationPreferences.setShowingFullCallstack(showFullCallstackCheckbox.isSelected()); applicationPreferences.setShowingStackTrace(showStackTraceCheckbox.isSelected()); + applicationPreferences.setLookAndFeel((String) lookAndFeelCombo.getSelectedItem()); + + applicationPreferences.setApplicationPath(new File(appPathTextField.getText())); + + applicationPreferences.setGlobalLoggingEnabled(globalLoggingEnabledCheckbox.isSelected()); } private class BrowseApplicationPathAction extends AbstractAction { + private static final long serialVersionUID = -5563121695654253673L; + public BrowseApplicationPathAction() { super(); Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/PreferencesDialog.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/PreferencesDialog.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/PreferencesDialog.java 2009-10-12 15:51:12 UTC (rev 372) @@ -54,6 +54,7 @@ { General, StartupShutdown, + Windows, Sounds, Sources, SourceLists, @@ -71,6 +72,7 @@ private GeneralPanel generalPanel; private StartupShutdownPanel startupShutdownPanel; + private WindowsPanel windowsPanel; private SoundsPanel soundsPanel; private SourcesPanel sourcesPanel; private SourceListsPanel sourceListsPanel; @@ -105,6 +107,7 @@ { generalPanel = new GeneralPanel(this); startupShutdownPanel = new StartupShutdownPanel(this); + windowsPanel = new WindowsPanel(this); soundsPanel = new SoundsPanel(this); sourcesPanel = new SourcesPanel(this); sourceListsPanel = new SourceListsPanel(this); @@ -117,6 +120,7 @@ tabbedPane.add("General", generalPanel); tabbedPane.add("Startup & Shutdown", startupShutdownPanel); + tabbedPane.add("Windows", windowsPanel); tabbedPane.add("Sounds", soundsPanel); tabbedPane.add("Sources", sourcesPanel); tabbedPane.add("Source Lists", sourceListsPanel); @@ -149,6 +153,7 @@ { generalPanel.initUI(); startupShutdownPanel.initUI(); + windowsPanel.initUI(); soundsPanel.initUI(); sourceNames = applicationPreferences.getSourceNames(); if(sourceNames == null) @@ -240,6 +245,7 @@ { generalPanel.saveSettings(); startupShutdownPanel.saveSettings(); + windowsPanel.saveSettings(); soundsPanel.saveSettings(); conditionsPanel.saveSettings(); applicationPreferences.setSourceNames(sourceNames); @@ -427,28 +433,31 @@ switch(pane) { case General: - tabbedPane.setSelectedComponent(generalPanel); + tabbedPane.setSelectedComponent(generalPanel); break; case StartupShutdown: - tabbedPane.setSelectedComponent(startupShutdownPanel); + tabbedPane.setSelectedComponent(startupShutdownPanel); break; + case Windows: + tabbedPane.setSelectedComponent(windowsPanel); + break; case Sounds: - tabbedPane.setSelectedComponent(soundsPanel); + tabbedPane.setSelectedComponent(soundsPanel); break; case Sources: - tabbedPane.setSelectedComponent(sourcesPanel); + tabbedPane.setSelectedComponent(sourcesPanel); break; case SourceLists: - tabbedPane.setSelectedComponent(sourceListsPanel); + tabbedPane.setSelectedComponent(sourceListsPanel); break; case SourceFiltering: - tabbedPane.setSelectedComponent(sourceFilteringPanel); + tabbedPane.setSelectedComponent(sourceFilteringPanel); break; case Conditions: - tabbedPane.setSelectedComponent(conditionsPanel); + tabbedPane.setSelectedComponent(conditionsPanel); break; case Troubleshooting: - tabbedPane.setSelectedComponent(troubleshootingPanel); + tabbedPane.setSelectedComponent(troubleshootingPanel); break; } if(!isVisible()) Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/SourceFilteringPanel.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/SourceFilteringPanel.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/SourceFilteringPanel.java 2009-10-12 15:51:12 UTC (rev 372) @@ -79,10 +79,10 @@ setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); - gbc.anchor = GridBagConstraints.WEST; + gbc.anchor = GridBagConstraints.FIRST_LINE_START; gbc.gridx = 0; gbc.gridy = 0; - gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.gridwidth = 2; add(disabledButton, gbc); gbc.gridx = 0; @@ -92,17 +92,21 @@ gbc.gridx = 1; gbc.gridy = 1; - gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.fill = GridBagConstraints.HORIZONTAL; add(blackListNames, gbc); gbc.gridx = 0; gbc.gridy = 2; - gbc.gridwidth = 1; + gbc.weightx = 0; + gbc.fill = GridBagConstraints.NONE; add(whitelistButton, gbc); gbc.gridx = 1; gbc.gridy = 2; - gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.weighty = 1; + gbc.fill = GridBagConstraints.HORIZONTAL; add(whiteListNames, gbc); } @@ -198,6 +202,8 @@ private class DisabledAction extends AbstractAction { + private static final long serialVersionUID = -4154256012969198212L; + public DisabledAction() { super("None"); @@ -218,6 +224,8 @@ private class BlacklistAction extends AbstractAction { + private static final long serialVersionUID = -1181737422196108645L; + public BlacklistAction() { super("Blacklist on..."); @@ -238,6 +246,8 @@ private class WhitelistAction extends AbstractAction { + private static final long serialVersionUID = -3403085106091507255L; + public WhitelistAction() { super("Whitelist on..."); Modified: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/StartupShutdownPanel.java =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/StartupShutdownPanel.java 2009-10-11 20:54:23 UTC (rev 371) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/StartupShutdownPanel.java 2009-10-12 15:51:12 UTC (rev 372) @@ -72,6 +72,7 @@ { GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.FIRST_LINE_START; gbc.gridwidth = 1; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; @@ -81,6 +82,7 @@ add(startupPanel, gbc); gbc.gridy = 1; + gbc.weighty = 1; add(shutdownPanel, gbc); } } Copied: trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/WindowsPanel.java (from rev 348, trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/GeneralPanel.java) =================================================================== --- trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/WindowsPanel.java (rev 0) +++ trunk/lilith/src/main/java/de/huxhorn/lilith/swing/preferences/WindowsPanel.java 2009-10-12 15:51:12 UTC (rev 372) @@ -0,0 +1,106 @@ +/* + * Lilith - a log event viewer. + * Copyright (C) 2007-2009 Joern Huxhorn + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package de.huxhorn.lilith.swing.preferences; + +import de.huxhorn.lilith.swing.ApplicationPreferences; + +import java.awt.*; + +import javax.swing.*; + +public class WindowsPanel + extends JPanel +{ + private ApplicationPreferences applicationPreferences; + + // Windows + private JCheckBox showingToolbarCheckbox; + private JCheckBox showingStatusbarCheckbox; + private JCheckBox internalFramesCheckbox; + private JCheckBox autoOpenCheckbox; + private JCheckBox autoFocusCheckbox; + private JCheckBox autoCloseCheckbox; + private JCheckBox showIdentifierCheckbox; + + public WindowsPanel(PreferencesDialog preferencesDialog) + { + applicationPreferences = preferencesDialog.getApplicationPreferences(); + createUI(); + } + + private void createUI() + { + showingToolbarCheckbox = new JCheckBox("Show toolbar."); + showingStatusbarCheckbox = new JCheckBox("Show statusbar."); + internalFramesCheckbox = new JCheckBox("Use internal frames."); + showIdentifierCheckbox = new JCheckBox("Show identifier for named sources."); + autoOpenCheckbox = new JCheckBox("Automatically open new views on connection."); + autoCloseCheckbox = new JCheckBox("Automatically close inactive views on disconnection."); + autoFocusCheckbox = new JCheckBox("Automatically focus window of new view."); + + setLayout(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = GridBagConstraints.FIRST_LINE_START; + gbc.weightx = 1; + gbc.gridx = 0; + + gbc.gridy = 0; + add(showingToolbarCheckbox, gbc); + + gbc.gridy = 1; + add(showingStatusbarCheckbox, gbc); + + gbc.gridy = 2; + add(internalFramesCheckbox, gbc); + + gbc.gridy = 3; + add(autoOpenCheckbox, gbc); + + gbc.gridy = 4; + add(autoFocusCheckbox, gbc); + + gbc.gridy = 5; + add(autoCloseCheckbox, gbc); + + gbc.weighty = 1; + gbc.gridy = 6; + add(showIdentifierCheckbox, gbc); + } + + public void initUI() + { + showingToolbarCheckbox.setSelected(applicationPreferences.isShowingToolbar()); + showingStatusbarCheckbox.setSelected(applicationPreferences.isShowingStatusbar()); + internalFramesCheckbox.setSelected(applicationPreferences.isUsingInternalFrames()); + autoOpenCheckbox.setSelected(applicationPreferences.isAutoOpening()); + autoFocusCheckbox.setSelected(applicationPreferences.isAutoFocusingWindow()); + autoCloseCheckbox.setSelected(applicationPreferences.isAutoClosing()); + showIdentifierCheckbox.setSelected(applicationPreferences.isShowingIdentifier()); + } + + public void saveSettings() + { + applicationPreferences.setShowingToolbar(showingToolbarCheckbox.isSelected()); + applicationPreferences.setShowingStatusbar(showingStatusbarCheckbox.isSelected()); + applicationPreferences.setUsingInternalFrames(internalFramesCheckbox.isSelected()); + applicationPreferences.setAutoOpening(autoOpenCheckbox.isSelected()); + applicationPreferences.setAutoFocusingWindow(autoFocusCheckbox.isSelected()); + applicationPreferences.setAutoClosing(autoCloseCheckbox.isSelected()); + applicationPreferences.setShowingIdentifier(showIdentifierCheckbox.isSelected()); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |