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