From abdfd78f1ec1757087693294fa0db6933af059b7 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Wed, 14 Jan 2015 15:04:52 +0000 Subject: [PATCH 1/6] Fix a couple of bugs in the popup windows. --- .../ui_swing/components/frames/DesktopWindowFrame.java | 10 +++------- .../addons/ui_swing/components/frames/TextFrame.java | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/DesktopWindowFrame.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/DesktopWindowFrame.java index 5edaae50b..8163e9a5b 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/DesktopWindowFrame.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/DesktopWindowFrame.java @@ -23,11 +23,10 @@ package com.dmdirc.addons.ui_swing.components.frames; import com.dmdirc.addons.ui_swing.EdtHandlerInvocation; +import com.dmdirc.addons.ui_swing.components.IconManager; import com.dmdirc.events.FrameIconChangedEvent; import com.dmdirc.events.FrameTitleChangedEvent; -import com.dmdirc.addons.ui_swing.components.IconManager; - -import java.awt.Point; +import com.dmdirc.ui.CoreUIUtils; import javax.swing.JFrame; @@ -46,8 +45,6 @@ public class DesktopWindowFrame extends JFrame { /** TextFrame associated with this popout window. */ private final TextFrame windowWindow; private final IconManager iconManager; - /** Initial location for popped out window. */ - private final Point initialLocation; /** * Creates a new instance of DesktopWindowFrame. @@ -57,7 +54,6 @@ public class DesktopWindowFrame extends JFrame { public DesktopWindowFrame(final TextFrame windowWindow, final IconManager iconManager) { this.windowWindow = windowWindow; this.iconManager = iconManager; - initialLocation = windowWindow.getLocationOnScreen(); setLayout(new MigLayout("fill, ins rel")); add(windowWindow, "grow"); @@ -71,8 +67,8 @@ public DesktopWindowFrame(final TextFrame windowWindow, final IconManager iconMa */ public void display() { pack(); + CoreUIUtils.centreWindow(this); setVisible(true); - setLocation(initialLocation); } @Handler(invocation = EdtHandlerInvocation.class, delivery = Invoke.Asynchronously) diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java index 20acc18d8..959ca4b26 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java @@ -182,9 +182,9 @@ public void windowClosing(final WindowEvent e) { popoutFrame.dispose(); eventBus.unsubscribe(popoutFrame); popoutFrame = null; - // TODO: This is a horrible hack really. - swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(Optional.of(this))); } + // TODO: This is a horrible hack really. + swingEventBus.publishAsync(new SwingActiveWindowChangeRequestEvent(Optional.of(this))); } /** From f049b30b00f209c063db6fc5ddd06f4a3faa285e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 14 Jan 2015 20:33:32 +0000 Subject: [PATCH 2/6] Remove usages of Channel in the UI. --- .../ui_swing/commands/ChannelSettings.java | 6 +-- .../components/frames/ChannelFrame.java | 32 ++++++------ .../frames/ChannelFrameFactory.java | 9 ++-- .../components/menubar/ChannelMenu.java | 11 +++-- .../components/modes/ChannelModesPane.java | 44 ++++++++++------- .../channelsetting/ChannelListModesPane.java | 49 ++++++++++--------- .../channelsetting/ChannelSettingsDialog.java | 19 ++++--- .../ui_swing/injection/DialogModule.java | 8 +-- 8 files changed, 93 insertions(+), 85 deletions(-) diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java b/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java index 3918dfc41..26d0feb83 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java @@ -22,7 +22,6 @@ package com.dmdirc.addons.ui_swing.commands; -import com.dmdirc.Channel; import com.dmdirc.FrameContainer; import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog; import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider; @@ -36,6 +35,7 @@ import com.dmdirc.commandparser.commands.context.ChannelCommandContext; import com.dmdirc.commandparser.commands.context.CommandContext; import com.dmdirc.interfaces.CommandController; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.ui.input.AdditionalTabTargets; import javax.annotation.Nonnull; @@ -51,7 +51,7 @@ public class ChannelSettings extends Command implements IntelligentCommand { public static final CommandInfo INFO = new BaseCommandInfo("channelsettings", "channelsettings - opens the channel settings window", CommandType.TYPE_CHANNEL); /** The controller to use to show the settings window. */ - private final KeyedDialogProvider dialogProvider; + private final KeyedDialogProvider dialogProvider; /** * Creates a new instance of the {@link ChannelSettings} command. @@ -62,7 +62,7 @@ public class ChannelSettings extends Command implements IntelligentCommand { @Inject public ChannelSettings( final CommandController commandController, - final KeyedDialogProvider dialogProvider) { + final KeyedDialogProvider dialogProvider) { super(commandController); this.dialogProvider = dialogProvider; } diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java index 12ed571bb..d1c675d5e 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrame.java @@ -22,7 +22,6 @@ package com.dmdirc.addons.ui_swing.components.frames; -import com.dmdirc.Channel; import com.dmdirc.DMDircMBassador; import com.dmdirc.ServerState; import com.dmdirc.addons.ui_swing.EDTInvocation; @@ -58,7 +57,7 @@ import static com.dmdirc.addons.ui_swing.SwingPreconditions.checkOnEDT; /** - * The channel frame is the GUI component that represents a channel to the user. + * The groupChat frame is the GUI component that represents a groupChat to the user. */ public final class ChannelFrame extends InputTextFrame { @@ -79,9 +78,9 @@ public final class ChannelFrame extends InputTextFrame { /** Config to read settings from. */ private final AggregateConfigProvider globalConfig; /** Channel settings dialog provider. */ - private final KeyedDialogProvider dialogProvider; - /** Channel instance. */ - private final Channel channel; + private final KeyedDialogProvider dialogProvider; + /** Group chat instance. */ + private final GroupChat groupChat; /** Config binder. */ private final ConfigBinder binder; @@ -91,33 +90,33 @@ public final class ChannelFrame extends InputTextFrame { * * @param deps The dependencies required by text frames. * @param inputFieldProvider The provider to use to create a new input field. - * @param identityFactory The factory to use to create a channel identity. + * @param identityFactory The factory to use to create a group chat identity. * @param topicBarFactory The factory to use to create topic bars. - * @param owner The Channel object that owns this frame + * @param owner The group chat object that owns this frame * @param domain The domain to read settings from - * @param dialogProvider The dialog provider to get the channel settings dialog from. + * @param dialogProvider The dialog provider to get the group chat settings dialog from. */ public ChannelFrame( final String domain, final TextFrameDependencies deps, final Provider inputFieldProvider, final IdentityFactory identityFactory, - final KeyedDialogProvider dialogProvider, + final KeyedDialogProvider dialogProvider, final InputTextFramePasteActionFactory inputTextFramePasteActionFactory, final TopicBarFactory topicBarFactory, - final Channel owner) { - super(deps, inputFieldProvider, inputTextFramePasteActionFactory, owner); + final GroupChat owner) { + super(deps, inputFieldProvider, inputTextFramePasteActionFactory, owner.getWindowModel()); this.eventBus = deps.eventBus; this.globalConfig = deps.globalConfig; this.dialogProvider = dialogProvider; - this.channel = owner; + this.groupChat = owner; initComponents(topicBarFactory, deps.colourManagerFactory); binder = getContainer().getConfigManager().getBinder().withDefaultDomain(domain); identity = identityFactory.createChannelConfig(owner.getConnection().get().getNetwork(), - owner.getChannelInfo().getName()); + owner.getName()); } /** @@ -142,8 +141,7 @@ private void initComponents(final TopicBarFactory topicBarFactory, nicklist = new NickList(this, getContainer().getConfigManager(), colourManagerFactory); settingsMI = new JMenuItem("Settings"); - settingsMI.addActionListener(l -> - dialogProvider.displayOrRequestFocus((Channel) getContainer())); + settingsMI.addActionListener(l -> dialogProvider.displayOrRequestFocus(groupChat)); splitPane = new SplitPane(globalConfig, SplitPane.Orientation.HORIZONTAL); @@ -212,7 +210,7 @@ public PopupType getNormalPopupType() { @Override public void addCustomPopupItems(final JPopupMenu popupMenu) { - if (channel.getConnection().get().getState() == ServerState.CONNECTED) { + if (groupChat.getConnection().get().getState() == ServerState.CONNECTED) { settingsMI.setEnabled(true); } else { settingsMI.setEnabled(false); @@ -228,7 +226,7 @@ public void addCustomPopupItems(final JPopupMenu popupMenu) { public void windowClosing(final FrameClosingEvent event) { saveSplitPanePosition(); topicBar.close(); - dialogProvider.dispose(channel); + dialogProvider.dispose(groupChat); super.windowClosing(event); } diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrameFactory.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrameFactory.java index 3aae9e998..a4ebcf310 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrameFactory.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/ChannelFrameFactory.java @@ -22,7 +22,6 @@ package com.dmdirc.addons.ui_swing.components.frames; -import com.dmdirc.Channel; import com.dmdirc.DMDircMBassador; import com.dmdirc.FrameContainer; import com.dmdirc.addons.ui_swing.SwingController; @@ -31,6 +30,7 @@ import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField; import com.dmdirc.addons.ui_swing.dialogs.channelsetting.ChannelSettingsDialog; import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.interfaces.config.IdentityFactory; import com.dmdirc.plugins.PluginDomain; import com.dmdirc.ui.core.components.WindowComponent; @@ -56,7 +56,7 @@ public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider { private final Provider inputFieldProvider; private final IdentityFactory identityFactory; private final InputTextFramePasteActionFactory inputTextFramePasteActionFactory; - private final Provider> dialogProvider; + private final Provider> dialogProvider; private final TopicBarFactory topicBarFactory; private final DMDircMBassador eventBus; @@ -68,7 +68,7 @@ public ChannelFrameFactory( final Provider inputFieldProvider, final InputTextFramePasteActionFactory inputTextFramePasteActionFactory, final IdentityFactory identityFactory, - final Provider> dialogProvider, + final Provider> dialogProvider, final TopicBarFactory topicBarFactory) { this.eventBus = eventBus; this.domain = domain; @@ -84,7 +84,8 @@ public ChannelFrameFactory( public TextFrame getWindow(final FrameContainer container) { final ChannelFrame frame = new ChannelFrame(domain, dependencies.get(), inputFieldProvider, identityFactory, dialogProvider.get(), inputTextFramePasteActionFactory, - topicBarFactory, (Channel) container); + topicBarFactory, (GroupChat) container); + // TODO: Can't assume containers are GroupChats... eventBus.subscribe(frame); return frame; } diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java index 54148d3ef..2f6d0d7e8 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/menubar/ChannelMenu.java @@ -22,7 +22,6 @@ package com.dmdirc.addons.ui_swing.components.menubar; -import com.dmdirc.Channel; import com.dmdirc.FrameContainer; import com.dmdirc.ServerState; import com.dmdirc.addons.ui_swing.MainFrame; @@ -34,6 +33,7 @@ import com.dmdirc.addons.ui_swing.injection.KeyedDialogProvider; import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager; import com.dmdirc.interfaces.Connection; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.parser.common.ChannelJoinRequest; import com.dmdirc.addons.ui_swing.components.IconManager; @@ -60,7 +60,7 @@ public class ChannelMenu extends JMenu implements MenuListener { /** Main frame. */ private final MainFrame mainFrame; /** Dialog provider. */ - private final KeyedDialogProvider dialogProvider; + private final KeyedDialogProvider dialogProvider; /** Channel list dialog provider. */ private final DialogProvider channelListDialogProvider; /** Active frame manager. */ @@ -73,7 +73,7 @@ public class ChannelMenu extends JMenu implements MenuListener { @Inject public ChannelMenu( final ActiveFrameManager activeFrameManager, - final KeyedDialogProvider dialogProvider, + final KeyedDialogProvider dialogProvider, final MainFrame mainFrame, final IconManager iconManager, final DialogProvider channelListDialogProvider) { @@ -121,8 +121,9 @@ private void joinChannel() { private void showChannelSettings() { activeFrameManager.getActiveFrame().ifPresent(f -> { - if (f.getContainer() instanceof Channel) { - dialogProvider.displayOrRequestFocus((Channel) f.getContainer()); + // TODO: Can't assume containers will be group chats. + if (f.getContainer() instanceof GroupChat) { + dialogProvider.displayOrRequestFocus((GroupChat) f.getContainer()); } }); } diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java b/ui_swing/src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java index 20ec17846..1aaf971d0 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/components/modes/ChannelModesPane.java @@ -22,74 +22,75 @@ package com.dmdirc.addons.ui_swing.components.modes; -import com.dmdirc.Channel; -import com.dmdirc.parser.interfaces.Parser; import com.dmdirc.addons.ui_swing.components.IconManager; +import com.dmdirc.interfaces.GroupChat; +import com.dmdirc.parser.interfaces.Parser; /** Non list mode panel. */ public final class ChannelModesPane extends ModesPane { /** Serial version UID. */ private static final long serialVersionUID = 1; - /** Parent channel. */ - private final Channel channel; + /** Parent group chat. */ + private final GroupChat groupChat; /** * Creates a new instance of ChannelModesPane. * - * @param channel Parent channel + * @param groupChat Parent group chat * @param iconManager The icon manager to use */ - public ChannelModesPane(final Channel channel, final IconManager iconManager) { - super(channel.getConfigManager(), iconManager); + public ChannelModesPane(final GroupChat groupChat, final IconManager iconManager) { + super(groupChat.getWindowModel().getConfigManager(), iconManager); - this.channel = channel; + this.groupChat = groupChat; initModesPanel(); } @Override public boolean hasModeValue(final String mode) { - return channel.getWindowModel().getConfigManager().hasOptionString("server", "mode" + mode); + return groupChat.getWindowModel().getConfigManager().hasOptionString("server", + "mode" + mode); } @Override public String getModeValue(final String mode) { - return channel.getWindowModel().getConfigManager().getOption("server", "mode" + mode); + return groupChat.getWindowModel().getConfigManager().getOption("server", "mode" + mode); } @Override public boolean isModeEnabled(final String mode) { - return !channel.getWindowModel().getConfigManager().hasOptionString("server", - "enablemode" + mode) || channel.getWindowModel().getConfigManager() + return !groupChat.getWindowModel().getConfigManager().hasOptionString("server", + "enablemode" + mode) || groupChat.getWindowModel().getConfigManager() .getOptionBool("server", "enablemode" + mode); } @Override public boolean isModeSettable(final String mode) { - return channel.getConnection().get().getParser().get().isUserSettable(mode.toCharArray() + return groupChat.getConnection().get().getParser().get().isUserSettable(mode.toCharArray() [0]); } @Override public String getAvailableBooleanModes() { - return channel.getConnection().get().getParser().get().getBooleanChannelModes(); + return groupChat.getConnection().get().getParser().get().getBooleanChannelModes(); } @Override public String getOurBooleanModes() { - return channel.getChannelInfo().getModes(); + return groupChat.getModes(); } @Override public String getAllParamModes() { - final Parser parser = channel.getConnection().get().getParser().get(); + final Parser parser = groupChat.getConnection().get().getParser().get(); return parser.getParameterChannelModes() + parser.getDoubleParameterChannelModes(); } @Override public String getParamModeValue(final String mode) { - return channel.getChannelInfo().getMode(mode.charAt(0)); + return groupChat.getModeValue(mode.charAt(0)); } @Override @@ -101,12 +102,17 @@ public void alterMode(final boolean add, final String mode, } else { state = getParamModes().get(mode).getState(); } - channel.getChannelInfo().alterMode(state, mode.charAt(0), parameter); + + if (state) { + groupChat.setMode(mode.charAt(0), parameter); + } else { + groupChat.removeMode(mode.charAt(0), parameter); + } } @Override public void flushModes() { - channel.getChannelInfo().flushModes(); + groupChat.flushModes(); } } diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java index 0384540b3..40993a1ad 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java @@ -22,15 +22,15 @@ package com.dmdirc.addons.ui_swing.dialogs.channelsetting; -import com.dmdirc.Channel; import com.dmdirc.addons.ui_swing.UIUtilities; +import com.dmdirc.addons.ui_swing.components.IconManager; import com.dmdirc.addons.ui_swing.components.renderers.ListModeCellRenderer; import com.dmdirc.addons.ui_swing.dialogs.StandardInputDialog; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.interfaces.config.AggregateConfigProvider; import com.dmdirc.interfaces.config.ConfigChangeListener; import com.dmdirc.interfaces.config.ConfigProvider; import com.dmdirc.parser.common.ChannelListModeItem; -import com.dmdirc.addons.ui_swing.components.IconManager; import com.dmdirc.util.collections.MapList; import com.dmdirc.util.validators.NotEmptyValidator; @@ -70,8 +70,8 @@ public final class ChannelListModesPane extends JPanel implements ActionListener /** A version number for this class. */ private static final long serialVersionUID = 5; - /** Channel. */ - private final Channel channel; + /** Group chat. */ + private final GroupChat groupChat; /** Combox box used to switch between list modes. */ private final JComboBox listModesMenu; /** Arraylist of jpanels containing the listmodes. */ @@ -111,33 +111,34 @@ public final class ChannelListModesPane extends JPanel implements ActionListener * @param globalConfig The config to read settings from. * @param userConfig The config to write settings to. * @param iconManager The manager to use to retrieve icons for dialogs and validation. - * @param channel Parent channel + * @param groupChat Parent group chat * @param parentWindow Parent window */ public ChannelListModesPane( final AggregateConfigProvider globalConfig, final ConfigProvider userConfig, final IconManager iconManager, - final Channel channel, + final GroupChat groupChat, final Window parentWindow) { this.globalConfig = checkNotNull(globalConfig); this.userConfig = checkNotNull(userConfig); this.iconManager = checkNotNull(iconManager); - this.channel = checkNotNull(channel); + this.groupChat = checkNotNull(groupChat); this.parentWindow = checkNotNull(parentWindow); setOpaque(UIUtilities.getTabbedPaneOpaque()); list = new JList<>(); nativeRenderer = list.getCellRenderer(); - if (channel.getConfigManager().getOptionBool("general", "extendedListModes")) { + if (groupChat.getWindowModel().getConfigManager() + .getOptionBool("general", "extendedListModes")) { renderer = new ExtendedListModeCellRenderer(); } else { renderer = new ListModeCellRenderer(nativeRenderer); } listModesPanel = new JScrollPane(); listModesPanels = new ArrayList<>(); - listModesArray = channel.getConnection().get().getParser().get() + listModesArray = groupChat.getConnection().get().getParser().get() .getListChannelModes().toCharArray(); existingListItems = new MapList<>(); listModesMenu = new JComboBox<>(new DefaultComboBoxModel<>()); @@ -145,8 +146,8 @@ public ChannelListModesPane( removeListModeButton = new JButton("Remove"); removeListModeButton.setEnabled(false); modeCount = new JLabel(); - toggle = new JCheckBox("Show extended information", - channel.getConfigManager().getOptionBool("general", "extendedListModes")); + toggle = new JCheckBox("Show extended information", groupChat.getWindowModel() + .getConfigManager().getOptionBool("general", "extendedListModes")); toggle.setOpaque(UIUtilities.getTabbedPaneOpaque()); initListModesPanel(); @@ -157,13 +158,13 @@ public ChannelListModesPane( public void update() { existingListItems.clear(); - if (channel.getChannelInfo() == null) { + if (!groupChat.isOnChannel()) { return; } + for (int i = 0; i < listModesArray.length; i++) { final char mode = listModesArray[i]; - final Collection listItems = channel - .getChannelInfo().getListMode(mode); + final Collection listItems = groupChat.getListModeItems(mode); if (listItems == null) { continue; } @@ -191,8 +192,9 @@ private void updateMenu() { getModel(); for (char mode : listModesArray) { String modeText = mode + " list"; - if (channel.getConfigManager().hasOptionString("server", "mode" + mode)) { - modeText = channel.getConfigManager().getOption("server", + if (groupChat.getWindowModel().getConfigManager() + .hasOptionString("server", "mode" + mode)) { + modeText = groupChat.getWindowModel().getConfigManager().getOption("server", "mode" + mode) + " list [+" + mode + ']'; } model.addElement(modeText); @@ -236,7 +238,8 @@ private void initListeners() { removeListModeButton.addActionListener(this); listModesMenu.addActionListener(this); toggle.addActionListener(this); - channel.getConfigManager().addChangeListener("general", "extendedListModes", this); + groupChat.getWindowModel().getConfigManager() + .addChangeListener("general", "extendedListModes", this); } @@ -266,15 +269,15 @@ public void save() { if (currentModes.containsKey(entry.getKey())) { currentModes.remove(entry.getKey()); } else { - channel.getChannelInfo().alterMode(true, entry.getValue(), entry.getKey().getItem()); + groupChat.setMode(entry.getValue(), entry.getKey().getItem()); } } for (Entry entry : currentModes.entrySet()) { - channel.getChannelInfo().alterMode(false, entry.getValue(), entry.getKey().getItem()); + groupChat.removeMode(entry.getValue(), entry.getKey().getItem()); } - channel.getChannelInfo().flushModes(); + groupChat.flushModes(); userConfig.setOption("general", "extendedListModes", toggle.isSelected()); } @@ -282,9 +285,9 @@ public void save() { private void addListMode() { final int selectedIndex = listModesMenu.getSelectedIndex(); String modeText = String.valueOf(listModesArray[selectedIndex]); - if (channel.getConfigManager().hasOptionString("server", "mode" + if (groupChat.getWindowModel().getConfigManager().hasOptionString("server", "mode" + listModesArray[selectedIndex])) { - modeText = channel.getConfigManager(). + modeText = groupChat.getWindowModel().getConfigManager(). getOption("server", "mode" + listModesArray[selectedIndex]); } new StandardInputDialog(parentWindow, ModalityType.DOCUMENT_MODAL, @@ -354,7 +357,7 @@ private void updateModeCount() { final int selected = listModesMenu.getSelectedIndex(); final int current = listModesPanels.get(selected).getModel().getSize(); - final int maxModes = channel.getConnection().get().getParser().get(). + final int maxModes = groupChat.getConnection().get().getParser().get(). getMaxListModes(listModesArray[selected]); if (maxModes == -1) { diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java index 51037806f..5849c6d09 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java @@ -22,21 +22,21 @@ package com.dmdirc.addons.ui_swing.dialogs.channelsetting; -import com.dmdirc.Channel; import com.dmdirc.DMDircMBassador; import com.dmdirc.addons.ui_swing.PrefsComponentFactory; import com.dmdirc.addons.ui_swing.SwingWindowFactory; import com.dmdirc.addons.ui_swing.UIUtilities; +import com.dmdirc.addons.ui_swing.components.IconManager; import com.dmdirc.addons.ui_swing.components.expandingsettings.SettingsPanel; import com.dmdirc.addons.ui_swing.components.modes.ChannelModesPane; import com.dmdirc.addons.ui_swing.dialogs.StandardDialog; import com.dmdirc.config.prefs.PreferencesManager; import com.dmdirc.interfaces.CommandController; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.interfaces.config.ConfigProvider; import com.dmdirc.interfaces.config.IdentityFactory; import com.dmdirc.interfaces.ui.InputWindow; import com.dmdirc.plugins.ServiceManager; -import com.dmdirc.addons.ui_swing.components.IconManager; import com.dmdirc.ui.input.TabCompleterUtils; import com.dmdirc.ui.messages.ColourManagerFactory; @@ -62,7 +62,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe /** Serial version UID. */ private static final long serialVersionUID = 8; /** The channel object that this dialog belongs to. */ - private final Channel channel; + private final GroupChat channel; /** Channel identity file. */ private final ConfigProvider identity; /** Channel window. */ @@ -104,7 +104,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe * @param serviceManager Service manager * @param preferencesManager Preferences Manager * @param compFactory Preferences setting component factory - * @param channel The channel object that we're editing settings for + * @param groupChat The group chat object that we're editing settings for * @param parentWindow Parent window * @param clipboard Clipboard to copy and paste from * @param commandController The controller to use to retrieve command information. @@ -117,7 +117,7 @@ public ChannelSettingsDialog( final ServiceManager serviceManager, final PreferencesManager preferencesManager, final PrefsComponentFactory compFactory, - final Channel channel, + final GroupChat groupChat, final Window parentWindow, final Clipboard clipboard, final CommandController commandController, @@ -131,17 +131,16 @@ public ChannelSettingsDialog( this.serviceManager = checkNotNull(serviceManager); this.preferencesManager = checkNotNull(preferencesManager); this.compFactory = checkNotNull(compFactory); - this.channel = checkNotNull(channel); + this.channel = checkNotNull(groupChat); this.clipboard = clipboard; this.commandController = checkNotNull(commandController); this.eventBus = eventBus; this.colourManagerFactory = colourManagerFactory; this.iconManager = iconManager; - identity = identityFactory.createChannelConfig( - channel.getConnection().get().getNetwork(), - channel.getChannelInfo().getName()); - channelWindow = (InputWindow) windowFactory.getSwingWindow(channel); + identity = identityFactory.createChannelConfig(groupChat.getConnection().get().getNetwork(), + groupChat.getName()); + channelWindow = (InputWindow) windowFactory.getSwingWindow(groupChat.getWindowModel()); initComponents(tabCompleterUtils); initListeners(); diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java b/ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java index 26714ce14..80efc85f8 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/injection/DialogModule.java @@ -22,7 +22,6 @@ package com.dmdirc.addons.ui_swing.injection; -import com.dmdirc.Channel; import com.dmdirc.ClientModule.UserConfig; import com.dmdirc.DMDircMBassador; import com.dmdirc.addons.ui_swing.MainFrame; @@ -44,6 +43,7 @@ import com.dmdirc.config.prefs.PreferencesManager; import com.dmdirc.interfaces.CommandController; import com.dmdirc.interfaces.Connection; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.interfaces.LifecycleController; import com.dmdirc.interfaces.config.ConfigProvider; import com.dmdirc.interfaces.config.IdentityFactory; @@ -186,7 +186,7 @@ protected ServerSettingsDialog getInstance(final Connection key) { @Provides @Singleton - public KeyedDialogProvider getChannelSettingsDialogProvider( + public KeyedDialogProvider getChannelSettingsDialogProvider( final IdentityFactory identityFactory, final SwingWindowFactory windowFactory, @UserConfig final ConfigProvider userConfig, @@ -200,9 +200,9 @@ public KeyedDialogProvider getChannelSettingsDia final ColourManagerFactory colourManagerFactory, final TabCompleterUtils tabCompleterUtils, final IconManager iconManager) { - return new KeyedDialogProvider() { + return new KeyedDialogProvider() { @Override - protected ChannelSettingsDialog getInstance(final Channel key) { + protected ChannelSettingsDialog getInstance(final GroupChat key) { return new ChannelSettingsDialog(identityFactory, windowFactory, userConfig, serviceManager, preferencesManager, compFactory, key, parentWindow, clipboard, commandController, eventBus, From 3b7ff01b5f8c34fe1f36bb592c1d85a9352869e1 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 14 Jan 2015 23:14:14 +0000 Subject: [PATCH 3/6] Try to speed up CI a bit. Try without using gradle's parallel function (probably adds more overhead for the tiny number of tests we have), and combine coveralls with the main test run. --- circle.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/circle.yml b/circle.yml index 586aa4e2c..4364f7744 100644 --- a/circle.yml +++ b/circle.yml @@ -37,11 +37,7 @@ dependencies: test: override: - - ./gradlew --stacktrace --parallel plugins:jar plugins:test: - pwd: - ../meta - post: - - ./gradlew plugins:coveralls: + - ./gradlew --stacktrace plugins:jar plugins:test plugins:coveralls: pwd: ../meta From d9c8335b02ea37f207708333bbb99500a10496c0 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 15 Jan 2015 11:33:59 +0000 Subject: [PATCH 4/6] Fix another couple of bugs in the profiles dialog. --- .../ui_swing/dialogs/profile/ProfileManagerController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profile/ProfileManagerController.java b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profile/ProfileManagerController.java index 0ea40025d..a5d07d4dd 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profile/ProfileManagerController.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/profile/ProfileManagerController.java @@ -285,6 +285,10 @@ public void profileSelectionChanged(final Optional profile) { } else { selectionModel.setLeadSelectionIndex(-1); } + addNickname.setEnabled(model.getSelectedProfile().isPresent()); + editNickname.setEnabled(model.getSelectedProfile().isPresent()); + addHighlight.setEnabled(model.getSelectedProfile().isPresent()); + editHighlight.setEnabled(model.getSelectedProfile().isPresent()); name.setEnabled(model.getSelectedProfile().isPresent()); name.setText(model.getSelectedProfileName().orElse("")); nicknames.setEnabled(model.getSelectedProfile().isPresent()); From 816aeb9fe4349b7fd5d22c17e21efca773e0fc67 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 15 Jan 2015 12:08:10 +0000 Subject: [PATCH 5/6] Changes to channel commands done in core. --- .../src/com/dmdirc/addons/contactlist/ContactListCommand.java | 4 ++-- .../com/dmdirc/addons/ui_swing/commands/ChannelSettings.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contactlist/src/com/dmdirc/addons/contactlist/ContactListCommand.java b/contactlist/src/com/dmdirc/addons/contactlist/ContactListCommand.java index 6511af452..57919b622 100644 --- a/contactlist/src/com/dmdirc/addons/contactlist/ContactListCommand.java +++ b/contactlist/src/com/dmdirc/addons/contactlist/ContactListCommand.java @@ -62,9 +62,9 @@ public void execute(@Nonnull final FrameContainer origin, final CommandArguments args, final CommandContext context) { final ChannelCommandContext chanContext = (ChannelCommandContext) context; - final ContactListListener listener = new ContactListListener(chanContext.getChannel()); + final ContactListListener listener = new ContactListListener(chanContext.getGroupChat()); listener.addListeners(); - chanContext.getChannel().getUsers().forEach(listener::clientAdded); + chanContext.getGroupChat().getUsers().forEach(listener::clientAdded); } @Override diff --git a/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java b/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java index 26d0feb83..d63997a50 100644 --- a/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java +++ b/ui_swing/src/com/dmdirc/addons/ui_swing/commands/ChannelSettings.java @@ -70,7 +70,7 @@ public ChannelSettings( @Override public void execute(@Nonnull final FrameContainer origin, final CommandArguments args, final CommandContext context) { - dialogProvider.displayOrRequestFocus(((ChannelCommandContext) context).getChannel()); + dialogProvider.displayOrRequestFocus(((ChannelCommandContext) context).getGroupChat()); } @Override From c226437737c4633b84d4620f4d7da5e8200930ce Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 15 Jan 2015 19:50:30 +0000 Subject: [PATCH 6/6] Remove use of ChannelInfo. --- .../dmdirc/addons/logging/LogFileLocator.java | 11 +++++----- .../dmdirc/addons/logging/LoggingManager.java | 22 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/logging/src/com/dmdirc/addons/logging/LogFileLocator.java b/logging/src/com/dmdirc/addons/logging/LogFileLocator.java index 6538f2a45..3c47be197 100644 --- a/logging/src/com/dmdirc/addons/logging/LogFileLocator.java +++ b/logging/src/com/dmdirc/addons/logging/LogFileLocator.java @@ -27,10 +27,11 @@ import com.dmdirc.commandline.CommandLineOptionsModule.Directory; import com.dmdirc.config.ConfigBinding; import com.dmdirc.events.UserErrorEvent; +import com.dmdirc.interfaces.Connection; +import com.dmdirc.interfaces.GroupChat; import com.dmdirc.interfaces.User; import com.dmdirc.interfaces.config.AggregateConfigProvider; import com.dmdirc.logger.ErrorLevel; -import com.dmdirc.parser.interfaces.ChannelInfo; import com.dmdirc.plugins.PluginDomain; import java.io.File; @@ -39,6 +40,7 @@ import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Optional; import javax.annotation.Nullable; import javax.inject.Inject; @@ -103,12 +105,11 @@ private StringBuffer getLogDirectory() { * * @return the name of the log file to use for this object. */ - public String getLogFile(final ChannelInfo channel) { + public String getLogFile(final GroupChat channel) { final StringBuffer directory = getLogDirectory(); final StringBuffer file = new StringBuffer(); - if (channel.getParser() != null) { - addNetworkDir(directory, file, channel.getParser().getNetworkName()); - } + final Optional network = channel.getConnection().map(Connection::getNetwork); + network.ifPresent(n -> addNetworkDir(directory, file, n)); file.append(sanitise(channel.getName().toLowerCase())); return getPath(directory, file, channel.getName()); } diff --git a/logging/src/com/dmdirc/addons/logging/LoggingManager.java b/logging/src/com/dmdirc/addons/logging/LoggingManager.java index 4bea9fe6f..a8e390c3c 100644 --- a/logging/src/com/dmdirc/addons/logging/LoggingManager.java +++ b/logging/src/com/dmdirc/addons/logging/LoggingManager.java @@ -260,19 +260,19 @@ public void handleQueryMessages(final BaseQueryMessageEvent event) { @Handler public void handleChannelMessage(final BaseChannelMessageEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); appendLine(filename, "<%s> %s", getDisplayName(event.getClient()), event.getMessage()); } @Handler public void handleChannelAction(final BaseChannelActionEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); appendLine(filename, "* %s %s", getDisplayName(event.getClient()), event.getMessage()); } @Handler public void handleChannelGotTopic(final ChannelGotTopicEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); final DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); @@ -286,14 +286,14 @@ public void handleChannelGotTopic(final ChannelGotTopicEvent event) { @Handler public void handleChannelTopicChange(final ChannelTopicChangeEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); appendLine(filename, "*** %s Changed the topic to: %s", event.getTopic().getClient().map(this::getDisplayName).orElse(""), event.getTopic()); } @Handler public void handleChannelJoin(final ChannelJoinEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); final GroupChatUser channelClient = event.getClient(); appendLine(filename, "*** %s (%s) joined the channel", getDisplayName(channelClient), channelClient.getNickname()); @@ -301,7 +301,7 @@ public void handleChannelJoin(final ChannelJoinEvent event) { @Handler public void handleChannelPart(final ChannelPartEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); final String message = event.getMessage(); final GroupChatUser channelClient = event.getClient(); if (message.isEmpty()) { @@ -315,7 +315,7 @@ public void handleChannelPart(final ChannelPartEvent event) { @Handler public void handleChannelQuit(final ChannelQuitEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); final String reason = event.getMessage(); final GroupChatUser channelClient = event.getClient(); if (reason.isEmpty()) { @@ -332,7 +332,7 @@ public void handleChannelKick(final ChannelKickEvent event) { final GroupChatUser victim = event.getVictim(); final GroupChatUser perpetrator = event.getClient(); final String reason = event.getReason(); - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); if (reason.isEmpty()) { appendLine(filename, "*** %s was kicked by %s", @@ -345,14 +345,14 @@ public void handleChannelKick(final ChannelKickEvent event) { @Handler public void handleNickChange(final ChannelNickChangeEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); appendLine(filename, "*** %s is now %s", getDisplayName(event.getClient(), event.getOldNick()), getDisplayName(event.getClient())); } @Handler public void handleModeChange(final ChannelModeChangeEvent event) { - final String filename = locator.getLogFile(event.getChannel().getChannelInfo()); + final String filename = locator.getLogFile(event.getChannel()); if (event.getClient().getNickname().isEmpty()) { appendLine(filename, "*** Channel modes are: %s", event.getModes()); } else { @@ -371,7 +371,7 @@ public void handleChannelOpened(final ChannelOpenedEvent event) { final String filename = locator.getLogFile(event.getChannel().getName()); if (autobackbuffer) { - showBackBuffer(event.getChannel(), filename); + showBackBuffer(event.getChannel().getWindowModel(), filename); } synchronized (FORMAT_LOCK) {