diff options
author | rsuen | 2007-03-10 03:20:37 +0000 |
---|---|---|
committer | rsuen | 2007-03-10 03:20:37 +0000 |
commit | 77a3191120dadf837091d729ebdaee916e57549b (patch) | |
tree | 347fc65d4437642c24ce1afef5ef57e2eb8e3464 /providers/bundles/org.eclipse.ecf.provider.msn.ui | |
parent | 3ca4152d8edf9b147b81ab0358ed8db33ac8be3d (diff) | |
download | org.eclipse.ecf-77a3191120dadf837091d729ebdaee916e57549b.tar.gz org.eclipse.ecf-77a3191120dadf837091d729ebdaee916e57549b.tar.xz org.eclipse.ecf-77a3191120dadf837091d729ebdaee916e57549b.zip |
Initial commit.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.msn.ui')
12 files changed, 441 insertions, 0 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/.classpath b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.classpath new file mode 100644 index 000000000..ce7393340 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/.cvsignore b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.cvsignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/.project b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.project new file mode 100644 index 000000000..9d4467552 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.ecf.provider.msn.ui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/.settings/org.eclipse.jdt.core.prefs b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..e77f6fcc8 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Sat Dec 30 20:20:26 GMT 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.msn.ui/META-INF/MANIFEST.MF new file mode 100644 index 000000000..6c24852d3 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.ecf.provider.msn.ui;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.ecf.internal.provider.msn.ui.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ecf, + org.eclipse.ecf.ui, + org.eclipse.ui, + org.eclipse.ecf.presence.ui, + org.eclipse.ecf.presence +Eclipse-LazyStart: true +Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-Vendor: %providerName diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/about.html b/providers/bundles/org.eclipse.ecf.provider.msn.ui/about.html new file mode 100644 index 000000000..8f7767892 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/about.html @@ -0,0 +1,29 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 2, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
+
diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/build.properties b/providers/bundles/org.eclipse.ecf.provider.msn.ui/build.properties new file mode 100644 index 000000000..a74843333 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/build.properties @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (c) 2007 Remy Suen 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 +################################################################################ + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.properties b/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.properties new file mode 100644 index 000000000..f49a93fd0 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.properties @@ -0,0 +1,13 @@ +################################################################################ +# Copyright (c) 2007 Remy Suen 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 +################################################################################ + +pluginName = MSN Provider UI +providerName = Eclipse.org diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.xml new file mode 100644 index 000000000..6e56cd100 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/plugin.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension + point="org.eclipse.ecf.ui.connectWizards"> + <wizard + class="org.eclipse.ecf.internal.provider.msn.ui.MSNConnectWizard" + containerFactoryName="ecf.msn.gokigenyou" + id="org.eclipse.ecf.provider.ui.msn.connectWizard" + name="MSN"/> + </extension> + +</plugin> diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/Activator.java b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/Activator.java new file mode 100644 index 000000000..e1fb02a32 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/Activator.java @@ -0,0 +1,60 @@ +/**************************************************************************** + * Copyright (c) 2007 Remy Suen 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.provider.msn.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.provider.msn.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.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizard.java b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizard.java new file mode 100644 index 000000000..b24375c9d --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizard.java @@ -0,0 +1,159 @@ +/**************************************************************************** + * Copyright (c) 2007 Remy Suen 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.provider.msn.ui; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.ecf.core.IContainer; +import org.eclipse.ecf.core.IContainerListener; +import org.eclipse.ecf.core.events.IContainerConnectedEvent; +import org.eclipse.ecf.core.events.IContainerEvent; +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.presence.IIMMessageEvent; +import org.eclipse.ecf.presence.IIMMessageListener; +import org.eclipse.ecf.presence.IPresenceContainerAdapter; +import org.eclipse.ecf.presence.im.IChatManager; +import org.eclipse.ecf.presence.im.IChatMessage; +import org.eclipse.ecf.presence.im.IChatMessageEvent; +import org.eclipse.ecf.presence.im.IChatMessageSender; +import org.eclipse.ecf.presence.ui.MessagesView; +import org.eclipse.ecf.presence.ui.MultiRosterView; +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.ui.IWorkbench; +import org.eclipse.ui.PartInitException; + +public class MSNConnectWizard extends Wizard implements IConnectWizard { + + private IWorkbench workbench; + + private MSNConnectWizardPage page; + + private IContainer container; + + private IChatMessageSender icms; + + private ID targetID; + + private IConnectContext connectContext; + + private ID userID; + + public void addPages() { + page = new MSNConnectWizardPage(); + addPage(page); + } + + public void init(IWorkbench workbench, IContainer container) { + this.workbench = workbench; + this.container = container; + } + + private void openView() { + try { + MultiRosterView view = (MultiRosterView) workbench + .getActiveWorkbenchWindow().getActivePage().showView( + MultiRosterView.VIEW_ID); + view.addContainer(container); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + private void displayMessage(IChatMessageEvent e) { + final IChatMessage message = e.getChatMessage(); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + MessagesView view = (MessagesView) workbench + .getActiveWorkbenchWindow().getActivePage() + .showView(MessagesView.VIEW_ID); + view.showMessage(icms, userID, message.getFromID(), message + .getThreadID(), message.getBody()); + } catch (PartInitException ex) { + ex.printStackTrace(); + } + } + }); + } + + public boolean performFinish() { + connectContext = ConnectContextFactory + .createPasswordConnectContext(page.getPassword()); + + try { + targetID = IDFactory.getDefault().createStringID(page.getEmail()); + } catch (IDCreateException e) { + new ContainerConnectErrorDialog(workbench + .getActiveWorkbenchWindow().getShell(), 1, + "The target ID to connect to could not be created", + targetID.getName(), e).open(); + return true; + } + + final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container + .getAdapter(IPresenceContainerAdapter.class); + container.addListener(new IContainerListener() { + public void handleEvent(IContainerEvent event) { + if (event instanceof IContainerConnectedEvent) { + userID = adapter.getRosterManager().getRoster().getUser() + .getID(); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + openView(); + } + }); + } + } + }); + + IChatManager icm = adapter.getChatManager(); + icms = icm.getChatMessageSender(); + + icm.addMessageListener(new IIMMessageListener() { + public void handleMessageEvent(IIMMessageEvent e) { + if (e instanceof IChatMessageEvent) { + displayMessage((IChatMessageEvent) e); + } + } + }); + + new AsynchContainerConnectAction(container, targetID, connectContext, + new IExceptionHandler() { + public IStatus handleException(final Throwable exception) { + if (exception != null) { + exception.printStackTrace(); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + new ContainerConnectErrorDialog(workbench + .getActiveWorkbenchWindow() + .getShell(), 1, "See Details", + targetID.getName(), exception) + .open(); + } + }); + } + return Status.OK_STATUS; + } + + }).run(null); + + return true; + } +} diff --git a/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizardPage.java b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizardPage.java new file mode 100644 index 000000000..fd99b9219 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.msn.ui/src/org/eclipse/ecf/internal/provider/msn/ui/MSNConnectWizardPage.java @@ -0,0 +1,87 @@ +/**************************************************************************** + * Copyright (c) 2007 Remy Suen 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.provider.msn.ui; + +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 MSNConnectWizardPage extends WizardPage { + + private Text emailText; + + private Text passwordText; + + MSNConnectWizardPage() { + super(""); + setTitle("MSN Connection Wizard"); + setPageComplete(false); + } + + private void addListeners() { + ModifyListener listener = new ModifyListener() { + public void modifyText(ModifyEvent e) { + String email = emailText.getText().trim(); + if (email.equals("")) { //$NON-NLS-1$ + setErrorMessage("An e-mail address must be entered."); + } else if (email.indexOf('@') == -1) { + setErrorMessage("A valid e-mail address must be entered."); + } else if (passwordText.getText().trim().equals("")) { //$NON-NLS-1$ + setErrorMessage("A password must be entered."); + } else { + setErrorMessage(null); + } + } + }; + + emailText.addModifyListener(listener); + passwordText.addModifyListener(listener); + } + + public void createControl(Composite parent) { + parent.setLayout(new GridLayout(2, false)); + + GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); + + Label label = new Label(parent, SWT.LEFT); + label.setText("E-mail address:"); + emailText = new Text(parent, SWT.SINGLE | SWT.BORDER); + emailText.setLayoutData(data); + + label = new Label(parent, SWT.LEFT); + label.setText("Password:"); + passwordText = new Text(parent, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER); + passwordText.setLayoutData(data); + + addListeners(); + setControl(parent); + } + + String getEmail() { + return emailText.getText(); + } + + String getPassword() { + return passwordText.getText(); + } + + public void setErrorMessage(String message) { + super.setErrorMessage(message); + setPageComplete(message == null); + } + +} |