Browse Source

Remove UI specific preferences methods from UIController.

Fixes CLIENT-274

Change-Id: I58feef90e9a80ef54549b84b6370fe0378e16996
Depends-On: Ic341d8fe573e6e2c0a8da07bd02e41110e7668e9
Reviewed-on: http://gerrit.dmdirc.com/2102
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.6b1
Greg Holmes 13 years ago
parent
commit
61c7913433

+ 25
- 13
src/com/dmdirc/config/prefs/PreferencesDialogModel.java View File

@@ -26,7 +26,6 @@ import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27 27
 import com.dmdirc.plugins.PluginManager;
28 28
 import com.dmdirc.plugins.Service;
29
-import com.dmdirc.ui.interfaces.UIController;
30 29
 import com.dmdirc.util.ListenerList;
31 30
 import com.dmdirc.util.validators.NumericalValidator;
32 31
 import com.dmdirc.util.validators.OptionalValidator;
@@ -42,24 +41,37 @@ import java.util.Map;
42 41
  */
43 42
 public class PreferencesDialogModel {
44 43
 
45
-    /** The UI controller to use for custom categories. */
46
-    private final UIController controller;
47
-
48 44
     /** A list of categories. */
49 45
     private final List<PreferencesCategory> categories
50 46
             = new ArrayList<PreferencesCategory>();
51
-
52 47
     /** A list of listeners. */
53 48
     private final ListenerList listeners = new ListenerList();
49
+    /** UI specific plugin panel. */
50
+    private final PreferencesInterface pluginPanel;
51
+    /** UI specific theme panel. */
52
+    private final PreferencesInterface themePanel;
53
+    /** UI specific updates panel. */
54
+    private final PreferencesInterface updatesPanel;
55
+    /** UI specific URL panel. */
56
+    private final PreferencesInterface urlHandlerPanel;
54 57
 
55 58
     /**
56 59
      * Creates a new instance of PreferencesDialogModel.
57 60
      *
58
-     * @param controller The UI controller to use to retrieve custom UIs for
59
-     * preferences panels.
61
+     * @param pluginPanel UI specific plugin panel
62
+     * @param themePanel UI specific theme panel
63
+     * @param updatesPanel UI specific updates panel
64
+     * @param urlHandlerPanel UI specific URL panel
60 65
      */
61
-    public PreferencesDialogModel(final UIController controller) {
62
-        this.controller = controller;
66
+    public PreferencesDialogModel(final PreferencesInterface pluginPanel,
67
+            final PreferencesInterface themePanel,
68
+            final PreferencesInterface updatesPanel,
69
+            final PreferencesInterface urlHandlerPanel) {
70
+        this.pluginPanel = pluginPanel;
71
+        this.themePanel = themePanel;
72
+        this.updatesPanel = updatesPanel;
73
+        this.urlHandlerPanel = urlHandlerPanel;
74
+
63 75
 
64 76
         addDefaultCategories();
65 77
 
@@ -485,7 +497,7 @@ public class PreferencesDialogModel {
485 497
      */
486 498
     private void addThemesCategory(final PreferencesCategory parent) {
487 499
         parent.addSubCategory(new PreferencesCategory("Themes", "",
488
-                "category-addons", controller.getThemesPrefsPanel()));
500
+                "category-addons", themePanel));
489 501
     }
490 502
 
491 503
     /**
@@ -493,7 +505,7 @@ public class PreferencesDialogModel {
493 505
      */
494 506
     private void addPluginsCategory() {
495 507
         addCategory(new PreferencesCategory("Plugins", "", "category-addons",
496
-                controller.getPluginPrefsPanel()));
508
+                pluginPanel));
497 509
     }
498 510
 
499 511
     /**
@@ -501,7 +513,7 @@ public class PreferencesDialogModel {
501 513
      */
502 514
     private void addUpdatesCategory() {
503 515
         addCategory(new PreferencesCategory("Updates", "", "category-updates",
504
-                controller.getUpdatesPrefsPanel()));
516
+                updatesPanel));
505 517
     }
506 518
 
507 519
     /**
@@ -510,7 +522,7 @@ public class PreferencesDialogModel {
510 522
     private void addUrlHandlerCategory() {
511 523
         addCategory(new PreferencesCategory("URL Handlers",
512 524
                 "Configure how DMDirc handles different types of URLs",
513
-                "category-urlhandlers", controller.getUrlHandlersPrefsPanel()));
525
+                "category-urlhandlers", urlHandlerPanel));
514 526
     }
515 527
 
516 528
     /**

+ 0
- 30
src/com/dmdirc/ui/interfaces/UIController.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.ui.interfaces;
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Server;
28
-import com.dmdirc.config.prefs.PreferencesInterface;
29 28
 
30 29
 import java.net.URI;
31 30
 
@@ -88,33 +87,4 @@ public interface UIController {
88 87
      * @param message Message to display
89 88
      */
