Search in sources :

Example 1 with MoveNoteCommand

use of org.talend.designer.core.ui.editor.cmd.MoveNoteCommand 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 2 with MoveNoteCommand

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

the class SubjobContainerLayoutEditPolicy method createAddCommand.

// ------------------------------------------------------------------------
// Abstract methods from ConstrainedLayoutEditPolicy
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createAddCommand(org.eclipse.gef.EditPart,
     * java.lang.Object)
     */
protected Command createAddCommand(final EditPart child, final Object constraint) {
    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 NodeLabelEditPart) {
        boolean nodeSelected;
        // if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
        // nodeSelected = true;
        // } else {
        nodeSelected = false;
        // }
        MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
        return locationCommand;
    } else if (child instanceof NodePart) {
        if (((Node) child.getModel()).isReadOnly()) {
            return null;
        }
        MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
        return locationCommand;
    } else {
        return null;
    }
}
Also used : MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 3 with MoveNoteCommand

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

the class SubjobContainerLayoutEditPolicy method createChangeConstraintCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
     * java.lang.Object)
     */
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
    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 NodeLabelEditPart) {
        boolean nodeSelected;
        // if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
        // nodeSelected = true;
        // } else {
        nodeSelected = false;
        // }
        MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
        return locationCommand;
    } else if (child instanceof NodePart) {
        if (((Node) child.getModel()).isReadOnly()) {
            return null;
        }
        MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
        return locationCommand;
    } else {
        return null;
    }
}
Also used : MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

MoveNodeCommand (org.talend.designer.core.ui.editor.cmd.MoveNodeCommand)3 MoveNoteCommand (org.talend.designer.core.ui.editor.cmd.MoveNoteCommand)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)3 Note (org.talend.designer.core.ui.editor.notes.Note)3 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 MoveNodeLabelCommand (org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand)2 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)2 Point (org.eclipse.draw2d.geometry.Point)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)1 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)1 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)1 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)1