ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/java/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java
Revision: 641
Committed: Mon Jan 21 11:14:52 2013 UTC (12 years, 9 months ago) by alloc
Content type: text/x-java
Original Path: AE/installer2/src/net/oni2/aeinstaller/gui/settings/SettingsDialog.java
File size: 2711 byte(s)
Log Message:
AEI2 0.98:
- Reduced number+size of HTTP queries
- Removed "submitter" field
- Added output of dependencies to be selected before continuing

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