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;
}
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;
}
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);
}
}
Aggregations