90 89
     void showMessageDialog(final String title, final String message);
91
-
92
-    /**
93
-     * Retrieves the object used to display the plugin preferences panel.
94
-     *
95
-     * @return The plugin preferences panel
96
-     */
97
-    PreferencesInterface getPluginPrefsPanel();
98
-
99
-    /**
100
-     * Retrieves the object used to display the updates preferences panel.
101
-     *
102
-     * @return The updates preferences panel
103
-     */
104
-    PreferencesInterface getUpdatesPrefsPanel();
105
-
106
-    /**
107
-     * Retrieves the object used to display the URL handlers preferences panel.
108
-     *
109
-     * @return The url handlers preferences panel
110
-     */
111
-    PreferencesInterface getUrlHandlersPrefsPanel();
112
-
113
-    /**
114
-     * Retrieves the object used to display the themes preferences panel.
115
-     *
116
-     * @return The themes preferences panel
117
-     */
118
-    PreferencesInterface getThemesPrefsPanel();
119
-
120 90
 }

+ 9
- 9
test/com/dmdirc/config/prefs/PreferencesManagerTest.java View File

@@ -48,7 +48,7 @@ public class PreferencesManagerTest {
48 48
 
49 49
     @Test
50 50
     public void testDefaults() {
51
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
51
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
52 52
         assertNotNull(pm.getCategory("General"));
53 53
         assertNotNull(pm.getCategory("Connection"));
54 54
         assertNotNull(pm.getCategory("Messages"));
@@ -62,7 +62,7 @@ public class PreferencesManagerTest {
62 62
     @Test
63 63
     public void testDismiss() {
64 64
         final PreferencesCategory category = mock(PreferencesCategory.class);
65
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
65
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
66 66
         pm.addCategory(category);
67 67
         pm.dismiss();
68 68
 
@@ -74,7 +74,7 @@ public class PreferencesManagerTest {
74 74
         final PreferencesCategory category = mock(PreferencesCategory.class);
75 75
         when(category.save()).thenReturn(false);
76 76
 
77
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
77
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
78 78
         pm.addCategory(category);
79 79
         assertFalse(pm.save());
80 80
 
@@ -86,7 +86,7 @@ public class PreferencesManagerTest {
86 86
         final PreferencesCategory category = mock(PreferencesCategory.class);
87 87
         when(category.save()).thenReturn(true);
88 88
 
89
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
89
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
90 90
         pm.addCategory(category);
91 91
         assertTrue(pm.save());
92 92
 
@@ -95,13 +95,13 @@ public class PreferencesManagerTest {
95 95
 
96 96
     @Test
97 97
     public void testGetCategory() {
98
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
98
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
99 99
         assertNull(pm.getCategory("unittest123"));
100 100
     }
101 101
 
102 102
     @Test
103 103
     public void testGetCategories() {
104
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
104
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
105 105
         assertNotNull(pm.getCategories());
106 106
         assertFalse(pm.getCategories().isEmpty());
107 107
 
@@ -112,7 +112,7 @@ public class PreferencesManagerTest {
112 112
 
113 113
     @Test
114 114
     public void testSaveListener() {
115
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
115
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
116 116
         final PreferencesInterface tpi = mock(PreferencesInterface.class);
117 117
 
118 118
         pm.registerSaveListener(tpi);
@@ -127,7 +127,7 @@ public class PreferencesManagerTest {
127 127
         ActionManager.getActionManager().initialise();
128 128
         ActionManager.getActionManager().registerListener(tal, CoreActionType.CLIENT_PREFS_OPENED);
129 129
 
130
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
130
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
131 131
 
132 132
         verify(tal).processEvent(eq(CoreActionType.CLIENT_PREFS_OPENED),
133 133
                 (StringBuffer) same(null), same(pm));
@@ -140,7 +140,7 @@ public class PreferencesManagerTest {
140 140
         ActionManager.getActionManager().initialise();
141 141
         ActionManager.getActionManager().registerListener(tal, CoreActionType.CLIENT_PREFS_CLOSED);
142 142
 
143
-        final PreferencesDialogModel pm = new PreferencesDialogModel(controller);
143
+        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null, null, null);
144 144
         pm.close();
145 145
 
146 146
         verify(tal).processEvent(eq(CoreActionType.CLIENT_PREFS_CLOSED),

Loading…
Cancel
Save