|
@@ -34,11 +34,16 @@ import com.dmdirc.themes.ThemeManager;
|
34
|
34
|
import com.dmdirc.ui.interfaces.PreferencesInterface;
|
35
|
35
|
import com.dmdirc.ui.swing.MainFrame;
|
36
|
36
|
import com.dmdirc.ui.swing.components.SwingPreferencesPanel;
|
|
37
|
+import java.awt.Component;
|
|
38
|
+import java.util.AbstractMap.SimpleImmutableEntry;
|
37
|
39
|
|
38
|
40
|
import java.util.HashMap;
|
39
|
41
|
import java.util.Map;
|
40
|
42
|
import java.util.Map.Entry;
|
41
|
43
|
import java.util.Properties;
|
|
44
|
+import javax.swing.DefaultComboBoxModel;
|
|
45
|
+import javax.swing.DefaultListCellRenderer;
|
|
46
|
+import javax.swing.JList;
|
42
|
47
|
import javax.swing.JOptionPane;
|
43
|
48
|
|
44
|
49
|
import javax.swing.UIManager;
|
|
@@ -222,37 +227,53 @@ public final class PreferencesDialog implements PreferencesInterface, ConfigChan
|
222
|
227
|
private void initNotificationsTab() {
|
223
|
228
|
final String tabName = "Notifications";
|
224
|
229
|
preferencesPanel.addCategory("Messages", tabName, "");
|
225
|
|
- final String[] windowOptions
|
226
|
|
- = new String[] {"all", "active", "server", };
|
|
230
|
+ final DefaultComboBoxModel windowOptions = new DefaultComboBoxModel(
|
|
231
|
+ new Entry[] {
|
|
232
|
+ new SimpleImmutableEntry<String, String>("All", "all"),
|
|
233
|
+ new SimpleImmutableEntry<String, String>("Active", "active"),
|
|
234
|
+ new SimpleImmutableEntry<String, String>("Server", "server"),
|
|
235
|
+ new SimpleImmutableEntry<String, String>("None", "none "), });
|
|
236
|
+ final DefaultComboBoxModel windowOptions2 = new DefaultComboBoxModel(
|
|
237
|
+ new Entry[] {
|
|
238
|
+ new SimpleImmutableEntry<String, String>("All", "all"),
|
|
239
|
+ new SimpleImmutableEntry<String, String>("Active", "active"),
|
|
240
|
+ new SimpleImmutableEntry<String, String>("Server", "server"),
|
|
241
|
+ new SimpleImmutableEntry<String, String>("Source of command",
|
|
242
|
+ "lastcommand:whois %4$s( %4$s)"),
|
|
243
|
+ new SimpleImmutableEntry<String, String>("None", "none "), });
|
227
|
244
|
|
228
|
245
|
preferencesPanel.addComboboxOption(tabName, "notifications.socketClosed",
|
229
|
246
|
"Socket closed: ", "Where to display socket closed notifications",
|
230
|
|
- windowOptions,
|
|
247
|
+ windowOptions, new MapEntryRenderer(),
|
231
|
248
|
config.getOption("notifications", "socketClosed"), false);
|
232
|
249
|
preferencesPanel.addComboboxOption(tabName, "notifications.privateNotice",
|
233
|
250
|
"Private notice: ", "Where to display private notice notifications",
|
234
|
|
- windowOptions,
|
|
251
|
+ windowOptions, new MapEntryRenderer(),
|
235
|
252
|
config.getOption("notifications", "privateNotice"), false);
|
236
|
253
|
preferencesPanel.addComboboxOption(tabName, "notifications.privateCTCP",
|
237
|
254
|
"CTCP request: ", "Where to display CTCP request notifications",
|
238
|
|
- windowOptions,
|
|
255
|
+ windowOptions, new MapEntryRenderer(),
|
239
|
256
|
config.getOption("notifications", "privateCTCP"), false);
|
240
|
257
|
preferencesPanel.addComboboxOption(tabName, "notifications.privateCTCPreply",
|
241
|
258
|
"CTCP reply: ", "Where to display CTCP reply notifications",
|
242
|
|
- windowOptions,
|
|
259
|
+ windowOptions, new MapEntryRenderer(),
|
243
|
260
|
config.getOption("notifications", "privateCTCPreply"), false);
|
244
|
261
|
preferencesPanel.addComboboxOption(tabName, "notifications.connectError",
|
245
|
262
|
"Connect error: ", "Where to display connect error notifications",
|
246
|
|
- windowOptions,
|
|
263
|
+ windowOptions, new MapEntryRenderer(),
|
247
|
264
|
config.getOption("notifications", "connectError"), false);
|
248
|
265
|
preferencesPanel.addComboboxOption(tabName, "notifications.connectRetry",
|
249
|
266
|
"Connect retry: ", "Where to display connect retry notifications",
|
250
|
|
- windowOptions,
|
|
267
|
+ windowOptions, new MapEntryRenderer(),
|
251
|
268
|
config.getOption("notifications", "connectRetry"), false);
|
252
|
269
|
preferencesPanel.addComboboxOption(tabName, "notifications.stonedServer",
|
253
|
|
- "Stoned server: ", "Where to display stone server notifications",
|
254
|
|
- windowOptions,
|
|
270
|
+ "Stoned server: ", "Where to display stoned server notifications",
|
|
271
|
+ windowOptions, new MapEntryRenderer(),
|
255
|
272
|
config.getOption("notifications", "stonedServer"), false);
|
|
273
|
+ preferencesPanel.addComboboxOption(tabName, "notifications.whois",
|
|
274
|
+ "Whois output: ", "Where to display whois command output",
|
|
275
|
+ windowOptions2, new MapEntryRenderer(),
|
|
276
|
+ config.getOption("notifications", "whois"), false);
|
256
|
277
|
}
|
257
|
278
|
|
258
|
279
|
/**
|
|
@@ -459,6 +480,7 @@ public final class PreferencesDialog implements PreferencesInterface, ConfigChan
|
459
|
480
|
}
|
460
|
481
|
|
461
|
482
|
/** {@inheritDoc}. */
|
|
483
|
+ @Override
|
462
|
484
|
public void configClosed(final Properties properties) {
|
463
|
485
|
final Identity identity = IdentityManager.getConfigIdentity();
|
464
|
486
|
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
|
@@ -495,11 +517,13 @@ public final class PreferencesDialog implements PreferencesInterface, ConfigChan
|
495
|
517
|
|
496
|
518
|
|
497
|
519
|
/** {@inheritDoc} */
|
|
520
|
+ @Override
|
498
|
521
|
public void configCancelled() {
|
499
|
522
|
dispose();
|
500
|
523
|
}
|
501
|
524
|
|
502
|
525
|
/** {@inheritDoc} */
|
|
526
|
+ @Override
|
503
|
527
|
public void configChanged(final String domain, final String key) {
|
504
|
528
|
if ("ui".equals(domain) && ("lookandfeel".equals(key)
|
505
|
529
|
|| "framemanager".equals(key) || "framemanagerPosition".equals(key))
|
|
@@ -521,4 +545,34 @@ public final class PreferencesDialog implements PreferencesInterface, ConfigChan
|
521
|
545
|
me = null;
|
522
|
546
|
}
|
523
|
547
|
}
|
|
548
|
+
|
|
549
|
+ private class MapEntryRenderer extends DefaultListCellRenderer {
|
|
550
|
+
|
|
551
|
+ /**
|
|
552
|
+ * A version number for this class. It should be changed whenever the class
|
|
553
|
+ * structure is changed (or anything else that would prevent serialized
|
|
554
|
+ * objects being unserialized with the new class).
|
|
555
|
+ */
|
|
556
|
+ private static final long serialVersionUID = 1;
|
|
557
|
+
|
|
558
|
+ /** {@inheritDoc} */
|
|
559
|
+ @Override
|
|
560
|
+ public Component getListCellRendererComponent(final JList list,
|
|
561
|
+ final Object value, final int index, final boolean isSelected,
|
|
562
|
+ final boolean hasFocus) {
|
|
563
|
+
|
|
564
|
+ super.getListCellRendererComponent(list, value, index, isSelected, hasFocus);
|
|
565
|
+
|
|
566
|
+ if (value == null) {
|
|
567
|
+ setText("Any");
|
|
568
|
+ } else if (value instanceof Entry) {
|
|
569
|
+ setText((String) ((Entry) value).getKey());
|
|
570
|
+ } else {
|
|
571
|
+ setText(value.toString());
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ return this;
|
|
575
|
+ }
|
|
576
|
+
|
|
577
|
+ }
|
524
|
578
|
}
|