1 | package net.oni2.aeinstaller.gui.packageinfobox;
|
---|
2 |
|
---|
3 | import java.awt.Insets;
|
---|
4 | import java.util.ResourceBundle;
|
---|
5 |
|
---|
6 | import javax.swing.JLabel;
|
---|
7 | import javax.swing.JPanel;
|
---|
8 |
|
---|
9 | import net.oni2.aeinstaller.backend.SizeFormatter;
|
---|
10 | import net.oni2.aeinstaller.backend.packages.Package;
|
---|
11 | import net.oni2.aeinstaller.backend.packages.Type;
|
---|
12 | import net.oni2.aeinstaller.gui.HTMLLinkLabel;
|
---|
13 | import net.oni2.resourcebundle.UTF8ResourceBundleLoader;
|
---|
14 |
|
---|
15 | import org.javabuilders.BuildResult;
|
---|
16 | import org.javabuilders.swing.SwingJavaBuilder;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @author Christian Illy
|
---|
20 | */
|
---|
21 | public class PackageInfoBox extends JPanel {
|
---|
22 | private static final long serialVersionUID = 233098603653577693L;
|
---|
23 |
|
---|
24 | private ResourceBundle bundle = UTF8ResourceBundleLoader
|
---|
25 | .getBundle("net.oni2.aeinstaller.localization."
|
---|
26 | + getClass().getSimpleName());
|
---|
27 | @SuppressWarnings("unused")
|
---|
28 | private BuildResult result = SwingJavaBuilder.build(this, bundle);
|
---|
29 |
|
---|
30 | private JLabel lblTitleVal;
|
---|
31 | private JLabel lblCreatorVal;
|
---|
32 | private JLabel lblTypesVal;
|
---|
33 | private JLabel lblPlatformVal;
|
---|
34 | private JLabel lblPackageNumberVal;
|
---|
35 | private JLabel lblVersionNumberVal;
|
---|
36 | private HTMLLinkLabel lblDescriptionVal;
|
---|
37 | private JLabel lblDownloadSizeVal;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Create a package info box
|
---|
41 | */
|
---|
42 | public PackageInfoBox() {
|
---|
43 | super();
|
---|
44 | lblDescriptionVal.setMargin(new Insets(-15, 0, 0, 0));
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * @param mod
|
---|
49 | * Mod info to show
|
---|
50 | */
|
---|
51 | public void updateInfo(Package mod) {
|
---|
52 | lblTitleVal.setText("");
|
---|
53 | lblCreatorVal.setText("");
|
---|
54 | lblDescriptionVal.setText("");
|
---|
55 | lblTypesVal.setText("");
|
---|
56 | lblPlatformVal.setText("");
|
---|
57 | lblPackageNumberVal.setText("");
|
---|
58 | lblVersionNumberVal.setText("");
|
---|
59 | lblDownloadSizeVal.setText("");
|
---|
60 |
|
---|
61 | if (mod != null) {
|
---|
62 | lblTitleVal.setText("<html>" + mod.getName() + "</html>");
|
---|
63 | lblCreatorVal.setText("<html>" + mod.getCreator() + "</html>");
|
---|
64 | lblDescriptionVal.setText(mod.getDescription());
|
---|
65 |
|
---|
66 | String types = "";
|
---|
67 | for (Type t : mod.getTypes()) {
|
---|
68 | if (types.length() > 0)
|
---|
69 | types += ", ";
|
---|
70 | types += t.getName();
|
---|
71 | }
|
---|
72 | lblTypesVal.setText("<html>" + types + "</html>");
|
---|
73 | lblPlatformVal.setText(mod.getPlatform().toString());
|
---|
74 | lblPackageNumberVal.setText(mod.getPackageNumberString());
|
---|
75 | lblVersionNumberVal.setText(mod.getVersion());
|
---|
76 | lblDownloadSizeVal
|
---|
77 | .setText(SizeFormatter.format(mod.getZipSize(), 3));
|
---|
78 | }
|
---|
79 | }
|
---|
80 | }
|
---|