From c9f749182e82cbd8e741a716485ab99928fbdf7a Mon Sep 17 00:00:00 2001 From: Javier Montalvo Orus Date: Thu, 7 Sep 2006 12:14:58 +0000 Subject: [PATCH] Initial population --- .../org.eclipse.rse.discovery/.classpath | 7 + discovery/org.eclipse.rse.discovery/.project | 28 + .../META-INF/MANIFEST.MF | 16 + .../org.eclipse.rse.discovery/about.html | 29 + .../build.properties | 4 + .../org.eclipse.rse.discovery/plugin.xml | 29 + .../org/eclipse/rse/discovery/Activator.java | 60 ++ .../org/eclipse/rse/discovery/Messages.java | 43 ++ .../rse/discovery/ServiceDiscoveryWizard.java | 130 ++++ .../ServiceDiscoveryWizardDelegate.java | 90 +++ .../eclipse/rse/discovery/messages.properties | 15 + .../.classpath | 7 + .../.project | 28 + .../META-INF/MANIFEST.MF | 12 + .../about.html | 29 + .../build.properties | 4 + .../plugin.xml | 10 + .../tm/discovery/transport/udp/Activator.java | 50 ++ .../discovery/transport/udp/UDPTransport.java | 104 ++++ .../org.eclipse.tm.discovery.view/.classpath | 7 + .../org.eclipse.tm.discovery.view/.project | 28 + .../META-INF/MANIFEST.MF | 24 + .../org.eclipse.tm.discovery.view/about.html | 29 + .../build.properties | 9 + .../icons/system_view.gif | Bin 0 -> 362 bytes .../org.eclipse.tm.discovery.view/plugin.xml | 30 + .../eclipse/tm/discovery/view/Activator.java | 71 +++ .../eclipse/tm/discovery/view/Messages.java | 56 ++ .../discovery/view/ServiceDiscoveryView.java | 313 ++++++++++ .../tm/discovery/view/messages.properties | 26 + .../.classpath | 7 + .../org.eclipse.tm.discovery.wizard/.project | 28 + .../META-INF/MANIFEST.MF | 17 + .../about.html | 29 + .../build.properties | 4 + .../tm/discovery/wizard/Activator.java | 60 ++ .../eclipse/tm/discovery/wizard/Messages.java | 32 + .../ServiceDiscoveryWizardDisplayPage.java | 589 ++++++++++++++++++ .../ServiceDiscoveryWizardMainPage.java | 200 ++++++ .../tm/discovery/wizard/messages.properties | 34 + 40 files changed, 2288 insertions(+) create mode 100644 discovery/org.eclipse.rse.discovery/.classpath create mode 100644 discovery/org.eclipse.rse.discovery/.project create mode 100644 discovery/org.eclipse.rse.discovery/META-INF/MANIFEST.MF create mode 100644 discovery/org.eclipse.rse.discovery/about.html create mode 100644 discovery/org.eclipse.rse.discovery/build.properties create mode 100644 discovery/org.eclipse.rse.discovery/plugin.xml create mode 100644 discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Activator.java create mode 100644 discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Messages.java create mode 100644 discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizard.java create mode 100644 discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java create mode 100644 discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/messages.properties create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/.classpath create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/.project create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/META-INF/MANIFEST.MF create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/about.html create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/build.properties create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/plugin.xml create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/Activator.java create mode 100644 discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/UDPTransport.java create mode 100644 discovery/org.eclipse.tm.discovery.view/.classpath create mode 100644 discovery/org.eclipse.tm.discovery.view/.project create mode 100644 discovery/org.eclipse.tm.discovery.view/META-INF/MANIFEST.MF create mode 100644 discovery/org.eclipse.tm.discovery.view/about.html create mode 100644 discovery/org.eclipse.tm.discovery.view/build.properties create mode 100644 discovery/org.eclipse.tm.discovery.view/icons/system_view.gif create mode 100644 discovery/org.eclipse.tm.discovery.view/plugin.xml create mode 100644 discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Activator.java create mode 100644 discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Messages.java create mode 100644 discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/ServiceDiscoveryView.java create mode 100644 discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/messages.properties create mode 100644 discovery/org.eclipse.tm.discovery.wizard/.classpath create mode 100644 discovery/org.eclipse.tm.discovery.wizard/.project create mode 100644 discovery/org.eclipse.tm.discovery.wizard/META-INF/MANIFEST.MF create mode 100644 discovery/org.eclipse.tm.discovery.wizard/about.html create mode 100644 discovery/org.eclipse.tm.discovery.wizard/build.properties create mode 100644 discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Activator.java create mode 100644 discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Messages.java create mode 100644 discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/ServiceDiscoveryWizardDisplayPage.java create mode 100644 discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/ServiceDiscoveryWizardMainPage.java create mode 100644 discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/messages.properties diff --git a/discovery/org.eclipse.rse.discovery/.classpath b/discovery/org.eclipse.rse.discovery/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/discovery/org.eclipse.rse.discovery/.project b/discovery/org.eclipse.rse.discovery/.project new file mode 100644 index 00000000000..26cf0633cda --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/.project @@ -0,0 +1,28 @@ + + + org.eclipse.rse.discovery + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/discovery/org.eclipse.rse.discovery/META-INF/MANIFEST.MF b/discovery/org.eclipse.rse.discovery/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..c52d64cc956 --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Service Discovery RSE Plug-in +Bundle-SymbolicName: org.eclipse.rse.discovery;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.rse.discovery.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.rse.ui, + org.eclipse.rse.core, + org.eclipse.emf.ecore;bundle-version="2.2.0", + org.eclipse.tm.discovery.wizard, + org.eclipse.tm.discovery.model +Eclipse-LazyStart: true +Bundle-Vendor: Symbian diff --git a/discovery/org.eclipse.rse.discovery/about.html b/discovery/org.eclipse.rse.discovery/about.html new file mode 100644 index 00000000000..928af38d499 --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/about.html @@ -0,0 +1,29 @@ + +About + + + + +

About This Content

+ +

July 27, 2006

+

License

