|
@@ -38,9 +38,11 @@ import java.util.List;
|
38
|
38
|
|
39
|
39
|
import javax.swing.DefaultListModel;
|
40
|
40
|
import javax.swing.JButton;
|
|
41
|
+import javax.swing.JLabel;
|
41
|
42
|
import javax.swing.JList;
|
42
|
43
|
import javax.swing.JPanel;
|
43
|
44
|
import javax.swing.JScrollPane;
|
|
45
|
+import javax.swing.SwingWorker;
|
44
|
46
|
import javax.swing.event.ListSelectionEvent;
|
45
|
47
|
import javax.swing.event.ListSelectionListener;
|
46
|
48
|
|
|
@@ -92,7 +94,7 @@ public final class ThemePanel extends JPanel implements
|
92
|
94
|
themeList = new JList(new DefaultListModel());
|
93
|
95
|
themeList.setCellRenderer(new AddonCellRenderer());
|
94
|
96
|
|
95
|
|
- scrollPane = new JScrollPane(themeList);
|
|
97
|
+ scrollPane = new JScrollPane(new JLabel("Loading plugins..."));
|
96
|
98
|
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
97
|
99
|
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
98
|
100
|
|
|
@@ -101,7 +103,21 @@ public final class ThemePanel extends JPanel implements
|
101
|
103
|
|
102
|
104
|
blurbLabel = new TextLabel("Themes alter the appearance of DMDirc");
|
103
|
105
|
|
104
|
|
- populateList();
|
|
106
|
+ /** {@inheritDoc}. */
|
|
107
|
+ new Thread(new SwingWorker() {
|
|
108
|
+
|
|
109
|
+ /** {@inheritDoc}. */
|
|
110
|
+ @Override
|
|
111
|
+ protected Object doInBackground() {
|
|
112
|
+ return populateList();
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ /** {@inheritDoc}. */
|
|
116
|
+ @Override
|
|
117
|
+ protected void done() {
|
|
118
|
+ scrollPane.setViewportView(themeList);
|
|
119
|
+ }
|
|
120
|
+ }).start();
|
105
|
121
|
}
|
106
|
122
|
|
107
|
123
|
/** Lays out the dialog. */
|
|
@@ -120,8 +136,12 @@ public final class ThemePanel extends JPanel implements
|
120
|
136
|
}
|
121
|
137
|
|
122
|
138
|
|
123
|
|
- /** Populates the plugins list with plugins from the plugin manager. */
|
124
|
|
- private void populateList() {
|
|
139
|
+ /**
|
|
140
|
+ * Populates the plugins list with plugins from the plugin manager.
|
|
141
|
+ *
|
|
142
|
+ * @return Populated list
|
|
143
|
+ */
|
|
144
|
+ private JList populateList() {
|
125
|
145
|
final List<Theme> list = new ArrayList<Theme>(ThemeManager.getAvailableThemes().values());
|
126
|
146
|
Collections.sort(list);
|
127
|
147
|
|
|
@@ -136,6 +156,7 @@ public final class ThemePanel extends JPanel implements
|
136
|
156
|
}
|
137
|
157
|
|
138
|
158
|
themeList.repaint();
|
|
159
|
+ return themeList;
|
139
|
160
|
}
|
140
|
161
|
|
141
|
162
|
/** Adds listeners to components. */
|
|
@@ -146,8 +167,10 @@ public final class ThemePanel extends JPanel implements
|
146
|
167
|
|
147
|
168
|
/**
|
148
|
169
|
* Invoked when an action occurs.
|
|
170
|
+ *
|
149
|
171
|
* @param e The event related to this action.
|
150
|
172
|
*/
|
|
173
|
+ @Override
|
151
|
174
|
public void actionPerformed(final ActionEvent e) {
|
152
|
175
|
if (e.getSource() == toggleButton && selectedTheme >= 0) {
|
153
|
176
|
final ThemeToggle theme = (ThemeToggle) themeList.getSelectedValue();
|
|
@@ -167,6 +190,7 @@ public final class ThemePanel extends JPanel implements
|
167
|
190
|
}
|
168
|
191
|
|
169
|
192
|
/** {@inheritDoc}. */
|
|
193
|
+ @Override
|
170
|
194
|
public void valueChanged(final ListSelectionEvent e) {
|
171
|
195
|
if (!e.getValueIsAdjusting()) {
|
172
|
196
|
final int selected = ((JList) e.getSource()).getSelectedIndex();
|