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

Last change on this file since 626 was 625, checked in by alloc, 12 years ago

AEI2 0.85:

  • Added intro/outro copy and settings
  • Added tool manager dialog (empty for now)
  • AEI uses jar-path as working location again. Only uses workingdirectory if run with -debug now
File size: 2.6 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.aeinstaller.backend.Settings;
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.getBundle(getClass()
28 .getName());
29 @SuppressWarnings("unused")
30 private BuildResult result = SwingJavaBuilder.build(this, bundle);
31
32 private JComboBox cmbLaF;
33 private LaFComboModel laFModel;
34
35 private JCheckBox chkNotifyOnStart;
36 private JCheckBox chkCopyIntro;
37 private JCheckBox chkCopyOutro;
38
39 /**
40 * Open the settings
41 */
42 public SettingsDialog() {
43 setResizable(false);
44
45 AbstractAction closeAction = new AbstractAction() {
46
47 private static final long serialVersionUID = 1L;
48
49 public void actionPerformed(ActionEvent arg0) {
50 dispose();
51 }
52 };
53 KeyStroke ksCtrlW = KeyStroke
54 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
55 getRootPane()
56 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
57 .put(ksCtrlW, "close");
58 getRootPane().getActionMap().put("close", closeAction);
59
60 initValues();
61 }
62
63 private void initValues() {
64 Settings set = Settings.getInstance();
65
66 laFModel = new LaFComboModel();
67 cmbLaF.setModel(laFModel);
68
69 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
70 chkCopyIntro.setSelected(set.get("copyintro", false));
71 chkCopyOutro.setSelected(set.get("copyoutro", true));
72 }
73
74 @SuppressWarnings("unused")
75 private boolean save() {
76 Settings set = Settings.getInstance();
77
78 set.put("notifyupdates", chkNotifyOnStart.isSelected());
79 set.put("copyintro", chkCopyIntro.isSelected());
80 set.put("copyoutro", chkCopyOutro.isSelected());
81
82 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
83 .getClass().getName());
84 String newLaf = laFModel.getSelectedClassName();
85
86 if (!newLaf.equals(oldLaf)) {
87 set.put("lookandfeel", newLaf);
88 JOptionPane.showMessageDialog(this,
89 bundle.getString("newLaF.text"),
90 bundle.getString("newLaF.title"),
91 JOptionPane.INFORMATION_MESSAGE);
92 }
93
94 return true;
95 }
96
97}
Note: See TracBrowser for help on using the repository browser.