+ +

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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/discovery/org.eclipse.rse.discovery/build.properties b/discovery/org.eclipse.rse.discovery/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/discovery/org.eclipse.rse.discovery/plugin.xml b/discovery/org.eclipse.rse.discovery/plugin.xml new file mode 100644 index 00000000000..4eaffc35a4e --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/plugin.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Activator.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Activator.java new file mode 100644 index 00000000000..e7e5ce370b3 --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Activator.java @@ -0,0 +1,60 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.rse.discovery; + +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.rse.discovery"; + + // 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/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Messages.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Messages.java new file mode 100644 index 00000000000..90659a7b23b --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/Messages.java @@ -0,0 +1,43 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.rse.discovery; +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.rse.discovery.messages"; //$NON-NLS-1$ + + public static String ServiceDiscoveryWizard_DiscoveryPropertySet; + + public static String ServiceDiscoveryWizard_Port; + + public static String ServiceDiscoveryWizard_SavingMessage; + + public static String ServiceDiscoveryWizard_StatusId; + + public static String ServiceDiscoveryWizard_StatusMessage; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizard.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizard.java new file mode 100644 index 00000000000..78a20cb0879 --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizard.java @@ -0,0 +1,130 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.rse.discovery; + +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.rse.model.IHost; +import org.eclipse.rse.model.IPropertySet; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.tm.discovery.model.Pair; +import org.eclipse.tm.discovery.model.Service; +import org.eclipse.tm.discovery.model.ServiceType; +import org.eclipse.tm.discovery.wizard.ServiceDiscoveryWizardDisplayPage; +import org.eclipse.tm.discovery.wizard.ServiceDiscoveryWizardMainPage; + +/** + * Service Discovery Wizard + */ + +public class ServiceDiscoveryWizard extends Wizard { + private ServiceDiscoveryWizardMainPage serviceDiscoveryMainPage; + + private ServiceDiscoveryWizardDisplayPage serviceDiscoveryPage = null; + + /** + * Service Discovery Wizard constructor + */ + public ServiceDiscoveryWizard() { + super(); + setNeedsProgressMonitor(false); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + public void addPages() { + + serviceDiscoveryMainPage = new ServiceDiscoveryWizardMainPage(); + addPage(serviceDiscoveryMainPage); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getNextPage(IWizardPage page) { + + if (page instanceof ServiceDiscoveryWizardMainPage) { + if (serviceDiscoveryPage == null) { + serviceDiscoveryPage = new ServiceDiscoveryWizardDisplayPage(serviceDiscoveryMainPage.getQuery(), serviceDiscoveryMainPage.getAddress(), serviceDiscoveryMainPage.getTransport(), serviceDiscoveryMainPage.getProtocol(), serviceDiscoveryMainPage.getTimeOut()); + addPage(serviceDiscoveryPage); + } else { + serviceDiscoveryPage.update(serviceDiscoveryMainPage.getQuery(), serviceDiscoveryMainPage.getAddress(), serviceDiscoveryMainPage.getTransport(), serviceDiscoveryMainPage.getProtocol(), serviceDiscoveryMainPage.getTimeOut()); + } + } + return super.getNextPage(page); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + public boolean performFinish() { + + String[] addresses = serviceDiscoveryPage.getAddresses(); + for (int i = 0; i < addresses.length; i++) { + + String hostName = addresses[i]; + Vector discoveredServices = serviceDiscoveryPage.getSelectedServices(addresses[i]); + + Enumeration serviceEnumeration = discoveredServices.elements(); + + while (serviceEnumeration.hasMoreElements()) { + IHost conn = null; + + Service service = (Service) serviceEnumeration.nextElement(); + String sysTypeString = ((ServiceType) service.eContainer()).getName(); + + try { + conn = RSEUIPlugin.getDefault().getSystemRegistry().createHost(sysTypeString, service.getName() + "@" + hostName, hostName, "Discovered "+sysTypeString+" server in "+hostName); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + e.printStackTrace(); + } + + if (conn != null) { + //copy discovered properties to RSE model + IPropertySet ps = conn.getConnectorServices()[0].createPropertySet(Messages.ServiceDiscoveryWizard_DiscoveryPropertySet); + Iterator pairIterator = service.getPair().iterator(); + while (pairIterator.hasNext()) { + Pair pair = (Pair) pairIterator.next(); + ps.addProperty(pair.getKey(), pair.getValue()); + + //add port to the RSE connection + if (pair.getKey().equalsIgnoreCase(Messages.ServiceDiscoveryWizard_Port)) { + conn.getConnectorServices()[0].setPort(Integer.parseInt(pair.getValue())); + } + } + RSEUIPlugin.getDefault().getSystemRegistry().expandHost(conn); + } + } + + (new Job(Messages.ServiceDiscoveryWizard_SavingMessage) { + + protected IStatus run(IProgressMonitor monitor) { + RSEUIPlugin.getDefault().getSystemRegistry().save(); + return new Status(IStatus.OK, Messages.ServiceDiscoveryWizard_StatusId, IStatus.OK, Messages.ServiceDiscoveryWizard_StatusMessage, null); + } + }).schedule(5000); + + } + return true; + } + +} \ No newline at end of file diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java new file mode 100644 index 00000000000..516d66ff52c --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java @@ -0,0 +1,90 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.rse.discovery; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.model.IHost; +import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; +import org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate; + +/** + * RSE Wizard extension for Service Discovery + */ + +public class ServiceDiscoveryWizardDelegate extends RSENewConnectionWizardDelegate { + + private ServiceDiscoveryWizard subWizard; + + private boolean isSubWizardCreated; + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType) + */ + public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { + super.init(wizard, systemType); + subWizard = new ServiceDiscoveryWizard(); + isSubWizardCreated = false; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getDummyHost() + */ + public IHost getDummyHost() { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getMainPage() + */ + public IWizardPage getMainPage() { + if (!isSubWizardCreated) { + subWizard.addPages(); + isSubWizardCreated = true; + } + IWizardPage firstSubPage = subWizard.getStartingPage(); + return firstSubPage; + + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#performFinish() + */ + public boolean performFinish() { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#canFinish() + */ + public boolean canFinish() { + return subWizard.canFinish(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#getNextPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getNextPage(IWizardPage page) { + return subWizard.getNextPage(page); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getPreviousPage(IWizardPage page) { + if (page == getMainPage()) { + return getWizard().getPreviousPage(page); + } else { + return subWizard.getPreviousPage(page); + } + } + +} diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/messages.properties b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/messages.properties new file mode 100644 index 00000000000..8f14ae4242e --- /dev/null +++ b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/messages.properties @@ -0,0 +1,15 @@ +################################################################################## +# Copyright (c) 2006 Symbian Software Ltd. 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: +# Javier Montalvo Orús (Symbian) - initial API and implementation +################################################################################## + +ServiceDiscoveryWizard_DiscoveryPropertySet=Discovery +ServiceDiscoveryWizard_Port=port +ServiceDiscoveryWizard_SavingMessage=Saving RSE model +ServiceDiscoveryWizard_StatusId=org.eclipse.tm.discovery.wizard +ServiceDiscoveryWizard_StatusMessage=RSE model saved diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/.classpath b/discovery/org.eclipse.tm.discovery.transport.udp/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/.project b/discovery/org.eclipse.tm.discovery.transport.udp/.project new file mode 100644 index 00000000000..31a4ba76468 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/.project @@ -0,0 +1,28 @@ + + + org.eclipse.tm.discovery.transport.udp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/META-INF/MANIFEST.MF b/discovery/org.eclipse.tm.discovery.transport.udp/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..21871043d3d --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: UDP Transport Plug-in +Bundle-SymbolicName: org.eclipse.tm.discovery.transport.udp;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.tm.discovery.transport.udp.Activator +Bundle-Vendor: Symbian +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.tm.discovery.engine +Eclipse-LazyStart: true diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/about.html b/discovery/org.eclipse.tm.discovery.transport.udp/about.html new file mode 100644 index 00000000000..928af38d499 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/about.html @@ -0,0 +1,29 @@ + +About + + + + +

