diff options
author | slewis | 2007-01-13 06:36:54 +0000 |
---|---|---|
committer | slewis | 2007-01-13 06:36:54 +0000 |
commit | 0a2e29e322a3cf16cc8f043304cebe37c74a10f2 (patch) | |
tree | 02decd39dd15334284494b0b7176217b3d905958 /providers/bundles/org.eclipse.ecf.provider.xmpp.ui | |
parent | 1042c86d356153dac82fc02e2480634c9d03df6c (diff) | |
download | org.eclipse.ecf-0a2e29e322a3cf16cc8f043304cebe37c74a10f2.tar.gz org.eclipse.ecf-0a2e29e322a3cf16cc8f043304cebe37c74a10f2.tar.xz org.eclipse.ecf-0a2e29e322a3cf16cc8f043304cebe37c74a10f2.zip |
Added classes for XMPPConnectWizard/XMPPSConnectWizard, XMPPConnectWizardPage/XMPPSConnectWizardPage
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.xmpp.ui')
5 files changed, 265 insertions, 1 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/META-INF/MANIFEST.MF index d40c4b5d0..a5bd5f68c 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/META-INF/MANIFEST.MF @@ -6,5 +6,7 @@ Bundle-Version: 0.9.6 Bundle-Activator: org.eclipse.ecf.internal.provider.xmpp.ui.Activator Bundle-Vendor: Eclipse.org Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime + org.eclipse.core.runtime, + org.eclipse.ecf, + org.eclipse.ecf.ui Eclipse-AutoStart: true diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizard.java b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizard.java new file mode 100644 index 000000000..9e6ad6379 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizard.java @@ -0,0 +1,90 @@ +/**************************************************************************** + * 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.provider.xmpp.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.provider.xmpp.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 class XMPPConnectWizard extends Wizard implements IConnectWizard { + + private static final int CONNECT_ERROR_CODE = 7777; + + private Shell shell; + + private XMPPConnectWizardPage page; + + private IContainer container; + + private ID targetID; + + private IConnectContext connectContext; + + public void addPages() { + page = new XMPPConnectWizardPage(); + 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; + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizardPage.java b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizardPage.java new file mode 100644 index 000000000..15985e0af --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPConnectWizardPage.java @@ -0,0 +1,83 @@ +/**************************************************************************** + * 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.provider.xmpp.ui.wizards; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class XMPPConnectWizardPage extends WizardPage { + + private Text connectText; + + private Text passwordText; + + XMPPConnectWizardPage() { + super(""); + setTitle("XMPP Connection Wizard"); + setDescription("Specify a nickname and XMPP server to connect to."); + } + + public void createControl(Composite parent) { + parent.setLayout(new GridLayout()); + GridData fillData = new GridData(SWT.FILL, SWT.CENTER, true, false); + GridData endData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); + + Label label = new Label(parent, SWT.LEFT); + label.setText("Connect ID:"); + + connectText = new Text(parent, SWT.SINGLE | SWT.BORDER); + connectText.setLayoutData(fillData); + connectText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (!connectText.getText().equals("")) { //$NON-NLS-1$ + updateStatus(null); + } else { + updateStatus("An connect ID must be specified."); + } + } + }); + + label = new Label(parent, SWT.RIGHT); + label.setText("xmpp://<user>@<xmppserver>[:port][/<#channel>]"); + label.setLayoutData(endData); + + label = new Label(parent, SWT.LEFT); + label.setText("Password:"); + passwordText = new Text(parent, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER); + passwordText.setLayoutData(fillData); + label = new Label(parent, SWT.RIGHT | SWT.WRAP); + label.setText("This password is for password-protected XMPP servers."); + label.setLayoutData(endData); + + setControl(parent); + } + + String getConnectID() { + return connectText.getText(); + } + + String getPassword() { + return passwordText.getText(); + } + + protected void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizard.java b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizard.java new file mode 100644 index 000000000..8776901f2 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizard.java @@ -0,0 +1,20 @@ +/**************************************************************************** + * 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.provider.xmpp.ui.wizards; + + +public final class XMPPSConnectWizard extends XMPPConnectWizard { + + public void addPages() { + addPage(new XMPPSConnectWizardPage()); + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizardPage.java b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizardPage.java new file mode 100644 index 000000000..796471fb5 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/provider/xmpp/ui/wizards/XMPPSConnectWizardPage.java @@ -0,0 +1,69 @@ +/**************************************************************************** + * 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.provider.xmpp.ui.wizards; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +final class XMPPSConnectWizardPage extends XMPPConnectWizardPage { + + private Text connectText; + + private Text passwordText; + + XMPPSConnectWizardPage() { + super(); + setTitle("XMPPS Connection Wizard"); + setDescription("Specify a nickname and XMPPS server to connect to."); + } + + public void createControl(Composite parent) { + parent.setLayout(new GridLayout()); + GridData fillData = new GridData(SWT.FILL, SWT.CENTER, true, false); + GridData endData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); + + Label label = new Label(parent, SWT.LEFT); + label.setText("Connect ID:"); + + connectText = new Text(parent, SWT.SINGLE | SWT.BORDER); + connectText.setLayoutData(fillData); + connectText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + if (!connectText.getText().equals("")) { //$NON-NLS-1$ + updateStatus(null); + } else { + updateStatus("An connect ID must be specified."); + } + } + }); + + label = new Label(parent, SWT.RIGHT); + label.setText("xmpps://<user>@<xmppserver>[:port][/<#channel>]"); + label.setLayoutData(endData); + + label = new Label(parent, SWT.LEFT); + label.setText("Password:"); + passwordText = new Text(parent, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER); + passwordText.setLayoutData(fillData); + label = new Label(parent, SWT.RIGHT | SWT.WRAP); + label.setText("This password is for password-protected XMPP servers."); + label.setLayoutData(endData); + + setControl(parent); + } + +} |