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

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

AEI2 0.86:

  • Added patch-type to tools
File size: 3.7 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.getBundle(getClass()
38 .getName());
39 @SuppressWarnings("unused")
40 private BuildResult result = SwingJavaBuilder.build(this, bundle);
41
42 private JList lstTools;
43
44 private JLabel lblSubmitterVal;
45 private JLabel lblCreatorVal;
46 private JLabel lblPlatformVal;
47 private JLabel lblPackageNumberVal;
48 private HTMLLinkLabel lblDescriptionVal;
49 private JLabel lblDownloadSizeVal;
50
51 private JButton btnInstall;
52
53 /**
54 * Open the dialog
55 */
56 public ToolManager() {
57 setMinimumSize(new Dimension(getWidth() + 100, getHeight() + 100));
58
59 AbstractAction closeAction = new AbstractAction() {
60
61 private static final long serialVersionUID = 1L;
62
63 public void actionPerformed(ActionEvent arg0) {
64 dispose();
65 }
66 };
67 KeyStroke ksCtrlW = KeyStroke
68 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
69 getRootPane()
70 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
71 .put(ksCtrlW, "close");
72 getRootPane().getActionMap().put("close", closeAction);
73
74 lstTools.addListSelectionListener(this);
75 lstTools.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
76
77 DefaultListModel dlm = new DefaultListModel();
78 TreeMap<String, Mod> tools = ModManager.getInstance().getTools();
79 for (String name : tools.keySet())
80 dlm.addElement(tools.get(name));
81 }
82
83 @SuppressWarnings("unused")
84 private void install() {
85 // TODO: care for offline mode
86 JOptionPane.showMessageDialog(this, "install", "todo",
87 JOptionPane.INFORMATION_MESSAGE);
88 }
89
90 @SuppressWarnings("unused")
91 private void installDone() {
92 }
93
94 @Override
95 public void valueChanged(ListSelectionEvent evt) {
96 lblSubmitterVal.setText("");
97 lblCreatorVal.setText("");
98 lblDescriptionVal.setText("");
99 lblPlatformVal.setText("");
100 lblPackageNumberVal.setText("");
101 lblDownloadSizeVal.setText("");
102 btnInstall.setEnabled(false);
103
104 if (lstTools.getSelectedValue() instanceof Mod) {
105 Mod m = (Mod) lstTools.getSelectedValue();
106 lblSubmitterVal.setText(m.getName());
107 lblCreatorVal.setText(m.getCreator());
108 lblDescriptionVal.setText(m.getDescription());
109 lblPlatformVal.setText(m.getPlatform().toString());
110 lblPackageNumberVal.setText(m.getPackageNumberString());
111 lblDownloadSizeVal.setText(SizeFormatter.format(m.getZipSize(), 3));
112 btnInstall.setEnabled(true);
113 if (Installer.getInstalledTools().contains(m.getPackageNumber())) {
114 btnInstall.setText(bundle.getString("btnInstall.un.text"));
115 btnInstall.setToolTipText(bundle
116 .getString("btnInstall.un.tooltip"));
117 } else {
118 btnInstall.setText(bundle.getString("btnInstall.text"));
119 btnInstall.setToolTipText(bundle
120 .getString("btnInstall.tooltip"));
121 }
122 }
123 }
124}
Note: See TracBrowser for help on using the repository browser.