1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 03:55:22 +02:00

[cleanup] Avoid Javadoc param tag on separate line

This commit is contained in:
Martin Oberhuber 2008-03-16 20:18:30 +00:00
parent 3ea93ca975
commit dd3b95b989
3 changed files with 265 additions and 275 deletions

View file

@ -66,7 +66,7 @@
<documentation> <documentation>
Allows specifying semicolon separated multicast addresses to be used with specific transports in the format &lt;transport&gt;:&lt;address&gt; Allows specifying semicolon separated multicast addresses to be used with specific transports in the format &lt;transport&gt;:&lt;address&gt;
An example would be: An example would be:
&lt;code&gt;&quot;transportName1:address1;transportName2:address2;UDP:224.0.0.251&quot;&lt;code/&gt; &lt;code&gt;&quot;transportName1:address1;transportName2:address2;UDP:224.0.0.251&quot;&lt;/code&gt;
</documentation> </documentation>
</annotation> </annotation>
</attribute> </attribute>

View file

@ -1,7 +1,7 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2006, 2007 Symbian Software Ltd. All rights reserved. * Copyright (c) 2006, 2007 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
@ -27,21 +27,21 @@ import org.eclipse.tm.discovery.transport.ITransport;
*/ */
public interface IProtocol { public interface IProtocol {
/** /**
* Instantiates a Job to populate a model given an initial query, a resource containing the model to be populated and an ITranport implementation. * Instantiates a Job to populate a model given an initial query, a resource
* containing the model to be populated and an ITranport implementation.
* *
* @param query * @param query Initial query to be sent to the target. This initial query
* Initial query to be sent to the target. This initial query can be obtained from the getQueries() method. * can be obtained from the getQueries() method.
* *
* @param resource * @param resource Resource containing the model to be populated with the
* Resource containing the model to be populated with the results of the service discovery action. * results of the service discovery action.
* *
* @param transport * @param transport ITransport implementation of the transport to be used
* ITransport implementation of the transport to be used for the discovery action. * for the discovery action.
* *
* @return * @return Job containing the service discovery action.
* Job containing the service discovery action.
* *
* @see Job * @see Job
* @see Resource * @see Resource
@ -49,8 +49,8 @@ public interface IProtocol {
* *
*/ */
public abstract Job getDiscoveryJob(String query, Resource resource, ITransport transport); public abstract Job getDiscoveryJob(String query, Resource resource, ITransport transport);
/** /**
* Gets the list of recommended queries to start the service discovery process. This queries can be used in getDiscoveryJob(). * Gets the list of recommended queries to start the service discovery process. This queries can be used in getDiscoveryJob().
* *
@ -58,5 +58,5 @@ public interface IProtocol {
* An array containing the recommended queries. * An array containing the recommended queries.
*/ */
public abstract String[] getQueries(); public abstract String[] getQueries();
} }

View file

