|
@@ -26,6 +26,7 @@ import com.dmdirc.actions.ActionManager;
|
26
|
26
|
import com.dmdirc.actions.CoreActionType;
|
27
|
27
|
import com.dmdirc.config.ConfigManager;
|
28
|
28
|
import com.dmdirc.interfaces.ConfigChangeListener;
|
|
29
|
+import com.dmdirc.interfaces.FrameCloseListener;
|
29
|
30
|
import com.dmdirc.interfaces.FrameInfoListener;
|
30
|
31
|
import com.dmdirc.interfaces.NotificationListener;
|
31
|
32
|
import com.dmdirc.interfaces.SelectionListener;
|
|
@@ -89,10 +90,10 @@ public abstract class FrameContainer<T extends Window> {
|
89
|
90
|
|
90
|
91
|
/** The transcoder to use for this container. */
|
91
|
92
|
private final StringTranscoder transcoder;
|
92
|
|
-
|
|
93
|
+
|
93
|
94
|
/** The config manager for this container. */
|
94
|
95
|
private final ConfigManager config;
|
95
|
|
-
|
|
96
|
+
|
96
|
97
|
/** The IconChanger for this container. */
|
97
|
98
|
private final IconChanger changer = new IconChanger();
|
98
|
99
|
|
|
@@ -101,7 +102,7 @@ public abstract class FrameContainer<T extends Window> {
|
101
|
102
|
|
102
|
103
|
/**
|
103
|
104
|
* Instantiate new frame container.
|
104
|
|
- *
|
|
105
|
+ *
|
105
|
106
|
* @param icon The icon to use for this container
|
106
|
107
|
* @param name The name of this container
|
107
|
108
|
* @param title The title of this container
|
|
@@ -129,7 +130,7 @@ public abstract class FrameContainer<T extends Window> {
|
129
|
130
|
tempTranscoder = new StringTranscoder(Charset.forName("UTF-8"));
|
130
|
131
|
}
|
131
|
132
|
transcoder = tempTranscoder;
|
132
|
|
-
|
|
133
|
+
|
133
|
134
|
setIcon(icon);
|
134
|
135
|
}
|
135
|
136
|
|
|
@@ -317,18 +318,18 @@ public abstract class FrameContainer<T extends Window> {
|
317
|
318
|
|
318
|
319
|
/**
|
319
|
320
|
* Sets the icon to be used by this frame container.
|
320
|
|
- *
|
|
321
|
+ *
|
321
|
322
|
* @param icon The new icon to be used
|
322
|
323
|
*/
|
323
|
324
|
public final void setIcon(final String icon) {
|
324
|
325
|
this.icon = icon;
|
325
|
|
-
|
|
326
|
+
|
326
|
327
|
iconUpdated();
|
327
|
|
-
|
|
328
|
+
|
328
|
329
|
config.removeListener(changer);
|
329
|
330
|
config.addChangeListener("icon", icon, changer);
|
330
|
331
|
}
|
331
|
|
-
|
|
332
|
+
|
332
|
333
|
/**
|
333
|
334
|
* Called when this container's icon is updated.
|
334
|
335
|
*/
|
|
@@ -454,6 +455,12 @@ public abstract class FrameContainer<T extends Window> {
|
454
|
455
|
* {@link WindowManager#removeWindow(com.dmdirc.ui.interfaces.Window)}</li>
|
455
|
456
|
* </ol>
|
456
|
457
|
* <p>
|
|
458
|
+ * <strong>NB:</strong> As of DMDirc 0.6.5, points 1 and 6 (making windows
|
|
459
|
+ * non-visible and removing the window from the window manager) are handled
|
|
460
|
+ * by the caller of this method, and should <strong>not</strong> be
|
|
461
|
+ * implemented by subclasses.
|
|
462
|
+ * </p>
|
|
463
|
+ * <p>
|
457
|
464
|
* While resources may be relinquished in step three, references MUST NOT
|
458
|
465
|
* be removed yet. That is, if a window holds a resource, the resource may
|
459
|
466
|
* be closed, but the relevant object MUST still be available for
|
|
@@ -464,7 +471,21 @@ public abstract class FrameContainer<T extends Window> {
|
464
|
471
|
* on its frame, parser, etc. The resources should be completely freed in
|
465
|
472
|
* the {@link #windowClosed()} method.
|
466
|
473
|
*/
|
467
|
|
- public abstract void windowClosing();
|
|
474
|
+ protected abstract void windowClosing();
|
|
475
|
+
|
|
476
|
+ /**
|
|
477
|
+ * Handles the closing of this container. This should be called by UI
|
|
478
|
+ * components when the user is attempting to close a corresponding window.
|
|
479
|
+ */
|
|
480
|
+ public void handleWindowClosing() {
|
|
481
|
+ for (FrameCloseListener listener : listeners.get(FrameCloseListener.class)) {
|
|
482
|
+ listener.windowClosing(this);
|
|
483
|
+ }
|
|
484
|
+
|
|
485
|
+ windowClosing();
|
|
486
|
+
|
|
487
|
+ WindowManager.removeWindow(this);
|
|
488
|
+ }
|
468
|
489
|
|
469
|
490
|
/**
|
470
|
491
|
* Invoked when our window has been closed.
|
|
@@ -614,6 +635,26 @@ public abstract class FrameContainer<T extends Window> {
|
614
|
635
|
listeners.remove(NotificationListener.class, listener);
|
615
|
636
|
}
|
616
|
637
|
|
|
638
|
+ /**
|
|
639
|
+ * Adds a close listener for this frame container.
|
|
640
|
+ *
|
|
641
|
+ * @since 0.6.5
|
|
642
|
+ * @param listener The listener to be added
|
|
643
|
+ */
|
|
644
|
+ public void addCloseListener(final FrameCloseListener listener) {
|
|
645
|
+ listeners.add(FrameCloseListener.class, listener);
|
|
646
|
+ }
|
|
647
|
+
|
|
648
|
+ /**
|
|
649
|
+ * Removes a close listener from this frame container.
|
|
650
|
+ *
|
|
651
|
+ * @since 0.6.5
|
|
652
|
+ * @param listener The listener to be removed
|
|
653
|
+ */
|
|
654
|
+ public void removeCloseListener(final FrameCloseListener listener) {
|
|
655
|
+ listeners.remove(FrameCloseListener.class, listener);
|
|
656
|
+ }
|
|
657
|
+
|
617
|
658
|
/**
|
618
|
659
|
* Adds a selection listener for this frame container.
|
619
|
660
|
*
|
|
@@ -701,6 +742,6 @@ public abstract class FrameContainer<T extends Window> {
|
701
|
742
|
public void configChanged(final String domain, final String key) {
|
702
|
743
|
iconUpdated();
|
703
|
744
|
}
|
704
|
|
-
|
|
745
|
+
|
705
|
746
|
}
|
706
|
747
|
}
|