source: AE/installer2/src/net/oni2/aeinstaller/gui/toolmanager/ToolManager.java@ 635

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

AEI2 0.88:

  • Localization files moved to common localization package
File size: 3.8 KB
Line 
1package net.oni2.aeinstaller.gui.toolmanager;
2
3import java.awt.Dimension;
4import java.awt.event.ActionEvent;
5import java.awt.event.KeyEvent;
6import java.util.ResourceBundle;
7import java.util.TreeMap;
8
9import javax.swing.AbstractAction;
10import javax.swing.DefaultListModel;
11import javax.swing.JButton;
12import javax.swing.JComponent;
13import javax.swing.JDialog;
14import javax.swing.JLabel;
15import javax.swing.JList;
16import javax.swing.JOptionPane;
17import javax.swing.KeyStroke;
18import javax.swing.ListSelectionModel;
19import javax.swing.event.ListSelectionEvent;
20import javax.swing.event.ListSelectionListener;
21
22import net.oni2.aeinstaller.backend.SizeFormatter;
23import net.oni2.aeinstaller.backend.mods.Mod;
24import net.oni2.aeinstaller.backend.mods.ModManager;
25import net.oni2.aeinstaller.backend.oni.Installer;
26import net.oni2.aeinstaller.gui.HTMLLinkLabel;
27
28import org.javabuilders.BuildResult;
29import org.javabuilders.swing.SwingJavaBuilder;
30
31/**
32 * @author Christian Illy
33 */
34public class ToolManager extends JDialog implements ListSelectionListener {
35 private static final long serialVersionUID = 343221630538866384L;
36
37 private ResourceBundle bundle = ResourceBundle
38 .getBundle("net.oni2.aeinstaller.localization."
39 + getClass().getSimpleName());
40 @SuppressWarnings("unused")
41 private BuildResult result = SwingJavaBuilder.build(this, bundle);
42
43 private JList lstTools;
44
45 private JLabel lblSubmitterVal;
46 private JLabel lblCreatorVal;
47 private JLabel lblPlatformVal;
48 private JLabel lblPackageNumberVal;
49 private HTMLLinkLabel lblDescriptionVal;
50 private JLabel lblDownloadSizeVal;
51
52 private JButton btnInstall;
53
54 /**
55 * Open the dialog
56 */
57 public ToolManager() {
58 setMinimumSize(new Dimension(getWidth() + 100, getHeight() + 100));
59
60 AbstractAction closeAction = new AbstractAction() {
61
62 private static final long serialVersionUID = 1L;
63
64 public void actionPerformed(ActionEvent arg0) {
65 dispose();
66 }
67 };
68 KeyStroke ksCtrlW = KeyStroke
69 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
70 getRootPane()
71 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
72 .put(ksCtrlW, "close");
73 getRootPane().getActionMap().put("close", closeAction);
74
75 lstTools.addListSelectionListener(this);
76 lstTools.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
77
78 DefaultListModel dlm = new DefaultListModel();
79 TreeMap<String, Mod> tools = ModManager.getInstance().getTools();
80 for (String name : tools.keySet())
81 dlm.addElement(tools.get(name));
82 }
83
84 @SuppressWarnings("unused")
85 private void install() {
86 // TODO: care for offline mode
87 JOptionPane.showMessageDialog(this, "install", "todo",
88 JOptionPane.INFORMATION_MESSAGE);
89 }
90
91 @SuppressWarnings("unused")
92 private void installDone() {
93 }
94
95 @Override
96 public void valueChanged(ListSelectionEvent evt) {
97 lblSubmitterVal.setText("");
98 lblCreatorVal.setText("");
99 lblDescriptionVal.setText("");
100 lblPlatformVal.setText("");
101 lblPackageNumberVal.setText("");
102 lblDownloadSizeVal.setText("");
103 btnInstall.setEnabled(false);
104
105 if (lstTools.getSelectedValue() instanceof Mod) {
106 Mod m = (Mod) lstTools.getSelectedValue();
107 lblSubmitterVal.setText(m.getName());
108 lblCreatorVal.setText(m.getCreator());
109 lblDescriptionVal.setText(m.getDescription());
110 lblPlatformVal.setText(m.getPlatform().toString());
111 lblPackageNumberVal.setText(m.getPackageNumberString());
112 lblDownloadSizeVal.setText(SizeFormatter.format(m.getZipSize(), 3));
113 btnInstall.setEnabled(true);
114 if (Installer.getInstalledTools().contains(m.getPackageNumber())) {
115 btnInstall.setText(bundle.getString("btnInstall.un.text"));
116 btnInstall.setToolTipText(bundle
117 .getString("btnInstall.un.tooltip"));
118 } else {
119 btnInstall.setText(bundle.getString("btnInstall.text"));
120 btnInstall.setToolTipText(bundle
121 .getString("btnInstall.tooltip"));
122 }
123 }
124 }
125}
Note: See TracBrowser for help on using the repository browser.