Parcourir la source

Remove ComponentFrameFactory.

Instead, pass a list of suppliers of components into ComponentFrame.

Also ditch ComponentInputFrame which is unused.
pull/104/head
Chris Smith il y a 9 ans
Parent
révision
d639d1d889

+ 12
- 2
dcc/src/com/dmdirc/addons/dcc/DCCManager.java Voir le fichier

@@ -31,6 +31,8 @@ import com.dmdirc.addons.dcc.io.DCC;
31 31
 import com.dmdirc.addons.dcc.io.DCCChat;
32 32
 import com.dmdirc.addons.dcc.io.DCCTransfer;
33 33
 import com.dmdirc.addons.dcc.kde.KFileChooser;
34
+import com.dmdirc.addons.dcc.ui.PlaceholderPanel;
35
+import com.dmdirc.addons.dcc.ui.TransferPanel;
34 36
 import com.dmdirc.addons.ui_swing.SwingWindowFactory;
35 37
 import com.dmdirc.addons.ui_swing.components.frames.ComponentFrameFactory;
36 38
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
@@ -56,6 +58,8 @@ import com.dmdirc.ui.input.TabCompleterFactory;
56 58
 import com.dmdirc.ui.messages.ColourManagerFactory;
57 59
 import com.dmdirc.util.URLBuilder;
58 60
 
61
+import com.google.common.collect.Lists;
62
+
59 63
 import java.awt.Dialog;
60 64
 import java.awt.Window;
61 65
 import java.io.File;
@@ -65,9 +69,11 @@ import java.net.UnknownHostException;
65 69
 import java.util.Arrays;
66 70
 import java.util.HashSet;
67 71
 import java.util.Set;
72
+import java.util.function.Supplier;
68 73
 
69 74
 import javax.inject.Inject;
70 75
 import javax.inject.Singleton;
76
+import javax.swing.JComponent;
71 77
 import javax.swing.JFileChooser;
72 78
 import javax.swing.JOptionPane;
73 79
 