About This Content

+ +

July 27, 2006

+

License

+ +

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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/build.properties b/discovery/org.eclipse.tm.discovery.transport.udp/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/plugin.xml b/discovery/org.eclipse.tm.discovery.transport.udp/plugin.xml new file mode 100644 index 00000000000..5951d38e4f0 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/Activator.java b/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/Activator.java new file mode 100644 index 00000000000..6dd8a85c5e8 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.tm.discovery.transport.udp; + +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.tm.discovery.transport.udp"; + + // 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/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/UDPTransport.java b/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/UDPTransport.java new file mode 100644 index 00000000000..00386e5ac30 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.transport.udp/src/org/eclipse/tm/discovery/transport/udp/UDPTransport.java @@ -0,0 +1,104 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.transport.udp; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.tm.discovery.transport.ITransport; + +/** + * UPD/IP transport implementation + */ + +public class UDPTransport implements ITransport { + + // Default multicast DNS port + public static int MDNS_PORT = 5353; + + // DNS-SD multicast address + public static String MULTICAST_ADDRESS = "224.0.0.251"; //$NON-NLS-1$ + + private DatagramSocket socket = null; + + private InetAddress server = null; + + private int port = MDNS_PORT; + + /** + * Constructor for transport for UDP/IP + */ + + public UDPTransport() { + try { + socket = new DatagramSocket(); + } catch (SocketException e) { + e.printStackTrace(); + } + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.discovery.transport.ITransport#setTargetAddress(java.lang.String) + */ + public void setTargetAddress(String address) throws UnknownHostException + { + + Pattern pattern = Pattern.compile("([^:]*)(:(\\d+))?"); //$NON-NLS-1$ + Matcher matcher = pattern.matcher(address); + if (matcher.matches()) { + server = InetAddress.getByName(matcher.group(1)); + if (server.isLoopbackAddress()) { + server = InetAddress.getLocalHost(); + } + + if (matcher.groupCount() == 3 && matcher.group(3) != null) + port = Integer.parseInt(matcher.group(3)); + } + + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.discovery.transport.ITransport#setTimeOut(int) + */ + public void setTimeOut(int timeOut) throws SocketException + { + socket.setSoTimeout(timeOut); + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.discovery.transport.ITransport#send(byte[]) + */ + public void send(byte[] packet) throws IOException { + DatagramPacket packetOut = new DatagramPacket(packet, packet.length,server, port); + socket.send(packetOut); + } + + + /* (non-Javadoc) + * @see org.eclipse.tm.discovery.transport.ITransport#receive(byte[]) + */ + public String receive(byte[] packet) throws IOException { + DatagramPacket packetIn = new DatagramPacket(packet, packet.length); + socket.receive(packetIn); + + return packetIn.getAddress().getHostAddress(); + } + +} diff --git a/discovery/org.eclipse.tm.discovery.view/.classpath b/discovery/org.eclipse.tm.discovery.view/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/discovery/org.eclipse.tm.discovery.view/.project b/discovery/org.eclipse.tm.discovery.view/.project new file mode 100644 index 00000000000..edc1b4cc7b7 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/.project @@ -0,0 +1,28 @@ + + + org.eclipse.tm.discovery.view + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/discovery/org.eclipse.tm.discovery.view/META-INF/MANIFEST.MF b/discovery/org.eclipse.tm.discovery.view/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..ad827e44d00 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Service Discovery View Plug-in +Bundle-SymbolicName: org.eclipse.tm.discovery.view;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.tm.discovery.view.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui.forms, + org.eclipse.tm.discovery.engine, + org.eclipse.tm.discovery.model, + org.eclipse.tm.discovery.model.edit, + org.eclipse.core.resources, + org.eclipse.emf.edit.ui;bundle-version="2.2.0", + org.eclipse.tm.discovery.wizard, + org.eclipse.ui.ide +Eclipse-LazyStart: false +Import-Package: org.eclipse.emf.common.ui, + org.eclipse.emf.common.util, + org.eclipse.tm.discovery.engine, + org.eclipse.tm.discovery.model.provider, + org.eclipse.tm.discovery.model.util +Export-Package: org.eclipse.tm.discovery.view +Bundle-Vendor: Symbian diff --git a/discovery/org.eclipse.tm.discovery.view/about.html b/discovery/org.eclipse.tm.discovery.view/about.html new file mode 100644 index 00000000000..b44929ae01d --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/about.html @@ -0,0 +1,29 @@ + +About + + + + +

About This Content

+ +

June 16, 2006

+

License

