1 package test;
2 import java.awt.BorderLayout;
3 import java.awt.Font;
4 import java.io.File;
5
6 import javax.swing.JComponent;
7 import javax.swing.JLabel;
8 import javax.swing.JList;
9 import javax.swing.JScrollPane;
10 import javax.swing.JSplitPane;
11 import javax.swing.JTabbedPane;
12 import javax.swing.JTextArea;
13
14 import net.sourceforge.jsh3modtool.mod.DefaultGameMod;
15 import net.sourceforge.jsh3modtool.mod.GameMod;
16 import net.sourceforge.jsh3modtool.modpackage.FolderModPackage;
17
18
19
20
21 /***
22 * @author Administratör
23 */
24 public class ModPanel extends JComponent
25 {
26 private GameMod gameMod;
27
28 private JLabel nameLabel;
29 private JTextArea descriptionTextArea;
30
31 private JTabbedPane tabPane;
32
33 private ModScreenshotsPanel screenshotsPanel;
34
35 /***
36 * This is the default constructor
37 */
38 public ModPanel()
39 {
40 super();
41 initialize();
42 }
43
44 /***
45 * This method initializes this
46 * @return void
47 */
48 private void initialize()
49 {
50 setLayout(new BorderLayout());
51
52 add(getNameLabel(), BorderLayout.NORTH);
53 add(getTabPane(), BorderLayout.CENTER);
54 }
55
56 public JLabel getNameLabel()
57 {
58 if (nameLabel == null)
59 {
60 nameLabel = new JLabel();
61 nameLabel.setFont(new Font("Arial", Font.BOLD, 15));
62 updateNameLabel();
63 }
64 return nameLabel;
65 }
66
67 private JTextArea getDescriptionTextArea() {
68 if (descriptionTextArea == null)
69 {
70 descriptionTextArea = new JTextArea();
71 descriptionTextArea.setLineWrap(true);
72 descriptionTextArea.setWrapStyleWord(true);
73 descriptionTextArea.setEditable(false);
74 }
75 return descriptionTextArea;
76 }
77
78 public JTabbedPane getTabPane()
79 {
80 if (tabPane == null)
81 {
82 tabPane = new JTabbedPane();
83 tabPane.add("Description", new JScrollPane( getDescriptionTextArea()));
84 tabPane.add("Screenshots", getScreenShotPanel());
85 tabPane.add("Files", getFileList());
86 }
87 return tabPane;
88 }
89
90 /***
91 * @return
92 */
93 private JComponent getFileList() {
94
95 return new JList();
96 }
97
98 /***
99 * @return
100 */
101 public JComponent getScreenShotPanel() {
102 if (screenshotsPanel == null)
103 {
104 screenshotsPanel = new ModScreenshotsPanel();
105 updateScrenshotsPanel();
106 }
107 return screenshotsPanel;
108 }
109
110 private void updateScrenshotsPanel()
111 {
112 screenshotsPanel.setGameMod(gameMod);
113 }
114
115 private void updateNameLabel()
116 {
117 if (gameMod == null)
118 {
119 nameLabel.setText("");
120 } else
121 {
122 nameLabel.setText("<html><body>" + gameMod.getName() + "</body></html>");
123 }
124 }
125
126 private void updateDescriptionTextArea()
127 {
128 if (gameMod == null)
129 {
130 descriptionTextArea.setText("");
131 } else
132 {
133 descriptionTextArea.setText(gameMod.getDescription());
134 }
135 }
136
137 public void setGameMod(GameMod gamemod)
138 {
139 gameMod = gamemod;
140 updateNameLabel();
141 updateScrenshotsPanel();
142 updateDescriptionTextArea();
143 }
144
145 public GameMod getGameMod()
146 {
147 return gameMod;
148 }
149 }