|
@@ -23,11 +23,14 @@
|
23
|
23
|
package com.dmdirc.addons.ui_swing;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.DMDircMBassador;
|
|
26
|
+import com.dmdirc.addons.ui_swing.components.IconManager;
|
26
|
27
|
import com.dmdirc.addons.ui_swing.components.SplitPane;
|
27
|
28
|
import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
|
28
|
29
|
import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
|
29
|
30
|
import com.dmdirc.addons.ui_swing.components.statusbar.SwingStatusBar;
|
30
|
31
|
import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
|
|
32
|
+import com.dmdirc.addons.ui_swing.events.ClientMinimisedEvent;
|
|
33
|
+import com.dmdirc.addons.ui_swing.events.ClientUnminimisedEvent;
|
31
|
34
|
import com.dmdirc.addons.ui_swing.events.SwingActiveWindowChangeRequestEvent;
|
32
|
35
|
import com.dmdirc.addons.ui_swing.events.SwingEventBus;
|
33
|
36
|
import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
|
|
@@ -36,8 +39,6 @@ import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
|
36
|
39
|
import com.dmdirc.addons.ui_swing.framemanager.FrameManager;
|
37
|
40
|
import com.dmdirc.addons.ui_swing.framemanager.FramemanagerPosition;
|
38
|
41
|
import com.dmdirc.addons.ui_swing.framemanager.ctrltab.CtrlTabWindowManager;
|
39
|
|
-import com.dmdirc.addons.ui_swing.events.ClientMinimisedEvent;
|
40
|
|
-import com.dmdirc.addons.ui_swing.events.ClientUnminimisedEvent;
|
41
|
42
|
import com.dmdirc.events.FrameTitleChangedEvent;
|
42
|
43
|
import com.dmdirc.events.UnreadStatusChangedEvent;
|
43
|
44
|
import com.dmdirc.interfaces.LifecycleController;
|
|
@@ -45,7 +46,6 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
45
|
46
|
import com.dmdirc.interfaces.config.ConfigChangeListener;
|
46
|
47
|
import com.dmdirc.interfaces.ui.Window;
|
47
|
48
|
import com.dmdirc.ui.CoreUIUtils;
|
48
|
|
-import com.dmdirc.addons.ui_swing.components.IconManager;
|
49
|
49
|
import com.dmdirc.util.collections.QueuedLinkedHashSet;
|
50
|
50
|
|
51
|
51
|
import java.awt.Dialog;
|
|
@@ -160,6 +160,7 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
160
|
160
|
|
161
|
161
|
@Override
|
162
|
162
|
public void setVisible(final boolean visible) {
|
|
163
|
+ checkOnEDT();
|
163
|
164
|
if (!initDone) {
|
164
|
165
|
swingEventBus.subscribe(this);
|
165
|
166
|
imageIcon = new ImageIcon(iconManager.getImage("icon"));
|
|
@@ -203,13 +204,12 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
203
|
204
|
|
204
|
205
|
@Override
|
205
|
206
|
public void setTitle(final String title) {
|
206
|
|
- UIUtilities.invokeLater(() -> {
|
207
|
|
- if (title == null || !activeFrame.isPresent()) {
|
208
|
|
- MainFrame.super.setTitle(getTitlePrefix());
|
209
|
|
- } else {
|
210
|
|
- MainFrame.super.setTitle(getTitlePrefix() + " - " + title);
|
211
|
|
- }
|
212
|
|
- });
|
|
207
|
+ checkOnEDT();
|
|
208
|
+ if (title == null || !activeFrame.isPresent()) {
|
|
209
|
+ MainFrame.super.setTitle(getTitlePrefix());
|
|
210
|
+ } else {
|
|
211
|
+ MainFrame.super.setTitle(getTitlePrefix() + " - " + title);
|
|
212
|
+ }
|
213
|
213
|
}
|
214
|
214
|
|
215
|
215
|
/**
|
|
@@ -258,38 +258,36 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
258
|
258
|
|
259
|
259
|
/** Initialiases the frame managers. */
|
260
|
260
|
private void initFrameManagers() {
|
261
|
|
- UIUtilities.invokeAndWait(() -> {
|
262
|
|
- frameManagerPanel.removeAll();
|
263
|
|
- if (mainFrameManager != null) {
|
264
|
|
- swingEventBus.unsubscribe(mainFrameManager);
|
265
|
|
- }
|
266
|
|
- mainFrameManager = frameManagerProvider.get();
|
267
|
|
- mainFrameManager.setParent(frameManagerPanel);
|
268
|
|
- swingEventBus.subscribe(mainFrameManager);
|
269
|
|
- });
|
|
261
|
+ checkOnEDT();
|
|
262
|
+ frameManagerPanel.removeAll();
|
|
263
|
+ if (mainFrameManager != null) {
|
|
264
|
+ swingEventBus.unsubscribe(mainFrameManager);
|
|
265
|
+ }
|
|
266
|
+ mainFrameManager = frameManagerProvider.get();
|
|
267
|
+ mainFrameManager.setParent(frameManagerPanel);
|
|
268
|
+ swingEventBus.subscribe(mainFrameManager);
|
270
|
269
|
}
|
271
|
270
|
|
272
|
271
|
/**
|
273
|
272
|
* Initialises the components for this frame.
|
274
|
273
|
*/
|
275
|
274
|
public void initComponents() {
|
276
|
|
- UIUtilities.invokeAndWait(() -> {
|
277
|
|
- frameManagerPanel = new JPanel();
|
278
|
|
- activeFrame = Optional.empty();
|
279
|
|
- framePanel = new JPanel(new MigLayout("fill, ins 0"));
|
280
|
|
- initFrameManagers();
|
281
|
|
- mainSplitPane = initSplitPane();
|
|
275
|
+ checkOnEDT();
|
|
276
|
+ frameManagerPanel = new JPanel();
|
|
277
|
+ activeFrame = Optional.empty();
|
|
278
|
+ framePanel = new JPanel(new MigLayout("fill, ins 0"));
|
|
279
|
+ initFrameManagers();
|
|
280
|
+ mainSplitPane = initSplitPane();
|
282
|
281
|
|
283
|
|
- setPreferredSize(new Dimension(800, 600));
|
|
282
|
+ setPreferredSize(new Dimension(800, 600));
|
284
|
283
|
|
285
|
|
- getContentPane().setLayout(new MigLayout(
|
286
|
|
- "fill, ins rel, wrap 1, hidemode 2"));
|
287
|
|
- layoutComponents();
|
|
284
|
+ getContentPane().setLayout(new MigLayout(
|
|
285
|
+ "fill, ins rel, wrap 1, hidemode 2"));
|
|
286
|
+ layoutComponents();
|
288
|
287
|
|
289
|
|
- setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
|
288
|
+ setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
290
|
289
|
|
291
|
|
- pack();
|
292
|
|
- });
|
|
290
|
+ pack();
|
293
|
291
|
}
|
294
|
292
|
|
295
|
293
|
/**
|
|
@@ -301,10 +299,9 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
301
|
299
|
* @param menuBar The menu bar to use.
|
302
|
300
|
*/
|
303
|
301
|
public void setMenuBar(final MenuBar menuBar) {
|
304
|
|
- UIUtilities.invokeAndWait(() -> {
|
305
|
|
- apple.setMenuBar(menuBar);
|
306
|
|
- setJMenuBar(menuBar);
|
307
|
|
- });
|
|
302
|
+ checkOnEDT();
|
|
303
|
+ apple.setMenuBar(menuBar);
|
|
304
|
+ setJMenuBar(menuBar);
|
308
|
305
|
}
|
309
|
306
|
|
310
|
307
|
/**
|
|
@@ -466,6 +463,7 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
466
|
463
|
|
467
|
464
|
@Handler(invocation = EdtHandlerInvocation.class)
|
468
|
465
|
public void setActiveFrame(final SwingActiveWindowChangeRequestEvent event) {
|
|
466
|
+ checkOnEDT();
|
469
|
467
|
focusOrder.offerAndMove(activeFrame);
|
470
|
468
|
framePanel.setVisible(false);
|
471
|
469
|
framePanel.removeAll();
|
|
@@ -493,16 +491,18 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
493
|
491
|
swingEventBus.publish(new SwingWindowSelectedEvent(activeFrame));
|
494
|
492
|
}
|
495
|
493
|
|
496
|
|
- @Handler
|
|
494
|
+ @Handler(invocation = EdtHandlerInvocation.class)
|
497
|
495
|
public void doWindowAdded(final SwingWindowAddedEvent event) {
|
|
496
|
+ checkOnEDT();
|
498
|
497
|
if (!activeFrame.isPresent()) {
|
499
|
498
|
setActiveFrame(new SwingActiveWindowChangeRequestEvent(
|
500
|
499
|
Optional.of(event.getChildWindow())));
|
501
|
500
|
}
|
502
|
501
|
}
|
503
|
502
|
|
504
|
|
- @Handler
|
|
503
|
+ @Handler(invocation = EdtHandlerInvocation.class)
|
505
|
504
|
public void doWindowDeleted(final SwingWindowDeletedEvent event) {
|
|
505
|
+ checkOnEDT();
|
506
|
506
|
final Optional<TextFrame> window = Optional.of(event.getChildWindow());
|
507
|
507
|
focusOrder.remove(window);
|
508
|
508
|
if (activeFrame.equals(window)) {
|
|
@@ -518,15 +518,17 @@ public class MainFrame extends JFrame implements WindowListener, ConfigChangeLis
|
518
|
518
|
}
|
519
|
519
|
}
|
520
|
520
|
|
521
|
|
- @Handler
|
|
521
|
+ @Handler(invocation = EdtHandlerInvocation.class)
|
522
|
522
|
public void titleChanged(final FrameTitleChangedEvent event) {
|
|
523
|
+ checkOnEDT();
|
523
|
524
|
activeFrame.map(Window::getContainer)
|
524
|
525
|
.filter(isEqual(event.getContainer()))
|
525
|
526
|
.ifPresent(c -> setTitle(event.getTitle()));
|
526
|
527
|
}
|
527
|
528
|
|
528
|
|
- @Handler
|
|
529
|
+ @Handler(invocation = EdtHandlerInvocation.class)
|
529
|
530
|
public void unreadStatusChanged(final UnreadStatusChangedEvent event) {
|
|
531
|
+ checkOnEDT();
|
530
|
532
|
activeFrame.map(Window::getContainer)
|
531
|
533
|
.filter(isEqual(event.getSource()))
|
532
|
534
|
.ifPresent(c -> event.getManager().clearStatus());
|