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

Last change on this file since 846 was 840, checked in by alloc, 12 years ago

AEI2.07:

  • Allow for non-ISO-8859-1 characters in properties files (more exactly require them to be UTF8)
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;
17import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
18
19import org.javabuilders.BuildResult;
20import org.javabuilders.swing.SwingJavaBuilder;
21
22/**
23 * @author Christian Illy
24 */
25public 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}
Note: See TracBrowser for help on using the repository browser.