Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DMDirc/Plugins into dev4
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Holmes committed Jan 15, 2015
2 parents 4c8fc9b + 29c2a51 commit 1d7c677
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 118 deletions.
6 changes: 1 addition & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions logging/src/com/dmdirc/addons/logging/LogFileLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String> 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());
}
Expand Down
22 changes: 11 additions & 11 deletions logging/src/com/dmdirc/addons/logging/LoggingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -286,22 +286,22 @@ 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());
}

@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()) {
Expand All @@ -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()) {
Expand All @@ -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",
Expand All @@ -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 {
Expand All @@ -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) {
Expand Down
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,15 +62,15 @@ 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;
}

@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
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 @@ -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;

Expand All @@ -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.
Expand All @@ -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");
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

/**
Expand Down
Loading

0 comments on commit 1d7c677

Please sign in to comment.