Browse Source

Use a LifeCycleController to quit.

Change-Id: I2d8bd7b8ab9e4f187e2a89ee43565cdad59502ce
Depends-On: Id6d237f386c6f35844136ceb64b7c46f0af76765
Reviewed-on: http://gerrit.dmdirc.com/2716
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 years ago
parent
commit
e09305301b

+ 9
- 2
src/com/dmdirc/addons/ui_swing/MainFrame.java View File

@@ -38,6 +38,7 @@ import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
38 38
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeFrameManager;
39 39
 import com.dmdirc.interfaces.ConfigChangeListener;
40 40
 import com.dmdirc.interfaces.FrameInfoListener;
41
+import com.dmdirc.interfaces.LifecycleController;
41 42
 import com.dmdirc.interfaces.NotificationListener;
42 43
 import com.dmdirc.logger.ErrorLevel;
43 44
 import com.dmdirc.logger.Logger;
@@ -88,6 +89,8 @@ public final class MainFrame extends JFrame implements WindowListener,
88 89
     private final QueuedLinkedHashSet<TextFrame> focusOrder;
89 90
     /** Swing Controller. */
90 91
     private final SwingController controller;
92
+    /** Controller to use to end the program. */
93
+    private final LifecycleController lifecycleController;
91 94
     /** Client Version. */
92 95
     private final String version;
93 96
     /** Frame manager used for ctrl tab frame switching. */
@@ -122,11 +125,15 @@ public final class MainFrame extends JFrame implements WindowListener,
122 125
      * Creates new form MainFrame.
123 126
      *
124 127
      * @param controller Swing controller
128
+     * @param lifecycleController Controller to use to end the application.
125 129
      */
126
-    public MainFrame(final SwingController controller) {
130
+    public MainFrame(
131
+            final SwingController controller,
132
+            final LifecycleController lifecycleController) {
127 133
         super();
128 134
 
129 135
         this.controller = controller;
136
+        this.lifecycleController = lifecycleController;
130 137
 
131 138
         focusOrder = new QueuedLinkedHashSet<>();
132 139
         initComponents();
@@ -272,7 +279,7 @@ public final class MainFrame extends JFrame implements WindowListener,
272 279
             /** {@inheritDoc} */
273 280
             @Override
274 281
             public void run() {
275
-                controller.getMain().quit(exitCode);
282
+                lifecycleController.quit(exitCode);
276 283
             }
277 284
         }, "Quit thread").start();
278 285
     }

+ 9
- 2
src/com/dmdirc/addons/ui_swing/SwingController.java View File

@@ -56,6 +56,7 @@ import com.dmdirc.config.prefs.PreferencesDialogModel;
56 56
 import com.dmdirc.config.prefs.PreferencesSetting;
57 57
 import com.dmdirc.config.prefs.PreferencesType;
58 58
 import com.dmdirc.interfaces.CommandController;
59
+import com.dmdirc.interfaces.LifecycleController;
59 60
 import com.dmdirc.interfaces.ui.UIController;
60 61
 import com.dmdirc.interfaces.ui.Window;
61 62
 import com.dmdirc.logger.ErrorLevel;
@@ -159,6 +160,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
159 160
     /** Plugin manager. */
160 161
     @Getter
161 162
     private final PluginManager pluginManager;
163
+    /** Controller to use to close the application. */
164
+    private final LifecycleController lifecycleController;
162 165
     /** Apple handler, deals with Mac specific code. */
163 166
     @Getter
164 167
     private final Apple apple;
@@ -173,6 +176,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
173 176
      * @param actionManager Action manager
174 177
      * @param commandController Command controller to register commands
175 178
      * @param serverManager Server manager to use for server information.
179
+     * @param lifecycleController Controller to use to close the application.
176 180
      */
177 181
     public SwingController(
178 182
             final PluginInfo pluginInfo,
@@ -181,7 +185,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
181 185
             final Main main,
182 186
             final ActionManager actionManager,
183 187
             final CommandController commandController,
184
-            final ServerManager serverManager) {
188
+            final ServerManager serverManager,
189
+            final LifecycleController lifecycleController) {
185 190
         super(commandController);
186 191
         this.main = main;
187 192
         this.pluginInfo = pluginInfo;
@@ -189,6 +194,8 @@ public class SwingController extends BaseCommandPlugin implements UIController {
189 194
         this.actionManager = actionManager;
190 195
         this.pluginManager = pluginManager;
191 196
         this.serverManager = serverManager;
197
+        this.lifecycleController = lifecycleController;
198
+
192 199
         globalConfig = identityManager.getGlobalConfiguration();
193 200
         globalIdentity = identityManager.getGlobalConfigIdentity();
194 201
         addonIdentity = identityManager.getGlobalAddonIdentity();
@@ -487,7 +494,7 @@ public class SwingController extends BaseCommandPlugin implements UIController {
487 494
             @Override
488 495
             public void run() {
489 496
                 initUISettings();
490
-                mainFrame = new MainFrame(SwingController.this);
497
+                mainFrame = new MainFrame(SwingController.this, lifecycleController);
491 498
                 getMainFrame().setVisible(true);
492 499
                 mainFrameCreated.set(true);
493 500
                 swingStatusBar = getMainFrame().getStatusBar();

Loading…
Cancel
Save