Search in sources :

Example 51 with NodeContainer

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;
}
Also used : CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) Command(org.eclipse.gef.commands.Command) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Process(org.talend.designer.core.ui.editor.process.Process) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 52 with NodeContainer

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

the class JobletContainerPart method createFigure.

@Override
protected IFigure createFigure() {
    IFigure layoutFigure = getLayer(TalendScalableFreeformRootEditPart.MAP_REDUCE_LAYER);
    JobletContainerFigure JobletContainerFigure = new JobletContainerFigure((JobletContainer) this.getModel(), layoutFigure);
    Node node = ((NodeContainer) getModel()).getNode();
    JobletContainerFigure.updateStatus(node.getStatus());
    return JobletContainerFigure;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IFigure(org.eclipse.draw2d.IFigure)

Example 53 with NodeContainer

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

the class NodeErrorEditPart method performRequest.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
     */
@Override
public void performRequest(final Request request) {
    if (request.getType().equals("open")) {
        //$NON-NLS-1$
        Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
        if (node.isErrorFlag()) {
            Shell shell = getViewer().getControl().getShell();
            ErrorMessageDialog dialog = new ErrorMessageDialog(new Shell(shell), node);
            dialog.open();
        }
    }
}
Also used : ErrorMessageDialog(org.talend.designer.core.ui.dialog.mergeorder.ErrorMessageDialog) Shell(org.eclipse.swt.widgets.Shell) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 54 with NodeContainer

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

the class SubjobContainer method deleteNodeContainer.

/**
     * DOC ycbai Comment method "deleteNodeContainer".
     * 
     * @param nodeUniqueName
     * @return
     */
public boolean deleteNodeContainer(String nodeUniqueName) {
    boolean deleted = false;
    if (nodeUniqueName == null) {
        return deleted;
    }
    List<NodeContainer> nContainers = getNodeContainers();
    Iterator<NodeContainer> nodeContainerIter = nContainers.iterator();
    while (nodeContainerIter.hasNext()) {
        NodeContainer nc = nodeContainerIter.next();
        if (nodeUniqueName.equals(nc.getNode().getUniqueName())) {
            nodeContainerIter.remove();
            deleted = true;
        }
    }
    if (deleted) {
        updateSubjobContainer();
    }
    return deleted;
}
Also used : NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 55 with NodeContainer

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

the class SubjobContainer method getSubjobContainerRectangle.

/**
     * DOC nrousseau Comment method "getSubjobContainerRectangle".
     * 
     * @return
     */
public Rectangle getSubjobContainerRectangle() {
    Rectangle totalRectangle = null;
    boolean collapsed = isCollapsed();
    boolean isTestContainer = false;
    ITestContainerGEFService testContainerService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
        testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault().getService(ITestContainerGEFService.class);
        if (testContainerService != null) {
            isTestContainer = testContainerService.isTestContainer(this.process);
        }
    }
    // boolean hasJoblet = false;
    for (NodeContainer container : nodeContainers) {
        Rectangle curRect = null;
        if (container instanceof AbstractJobletContainer) {
            curRect = ((AbstractJobletContainer) container).getJobletContainerRectangle();
        } else if (isTestContainer && testContainerService != null) {
            curRect = testContainerService.getJunitContainerRectangle(container);
        } else {
            curRect = container.getNodeContainerRectangle();
        }
        if ((curRect.x + curRect.width) == (container.getNode().getPosX() + container.getNode().getSize().width)) {
            curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
        }
        if ((curRect.y + curRect.height) == (container.getNode().getPosY() + container.getNode().getSize().height)) {
            curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
        }
        if (curRect.y == container.getNode().getPosY()) {
            // means have totally no other status or such on the top of the node in the NodeContainerFigure, then we
            // add one more space on the top of the subjob
            // this could be done only once, but to simplify the calculation, just do for every node
            curRect.setLocation(curRect.getLocation().x, curRect.getLocation().y - TalendEditor.GRID_SIZE);
            curRect.setSize(curRect.getSize().width, curRect.getSize().height + TalendEditor.GRID_SIZE);
        }
        if (curRect.x == container.getNode().getPosX()) {
            // means if the node container figure is just at the border of the size of the component
            // then we add one more space on the left of the component, just to avoid have one subjob background
            // "too small" (too close to component)
            // this could be done only once, but to simplify the calculation, just do for every node
            curRect.setLocation(curRect.getLocation().x - TalendEditor.GRID_SIZE, curRect.getLocation().y);
            curRect.setSize(curRect.getSize().width + TalendEditor.GRID_SIZE, curRect.getSize().height);
        }
        if (collapsed && totalRectangle == null) {
            totalRectangle = curRect.getCopy();
        } else if (!collapsed) {
            if (totalRectangle == null) {
                totalRectangle = curRect.getCopy();
            } else {
                totalRectangle = totalRectangle.getUnion(curRect);
            }
        } else if (collapsed && testContainerService != null && testContainerService.isJunitContainer(container)) {
            INode startNode = this.getSubjobStartNode().getJunitNode();
            INode containerNode = container.getNode().getJunitNode();
            if (startNode != null && containerNode != null && startNode == containerNode) {
                totalRectangle = testContainerService.getJunitContainerRectangle(container).getCopy();
            }
        }
        if (isTestContainer && !collapsed) {
            if (curRect.x == totalRectangle.x) {
                totalRectangle.setLocation(totalRectangle.getLocation().x - TalendEditor.GRID_SIZE, totalRectangle.getLocation().y);
                totalRectangle.setSize(totalRectangle.getSize().width + TalendEditor.GRID_SIZE, totalRectangle.getSize().height);
            }
            if (curRect.y == totalRectangle.y) {
                totalRectangle.setLocation(totalRectangle.getLocation().x, totalRectangle.getLocation().y - TalendEditor.GRID_SIZE);
                totalRectangle.setSize(totalRectangle.getSize().width, totalRectangle.getSize().height + TalendEditor.GRID_SIZE);
            }
        }
    }
    if (totalRectangle == null) {
        return null;
    }
    Point location = totalRectangle.getLocation();
    Point newLocation = new Point();
    newLocation.x = (location.x / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    newLocation.y = (location.y / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    // bug 5158
    if (newLocation.y <= 0 && location.y < 0) {
        newLocation.y = newLocation.y - TalendEditor.GRID_SIZE;
    }
    if (newLocation.x <= 0 && location.x < 0) {
        newLocation.x = newLocation.x - TalendEditor.GRID_SIZE;
    }
    totalRectangle.setLocation(newLocation);
    Dimension diff = location.getDifference(newLocation);
    Dimension size = totalRectangle.getSize().expand(diff);
    if ((size.height % TalendEditor.GRID_SIZE) == 0) {
        size.height = (size.height / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    } else {
        size.height = ((size.height / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
    }
    if ((size.width % TalendEditor.GRID_SIZE) == 0) {
        size.width = (size.width / TalendEditor.GRID_SIZE) * TalendEditor.GRID_SIZE;
    } else {
        size.width = ((size.width / TalendEditor.GRID_SIZE) + 1) * TalendEditor.GRID_SIZE;
    }
    // if (hasJoblet) {
    // size.width = size.width + TalendEditor.GRID_SIZE;
    // }
    totalRectangle.setSize(size);
    return totalRectangle;
}
Also used : INode(org.talend.core.model.process.INode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ITestContainerGEFService(org.talend.designer.core.ITestContainerGEFService) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

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