Skip to content

Commit

Permalink
Recompile a few more times and fix errant EventBouses
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Holmes committed Feb 1, 2015
1 parent 2d89797 commit 195986e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 46 deletions.
8 changes: 3 additions & 5 deletions ui_swing/src/com/dmdirc/addons/ui_swing/UIUtilities.java
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
import com.dmdirc.addons.ui_swing.components.RunnableLoggingSwingWorker;
import com.dmdirc.addons.ui_swing.components.RunnableSwingWorker;
Expand Down Expand Up @@ -91,24 +90,23 @@ private UIUtilities() {
/**
* Adds an undo manager and associated key bindings to the specified text component.
*
* @param eventBus The event bus to post errors to
* @param component The text component to add an undo manager to
*/
public static void addUndoManager(final DMDircMBassador eventBus, final JTextComponent component) {
public static void addUndoManager(final JTextComponent component) {
final UndoManager undoManager = new UndoManager();

// Listen for undo and redo events
component.getDocument().addUndoableEditListener(
new DMDircUndoableEditListener(undoManager));

// Create an undo action and add it to the text component
component.getActionMap().put("Undo", new UndoAction(eventBus, undoManager));
component.getActionMap().put("Undo", new UndoAction(undoManager));

// Bind the undo action to ctl-Z
component.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");

// Create a redo action and add it to the text component
component.getActionMap().put("Redo", new RedoAction(eventBus, undoManager));
component.getActionMap().put("Redo", new RedoAction(undoManager));

// Bind the redo action to ctl-Y
component.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.components;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
import com.dmdirc.addons.ui_swing.UIUtilities;
Expand Down Expand Up @@ -136,8 +135,7 @@ public TopicBar(
final GroupChat channel,
final ChannelFrame window,
final IconManager iconManager,
final TabCompleterUtils tabCompleterUtils,
final DMDircMBassador eventBus) {
final TabCompleterUtils tabCompleterUtils) {
this.channel = channel;
this.domain = domain;
this.colourManager = colourManager;
Expand All @@ -151,7 +149,7 @@ public TopicBar(
new NewlinesDocumentFilter());

topicText.getActionMap().put("paste-from-clipboard",
new ReplacePasteAction(eventBus, clipboard, "(\r\n|\n|\r)", " "));
new ReplacePasteAction(clipboard, "(\r\n|\n|\r)", " "));
topicEdit = new ImageButton<>("edit",
iconManager.getIcon("edit-inactive"),
iconManager.getIcon("edit"));
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.components;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.addons.ui_swing.SwingController;
import com.dmdirc.addons.ui_swing.components.frames.ChannelFrame;
import com.dmdirc.addons.ui_swing.injection.MainWindow;
Expand Down Expand Up @@ -56,7 +55,6 @@ public class TopicBarFactory {
private final ServiceManager serviceManager;
private final Clipboard clipboard;
private final CommandController commandController;
private final DMDircMBassador eventBus;
private final TabCompleterUtils tabCompleterUtils;
private final IconManager iconManager;

Expand All @@ -69,7 +67,6 @@ public TopicBarFactory(
final ServiceManager serviceManager,
final Clipboard clipboard,
final CommandController commandController,
final DMDircMBassador eventBus,
final TabCompleterUtils tabCompleterUtils,
final IconManager iconManager) {
this.parentWindow = parentWindow;
Expand All @@ -79,7 +76,6 @@ public TopicBarFactory(
this.serviceManager = serviceManager;
this.clipboard = clipboard;
this.commandController = commandController;
this.eventBus = eventBus;
this.tabCompleterUtils = tabCompleterUtils;
this.iconManager = iconManager;
}
Expand All @@ -90,7 +86,7 @@ public TopicBar getTopicBar(
return new TopicBar(parentWindow.get(), globalConfig, domain,
colourManagerFactory.getColourManager(channel.getWindowModel().getConfigManager()),
serviceManager, clipboard, commandController, channel, window, iconManager,
tabCompleterUtils, eventBus);
tabCompleterUtils);
}

}
Expand Up @@ -172,7 +172,7 @@ private void initPopupMenu() {
* Initialises the input field.
*/
private void initInputField() {
UIUtilities.addUndoManager(eventBus, getInputField().getTextField());
UIUtilities.addUndoManager(getInputField().getTextField());

getInputField().getActionMap().put("paste", inputTextFramePasteActionFactory
.getInputTextFramePasteAction(this, inputField, getContainer()));
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.dialogs.aliases;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.addons.ui_swing.components.IconManager;
import com.dmdirc.addons.ui_swing.components.text.TextLabel;
Expand Down Expand Up @@ -55,7 +54,6 @@ public class AliasManagerDialog extends StandardDialog {
private static final long serialVersionUID = 1;
private final AliasDialogModel model;
private final IconManager iconManager;
private final DMDircMBassador eventBus;
private JList<Alias> aliasList;
private JTextField command;
private JSpinner argumentsNumber;
Expand All @@ -66,19 +64,18 @@ public class AliasManagerDialog extends StandardDialog {

@Inject
public AliasManagerDialog(@MainWindow final Window mainFrame, final AliasDialogModel model,
final IconManager iconManager, final DMDircMBassador eventBus) {
final IconManager iconManager) {
super(mainFrame, ModalityType.DOCUMENT_MODAL);
this.model = model;
this.iconManager = iconManager;
this.eventBus = eventBus;
initComponents();
layoutComponents();
}

@Override
public void display() {
final AliasManagerLinker linker = new AliasManagerLinker(model, this, iconManager);
UIUtilities.addUndoManager(eventBus, response);
UIUtilities.addUndoManager(response);
linker.bindCommandList(aliasList);
linker.bindCommand(command);
linker.bindArgumentsNumber(argumentsNumber);
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.dialogs.channelsetting;

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;
Expand All @@ -48,6 +47,7 @@
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.WindowConstants;

import net.miginfocom.swing.MigLayout;
Expand Down Expand Up @@ -90,8 +90,6 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
private final Clipboard clipboard;
/** The controller to use to retrieve command information. */
private final CommandController commandController;
/** The event bus to post errors to. */
private final DMDircMBassador eventBus;
/** Colour manager factory. */
private final ColourManagerFactory colourManagerFactory;

Expand All @@ -108,7 +106,6 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
* @param parentWindow Parent window
* @param clipboard Clipboard to copy and paste from
* @param commandController The controller to use to retrieve command information.
* @param eventBus The event bus to post errors to.
*/
public ChannelSettingsDialog(
final IdentityFactory identityFactory,
Expand All @@ -121,7 +118,6 @@ public ChannelSettingsDialog(
final Window parentWindow,
final Clipboard clipboard,
final CommandController commandController,
final DMDircMBassador eventBus,
final ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils,
final IconManager iconManager) {
Expand All @@ -134,7 +130,6 @@ public ChannelSettingsDialog(
this.channel = checkNotNull(groupChat);
this.clipboard = clipboard;
this.commandController = checkNotNull(commandController);
this.eventBus = eventBus;
this.colourManagerFactory = colourManagerFactory;
this.iconManager = iconManager;

Expand Down Expand Up @@ -178,7 +173,7 @@ private void initComponents(final TabCompleterUtils tabCompleterUtils) {
private void initTopicTab(final TabCompleterUtils tabCompleterUtils) {
topicModesPane = new TopicPane(channel, iconManager,
commandController, serviceManager,
this, channelWindow, clipboard, eventBus, colourManagerFactory, tabCompleterUtils);
this, channelWindow, clipboard, colourManagerFactory, tabCompleterUtils);
tabbedPane.addTab("Topic", topicModesPane);
}

Expand All @@ -187,7 +182,7 @@ private void initIrcTab() {
channelModesPane = new ChannelModesPane(channel, iconManager);

final JScrollPane channelModesSP = new JScrollPane(channelModesPane);
channelModesSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
channelModesSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
channelModesSP.setOpaque(UIUtilities.getTabbedPaneOpaque());
channelModesSP.getViewport().setOpaque(UIUtilities.getTabbedPaneOpaque());
channelModesSP.setBorder(null);
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.dialogs.channelsetting;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.addons.ui_swing.actions.ReplacePasteAction;
Expand Down Expand Up @@ -71,8 +70,6 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
private final int topicLengthMax;
/** Clipboard to copy and paste from. */
private final Clipboard clipboard;
/** The event bus to post errors to. */
private final DMDircMBassador eventBus;
/** label showing the number of characters left in a topic. */
private JLabel topicLengthLabel;
/** Topic text entry text area. */
Expand All @@ -91,20 +88,18 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
* @param channelWindow Channel window
* @param clipboard Clipboard to copy and paste
* @param commandController The controller to use to retrieve command information.
* @param eventBus The event bus to post errors to.
*/
public TopicDisplayPane(final GroupChat groupChat, final IconManager iconManager,
final ServiceManager serviceManager, final ChannelSettingsDialog parent,
final InputWindow channelWindow, final Clipboard clipboard,
final CommandController commandController, final DMDircMBassador eventBus,
final CommandController commandController,
final ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils) {
this.clipboard = clipboard;
this.groupChat = groupChat;
this.parent = parent;
topicLengthMax = groupChat.getConnection().get().getParser().get().getMaxTopicLength();
this.channelWindow = channelWindow;
this.eventBus = eventBus;

initComponents(iconManager, groupChat.getWindowModel().getConfigManager(), serviceManager,
commandController, colourManagerFactory, tabCompleterUtils);
Expand Down Expand Up @@ -137,13 +132,13 @@ private void initComponents(
handler.setTabCompleter(groupChat.getWindowModel().getTabCompleter());

topicText.getActionMap().put("paste-from-clipboard",
new ReplacePasteAction(eventBus, clipboard, "(\r\n|\n|\r)", " "));
new ReplacePasteAction(clipboard, "(\r\n|\n|\r)", " "));
topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
0), new TopicEnterAction(parent));
topicText.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
UIUtilities.getCtrlDownMask()), new TopicEnterAction(parent));

UIUtilities.addUndoManager(eventBus, topicText);
UIUtilities.addUndoManager(topicText);
}

/** Adds listeners to the components. */
Expand Down
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.dialogs.channelsetting;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.addons.ui_swing.components.IconManager;
Expand Down Expand Up @@ -70,13 +69,11 @@ public class TopicPane extends JPanel implements ActionListener {
* @param parent Parent dialog
* @param channelWindow Channel window
* @param clipboard Clipboard to copy and paste with
* @param eventBus The event bus to post errors to
*/
public TopicPane(final GroupChat groupChat, final IconManager iconManager,
final CommandController commandController,
final ServiceManager serviceManager, final ChannelSettingsDialog parent,
final InputWindow channelWindow, final Clipboard clipboard,
final DMDircMBassador eventBus,
final ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils) {
setOpaque(UIUtilities.getTabbedPaneOpaque());
Expand All @@ -88,8 +85,8 @@ public TopicPane(final GroupChat groupChat, final IconManager iconManager,
setVisible(false);

removeAll();
initTopicsPanel(iconManager, serviceManager, commandController, eventBus,
colourManagerFactory, tabCompleterUtils);
initTopicsPanel(iconManager, serviceManager, commandController, colourManagerFactory,
tabCompleterUtils);
layoutComponents();

topicHistoryPane.addActionListener(this);
Expand All @@ -101,11 +98,10 @@ private void initTopicsPanel(
final IconManager iconManager,
final ServiceManager serviceManager,
final CommandController commandController,
final DMDircMBassador eventBus,
final ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils) {
topicDisplayPane = new TopicDisplayPane(groupChat, iconManager, serviceManager, parent,
channelWindow, clipboard, commandController, eventBus, colourManagerFactory,
channelWindow, clipboard, commandController, colourManagerFactory,
tabCompleterUtils);
topicHistoryPane = new TopicHistoryPane(groupChat);
}
Expand Down
Expand Up @@ -137,7 +137,7 @@ private void initComponents(final DMDircMBassador eventBus, final String text,
editButton = new JButton("Edit");
infoLabel = new TextLabel();

UIUtilities.addUndoManager(eventBus, textField);
UIUtilities.addUndoManager(textField);

orderButtons(new JButton(), new JButton());
getOkButton().setText("Send");
Expand Down
Expand Up @@ -222,8 +222,8 @@ public KeyedDialogProvider<GroupChat, ChannelSettingsDialog> getChannelSettingsD
protected ChannelSettingsDialog getInstance(final GroupChat key) {
return new ChannelSettingsDialog(identityFactory, windowFactory,
userConfig, serviceManager, preferencesManager, compFactory, key,
parentWindow, clipboard, commandController, eventBus,
colourManagerFactory, tabCompleterUtils, iconManager);
parentWindow, clipboard, commandController, colourManagerFactory,
tabCompleterUtils, iconManager);
}
};
}
Expand Down

0 comments on commit 195986e

Please sign in to comment.