use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.
protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
ProcessPart processPart = (ProcessPart) this.getHost();
final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
final IProcess2 process = (IProcess2) processPart.getModel();
TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
char start = '*';
assist.showComponentCreationAssist(start);
ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
if (assist.getComponentName() == null) {
assist.releaseText();
return cmd;
}
IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
if (component == null) {
assist.releaseText();
return cmd;
}
assist.releaseText();
Node newNode = new Node(component);
NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
cc.add(command);
cmd.setTarget(newNode);
cc.add(cmd);
return cc;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ProcessResizableEditPolicy method getCustomFeedbackFigure.
/**
* This will take the figure of the node and set it as feedback figure.
*
* @param modelPart
* @return
*/
protected IFigure getCustomFeedbackFigure(Object modelPart) {
IFigure figure;
if (modelPart instanceof NodeContainer) {
return null;
}
if (modelPart instanceof Node) {
Node node = (Node) modelPart;
figure = new NodeFigure(node);
if (node.isStart()) {
figure.setBackgroundColor(NodeFigure.START_COLOR);
} else {
figure.setOpaque(false);
}
} else {
figure = new RectangleFigure();
((RectangleFigure) figure).setXOR(true);
((RectangleFigure) figure).setFill(true);
figure.setBackgroundColor(ColorConstants.darkGreen);
figure.setForegroundColor(ColorConstants.white);
}
return figure;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class SetParallelizationAction method run.
@Override
public void run() {
List editparts = getSelectedObjects();
if (editparts.size() == 1) {
Object o = editparts.get(0);
if (o instanceof NodePart) {
NodePart part = (NodePart) o;
Node node = (Node) part.getModel();
getCommandStack().execute(new SetParallelizationCommand(node));
} else if (o instanceof SubjobContainerPart) {
boolean hasStartNode = false;
List<NodeContainerPart> childNodes = ((SubjobContainerPart) o).getChildren();
for (NodeContainerPart childNode : childNodes) {
NodeContainerPart part = (NodeContainerPart) childNode;
NodeContainer node = (NodeContainer) part.getModel();
if (node.getNode().isStart()) {
hasStartNode = true;
getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
}
}
if (!hasStartNode) {
for (NodeContainerPart childNode : childNodes) {
NodeContainerPart part = (NodeContainerPart) childNode;
NodeContainer node = (NodeContainer) part.getModel();
if (node.getNode().isSubProcessStart()) {
getCommandStack().execute(new SetParallelizationCommand(node.getNode()));
}
}
}
}
}
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletUtil method cloneNodeContainer.
public NodeContainer cloneNodeContainer(NodeContainer nodeContainer, Node cloneNode) {
NodeContainerPart nodeConPart = new NodeContainerPart();
// TDI-13132
IComponent tempComponent = cloneNode.getComponent();
if (tempComponent != null) {
String tempComponentName = tempComponent.getName();
if (tempComponentName != null) {
IComponent component = ComponentsFactoryProvider.getInstance().get(tempComponentName, cloneNode.getProcess().getComponentsType());
if (component != null) {
cloneNode.setComponent(component);
}
}
}
NodeContainer cloneNodeContainer = new NodeContainer(cloneNode);
nodeConPart.setModel(cloneNodeContainer);
cloneNodeContainer.setNodeError(cloneNode.getNodeError());
cloneNodeContainer.setNodeLabel(cloneNode.getNodeLabel());
cloneNodeContainer.setNodeProgressBar(cloneNode.getNodeProgressBar());
cloneNodeContainer.setReadOnly(nodeContainer.isReadOnly());
return cloneNodeContainer;
}
use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class JobletContainerLayoutEditPolicy method getCreateCommand.
@Override
protected Command getCreateCommand(CreateRequest request) {
Rectangle constraint = (Rectangle) getConstraintFor(request);
Process linkedProcess = (Process) ((JobletContainer) getHost().getModel()).getNode().getProcess();
Command command = null;
if (Note.class.equals(request.getNewObjectType())) {
command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
} else if (request.getNewObject() instanceof Node) {
Node node = (Node) request.getNewObject();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
}
return command;
}
Aggregations