source: java/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java@ 853

Last change on this file since 853 was 852, checked in by alloc, 12 years ago

AEI2.08, AEIUpdater:

File size: 3.1 KB
Line 
1package net.oni2.aeinstaller.gui.settings;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.KeyEvent;
5import java.util.ResourceBundle;
6
7import javax.swing.AbstractAction;
8import javax.swing.JCheckBox;
9import javax.swing.JComboBox;
10import javax.swing.JComponent;
11import javax.swing.JDialog;
12import javax.swing.JOptionPane;
13import javax.swing.KeyStroke;
14import javax.swing.UIManager;
15
16import net.oni2.ProxySettings;
17import net.oni2.SettingsManager;
18import net.oni2.aeinstaller.backend.Paths;
19import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
20
21import org.javabuilders.BuildResult;
22import org.javabuilders.swing.SwingJavaBuilder;
23
24/**
25 * @author Christian Illy
26 */
27public 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}
Note: See TracBrowser for help on using the repository browser.