Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-04-29 22:16:20 +0000
committerslewis2007-04-29 22:16:20 +0000
commite2c49b8d875b1e5bcfe121f1513237795081a9f1 (patch)
tree99e2dd48aacb3bfe47f344c255944d9457cb674a /providers/bundles/org.eclipse.ecf.provider.irc.ui
parent641b8cd0c0e928eb80808e0b3c6672f05cdc33d1 (diff)
downloadorg.eclipse.ecf-e2c49b8d875b1e5bcfe121f1513237795081a9f1.tar.gz
org.eclipse.ecf-e2c49b8d875b1e5bcfe121f1513237795081a9f1.tar.xz
org.eclipse.ecf-e2c49b8d875b1e5bcfe121f1513237795081a9f1.zip
Refactoring of ChatRoomManagerView and dependent classes. Also added support for multiple channels to connect to upon initial connect
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.java63
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java39
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java4
3 files changed, 83 insertions, 23 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
new file mode 100644
index 000000000..a7129af1a
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/IRCUI.java
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.irc.ui;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.util.IExceptionHandler;
+import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
+import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI;
+
+/**
+ *
+ */
+public class IRCUI extends ChatRoomManagerUI {
+
+ public static final String CHANNEL_PREFIX = "#";
+
+ /**
+ * @param container
+ * @param manager
+ */
+ public IRCUI(IContainer container, IChatRoomManager manager) {
+ super(container, manager);
+ }
+
+ public IRCUI(IContainer container, IChatRoomManager manager,
+ IExceptionHandler exceptionHandler) {
+ super(container,manager,exceptionHandler);
+ }
+
+ protected String modifyRoomNameForTarget(String roomName) {
+ if (!roomName.startsWith(CHANNEL_PREFIX)) return new String(CHANNEL_PREFIX+roomName);
+ return roomName;
+ }
+
+ protected String[] getRoomsForTarget() {
+ String initialRooms = null;
+ try {
+ URI targetURI = new URI(targetID.getName());
+ initialRooms = targetURI.getPath();
+ } catch (URISyntaxException e) {
+ }
+ if (initialRooms == null || initialRooms.equals("")) //$NON-NLS-1$
+ 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();
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java
index 6f1b44ff1..16d8c8ebd 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java
@@ -11,22 +11,25 @@
*****************************************************************************/
package org.eclipse.ecf.internal.irc.ui.wizards;
+import java.net.URI;
+
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.security.ConnectContextFactory;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.core.util.IExceptionHandler;
import org.eclipse.ecf.internal.irc.ui.Activator;
+import org.eclipse.ecf.internal.irc.ui.IRCUI;
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
-import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI;
import org.eclipse.ecf.ui.IConnectWizard;
import org.eclipse.ecf.ui.actions.AsynchContainerConnectAction;
import org.eclipse.ecf.ui.dialogs.ContainerConnectErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
@@ -44,7 +47,7 @@ public final class IRCConnectWizard extends Wizard implements IConnectWizard {
private IConnectContext connectContext;
private String uriString = null;
-
+
private IExceptionHandler exceptionHandler = new IExceptionHandler() {
public IStatus handleException(final Throwable exception) {
if (exception != null) {
@@ -64,11 +67,12 @@ public final class IRCConnectWizard extends Wizard implements IConnectWizard {
public IRCConnectWizard() {
super();
}
-
+
public IRCConnectWizard(String uri) {
super();
uriString = uri;
}
+
public void addPages() {
page = new IRCConnectWizardPage(uriString);
addPage(page);
@@ -84,32 +88,25 @@ public final class IRCConnectWizard extends Wizard implements IConnectWizard {
.createPasswordConnectContext(page.getPassword());
try {
+ new URI(page.getConnectID());
targetID = IDFactory.getDefault().createID(
container.getConnectNamespace(), page.getConnectID());
- } catch (IDCreateException e) {
- // TODO: This needs to be handled properly
- e.printStackTrace();
+ } catch (Exception e) {
+ MessageDialog.openError(shell, "Connect Error", NLS.bind(
+ "Invalid connect ID: {0}", page.getConnectID()));
return false;
}
IChatRoomManager manager = (IChatRoomManager) this.container
.getAdapter(IChatRoomManager.class);
- if (manager == null) {
- // XXX
- // Serious error...log, show dialog, freak out, etc
- return false;
- } else {
- ChatRoomManagerUI ui = new ChatRoomManagerUI(this.container,
- manager, exceptionHandler);
- ui.showForTarget(targetID);
- // If it's not already connected, then we connect this new container
- if (!ui.isContainerConnected()) {
- new AsynchContainerConnectAction(this.container, this.targetID,
- this.connectContext, exceptionHandler).run(null);
+ IRCUI ui = new IRCUI(this.container, manager, exceptionHandler);
+ ui.showForTarget(targetID);
+ // If it's not already connected, then we connect this new container
+ if (!ui.isContainerConnected())
+ new AsynchContainerConnectAction(this.container, this.targetID,
+ this.connectContext, exceptionHandler).run(null);
- }
- }
return true;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java
index 6abad5b6c..835abde7f 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java
@@ -39,7 +39,7 @@ final class IRCConnectWizardPage extends WizardPage {
this();
uriString = uri;
}
-
+
public void createControl(Composite parent) {
parent.setLayout(new GridLayout());
GridData fillData = new GridData(SWT.FILL, SWT.CENTER, true, false);
@@ -60,7 +60,7 @@ final class IRCConnectWizardPage extends WizardPage {
}
});
label = new Label(parent, SWT.RIGHT);
- label.setText("irc://<user>@<ircserver>[/<#channel>]");
+ label.setText("irc://[<user>@]<ircserver[:port]>[/<channel>,<channel2>,...]");
label.setLayoutData(endData);
label = new Label(parent, SWT.LEFT);

Back to the top