Sfoglia il codice sorgente

Remove some uses of Window.

Window only has a getContainer() method, so we may as well just
pass a WindowModel around instead.
pull/480/head
Chris Smith 7 anni fa
parent
commit
cda455a87e

+ 7
- 8
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/actions/CloseWindowAction.java Vedi File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.actions;
24 24
 
25
-import com.dmdirc.interfaces.ui.Window;
25
+import com.dmdirc.interfaces.WindowModel;
26 26
 
27 27
 import java.awt.event.ActionEvent;
28 28
 
@@ -36,23 +36,22 @@ public final class CloseWindowAction extends AbstractAction {
36 36
     /** A version number for this class. */
37 37
     private static final long serialVersionUID = 1;
38 38
     /** Window to be closed. */
39
-    private final Window frame;
39
+    private final WindowModel window;
40 40
 
41 41
     /**
42 42
      * Instantiates a new close a window action.
43 43
      *
44
-     * @param frame window to be closed
44
+     * @param window window to be closed
45 45
      */
46
-    public CloseWindowAction(final Window frame) {
46
+    public CloseWindowAction(final WindowModel window) {
47 47
         super("Close");
48
-
49
-        this.frame = frame;
48
+        this.window = window;
50 49
     }
51 50
 
52 51
     @Override
53 52
     public void actionPerformed(final ActionEvent e) {
54
-        if (frame != null) {
55
-            frame.getContainer().close();
53
+        if (window != null) {
54
+            window.close();
56 55
         }
57 56
     }
58 57
 

+ 4
- 4
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/frames/CommandAction.java Vedi File

@@ -23,7 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25 25
 import com.dmdirc.commandparser.parsers.CommandParser;
26
-import com.dmdirc.interfaces.ui.Window;
26
+import com.dmdirc.interfaces.WindowModel;
27 27
 
28 28
 import java.awt.event.ActionEvent;
29 29
 
@@ -39,7 +39,7 @@ public class CommandAction extends AbstractAction {
39 39
     /** Command parser. */
40 40
     private final CommandParser parser;
41 41
     /** Window. */
42
-    private final transient Window window;
42
+    private final transient WindowModel window;
43 43
     /** Command. */
44 44
     private final String command;
45 45
 
@@ -51,7 +51,7 @@ public class CommandAction extends AbstractAction {
51 51
      * @param name    Command name
52 52
      * @param command Command to execute
53 53
      */
54
-    public CommandAction(final CommandParser parser, final Window window,
54
+    public CommandAction(final CommandParser parser, final WindowModel window,
55 55
             final String name, final String command) {
56 56
         super(name);
57 57
 
@@ -63,7 +63,7 @@ public class CommandAction extends AbstractAction {
63 63
     @Override
64 64
     public void actionPerformed(final ActionEvent e) {
65 65
         for (String line : command.split("\n")) {
66
-            parser.parseCommand(window.getContainer(), line);
66
+            parser.parseCommand(window, line);
67 67
         }
68 68
     }
69 69
 

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Vedi File

@@ -455,7 +455,7 @@ public abstract class TextFrame extends JPanel implements Window, TextPaneListen
455 455
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
456 456
                         menuItem.getSubMenu(), arguments));
457 457
             } else {
458
-                menu.add(new JMenuItem(new CommandAction(commandParser, this,
458
+                menu.add(new JMenuItem(new CommandAction(commandParser, getContainer(),
459 459
                         menuItem.getName(), menuItem.getCommand(arguments))));
460 460
             }
461 461
 

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/framemanager/tree/Tree.java Vedi File

@@ -259,7 +259,7 @@ public class Tree extends JTree implements MouseMotionListener, MouseListener, A
259 259
 
260 260
             popupMenu.add(moveUp);
261 261
             popupMenu.add(moveDown);
262
-            popupMenu.add(new JMenuItem(new CloseWindowAction(frame)));
262
+            popupMenu.add(new JMenuItem(new CloseWindowAction(frame.getContainer())));
263 263
             popupMenu.show(this, e.getX(), e.getY());
264 264
         }
265 265
     }

+ 12
- 14
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/textpane/TextPane.java Vedi File

@@ -23,8 +23,8 @@
23 23
 package com.dmdirc.addons.ui_swing.textpane;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.interfaces.WindowModel;
26 27
 import com.dmdirc.interfaces.config.ConfigChangeListener;
27
-import com.dmdirc.interfaces.ui.Window;
28 28
 import com.dmdirc.ui.messages.CachingDocument;
29 29
 import com.dmdirc.ui.messages.IRCDocument;
30 30
 import com.dmdirc.ui.messages.IRCDocumentListener;
@@ -73,8 +73,8 @@ public final class TextPane extends JComponent implements MouseWheelListener,
73 73
     private final TextPaneCanvas canvas;
74 74
     /** IRCDocument. */
75 75
     private final IRCDocument document;
76
-    /** Parent Frame. */
77
-    private final Window frame;
76
+    /** Parent window. */
77
+    private final WindowModel window;
78 78
     /** Indicator to show whether new lines have been added. */
79 79
     private final JLabel newLineIndicator;
80 80
     /** Background painter. */
@@ -94,18 +94,18 @@ public final class TextPane extends JComponent implements MouseWheelListener,
94 94
      * @param configDomain The domain to read configuration from.
95 95
      * @param urlBuilder   The builder to use to construct URLs for resources.
96 96
      * @param clipboard    The clipboard to handle copy and paste actions
97
-     * @param frame        Parent Frame
97
+     * @param window       Parent window
98 98
      */
99 99
     public TextPane(
100 100
             final String configDomain,
101 101
             final URLBuilder urlBuilder, final Clipboard clipboard,
102
-            final Window frame) {
103
-        this.frame = frame;
102
+            final WindowModel window) {
103
+        this.window = window;
104 104
         this.configDomain = configDomain;
105 105
         this.clipboard = clipboard;
106 106
 
107 107
         setUI(new TextPaneUI());
108
-        document = frame.getContainer().getBackBuffer().getDocument();
108
+        document = window.getBackBuffer().getDocument();
109 109
         newLineIndicator = new JLabel("", SwingConstants.CENTER);
110 110
         newLineIndicator.setBackground(Color.RED);
111 111
         newLineIndicator.setForeground(Color.WHITE);
@@ -113,7 +113,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
113 113
         newLineIndicator.setVisible(false);
114 114
 
115 115
         setLayout(new MigLayout("fill, hidemode 3"));
116
-        backgroundPainter = new BackgroundPainter(frame.getContainer().getConfigManager(),
116
+        backgroundPainter = new BackgroundPainter(window.getConfigManager(),
117 117
                 urlBuilder, configDomain, "textpanebackground",
118 118
                 "textpanebackgroundoption", "textpanebackgroundopacity");
119 119
         canvas = new TextPaneCanvas(this,
@@ -130,8 +130,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
130 130
         add(scrollBar, "dock east");
131 131
         scrollBar.addAdjustmentListener(this);
132 132
         scrollBar.addAdjustmentListener(canvas);
133
-        frame.getContainer().getConfigManager().addChangeListener(configDomain,
134
-                "textpanelinenotification", this);
133
+        window.getConfigManager().addChangeListener(configDomain, "textpanelinenotification", this);
135 134
         configChanged("", "textpanelinenotification");
136 135
 
137 136
         addMouseWheelListener(this);
@@ -497,8 +496,8 @@ public final class TextPane extends JComponent implements MouseWheelListener,
497 496
      *
498 497
      * @return Parent window
499 498
      */
500
-    public Window getWindow() {
501
-        return frame;
499
+    public WindowModel getWindow() {
500
+        return window;
502 501
     }
503 502
 
504 503
     /**
@@ -521,8 +520,7 @@ public final class TextPane extends JComponent implements MouseWheelListener,
521 520
 
522 521
     @Override
523 522
     public void configChanged(final String domain, final String key) {
524
-        showNotification = frame.getContainer().getConfigManager()
525
-                .getOptionBool(configDomain, "textpanelinenotification");
523
+        showNotification = window.getConfigManager().getOptionBool(configDomain, "textpanelinenotification");
526 524
         if (!showNotification) {
527 525
             UIUtilities.invokeLater(() -> newLineIndicator.setVisible(false));
528 526
         }

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/textpane/TextPaneCanvas.java Vedi File

@@ -103,7 +103,7 @@ class TextPaneCanvas extends JPanel implements MouseInputListener,
103 103
     public TextPaneCanvas(final TextPane parent, final CachingDocument<AttributedString> document) {
104 104
         this.document = document;
105 105
         textPane = parent;
106
-        this.manager = parent.getWindow().getContainer().getConfigManager();
106
+        this.manager = parent.getWindow().getConfigManager();
107 107
         this.lineRenderer = new BasicTextLineRenderer(textPane, this, document);
108 108
         startLine = 0;
109 109
         setDoubleBuffered(true);

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/textpane/TextPaneFactory.java Vedi File

@@ -51,7 +51,7 @@ public class TextPaneFactory {
51 51
     }
52 52
 
53 53
     public TextPane getTextPane(final TextFrame frame) {
54
-        return new TextPane(configDomain, urlBuilder, clipboard, frame);
54
+        return new TextPane(configDomain, urlBuilder, clipboard, frame.getContainer());
55 55
     }
56 56
 
57 57
 }

Loading…
Annulla
Salva