Search in sources :

Example 46 with NodeContainer

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;
}
Also used : MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Note(org.talend.designer.core.ui.editor.notes.Note) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 47 with NodeContainer

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;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) TalendEditorConnectionTargetAssist(org.talend.designer.core.assist.TalendEditorConnectionTargetAssist)

Example 48 with NodeContainer

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;
}
Also used : RectangleFigure(org.eclipse.draw2d.RectangleFigure) NodeFigure(org.talend.designer.core.ui.editor.nodes.NodeFigure) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 49 with NodeContainer

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()));
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) SetParallelizationCommand(org.talend.designer.core.ui.editor.cmd.SetParallelizationCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 50 with NodeContainer

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;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IComponent(org.talend.core.model.components.IComponent) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Aggregations

NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)60 Node (org.talend.designer.core.ui.editor.nodes.Node)43 ArrayList (java.util.ArrayList)23 INode (org.talend.core.model.process.INode)23 List (java.util.List)20 Process (org.talend.designer.core.ui.editor.process.Process)20 Point (org.eclipse.draw2d.geometry.Point)17 IComponent (org.talend.core.model.components.IComponent)13 IConnection (org.talend.core.model.process.IConnection)12 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 IProcess (org.talend.core.model.process.IProcess)11 Connection (org.talend.designer.core.ui.editor.connections.Connection)11 IElementParameter (org.talend.core.model.process.IElementParameter)10 EditPart (org.eclipse.gef.EditPart)9 IExternalNode (org.talend.core.model.process.IExternalNode)9 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)9 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)9 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)9 HashMap (java.util.HashMap)8