source: AE/installer2/src/net/oni2/aeinstaller/gui/mandatorypackages/MandatoryPackagesDialog.java@ 647

Last change on this file since 647 was 646, checked in by alloc, 12 years ago

AEI2 0.99c:

  • Download window: Show which file is currently being downloaded and if it is an automaticly resolved dependency
  • Added mandatory packages dialog
  • Added option to show automatic resolved dependencies after installation is done instead of interrupting installation process to ask whether to continue
  • ToolManager: version number + last change added
  • Correct output of download-size in mainwin after installation of mods done
File size: 3.9 KB
Line 
1package net.oni2.aeinstaller.gui.mandatorypackages;
2
3import java.awt.Dimension;
4import java.awt.event.ActionEvent;
5import java.awt.event.KeyEvent;
6import java.text.SimpleDateFormat;
7import java.util.Date;
8import java.util.ResourceBundle;
9import java.util.TreeSet;
10
11import javax.swing.AbstractAction;
12import javax.swing.DefaultListModel;
13import javax.swing.JComponent;
14import javax.swing.JDialog;
15import javax.swing.JLabel;
16import javax.swing.JList;
17import javax.swing.JSplitPane;
18import javax.swing.KeyStroke;
19import javax.swing.ListSelectionModel;
20import javax.swing.event.ListSelectionEvent;
21import javax.swing.event.ListSelectionListener;
22
23import net.oni2.aeinstaller.backend.SizeFormatter;
24import net.oni2.aeinstaller.backend.mods.Mod;
25import net.oni2.aeinstaller.backend.mods.ModManager;
26import net.oni2.aeinstaller.backend.mods.Type;
27import net.oni2.aeinstaller.gui.HTMLLinkLabel;
28
29import org.javabuilders.BuildResult;
30import org.javabuilders.swing.SwingJavaBuilder;
31
32/**
33 * @author Christian Illy
34 */
35public class MandatoryPackagesDialog extends JDialog implements
36 ListSelectionListener {
37 private static final long serialVersionUID = -5444213842599816301L;
38
39 private ResourceBundle bundle = ResourceBundle
40 .getBundle("net.oni2.aeinstaller.localization."
41 + getClass().getSimpleName());
42 @SuppressWarnings("unused")
43 private BuildResult result = SwingJavaBuilder.build(this, bundle);
44
45 private JSplitPane contents;
46
47 private JList lstTools;
48
49 private JLabel lblTitleVal;
50 private JLabel lblCreatorVal;
51 private JLabel lblTypesVal;
52 private JLabel lblPlatformVal;
53 private JLabel lblPackageNumberVal;
54 private JLabel lblVersionNumberVal;
55 private JLabel lblLastChangeVal;
56 private HTMLLinkLabel lblDescriptionVal;
57 private JLabel lblDownloadSizeVal;
58
59 private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
60
61 /**
62 * Open the dialog
63 */
64 public MandatoryPackagesDialog() {
65 setMinimumSize(new Dimension(getWidth() + 100, getHeight() + 100));
66
67 AbstractAction closeAction = new AbstractAction() {
68
69 private static final long serialVersionUID = 1L;
70
71 public void actionPerformed(ActionEvent arg0) {
72 dispose();
73 }
74 };
75 KeyStroke ksCtrlW = KeyStroke
76 .getKeyStroke('W', KeyEvent.CTRL_DOWN_MASK);
77 getRootPane()
78 .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
79 .put(ksCtrlW, "close");
80 getRootPane().getActionMap().put("close", closeAction);
81
82 contents.setDividerLocation(200);
83 contents.setResizeWeight(0.4);
84
85 lstTools.addListSelectionListener(this);
86 lstTools.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
87
88 DefaultListModel dlm = new DefaultListModel();
89 TreeSet<Mod> tools = ModManager.getInstance().getMandatoryTools();
90 for (Mod m : tools)
91 dlm.addElement(m);
92 TreeSet<Mod> mods = ModManager.getInstance().getMandatoryMods();
93 for (Mod m : mods)
94 dlm.addElement(m);
95 lstTools.setModel(dlm);
96
97 setLocationRelativeTo(null);
98 }
99
100 @Override
101 public void valueChanged(ListSelectionEvent evt) {
102 lblTitleVal.setText("");
103 lblCreatorVal.setText("");
104 lblDescriptionVal.setText("");
105 lblTypesVal.setText("");
106 lblPlatformVal.setText("");
107 lblPackageNumberVal.setText("");
108 lblVersionNumberVal.setText("");
109 lblLastChangeVal.setText("");
110 lblDownloadSizeVal.setText("");
111
112 if (lstTools.getSelectedValue() instanceof Mod) {
113 Mod m = (Mod) lstTools.getSelectedValue();
114 lblTitleVal.setText(m.getName());
115 lblCreatorVal.setText(m.getCreator());
116 lblDescriptionVal.setText(m.getDescription());
117
118 String types = "";
119 for (Type t : m.getTypes()) {
120 if (types.length() > 0)
121 types += ", ";
122 types += t.getName();
123 }
124 lblTypesVal.setText(types);
125 lblPlatformVal.setText(m.getPlatform().toString());
126 lblPackageNumberVal.setText(m.getPackageNumberString());
127 lblVersionNumberVal.setText(m.getVersion());
128 if (m.getFile() != null)
129 lblLastChangeVal.setText(sdf.format(new Date(m.getFile()
130 .getTimestamp() * 1000)));
131 lblDownloadSizeVal.setText(SizeFormatter.format(m.getZipSize(), 3));
132 }
133 }
134}
Note: See TracBrowser for help on using the repository browser.