Explorar el Código

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 hace 10 años
padre
commit
e09305301b

+ 9
- 2
src/com/dmdirc/addons/ui_swing/MainFrame.java Ver fichero

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

+ 9
- 2
src/com/dmdirc/addons/ui_swing/SwingController.java Ver fichero

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

Loading…
Cancelar
Guardar