@ -1,7 +1,7 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2006, 2007 Symbian Software Ltd. and others. All rights reserved. * Copyright (c) 2006, 2007 Symbian Software Ltd. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
@ -88,75 +88,71 @@ import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
*/ */
public class ServiceDiscoveryWizardDisplayPage extends WizardPage { public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
//tree widgets //tree widgets
private TreeViewer treeViewer; private TreeViewer treeViewer;
private ViewerPane viewerPaneTree; private ViewerPane viewerPaneTree;
private ViewerFilter filter; private ViewerFilter filter;
//table widgets //table widgets
private TableViewer tableViewer; private TableViewer tableViewer;
private ViewerPane viewerPaneTable; private ViewerPane viewerPaneTable;
private Table table; private Table table;
private TableEditor editor; private TableEditor editor;
private ComposedAdapterFactory adapterFactory; private ComposedAdapterFactory adapterFactory;
//button widgets //button widgets
private Button showAllButton; private Button showAllButton;
//static service discovery engine //static service discovery engine
private final ServiceDiscoveryEngine serviceDiscoveryEngine = ServiceDiscoveryEngine.getInstance(); private final ServiceDiscoveryEngine serviceDiscoveryEngine = ServiceDiscoveryEngine.getInstance();
//service discovery settings //service discovery settings
private String query = null; private String query = null;
private String address = null; private String address = null;
private String transportName = null; private String transportName = null;
private String protocolName = null; private String protocolName = null;
private int timeOut = 500; private int timeOut = 500;
//format of serviceType attribute list of names and transports //format of serviceType attribute list of names and transports
//of extension point org.eclipse.core.subsystemConfigurations //of extension point org.eclipse.core.subsystemConfigurations
private final Pattern serviceTypeFormat = Pattern.compile("_(.+)\\._(.+)"); //$NON-NLS-1$ private final Pattern serviceTypeFormat = Pattern.compile("_(.+)\\._(.+)"); //$NON-NLS-1$
private Service lastSelectedService = null; private Service lastSelectedService = null;
private Hashtable supportedServicesType = new Hashtable(); private Hashtable supportedServicesType = new Hashtable();
/** /**
* Constructor for the wizard page performing and displayin the results of the service discovery * Constructor for the wizard page performing and displayin the results of
* the service discovery
* *
* @param query * @param query Query for the service discovery action
* Query for the service discovery action * @param address Address of the target device
* @param address * @param transportName Name of the transport implementation to be used
* Address of the target device * @param protocolName Name of the protocol implementation to be used
* @param transportName * @param timeOut Timeout to be used in the transport
* 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) { public ServiceDiscoveryWizardDisplayPage(String query, String address, String transportName, String protocolName, int timeOut) {
super("wizardPage2"); //$NON-NLS-1$ super("wizardPage2"); //$NON-NLS-1$
setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageTitle")); //$NON-NLS-1$ setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageTitle")); //$NON-NLS-1$
setDescription(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageDescription")); //$NON-NLS-1$ setDescription(Messages.getString("ServiceDiscoveryWizardDisplayPage.WizardPageDescription")); //$NON-NLS-1$
//load all service id's from the extension point registry //load all service id's from the extension point registry
//this id will be used to filter the supported sytem types //this id will be used to filter the supported sytem types
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.core","subsystemConfigurations"); //$NON-NLS-1$ //$NON-NLS-2$ IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.rse.core","subsystemConfigurations"); //$NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement[] ce = ep.getConfigurationElements(); IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) { for (int i = 0; i < ce.length; i++) {
String type = ce[i].getAttribute("serviceType"); //$NON-NLS-1$ String type = ce[i].getAttribute("serviceType"); //$NON-NLS-1$
if(type!=null) if(type!=null)
{ {
String[] variants = type.split(";"); //$NON-NLS-1$ String[] variants = type.split(";"); //$NON-NLS-1$
for (int j = 0; j < variants.length; j++) { for (int j = 0; j < variants.length; j++) {
Matcher match = serviceTypeFormat.matcher(variants[j]); Matcher match = serviceTypeFormat.matcher(variants[j]);
if(match.matches()) if(match.matches())
{ {
String name = match.group(1); String name = match.group(1);
@ -175,30 +171,25 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
} }
} }
} }
} }
} }
this.query = query; this.query = query;
this.address = address; this.address = address;
this.transportName = transportName; this.transportName = transportName;
this.protocolName = protocolName; this.protocolName = protocolName;
this.timeOut = timeOut; this.timeOut = timeOut;
} }
/** /**
* Refresh the contents of the service discovery model * Refresh the contents of the service discovery model
* *
* @param query * @param query Query for the service discovery action
* Query for the service discovery action * @param address Address of the target device
* @param address * @param transportName Name of the transport implementation to be used
* Address of the target device * @param protocolName Name of the protocol implementation to be used
* @param transportName * @param timeOut Timeout to be used in the transport
* 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) public void update(String query, String address, String transportName, String protocolName, int timeOut)
{ {
@ -208,19 +199,19 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
this.transportName = transportName; this.transportName = transportName;
this.protocolName = protocolName; this.protocolName = protocolName;
this.timeOut = timeOut; this.timeOut = timeOut;
//instantiate protocol and transport from factories (extensions) //instantiate protocol and transport from factories (extensions)
//and perform the service discovery action //and perform the service discovery action
IProtocol protocol = null; IProtocol protocol = null;
ITransport transport = null; ITransport transport = null;
try { try {
protocol = ProtocolFactory.getProtocol(protocolName); protocol = ProtocolFactory.getProtocol(protocolName);
} catch (Exception e) { } catch (Exception e) {
MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorMessage")+protocolName); //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.ProtocolErrorMessage")+protocolName); //$NON-NLS-1$ //$NON-NLS-2$
} }
try { try {
transport = TransportFactory.getTransport(transportName, address, timeOut); transport = TransportFactory.getTransport(transportName, address, timeOut);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
@ -228,7 +219,7 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
} catch (Exception e) { } catch (Exception e) {
MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorMessage")+transportName); //$NON-NLS-1$ //$NON-NLS-2$ MessageDialog.openError(new Shell(), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorTitle"), Messages.getString("ServiceDiscoveryWizardDisplayPage.TransportErrorMessage")+transportName); //$NON-NLS-1$ //$NON-NLS-2$
} }
if(protocol != null && transport != null) if(protocol != null && transport != null)
{ {
try{ try{
@ -236,86 +227,86 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
}catch(Exception e){} }catch(Exception e){}
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/ */
public void createControl(Composite parent) { public void createControl(Composite parent) {
List factories = new ArrayList(); List factories = new ArrayList();
factories.add(new ResourceItemProviderAdapterFactory()); factories.add(new ResourceItemProviderAdapterFactory());
factories.add(new ModelItemProviderAdapterFactory()); factories.add(new ModelItemProviderAdapterFactory());
factories.add(new ReflectiveItemProviderAdapterFactory()); factories.add(new ReflectiveItemProviderAdapterFactory());
adapterFactory = new ComposedAdapterFactory(factories); adapterFactory = new ComposedAdapterFactory(factories);
Composite comp = new Composite(parent, SWT.NULL); Composite comp = new Composite(parent, SWT.NULL);
GridLayout gridLayout = new GridLayout(); GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1; gridLayout.numColumns = 1;
comp.setLayout(gridLayout); comp.setLayout(gridLayout);
//TOOLBAR //TOOLBAR
createToolBar(comp); createToolBar(comp);
GridData data = new GridData(); GridData data = new GridData();
data.horizontalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true; data.grabExcessHorizontalSpace = true;
data.verticalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL;
data.grabExcessVerticalSpace = true; data.grabExcessVerticalSpace = true;
SashForm sashForm = new SashForm(comp,SWT.NULL ); SashForm sashForm = new SashForm(comp,SWT.NULL );
sashForm.setOrientation(SWT.HORIZONTAL); sashForm.setOrientation(SWT.HORIZONTAL);
sashForm.setLayoutData(data); sashForm.setLayoutData(data);
// TREE // TREE
Composite sashComposite = new Composite(sashForm,SWT.BORDER); Composite sashComposite = new Composite(sashForm,SWT.BORDER);
sashComposite.setLayout(new FillLayout()); sashComposite.setLayout(new FillLayout());
createTree(sashComposite); createTree(sashComposite);
// TABLE // TABLE
Composite innerComposite = new Composite(sashForm,SWT.BORDER); Composite innerComposite = new Composite(sashForm,SWT.BORDER);
innerComposite.setLayout(new FillLayout()); innerComposite.setLayout(new FillLayout());
createTable(innerComposite); createTable(innerComposite);
// SHOW ALL SERVICES BUTTON // SHOW ALL SERVICES BUTTON
createShowAllButton(comp); createShowAllButton(comp);
update(query, address, transportName, protocolName, timeOut); update(query, address, transportName, protocolName, timeOut);
setPageComplete(false); setPageComplete(false);
setControl(comp); setControl(comp);
} }
/* /*
* ToolBar of the wizard page * ToolBar of the wizard page
*/ */
private void createToolBar(Composite comp) private void createToolBar(Composite comp)
{ {
ToolBar toolBar = new ToolBar(comp,SWT.HORIZONTAL | SWT.FLAT | SWT.LEFT | SWT.WRAP ); ToolBar toolBar = new ToolBar(comp,SWT.HORIZONTAL | SWT.FLAT | SWT.LEFT | SWT.WRAP );
ToolItem refreshButton = new ToolItem(toolBar, SWT.NULL); ToolItem refreshButton = new ToolItem(toolBar, SWT.NULL);
refreshButton.addListener(SWT.Selection, new Listener(){ refreshButton.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event event) { public void handleEvent(Event event) {
update(query, address, transportName, protocolName, timeOut); update(query, address, transportName, protocolName, timeOut);
} }
}); });
refreshButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.RefreshButtonToolTipText")); //$NON-NLS-1$ refreshButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.RefreshButtonToolTipText")); //$NON-NLS-1$
refreshButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO).createImage()); refreshButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_REDO).createImage());
ToolItem cleanButton = new ToolItem(toolBar, SWT.NULL); ToolItem cleanButton = new ToolItem(toolBar, SWT.NULL);
cleanButton.addListener(SWT.Selection, new Listener(){ cleanButton.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event event) { public void handleEvent(Event event) {
@ -323,52 +314,52 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
tableViewer.setInput(null); tableViewer.setInput(null);
} }
}); });
cleanButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ClearButtonToolTipText")); //$NON-NLS-1$ cleanButton.setToolTipText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ClearButtonToolTipText")); //$NON-NLS-1$
cleanButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE).createImage()); cleanButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE).createImage());
} }
/* /*
* Tree of the wizard page * Tree of the wizard page
*/ */
private void createTree(Composite comp) private void createTree(Composite comp)
{ {
viewerPaneTree = new ViewerPane( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), viewerPaneTree = new ViewerPane( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) {
public Viewer createViewer(Composite composite) { public Viewer createViewer(Composite composite) {
Tree tree = new Tree(composite, SWT.CHECK); Tree tree = new Tree(composite, SWT.CHECK);
ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(tree); ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(tree);
return treeViewer; return treeViewer;
} }
public void requestActivation() { public void requestActivation() {
super.requestActivation(); super.requestActivation();
} }
}; };
viewerPaneTree.createControl(comp); viewerPaneTree.createControl(comp);
treeViewer = (TreeViewer) viewerPaneTree.getViewer(); treeViewer = (TreeViewer) viewerPaneTree.getViewer();
treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
viewerPaneTree.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.ServicesTreeTitle"), null); //$NON-NLS-1$ viewerPaneTree.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.ServicesTreeTitle"), null); //$NON-NLS-1$
treeViewer.setInput(serviceDiscoveryEngine.getResource()); treeViewer.setInput(serviceDiscoveryEngine.getResource());
new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addSelectionChangedListener(new ISelectionChangedListener() { ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) { public void selectionChanged(SelectionChangedEvent event) {
if(!event.getSelection().isEmpty()) if(!event.getSelection().isEmpty())
{ {
EObject obj = (EObject)((IStructuredSelection) event.getSelection()).getFirstElement(); EObject obj = (EObject)((IStructuredSelection) event.getSelection()).getFirstElement();
if(obj instanceof Service) if(obj instanceof Service)
{ {
tableViewer.setInput(obj); tableViewer.setInput(obj);
@ -377,28 +368,28 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
} }
} }
}); });
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addCheckStateListener(new ICheckStateListener() { ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) { public void checkStateChanged(CheckStateChangedEvent event) {
ContainerCheckedTreeViewer treeViewer = (ContainerCheckedTreeViewer) event.getSource(); ContainerCheckedTreeViewer treeViewer = (ContainerCheckedTreeViewer) event.getSource();
if(treeViewer.getCheckedElements().length > 0) if(treeViewer.getCheckedElements().length > 0)
setPageComplete(true); setPageComplete(true);
else else
setPageComplete(false); setPageComplete(false);
} }
}); });
filter = new ViewerFilter(){ filter = new ViewerFilter(){
public boolean select(Viewer viewer, Object parentElement, Object element) { public boolean select(Viewer viewer, Object parentElement, Object element) {
boolean supported = true; boolean supported = true;
if(element instanceof ServiceType) { if(element instanceof ServiceType) {
//check if the service type is in the supported list //check if the service type is in the supported list
String serviceTypeName = ((ServiceType)element).getName(); String serviceTypeName = ((ServiceType)element).getName();
if(!supportedServicesType.containsKey(serviceTypeName)) if(!supportedServicesType.containsKey(serviceTypeName))
@ -406,153 +397,153 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
supported = false; supported = false;
} }
} }
if(element instanceof Service) { if(element instanceof Service) {
//if the discovered transport value is not contained in the list of supported transports filter this service //if the discovered transport value is not contained in the list of supported transports filter this service
supported = false; supported = false;
String serviceTypeName = ((ServiceType)((Service)element).eContainer()).getName(); String serviceTypeName = ((ServiceType)((Service)element).eContainer()).getName();
//check if the transport service is supported //check if the transport service is supported
Vector transports = (Vector)supportedServicesType.get(serviceTypeName); Vector transports = (Vector)supportedServicesType.get(serviceTypeName);
Iterator it = ((Service)element).getPair().iterator(); Iterator it = ((Service)element).getPair().iterator();
while(it.hasNext()) while(it.hasNext())
{ {
Pair pair = (Pair)it.next(); Pair pair = (Pair)it.next();
if(pair.getKey().equalsIgnoreCase("transport")) //$NON-NLS-1$ if(pair.getKey().equalsIgnoreCase("transport")) //$NON-NLS-1$
{ {
String transport = pair.getValue(); String transport = pair.getValue();
for (int i = 0; i < transports.size(); i++) { for (int i = 0; i < transports.size(); i++) {
if(((String)transports.elementAt(i)).equalsIgnoreCase(transport)) if(((String)transports.elementAt(i)).equalsIgnoreCase(transport))
{ {
//found a supported transport //found a supported transport
supported = true; supported = true;
}
} }
}
} }
} }
} }
return supported; return supported;
}}; }};
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter); ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter);
} }
/* /*
* Table of the wizard page * Table of the wizard page
*/ */
private void createTable(Composite comp) private void createTable(Composite comp)
{ {
viewerPaneTable = viewerPaneTable =
new ViewerPane(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), new ViewerPane(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()) {
public Viewer createViewer(Composite composite) { public Viewer createViewer(Composite composite) {
return new TableViewer(composite); return new TableViewer(composite);
} }
}; };
viewerPaneTable.createControl(comp);
tableViewer = (TableViewer)viewerPaneTable.getViewer();
viewerPaneTable.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.PropertiesTableTitle"), null); //$NON-NLS-1$ viewerPaneTable.createControl(comp);
tableViewer = (TableViewer)viewerPaneTable.getViewer();
table = tableViewer.getTable();
TableLayout layout = new TableLayout();
table.setLayout(layout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn objectColumn = new TableColumn(table, SWT.NONE); viewerPaneTable.setTitle(Messages.getString("ServiceDiscoveryWizardDisplayPage.PropertiesTableTitle"), null); //$NON-NLS-1$
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)); table = tableViewer.getTable();
selfColumn.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ValueColumnLabel")); //$NON-NLS-1$
selfColumn.setResizable(true); TableLayout layout = new TableLayout();
table.setLayout(layout);
tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
table.setHeaderVisible(true);
tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); table.setLinesVisible(true);
editor = new TableEditor(table); TableColumn objectColumn = new TableColumn(table, SWT.NONE);
editor.horizontalAlignment = SWT.LEFT; layout.addColumnData(new ColumnWeightData(3, 100, true));
editor.grabHorizontal = true; objectColumn.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.KeyColumnLabel")); //$NON-NLS-1$
table.addListener (SWT.MouseDown, new Listener () { objectColumn.setResizable(true);
public void handleEvent (Event event) {
Rectangle clientArea = table.getClientArea (); TableColumn selfColumn = new TableColumn(table, SWT.NONE);
Point pt = new Point (event.x, event.y); layout.addColumnData(new ColumnWeightData(2, 100, true));
int index = table.getTopIndex (); selfColumn.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ValueColumnLabel")); //$NON-NLS-1$
while (index < table.getItemCount ()) { selfColumn.setResizable(true);
boolean visible = false;
final TableItem item = table.getItem (index); tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
for (int i=table.getColumnCount()-1; i<table.getColumnCount(); i++) {
Rectangle rect = item.getBounds (i); tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
if (rect.contains (pt)) {
final int column = i; editor = new TableEditor(table);
final Text text = new Text (table, SWT.NONE); editor.horizontalAlignment = SWT.LEFT;
Listener textListener = new Listener () { editor.grabHorizontal = true;
public void handleEvent (final Event e) { table.addListener (SWT.MouseDown, new Listener () {
switch (e.type) { public void handleEvent (Event event) {
case SWT.FocusOut: Rectangle clientArea = table.getClientArea ();
item.setText (column, text.getText ()); Point pt = new Point (event.x, event.y);
text.dispose (); int index = table.getTopIndex ();
while (index < table.getItemCount ()) {
//update model when focus out boolean visible = false;
updatePairs(item.getText(0),item.getText(1)); final TableItem item = table.getItem (index);
break; for (int i=table.getColumnCount()-1; i<table.getColumnCount(); i++) {
Rectangle rect = item.getBounds (i);
case SWT.Traverse: if (rect.contains (pt)) {
switch (e.detail) { final int column = i;
case SWT.TRAVERSE_RETURN: final Text text = new Text (table, SWT.NONE);
item.setText (column, text.getText ()); Listener textListener = new Listener () {
public void handleEvent (final Event e) {
//update model when pressing return switch (e.type) {
updatePairs(item.getText(0),item.getText(1)); case SWT.FocusOut:
text.dispose (); item.setText (column, text.getText ());
e.doit = false; text.dispose ();
break;
case SWT.TRAVERSE_ESCAPE: //update model when focus out
text.dispose (); updatePairs(item.getText(0),item.getText(1));
e.doit = false; break;
}
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));
text.dispose ();
e.doit = false;
break;
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; text.addListener (SWT.FocusOut, textListener);
} text.addListener (SWT.Traverse, textListener);
} editor.setEditor (text, item, i);
if (!visible) return; text.setText (item.getText (i));
index++; text.selectAll ();
text.setFocus ();
return;
}
if (!visible && rect.intersects (clientArea)) {
visible = true;
} }
} }
}); if (!visible) return;
index++;
}
}
});
} }
/* /*
* Check box to show all services * Check box to show all services
*/ */
@ -560,28 +551,28 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
{ {
showAllButton = new Button(comp,SWT.CHECK); showAllButton = new Button(comp,SWT.CHECK);
showAllButton.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ShowAllServicesButtonText")); //$NON-NLS-1$ showAllButton.setText(Messages.getString("ServiceDiscoveryWizardDisplayPage.ShowAllServicesButtonText")); //$NON-NLS-1$
showAllButton.addSelectionListener(new SelectionListener(){ showAllButton.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
Object src = e.getSource(); Object src = e.getSource();
if(((Button)src).getSelection()) if(((Button)src).getSelection())
{ {
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).removeFilter(filter); ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).removeFilter(filter);
} }
else else
{ {
((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter); ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).addFilter(filter);
} }
} }
}); });
} }
/* /*
* Update the service pairs information in the model * Update the service pairs information in the model
*/ */
private void updatePairs(String key, String value) private void updatePairs(String key, String value)
{ {
@ -595,21 +586,20 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
} }
} }
} }
/** /**
* Get the <code>Service<code> objects selected in the tree view from the specified host * Get the
* <code>Service<code> objects selected in the tree view from the specified host
* *
* @param address * @param address Address of the host which services are queried
* Address of the host which services are queried * @return Vector containing the <code>Service<code> selected
* @return
* Vector containing the <code>Service<code> selected
* *
* @see Service * @see Service
*/ */
public Vector getSelectedServices(String address) public Vector getSelectedServices(String address)
{ {
Vector services = new Vector(); Vector services = new Vector();
Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements(); Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements();
for(int i=0; i<checkedElements.length; i++) for(int i=0; i<checkedElements.length; i++)
{ {
@ -622,12 +612,12 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
} }
} }
} }
return services; return services;
} }
/** /**
* Get the addresses of the discovered hosts that have at least one service selected * Get the addresses of the discovered hosts that have at least one service selected
* *
* @return * @return
* String[] containing the addresses of the selected hosts * String[] containing the addresses of the selected hosts
@ -635,7 +625,7 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
public String[] getAddresses() public String[] getAddresses()
{ {
Vector addressVector = new Vector(); Vector addressVector = new Vector();
Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements(); Object[] checkedElements = ((ContainerCheckedTreeViewer) viewerPaneTree.getViewer()).getCheckedElements();
for(int i=0; i<checkedElements.length; i++) for(int i=0; i<checkedElements.length; i++)
{ {
@ -644,18 +634,18 @@ public class ServiceDiscoveryWizardDisplayPage extends WizardPage {
addressVector.add(((Device)checkedElements[i]).getAddress()); addressVector.add(((Device)checkedElements[i]).getAddress());
} }
} }
String[] addresses = new String[addressVector.size()]; String[] addresses = new String[addressVector.size()];
addressVector.copyInto(addresses); addressVector.copyInto(addresses);
return addresses; return addresses;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage() * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
*/ */
public boolean canFlipToNextPage() { public boolean canFlipToNextPage() {
return false; return false;
} }
} }