瀏覽代碼

Add events for various frame events.

Change-Id: I0fed39b3e4a199a4b87d3b2e182d1c674ac4c072
Reviewed-on: http://gerrit.dmdirc.com/3755
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Greg Holmes 9 年之前
父節點
當前提交
ba81ca3604

+ 16
- 0
src/com/dmdirc/FrameContainer.java 查看文件

@@ -24,9 +24,14 @@ 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.FrameClosingEvent;
28
+import com.dmdirc.events.FrameComponentAddedEvent;
29
+import com.dmdirc.events.FrameComponentRemovedEvent;
27 30
 import com.dmdirc.events.FrameIconChangedEvent;
28 31
 import com.dmdirc.events.FrameNameChangedEvent;
29 32
 import com.dmdirc.events.FrameTitleChangedEvent;
33
+import com.dmdirc.events.NotificationClearedEvent;
34
+import com.dmdirc.events.NotificationSetEvent;
30 35
 import com.dmdirc.interfaces.Connection;
31 36
 import com.dmdirc.interfaces.FrameCloseListener;
32 37
 import com.dmdirc.interfaces.FrameComponentChangeListener;
@@ -351,6 +356,7 @@ public abstract class FrameContainer {
351 356
     public void addComponent(final String component) {
352 357
         components.add(component);
353 358
 
359
+        eventBus.publishAsync(new FrameComponentAddedEvent(this, component));
354 360
         for (FrameComponentChangeListener listener
355 361
                 : listeners.get(FrameComponentChangeListener.class)) {
356 362
             listener.componentAdded(this, component);
@@ -366,6 +372,7 @@ public abstract class FrameContainer {
366 372
     public void removeComponent(final String component) {
367 373
         components.remove(component);
368 374
 
375
+        eventBus.publishAsync(new FrameComponentRemovedEvent(this, component));
369 376
         for (FrameComponentChangeListener listener
370 377
                 : listeners.get(FrameComponentChangeListener.class)) {
371 378
             listener.componentRemoved(this, component);
@@ -378,6 +385,7 @@ public abstract class FrameContainer {
378 385
     public void close() {
379 386
         eventBusManager.disconnect();
380 387
 
388
+        eventBus.publishAsync(new FrameClosingEvent(this));
381 389
         for (FrameCloseListener listener : listeners.get(FrameCloseListener.class)) {
382 390
             listener.windowClosing(this);
383 391
             listeners.remove(FrameCloseListener.class, listener);
@@ -433,6 +441,7 @@ public abstract class FrameContainer {
433 441
      */
434 442
     public void clearNotification() {
435 443
         notification = Optional.absent();
444
+        eventBus.publishAsync(new NotificationClearedEvent(this));
436 445
         listeners.getCallable(NotificationListener.class).notificationCleared(this);
437 446
     }
438 447
 
@@ -444,6 +453,7 @@ public abstract class FrameContainer {
444 453
     public void sendNotification(final Colour colour) {
445 454
         if (!notification.isPresent() || !colour.equals(notification.get())) {
446 455
             notification = Optional.of(colour);
456
+            eventBus.publishAsync(new NotificationSetEvent(this, colour));
447 457
             listeners.getCallable(NotificationListener.class).notificationSet(this, colour);
448 458
         }
449 459
     }
@@ -548,6 +558,7 @@ public abstract class FrameContainer {
548 558
      *
549 559
      * @param listener The listener to be added
550 560
      */
561
+    @Deprecated
551 562
     public void addCloseListener(final FrameCloseListener listener) {
552 563
         listeners.add(FrameCloseListener.class, listener);
553 564
     }
@@ -558,6 +569,7 @@ public abstract class FrameContainer {
558 569
      * @since 0.6.5
559 570
      * @param listener The listener to be removed
560 571
      */
572
+    @Deprecated
561 573
     public void removeCloseListener(final FrameCloseListener listener) {
562 574
         listeners.remove(FrameCloseListener.class, listener);
563 575
     }
@@ -568,6 +580,7 @@ public abstract class FrameContainer {
568 580
      * @since 0.6.6
569 581
      * @param listener The listener to be added
570 582
      */
583
+    @Deprecated
571 584
     public void addComponentListener(final FrameComponentChangeListener listener) {
572 585
         listeners.add(FrameComponentChangeListener.class, listener);
573 586
     }
@@ -578,6 +591,7 @@ public abstract class FrameContainer {
578 591
      * @since 0.6.6
579 592
      * @param listener The listener to be removed
580 593
      */
594
+    @Deprecated
581 595
     public void removeComponentListener(final FrameComponentChangeListener listener) {
582 596
         listeners.remove(FrameComponentChangeListener.class, listener);
583 597
     }
@@ -587,6 +601,7 @@ public abstract class FrameContainer {
587 601
      *
588 602
      * @param listener The listener to inform of notification events.
589 603
      */
604
+    @Deprecated
590 605
     public void addNotificationListener(final NotificationListener listener) {
591 606
         listeners.add(NotificationListener.class, listener);
592 607
     }
@@ -596,6 +611,7 @@ public abstract class FrameContainer {
596 611
      *
597 612
      * @param listener The listener to be removed.
598 613
      */
614
+    @Deprecated
599 615
     public void removeNotificationListener(final NotificationListener listener) {
600 616
         listeners.remove(NotificationListener.class, listener);
601 617
     }

+ 35
- 0
src/com/dmdirc/events/FrameClosingEvent.java 查看文件

@@ -0,0 +1,35 @@
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 window is closed in the client.
29
+ */
30
+public class FrameClosingEvent extends FrameEvent {
31
+
32
+    public FrameClosingEvent(final FrameContainer container) {
33
+        super(container);
34
+    }
35
+}

+ 35
- 0
src/com/dmdirc/events/FrameComponentAddedEvent.java 查看文件

@@ -0,0 +1,35 @@
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 component is added.
29
+ */
30
+public class FrameComponentAddedEvent extends FrameComponentEvent {
31
+
32
+    public FrameComponentAddedEvent(final FrameContainer container, final String component) {
33
+        super(container, component);
34
+    }
35
+}

+ 47
- 0
src/com/dmdirc/events/FrameComponentEvent.java 查看文件

@@ -0,0 +1,47 @@
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 frame component events.
29
+ */
30
+public abstract class FrameComponentEvent {
31
+
32
+    private final FrameContainer container;
33
+    private final String component;
34
+
35
+    public FrameComponentEvent(final FrameContainer container, final String component) {
36
+        this.container = container;
37
+        this.component = component;
38
+    }
39
+
40
+    public FrameContainer getContainer() {
41
+        return container;
42
+    }
43
+
44
+    public String getComponent() {
45
+        return component;
46
+    }
47
+}

+ 35
- 0
src/com/dmdirc/events/FrameComponentRemovedEvent.java 查看文件

@@ -0,0 +1,35 @@
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 component is removed.
29
+ */
30
+public class FrameComponentRemovedEvent extends FrameComponentEvent {
31
+
32
+    public FrameComponentRemovedEvent(final FrameContainer container, final String component) {
33
+        super(container, component);
34
+    }
35
+}

+ 41
- 0
src/com/dmdirc/events/FrameEvent.java 查看文件

@@ -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 window related events in the client.
29
+ */
30
+public abstract class FrameEvent extends DMDircEvent {
31
+
32
+    private final FrameContainer container;
33
+
34
+    public FrameEvent(final FrameContainer container) {
35
+        this.container = container;
36
+    }
37
+
38
+    public FrameContainer getContainer() {
39
+        return container;
40
+    }
41
+}

+ 35
- 0
src/com/dmdirc/events/NotificationClearedEvent.java 查看文件

@@ -0,0 +1,35 @@
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 notification has been cleared.
29
+ */
30
+public class NotificationClearedEvent extends NotificationEvent {
31
+
32
+    public NotificationClearedEvent(final FrameContainer container) {
33
+        super(container);
34
+    }
35
+}

+ 41
- 0
src/com/dmdirc/events/NotificationEvent.java 查看文件

@@ -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 notification events in the client.
29
+ */
30
+public abstract class NotificationEvent extends DMDircEvent {
31
+
32
+    private final FrameContainer window;
33
+
34
+    public NotificationEvent(final FrameContainer window) {
35
+        this.window = window;
36
+    }
37
+
38
+    public FrameContainer getWindow() {
39
+        return window;
40
+    }
41
+}

+ 43
- 0
src/com/dmdirc/events/NotificationSetEvent.java 查看文件

@@ -0,0 +1,43 @@
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
+import com.dmdirc.ui.Colour;
27
+
28
+/**
29
+ * Fired when the notification colour has been changed.
30
+ */
31
+public class NotificationSetEvent extends NotificationEvent {
32
+
33
+    private final Colour colour;
34
+
35
+    public NotificationSetEvent(final FrameContainer container, final Colour colour) {
36
+        super(container);
37
+        this.colour = colour;
38
+    }
39
+
40
+    public Colour getColour() {
41
+        return colour;
42
+    }
43
+}

+ 3
- 0
src/com/dmdirc/interfaces/FrameCloseListener.java 查看文件

@@ -29,7 +29,10 @@ import com.dmdirc.FrameContainer;
29 29
  * of a {@link FrameContainer}.
30 30
  *
31 31
  * @since 0.6.5
32
+ *
33
+ * @deprecated @see com.dmdirc.events.WindowClosingEvent
32 34
  */
35
+@Deprecated
33 36
 public interface FrameCloseListener {
34 37
 
35 38
     /**

+ 1
- 0
src/com/dmdirc/interfaces/FrameComponentChangeListener.java 查看文件

@@ -29,6 +29,7 @@ import com.dmdirc.FrameContainer;
29 29
  *
30 30
  * @since 0.6.6
31 31
  */
32
+@Deprecated
32 33
 public interface FrameComponentChangeListener {
33 34
 
34 35
     /**

+ 1
- 0
src/com/dmdirc/interfaces/NotificationListener.java 查看文件

@@ -31,6 +31,7 @@ import java.util.EventListener;
31 31
  * Defines the methods that should be implemented by classes which wish to receive information about
32 32
  * notification changes.
33 33
  */
34
+@Deprecated
34 35
 public interface NotificationListener extends EventListener {
35 36
 
36 37
     /**

Loading…
取消
儲存