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,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;
Expand All @@ -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;
Expand All @@ -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<Channel, ChannelSettingsDialog> dialogProvider;
private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;

/**
* Creates a new instance of the {@link ChannelSettings} command.
Expand All @@ -62,7 +62,7 @@ public class ChannelSettings extends Command implements IntelligentCommand {
@Inject
public ChannelSettings(
final CommandController commandController,
final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider) {
final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider) {
super(commandController);
this.dialogProvider = dialogProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand All @@ -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<Channel, ChannelSettingsDialog> dialogProvider;
/** Channel instance. */
private final Channel channel;
private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;
/** Group chat instance. */
private final GroupChat groupChat;
/** Config binder. */
private final ConfigBinder binder;

Expand All @@ -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<SwingInputField> inputFieldProvider,
final IdentityFactory identityFactory,
final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider,
final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> 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());
}

/**
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -56,7 +56,7 @@ public class ChannelFrameFactory implements SwingWindowFactory.WindowProvider {
private final Provider<SwingInputField> inputFieldProvider;
private final IdentityFactory identityFactory;
private final InputTextFramePasteActionFactory inputTextFramePasteActionFactory;
private final Provider<KeyedDialogProvider<Channel, ChannelSettingsDialog>> dialogProvider;
private final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider;
private final TopicBarFactory topicBarFactory;
private final DMDircMBassador eventBus;

Expand All @@ -68,7 +68,7 @@ public ChannelFrameFactory(
final Provider<SwingInputField> inputFieldProvider,
final InputTextFramePasteActionFactory inputTextFramePasteActionFactory,
final IdentityFactory identityFactory,
final Provider<KeyedDialogProvider<Channel, ChannelSettingsDialog>> dialogProvider,
final Provider<KeyedDialogProvider<GroupChat, ChannelSettingsDialog>> dialogProvider,
final TopicBarFactory topicBarFactory) {
this.eventBus = eventBus;
this.domain = domain;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -60,7 +60,7 @@ public class ChannelMenu extends JMenu implements MenuListener {
/** Main frame. */
private final MainFrame mainFrame;
/** Dialog provider. */
private final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider;
private final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider;
/** Channel list dialog provider. */
private final DialogProvider<ChannelListDialog> channelListDialogProvider;
/** Active frame manager. */
Expand All @@ -73,7 +73,7 @@ public class ChannelMenu extends JMenu implements MenuListener {
@Inject
public ChannelMenu(
final ActiveFrameManager activeFrameManager,
final KeyedDialogProvider<Channel, ChannelSettingsDialog> dialogProvider,
final KeyedDialogProvider<GroupChat, ChannelSettingsDialog> dialogProvider,
final MainFrame mainFrame,
final IconManager iconManager,
final DialogProvider<ChannelListDialog> channelListDialogProvider) {
Expand Down Expand Up @@ -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());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}

}
Loading