Преглед на файлове

Merge branch 'master' of https://github.com/DMDirc/Plugins into dev4

pull/339/head
Greg Holmes преди 9 години
родител
ревизия
1d7c677815

+ 1
- 5
circle.yml Целия файл

@@ -37,11 +37,7 @@ dependencies:
37 37
 
38 38
 test:
39 39
   override:
40
-    - ./gradlew --stacktrace --parallel plugins:jar plugins:test:
41
-        pwd:
42
-          ../meta
43
-  post:
44
-    - ./gradlew plugins:coveralls:
40
+    - ./gradlew --stacktrace plugins:jar plugins:test plugins:coveralls:
45 41
         pwd:
46 42
           ../meta
47 43
 

+ 2
- 2
contactlist/src/com/dmdirc/addons/contactlist/ContactListCommand.java Целия файл

@@ -62,9 +62,9 @@ public class ContactListCommand extends Command implements IntelligentCommand {
62 62
             final CommandArguments args, final CommandContext context) {
63 63
         final ChannelCommandContext chanContext = (ChannelCommandContext) context;
64 64
 
65
-        final ContactListListener listener = new ContactListListener(chanContext.getChannel());
65
+        final ContactListListener listener = new ContactListListener(chanContext.getGroupChat());
66 66
         listener.addListeners();
67
-        chanContext.getChannel().getUsers().forEach(listener::clientAdded);
67
+        chanContext.getGroupChat().getUsers().forEach(listener::clientAdded);
68 68
     }
69 69
 
70 70
     @Override

+ 6
- 5
logging/src/com/dmdirc/addons/logging/LogFileLocator.java Целия файл

@@ -27,10 +27,11 @@ import com.dmdirc.DMDircMBassador;
27 27
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
28 28
 import com.dmdirc.config.ConfigBinding;
29 29
 import com.dmdirc.events.UserErrorEvent;
30
+import com.dmdirc.interfaces.Connection;
31
+import com.dmdirc.interfaces.GroupChat;
30 32
 import com.dmdirc.interfaces.User;
31 33
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 34
 import com.dmdirc.logger.ErrorLevel;
33
-import com.dmdirc.parser.interfaces.ChannelInfo;
34 35
 import com.dmdirc.plugins.PluginDomain;
35 36
 
36 37
 import java.io.File;
@@ -39,6 +40,7 @@ import java.security.MessageDigest;
39 40
 import java.security.NoSuchAlgorithmException;
40 41
 import java.text.SimpleDateFormat;
41 42
 import java.util.Date;
43
+import java.util.Optional;
42 44
 
43 45
 import javax.annotation.Nullable;
44 46
 import javax.inject.Inject;
