Search in sources :

Example 11 with IGraphicalNode

use of org.talend.core.ui.process.IGraphicalNode in project tdi-studio-se by Talend.

the class NodesPasteCommand method computeTheDistance.

private Point computeTheDistance(int index, int firstIndex, Point location) {
    Point firstNodeLocation = ((IGraphicalNode) nodePart.getModel()).getLocation();
    Point currentNodeLocation = ((IGraphicalNode) nodeParts.get(index).getModel()).getLocation();
    int distanceX = firstNodeLocation.x - currentNodeLocation.x;
    int distanceY = firstNodeLocation.y - currentNodeLocation.y;
    location.x = location.x - distanceX;
    location.y = location.y - distanceY;
    return location;
}
Also used : IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 12 with IGraphicalNode

use of org.talend.core.ui.process.IGraphicalNode 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)

Aggregations

IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)12 Point (org.eclipse.draw2d.geometry.Point)11 ArrayList (java.util.ArrayList)7 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)5 List (java.util.List)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 INode (org.talend.core.model.process.INode)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 IConnection (org.talend.core.model.process.IConnection)3 IExternalNode (org.talend.core.model.process.IExternalNode)3 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)3 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 IComponent (org.talend.core.model.components.IComponent)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2