1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

Initial population

This commit is contained in:
Javier Montalvo Orus 2006-09-07 12:14:58 +00:00
parent 782cb9ad70
commit c9f749182e
40 changed files with 2288 additions and 0 deletions

View file

@ -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"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.rse.discovery</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>

View file

@ -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

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 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 http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<!--
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
-->
<plugin>
<extension
id="a"
name="as"
point="org.eclipse.rse.ui.newConnectionWizardDelegate">
<newConnectionWizardDelegate
class="org.eclipse.rse.discovery.ServiceDiscoveryWizardDelegate"
systemType="org.eclipse.rse.systemtype.discovery"/>
</extension>
</plugin>

View file

@ -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;
}
}

View file

@ -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() {
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}
}

View file

@ -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

View file

@ -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"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.transport.udp</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>

View file

@ -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

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 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 http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.tm.discovery.engine.discoveryTransport">
<transport
class="org.eclipse.tm.discovery.transport.udp.UDPTransport"
name="UDP"/>
</extension>
</plugin>

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.view</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>

View file

@ -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

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>June 16, 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 http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,9 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
about.html
src.includes = about.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<!--
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
-->
<plugin>
<extension
point="org.eclipse.ui.views">
<category
name="Service Discovery"
id="org.eclipse.rse.discovery.category">
</category>
<view
category="org.eclipse.rse.discovery.category"
class="org.eclipse.tm.discovery.view.ServiceDiscoveryView"
icon="icons/system_view.gif"
id="org.eclipse.rse.discovery.view.MultipleView"
name="Service Discovery Properties"/>
</extension>
</plugin>

View file

@ -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);
}
}

View file

@ -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() {
}
}

View file

@ -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() {
}
}

View file

@ -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

View file

@ -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"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.wizard</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>

View file

@ -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

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 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 http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -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;
}
}

View file

@ -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 + '!';
}
}
}

View file

@ -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; i<table.getColumnCount(); i++) {
Rectangle rect = item.getBounds (i);
if (rect.contains (pt)) {
final int column = i;
final Text text = new Text (table, SWT.NONE);
Listener textListener = new Listener () {
public void handleEvent (final Event e) {
switch (e.type) {
case SWT.FocusOut:
item.setText (column, text.getText ());
text.dispose ();
//update model when focus out
updatePairs(item.getText(0),item.getText(1));
break;
case SWT.Traverse:
switch (e.detail) {
case SWT.TRAVERSE_RETURN:
item.setText (column, text.getText ());
//update model when pressing return
updatePairs(item.getText(0),item.getText(1));
case SWT.TRAVERSE_ESCAPE:
text.dispose ();
e.doit = false;
}
break;
}
}
};
text.addListener (SWT.FocusOut, textListener);
text.addListener (SWT.Traverse, textListener);
editor.setEditor (text, item, i);
text.setText (item.getText (i));
text.selectAll ();
text.setFocus ();
return;
}
if (!visible && rect.intersects (clientArea)) {
visible = true;
}
}
if (!visible) return;
index++;
}
}
});
}
/*
* Check box to show all services
*/
private void createShowAllButton(Composite comp)
{
showAllButton = new Button(comp,SWT.CHECK);
showAllButton.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ShowAllServicesButtonText")); //$NON-NLS-1$
showAllButton.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
Object src = e.getSource();
if(((Button)src).getSelection())
{
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).removeFilter(filter);
}
else
{
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter);
}
}
});
}
/*
* Update the service pairs information in the model
*/
private void updatePairs(String key, String value)
{
Iterator pairsIterator = lastSelectedService.getPair().iterator();
while(pairsIterator.hasNext())
{
Pair pair = (Pair)pairsIterator.next();
if(pair.getKey().equals(key))
{
pair.setValue(value);
}
}
}
/**
* Get the <code>Service<code> objects selected in the tree view from the specified host
*
* @param address
* Address of the host which services are queried
* @return
* Vector containing the <code>Service<code> selected
*
* @see Service
*/
public Vector getSelectedServices(String address)
{
Vector services = new Vector();
Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements();
for(int i=0; i<checkedElements.length; i++)
{
if(checkedElements[i] instanceof Service)
{
Service service = (Service)checkedElements[i];
if(((Device)service.eContainer().eContainer()).getAddress().equalsIgnoreCase(address))
{
services.add(service);
}
}
}
return services;
}
/**
* Get the addresses of the discovered hosts that have at least one service selected
*
* @return
* String[] containing the addresses of the selected hosts
*/
public String[] getAddresses()
{
Vector addressVector = new Vector();
Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements();
for(int i=0; i<checkedElements.length; i++)
{
if(checkedElements[i] instanceof Device)
{
addressVector.add(((Device)checkedElements[i]).getAddress());
}
}
String[] addresses = new String[addressVector.size()];
addressVector.copyInto(addresses);
return addresses;
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
*/
public boolean canFlipToNextPage() {
return isPageComplete();
}
}

View file

@ -0,0 +1,200 @@
/********************************************************************************
* 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.core.runtime.CoreException;
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.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tm.discovery.protocol.ProtocolFactory;
import org.eclipse.tm.discovery.transport.TransportFactory;
/**
* Main wizard page for the service discovery process.</br>
* It provides a wizard page with text boxes and combo boxes to gather the following data:
* <ul>
* <li>Protocol
* <li>Transport
* <li>Query
* <li>Timeout
* </li>
*
* @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();
}
}

View file

@ -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