@@ -151,7 +157,9 @@ public class DCCManager {
151 157
                 new SwingWindowFactory.WindowProvider() {
152 158
                     @Override
153 159
                     public TextFrame getWindow(final FrameContainer container) {
154
-                        return componentFrameFactory.getComponentFrame(container, commandParser);
160
+                        return componentFrameFactory.getComponentFrame(container, commandParser,
161
+                                Lists.<Supplier<? extends JComponent>>newArrayList(
162
+                                        PlaceholderPanel::new));
155 163
                     }
156 164
 
157 165
                     @Override
@@ -164,7 +172,9 @@ public class DCCManager {
164 172
                 new SwingWindowFactory.WindowProvider() {
165 173
                     @Override
166 174
                     public TextFrame getWindow(final FrameContainer container) {
167
-                        return componentFrameFactory.getComponentFrame(container, commandParser);
175
+                        return componentFrameFactory.getComponentFrame(container, commandParser,
176
+                                Lists.<Supplier<? extends JComponent>>newArrayList(
177
+                                        () -> new TransferPanel(container, eventBus)));
168 178
                     }
169 179
 
170 180
                     @Override

+ 8
- 26
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ComponentFrame.java Voir le fichier

@@ -22,12 +22,11 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
-import com.dmdirc.DMDircMBassador;
26 25
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.addons.ui_swing.SwingController;
28 26
 import com.dmdirc.commandparser.PopupType;
29 27
 import com.dmdirc.commandparser.parsers.CommandParser;
30
-import com.dmdirc.util.URLBuilder;
28
+
29
+import java.util.function.Supplier;
31 30
 
32 31
 import javax.swing.JComponent;
33 32
 import javax.swing.JPopupMenu;
@@ -41,47 +40,30 @@ public class ComponentFrame extends TextFrame {
41 40
 
42 41
     /** A version number for this class. */
43 42
     private static final long serialVersionUID = 2;
44
-    /** URL builder to use when making components. */
45
-    private final URLBuilder urlBuilder;
46
-    /** Parent frame container. */
47
-    private final FrameContainer owner;
48
-    /** Parent controller. */
49
-    private final SwingController controller;
50
-    /** The global event bus. */
51
-    private final DMDircMBassador eventBus;
52 43
 
53 44
     /**
54 45
      * Creates a new instance of CustomFrame.
55 46
      *
56
-     * @param eventBus      The global event bus
57 47
      * @param deps          The dependencies required by text frames.
58
-     * @param urlBuilder    URL builder to use when making components.
59 48
      * @param owner         The frame container that owns this frame.
60 49
      * @param commandParser The parser to use to process commands.
50
+     * @param componentSupplier Supplier of components that will be in this frame.
61 51
      */
62 52
     public ComponentFrame(
63
-            final DMDircMBassador eventBus,
64 53
             final TextFrameDependencies deps,
65
-            final URLBuilder urlBuilder,
66 54
             final FrameContainer owner,
67
-            final CommandParser commandParser) {
55
+            final CommandParser commandParser,
56
+            final Iterable<Supplier<? extends JComponent>> componentSupplier) {
68 57
         super(owner, commandParser, deps);
69
-        this.eventBus = eventBus;
70
-        this.controller = deps.controller;
71
-        this.urlBuilder = urlBuilder;
72
-        this.owner = owner;
73
-        initComponents();
58
+        initComponents(componentSupplier);
74 59
     }
75 60
 
76 61
     /**
77 62
      * Initialises components in this frame.
78 63
      */
79
-    private void initComponents() {
64
+    private void initComponents(final Iterable<Supplier<? extends JComponent>> componentSupplier) {
80 65
         setLayout(new MigLayout("fill"));
81
-        for (JComponent comp : new ComponentCreator()
82
-                .initFrameComponents(this, controller, eventBus, urlBuilder, owner)) {
83
-            add(comp, "wrap, grow");
84
-        }
66
+        componentSupplier.forEach(c -> add(c.get(), "wrap, grow"));
85 67
     }
86 68
 
87 69
     @Override

+ 8
- 8
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ComponentFrameFactory.java Voir le fichier

@@ -25,10 +25,12 @@ package com.dmdirc.addons.ui_swing.components.frames;
25 25
 import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.commandparser.parsers.CommandParser;
28
-import com.dmdirc.util.URLBuilder;
28
+
29
+import java.util.function.Supplier;
29 30
 
30 31
 import javax.inject.Inject;
31 32
 import javax.inject.Singleton;
33
+import javax.swing.JComponent;
32 34
 
33 35
 import static com.dmdirc.addons.ui_swing.components.frames.TextFrame.TextFrameDependencies;
34 36
 
@@ -40,23 +42,21 @@ public class ComponentFrameFactory {
40 42
 
41 43
     private final DMDircMBassador eventBus;
42 44
     private final TextFrameDependencies dependencies;
43
-    private final URLBuilder urlBuilder;
44 45
 
45 46
     @Inject
46 47
     public ComponentFrameFactory(
47 48
             final DMDircMBassador eventBus,
48
-            final TextFrameDependencies dependencies,
49
-            final URLBuilder urlBuilder) {
49
+            final TextFrameDependencies dependencies) {
50 50
         this.eventBus = eventBus;
51 51
         this.dependencies = dependencies;
52
-        this.urlBuilder = urlBuilder;
53 52
     }
54 53
 
55 54
     public ComponentFrame getComponentFrame(
56 55
             final FrameContainer owner,
57
-            final CommandParser commandParser) {
58
-        final ComponentFrame frame = new ComponentFrame(eventBus, dependencies, urlBuilder, owner,
59
-                commandParser);
56
+            final CommandParser commandParser,
57
+            final Iterable<Supplier<? extends JComponent>> componentSupplier) {
58
+        final ComponentFrame frame = new ComponentFrame(dependencies, owner, commandParser,
59
+                componentSupplier);
60 60
         eventBus.subscribe(frame);
61 61
         return frame;
62 62
     }

+ 0
- 113
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ComponentInputFrame.java Voir le fichier

@@ -1,113 +0,0 @@
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.addons.ui_swing.components.frames;
24
-
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.FrameContainer;
27
-import com.dmdirc.addons.ui_swing.SwingController;
28
-import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
29
-import com.dmdirc.commandparser.PopupType;
30
-import com.dmdirc.util.URLBuilder;
31
-
32
-import javax.inject.Provider;
33
-import javax.swing.JComponent;
34
-import javax.swing.JPopupMenu;
35
-
36
-import net.miginfocom.swing.MigLayout;
37
-
38
-/**
39
- * A component frame that includes an input field (for use with writable containers).
40
- */
41
-public class ComponentInputFrame extends InputTextFrame {
42
-
43
-    /** A version number for this class. */
44
-    private static final long serialVersionUID = 2;
45
-    /** URL builder to use when making components. */
46
-    private final URLBuilder urlBuilder;
47
-    /** Parent frame container. */
48
-    private final FrameContainer owner;
49
-    /** Parent controller. */
50
-    private final SwingController controller;
51
-    /** The global event bus. */
52
-    private final DMDircMBassador eventBus;
53
-
54
-    /**
55
-     * Creates a new instance of CustomInputFrame.
56
-     *
57
-     * @param eventBus           The global event bus
58
-     * @param deps               The dependencies required by text frames.
59
-     * @param inputFieldProvider The provider to use to create a new input field.
60
-     * @param urlBuilder         URL builder to use when making components.
61
-     * @param owner              The frame container that owns this frame
62
-     */
63
-    public ComponentInputFrame(
64
-            final DMDircMBassador eventBus,
65
-            final TextFrameDependencies deps,
66
-            final Provider<SwingInputField> inputFieldProvider,
67
-            final URLBuilder urlBuilder,
68
-            final FrameContainer owner) {
69
-        super(deps, inputFieldProvider, owner);
70
-        this.eventBus = eventBus;
71
-        this.controller = deps.controller;
72
-        this.urlBuilder = urlBuilder;
73
-        this.owner = owner;
74
-        initComponents();
75
-    }
76
-
77
-    /**
78
-     * Initialises components in this frame.
79
-     */
80
-    private void initComponents() {
81
-        setLayout(new MigLayout("fill"));
82
-        for (JComponent comp : new ComponentCreator()
83
-                .initFrameComponents(this, controller, eventBus, urlBuilder, owner)) {
84
-            add(comp, "wrap, grow");
85
-        }
86
-    }
87
-
88
-    @Override
89
-    public PopupType getNicknamePopupType() {
90
-        return null;
91
-    }
92
-
93
-    @Override
94
-    public PopupType getChannelPopupType() {
95
-        return null;
96
-    }
97
-
98
-    @Override
99
-    public PopupType getHyperlinkPopupType() {
100
-        return null;
101
-    }
102
-
103
-    @Override
104
-    public PopupType getNormalPopupType() {
105
-        return null;
106
-    }
107
-
108
-    @Override
109
-    public void addCustomPopupItems(final JPopupMenu popupMenu) {
110
-        //Add no custom popup items
111
-    }
112
-
113
-}

Chargement…
Annuler
Enregistrer