+ +

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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/discovery/org.eclipse.tm.discovery.view/build.properties b/discovery/org.eclipse.tm.discovery.view/build.properties new file mode 100644 index 00000000000..7f02c0aadd1 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/build.properties @@ -0,0 +1,9 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + about.html +src.includes = about.html + diff --git a/discovery/org.eclipse.tm.discovery.view/icons/system_view.gif b/discovery/org.eclipse.tm.discovery.view/icons/system_view.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3fe221a1d9398f10cec5def599c9e062f65ef28 GIT binary patch literal 362 zcmZ?wbhEHb6krfwxXQqA)G4zdA)_LrprN3mF0Zbmp`)RqVaJ9YkMBP|f9Cv!3pd`p zdB0}e*3zo3%9cen?Mu3*tf{PRU%Bz{`mKkz?>)70&E}Q~D=X_dd?E`EpSYNsTeW1} z{&`E*EnK#4``%+mPF)tsb`i~X7R_;%DfEyj^i(PL*RBawDfiQ^2{CAhD4O3~u%V!0 zL&1U*4aZI%+_HVu|KI2S|NqZGG*JA>!pOj2$e;t#0rC?ATl;|-1sWxZeIDWyJAPWs zM9N(=M}v^#4~o-83PHbZP8JG+{Wu8s!B;>COuxwzD|4YXBPtl;LK$jGQXUq^+J biJ6U4YNC^(g3=Lvx#M!~`Y~q=9T}_vHj0Sg literal 0 HcmV?d00001 diff --git a/discovery/org.eclipse.tm.discovery.view/plugin.xml b/discovery/org.eclipse.tm.discovery.view/plugin.xml new file mode 100644 index 00000000000..edeb4f0bf72 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Activator.java b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Activator.java new file mode 100644 index 00000000000..65a70502d5f --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Activator.java @@ -0,0 +1,71 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.view; + +import org.eclipse.jface.resource.ImageDescriptor; +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.rse.discovery.view"; + + // 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; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Messages.java b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Messages.java new file mode 100644 index 00000000000..334282f246e --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/Messages.java @@ -0,0 +1,56 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.view; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.tm.discovery.view.messages"; //$NON-NLS-1$ + + public static String ServiceDiscoveryView_ClearActionText; + + public static String ServiceDiscoveryView_ClearActionToolTipText; + + public static String ServiceDiscoveryView_DiscoveryActionText; + + public static String ServiceDiscoveryView_DiscoveryActionToolTipText; + + public static String ServiceDiscoveryView_KeyColumnLabel; + + public static String ServiceDiscoveryView_PropertiesTableTitle; + + public static String ServiceDiscoveryView_ProtocolErrorDialogMessage; + + public static String ServiceDiscoveryView_ProtocolErrorDialogTitle; + + public static String ServiceDiscoveryView_RefreshActionText; + + public static String ServiceDiscoveryView_RefreshActionToolTipText; + + public static String ServiceDiscoveryView_ServicesTreeTitle; + + public static String ServiceDiscoveryView_TransportErrorDialogMessage; + + public static String ServiceDiscoveryView_TransportErrorDialogTitle; + + public static String ServiceDiscoveryView_TransportNoAddressFoundDialogTitle; + + public static String ServiceDiscoveryView_TransportNoAddressFoundDialogTransport; + + public static String ServiceDiscoveryView_ValueColumnLabel; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/ServiceDiscoveryView.java b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/ServiceDiscoveryView.java new file mode 100644 index 00000000000..0c6bb5a4871 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/ServiceDiscoveryView.java @@ -0,0 +1,313 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.view; + +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.ui.ViewerPane; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; +import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.tm.discovery.engine.ServiceDiscoveryEngine; +import org.eclipse.tm.discovery.model.Service; +import org.eclipse.tm.discovery.model.provider.ModelItemProviderAdapterFactory; +import org.eclipse.tm.discovery.protocol.IProtocol; +import org.eclipse.tm.discovery.protocol.ProtocolFactory; +import org.eclipse.tm.discovery.transport.ITransport; +import org.eclipse.tm.discovery.transport.TransportFactory; +import org.eclipse.tm.discovery.wizard.ServiceDiscoveryWizardMainPage; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; +import org.eclipse.ui.part.ViewPart; + +/** + * View to display the Service Discovery model in a tree form. + * + * @see TransportFactory + * @see ServiceDiscoveryEngine + * + */ +public class ServiceDiscoveryView extends ViewPart { + + //Tree widgets + private TreeViewer treeViewer; + private ViewerPane viewerPaneTree; + + // Table widgets + private TableViewer tableViewer; + private ViewerPane viewerPaneTable; + + private String query = null; + + private Table table; + + private Action discoveryAction; + private Action refreshAction; + private Action clearAction; + + private ITransport transport = null; + private IProtocol protocol = null; + + private ServiceDiscoveryWizardMainPage serviceDiscoveryWizardMainPage; + private Resource resource; + + private ServiceDiscoveryEngine serviceDiscoveryEngine = ServiceDiscoveryEngine.getServiceDiscoveryEngine(); + +public void createPartControl(Composite parent) { + + resource = serviceDiscoveryEngine.getResource(); + + List factories = new ArrayList(); + factories.add(new ResourceItemProviderAdapterFactory()); + factories.add(new ModelItemProviderAdapterFactory()); + factories.add(new ReflectiveItemProviderAdapterFactory()); + + ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory( + factories); + + Composite comp = new Composite(parent, SWT.NULL); + + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + comp.setLayout(gridLayout); + + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + data.verticalAlignment = GridData.FILL; + data.grabExcessVerticalSpace = true; + + SashForm sashForm = new SashForm(comp,SWT.NULL ); + sashForm.setOrientation(SWT.HORIZONTAL); + + sashForm.setLayoutData(data); + + // TREE + + viewerPaneTree = new ViewerPane(getSite().getPage(), ServiceDiscoveryView.this) { + public Viewer createViewer(Composite composite) { + Tree tree = new Tree(composite, SWT.NULL); + ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(tree); + + return treeViewer; + } + + public void requestActivation() { + super.requestActivation(); + } + }; + + Composite sashComposite = new Composite(sashForm,SWT.BORDER); + sashComposite.setLayout(new FillLayout()); + + viewerPaneTree.createControl(sashComposite); + + treeViewer = (TreeViewer) viewerPaneTree.getViewer(); + + treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + + treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + + viewerPaneTree.setTitle(Messages.ServiceDiscoveryView_ServicesTreeTitle, null); + + treeViewer.setInput(resource); + + new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); + + ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + if(!event.getSelection().isEmpty()) + { + EObject obj = (EObject)((IStructuredSelection) event.getSelection()).getFirstElement(); + + if(obj instanceof Service) + tableViewer.setInput(obj); + } + } + }); + + + // TABLE + + viewerPaneTable = + new ViewerPane(getSite().getPage(), ServiceDiscoveryView.this) { + public Viewer createViewer(Composite composite) { + return new TableViewer(composite); + } + }; + + Composite c3 = new Composite(sashForm,SWT.BORDER); + c3.setLayout(new FillLayout()); + + viewerPaneTable.createControl(c3); + tableViewer = (TableViewer)viewerPaneTable.getViewer(); + + viewerPaneTable.setTitle(Messages.ServiceDiscoveryView_PropertiesTableTitle, null); + + + table = tableViewer.getTable(); + + TableLayout layout = new TableLayout(); + table.setLayout(layout); + + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableColumn objectColumn = new TableColumn(table, SWT.NONE); + layout.addColumnData(new ColumnWeightData(3, 100, true)); + objectColumn.setText(Messages.ServiceDiscoveryView_KeyColumnLabel); + objectColumn.setResizable(true); + + TableColumn selfColumn = new TableColumn(table, SWT.NONE); + layout.addColumnData(new ColumnWeightData(2, 100, true)); + selfColumn.setText(Messages.ServiceDiscoveryView_ValueColumnLabel); + selfColumn.setResizable(true); + + tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + + tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + + makeActions(); + + getViewSite().getActionBars().getToolBarManager().add(discoveryAction); + getViewSite().getActionBars().getToolBarManager().add(new Separator()); + getViewSite().getActionBars().getToolBarManager().add(refreshAction); + getViewSite().getActionBars().getToolBarManager().add(new Separator()); + getViewSite().getActionBars().getToolBarManager().add(clearAction); + + } + + private void update(String query, String address, String transportName, String protocolName, int timeOut) + { + this.query = query; + + //instantiate protocol and transport from factories (extensions) + + try { + protocol = ProtocolFactory.getProtocol(protocolName); + } catch (Exception e) { + MessageDialog.openError(new Shell(), Messages.ServiceDiscoveryView_ProtocolErrorDialogTitle, Messages.ServiceDiscoveryView_ProtocolErrorDialogMessage+protocolName); + } + + try { + transport = TransportFactory.getTransport(transportName, address, timeOut); + } catch (UnknownHostException e) { + MessageDialog.openError(new Shell(), Messages.ServiceDiscoveryView_TransportNoAddressFoundDialogTitle, Messages.ServiceDiscoveryView_TransportNoAddressFoundDialogTransport+address); + } catch (Exception e) { + MessageDialog.openError(new Shell(), Messages.ServiceDiscoveryView_TransportErrorDialogTitle, Messages.ServiceDiscoveryView_TransportErrorDialogMessage+transportName); + } + + + if(protocol != null && transport != null) + { + serviceDiscoveryEngine.doServiceDiscovery(query, protocol,transport); + } + } + + + + private void makeActions() { + discoveryAction = new Action() { + public void run() { + + Wizard wizard = new Wizard(){ + + public boolean performFinish() { + + update(serviceDiscoveryWizardMainPage.getQuery(), + serviceDiscoveryWizardMainPage.getAddress(), + serviceDiscoveryWizardMainPage.getTransport(), + serviceDiscoveryWizardMainPage.getProtocol(), + serviceDiscoveryWizardMainPage.getTimeOut()); + + return true; + }}; + + serviceDiscoveryWizardMainPage = new ServiceDiscoveryWizardMainPage(); + + wizard.addPage(serviceDiscoveryWizardMainPage); + + Shell shell = new Shell(); + WizardDialog dialog = new WizardDialog(shell, wizard); + + Rectangle absoluteRect = shell.getMonitor().getClientArea(); + Rectangle shellRect = shell.getBounds(); + shell.setLocation(((absoluteRect.width - shellRect.width) / 2), ((absoluteRect.height - shellRect.height) / 2)); + + dialog.open(); + } + }; + + discoveryAction.setText(Messages.ServiceDiscoveryView_DiscoveryActionText); + discoveryAction.setToolTipText(Messages.ServiceDiscoveryView_DiscoveryActionToolTipText); + discoveryAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD)); + + refreshAction = new Action() { + public void run() { + if(query != null && transport != null && protocol != null) + { + serviceDiscoveryEngine.doServiceDiscovery(query, protocol,transport); + } + } + }; + refreshAction.setText(Messages.ServiceDiscoveryView_RefreshActionText); + refreshAction.setToolTipText(Messages.ServiceDiscoveryView_RefreshActionToolTipText); + refreshAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO)); + + + clearAction = new Action() { + public void run() { + resource.getContents().clear(); + tableViewer.setInput(null); + } + }; + clearAction.setText(Messages.ServiceDiscoveryView_ClearActionText); + clearAction.setToolTipText(Messages.ServiceDiscoveryView_ClearActionToolTipText); + clearAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); + + } + + public void setFocus() { + } + +} diff --git a/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/messages.properties b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/messages.properties new file mode 100644 index 00000000000..61dd8f10f79 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.view/src/org/eclipse/tm/discovery/view/messages.properties @@ -0,0 +1,26 @@ +################################################################################## +# Copyright (c) 2006 Symbian Software Ltd. 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: +# Javier Montalvo Orús (Symbian) - initial API and implementation +################################################################################## + +ServiceDiscoveryView_ServicesTreeTitle=\ \ \ \ \ \ \ \ Services +ServiceDiscoveryView_PropertiesTableTitle=\ \ \ \ \ \ \ \ Properties +ServiceDiscoveryView_KeyColumnLabel=Key +ServiceDiscoveryView_ValueColumnLabel=Value +ServiceDiscoveryView_ProtocolErrorDialogTitle=Error +ServiceDiscoveryView_ProtocolErrorDialogMessage=Error loading protocol +ServiceDiscoveryView_TransportNoAddressFoundDialogTitle=Error +ServiceDiscoveryView_TransportNoAddressFoundDialogTransport=Error resolving address +ServiceDiscoveryView_TransportErrorDialogTitle=Error +ServiceDiscoveryView_TransportErrorDialogMessage=Error loading transport +ServiceDiscoveryView_DiscoveryActionText=New Service Discovery +ServiceDiscoveryView_DiscoveryActionToolTipText=New Service Discovery +ServiceDiscoveryView_RefreshActionText=Refresh +ServiceDiscoveryView_RefreshActionToolTipText=Refresh +ServiceDiscoveryView_ClearActionText=Clear +ServiceDiscoveryView_ClearActionToolTipText=Clear diff --git a/discovery/org.eclipse.tm.discovery.wizard/.classpath b/discovery/org.eclipse.tm.discovery.wizard/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/discovery/org.eclipse.tm.discovery.wizard/.project b/discovery/org.eclipse.tm.discovery.wizard/.project new file mode 100644 index 00000000000..e2bf0a62dfb --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/.project @@ -0,0 +1,28 @@ + + + org.eclipse.tm.discovery.wizard + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/discovery/org.eclipse.tm.discovery.wizard/META-INF/MANIFEST.MF b/discovery/org.eclipse.tm.discovery.wizard/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..7555e408128 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Service Discovery Wizard Pages Plug-in +Bundle-SymbolicName: org.eclipse.tm.discovery.wizard +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.tm.discovery.wizard.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.emf.ecore.edit;bundle-version="2.2.0", + org.eclipse.emf.edit.ui;bundle-version="2.2.0", + org.eclipse.core.runtime, + org.eclipse.tm.discovery.engine, + org.eclipse.tm.discovery.model, + org.eclipse.tm.discovery.model.edit +Eclipse-LazyStart: true +Export-Package: org.eclipse.tm.discovery.wizard +Bundle-Vendor: Symbian diff --git a/discovery/org.eclipse.tm.discovery.wizard/about.html b/discovery/org.eclipse.tm.discovery.wizard/about.html new file mode 100644 index 00000000000..928af38d499 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/about.html @@ -0,0 +1,29 @@ + +About + + + + +

About This Content

+ +

July 27, 2006

+

License

+ +

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 http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

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 http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/discovery/org.eclipse.tm.discovery.wizard/build.properties b/discovery/org.eclipse.tm.discovery.wizard/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Activator.java b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Activator.java new file mode 100644 index 00000000000..c1d750a883c --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Activator.java @@ -0,0 +1,60 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.wizard; + +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.tm.wizard.pages"; + + // 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/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Messages.java b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Messages.java new file mode 100644 index 00000000000..6ec48c23781 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/Messages.java @@ -0,0 +1,32 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.wizard; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.tm.discovery.wizard.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/ServiceDiscoveryWizardDisplayPage.java b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/ServiceDiscoveryWizardDisplayPage.java new file mode 100644 index 00000000000..64db196d371 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/ServiceDiscoveryWizardDisplayPage.java @@ -0,0 +1,589 @@ +/******************************************************************************** + * Copyright (c) 2006 Symbian Software Ltd. 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: + * Javier Montalvo Orús (Symbian) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.tm.discovery.wizard; + +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.eclipse.swt.widgets.Button; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.ui.ViewerPane; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; +import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableLayout; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.custom.TableEditor; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.tm.discovery.engine.ServiceDiscoveryEngine; +import org.eclipse.tm.discovery.model.Device; +import org.eclipse.tm.discovery.model.Pair; +import org.eclipse.tm.discovery.model.Service; +import org.eclipse.tm.discovery.model.ServiceType; +import org.eclipse.tm.discovery.model.provider.ModelItemProviderAdapterFactory; +import org.eclipse.tm.discovery.protocol.IProtocol; +import org.eclipse.tm.discovery.protocol.ProtocolFactory; +import org.eclipse.tm.discovery.transport.ITransport; +import org.eclipse.tm.discovery.transport.TransportFactory; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; + +/** + * Wizard page providing the list of discovered services + */ + +public class ServiceDiscoveryWizardDisplayPage extends WizardPage { + + //tree widgets + private TreeViewer treeViewer; + private ViewerPane viewerPaneTree; + private ViewerFilter filter; + + //table widgets + private TableViewer tableViewer; + private ViewerPane viewerPaneTable; + private Table table; + private TableEditor editor; + + private ComposedAdapterFactory adapterFactory; + + //button widgets + private Button showAllButton; + + //static service discovery engine + private final ServiceDiscoveryEngine serviceDiscoveryEngine = ServiceDiscoveryEngine.getServiceDiscoveryEngine(); + + //service discovery settings + private String query = null; + private String address = null; + private String transportName = null; + private String protocolName = null; + private int timeOut = 500; + + private Service lastSelectedService = null; + + private Vector supportedServicesType = new Vector(); + + /** + * Constructor for the wizard page performing and displayin the results of the service discovery + * + * @param query + * Query for the service discovery action + * @param address + * Address of the target device + * @param transportName + * Name of the transport implementation to be used + * @param protocolName + * Name of the protocol implementation to be used + * @param timeOut + * Timeout to be used in the transport + */ + + public ServiceDiscoveryWizardDisplayPage(String query, String address, String transportName, String protocolName, int timeOut) { + super("wizardPage2"); //$NON-NLS-1$ + setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageTitle")); //$NON-NLS-1$ + setDescription(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageDescription")); //$NON-NLS-1$ + + //load all service id's from the extension point registry + //this id will be used to filter the supported services in the view + + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.ui","subsystemConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ + IConfigurationElement[] ce = ep.getConfigurationElements(); + for (int i = 0; i < ce.length; i++) { + String id = ce[i].getAttribute("id"); //$NON-NLS-1$ + if(id!=null) + supportedServicesType.add(id); + } + + this.query = query; + this.address = address; + this.transportName = transportName; + this.protocolName = protocolName; + this.timeOut = timeOut; + + } + + /** + * Refresh the contents of the service discovery model + * + * @param query + * Query for the service discovery action + * @param address + * Address of the target device + * @param transportName + * Name of the transport implementation to be used + * @param protocolName + * Name of the protocol implementation to be used + * @param timeOut + * Timeout to be used in the transport + */ + public void update(String query, String address, String transportName, String protocolName, int timeOut) + { + //update settings + this.query = query; + this.address = address; + this.transportName = transportName; + this.protocolName = protocolName; + this.timeOut = timeOut; + + //instantiate protocol and transport from factories (extensions) + //and perform the service discovery action + + IProtocol protocol = null; + ITransport transport = null; + + try { + protocol = ProtocolFactory.getProtocol(protocolName); + } catch (Exception e) { + MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorMessage")+protocolName); //$NON-NLS-1$ //$NON-NLS-2$ + } + + try { + transport = TransportFactory.getTransport(transportName, address, timeOut); + } catch (UnknownHostException e) { + MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundMessage")+address); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorMessage")+transportName); //$NON-NLS-1$ //$NON-NLS-2$ + } + + if(protocol != null && transport != null) + { + try{ + serviceDiscoveryEngine.doServiceDiscovery(query, protocol,transport); + }catch(Exception e){} + } + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + + List factories = new ArrayList(); + factories.add(new ResourceItemProviderAdapterFactory()); + factories.add(new ModelItemProviderAdapterFactory()); + factories.add(new ReflectiveItemProviderAdapterFactory()); + + adapterFactory = new ComposedAdapterFactory(factories); + + Composite comp = new Composite(parent, SWT.NULL); + + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + comp.setLayout(gridLayout); + + //TOOLBAR + + createToolBar(comp); + + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + data.verticalAlignment = GridData.FILL; + data.grabExcessVerticalSpace = true; + + SashForm sashForm = new SashForm(comp,SWT.NULL ); + sashForm.setOrientation(SWT.HORIZONTAL); + + sashForm.setLayoutData(data); + + // TREE + + Composite sashComposite = new Composite(sashForm,SWT.BORDER); + sashComposite.setLayout(new FillLayout()); + + createTree(sashComposite); + + // TABLE + + Composite innerComposite = new Composite(sashForm,SWT.BORDER); + innerComposite.setLayout(new FillLayout()); + + createTable(innerComposite); + + + // SHOW ALL SERVICES BUTTON + + createShowAllButton(comp); + + + update(query, address, transportName, protocolName, timeOut); + + setPageComplete(false); + + setControl(comp); + + } + + /* + * ToolBar of the wizard page + */ + private void createToolBar(Composite comp) + { + ToolBar toolBar = new ToolBar(comp,SWT.HORIZONTAL | SWT.FLAT | SWT.LEFT | SWT.WRAP ); + + ToolItem refreshButton = new ToolItem(toolBar, SWT.NULL); + refreshButton.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event event) { + update(query, address, transportName, protocolName, timeOut); + } + }); + + refreshButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.RefreshButtonToolTipText")); //$NON-NLS-1$ + refreshButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO).createImage()); + + ToolItem cleanButton = new ToolItem(toolBar, SWT.NULL); + cleanButton.addListener(SWT.Selection, new Listener(){ + public void handleEvent(Event event) { + serviceDiscoveryEngine.getResource().getContents().clear(); + tableViewer.setInput(null); + } + }); + + cleanButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ClearButtonToolTipText")); //$NON-NLS-1$ + cleanButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE).createImage()); + + } + + /* + * Tree of the wizard page + */ + private void createTree(Composite comp) + { + + viewerPaneTree = new ViewerPane( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) { + public Viewer createViewer(Composite composite) { + Tree tree = new Tree(composite, SWT.CHECK); + ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(tree); + + return treeViewer; + } + + public void requestActivation() { + super.requestActivation(); + } + }; + + viewerPaneTree.createControl(comp); + + treeViewer = (TreeViewer) viewerPaneTree.getViewer(); + + treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + + treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + + viewerPaneTree.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.ServicesTreeTitle"), null); //$NON-NLS-1$ + + treeViewer.setInput(serviceDiscoveryEngine.getResource()); + + new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); + + ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + if(!event.getSelection().isEmpty()) + { + EObject obj = (EObject)((IStructuredSelection) event.getSelection()).getFirstElement(); + + if(obj instanceof Service) + { + tableViewer.setInput(obj); + lastSelectedService = (Service)obj; + } + } + } + }); + + + ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + + ContainerCheckedTreeViewer treeViewer = (ContainerCheckedTreeViewer) event.getSource(); + + if(treeViewer.getCheckedElements().length > 0) + setPageComplete(true); + else + setPageComplete(false); + + } + }); + + filter = new ViewerFilter(){ + + public boolean select(Viewer viewer, Object parentElement, Object element) { + boolean supported = true; + if(element instanceof ServiceType) { + String serviceTypeName = ((ServiceType)element).getName(); + if(!supportedServicesType.contains(serviceTypeName)) + { + supported = false; + } + } + return supported; + + }}; + + ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter); + + } + + /* + * Table of the wizard page + */ + private void createTable(Composite comp) + { + viewerPaneTable = + new ViewerPane(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) { + public Viewer createViewer(Composite composite) { + return new TableViewer(composite); + } + }; + + viewerPaneTable.createControl(comp); + tableViewer = (TableViewer)viewerPaneTable.getViewer(); + + viewerPaneTable.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.PropertiesTableTitle"), null); //$NON-NLS-1$ + + + table = tableViewer.getTable(); + + TableLayout layout = new TableLayout(); + table.setLayout(layout); + + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableColumn objectColumn = new TableColumn(table, SWT.NONE); + layout.addColumnData(new ColumnWeightData(3, 100, true)); + objectColumn.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.KeyColumnLabel")); //$NON-NLS-1$ + objectColumn.setResizable(true); + + TableColumn selfColumn = new TableColumn(table, SWT.NONE); + layout.addColumnData(new ColumnWeightData(2, 100, true)); + selfColumn.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ValueColumnLabel")); //$NON-NLS-1$ + selfColumn.setResizable(true); + + tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + + tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + + editor = new TableEditor(table); + editor.horizontalAlignment = SWT.LEFT; + editor.grabHorizontal = true; + table.addListener (SWT.MouseDown, new Listener () { + public void handleEvent (Event event) { + Rectangle clientArea = table.getClientArea (); + Point pt = new Point (event.x, event.y); + int index = table.getTopIndex (); + while (index < table.getItemCount ()) { + boolean visible = false; + final TableItem item = table.getItem (index); + for (int i=table.getColumnCount()-1; iService objects selected in the tree view from the specified host + * + * @param address + * Address of the host which services are queried + * @return + * Vector containing the Service selected + * + * @see Service + */ + public Vector getSelectedServices(String address) + { + Vector services = new Vector(); + + Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements(); + for(int i=0; i + * It provides a wizard page with text boxes and combo boxes to gather the following data: + *
    + *
  • Protocol + *
  • Transport + *
  • Query + *
  • Timeout + *
  • + * + * @see WizardPage + */ + +public class ServiceDiscoveryWizardMainPage extends WizardPage { + + // settings + private int timeOut = 500; //ms + + // widgets + private Combo queryCombo, transportCombo, protocolCombo; + private Text addressText, timeOutText; + + /** + * Wizard main page constructor + */ + public ServiceDiscoveryWizardMainPage() { + super("wizardPage1"); //$NON-NLS-1$ + setTitle(Messages.getString("ServiceDiscoveryWizardMainPage.WizardPageTitle")); //$NON-NLS-1$ + setDescription(Messages.getString("ServiceDiscoveryWizardMainPage.WizardPageDescription")); //$NON-NLS-1$ + setErrorMessage(Messages.getString("ServiceDiscoveryWizardMainPage.ProvideAddressError")); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + + FillLayout layout = new FillLayout(); + layout.type = SWT.VERTICAL; + + Composite comp = new Composite(parent,SWT.NULL); + comp.setLayout(layout); + + new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.AddressLabel")); //$NON-NLS-1$ + + addressText = new Text(comp, SWT.BORDER | SWT.SINGLE | SWT.WRAP); + addressText.addModifyListener(new ModifyListener(){ + + public void modifyText(ModifyEvent e) { + if(((Text)e.getSource()).getText().equals("")) //$NON-NLS-1$ + { + setErrorMessage(Messages.getString("ServiceDiscoveryWizardMainPage.ProvideAddressError")); //$NON-NLS-1$ + setPageComplete(false); + } + else + { + setErrorMessage(null); + setPageComplete(true); + } + + } + }); + + new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.TransportLabel")); //$NON-NLS-1$ + + transportCombo = new Combo(comp, SWT.READ_ONLY); + transportCombo.setItems(TransportFactory.getTransportList()); + transportCombo.select(0); + + new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.ProtocolLabel")); //$NON-NLS-1$ + + protocolCombo = new Combo(comp, SWT.READ_ONLY); + protocolCombo.setItems(ProtocolFactory.getProtocolList()); + protocolCombo.select(0); + + protocolCombo.addSelectionListener(new SelectionListener(){ + + public void widgetDefaultSelected(SelectionEvent e) { + } + + public void widgetSelected(SelectionEvent event) { + String selectedProtocol = ((Combo)event.getSource()).getText(); + + String[] queries = new String[]{}; + try { + queries = ProtocolFactory.getQueryList(selectedProtocol); + } catch (CoreException e) {} + queryCombo.removeAll(); + queryCombo.setItems(queries); + queryCombo.select(0); + } + }); + + + new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.DiscoveryQueryLabel")); //$NON-NLS-1$ + + queryCombo = new Combo(comp, SWT.NONE); + String[] queries = new String[]{}; + try { + queries = ProtocolFactory.getQueryList(protocolCombo.getText()); + } catch (CoreException e) {} + for (int i = 0; i < queries.length; i++) { + queryCombo.add(queries[i]); + } + queryCombo.select(0); + + + new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.TimeOutLabel")); //$NON-NLS-1$ + + timeOutText = new Text(comp, SWT.BORDER | SWT.SINGLE | SWT.WRAP); + timeOutText.setText(Messages.getString("ServiceDiscoveryWizardMainPage.TimeOutValue")); //$NON-NLS-1$ + timeOutText.redraw(); + + setPageComplete(false); + + setControl(comp); + + } + + /** + * Gets the service discovery command + * @return command introduced in the settings window + */ + public String getQuery() { + return queryCombo.getText(); + } + + /** + * Gets the service discovery address + * @return address introduced in the settings window + */ + public String getAddress() { + return addressText.getText(); + } + + /** + * Gets the service discovery transport + * @return address introduced in the settings window + */ + public String getTransport() { + return transportCombo.getText(); + } + + /** + * Gets the service discovery protocol + * @return address introduced in the settings window + */ + public String getProtocol() { + return protocolCombo.getText(); + } + + /** + * Gets the service discovery timeout + * @return timeout introduced in the settings window + */ + public int getTimeOut() { + + try{ + timeOut = Integer.parseInt(timeOutText.getText().trim()); + }catch(NumberFormatException e){} + + return timeOut; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage() + */ + public boolean canFlipToNextPage() { + return isPageComplete(); + } + + +} diff --git a/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/messages.properties b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/messages.properties new file mode 100644 index 00000000000..dbd13c37ea4 --- /dev/null +++ b/discovery/org.eclipse.tm.discovery.wizard/src/org/eclipse/tm/discovery/wizard/messages.properties @@ -0,0 +1,34 @@ +################################################################################## +# Copyright (c) 2006 Symbian Software Ltd. 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: +# Javier Montalvo Orús (Symbian) - initial API and implementation +################################################################################## + +ServiceDiscoveryWizardDisplayPage.WizardPageTitle=Service Discovery +ServiceDiscoveryWizardDisplayPage.WizardPageDescription=Select discovered services. +ServiceDiscoveryWizardMainPage.AddressLabel=Address: +ServiceDiscoveryWizardMainPage.TransportLabel=Transport: +ServiceDiscoveryWizardMainPage.ProtocolLabel=Protocol: +ServiceDiscoveryWizardMainPage.TimeOutLabel=Timeout (ms): +ServiceDiscoveryWizardMainPage.TimeOutValue=500 +ServiceDiscoveryWizardDisplayPage.ProtocolErrorTitle=Error +ServiceDiscoveryWizardMainPage.WizardPageDescription=Discover available services in the target device. +ServiceDiscoveryWizardDisplayPage.ProtocolErrorMessage=Error loading protocol +ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundTitle=Error +ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundMessage=Error resolving address +ServiceDiscoveryWizardDisplayPage.TransportErrorTitle=Error +ServiceDiscoveryWizardDisplayPage.TransportErrorMessage=Error loading transport +ServiceDiscoveryWizardDisplayPage.RefreshButtonToolTipText=Refresh +ServiceDiscoveryWizardDisplayPage.ClearButtonToolTipText=Clear +ServiceDiscoveryWizardDisplayPage.ServicesTreeTitle=\ \ \ \ \ \ \ \ Services +ServiceDiscoveryWizardDisplayPage.PropertiesTableTitle=\ \ \ \ \ \ \ \ Properties +ServiceDiscoveryWizardDisplayPage.KeyColumnLabel=Key +ServiceDiscoveryWizardMainPage.WizardPageTitle=Service Discovery +ServiceDiscoveryWizardDisplayPage.ValueColumnLabel=Value +ServiceDiscoveryWizardMainPage.ProvideAddressError=Provide a valid address +ServiceDiscoveryWizardMainPage.DiscoveryQueryLabel=Discovery Query: +ServiceDiscoveryWizardDisplayPage.ShowAllServicesButtonText=Show all services