From 76f68c1994f009e58bcdfea629db9591e92a7943 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Paour Date: Fri, 13 Jun 2003 00:23:37 +0000 Subject: [PATCH] Preferences can be invoked in such a way that it jumps to a panel immediately. --- .../prefs/PreferencesDialog.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/com/gallery/GalleryRemote/prefs/PreferencesDialog.java b/com/gallery/GalleryRemote/prefs/PreferencesDialog.java index b45f72d..05200f5 100644 --- a/com/gallery/GalleryRemote/prefs/PreferencesDialog.java +++ b/com/gallery/GalleryRemote/prefs/PreferencesDialog.java @@ -14,6 +14,7 @@ import java.util.Properties; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.io.IOException; /** @@ -26,7 +27,8 @@ public class PreferencesDialog extends JDialog implements ListSelectionListener, public static final String MODULE = "PrefsDlog"; DefaultListModel panels = new DefaultListModel(); - PropertiesFile oldProperties = null; + HashMap panelNames = new HashMap(); + private boolean isOK = false; JPanel jPanel1 = new JPanel(); JScrollPane jScrollPane1 = new JScrollPane(); @@ -42,7 +44,6 @@ public class PreferencesDialog extends JDialog implements ListSelectionListener, public PreferencesDialog(Frame owner) { super(owner, true); - oldProperties = (PropertiesFile) GalleryRemote.getInstance().properties.clone(); try { jbInit(); @@ -55,8 +56,6 @@ public PreferencesDialog(Frame owner) { jIcons.setSelectedIndex(0); // this must be done to call valueChanged DialogUtil.center(this, owner); - - setVisible( true ); } private void loadPanes() { @@ -77,6 +76,8 @@ private void loadPanes() { panels.addElement(pp); jPanels.add(className, pp); + + panelNames.put(className, pp); } catch (Exception e) { Log.log(Log.ERROR, MODULE, "Bad panel: " + className); Log.logException(Log.ERROR, MODULE, e); @@ -89,6 +90,12 @@ private void loadPanes() { } } + public void setPanel(String className) { + PreferencePanel pp = (PreferencePanel) panelNames.get(className); + + jIcons.setSelectedValue(pp, true); + } + private void jbInit() throws Exception { jPanel1.setLayout(gridBagLayout1); jScrollPane1.setAlignmentY((float) 0.5); @@ -156,10 +163,12 @@ public void actionPerformed(ActionEvent e) { } } + isOK = true; + setVisible(false); - Log.log(Log.TRACE, MODULE, "Updating preferences"); - ((MainFrame) getOwner()).readPreferences(oldProperties); + //Log.log(Log.TRACE, MODULE, "Updating preferences"); + //((MainFrame) getOwner()).readPreferences(oldProperties); } else if (cmd.equals("Cancel")) { setVisible(false); } else if (cmd.equals("Revert")) { @@ -169,6 +178,10 @@ public void actionPerformed(ActionEvent e) { } } + public boolean isOK() { + return isOK; + } + /** * Cell renderer *