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

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

AEI2:

  • Added BSL handling to installation
  • Updated config-terms for dependencies/incompatibilities
  • Fixed mod counts for types
  • Open Edition folder through menu
  • Open folder of already downloaded mod through context menu
  • (Semi?)Fixed launching Oni on MacOS
  • Settings: Added checkbox for update notification
File size: 2.4 KB
Line 
1package net.oni2.aeinstaller.gui.settings;
2
3import java.awt.Dimension;
4import java.awt.event.ActionEvent;
5import java.awt.event.KeyEvent;
6import java.util.ResourceBundle;
7
8import javax.swing.AbstractAction;
9import javax.swing.JCheckBox;
10import javax.swing.JComboBox;
11import javax.swing.JComponent;
12import javax.swing.JDialog;
13import javax.swing.JOptionPane;
14import javax.swing.KeyStroke;
15import javax.swing.UIManager;
16
17import net.oni2.aeinstaller.backend.Settings;
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 = ResourceBundle.getBundle(getClass()
29 .getName());
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
38 /**
39 * Open the settings
40 */
41 public SettingsDialog() {
42 setMinimumSize(new Dimension(320, (int) getSize().getHeight() + 0));
43
44 AbstractAction closeAction = new AbstractAction() {
45
46 private static final long serialVersionUID = 1L;
47
48 public void actionPerformed(ActionEvent arg0) {
49 dispose();
50 }
51 };
52 KeyStroke ksCtrlW = KeyStroke
53 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
54 getRootPane()
55 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
56 .put(ksCtrlW, "close");
57 getRootPane().getActionMap().put("close", closeAction);
58
59 initValues();
60 }
61
62 private void initValues() {
63 Settings set = Settings.getInstance();
64
65 laFModel = new LaFComboModel();
66 cmbLaF.setModel(laFModel);
67
68 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
69 }
70
71 @SuppressWarnings("unused")
72 private boolean save() {
73 Settings set = Settings.getInstance();
74
75 set.get("notifyupdates", chkNotifyOnStart.isSelected());
76
77 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
78 .getClass().getName());
79 String newLaf = laFModel.getSelectedClassName();
80
81 if (!newLaf.equals(oldLaf)) {
82 set.put("lookandfeel", newLaf);
83 JOptionPane.showMessageDialog(this,
84 bundle.getString("newLaF.text"),
85 bundle.getString("newLaF.title"),
86 JOptionPane.INFORMATION_MESSAGE);
87 }
88
89 return true;
90 }
91
92}
Note: See TracBrowser for help on using the repository browser.