소스 검색

Update profile list when profiles change

Change-Id: Ife3bb95f8b8fb36837e6f01d108132362828678c
Depends-On: Idbe3fa49249f84cf31b4d42d041da27850e71061
Reviewed-on: http://gerrit.dmdirc.com/2412
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.7rc1
Greg Holmes 12 년 전
부모
커밋
50d5d31bcc
1개의 변경된 파일41개의 추가작업 그리고 1개의 파일을 삭제
  1. 41
    1
      src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java

+ 41
- 1
src/com/dmdirc/addons/ui_swing/dialogs/NewServerDialog.java 파일 보기

@@ -25,6 +25,7 @@ package com.dmdirc.addons.ui_swing.dialogs;
25 25
 import com.dmdirc.Server;
26 26
 import com.dmdirc.ServerManager;
27 27
 import com.dmdirc.addons.ui_swing.SwingController;
28
+import com.dmdirc.addons.ui_swing.UIUtilities;
28 29
 import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
29 30
 import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
30 31
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableChangeEvent;
@@ -32,6 +33,8 @@ import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxModel;
32 33
 import com.dmdirc.addons.ui_swing.components.vetoable.VetoableComboBoxSelectionListener;
33 34
 import com.dmdirc.addons.ui_swing.dialogs.profiles.ProfileManagerDialog;
34 35
 import com.dmdirc.config.Identity;
36
+import com.dmdirc.config.IdentityListener;
37
+import com.dmdirc.config.IdentityManager;
35 38
 import com.dmdirc.logger.ErrorLevel;
36 39
 import com.dmdirc.logger.Logger;
37 40
 import com.dmdirc.util.validators.PortValidator;
@@ -60,10 +63,12 @@ import net.miginfocom.swing.MigLayout;
60 63
  * Dialog that allows the user to enter details of a new server to connect to.
61 64
  */
62 65
 public final class NewServerDialog extends StandardDialog implements
63
-        ActionListener, VetoableComboBoxSelectionListener {
66
+        ActionListener, VetoableComboBoxSelectionListener, IdentityListener {
64 67
 
65 68
     /** Serial version UID. */
66 69
     private static final long serialVersionUID = 8;
70
+    /** Identity Manager. */
71
+    private final IdentityManager identityManager;
67 72
     /** checkbox. */
68 73
     private JCheckBox newServerWindowCheck;
69 74
     /** checkbox. */
@@ -88,12 +93,14 @@ public final class NewServerDialog extends StandardDialog implements
88 93
      */
89 94
     public NewServerDialog(final SwingController controller) {
90 95
         super(controller, controller.getMainFrame(), ModalityType.MODELESS);
96
+        identityManager = controller.getIdentityManager();
91 97
 
92 98
         initComponents();
93 99
         layoutComponents();
94 100
         addListeners();
95 101
         setResizable(false);
96 102
 
103
+        identityManager.registerIdentityListener("profile", this);
97 104
         update();
98 105
     }
99 106
 
@@ -307,4 +314,37 @@ public final class NewServerDialog extends StandardDialog implements
307 314
         }
308 315
         return true;
309 316
     }
317
+
318
+    /** {@inheritDoc} */
319
+    @Override
320
+    public void identityAdded(final Identity identity) {
321
+        UIUtilities.invokeLater(new Runnable() {
322
+
323
+            /** {@inheritDoc} */
324
+            @Override
325
+            public void run() {
326
+                populateProfiles();
327
+            }
328
+        });
329
+    }
330
+
331
+    /** {@inheritDoc} */
332
+    @Override
333
+    public void dispose() {
334
+        identityManager.unregisterIdentityListener(this);
335
+        super.dispose();
336
+    }
337
+
338
+    /** {@inheritDoc} */
339
+    @Override
340
+    public void identityRemoved(final Identity identity) {
341
+        UIUtilities.invokeLater(new Runnable() {
342
+
343
+            /** {@inheritDoc} */
344
+            @Override
345
+            public void run() {
346
+                populateProfiles();
347
+            }
348
+        });
349
+    }
310 350
 }

Loading…
취소
저장