ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java
Revision: 840
Committed: Tue Apr 30 00:05:15 2013 UTC (12 years, 5 months ago) by alloc
Content type: text/x-java
File size: 3013 byte(s)
Log Message:
AEI2.07:
- Allow for non-ISO-8859-1 characters in properties files (more exactly require them to be UTF8)

File Contents

# Content
1 package net.oni2.aeinstaller.gui.settings;
2
3 import java.awt.event.ActionEvent;
4 import java.awt.event.KeyEvent;
5 import java.util.ResourceBundle;
6
7 import javax.swing.AbstractAction;
8 import javax.swing.JCheckBox;
9 import javax.swing.JComboBox;
10 import javax.swing.JComponent;
11 import javax.swing.JDialog;
12 import javax.swing.JOptionPane;
13 import javax.swing.KeyStroke;
14 import javax.swing.UIManager;
15
16 import net.oni2.SettingsManager;
17 import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
18
19 import org.javabuilders.BuildResult;
20 import org.javabuilders.swing.SwingJavaBuilder;
21
22 /**
23 * @author Christian Illy
24 */
25 public class SettingsDialog extends JDialog {
26 private static final long serialVersionUID = -5719515325671846620L;
27
28 private ResourceBundle bundle = UTF8ResourceBundleLoader
29 .getBundle("net.oni2.aeinstaller.localization."
30 + getClass().getSimpleName());
31 @SuppressWarnings("unused")
32 private BuildResult result = SwingJavaBuilder.build(this, bundle);
33
34 private JComboBox cmbLaF;
35 private LaFComboModel laFModel;
36
37 private JCheckBox chkNotifyOnStart;
38 private JCheckBox chkNotifyDepsAfterInstall;
39 private JCheckBox chkCopyIntro;
40 private JCheckBox chkCopyOutro;
41
42 /**
43 * Open the settings
44 */
45 public SettingsDialog() {
46 setResizable(false);
47
48 AbstractAction closeAction = new AbstractAction() {
49
50 private static final long serialVersionUID = 1L;
51
52 public void actionPerformed(ActionEvent arg0) {
53 dispose();
54 }
55 };
56 KeyStroke ksCtrlW = KeyStroke
57 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
58 getRootPane()
59 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
60 .put(ksCtrlW, "close");
61 getRootPane().getActionMap().put("close", closeAction);
62
63 initValues();
64
65 setLocationRelativeTo(null);
66 }
67
68 private void initValues() {
69 SettingsManager set = SettingsManager.getInstance();
70
71 laFModel = new LaFComboModel();
72 cmbLaF.setModel(laFModel);
73
74 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
75 chkNotifyDepsAfterInstall.setSelected(set.get("notifyDepsAfterInstall",
76 false));
77 chkCopyIntro.setSelected(set.get("copyintro", false));
78 chkCopyOutro.setSelected(set.get("copyoutro", true));
79 }
80
81 @SuppressWarnings("unused")
82 private boolean save() {
83 SettingsManager set = SettingsManager.getInstance();
84
85 set.put("notifyupdates", chkNotifyOnStart.isSelected());
86 set.put("notifyDepsAfterInstall",
87 chkNotifyDepsAfterInstall.isSelected());
88 set.put("copyintro", chkCopyIntro.isSelected());
89 set.put("copyoutro", chkCopyOutro.isSelected());
90
91 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
92 .getClass().getName());
93 String newLaf = laFModel.getSelectedClassName();
94
95 if (!newLaf.equals(oldLaf)) {
96 set.put("lookandfeel", newLaf);
97 JOptionPane.showMessageDialog(this,
98 bundle.getString("newLaF.text"),
99 bundle.getString("newLaF.title"),
100 JOptionPane.INFORMATION_MESSAGE);
101 }
102
103 return true;
104 }
105
106 }