Browse Source

Add getOptionalConnection

pull/102/head
Greg Holmes 9 years ago
parent
commit
006a9afa9f

+ 6
- 0
dcc/src/com/dmdirc/addons/dcc/DCCFrameContainer.java View File

@@ -33,6 +33,7 @@ import com.dmdirc.ui.messages.ColourManagerFactory;
33 33
 import com.dmdirc.util.URLBuilder;
34 34
 
35 35
 import java.util.Collection;
36
+import java.util.Optional;
36 37
 
37 38
 import javax.annotation.Nullable;
38 39
 
@@ -87,6 +88,11 @@ public abstract class DCCFrameContainer extends FrameContainer {
87 88
         return null;
88 89
     }
89 90
 
91
+    @Override
92
+    public Optional<Connection> getOptionalConnection() { //NOPMD - server will always be null
93
+        return Optional.empty();
94
+    }
95
+
90 96
     /**
91 97
      * Is the window closing?
92 98
      *

+ 6
- 0
dcc/src/com/dmdirc/addons/dcc/PlaceholderContainer.java View File

@@ -33,6 +33,7 @@ import com.dmdirc.util.URLBuilder;
33 33
 import java.awt.Dialog.ModalityType;
34 34
 import java.awt.Window;
35 35
 import java.util.Collections;
36
+import java.util.Optional;
36 37
 
37 38
 /**
38 39
  * Creates a placeholder DCC Frame.
@@ -95,6 +96,11 @@ public class PlaceholderContainer extends FrameContainer {
95 96
         return null;
96 97
     }
97 98
 
99
+    @Override
100
+    public Optional<Connection> getOptionalConnection() {
101
+        return Optional.empty();
102
+    }
103
+
98 104
     @Override
99 105
     public void removeChild(final FrameContainer child) {
100 106
         super.removeChild(child);

+ 6
- 0
dcc/src/com/dmdirc/addons/dcc/TransferContainer.java View File

@@ -41,6 +41,7 @@ import java.awt.Desktop;
41 41
 import java.io.File;
42 42
 import java.util.Arrays;
43 43
 import java.util.Date;
44
+import java.util.Optional;
44 45
 
45 46
 import javax.swing.JOptionPane;
46 47
 
@@ -369,4 +370,9 @@ public class TransferContainer extends FrameContainer implements
369 370
         return null;
370 371
     }
371 372
 
373
+    @Override
374
+    public Optional<Connection> getOptionalConnection() {
375
+        return Optional.empty();
376
+    }
377
+
372 378
 }

+ 6
- 0
logging/src/com/dmdirc/addons/logging/HistoryWindow.java View File

@@ -81,4 +81,10 @@ public class HistoryWindow extends FrameContainer {
81 81
         return parent.isPresent() ? parent.get().getConnection() : null;
82 82
     }
83 83
 
84
+    @Override
85
+    public Optional<Connection> getOptionalConnection() {
86
+        final Optional<FrameContainer> parent = getParent();
87
+        return Optional.ofNullable(parent.isPresent() ? parent.get().getConnection() : null);
88
+    }
89
+
84 90
 }

+ 6
- 0
parserdebug/src/com/dmdirc/addons/parserdebug/DebugWindow.java View File

@@ -32,6 +32,7 @@ import com.dmdirc.ui.messages.ColourManagerFactory;
32 32
 import com.dmdirc.util.URLBuilder;
33 33
 
34 34
 import java.util.Arrays;
35
+import java.util.Optional;
35 36
 
36 37
 /**
37 38
  * This class is used to show the parser debug in a window
@@ -81,6 +82,11 @@ public class DebugWindow extends FrameContainer {
81 82
         return connection;
82 83
     }
83 84
 
85
+    @Override
86
+    public Optional<Connection> getOptionalConnection() {
87
+        return Optional.of(connection);
88
+    }
89
+
84 90
     /**
85 91
      * Set the parser to null to stop us holding onto parsers when the server connection is closed.
86 92
      */

+ 6
- 0
redirect/src/com/dmdirc/addons/redirect/FakeWriteableFrameContainer.java View File

@@ -32,6 +32,7 @@ import com.dmdirc.util.URLBuilder;
32 32
 
33 33
 import java.util.Collections;
34 34
 import java.util.Date;
35
+import java.util.Optional;
35 36
 
36 37
 /**
37 38
  * Implements a fake input window, which sends echoed text to the specified chat window instead.
@@ -107,4 +108,9 @@ public class FakeWriteableFrameContainer extends FrameContainer {
107 108
         return target.getConnection();
108 109
     }
109 110
 
111
+    @Override
112
+    public Optional<Connection> getOptionalConnection() {
113
+        return Optional.of(target.getConnection());
114
+    }
115
+
110 116
 }

Loading…
Cancel
Save