@@ -103,12 +105,11 @@ public class LogFileLocator {
103 105
      *
104 106
      * @return the name of the log file to use for this object.
105 107
      */
106
-    public String getLogFile(final ChannelInfo channel) {
108
+    public String getLogFile(final GroupChat channel) {
107 109
         final StringBuffer directory = getLogDirectory();
108 110
         final StringBuffer file = new StringBuffer();
109
-        if (channel.getParser() != null) {
110
-            addNetworkDir(directory, file, channel.getParser().getNetworkName());
111
-        }
111
+        final Optional<String> network = channel.getConnection().map(Connection::getNetwork);
112
+        network.ifPresent(n -> addNetworkDir(directory, file, n));
112 113
         file.append(sanitise(channel.getName().toLowerCase()));
113 114
         return getPath(directory, file, channel.getName());
114 115
     }

+ 11
- 11
logging/src/com/dmdirc/addons/logging/LoggingManager.java Целия файл

@@ -260,19 +260,19 @@ public class LoggingManager implements ConfigChangeListener {
260 260
 
261 261
     @Handler
262 262
     public void handleChannelMessage(final BaseChannelMessageEvent event) {
263
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
263
+        final String filename = locator.getLogFile(event.getChannel());
264 264
         appendLine(filename, "<%s> %s", getDisplayName(event.getClient()), event.getMessage());
265 265
     }
266 266
 
267 267
     @Handler
268 268
     public void handleChannelAction(final BaseChannelActionEvent event) {
269
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
269
+        final String filename = locator.getLogFile(event.getChannel());
270 270
         appendLine(filename, "* %s %s", getDisplayName(event.getClient()), event.getMessage());
271 271
     }
272 272
 
273 273
     @Handler
274 274
     public void handleChannelGotTopic(final ChannelGotTopicEvent event) {
275
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
275
+        final String filename = locator.getLogFile(event.getChannel());
276 276
         final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
277 277
         final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
278 278
 
@@ -286,14 +286,14 @@ public class LoggingManager implements ConfigChangeListener {
286 286
 
287 287
     @Handler
288 288
     public void handleChannelTopicChange(final ChannelTopicChangeEvent event) {
289
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
289
+        final String filename = locator.getLogFile(event.getChannel());
290 290
         appendLine(filename, "*** %s Changed the topic to: %s",
291 291
                 event.getTopic().getClient().map(this::getDisplayName).orElse(""), event.getTopic());
292 292
     }
293 293
 
294 294
     @Handler
295 295
     public void handleChannelJoin(final ChannelJoinEvent event) {
296
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
296
+        final String filename = locator.getLogFile(event.getChannel());
297 297
         final GroupChatUser channelClient = event.getClient();
298 298
         appendLine(filename, "*** %s (%s) joined the channel", getDisplayName(channelClient),
299 299
                 channelClient.getNickname());
@@ -301,7 +301,7 @@ public class LoggingManager implements ConfigChangeListener {
301 301
 
302 302
     @Handler
303 303
     public void handleChannelPart(final ChannelPartEvent event) {
304
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
304
+        final String filename = locator.getLogFile(event.getChannel());
305 305
         final String message = event.getMessage();
306 306
         final GroupChatUser channelClient = event.getClient();
307 307
         if (message.isEmpty()) {
@@ -315,7 +315,7 @@ public class LoggingManager implements ConfigChangeListener {
315 315
 
316 316
     @Handler
317 317
     public void handleChannelQuit(final ChannelQuitEvent event) {
318
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
318
+        final String filename = locator.getLogFile(event.getChannel());
319 319
         final String reason = event.getMessage();
320 320
         final GroupChatUser channelClient = event.getClient();
321 321
         if (reason.isEmpty()) {
@@ -332,7 +332,7 @@ public class LoggingManager implements ConfigChangeListener {
332 332
         final GroupChatUser victim = event.getVictim();
333 333
         final GroupChatUser perpetrator = event.getClient();
334 334
         final String reason = event.getReason();
335
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
335
+        final String filename = locator.getLogFile(event.getChannel());
336 336
 
337 337
         if (reason.isEmpty()) {
338 338
             appendLine(filename, "*** %s was kicked by %s",
@@ -345,14 +345,14 @@ public class LoggingManager implements ConfigChangeListener {
345 345
 
346 346
     @Handler
347 347
     public void handleNickChange(final ChannelNickChangeEvent event) {
348
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
348
+        final String filename = locator.getLogFile(event.getChannel());
349 349
         appendLine(filename, "*** %s is now %s", getDisplayName(event.getClient(),
350 350
                 event.getOldNick()), getDisplayName(event.getClient()));
351 351
     }
352 352
 
353 353
     @Handler
354 354
     public void handleModeChange(final ChannelModeChangeEvent event) {
355
-        final String filename = locator.getLogFile(event.getChannel().getChannelInfo());
355
+        final String filename = locator.getLogFile(event.getChannel());
356 356
         if (event.getClient().getNickname().isEmpty()) {
357 357
             appendLine(filename, "*** Channel modes are: %s", event.getModes());
358 358
         } else {
@@ -371,7 +371,7 @@ public class LoggingManager implements ConfigChangeListener {
371 371
         final String filename = locator.getLogFile(event.getChannel().getName());
372 372
 
373 373
         if (autobackbuffer) {
374
-            showBackBuffer(event.getChannel(), filename);
374
+            showBackBuffer(event.getChannel().getWindowModel(), filename);
375 375
         }
376 376
 
377 377
         synchronized (FORMAT_LOCK) {

+ 4
- 4
ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.commands;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
28 27
 import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
@@ -36,6 +35,7 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
36 35
 import com.dmdirc.commandparser.commands.context.ChannelCommandContext;
37 36
 import com.dmdirc.commandparser.commands.context.CommandContext;
38 37
 import com.dmdirc.interfaces.CommandController;
38
+import com.dmdirc.interfaces.GroupChat;
39 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
40 40
 
41 41
 import javax.annotation.Nonnull;
@@ -51,7 +51,7 @@ public class ChannelSettings extends Command implements IntelligentCommand {
51 51
     public static final CommandInfo INFO = new BaseCommandInfo("channelsettings",
52 52
             "channelsettings - opens the channel settings window", CommandType.TYPE_CHANNEL);
53 53
     /** The controller to use to show the settings window. */
54
-    private final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider;
54
+    private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;
55 55
 
56 56
     /**
57 57
      * Creates a new instance of the {@link ChannelSettings} command.
@@ -62,7 +62,7 @@ public class ChannelSettings extends Command implements IntelligentCommand {
62 62
     @Inject
63 63
     public ChannelSettings(
64 64
             final CommandController commandController,
65
-            final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider) {
65
+            final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider) {
66 66
         super(commandController);
67 67
         this.dialogProvider = dialogProvider;
68 68
     }
@@ -70,7 +70,7 @@ public class ChannelSettings extends Command implements IntelligentCommand {
70 70
     @Override
71 71
     public void execute(@Nonnull final FrameContainer origin,
72 72
             final CommandArguments args, final CommandContext context) {
73
-        dialogProvider.displayOrRequestFocus(((ChannelCommandContext) context).getChannel());
73
+        dialogProvider.displayOrRequestFocus(((ChannelCommandContext) context).getGroupChat());
74 74
     }
75 75
 
76 76
     @Override

+ 15
- 17
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.DMDircMBassador;
27 26
 import com.dmdirc.ServerState;
28 27
 import com.dmdirc.addons.ui_swing.EDTInvocation;
@@ -58,7 +57,7 @@ import net.engio.mbassy.listener.Handler;
58 57
 import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT;
59 58
 
60 59
 /**
61
- * The channel frame is the GUI component that represents a channel to the user.
60
+ * The groupChat frame is the GUI component that represents a groupChat to the user.
62 61
  */
63 62
 public final class ChannelFrame extends InputTextFrame {
64 63
 
@@ -79,9 +78,9 @@ public final class ChannelFrame extends InputTextFrame {
79 78
     /** Config to read settings from. */
80 79
     private final AggregateConfigProvider globalConfig;
81 80
     /** Channel settings dialog provider. */
82
-    private final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider;
83
-    /** Channel instance. */
84
-    private final Channel channel;
81
+    private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;
82
+    /** Group chat instance. */
83
+    private final GroupChat groupChat;
85 84
     /** Config binder. */
86 85
     private final ConfigBinder binder;
87 86
 
@@ -91,33 +90,33 @@ public final class ChannelFrame extends InputTextFrame {
91 90
      *
92 91
      * @param deps               The dependencies required by text frames.
93 92
      * @param inputFieldProvider The provider to use to create a new input field.
94
-     * @param identityFactory    The factory to use to create a channel identity.
93
+     * @param identityFactory    The factory to use to create a group chat identity.
95 94
      * @param topicBarFactory    The factory to use to create topic bars.
96
-     * @param owner              The Channel object that owns this frame
95
+     * @param owner              The group chat object that owns this frame
97 96
      * @param domain             The domain to read settings from
98
-     * @param dialogProvider     The dialog provider to get the channel settings dialog from.
97
+     * @param dialogProvider     The dialog provider to get the group chat settings dialog from.
99 98
      */
100 99
     public ChannelFrame(
101 100
             final String domain,
102 101
             final TextFrameDependencies deps,
103 102
             final Provider<SwingInputField> inputFieldProvider,
104 103
             final IdentityFactory identityFactory,
105
-            final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider,
104
+            final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider,
106 105
             final InputTextFramePasteActionFactory inputTextFramePasteActionFactory,
107 106
             final TopicBarFactory topicBarFactory,
108
-            final Channel owner) {
109
-        super(deps, inputFieldProvider, inputTextFramePasteActionFactory, owner);
107
+            final GroupChat owner) {
108
+        super(deps, inputFieldProvider, inputTextFramePasteActionFactory, owner.getWindowModel());
110 109
 
111 110
         this.eventBus = deps.eventBus;
112 111
         this.globalConfig = deps.globalConfig;
113 112
         this.dialogProvider = dialogProvider;
114
-        this.channel = owner;
113
+        this.groupChat = owner;
115 114
 
116 115
         initComponents(topicBarFactory, deps.colourManagerFactory);
117 116
         binder = getContainer().getConfigManager().getBinder().withDefaultDomain(domain);
118 117
 
119 118
         identity = identityFactory.createChannelConfig(owner.getConnection().get().getNetwork(),
120
-                owner.getChannelInfo().getName());
119
+                owner.getName());
121 120
     }
122 121
 
123 122
     /**
@@ -142,8 +141,7 @@ public final class ChannelFrame extends InputTextFrame {
142 141
 
143 142
         nicklist = new NickList(this, getContainer().getConfigManager(), colourManagerFactory);
144 143
         settingsMI = new JMenuItem("Settings");
145
-        settingsMI.addActionListener(l ->
146
-                dialogProvider.displayOrRequestFocus((Channel) getContainer()));
144
+        settingsMI.addActionListener(l -> dialogProvider.displayOrRequestFocus(groupChat));
147 145
 
148 146
         splitPane = new SplitPane(globalConfig, SplitPane.Orientation.HORIZONTAL);
149 147
 
@@ -212,7 +210,7 @@ public final class ChannelFrame extends InputTextFrame {
212 210
 
213 211
     @Override
214 212
     public void addCustomPopupItems(final JPopupMenu popupMenu) {
215
-        if (channel.getConnection().get().getState() == ServerState.CONNECTED) {
213
+        if (groupChat.getConnection().get().getState() == ServerState.CONNECTED) {
216 214
             settingsMI.setEnabled(true);
217 215
         } else {
218 216
             settingsMI.setEnabled(false);
@@ -228,7 +226,7 @@ public final class ChannelFrame extends InputTextFrame {
228 226
     public void windowClosing(final FrameClosingEvent event) {
229 227
         saveSplitPanePosition();
230 228
         topicBar.close();
231
-        dialogProvider.dispose(channel);
229
+        dialogProvider.dispose(groupChat);
232 230
         super.windowClosing(event);
233 231
     }
234 232
 

+ 5
- 4
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrameFactory.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.DMDircMBassador;
27 26
 import com.dmdirc.FrameContainer;
28 27
 import com.dmdirc.addons.ui_swing.SwingController;
@@ -31,6 +30,7 @@ import com.dmdirc.addons.ui_swing.components.TopicBarFactory;
31 30
 import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
32 31
 import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog;
33 32
 import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
33
+import com.dmdirc.interfaces.GroupChat;
34 34
 import com.dmdirc.interfaces.config.IdentityFactory;
35 35
 import com.dmdirc.plugins.PluginDomain;
36 36
 import com.dmdirc.ui.core.components.WindowComponent;
@@ -56,7 +56,7 @@ public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider {
56 56
     private final Provider<SwingInputField> inputFieldProvider;
57 57
     private final IdentityFactory identityFactory;
58 58
     private final InputTextFramePasteActionFactory inputTextFramePasteActionFactory;
59
-    private final Provider<KeyedDialogProvider<Channel, ChannelSettingsDialog>> dialogProvider;
59
+    private final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider;
60 60
     private final TopicBarFactory topicBarFactory;
61 61
     private final DMDircMBassador eventBus;
62 62
 
@@ -68,7 +68,7 @@ public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider {
68 68
             final Provider<SwingInputField> inputFieldProvider,
69 69
             final InputTextFramePasteActionFactory inputTextFramePasteActionFactory,
70 70
             final IdentityFactory identityFactory,
71
-            final Provider<KeyedDialogProvider<Channel, ChannelSettingsDialog>> dialogProvider,
71
+            final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider,
72 72
             final TopicBarFactory topicBarFactory) {
73 73
         this.eventBus = eventBus;
74 74
         this.domain = domain;
@@ -84,7 +84,8 @@ public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider {
84 84
     public TextFrame getWindow(final FrameContainer container) {
85 85
         final ChannelFrame frame = new ChannelFrame(domain, dependencies.get(), inputFieldProvider,
86 86
                 identityFactory, dialogProvider.get(), inputTextFramePasteActionFactory,
87
-                topicBarFactory, (Channel) container);
87
+                topicBarFactory, (GroupChat) container);
88
+                // TODO: Can't assume containers are GroupChats...
88 89
         eventBus.subscribe(frame);
89 90
         return frame;
90 91
     }

+ 3
- 7
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/DesktopWindowFrame.java Целия файл

@@ -23,11 +23,10 @@
23 23
 package com.dmdirc.addons.ui_swing.components.frames;
24 24
 
25 25
 import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
26
+import com.dmdirc.addons.ui_swing.components.IconManager;
26 27
 import com.dmdirc.events.FrameIconChangedEvent;
27 28
 import com.dmdirc.events.FrameTitleChangedEvent;
28
-import com.dmdirc.addons.ui_swing.components.IconManager;
29
-
30
-import java.awt.Point;
29
+import com.dmdirc.ui.CoreUIUtils;
31 30
 
32 31
 import javax.swing.JFrame;
33 32
 
@@ -46,8 +45,6 @@ public class DesktopWindowFrame extends JFrame {
46 45
     /** TextFrame associated with this popout window. */
47 46
     private final TextFrame windowWindow;
48 47
     private final IconManager iconManager;
49
-    /** Initial location for popped out window. */
50
-    private final Point initialLocation;
51 48
 
52 49
     /**
53 50
      * Creates a new instance of DesktopWindowFrame.
@@ -57,7 +54,6 @@ public class DesktopWindowFrame extends JFrame {
57 54
     public DesktopWindowFrame(final TextFrame windowWindow, final IconManager iconManager) {
58 55
         this.windowWindow = windowWindow;
59 56
         this.iconManager = iconManager;
60
-        initialLocation = windowWindow.getLocationOnScreen();
61 57
 
62 58
         setLayout(new MigLayout("fill, ins rel"));
63 59
         add(windowWindow, "grow");
@@ -71,8 +67,8 @@ public class DesktopWindowFrame extends JFrame {
71 67
      */
72 68
     public void display() {
73 69
         pack();
70
+        CoreUIUtils.centreWindow(this);
74 71
         setVisible(true);
75
-        setLocation(initialLocation);
76 72
     }
77 73
 
78 74
     @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously)

+ 2
- 2
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Целия файл

@@ -182,9 +182,9 @@ public abstract class TextFrame extends JPanel implements Window, TextPaneListen
182 182
             popoutFrame.dispose();
183 183
             eventBus.unsubscribe(popoutFrame);
184 184
             popoutFrame = null;
185
-            // TODO: This is a horrible hack really.
186
-            swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(Optional.of(this)));
187 185
         }
186
+        // TODO: This is a horrible hack really.
187
+        swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(Optional.of(this)));
188 188
     }
189 189
 
190 190
     /**

+ 6
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.menubar;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.FrameContainer;
27 26
 import com.dmdirc.ServerState;
28 27
 import com.dmdirc.addons.ui_swing.MainFrame;
@@ -34,6 +33,7 @@ import com.dmdirc.addons.ui_swing.injection.DialogProvider;
34 33
 import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider;
35 34
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
36 35
 import com.dmdirc.interfaces.Connection;
36
+import com.dmdirc.interfaces.GroupChat;
37 37
 import com.dmdirc.parser.common.ChannelJoinRequest;
38 38
 import com.dmdirc.addons.ui_swing.components.IconManager;
39 39
 
@@ -60,7 +60,7 @@ public class ChannelMenu extends JMenu implements MenuListener {
60 60
     /** Main frame. */
61 61
     private final MainFrame mainFrame;
62 62
     /** Dialog provider. */
63
-    private final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider;
63
+    private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;
64 64
     /** Channel list dialog provider. */
65 65
     private final DialogProvider<ChannelListDialog> channelListDialogProvider;
66 66
     /** Active frame manager. */
@@ -73,7 +73,7 @@ public class ChannelMenu extends JMenu implements MenuListener {
73 73
     @Inject
74 74
     public ChannelMenu(
75 75
             final ActiveFrameManager activeFrameManager,
76
-            final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider,
76
+            final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider,
77 77
             final MainFrame mainFrame,
78 78
             final IconManager iconManager,
79 79
             final DialogProvider<ChannelListDialog> channelListDialogProvider) {
@@ -121,8 +121,9 @@ public class ChannelMenu extends JMenu implements MenuListener {
121 121
 
122 122
     private void showChannelSettings() {
123 123
         activeFrameManager.getActiveFrame().ifPresent(f -> {
124
-            if (f.getContainer() instanceof Channel) {
125
-                dialogProvider.displayOrRequestFocus((Channel) f.getContainer());
124
+            // TODO: Can't assume containers will be group chats.
125
+            if (f.getContainer() instanceof GroupChat) {
126
+                dialogProvider.displayOrRequestFocus((GroupChat) f.getContainer());
126 127
             }
127 128
         });
128 129
     }

+ 25
- 19
ui_swing/src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java Целия файл

@@ -22,74 +22,75 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.modes;
24 24
 
25
-import com.dmdirc.Channel;
26
-import com.dmdirc.parser.interfaces.Parser;
27 25
 import com.dmdirc.addons.ui_swing.components.IconManager;
26
+import com.dmdirc.interfaces.GroupChat;
27
+import com.dmdirc.parser.interfaces.Parser;
28 28
 
29 29
 /** Non list mode panel. */
30 30
 public final class ChannelModesPane extends ModesPane {
31 31
 
32 32
     /** Serial version UID. */
33 33
     private static final long serialVersionUID = 1;
34
-    /** Parent channel. */
35
-    private final Channel channel;
34
+    /** Parent group chat. */
35
+    private final GroupChat groupChat;
36 36
 
37 37
     /**
38 38
      * Creates a new instance of ChannelModesPane.
39 39
      *
40
-     * @param channel Parent channel
40
+     * @param groupChat Parent group chat
41 41
      * @param iconManager The icon manager to use
42 42
      */
43
-    public ChannelModesPane(final Channel channel, final IconManager iconManager) {
44
-        super(channel.getConfigManager(), iconManager);
43
+    public ChannelModesPane(final GroupChat groupChat, final IconManager iconManager) {
44
+        super(groupChat.getWindowModel().getConfigManager(), iconManager);
45 45
 
46
-        this.channel = channel;
46
+        this.groupChat = groupChat;
47 47
         initModesPanel();
48 48
     }
49 49
 
50 50
     @Override
51 51
     public boolean hasModeValue(final String mode) {
52
-        return channel.getWindowModel().getConfigManager().hasOptionString("server", "mode" + mode);
52
+        return groupChat.getWindowModel().getConfigManager().hasOptionString("server",
53
+                "mode" + mode);
53 54
     }
54 55
 
55 56
     @Override
56 57
     public String getModeValue(final String mode) {
57
-        return channel.getWindowModel().getConfigManager().getOption("server", "mode" + mode);
58
+        return groupChat.getWindowModel().getConfigManager().getOption("server", "mode" + mode);
58 59
     }
59 60
 
60 61
     @Override
61 62
     public boolean isModeEnabled(final String mode) {
62
-        return !channel.getWindowModel().getConfigManager().hasOptionString("server",
63
-                "enablemode" + mode) || channel.getWindowModel().getConfigManager()
63
+        return !groupChat.getWindowModel().getConfigManager().hasOptionString("server",
64
+                "enablemode" + mode) || groupChat.getWindowModel().getConfigManager()
64 65
                 .getOptionBool("server", "enablemode" + mode);
65 66
     }
66 67
 
67 68
     @Override
68 69
     public boolean isModeSettable(final String mode) {
69
-        return channel.getConnection().get().getParser().get().isUserSettable(mode.toCharArray()
70
+        return groupChat.getConnection().get().getParser().get().isUserSettable(mode.toCharArray()
70 71
                 [0]);
71 72
     }
72 73
 
73 74
     @Override
74 75
     public String getAvailableBooleanModes() {
75
-        return channel.getConnection().get().getParser().get().getBooleanChannelModes();
76
+        return groupChat.getConnection().get().getParser().get().getBooleanChannelModes();
76 77
     }
77 78
 
78 79
     @Override
79 80
     public String getOurBooleanModes() {
80
-        return channel.getChannelInfo().getModes();
81
+        return groupChat.getModes();
81 82
     }
82 83
 
83 84
     @Override
84 85
     public String getAllParamModes() {
85
-        final Parser parser = channel.getConnection().get().getParser().get();
86
+        final Parser parser = groupChat.getConnection().get().getParser().get();
86 87
         return parser.getParameterChannelModes()
87 88
                 + parser.getDoubleParameterChannelModes();
88 89
     }
89 90
 
90 91
     @Override
91 92
     public String getParamModeValue(final String mode) {
92
-        return channel.getChannelInfo().getMode(mode.charAt(0));
93
+        return groupChat.getModeValue(mode.charAt(0));
93 94
     }
94 95
 
95 96
     @Override
@@ -101,12 +102,17 @@ public final class ChannelModesPane extends ModesPane {
101 102
         } else {
102 103
             state = getParamModes().get(mode).getState();
103 104
         }
104
-        channel.getChannelInfo().alterMode(state, mode.charAt(0), parameter);
105
+
106
+        if (state) {
107
+            groupChat.setMode(mode.charAt(0), parameter);
108
+        } else {
109
+            groupChat.removeMode(mode.charAt(0), parameter);
110
+        }
105 111
     }
106 112
 
107 113
     @Override
108 114
     public void flushModes() {
109
-        channel.getChannelInfo().flushModes();
115
+        groupChat.flushModes();
110 116
     }
111 117
 
112 118
 }

+ 26
- 23
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java Целия файл

@@ -22,15 +22,15 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.channelsetting;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.addons.ui_swing.UIUtilities;
26
+import com.dmdirc.addons.ui_swing.components.IconManager;
27 27
 import com.dmdirc.addons.ui_swing.components.renderers.ListModeCellRenderer;
28 28
 import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog;
29
+import com.dmdirc.interfaces.GroupChat;
29 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30 31
 import com.dmdirc.interfaces.config.ConfigChangeListener;
31 32
 import com.dmdirc.interfaces.config.ConfigProvider;
32 33
 import com.dmdirc.parser.common.ChannelListModeItem;
33
-import com.dmdirc.addons.ui_swing.components.IconManager;
34 34
 import com.dmdirc.util.collections.MapList;
35 35
 import com.dmdirc.util.validators.NotEmptyValidator;
36 36
 
@@ -70,8 +70,8 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
70 70
 
71 71
     /** A version number for this class. */
72 72
     private static final long serialVersionUID = 5;
73
-    /** Channel. */
74
-    private final Channel channel;
73
+    /** Group chat. */
74
+    private final GroupChat groupChat;
75 75
     /** Combox box used to switch between list modes. */
76 76
     private final JComboBox<String> listModesMenu;
77 77
     /** Arraylist of jpanels containing the listmodes. */
@@ -111,33 +111,34 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
111 111
      * @param globalConfig The config to read settings from.
112 112
      * @param userConfig   The config to write settings to.
113 113
      * @param iconManager  The manager to use to retrieve icons for dialogs and validation.
114
-     * @param channel      Parent channel
114
+     * @param groupChat    Parent group chat
115 115
      * @param parentWindow Parent window
116 116
      */
117 117
     public ChannelListModesPane(
118 118
             final AggregateConfigProvider globalConfig,
119 119
             final ConfigProvider userConfig,
120 120
             final IconManager iconManager,
121
-            final Channel channel,
121
+            final GroupChat groupChat,
122 122
             final Window parentWindow) {
123 123
 
124 124
         this.globalConfig = checkNotNull(globalConfig);
125 125
         this.userConfig = checkNotNull(userConfig);
126 126
         this.iconManager = checkNotNull(iconManager);
127
-        this.channel = checkNotNull(channel);
127
+        this.groupChat = checkNotNull(groupChat);
128 128
         this.parentWindow = checkNotNull(parentWindow);
129 129
         setOpaque(UIUtilities.getTabbedPaneOpaque());
130 130
 
131 131
         list = new JList<>();
132 132
         nativeRenderer = list.getCellRenderer();
133
-        if (channel.getConfigManager().getOptionBool("general", "extendedListModes")) {
133
+        if (groupChat.getWindowModel().getConfigManager()
134
+                .getOptionBool("general", "extendedListModes")) {
134 135
             renderer = new ExtendedListModeCellRenderer();
135 136
         } else {
136 137
             renderer = new ListModeCellRenderer(nativeRenderer);
137 138
         }
138 139
         listModesPanel = new JScrollPane();
139 140
         listModesPanels = new ArrayList<>();
140
-        listModesArray = channel.getConnection().get().getParser().get()
141
+        listModesArray = groupChat.getConnection().get().getParser().get()
141 142
                 .getListChannelModes().toCharArray();
142 143
         existingListItems = new MapList<>();
143 144
         listModesMenu = new JComboBox<>(new DefaultComboBoxModel<>());
@@ -145,8 +146,8 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
145 146
         removeListModeButton = new JButton("Remove");
146 147
         removeListModeButton.setEnabled(false);
147 148
         modeCount = new JLabel();
148
-        toggle = new JCheckBox("Show extended information",
149
-                channel.getConfigManager().getOptionBool("general", "extendedListModes"));
149
+        toggle = new JCheckBox("Show extended information", groupChat.getWindowModel()
150
+                .getConfigManager().getOptionBool("general", "extendedListModes"));
150 151
         toggle.setOpaque(UIUtilities.getTabbedPaneOpaque());
151 152
 
152 153
         initListModesPanel();
@@ -157,13 +158,13 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
157 158
     public void update() {
158 159
         existingListItems.clear();
159 160
 
160
-        if (channel.getChannelInfo() == null) {
161
+        if (!groupChat.isOnChannel()) {
161 162
             return;
162 163
         }
164
+
163 165
         for (int i = 0; i < listModesArray.length; i++) {
164 166
             final char mode = listModesArray[i];
165
-            final Collection<ChannelListModeItem> listItems = channel
166
-                    .getChannelInfo().getListMode(mode);
167
+            final Collection<ChannelListModeItem> listItems = groupChat.getListModeItems(mode);
167 168
             if (listItems == null) {
168 169
                 continue;
169 170
             }
@@ -191,8 +192,9 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
191 192
                 getModel();
192 193
         for (char mode : listModesArray) {
193 194
             String modeText = mode + " list";
194
-            if (channel.getConfigManager().hasOptionString("server", "mode" + mode)) {
195
-                modeText = channel.getConfigManager().getOption("server",
195
+            if (groupChat.getWindowModel().getConfigManager()
196
+                    .hasOptionString("server", "mode" + mode)) {
197
+                modeText = groupChat.getWindowModel().getConfigManager().getOption("server",
196 198
                         "mode" + mode) + " list [+" + mode + ']';
197 199
             }
198 200
             model.addElement(modeText);
@@ -236,7 +238,8 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
236 238
         removeListModeButton.addActionListener(this);
237 239
         listModesMenu.addActionListener(this);
238 240
         toggle.addActionListener(this);
239
-        channel.getConfigManager().addChangeListener("general", "extendedListModes", this);
241
+        groupChat.getWindowModel().getConfigManager()
242
+                .addChangeListener("general", "extendedListModes", this);
240 243
 
241 244
     }
242 245
 
@@ -266,15 +269,15 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
266 269
             if (currentModes.containsKey(entry.getKey())) {
267 270
                 currentModes.remove(entry.getKey());
268 271
             } else {
269
-                channel.getChannelInfo().alterMode(true, entry.getValue(), entry.getKey().getItem());
272
+                groupChat.setMode(entry.getValue(), entry.getKey().getItem());
270 273
             }
271 274
         }
272 275
 
273 276
         for (Entry<ChannelListModeItem, Character> entry : currentModes.entrySet()) {
274
-            channel.getChannelInfo().alterMode(false, entry.getValue(), entry.getKey().getItem());
277
+            groupChat.removeMode(entry.getValue(), entry.getKey().getItem());
275 278
         }
276 279
 
277
-        channel.getChannelInfo().flushModes();
280
+        groupChat.flushModes();
278 281
         userConfig.setOption("general", "extendedListModes", toggle.isSelected());
279 282
     }
280 283
 
@@ -282,9 +285,9 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
282 285
     private void addListMode() {
283 286
         final int selectedIndex = listModesMenu.getSelectedIndex();
284 287
         String modeText = String.valueOf(listModesArray[selectedIndex]);
285
-        if (channel.getConfigManager().hasOptionString("server", "mode"
288
+        if (groupChat.getWindowModel().getConfigManager().hasOptionString("server", "mode"
286 289
                 + listModesArray[selectedIndex])) {
287
-            modeText = channel.getConfigManager().
290
+            modeText = groupChat.getWindowModel().getConfigManager().
288 291
                     getOption("server", "mode" + listModesArray[selectedIndex]);
289 292
         }
290 293
         new StandardInputDialog(parentWindow, ModalityType.DOCUMENT_MODAL,
@@ -354,7 +357,7 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
354 357
 
355 358
         final int selected = listModesMenu.getSelectedIndex();
356 359
         final int current = listModesPanels.get(selected).getModel().getSize();
357
-        final int maxModes = channel.getConnection().get().getParser().get().
360
+        final int maxModes = groupChat.getConnection().get().getParser().get().
358 361
                 getMaxListModes(listModesArray[selected]);
359 362
 
360 363
         if (maxModes == -1) {

+ 9
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java Целия файл

@@ -22,21 +22,21 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.dialogs.channelsetting;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.DMDircMBassador;
27 26
 import com.dmdirc.addons.ui_swing.PrefsComponentFactory;
28 27
 import com.dmdirc.addons.ui_swing.SwingWindowFactory;
29 28
 import com.dmdirc.addons.ui_swing.UIUtilities;
29
+import com.dmdirc.addons.ui_swing.components.IconManager;
30 30
 import com.dmdirc.addons.ui_swing.components.expandingsettings.SettingsPanel;
31 31
 import com.dmdirc.addons.ui_swing.components.modes.ChannelModesPane;
32 32
 import com.dmdirc.addons.ui_swing.dialogs.StandardDialog;
33 33
 import com.dmdirc.config.prefs.PreferencesManager;
34 34
 import com.dmdirc.interfaces.CommandController;
35
+import com.dmdirc.interfaces.GroupChat;
35 36
 import com.dmdirc.interfaces.config.ConfigProvider;
36 37
 import com.dmdirc.interfaces.config.IdentityFactory;
37 38
 import com.dmdirc.interfaces.ui.InputWindow;
38 39
 import com.dmdirc.plugins.ServiceManager;
39
-import com.dmdirc.addons.ui_swing.components.IconManager;
40 40
 import com.dmdirc.ui.input.TabCompleterUtils;
41 41
 import com.dmdirc.ui.messages.ColourManagerFactory;
42 42
 
@@ -62,7 +62,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
62 62
     /** Serial version UID. */
63 63
     private static final long serialVersionUID = 8;
64 64
     /** The channel object that this dialog belongs to. */
65
-    private final Channel channel;
65
+    private final GroupChat channel;
66 66
     /** Channel identity file. */
67 67
     private final ConfigProvider identity;
68 68
     /** Channel window. */
@@ -104,7 +104,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
104 104
      * @param serviceManager     Service manager
105 105
      * @param preferencesManager Preferences Manager
106 106
      * @param compFactory        Preferences setting component factory
107
-     * @param channel            The channel object that we're editing settings for
107
+     * @param groupChat          The group chat object that we're editing settings for
108 108
      * @param parentWindow       Parent window
109 109
      * @param clipboard          Clipboard to copy and paste from
110 110
      * @param commandController  The controller to use to retrieve command information.
@@ -117,7 +117,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
117 117
             final ServiceManager serviceManager,
118 118
             final PreferencesManager preferencesManager,
119 119
             final PrefsComponentFactory compFactory,
120
-            final Channel channel,
120
+            final GroupChat groupChat,
121 121
             final Window parentWindow,
122 122
             final Clipboard clipboard,
123 123
             final CommandController commandController,
@@ -131,17 +131,16 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
131 131
         this.serviceManager = checkNotNull(serviceManager);
132 132
         this.preferencesManager = checkNotNull(preferencesManager);
133 133
         this.compFactory = checkNotNull(compFactory);
134
-        this.channel = checkNotNull(channel);
134
+        this.channel = checkNotNull(groupChat);
135 135
         this.clipboard = clipboard;
136 136
         this.commandController = checkNotNull(commandController);
137 137
         this.eventBus = eventBus;
138 138
         this.colourManagerFactory = colourManagerFactory;
139 139
         this.iconManager = iconManager;
140 140
 
141
-        identity = identityFactory.createChannelConfig(
142
-                channel.getConnection().get().getNetwork(),
143
-                channel.getChannelInfo().getName());
144
-        channelWindow = (InputWindow) windowFactory.getSwingWindow(channel);
141
+        identity = identityFactory.createChannelConfig(groupChat.getConnection().get().getNetwork(),
142
+                groupChat.getName());
143
+        channelWindow = (InputWindow) windowFactory.getSwingWindow(groupChat.getWindowModel());
145 144
 
146 145
         initComponents(tabCompleterUtils);
147 146
         initListeners();

+ 4
- 0
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profile/ProfileManagerController.java Целия файл

@@ -285,6 +285,10 @@ public class ProfileManagerController implements ProfilesDialogModelListener {
285 285
         } else {
286 286
             selectionModel.setLeadSelectionIndex(-1);
287 287
         }
288
+        addNickname.setEnabled(model.getSelectedProfile().isPresent());
289
+        editNickname.setEnabled(model.getSelectedProfile().isPresent());
290
+        addHighlight.setEnabled(model.getSelectedProfile().isPresent());
291
+        editHighlight.setEnabled(model.getSelectedProfile().isPresent());
288 292
         name.setEnabled(model.getSelectedProfile().isPresent());
289 293
         name.setText(model.getSelectedProfileName().orElse(""));
290 294
         nicknames.setEnabled(model.getSelectedProfile().isPresent());

+ 4
- 4
ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.injection;
24 24
 
25
-import com.dmdirc.Channel;
26 25
 import com.dmdirc.ClientModule.UserConfig;
27 26
 import com.dmdirc.DMDircMBassador;
28 27
 import com.dmdirc.addons.ui_swing.MainFrame;
@@ -44,6 +43,7 @@ import com.dmdirc.commandparser.auto.AutoCommandManager;
44 43
 import com.dmdirc.config.prefs.PreferencesManager;
45 44
 import com.dmdirc.interfaces.CommandController;
46 45
 import com.dmdirc.interfaces.Connection;
46
+import com.dmdirc.interfaces.GroupChat;
47 47
 import com.dmdirc.interfaces.LifecycleController;
48 48
 import com.dmdirc.interfaces.config.ConfigProvider;
49 49
 import com.dmdirc.interfaces.config.IdentityFactory;
@@ -186,7 +186,7 @@ public class DialogModule {
186 186
 
187 187
     @Provides
188 188
     @Singleton
189
-    public KeyedDialogProvider<Channel, ChannelSettingsDialog> getChannelSettingsDialogProvider(
189
+    public KeyedDialogProvider<GroupChat, ChannelSettingsDialog> getChannelSettingsDialogProvider(
190 190
             final IdentityFactory identityFactory,
191 191
             final SwingWindowFactory windowFactory,
192 192
             @UserConfig final ConfigProvider userConfig,
@@ -200,9 +200,9 @@ public class DialogModule {
200 200
             final ColourManagerFactory colourManagerFactory,
201 201
             final TabCompleterUtils tabCompleterUtils,
202 202
             final IconManager iconManager) {
203
-        return new KeyedDialogProvider<Channel, ChannelSettingsDialog>() {
203
+        return new KeyedDialogProvider<GroupChat, ChannelSettingsDialog>() {
204 204
             @Override
205
-            protected ChannelSettingsDialog getInstance(final Channel key) {
205
+            protected ChannelSettingsDialog getInstance(final GroupChat key) {
206 206
                 return new ChannelSettingsDialog(identityFactory, windowFactory,
207 207
                         userConfig, serviceManager, preferencesManager, compFactory, key,
208 208
                         parentWindow, clipboard, commandController, eventBus,

Loading…
Отказ
Запис