use of org.talend.designer.core.ui.editor.nodecontainer.NodeContainer in project tdi-studio-se by Talend.
the class ProcessLayoutEditPolicy method createChangeConstraintCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
* java.lang.Object)
*/
@Override
public Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// return a command to move the part to the location given by the constraint
if (child instanceof NodePart) {
if (((Node) child.getModel()).isReadOnly()) {
return null;
}
MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof NoteEditPart) {
if (((Note) child.getModel()).isReadOnly()) {
return null;
}
MoveNoteCommand locationCommand = new MoveNoteCommand((Note) child.getModel(), ((Rectangle) constraint).getLocation());
return locationCommand;
}
if (child instanceof SubjobContainerPart) {
SubjobContainer sjc = (SubjobContainer) child.getModel();
Point sjcLocation = sjc.getSubjobContainerRectangle().getLocation();
Point translationNeeded = new Point(((Rectangle) constraint).getLocation().x - sjcLocation.x, ((Rectangle) constraint).getLocation().y - sjcLocation.y);
CompoundCommand cc = new CompoundCommand();
for (NodeContainer nc : sjc.getNodeContainers()) {
if (nc.isReadOnly()) {
return null;
}
IGraphicalNode node = nc.getNode();
Point nodeLocation = node.getLocation();
MoveNodeCommand locationCommand = new MoveNodeCommand(nc.getNode(), nodeLocation.getTranslated(translationNeeded));
cc.add(locationCommand);
}
return cc;
}
return null;
}
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;
}
Aggregations