1 | package net.oni2.aeinstaller.gui.corepackages;
|
---|
2 |
|
---|
3 | import java.awt.event.ActionEvent;
|
---|
4 | import java.awt.event.KeyEvent;
|
---|
5 | import java.util.ResourceBundle;
|
---|
6 |
|
---|
7 | import javax.swing.AbstractAction;
|
---|
8 | import javax.swing.JComponent;
|
---|
9 | import javax.swing.JDialog;
|
---|
10 | import javax.swing.JScrollPane;
|
---|
11 | import javax.swing.JSplitPane;
|
---|
12 | import javax.swing.KeyStroke;
|
---|
13 |
|
---|
14 | import net.oni2.SettingsManager;
|
---|
15 | import net.oni2.aeinstaller.backend.packages.Package;
|
---|
16 | import net.oni2.aeinstaller.gui.modtable.ModSelectionListener;
|
---|
17 | import net.oni2.aeinstaller.gui.modtable.ModTable;
|
---|
18 | import net.oni2.aeinstaller.gui.modtable.ModTable.ETableContentType;
|
---|
19 | import net.oni2.aeinstaller.gui.packageinfobox.PackageInfoBox;
|
---|
20 | import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
|
---|
21 |
|
---|
22 | import org.javabuilders.BuildResult;
|
---|
23 | import org.javabuilders.swing.SwingJavaBuilder;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * @author Christian Illy
|
---|
27 | */
|
---|
28 | public class CorePackagesDialog extends JDialog implements ModSelectionListener {
|
---|
29 | private static final long serialVersionUID = -5444213842599816301L;
|
---|
30 |
|
---|
31 | private ResourceBundle bundle = UTF8ResourceBundleLoader
|
---|
32 | .getBundle("net.oni2.aeinstaller.localization."
|
---|
33 | + getClass().getSimpleName());
|
---|
34 | @SuppressWarnings("unused")
|
---|
35 | private BuildResult result = SwingJavaBuilder.build(this, bundle);
|
---|
36 |
|
---|
37 | private JSplitPane contents;
|
---|
38 |
|
---|
39 | private JScrollPane scrollTools;
|
---|
40 | private ModTable tblTools;
|
---|
41 |
|
---|
42 | private PackageInfoBox pkgInfo;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Open the dialog
|
---|
46 | */
|
---|
47 | public CorePackagesDialog() {
|
---|
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 | contents.setDividerLocation(SettingsManager.getInstance().get(
|
---|
64 | "win_core_divloc", 550));
|
---|
65 | contents.setResizeWeight(0.4);
|
---|
66 |
|
---|
67 | tblTools = new ModTable(ETableContentType.CORE);
|
---|
68 | tblTools.reloadData();
|
---|
69 | scrollTools.setViewportView(tblTools);
|
---|
70 |
|
---|
71 | tblTools.addModSelectionListener(this);
|
---|
72 |
|
---|
73 | setSize(SettingsManager.getInstance().get("win_core_width", 950),
|
---|
74 | SettingsManager.getInstance().get("win_core_height", 600));
|
---|
75 | setLocationRelativeTo(null);
|
---|
76 | }
|
---|
77 |
|
---|
78 | @Override
|
---|
79 | public void modSelectionChanged(ModTable source, Package mod) {
|
---|
80 | pkgInfo.updateInfo(mod);
|
---|
81 | }
|
---|
82 |
|
---|
83 | @SuppressWarnings("unused")
|
---|
84 | private void closing() {
|
---|
85 | SettingsManager.getInstance().put("win_core_divloc",
|
---|
86 | contents.getDividerLocation());
|
---|
87 | SettingsManager.getInstance().put("win_core_width", getWidth());
|
---|
88 | SettingsManager.getInstance().put("win_core_height", getHeight());
|
---|
89 | }
|
---|
90 | }
|
---|