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

Last change on this file since 722 was 720, checked in by alloc, 12 years ago

AEI2: Looooots of refactorings for breaking out independent features into libraries

File size: 2.9 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.SettingsManager;
17
18import org.javabuilders.BuildResult;
19import org.javabuilders.swing.SwingJavaBuilder;
20
21/**
22 * @author Christian Illy
23 */
24public 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 chkNotifyDepsAfterInstall;
38 private JCheckBox chkCopyIntro;
39 private JCheckBox chkCopyOutro;
40
41 /**
42 * Open the settings
43 */
44 public SettingsDialog() {
45 setResizable(false);
46
47 AbstractAction closeAction = new AbstractAction() {
48
49 private static final long serialVersionUID = 1L;
50
51 public void actionPerformed(ActionEvent arg0) {
52 dispose();
53 }
54 };
55 KeyStroke ksCtrlW = KeyStroke
56 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
57 getRootPane()
58 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
59 .put(ksCtrlW, "close");
60 getRootPane().getActionMap().put("close", closeAction);
61
62 initValues();
63
64 setLocationRelativeTo(null);
65 }
66
67 private void initValues() {
68 SettingsManager set = SettingsManager.getInstance();
69
70 laFModel = new LaFComboModel();
71 cmbLaF.setModel(laFModel);
72
73 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
74 chkNotifyDepsAfterInstall.setSelected(set.get("notifyDepsAfterInstall", false));
75 chkCopyIntro.setSelected(set.get("copyintro", false));
76 chkCopyOutro.setSelected(set.get("copyoutro", true));
77 }
78
79 @SuppressWarnings("unused")
80 private boolean save() {
81 SettingsManager set = SettingsManager.getInstance();
82
83 set.put("notifyupdates", chkNotifyOnStart.isSelected());
84 set.put("notifyDepsAfterInstall", chkNotifyDepsAfterInstall.isSelected());
85 set.put("copyintro", chkCopyIntro.isSelected());
86 set.put("copyoutro", chkCopyOutro.isSelected());
87
88 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
89 .getClass().getName());
90 String newLaf = laFModel.getSelectedClassName();
91
92 if (!newLaf.equals(oldLaf)) {
93 set.put("lookandfeel", newLaf);
94 JOptionPane.showMessageDialog(this,
95 bundle.getString("newLaF.text"),
96 bundle.getString("newLaF.title"),
97 JOptionPane.INFORMATION_MESSAGE);
98 }
99
100 return true;
101 }
102
103}
Note: See TracBrowser for help on using the repository browser.