Skip to content

Commit

Permalink
Preferences can be invoked in such a way that it jumps to a panel imm…
Browse files Browse the repository at this point in the history
…ediately.
  • Loading branch information
Pierre-Luc Paour committed Jun 13, 2003
1 parent 88778b2 commit 76f68c1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions com/gallery/GalleryRemote/prefs/PreferencesDialog.java
Expand Up @@ -14,6 +14,7 @@
import java.util.Properties;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.io.IOException;

/**
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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() {
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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")) {
Expand All @@ -169,6 +178,10 @@ public void actionPerformed(ActionEvent e) {
}
}

public boolean isOK() {
return isOK;
}

/**
* Cell renderer
*
Expand Down

0 comments on commit 76f68c1

Please sign in to comment.