use of net.sourceforge.usbdm.peripheralDatabase.IPeripheralDescriptionProvider in project usbdm-eclipse-plugins by podonoghue.
the class DevicePeripheralSelectionDialogue method populateDeviceList.
/**
* Populate device list based on currently selected provider
*/
void populateDeviceList() {
// Clear existing device details
comboManufacturerSelect.setToolTipText("No description");
comboDeviceName.removeAll();
String providerId = getProviderId();
if (providerId == null) {
return;
}
try {
IPeripheralDescriptionProvider peripheralDescriptionProvider = devicePeriperalsProviderInterface.getProvider(providerId);
comboManufacturerSelect.setToolTipText(peripheralDescriptionProvider.getDescription());
Vector<String> deviceNames = peripheralDescriptionProvider.getDeviceNames();
for (String s : deviceNames) {
comboDeviceName.add(s);
}
comboDeviceName.select(0);
} catch (Exception e) {
System.err.println("DevicePeripheralSelectionDialogue.populateDeviceList()" + e.getMessage());
}
}
use of net.sourceforge.usbdm.peripheralDatabase.IPeripheralDescriptionProvider in project usbdm-eclipse-plugins by podonoghue.
the class DevicePeripheralSelectionDialogue method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
// Create the manager and bind to main composite
resManager = new LocalResourceManager(JFaceResources.getResources(), parent);
Composite container = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout(1, false);
layout.marginRight = 5;
layout.marginLeft = 5;
container.setLayout(layout);
/*
* Create Internal group
*/
grpInternal = new Group(container, SWT.NONE);
grpInternal.setText("Internal SVD Files");
grpInternal.setLayout(new GridLayout(3, false));
grpInternal.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Label label = new Label(grpInternal, SWT.NONE);
// $NON-NLS-1$
label.setText("Manufacturer:");
comboManufacturerSelect = new Combo(grpInternal, SWT.BORDER | SWT.READ_ONLY);
comboManufacturerSelect.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
new Label(grpInternal, SWT.NONE);
providerIds = devicePeriperalsProviderInterface.getProviderIDs();
for (String pd : providerIds) {
comboManufacturerSelect.add(devicePeriperalsProviderInterface.getProviderName(pd));
}
comboManufacturerSelect.select(0);
comboManufacturerSelect.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
manufacturerChanged();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
label = new Label(grpInternal, SWT.NONE);
// $NON-NLS-1$
label.setText("Target Device:");
comboDeviceName = new Combo(grpInternal, SWT.BORDER | SWT.READ_ONLY);
comboDeviceName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
populateDeviceList();
comboDeviceName.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
// Selected device has changed
updateSvdId();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnDeviceSelect = new Button(grpInternal, SWT.NONE);
btnDeviceSelect.setText("Device...");
btnDeviceSelect.setToolTipText("Select internal USBDM\ndevice by category");
btnDeviceSelect.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
// Open dialogue to select device
DeviceSelector ds = new DeviceSelector(getShell(), targetType, comboDeviceName.getText());
if (ds.open() == Window.OK) {
// Map device name to SVD file name
String message = null;
try {
IPeripheralDescriptionProvider provider = devicePeriperalsProviderInterface.getProvider(UsbdmPeripheralDescriptionProvider.ID);
String mappedName = provider.getMappedDeviceName(ds.getText());
if (mappedName == null) {
message = "Cannot locate SVD file for device";
} else {
// System.err.println("Mapped name = " + mappedName);
int providerIndex = providerIds.indexOf(UsbdmPeripheralDescriptionProvider.ID);
if (providerIndex < 0) {
providerIndex = 0;
}
comboManufacturerSelect.select(providerIndex);
populateDeviceList();
comboDeviceName.setText(mappedName);
updateSvdId();
}
} catch (Exception e) {
message = "Cannot locate SVD for device\nReason " + e.getMessage();
}
if (message != null) {
MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.CANCEL);
messageBox.setText("Error");
messageBox.setMessage(message);
messageBox.open();
}
}
validate();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
chkUseExternalSVDFile = new Button(container, SWT.CHECK);
chkUseExternalSVDFile.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
chkUseExternalSVDFile.setText("Use external SVD file");
chkUseExternalSVDFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSvdId();
}
});
/*
* Create External group
*/
grpExternal = new Group(container, SWT.NONE);
grpExternal.setText("External SVD File");
grpExternal.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpExternal.setLayout(new GridLayout(3, false));
label = new Label(grpExternal, SWT.NONE);
// $NON-NLS-1$
label.setText("External File:");
txtFilePath = new Text(grpExternal, SWT.BORDER | SWT.READ_ONLY);
txtFilePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnFileBrowse = new Button(grpExternal, SWT.PUSH);
btnFileBrowse.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
btnFileBrowse.setText("Browse...");
btnFileBrowse.setToolTipText("Select external file...");
btnFileBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final String[] filterExts = { "*.svd;*.xml" };
FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
fd.setText("Locate SVD file describing device");
fd.setFilterPath(txtFilePath.getText());
fd.setFilterExtensions(filterExts);
String directoryPath = fd.open();
if (directoryPath != null) {
txtFilePath.setText(directoryPath);
updateSvdId();
}
}
});
setSvdIdentifier(fSvdIdentifier);
return container;
}
Aggregations