浏览代码

Minor tidying

Change-Id: Ibcb8c43c3d9fcd18d80e087e951c2466bf717898
Reviewed-on: http://gerrit.dmdirc.com/3824
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
changes/24/3824/2
Chris Smith 9 年前
父节点
当前提交
64a22c788f

+ 11
- 14
src/com/dmdirc/addons/contactlist/ContactListListener.java 查看文件

@@ -22,19 +22,17 @@
22 22
 
23 23
 package com.dmdirc.addons.contactlist;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.DMDircMBassador;
27 26
 import com.dmdirc.Query;
28 27
 import com.dmdirc.events.ChannelUserAwayEvent;
29 28
 import com.dmdirc.events.ChannelUserBackEvent;
30 29
 import com.dmdirc.events.FrameClosingEvent;
30
+import com.dmdirc.interfaces.GroupChat;
31 31
 import com.dmdirc.interfaces.NicklistListener;
32 32
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
33 33
 
34 34
 import java.util.Collection;
35 35
 
36
-import javax.inject.Inject;
37
-
38 36
 import net.engio.mbassy.listener.Handler;
39 37
 
40 38
 /**
@@ -42,27 +40,26 @@ import net.engio.mbassy.listener.Handler;
42 40
  */
43 41
 public class ContactListListener implements NicklistListener {
44 42
 
45
-    /** The channel this listener is for. */
46
-    private final Channel channel;
43
+    /** The group chat this listener is for. */
44
+    private final GroupChat groupChat;
47 45
     /** Event bus to register listeners with. */
48 46
     private final DMDircMBassador eventBus;
49 47
 
50 48
     /**
51
-     * Creates a new ContactListListener for the specified channel.
49
+     * Creates a new ContactListListener for the specified group chat.
52 50
      *
53
-     * @param channel The channel to show a contact list for
51
+     * @param groupChat The group chat to show a contact list for
54 52
      */
55
-    @Inject
56
-    public ContactListListener(final Channel channel) {
57
-        this.channel = channel;
58
-        this.eventBus = channel.getEventBus();
53
+    public ContactListListener(final GroupChat groupChat) {
54
+        this.groupChat = groupChat;
55
+        this.eventBus = groupChat.getEventBus();
59 56
     }
60 57
 
61 58
     /**
62 59
      * Adds all necessary listeners for this contact list listener to function.
63 60
      */
64 61
     public void addListeners() {
65
-        channel.addNicklistListener(this);
62
+        groupChat.addNicklistListener(this);
66 63
         eventBus.subscribe(this);
67 64
     }
68 65
 
@@ -70,7 +67,7 @@ public class ContactListListener implements NicklistListener {
70 67
      * Removes the listeners added by {@link #addListeners()}.
71 68
      */
72 69
     public void removeListeners() {
73
-        channel.removeNicklistListener(this);
70
+        groupChat.removeNicklistListener(this);
74 71
         eventBus.unsubscribe(this);
75 72
     }
76 73
 
@@ -88,7 +85,7 @@ public class ContactListListener implements NicklistListener {
88 85
 
89 86
     @Override
90 87
     public void clientAdded(final ChannelClientInfo client) {
91
-        final Query query = channel.getConnection().
88
+        final Query query = groupChat.getConnection().
92 89
                 getQuery(client.getClient().getNickname(), false);
93 90
 
94 91
         query.setIcon("query-" + client.getClient().getAwayState().name().toLowerCase());

+ 7
- 6
src/com/dmdirc/addons/ui_swing/components/TopicBar.java 查看文件

@@ -56,10 +56,11 @@ import javax.swing.JComponent;
56 56
 import javax.swing.JLabel;
57 57
 import javax.swing.JScrollPane;
58 58
 import javax.swing.KeyStroke;
59
+import javax.swing.ScrollPaneConstants;
59 60
 import javax.swing.SwingUtilities;
60 61
 import javax.swing.event.DocumentEvent;
61 62
 import javax.swing.event.DocumentListener;
62
-import javax.swing.text.DefaultStyledDocument;
63
+import javax.swing.text.AbstractDocument;
63 64
 import javax.swing.text.SimpleAttributeSet;
64 65
 import javax.swing.text.StyleConstants;
65 66
 import javax.swing.text.StyledDocument;
@@ -141,7 +142,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
141 142
         updateOptions();
142 143
         errorIcon = new JLabel(iconManager.getIcon("input-error"));
143 144
         topicText.setEditorKit(new WrapEditorKit(showFull, channel.getEventBus(), window));
144
-        ((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
145
+        ((AbstractDocument) topicText.getDocument()).setDocumentFilter(
145 146
                 new NewlinesDocumentFilter());
146 147
 
147 148
         topicText.getActionMap().put("paste-from-clipboard",
@@ -160,8 +161,8 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
160 161
         handler.setTabCompleter(channel.getTabCompleter());
161 162
 
162 163
         final JScrollPane sp = new JScrollPane(topicText);
163
-        sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
164
-        sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
164
+        sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
165
+        sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
165 166
 
166 167
         setLayout(new MigLayout("fillx, ins 0, hidemode 3"));
167 168
         add(sp, "growx, pushx");
@@ -367,7 +368,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
367 368
      */
368 369
     private void applyAttributes() {
369 370
         setAttributes();
370
-        ((DefaultStyledDocument) topicText.getDocument())
371
+        ((StyledDocument) topicText.getDocument())
371 372
                 .setCharacterAttributes(0, Integer.MAX_VALUE, as, true);
372 373
     }
373 374
 
@@ -445,7 +446,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
445 446
         cancelTopicEdit();
446 447
         if ("showfulltopic".equals(key)) {
447 448
             topicText.setEditorKit(new WrapEditorKit(showFull, channel.getEventBus(), window));
448
-            ((DefaultStyledDocument) topicText.getDocument()).setDocumentFilter(
449
+            ((AbstractDocument) topicText.getDocument()).setDocumentFilter(
449 450
                     new NewlinesDocumentFilter());
450 451
             topicChanged(channel, null);
451 452
         }

+ 1
- 29
src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java 查看文件

@@ -48,7 +48,6 @@ import java.awt.event.ActionListener;
48 48
 import javax.inject.Provider;
49 49
 import javax.swing.JMenuItem;
50 50
 import javax.swing.JPopupMenu;
51
-import javax.swing.JSplitPane;
52 51
 
53 52
 import net.miginfocom.swing.MigLayout;
54 53
 
@@ -120,24 +119,6 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
120 119
                 owner.getChannelInfo().getName());
121 120
     }
122 121
 
123
-    /**
124
-     * Retrieves this channel frame's nicklist component.
125
-     *
126
-     * @return This channel's nicklist
127
-     */
128
-    public NickList getNickList() {
129
-        return nicklist;
130
-    }
131
-
132
-    /**
133
-     * Returns the topic bar for this channel frame.
134
-     *
135
-     * @return Topic bar or null if none exists
136
-     */
137
-    public TopicBar getTopicBar() {
138
-        return topicBar;
139
-    }
140
-
141 122
     /**
142 123
      * Initialises the components in this frame.
143 124
      *
@@ -182,15 +163,6 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
182 163
         }
183 164
     }
184 165
 
185
-    /**
186
-     * Returns the splitpane.
187
-     *
188
-     * @return nicklist JSplitPane
189
-     */
190
-    public JSplitPane getSplitPane() {
191
-        return splitPane;
192
-    }
193
-
194 166
     @Override
195 167
     public void configChanged(final String domain, final String key) {
196 168
         super.configChanged(domain, key);
@@ -258,7 +230,7 @@ public final class ChannelFrame extends InputTextFrame implements ActionListener
258 230
 
259 231
     @Override
260 232
     public void addCustomPopupItems(final JPopupMenu popupMenu) {
261
-        if (getContainer().getConnection().getState().equals(ServerState.CONNECTED)) {
233
+        if (channel.getConnection().getState() == ServerState.CONNECTED) {
262 234
             settingsMI.setEnabled(true);
263 235
         } else {
264 236
             settingsMI.setEnabled(false);

正在加载...
取消
保存