Search in sources :

Example 1 with IBrmsExtension

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;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CoreException(org.eclipse.core.runtime.CoreException) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) BrmsDialog(org.talend.designer.core.ui.dialog.BrmsDialog) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) FileDialog(org.eclipse.swt.widgets.FileDialog) IBrmsExtension(org.talend.designer.core.ui.dialog.IBrmsExtension) CoreException(org.eclipse.core.runtime.CoreException) IExternalNode(org.talend.core.model.process.IExternalNode)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 CCombo (org.eclipse.swt.custom.CCombo)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 IExternalNode (org.talend.core.model.process.IExternalNode)1 BrmsDialog (org.talend.designer.core.ui.dialog.BrmsDialog)1 IBrmsExtension (org.talend.designer.core.ui.dialog.IBrmsExtension)1 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1