Search in sources :

Example 51 with EditPart

use of org.eclipse.gef.EditPart in project knime-core by knime.

the class WorkflowSelectionDragEditPartsTracker method getCommand.

/**
 * Asks each edit part in the
 * {@link org.eclipse.gef.tools.AbstractTool#getOperationSet() operation set}
 * to contribute to a {@link CompoundCommand} after first setting the
 * request type to either {@link org.eclipse.gef.RequestConstants#REQ_MOVE}
 * or {@link org.eclipse.gef.RequestConstants#REQ_ORPHAN}, depending on the
 * result of {@link #isMove()}.
 *
 * Additionally the method creates a command to adapt connections where both
 * node container are include in the drag operation.
 *
 * {@inheritDoc}
 */
@Override
protected Command getCommand() {
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel("Drag Object Tracker");
    Iterator iter = getOperationSet().iterator();
    Request request = getTargetRequest();
    if (isCloneActive()) {
        request.setType(REQ_CLONE);
    } else if (isMove()) {
        request.setType(REQ_MOVE);
    } else {
        request.setType(REQ_ORPHAN);
    }
    if (!isCloneActive()) {
        while (iter.hasNext()) {
            EditPart editPart = (EditPart) iter.next();
            command.add(editPart.getCommand(request));
        }
    }
    // now add the commands for the node-embraced connections
    ConnectionContainerEditPart[] connectionsToAdapt = getEmbracedConnections(getOperationSet());
    for (ConnectionContainerEditPart connectionPart : connectionsToAdapt) {
        command.add(connectionPart.getBendpointAdaptionCommand(request));
    }
    if (!isMove() || isCloneActive()) {
        if (!isCloneActive()) {
            request.setType(REQ_ADD);
        }
        if (getTargetEditPart() == null) {
            command.add(UnexecutableCommand.INSTANCE);
        } else {
            command.add(getTargetEditPart().getCommand(getTargetRequest()));
        }
    }
    return command;
}
Also used : ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) Iterator(java.util.Iterator) Request(org.eclipse.gef.Request) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 52 with EditPart

use of org.eclipse.gef.EditPart in project knime-core by knime.

the class WorkflowSelectionDragEditPartsTracker method handleDoubleClick.

/**
 * {@inheritDoc}
 */
@Override
protected boolean handleDoubleClick(final int button) {
    EditPart part = getSourceEditPart();
    if (part instanceof NodeContainerEditPart && getCurrentInput().isModKeyDown(SWT.MOD1)) {
        NodeContainerEditPart ncPart = ((NodeContainerEditPart) part);
        NodeContainerUI container = (NodeContainerUI) ncPart.getModel();
        if (container instanceof SubNodeContainerUI) {
            ncPart.openSubWorkflowEditor();
            return false;
        }
    }
    return super.handleDoubleClick(button);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI)

Example 53 with EditPart

use of org.eclipse.gef.EditPart in project knime-core by knime.

the class WorkflowMarqueeSelectionTool method calculateConnections.

private void calculateConnections(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
    // determine the currently selected nodes minus the ones that are to be
    // deselected
    Collection<EditPart> currentNodes = new HashSet<EditPart>();
    if (getSelectionMode() != DEFAULT_MODE) {
        // everything is deselected
        // in default mode
        Iterator<EditPart> iter = getCurrentViewer().getSelectedEditParts().iterator();
        while (iter.hasNext()) {
            EditPart selected = iter.next();
            if (!(selected instanceof ConnectionEditPart) && !deselections.contains(selected)) {
                currentNodes.add(selected);
            }
        }
    }
    // add new connections to be selected to newSelections
    Collection<ConnectionEditPart> connections = new ArrayList<ConnectionEditPart>();
    for (Iterator<GraphicalEditPart> nodes = newSelections.iterator(); nodes.hasNext(); ) {
        GraphicalEditPart node = nodes.next();
        for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart sourceConn = itr.next();
            if (sourceConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(sourceConn.getTarget()) || currentNodes.contains(sourceConn.getTarget()))) {
                connections.add(sourceConn);
            }
        }
        for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart targetConn = itr.next();
            if (targetConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(targetConn.getSource()) || currentNodes.contains(targetConn.getSource()))) {
                connections.add(targetConn);
            }
        }
    }
    newSelections.addAll(connections);
    // add currently selected connections that are to be deselected to
    // deselections
    connections = new HashSet<ConnectionEditPart>();
    for (Iterator<GraphicalEditPart> nodes = deselections.iterator(); nodes.hasNext(); ) {
        GraphicalEditPart node = nodes.next();
        for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart sourceConn = itr.next();
            if (sourceConn.getSelected() != EditPart.SELECTED_NONE) {
                connections.add(sourceConn);
            }
        }
        for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart targetConn = itr.next();
            if (targetConn.getSelected() != EditPart.SELECTED_NONE) {
                connections.add(targetConn);
            }
        }
    }
    deselections.addAll(connections);
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 54 with EditPart

use of org.eclipse.gef.EditPart in project knime-core by knime.

the class WorkflowMarqueeSelectionTool method showTargetFeedback.

private void showTargetFeedback() {
    for (Iterator<GraphicalEditPart> itr = selectedEditParts.iterator(); itr.hasNext(); ) {
        EditPart editPart = itr.next();
        editPart.showTargetFeedback(getTargetRequest());
    }
}
Also used : AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 55 with EditPart

use of org.eclipse.gef.EditPart in project knime-core by knime.

the class CutAction method runInSWT.

/**
 * Invokes the copy action followed by the delete command.
 * {@inheritDoc}
 */
@Override
public void runInSWT() {
    LOGGER.debug("Clipboard cut action invoked...");
    // invoke copy action
    CopyAction copy = new CopyAction(getEditor());
    copy.runInSWT();
    NodeContainerEditPart[] nodeParts = copy.getNodeParts();
    AnnotationEditPart[] annotationParts = copy.getAnnotationParts();
    Collection<EditPart> coll = new ArrayList<EditPart>();
    coll.addAll(Arrays.asList(nodeParts));
    coll.addAll(Arrays.asList(annotationParts));
    DeleteCommand delete = new DeleteCommand(coll, getEditor().getWorkflowManager().get());
    // enable undo
    getCommandStack().execute(delete);
    getEditor().updateActions();
    // Give focus to the editor again. Otherwise the actions (selection)
    // is not updated correctly.
    getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
Also used : DeleteCommand(org.knime.workbench.editor2.commands.DeleteCommand) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList)

Aggregations

EditPart (org.eclipse.gef.EditPart)132 List (java.util.List)50 ArrayList (java.util.ArrayList)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)26 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 Point (org.eclipse.draw2d.geometry.Point)17 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 Command (org.eclipse.gef.commands.Command)16 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)15 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 RootEditPart (org.eclipse.gef.RootEditPart)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)10 INode (org.talend.core.model.process.INode)10