Search in sources :

Example 1 with ChangeActivateStatusElementCommand

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

the class RadioController method createCommand.

private List<Command> createCommand(SelectionEvent event) {
    Set<String> elementsName;
    Control ctrl = (Control) event.getSource();
    elementsName = hashCurControls.keySet();
    List<Command> commands = new ArrayList<Command>();
    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(event.getSource())) {
                if (ctrl instanceof Button) {
                    // before
                    if (!elem.getPropertyValue(name).equals(new Boolean(((Button) ctrl).getSelection()))) {
                        Command cmd = null;
                        Boolean value = new Boolean(((Button) ctrl).getSelection());
                        if (name.equals(EParameterName.ACTIVATE.getName())) {
                            if (elem instanceof Node) {
                                List<Node> nodeList = new ArrayList<Node>();
                                nodeList.add((Node) elem);
                                List<Connection> connList = new ArrayList<Connection>();
                                cmd = new ChangeActivateStatusElementCommand(value, nodeList, connList);
                                commands.add(cmd);
                            }
                        } else {
                            IElementParameter param = elem.getElementParameter(name);
                            if (Boolean.TRUE.equals(value)) {
                                List<IElementParameter> parameters = DesignerUtilities.findRadioParamInSameGroup(elem.getElementParameters(), param);
                                for (IElementParameter currentRadioParam : parameters) {
                                    if (Boolean.TRUE.equals(currentRadioParam.getValue())) {
                                        cmd = new PropertyChangeCommand(elem, currentRadioParam.getName(), Boolean.FALSE);
                                        commands.add(cmd);
                                    }
                                }
                            }
                            cmd = new PropertyChangeCommand(elem, name, value);
                            commands.add(cmd);
                            String groupName = param.getGroup();
                            if (groupName != null && elem.getElementParameter(groupName) != null) {
                                Command cmd2 = new PropertyChangeCommand(elem, groupName, name);
                                commands.add(cmd2);
                            }
                        }
                        return commands;
                    }
                }
            }
        }
    }
    return null;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Connection(org.talend.designer.core.ui.editor.connections.Connection) Control(org.eclipse.swt.widgets.Control) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand) Button(org.eclipse.swt.widgets.Button) IElementParameter(org.talend.core.model.process.IElementParameter) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand)

Example 2 with ChangeActivateStatusElementCommand

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

the class CheckController method createCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
     */
private Command createCommand(SelectionEvent event) {
    Control ctrl = (Control) event.getSource();
    String paramName = (String) ctrl.getData(PARAMETER_NAME);
    // only for checkbox, other buttons must be checked
    // before
    Command cmd = null;
    Boolean value = new Boolean(((Button) ctrl).getSelection());
    // Empty EParameterName.PROCESS_TYPE_PROCESS parameter if the select job is a M/R job(TDI-25914).
    if (value && paramName.equals(EParameterName.USE_DYNAMIC_JOB.getName())) {
        if (elem instanceof Node) {
            String processParamName = EParameterName.PROCESS_TYPE_PROCESS.getName();
            IElementParameter processParameter = elem.getElementParameter(processParamName);
            if (processParameter != null) {
                String processId = String.valueOf(processParameter.getValue());
                IRepositoryNode repNode = null;
                if (StringUtils.isNotEmpty(processId)) {
                    repNode = RepositorySeekerManager.getInstance().searchRepoViewNode(processId);
                }
                if (repNode != null && ERepositoryObjectType.PROCESS_MR != null && ERepositoryObjectType.PROCESS_MR.equals(repNode.getObjectType())) {
                    //$NON-NLS-1$
                    cmd = new PropertyChangeCommand(elem, processParamName, "");
                    executeCommand(cmd);
                }
            }
        }
    }
    if (paramName.equals(EParameterName.ACTIVATE.getName())) {
        if (elem instanceof Node) {
            List<Node> nodeList = new ArrayList<Node>();
            nodeList.add((Node) elem);
            List<Connection> connList = new ArrayList<Connection>();
            cmd = new ChangeActivateStatusElementCommand(value, nodeList, connList);
        } else if (elem instanceof Connection) {
            List<Node> nodeList = new ArrayList<Node>();
            List<Connection> connList = new ArrayList<Connection>();
            connList.add((Connection) elem);
            cmd = new ChangeActivateStatusElementCommand(value, nodeList, connList);
        }
    } else {
        cmd = new PropertyChangeCommand(elem, paramName, value);
    }
    return cmd;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) Connection(org.talend.designer.core.ui.editor.connections.Connection) Control(org.eclipse.swt.widgets.Control) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand) IElementParameter(org.talend.core.model.process.IElementParameter) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ChangeActivateStatusElementCommand

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

the class ActivateElementAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() >= 1) {
        ChangeActivateStatusElementCommand changeActivateStatusCommand = new ChangeActivateStatusElementCommand(activate, nodeList, connectionList);
        execute(changeActivateStatusCommand);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ChangeActivateStatusElementCommand(org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand)

Aggregations

ArrayList (java.util.ArrayList)3 ChangeActivateStatusElementCommand (org.talend.designer.core.ui.editor.cmd.ChangeActivateStatusElementCommand)3 List (java.util.List)2 Command (org.eclipse.gef.commands.Command)2 Control (org.eclipse.swt.widgets.Control)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)2 Connection (org.talend.designer.core.ui.editor.connections.Connection)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 Button (org.eclipse.swt.widgets.Button)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1