Selaa lähdekoodia

Switch to AutoClose instead of StreamUtils.

Change-Id: I6af125efcbd20942f62774570aa670b40ee12538
Reviewed-on: http://gerrit.dmdirc.com/3793
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/93/3793/2
Greg Holmes 9 vuotta sitten
vanhempi
commit
607e82d8d9

+ 2
- 7
src/com/dmdirc/addons/identd/IdentClient.java Näytä tiedosto

@@ -91,11 +91,8 @@ public class IdentClient implements Runnable {
91 91
     @Override
92 92
     public void run() {
93 93
         final Thread thisThread = Thread.currentThread();
94
-        PrintWriter out = null;
95
-        BufferedReader in = null;
96
-        try {
97
-            out = new PrintWriter(socket.getOutputStream(), true);
98
-            in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
94
+        try (PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
95
+                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) {
99 96
             final String inputLine;
100 97
             if ((inputLine = in.readLine()) != null) {
101 98
                 out.println(getIdentResponse(inputLine, config));
@@ -106,8 +103,6 @@ public class IdentClient implements Runnable {
106 103
                         "ClientSocket Error: " + e.getMessage(), ""));
107 104
             }
108 105
         } finally {
109
-            StreamUtils.close(in);
110
-            StreamUtils.close(out);
111 106
             StreamUtils.close(socket);
112 107
             server.delClient(this);
113 108
         }

+ 7
- 21
src/com/dmdirc/addons/ui_swing/MainFrame.java Näytä tiedosto

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.addons.ui_swing.components.SplitPane;
28 27
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
29 28
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
@@ -41,11 +40,10 @@ import com.dmdirc.events.ClientFocusLostEvent;
41 40
 import com.dmdirc.events.ClientMinimisedEvent;
42 41
 import com.dmdirc.events.ClientUnminimisedEvent;
43 42
 import com.dmdirc.events.FrameTitleChangedEvent;
43
+import com.dmdirc.events.NotificationSetEvent;
44 44
 import com.dmdirc.interfaces.LifecycleController;
45
-import com.dmdirc.interfaces.NotificationListener;
46 45
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
47 46
 import com.dmdirc.interfaces.config.ConfigChangeListener;
48
-import com.dmdirc.ui.Colour;
49 47
 import com.dmdirc.ui.CoreUIUtils;
50 48
 import com.dmdirc.ui.IconManager;
51 49
 import com.dmdirc.util.collections.ListenerList;
@@ -73,8 +71,8 @@ import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT;
73 71
 /**
74 72
  * The main application frame.
75 73
  */
76
-public class MainFrame extends JFrame implements WindowListener,
77
-        ConfigChangeListener, NotificationListener, ActiveFrameManager {
74
+public class MainFrame extends JFrame implements WindowListener, ConfigChangeListener,
75
+        ActiveFrameManager {
78 76
 
79 77
     /** A version number for this class. */
80 78
     private static final long serialVersionUID = 9;
@@ -545,10 +543,6 @@ public class MainFrame extends JFrame implements WindowListener,
545 543
                 framePanel.setVisible(false);
546 544
                 framePanel.removeAll();
547 545
 
548
-                if (MainFrame.this.activeFrame != null) {
549
-                    MainFrame.this.activeFrame.getContainer()
550
-                            .removeNotificationListener(MainFrame.this);
551
-                }
552 546
                 MainFrame.this.activeFrame = activeFrame;
553 547
 
554 548
                 if (activeFrame == null) {
@@ -557,8 +551,6 @@ public class MainFrame extends JFrame implements WindowListener,
557 551
                 } else {
558 552
                     framePanel.add(activeFrame.getDisplayFrame(), "grow");
559 553
                     setTitle(activeFrame.getContainer().getTitle());
560
-                    activeFrame.getContainer().addNotificationListener(
561
-                            MainFrame.this);
562 554
                 }
563 555
 
564 556
                 framePanel.setVisible(true);
@@ -628,19 +620,13 @@ public class MainFrame extends JFrame implements WindowListener,
628 620
         }
629 621
     }
630 622
 
631
-    @Override
632
-    public void notificationSet(final FrameContainer window,
633
-            final Colour colour) {
634
-        if (activeFrame != null && activeFrame.getContainer().equals(window)) {
635
-            window.clearNotification();
623
+    @Handler
624
+    public void notificationSet(final NotificationSetEvent event) {
625
+        if (activeFrame != null && activeFrame.getContainer().equals(event.getWindow())) {
626
+            event.getWindow().clearNotification();
636 627
         }
637 628
     }
638 629
 
639
-    @Override
640
-    public void notificationCleared(final FrameContainer window) {
641
-        //Ignore
642
-    }
643
-
644 630
     @Override
645 631
     public void dispose() {
646 632
         if (!quitting) {

Loading…
Peruuta
Tallenna