Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@

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

import com.dmdirc.Channel;
import com.dmdirc.DMDircMBassador;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.addons.ui_swing.actions.ReplacePasteAction;
import com.dmdirc.addons.ui_swing.components.IconManager;
import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputHandler;
import com.dmdirc.addons.ui_swing.components.inputfields.TextAreaInputField;
import com.dmdirc.addons.ui_swing.components.text.TextLabel;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.GroupChat;
import com.dmdirc.interfaces.GroupChatUser;
import com.dmdirc.interfaces.config.AggregateConfigProvider;
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;

Expand All @@ -55,16 +55,16 @@
import net.miginfocom.swing.MigLayout;

/**
* Class to display a topic to an end user as part of the channel settings dialog.
* Class to display a topic to an end user as part of the groupChat settings dialog.
*/
public class TopicDisplayPane extends JPanel implements DocumentListener {

/** Serial version UID. */
private static final long serialVersionUID = 1;
/** Parent topic pane. */
private final ChannelSettingsDialog parent;
/** Associated channel. */
private final Channel channel;
/** Associated group chat. */
private final GroupChat groupChat;
/** Channel window. */
private final InputWindow channelWindow;
/** the maximum length allowed for a topic. */
Expand All @@ -84,34 +84,34 @@ public class TopicDisplayPane extends JPanel implements DocumentListener {
* Creates a new topic display panel. This panel shows an editable version of the current topic
* along with relating meta data and validates the length of the new input.
*
* @param channel Associated channel
* @param groupChat Associated group chat
* @param iconManager Icon manager
* @param serviceManager Service manager
* @param parent Parent channel settings dialog
* @param parent Parent settings dialog
* @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 Channel channel, final IconManager iconManager,
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 ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils) {
this.clipboard = clipboard;
this.channel = channel;
this.groupChat = groupChat;
this.parent = parent;
topicLengthMax = channel.getConnection().get().getParser().get().getMaxTopicLength();
topicLengthMax = groupChat.getConnection().get().getParser().get().getMaxTopicLength();
this.channelWindow = channelWindow;
this.eventBus = eventBus;

initComponents(iconManager, channel.getConfigManager(), serviceManager, commandController,
colourManagerFactory, tabCompleterUtils);
initComponents(iconManager, groupChat.getWindowModel().getConfigManager(), serviceManager,
commandController, colourManagerFactory, tabCompleterUtils);
addListeners();
layoutComponents();

setTopic(channel.getCurrentTopic());
setTopic(groupChat.getCurrentTopic());
}

private void initComponents(
Expand All @@ -131,10 +131,10 @@ private void initComponents(
topicText.setRows(5);
topicText.setColumns(30);
final SwingInputHandler handler = new SwingInputHandler(serviceManager, topicText,
commandController, channel.getCommandParser(), channelWindow.getContainer(),
tabCompleterUtils, channel.getEventBus());
commandController, groupChat.getWindowModel().getCommandParser(),
channelWindow.getContainer(), tabCompleterUtils, groupChat.getEventBus());
handler.setTypes(true, false, true, false);
handler.setTabCompleter(channel.getTabCompleter());
handler.setTabCompleter(groupChat.getWindowModel().getTabCompleter());

topicText.getActionMap().put("paste-from-clipboard",
new ReplacePasteAction(eventBus, clipboard, "(\r\n|\n|\r)", " "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

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

import com.dmdirc.Channel;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.interfaces.GroupChat;
import com.dmdirc.util.collections.ListenerList;

import java.awt.event.ActionEvent;
Expand Down Expand Up @@ -61,20 +61,21 @@ public class TopicHistoryPane extends JPanel implements ListSelectionListener {
/**
* Instantiates a new topic history pane.
*
* @param channel Parent channel
* @param groupChat Parent group chat
*/
public TopicHistoryPane(final Channel channel) {
public TopicHistoryPane(final GroupChat groupChat) {

topicHistory.getSelectionModel().addListSelectionListener(this);
topicHistory.getSelectionModel().setSelectionMode(
ListSelectionModel.SINGLE_SELECTION);
final List<Topic> topics = channel.getTopics();
final List<Topic> topics = groupChat.getTopics();
Collections.reverse(topics);
scrollPane.getVerticalScrollBar().setUnitIncrement(15);

for (Topic topic : topics) {
topicHistory.getModel().addRow(new Object[]{new TopicLabel(channel,
topic),});
topicHistory.getModel().addRow(new Object[]{
new TopicLabel(groupChat, topic),
});
}
topicHistory.getSelectionModel().setSelectionInterval(0, 0);
topicHistory.setShowGrid(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

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

import com.dmdirc.Channel;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.components.text.TextLabel;
import com.dmdirc.addons.ui_swing.textpane.StyledDocumentMaker;
import com.dmdirc.interfaces.GroupChat;
import com.dmdirc.interfaces.GroupChatUser;

import java.awt.Color;
Expand Down Expand Up @@ -53,8 +53,8 @@ public class TopicLabel extends JPanel {
private static final int MILLIS_IN_SECOND = 1000;
/** Topic this label represents. */
private final Topic topic;
/** The channel to which this label belongs. */
private final Channel channel;
/** The group chat to which this label belongs. */
private final GroupChat groupChat;
/** Topic field. */
private JEditorPane pane;
/** Empty Attrib set. */
Expand All @@ -63,19 +63,18 @@ public class TopicLabel extends JPanel {
/**
* Instantiates a new topic label based on the specified topic.
*
* @param channel The channel to which this label belongs
* @param groupChat The group chat to which this label belongs
* @param topic Specified topic
*
* @since 0.6.3
*/
public TopicLabel(final Channel channel, final Topic topic) {

public TopicLabel(final GroupChat groupChat, final Topic topic) {
if (topic == null) {
throw new IllegalArgumentException();
}

this.topic = topic;
this.channel = channel;
this.groupChat = groupChat;

super.setBackground(UIManager.getColor("Table.background"));
super.setForeground(UIManager.getColor("Table.foreground"));
Expand Down Expand Up @@ -123,7 +122,7 @@ private void init() {
setLayout(new MigLayout("fill, ins 0, debug", "[]0[]", "[]0[]"));

if (!topic.getTopic().isEmpty()) {
channel.getBackBuffer().getStyliser().addStyledString(
groupChat.getWindowModel().getBackBuffer().getStyliser().addStyledString(
new StyledDocumentMaker((StyledDocument) pane.getDocument(), as),
topic.getTopic());
add(pane, "wmax 450, grow, push, wrap, gapleft 5, gapleft 5");
Expand Down Expand Up @@ -159,6 +158,8 @@ public Topic getTopic() {
@Override
public void setBackground(final Color bg) {
super.setBackground(bg);
// This method can be called from the super class constructor, so topic may not have been
// instansiated.
if (topic != null
&& ((getBackground() != null && !getBackground().equals(bg))
|| (bg != null && !bg.equals(getBackground())))) {
Expand All @@ -169,6 +170,8 @@ public void setBackground(final Color bg) {
@Override
public void setForeground(final Color fg) {
super.setForeground(fg);
// This method can be called from the super class constructor, so topic may not have been
// instansiated.
if (topic != null
&& ((getForeground() != null && !getForeground().equals(fg))
|| (fg != null && !fg.equals(getForeground())))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

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

import com.dmdirc.Channel;
import com.dmdirc.DMDircMBassador;
import com.dmdirc.Topic;
import com.dmdirc.addons.ui_swing.UIUtilities;
import com.dmdirc.addons.ui_swing.components.IconManager;
import com.dmdirc.interfaces.CommandController;
import com.dmdirc.interfaces.GroupChat;
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;

Expand All @@ -46,8 +47,8 @@ public class TopicPane extends JPanel implements ActionListener {

/** A version number for this class. */
private static final long serialVersionUID = 2;
/** Parent channel. */
private final Channel channel;
/** Parent group chat. */
private final GroupChat groupChat;
/** Channel window. */
private final InputWindow channelWindow;
/** Parent dialog. */
Expand All @@ -62,7 +63,7 @@ public class TopicPane extends JPanel implements ActionListener {
/**
* Creates a new instance of TopicModesPane.
*
* @param channel Parent channel
* @param groupChat Parent group chat
* @param iconManager Icon manager
* @param commandController The controller to use to retrieve command information.
* @param serviceManager Service manager
Expand All @@ -71,15 +72,15 @@ public class TopicPane extends JPanel implements ActionListener {
* @param clipboard Clipboard to copy and paste with
* @param eventBus The event bus to post errors to
*/
public TopicPane(final Channel channel, final IconManager iconManager,
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());
this.channel = channel;
this.groupChat = groupChat;
this.parent = parent;
this.channelWindow = channelWindow;
this.clipboard = clipboard;
Expand All @@ -103,10 +104,10 @@ private void initTopicsPanel(
final DMDircMBassador eventBus,
final ColourManagerFactory colourManagerFactory,
final TabCompleterUtils tabCompleterUtils) {
topicDisplayPane = new TopicDisplayPane(channel, iconManager, serviceManager, parent,
topicDisplayPane = new TopicDisplayPane(groupChat, iconManager, serviceManager, parent,
channelWindow, clipboard, commandController, eventBus, colourManagerFactory,
tabCompleterUtils);
topicHistoryPane = new TopicHistoryPane(channel);
topicHistoryPane = new TopicHistoryPane(groupChat);
}

/** Lays out the components. */
Expand All @@ -120,8 +121,8 @@ private void layoutComponents() {
/** Processes the topic and changes it if necessary. */
protected void setChangedTopic() {
final String topic = topicDisplayPane.getTopic();
if (!channel.getChannelInfo().getTopic().equals(topic)) {
channel.setTopic(topic);
if (!groupChat.getCurrentTopic().map(Topic::getTopic).orElse("").equals(topic)) {
groupChat.setTopic(topic);
}
}

Expand Down