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

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

AEI2 0.88:

  • Localization files moved to common localization package
File size: 2.6 KB
RevLine 
[591]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;
[608]8import javax.swing.JCheckBox;
[591]9import javax.swing.JComboBox;
10import javax.swing.JComponent;
[593]11import javax.swing.JDialog;
[591]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 */
[593]24public class SettingsDialog extends JDialog {
[591]25 private static final long serialVersionUID = -5719515325671846620L;
26
[629]27 private ResourceBundle bundle = ResourceBundle
28 .getBundle("net.oni2.aeinstaller.localization."
29 + getClass().getSimpleName());
[591]30 @SuppressWarnings("unused")
31 private BuildResult result = SwingJavaBuilder.build(this, bundle);
32
33 private JComboBox cmbLaF;
34 private LaFComboModel laFModel;
35
[608]36 private JCheckBox chkNotifyOnStart;
[625]37 private JCheckBox chkCopyIntro;
38 private JCheckBox chkCopyOutro;
[608]39
[591]40 /**
[593]41 * Open the settings
[591]42 */
[593]43 public SettingsDialog() {
[609]44 setResizable(false);
[591]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
64 private void initValues() {
65 Settings set = Settings.getInstance();
66
67 laFModel = new LaFComboModel();
68 cmbLaF.setModel(laFModel);
[608]69
70 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
[625]71 chkCopyIntro.setSelected(set.get("copyintro", false));
72 chkCopyOutro.setSelected(set.get("copyoutro", true));
[591]73 }
74
75 @SuppressWarnings("unused")
76 private boolean save() {
77 Settings set = Settings.getInstance();
78
[625]79 set.put("notifyupdates", chkNotifyOnStart.isSelected());
80 set.put("copyintro", chkCopyIntro.isSelected());
81 set.put("copyoutro", chkCopyOutro.isSelected());
[608]82
83 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
84 .getClass().getName());
[591]85 String newLaf = laFModel.getSelectedClassName();
86
87 if (!newLaf.equals(oldLaf)) {
88 set.put("lookandfeel", newLaf);
89 JOptionPane.showMessageDialog(this,
90 bundle.getString("newLaF.text"),
91 bundle.getString("newLaF.title"),
92 JOptionPane.INFORMATION_MESSAGE);
93 }
94
95 return true;
96 }
97
98}
Note: See TracBrowser for help on using the repository browser.