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

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

AEI2.08, AEIUpdater:

File size: 3.1 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
[852]16import net.oni2.ProxySettings;
[720]17import net.oni2.SettingsManager;
[852]18import net.oni2.aeinstaller.backend.Paths;
[840]19import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
[591]20
21import org.javabuilders.BuildResult;
22import org.javabuilders.swing.SwingJavaBuilder;
23
24/**
25 * @author Christian Illy
26 */
[593]27public class SettingsDialog extends JDialog {
[591]28 private static final long serialVersionUID = -5719515325671846620L;
29
[840]30 private ResourceBundle bundle = UTF8ResourceBundleLoader
[629]31 .getBundle("net.oni2.aeinstaller.localization."
32 + getClass().getSimpleName());
[591]33 @SuppressWarnings("unused")
34 private BuildResult result = SwingJavaBuilder.build(this, bundle);
35
36 private JComboBox cmbLaF;
37 private LaFComboModel laFModel;
38
[608]39 private JCheckBox chkNotifyOnStart;
[646]40 private JCheckBox chkNotifyDepsAfterInstall;
[625]41 private JCheckBox chkCopyIntro;
42 private JCheckBox chkCopyOutro;
[608]43
[591]44 /**
[593]45 * Open the settings
[591]46 */
[593]47 public SettingsDialog() {
[609]48 setResizable(false);
[591]49
50 AbstractAction closeAction = new AbstractAction() {
51
52 private static final long serialVersionUID = 1L;
53
54 public void actionPerformed(ActionEvent arg0) {
55 dispose();
56 }
57 };
58 KeyStroke ksCtrlW = KeyStroke
59 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
60 getRootPane()
61 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
62 .put(ksCtrlW, "close");
63 getRootPane().getActionMap().put("close", closeAction);
64
65 initValues();
[641]66
67 setLocationRelativeTo(null);
[591]68 }
69
70 private void initValues() {
[720]71 SettingsManager set = SettingsManager.getInstance();
[591]72
73 laFModel = new LaFComboModel();
74 cmbLaF.setModel(laFModel);
[608]75
76 chkNotifyOnStart.setSelected(set.get("notifyupdates", true));
[840]77 chkNotifyDepsAfterInstall.setSelected(set.get("notifyDepsAfterInstall",
78 false));
[625]79 chkCopyIntro.setSelected(set.get("copyintro", false));
80 chkCopyOutro.setSelected(set.get("copyoutro", true));
[591]81 }
82
83 @SuppressWarnings("unused")
84 private boolean save() {
[720]85 SettingsManager set = SettingsManager.getInstance();
[591]86
[625]87 set.put("notifyupdates", chkNotifyOnStart.isSelected());
[840]88 set.put("notifyDepsAfterInstall",
89 chkNotifyDepsAfterInstall.isSelected());
[625]90 set.put("copyintro", chkCopyIntro.isSelected());
91 set.put("copyoutro", chkCopyOutro.isSelected());
[608]92
93 String oldLaf = set.get("lookandfeel", UIManager.getLookAndFeel()
94 .getClass().getName());
[591]95 String newLaf = laFModel.getSelectedClassName();
96
97 if (!newLaf.equals(oldLaf)) {
98 set.put("lookandfeel", newLaf);
99 JOptionPane.showMessageDialog(this,
100 bundle.getString("newLaF.text"),
101 bundle.getString("newLaF.title"),
102 JOptionPane.INFORMATION_MESSAGE);
103 }
[852]104
105 ProxySettings prox = ProxySettings.getInstance();
106 prox.serializeToFile(Paths.getProxySettingsFilename());
[591]107
108 return true;
109 }
110
111}
Note: See TracBrowser for help on using the repository browser.