Bläddra i källkod

Add frame changed events, deprecate listener.

Change-Id: I1d3f667790a1daedd736e46751ee8d7106d316a1
Reviewed-on: http://gerrit.dmdirc.com/3749
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Greg Holmes 9 år sedan
förälder
incheckning
411e2cbcac

+ 12
- 0
src/com/dmdirc/FrameContainer.java Visa fil

@@ -24,6 +24,9 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.commandparser.parsers.CommandParser;
26 26
 import com.dmdirc.events.ClientLineAddedEvent;
27
+import com.dmdirc.events.FrameIconChangedEvent;
28
+import com.dmdirc.events.FrameNameChangedEvent;
29
+import com.dmdirc.events.FrameTitleChangedEvent;
27 30
 import com.dmdirc.interfaces.Connection;
28 31
 import com.dmdirc.interfaces.FrameCloseListener;
29 32
 import com.dmdirc.interfaces.FrameComponentChangeListener;
@@ -310,6 +313,7 @@ public abstract class FrameContainer {
310 313
     protected void setName(final String name) {
311 314
         this.name = name;
312 315
 
316
+        eventBus.post(new FrameNameChangedEvent(this, name));
313 317
         listeners.getCallable(FrameInfoListener.class).nameChanged(this, name);
314 318
     }
315 319
 
@@ -322,6 +326,7 @@ public abstract class FrameContainer {
322 326
     public void setTitle(final String title) {
323 327
         this.title = title;
324 328
 
329
+        eventBus.post(new FrameTitleChangedEvent(this, title));
325 330
         listeners.getCallable(FrameInfoListener.class).titleChanged(this, title);
326 331
     }
327 332
 
@@ -404,6 +409,7 @@ public abstract class FrameContainer {
404 409
      * Called when this container's icon is updated.
405 410
      */
406 411
     private void iconUpdated() {
412
+        eventBus.post(new FrameIconChangedEvent(this, icon));
407 413
         listeners.getCallable(FrameInfoListener.class).iconChanged(this, icon);
408 414
     }
409 415
 
@@ -597,7 +603,10 @@ public abstract class FrameContainer {
597 603
      * Adds a frame info listener to this container.
598 604
      *
599 605
      * @param listener The listener to be informed of frame information changes.
606
+     *
607
+     * @deprecated Use @{link FrameChangedEvent} instead
600 608
      */
609
+    @Deprecated
601 610
     public void addFrameInfoListener(final FrameInfoListener listener) {
602 611
         listeners.add(FrameInfoListener.class, listener);
603 612
     }
@@ -606,7 +615,10 @@ public abstract class FrameContainer {
606 615
      * Removes a frame info listener from this container.
607 616
      *
608 617
      * @param listener The listener to be removed.
618
+     *
619
+     * @deprecated Use @{link FrameChangedEvent} instead
609 620
      */
621
+    @Deprecated
610 622
     public void removeFrameInfoListener(final FrameInfoListener listener) {
611 623
         listeners.remove(FrameInfoListener.class, listener);
612 624
     }

+ 41
- 0
src/com/dmdirc/events/FrameChangedEvent.java Visa fil

@@ -0,0 +1,41 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.FrameContainer;
26
+
27
+/**
28
+ * Base class for all frame info events.
29
+ */
30
+public class FrameChangedEvent extends DMDircEvent {
31
+
32
+    private final FrameContainer container;
33
+
34
+    public FrameChangedEvent(final FrameContainer container) {
35
+        this.container = container;
36
+    }
37
+
38
+    public FrameContainer getContainer() {
39
+        return container;
40
+    }
41
+}

+ 42
- 0
src/com/dmdirc/events/FrameIconChangedEvent.java Visa fil

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.FrameContainer;
26
+
27
+/**
28
+ * Fired when a frame icon changes.
29
+ */
30
+public class FrameIconChangedEvent extends FrameChangedEvent {
31
+
32
+    private final String icon;
33
+
34
+    public FrameIconChangedEvent(final FrameContainer container, final String icon) {
35
+        super(container);
36
+        this.icon = icon;
37
+    }
38
+
39
+    public String getIcon() {
40
+        return icon;
41
+    }
42
+}

+ 42
- 0
src/com/dmdirc/events/FrameNameChangedEvent.java Visa fil

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.FrameContainer;
26
+
27
+/**
28
+ * Fired when a frame's name changes.
29
+ */
30
+public class FrameNameChangedEvent extends FrameChangedEvent {
31
+
32
+    private final String name;
33
+
34
+    public FrameNameChangedEvent(final FrameContainer container, final String name) {
35
+        super(container);
36
+        this.name = name;
37
+    }
38
+
39
+    public String getName() {
40
+        return name;
41
+    }
42
+}

+ 42
- 0
src/com/dmdirc/events/FrameTitleChangedEvent.java Visa fil

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.events;
24
+
25
+import com.dmdirc.FrameContainer;
26
+
27
+/**
28
+ * Fired when a frame title changes.
29
+ */
30
+public class FrameTitleChangedEvent extends FrameChangedEvent {
31
+
32
+    private final String title;
33
+
34
+    public FrameTitleChangedEvent(final FrameContainer container, final String title) {
35
+        super(container);
36
+        this.title = title;
37
+    }
38
+
39
+    public String getTitle() {
40
+        return title;
41
+    }
42
+}

+ 2
- 0
src/com/dmdirc/interfaces/FrameInfoListener.java Visa fil

@@ -31,7 +31,9 @@ import java.util.EventListener;
31 31
  * frame icon or title changes.
32 32
  *
33 33
  * @since 0.6.3m2
34
+ * @deprecated Use @{link com.dmdirc.events.FrameChangedEvent} or its children.
34 35
  */
36
+@Deprecated
35 37
 public interface FrameInfoListener extends EventListener {
36 38
 
37 39
     /**

Laddar…
Avbryt
Spara