1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

improved service discovery wizard page and added multicast addresses in protocol extension point

This commit is contained in:
Javier Montalvo Orus 2007-05-10 16:54:27 +00:00
parent 1fe5c4b9dd
commit 4d99f3a4aa
5 changed files with 134 additions and 5 deletions

View file

@ -61,6 +61,13 @@
</appInfo>
</annotation>
</attribute>
<attribute name="multicast" type="string">
<annotation>
<documentation>
Allows specifying multicast addresses to be used with different transports in the format &quot;transportName1#address1;transportName2#address2&quot;
</documentation>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -112,5 +112,48 @@ public class ProtocolFactory {
}
return protocol;
}
/**
* Gets the multicast address given a protocol name and a transport name or returns null if this information is not available
*
* @param protocolName
* Name of the protocol
* @param transportName
* Name of the transport
* @return
* String representing the multicast address of the given protocol and transport or null if not available
* @throws CoreException
*
* @see IProtocol
*/
public static String getMulticastAddress(String protocolName, String transportName) throws CoreException {
String multiCastAddress = null;
IConfigurationElement[] ce = ep.getConfigurationElements();
for (int i = 0; i < ce.length; i++) {
String name = ce[i].getAttribute("name"); //$NON-NLS-1$
if(name!=null)
if(name.equalsIgnoreCase(protocolName))
{
String multicastAddresses = ce[i].getAttribute("multicast"); //$NON-NLS-1$
if(multicastAddresses==null)
break;
String[] pairs = multicastAddresses.split(";"); //$NON-NLS-1$
for (int j = 0; j < pairs.length; j++) {
String[] pair = pairs[j].split("#"); //$NON-NLS-1$
if(pair[0].equals(transportName))
{
multiCastAddress = pair[1];
break;
}
}
}
}
return multiCastAddress;
}
}

View file

@ -14,7 +14,8 @@ Contributors:
<plugin>
<extension point="org.eclipse.tm.discovery.engine.discoveryProtocol">
<protocol
class="org.eclipse.tm.internal.discovery.protocol.dnssd.DNSSDProtocol"
name="DNS-SD"/>
class="org.eclipse.tm.internal.discovery.protocol.dnssd.DNSSDProtocol"
multicast="UDP#224.0.0.251"
name="DNS-SD"/>
</extension>
</plugin>

View file

@ -17,7 +17,9 @@ 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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@ -46,6 +48,9 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
// widgets
private Combo queryCombo, transportCombo, protocolCombo;
private Text addressText, timeOutText;
private Button multicastButton;
private String tempAddress;
/**
* Wizard main page constructor
@ -62,12 +67,22 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
*/
public void createControl(Composite parent) {
FillLayout layout = new FillLayout();
layout.type = SWT.VERTICAL;
Composite comp = new Composite(parent,SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
comp.setLayout(layout);
//GridData
GridData data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
data.verticalAlignment = SWT.BEGINNING;
data.grabExcessVerticalSpace = false;
comp.setLayoutData(data);
new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.AddressLabel")); //$NON-NLS-1$
addressText = new Text(comp, SWT.BORDER | SWT.SINGLE | SWT.WRAP);
@ -88,12 +103,55 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
}
});
addressText.setLayoutData(data);
Composite comp2 = new Composite(comp,SWT.NULL);
GridLayout layout2 = new GridLayout();
layout2.numColumns = 2;
comp2.setLayout(layout2);
multicastButton = new Button(comp2,SWT.CHECK);
multicastButton.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
Object src = e.getSource();
if(((Button)src).getSelection())
{
String multicastAddress = null;
try {
multicastAddress = ProtocolFactory.getMulticastAddress(protocolCombo.getText(), transportCombo.getText());
} catch (CoreException e1) {}
if(multicastAddress!=null)
{
tempAddress = addressText.getText();
addressText.setText(multicastAddress);
}
}
else
{
addressText.setText(tempAddress);
}
}
});
new Label(comp2,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.MuticastAddressLabel0")); //$NON-NLS-1$
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);
transportCombo.setLayoutData(data);
new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.ProtocolLabel")); //$NON-NLS-1$
protocolCombo = new Combo(comp, SWT.READ_ONLY);
@ -115,9 +173,25 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
queryCombo.removeAll();
queryCombo.setItems(queries);
queryCombo.select(0);
if(multicastButton.getSelection())
{
String multicastAddress = null;
try {
multicastAddress = ProtocolFactory.getMulticastAddress(protocolCombo.getText(), transportCombo.getText());
} catch (CoreException e1) {}
if(multicastAddress!=null)
{
tempAddress = addressText.getText();
addressText.setText(multicastAddress);
}
}
}
});
protocolCombo.setLayoutData(data);
new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.DiscoveryQueryLabel")); //$NON-NLS-1$
@ -131,6 +205,7 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
}
queryCombo.select(0);
queryCombo.setLayoutData(data);
new Label(comp,SWT.NULL).setText(Messages.getString("ServiceDiscoveryWizardMainPage.TimeOutLabel")); //$NON-NLS-1$
@ -138,6 +213,8 @@ public class ServiceDiscoveryWizardMainPage extends WizardPage {
timeOutText.setText(Messages.getString("ServiceDiscoveryWizardMainPage.TimeOutValue")); //$NON-NLS-1$
timeOutText.redraw();
timeOutText.setLayoutData(data);
setPageComplete(false);
setControl(comp);

View file

@ -17,6 +17,7 @@ ServiceDiscoveryWizardMainPage.TimeOutLabel=Timeout (ms):
ServiceDiscoveryWizardMainPage.TimeOutValue=500
ServiceDiscoveryWizardDisplayPage.ProtocolErrorTitle=Error
ServiceDiscoveryWizardMainPage.WizardPageDescription=Discover available services in the target device.
ServiceDiscoveryWizardMainPage.MuticastAddressLabel0=multicast address
ServiceDiscoveryWizardDisplayPage.ProtocolErrorMessage=Error loading protocol
ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundTitle=Error
ServiceDiscoveryWizardDisplayPage.TransportAddressNotFoundMessage=Error resolving address