Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2007-01-12 15:13:39 -0500
committerrsuen2007-01-12 15:13:39 -0500
commit6cb65ead7fcd323485b6d976e87361536ea44d58 (patch)
tree46457e047a80abbbec098af3a6f6e7febd6a246a /providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf
parentb091d259736af14fb59060464bfcdaad75f3703b (diff)
downloadorg.eclipse.ecf-6cb65ead7fcd323485b6d976e87361536ea44d58.tar.gz
org.eclipse.ecf-6cb65ead7fcd323485b6d976e87361536ea44d58.tar.xz
org.eclipse.ecf-6cb65ead7fcd323485b6d976e87361536ea44d58.zip
Moving this from org.eclipse.ecf.irc.ui to org.eclipse.ecf.provider.irc.ui.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Activator.java62
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.java90
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.java83
3 files changed, 235 insertions, 0 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Activator.java b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Activator.java
new file mode 100644
index 000000000..68e574963
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/Activator.java
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * 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;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.irc.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
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
new file mode 100644
index 000000000..d765a0e4e
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizard.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.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;
+ }
+
+}
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
new file mode 100644
index 000000000..614392566
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.irc.ui/src/org/eclipse/ecf/internal/irc/ui/wizards/IRCConnectWizardPage.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.internal.irc.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;
+
+final class IRCConnectWizardPage extends WizardPage {
+
+ private Text connectText;
+
+ private Text passwordText;
+
+ IRCConnectWizardPage() {
+ super("");
+ setTitle("IRC Connection Wizard");
+ setDescription("Specify a nickname and IRC 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("irc://<user>@<ircserver>[/<#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 IRC servers.");
+ label.setLayoutData(endData);
+
+ setControl(parent);
+ }
+
+ String getConnectID() {
+ return connectText.getText();
+ }
+
+ String getPassword() {
+ return passwordText.getText();
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+}

Back to the top