Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-05-01 00:01:05 +0000
committerslewis2007-05-01 00:01:05 +0000
commitb68bb8b006b7de470894d27201d8a45c45e270fd (patch)
tree5db6c40b64d61c123ee1fa919fe96ffa5901839a /providers/bundles/org.eclipse.ecf.provider.irc.ui
parent9dfc97b7e4368a203129d3fc9d466c90e1332dc8 (diff)
downloadorg.eclipse.ecf-b68bb8b006b7de470894d27201d8a45c45e270fd.tar.gz
org.eclipse.ecf-b68bb8b006b7de470894d27201d8a45c45e270fd.tar.xz
org.eclipse.ecf-b68bb8b006b7de470894d27201d8a45c45e270fd.zip
Refactoring of org.eclipse.ecf.ui and org.eclipse.ecf.presence.ui plugins to simplify, make only code available in public packages that should be exposed in API, fixed string externalization in these two API plugins.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.irc.ui')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java86
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java7
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties7
3 files changed, 90 insertions, 10 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java
index a7129af1a..a269fa0e5 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java
@@ -13,19 +13,28 @@ package org.eclipse.ecf.internal.irc.ui;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.StringTokenizer;
import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.util.IExceptionHandler;
+import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
/**
- *
+ *
*/
public class IRCUI extends ChatRoomManagerUI {
- public static final String CHANNEL_PREFIX = "#";
-
+ public static final String CHANNEL_PREFIX = "#"; //$NON-NLS-1$
+
+ private static final String COMMAND_PREFIX = "/"; //$NON-NLS-1$
+
+ private static final String COMMAND_DELIM = " "; //$NON-NLS-1$
+
/**
* @param container
* @param manager
@@ -36,14 +45,15 @@ public class IRCUI extends ChatRoomManagerUI {
public IRCUI(IContainer container, IChatRoomManager manager,
IExceptionHandler exceptionHandler) {
- super(container,manager,exceptionHandler);
+ super(container, manager, exceptionHandler);
}
-
+
protected String modifyRoomNameForTarget(String roomName) {
- if (!roomName.startsWith(CHANNEL_PREFIX)) return new String(CHANNEL_PREFIX+roomName);
+ if (!roomName.startsWith(CHANNEL_PREFIX))
+ return new String(CHANNEL_PREFIX + roomName);
return roomName;
}
-
+
protected String[] getRoomsForTarget() {
String initialRooms = null;
try {
@@ -55,9 +65,65 @@ public class IRCUI extends ChatRoomManagerUI {
return new String[0];
while (initialRooms.charAt(0) == '/')
initialRooms = initialRooms.substring(1);
-
- if (initialRooms.startsWith(CHANNEL_PREFIX)) return new String [] { initialRooms };
- else return super.getRoomsForTarget();
+
+ if (initialRooms.startsWith(CHANNEL_PREFIX))
+ return new String[] { initialRooms };
+ else
+ return super.getRoomsForTarget();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI#handleCommand(java.lang.String)
+ */
+ public String handleCommand(IChatRoomContainer chatRoomContainer,
+ String inputLine) {
+ if ((inputLine != null && inputLine.startsWith(COMMAND_PREFIX))) {
+ StringTokenizer st = new StringTokenizer(inputLine, COMMAND_DELIM);
+ int countTokens = st.countTokens();
+ String tokens[] = new String[countTokens];
+ for (int i = 0; i < countTokens; i++)
+ tokens[i] = st.nextToken();
+ String command = tokens[0];
+ while (command.startsWith(COMMAND_PREFIX))
+ command = command.substring(1);
+ // Look at first one and switch
+ String[] args = new String[tokens.length - 1];
+ System.arraycopy(tokens, 1, args, 0, tokens.length - 1);
+ // JOIN can be done from root or channel
+ if (command.equalsIgnoreCase(Messages.IRCUI_JOIN_COMMAND)) {
+ String arg1 = args[0];
+ String arg2 = ""; //$NON-NLS-1$
+ if (args.length > 1) {
+ arg2 = args[1];
+ }
+ chatroomview.joinRoom(arg1, arg2);
+ return null;
+ }
+ // QUIT can be done from root or channel
+ if (command.equalsIgnoreCase(Messages.IRCUI_QUIT_COMMAND)) {
+ ID connectedID = container.getConnectedID();
+ if (connectedID != null
+ && MessageDialog.openQuestion(chatroomview.getSite()
+ .getShell(), Messages.IRCUI_DISCONNECT_CONFIRM_TITLE, NLS
+ .bind(Messages.IRCUI_DISCONNECT_CONFIRM_MESSAGE, connectedID
+ .getName())))
+ chatroomview.hardDisconnect();
+ return null;
+ }
+ if (chatRoomContainer != null
+ && command.equalsIgnoreCase(Messages.IRCUI_PART_COMMAND)
+ && MessageDialog.openQuestion(chatroomview.getSite()
+ .getShell(), Messages.IRCUI_DEPART_CONFIRM_TITLE, NLS.bind(
+ Messages.IRCUI_DEPART_CONFIRM_MESSAGE, chatRoomContainer
+ .getConnectedID().getName()))) {
+ chatRoomContainer.disconnect();
+ return null;
+ }
+ }
+ return inputLine;
+
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java
index 981303916..13ea8623d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Messages.java
@@ -19,6 +19,13 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.irc.ui.messages"; //$NON-NLS-1$
public static String IRCHyperlink_EXCEPTION_IRC_HYPERLINK;
+ public static String IRCUI_DEPART_CONFIRM_MESSAGE;
+ public static String IRCUI_DEPART_CONFIRM_TITLE;
+ public static String IRCUI_DISCONNECT_CONFIRM_MESSAGE;
+ public static String IRCUI_DISCONNECT_CONFIRM_TITLE;
+ public static String IRCUI_JOIN_COMMAND;
+ public static String IRCUI_PART_COMMAND;
+ public static String IRCUI_QUIT_COMMAND;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties
index 4f22b430b..02dd7512a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/messages.properties
@@ -1 +1,8 @@
IRCHyperlink_EXCEPTION_IRC_HYPERLINK=Exception in IRC hyperlink open
+IRCUI_JOIN_COMMAND=JOIN
+IRCUI_QUIT_COMMAND=QUIT
+IRCUI_DISCONNECT_CONFIRM_TITLE=Disconnect from Server
+IRCUI_DISCONNECT_CONFIRM_MESSAGE=Disconnect from {0}?
+IRCUI_PART_COMMAND=PART
+IRCUI_DEPART_CONFIRM_TITLE=Depart from IRC Channel
+IRCUI_DEPART_CONFIRM_MESSAGE=Depart from IRC channel {0}?

Back to the top