From 519e3b64d4c4b8568e285547a368f1250e13297e Mon Sep 17 00:00:00 2001 From: slewis Date: Mon, 26 Mar 2007 19:04:49 +0000 Subject: Added chatroommanagerui class to org.eclipse.ecf.presence.ui and used this new class in org.eclipse.ecf.provider.irc.ui wizard --- .../META-INF/MANIFEST.MF | 3 +- .../org.eclipse.ecf.provider.irc.ui/plugin.xml | 24 +-- .../internal/irc/ui/wizards/IRCConnectWizard.java | 197 +++++++++++---------- 3 files changed, 121 insertions(+), 103 deletions(-) (limited to 'providers/bundles/org.eclipse.ecf.provider.irc.ui') diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF index 694c69a5e..28bdd88f8 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ecf.ui, org.eclipse.ecf, org.eclipse.ui, - org.eclipse.ecf.presence + org.eclipse.ecf.presence, + org.eclipse.ecf.presence.ui Eclipse-LazyStart: true Export-Package: org.eclipse.ecf.internal.irc.ui;x-internal:=true, org.eclipse.ecf.internal.irc.ui.wizards;x-internal:=true diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml index 712213df2..cb9834bc8 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml +++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/plugin.xml @@ -1,12 +1,12 @@ - - - - - - - + + + + + + + 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 - 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 - initial API and implementation + * Scott Lewis + *****************************************************************************/ +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; + } + +} -- cgit v1.2.3