Search in sources :

Example 26 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class ImportRulesFromRepository method updateParameters.

public void updateParameters(Object propValue) {
    PropertyChangeCommand cmd = new PropertyChangeCommand(node, RULE_TABLE, propValue);
    cmd.setUpdate(true);
    controller.executeCommand(cmd);
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)

Example 27 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class ModuleListController method createCommand.

public Command createCommand(SelectionEvent selectionEvent) {
    Set<String> elementsName;
    Control ctrl;
    elementsName = hashCurControls.keySet();
    for (String name : elementsName) {
        Object o = hashCurControls.get(name);
        if (o instanceof Control) {
            ctrl = (Control) o;
            if (ctrl == null) {
                hashCurControls.remove(name);
                return null;
            }
            if (ctrl.equals(selectionEvent.getSource()) && ctrl instanceof CCombo) {
                boolean isDisposed = ((CCombo) ctrl).isDisposed();
                if (!isDisposed && (!elem.getPropertyValue(name).equals(((CCombo) ctrl).getText()))) {
                    //$NON-NLS-1$
                    String value = new String("");
                    for (int i = 0; i < elem.getElementParameters().size(); i++) {
                        IElementParameter param = elem.getElementParameters().get(i);
                        if (param.getName().equals(name)) {
                            for (int j = 0; j < param.getListItemsValue().length; j++) {
                                if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) {
                                    value = (String) param.getListItemsValue()[j];
                                }
                            }
                        }
                    }
                    if (value.equals(elem.getPropertyValue(name))) {
                        // anything
                        return null;
                    }
                    CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
                    return new PropertyChangeCommand(elem, name, value);
                }
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter) Point(org.eclipse.swt.graphics.Point)

Example 28 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tdi-studio-se by Talend.

the class OpenedListController method modifyCommand.

/**
     * DOC zli Comment method "modifyCommand".
     * 
     * @param event
     * @return
     */
private Command modifyCommand(ModifyEvent event) {
    Set<String> elementsName;
    Control ctrl;
    elementsName = hashCurControls.keySet();
    for (String name : elementsName) {
        Object o = hashCurControls.get(name);
        if (o instanceof Control) {
            ctrl = (Control) o;
            if (ctrl == null) {
                hashCurControls.remove(name);
                return null;
            }
            CCombo combo = (CCombo) event.getSource();
            Object data = ctrl.getData(PARAMETER_NAME);
            if (!(ctrl instanceof CCombo)) {
                continue;
            }
            boolean isDisposed = ((CCombo) ctrl).isDisposed() || combo.isDisposed();
            if (isDisposed) {
                continue;
            }
            String paramName = "";
            if (data != null) {
                paramName = data.toString();
            }
            String value = "";
            if (data != null && data.equals(combo.getData(PARAMETER_NAME))) {
                for (int i = 0; i < elem.getElementParameters().size(); i++) {
                    IElementParameter param = elem.getElementParameters().get(i);
                    if (param.getFieldType().equals(EParameterFieldType.OPENED_LIST) && paramName.equals(param.getName())) {
                        String text = ((CCombo) ctrl).getText();
                        String[] listItemsDisplayName = param.getListItemsDisplayName();
                        boolean valueSet = false;
                        Object[] listItemsValue = param.getListItemsValue();
                        for (int j = 0; j < listItemsValue.length; j++) {
                            if (j < listItemsDisplayName.length && text.equals(listItemsDisplayName[j])) {
                                value = (String) listItemsValue[j];
                                valueSet = true;
                                break;
                            }
                        }
                        if (!valueSet) {
                            value = text;
                        }
                        // TDI-21313
                        if (value != null && value.equals(param.getValue())) {
                            return null;
                        }
                        param.setValue(value);
                    }
                }
                return new PropertyChangeCommand(elem, paramName, value);
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter) Point(org.eclipse.swt.graphics.Point)

Example 29 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tesb-studio-se by Talend.

the class RouteResourceController method createComboCommand.

/**
 * DOC nrousseau Comment method "createComboCommand".
 *
 * @param source
 * @return
 */
private PropertyChangeCommand createComboCommand(CCombo combo) {
    String paramName = (String) combo.getData(PARAMETER_NAME);
    IElementParameter param = elem.getElementParameter(paramName);
    String value = combo.getText();
    // }
    if (value.equals(param.getValue())) {
        return null;
    }
    return new PropertyChangeCommand(elem, paramName, value);
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 30 with PropertyChangeCommand

use of org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand in project tbd-studio-se by Talend.

the class AbstractHDFSBrowseController method createCommand.

protected Command createCommand(SelectionEvent event, HDFSConnectionBean connection) {
    HDFSBrowseDialog dial = new HDFSBrowseDialog(composite.getShell(), getHDFSType(), connection);
    Button btn = (Button) event.getSource();
    String propertyName = (String) btn.getData(PARAMETER_NAME);
    Text filePathText = (Text) hashCurControls.get(propertyName);
    if (dial.open() == Window.OK) {
        IHDFSNode result = dial.getResult();
        String path = result.getPath();
        path = TalendQuoteUtils.addQuotesIfNotExist(path);
        if (!elem.getPropertyValue(propertyName).equals(path)) {
            filePathText.setText(path);
            return new PropertyChangeCommand(elem, propertyName, path);
        }
    }
    return null;
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Button(org.eclipse.swt.widgets.Button) Text(org.eclipse.swt.widgets.Text) IHDFSNode(org.talend.designer.hdfsbrowse.model.IHDFSNode)

Aggregations

PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)69 IElementParameter (org.talend.core.model.process.IElementParameter)34 Command (org.eclipse.gef.commands.Command)24 Point (org.eclipse.swt.graphics.Point)18 INode (org.talend.core.model.process.INode)18 Node (org.talend.designer.core.ui.editor.nodes.Node)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 Control (org.eclipse.swt.widgets.Control)14 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)13 RepositoryNode (org.talend.repository.model.RepositoryNode)12 CCombo (org.eclipse.swt.custom.CCombo)11 IConnection (org.talend.core.model.process.IConnection)11 ConnectionItem (org.talend.core.model.properties.ConnectionItem)11 ArrayList (java.util.ArrayList)10 List (java.util.List)10 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)10 Item (org.talend.core.model.properties.Item)10 Button (org.eclipse.swt.widgets.Button)9 Text (org.eclipse.swt.widgets.Text)8 MetadataTable (org.talend.core.model.metadata.MetadataTable)8