ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java
Revision: 852
Committed: Fri May 3 12:25:21 2013 UTC (12 years, 6 months ago) by alloc
Content type: text/x-java
File size: 3205 byte(s)
Log Message:
AEI2.08, AEIUpdater:
- Fixes #3

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