Pārlūkot izejas kodu

Merge pull request #480 from csmith/master

Remove some uses of Window.
pull/481/head
Greg Holmes 8 gadus atpakaļ
vecāks
revīzija
2332aeff28

+ 7
- 8
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/actions/CloseWindowAction.java Parādīt failu

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.actions;
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
 import java.awt.event.ActionEvent;
27
 import java.awt.event.ActionEvent;
28
 
28
 
36
     /** A version number for this class. */
36
     /** A version number for this class. */
37
     private static final long serialVersionUID = 1;
37
     private static final long serialVersionUID = 1;
38
     /** Window to be closed. */
38
     /** Window to be closed. */
39
-    private final Window frame;
39
+    private final WindowModel window;
40
 
40
 
41
     /**
41
     /**
42
      * Instantiates a new close a window action.
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
         super("Close");
47
         super("Close");
48
-
49
-        this.frame = frame;
48
+        this.window = window;
50
     }
49
     }
51
 
50
 
52
     @Override
51
     @Override
53
     public void actionPerformed(final ActionEvent e) {
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 Parādīt failu

23
 package com.dmdirc.addons.ui_swing.components.frames;
23
 package com.dmdirc.addons.ui_swing.components.frames;
24
 
24
 
25
 import com.dmdirc.commandparser.parsers.CommandParser;
25
 import com.dmdirc.commandparser.parsers.CommandParser;
26
-import com.dmdirc.interfaces.ui.Window;
26
+import com.dmdirc.interfaces.WindowModel;
27
 
27
 
28
 import java.awt.event.ActionEvent;
28
 import java.awt.event.ActionEvent;
29
 
29
 
39
     /** Command parser. */
39
     /** Command parser. */
40
     private final CommandParser parser;
40
     private final CommandParser parser;
41
     /** Window. */
41
     /** Window. */
42
-    private final transient Window window;
42
+    private final transient WindowModel window;
43
     /** Command. */
43
     /** Command. */
44
     private final String command;
44
     private final String command;
45
 
45
 
51
      * @param name    Command name
51
      * @param name    Command name
52
      * @param command Command to execute
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
             final String name, final String command) {
55
             final String name, final String command) {
56
         super(name);
56
         super(name);
57
 
57
 
63
     @Override
63
     @Override
64
     public void actionPerformed(final ActionEvent e) {
64
     public void actionPerformed(final ActionEvent e) {
65
         for (String line : command.split("\n")) {
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 Parādīt failu

455
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
455
                 menu.add(populatePopupMenu(new JMenu(menuItem.getName()),
456
                         menuItem.getSubMenu(), arguments));
456
                         menuItem.getSubMenu(), arguments));
457
             } else {
457
             } else {
458
-                menu.add(new JMenuItem(new CommandAction(commandParser, this,
458
+                menu.add(new JMenuItem(new CommandAction(commandParser, getContainer(),
459
                         menuItem.getName(), menuItem.getCommand(arguments))));
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 Parādīt failu

259
 
259
 
260
             popupMenu.add(moveUp);
260
             popupMenu.add(moveUp);
261
             popupMenu.add(moveDown);
261
             popupMenu.add(moveDown);
262
-            popupMenu.add(new JMenuItem(new CloseWindowAction(frame)));
262
+            popupMenu.add(new JMenuItem(new CloseWindowAction(frame.getContainer())));
263
             popupMenu.show(this, e.getX(), e.getY());
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 Parādīt failu

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

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/textpane/TextPaneCanvas.java Parādīt failu

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

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/textpane/TextPaneFactory.java Parādīt failu

51
     }
51
     }
52
 
52
 
53
     public TextPane getTextPane(final TextFrame frame) {
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
 }

Notiek ielāde…
Atcelt
Saglabāt