use of org.talend.designer.core.ui.dialog.IBrmsExtension in project tdi-studio-se by Talend.
the class ModuleListController method createCommand.
public Command createCommand(Button button) {
Node node = (Node) elem;
IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
if (externalNode != null && externalNode.getUniqueName().contains("tBRMS_")) {
IConfigurationElement[] elems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.talend.designer.core.brms_provider");
String propertyName = (String) button.getData(PARAMETER_NAME);
for (IConfigurationElement conElem : elems) {
IBrmsExtension createExecutableExtension;
try {
createExecutableExtension = (IBrmsExtension) conElem.createExecutableExtension("class");
createExecutableExtension.initialize(node, propertyName, hashCurControls);
BrmsDialog brmsDialog = createExecutableExtension.createBrmsDialog(composite.getShell());
String file = brmsDialog.getFile();
if (file != null && !file.equals("")) {
String lastSegment = TalendTextUtils.addQuotes(Path.fromOSString(file).lastSegment());
try {
CorePlugin.getDefault().getLibrariesService().deployLibrary(Path.fromOSString(file).toFile().toURL());
} catch (Exception e) {
ExceptionHandler.process(e);
}
// update the combo current value
CCombo combo = (CCombo) hashCurControls.get(propertyName);
if (combo != null && !combo.isDisposed()) {
combo.setText(Path.fromOSString(file).lastSegment());
}
return new PropertyChangeCommand(elem, propertyName, lastSegment);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
} else {
FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
dial.setFilterExtensions(FilesUtils.getAcceptJARFilesSuffix());
String file = dial.open();
if (file != null && !file.equals("")) {
//$NON-NLS-1$
String propertyName = (String) button.getData(PARAMETER_NAME);
String lastSegment = TalendTextUtils.addQuotes(Path.fromOSString(file).lastSegment());
try {
CorePlugin.getDefault().getLibrariesService().deployLibrary(Path.fromOSString(file).toFile().toURL());
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (!elem.getPropertyValue(propertyName).equals(lastSegment)) {
// update the combo current value
CCombo combo = (CCombo) hashCurControls.get(propertyName);
if (combo != null && !combo.isDisposed()) {
combo.setText(Path.fromOSString(file).lastSegment());
}
return new PropertyChangeCommand(elem, propertyName, lastSegment);
}
}
}
return null;
}
Aggregations