diff options
author | slewis | 2007-03-26 19:04:49 +0000 |
---|---|---|
committer | slewis | 2007-03-26 19:04:49 +0000 |
commit | 519e3b64d4c4b8568e285547a368f1250e13297e (patch) | |
tree | 433a3830cd7e952dc79e5632701ba0dc81048bc2 /providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org | |
parent | 0c462257bd337044fe6d84d6c3eca1b6c50303e6 (diff) | |
download | org.eclipse.ecf-519e3b64d4c4b8568e285547a368f1250e13297e.tar.gz org.eclipse.ecf-519e3b64d4c4b8568e285547a368f1250e13297e.tar.xz org.eclipse.ecf-519e3b64d4c4b8568e285547a368f1250e13297e.zip |
Added chatroommanagerui class to org.eclipse.ecf.presence.ui and used this new class in org.eclipse.ecf.provider.irc.ui wizard
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org')
-rw-r--r-- | providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java | 197 |
1 files changed, 107 insertions, 90 deletions
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 d765a0e4e..992d54661 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 @@ -1,90 +1,107 @@ -/****************************************************************************
- * Copyright (c) 2007 Remy Suen, 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:
- * Remy Suen <remy.suen@gmail.com> - initial API and implementation
- *****************************************************************************/
-package org.eclipse.ecf.internal.irc.ui.wizards;
-
-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.ui.IConnectWizard;
-import org.eclipse.ecf.ui.actions.AsynchContainerConnectAction;
-import org.eclipse.ecf.ui.dialogs.ContainerConnectErrorDialog;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-
-public final class IRCConnectWizard extends Wizard implements IConnectWizard {
-
- private static final int CONNECT_ERROR_CODE = 7777;
-
- private Shell shell;
-
- private IRCConnectWizardPage page;
-
- private IContainer container;
-
- private ID targetID;
-
- private IConnectContext connectContext;
-
- public void addPages() {
- page = new IRCConnectWizardPage();
- addPage(page);
- }
-
- public void init(IWorkbench workbench, IContainer container) {
- shell = workbench.getActiveWorkbenchWindow().getShell();
- this.container = container;
- }
-
- public boolean performFinish() {
- connectContext = ConnectContextFactory
- .createPasswordConnectContext(page.getPassword());
-
- try {
- targetID = IDFactory.getDefault().createID(
- container.getConnectNamespace(), page.getConnectID());
- } catch (IDCreateException e) {
- // TODO: This needs to be handled properly
- e.printStackTrace();
- return false;
- }
-
- new AsynchContainerConnectAction(this.container, this.targetID,
- this.connectContext, new IExceptionHandler() {
- public IStatus handleException(final Throwable exception) {
- if (exception != null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- new ContainerConnectErrorDialog(shell,
- CONNECT_ERROR_CODE, "See Details",
- targetID.getName(), exception)
- .open();
- }
- });
- }
- return new Status(IStatus.OK, Activator.PLUGIN_ID, 0,
- "", null);
- }
-
- }).run(null);
-
- return true;
- }
-
-}
+/**************************************************************************** + * Copyright (c) 2007 Remy Suen, 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: + * Remy Suen <remy.suen@gmail.com> - initial API and implementation + * Scott Lewis <slewis@composent.com> + *****************************************************************************/ +package org.eclipse.ecf.internal.irc.ui.wizards; + +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.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.wizard.Wizard; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; + +public final class IRCConnectWizard extends Wizard implements IConnectWizard { + + private Shell shell; + + private IRCConnectWizardPage page; + + private IContainer container; + + private ID targetID; + + private IConnectContext connectContext; + + private IExceptionHandler exceptionHandler = new IExceptionHandler() { + public IStatus handleException(final Throwable exception) { + if (exception != null) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + new ContainerConnectErrorDialog(shell, IStatus.ERROR, + "See Details", targetID.getName(), exception) + .open(); + } + }); + } + return new Status(IStatus.OK, Activator.PLUGIN_ID, IStatus.OK, + "Connected", null); + } + }; + + public void addPages() { + page = new IRCConnectWizardPage(); + addPage(page); + } + + public void init(IWorkbench workbench, IContainer container) { + shell = workbench.getActiveWorkbenchWindow().getShell(); + this.container = container; + } + + public boolean performFinish() { + connectContext = ConnectContextFactory + .createPasswordConnectContext(page.getPassword()); + + try { + targetID = IDFactory.getDefault().createID( + container.getConnectNamespace(), page.getConnectID()); + } catch (IDCreateException e) { + // TODO: This needs to be handled properly + e.printStackTrace(); + 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); + + } + } + + return true; + } + +} |