Search in sources :

Example 6 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class ToggleGridAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    final WorkflowEditor editor = getEditor();
    EditorUIInformation settings = editor.getCurrentEditorSettings();
    EditorUIInformation newSet = EditorUIInformation.builder().setSnapToGrid(!settings.getSnapToGrid()).build();
    editor.applyEditorSettings(newSet);
    editor.markDirty();
}
Also used : WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) EditorUIInformation(org.knime.core.node.workflow.EditorUIInformation)

Example 7 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class ShowNodeIdsEditorAction method createAction.

/**
 * {@inheritDoc}
 */
@Override
protected AbstractNodeAction createAction(final WorkflowEditor editor) {
    WorkflowRootEditPart part = (WorkflowRootEditPart) ((editor).getViewer().getRootEditPart().getChildren().get(0));
    ShowNodeIdsAction showNodeIdsAction = new ShowNodeIdsAction(editor);
    showNodeIdsAction.setChecked(part.showNodeId());
    return showNodeIdsAction;
}
Also used : ShowNodeIdsAction(org.knime.workbench.editor2.actions.ShowNodeIdsAction) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart)

Example 8 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class NodeConnectionContainerDeleteAction method createDeleteCommand.

/**
 * Create one command to remove the selected objects.
 *
 * @param objects The objects to be deleted.
 * @return The command to remove the selected objects.
 */
@Override
public Command createDeleteCommand(final List objects) {
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    VerifyingCompoundCommand compoundCmd = new VerifyingCompoundCommand(GEFMessages.DeleteAction_ActionDeleteCommandName);
    // will contain nodes -- just used for marking
    NodeContainerEditPart[] nodeParts = AbstractNodeAction.filterObjects(NodeContainerEditPart.class, objects);
    Optional<WorkflowManager> manager = ((WorkflowEditor) getWorkbenchPart()).getWorkflowManager();
    if (manager.isPresent()) {
        DeleteCommand cmd = new DeleteCommand(objects, manager.get());
        int nodeCount = cmd.getNodeCount();
        int connCount = cmd.getConnectionCount();
        int annoCount = cmd.getAnnotationCount();
        StringBuilder dialogText = new StringBuilder("Do you really want to delete ");
        if (nodeCount > 0) {
            dialogText.append(nodeCount).append(" node");
            dialogText.append(nodeCount > 1 ? "s" : "");
            if (annoCount > 0 && connCount > 0) {
                dialogText.append(" , ");
            } else if (annoCount > 0 || connCount > 0) {
                dialogText.append(" and ");
            }
        }
        if (connCount > 0) {
            dialogText.append(connCount).append(" connection");
            dialogText.append(connCount > 1 ? "s" : "");
            dialogText.append(annoCount > 0 ? " and " : "");
        }
        if (annoCount > 0) {
            dialogText.append(annoCount).append(" annotation");
            dialogText.append(annoCount > 1 ? "s" : "");
        }
        dialogText.append("?");
        compoundCmd.setDialogDisplayText(dialogText.toString());
        // set the parts into the compound command (for unmarking after cancel)
        compoundCmd.setNodeParts(Arrays.asList(nodeParts));
        compoundCmd.add(cmd);
    }
    return compoundCmd;
}
Also used : VerifyingCompoundCommand(org.knime.workbench.editor2.commands.VerifyingCompoundCommand) WorkflowEditor(org.knime.workbench.editor2.WorkflowEditor) DeleteCommand(org.knime.workbench.editor2.commands.DeleteCommand) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart)

Example 9 with WorkflowEditor

use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.

the class HideNodeNamesEditorAction method createAction.

/**
 * {@inheritDoc}
 */
@Override
protected AbstractNodeAction createAction(final WorkflowEditor editor) {
    WorkflowRootEditPart part = (WorkflowRootEditPart) ((editor).getViewer().getRootEditPart().getChildren().get(0));
    HideNodeNamesAction hideNodeIdsAction = new HideNodeNamesAction(editor);
    hideNodeIdsAction.setChecked(part.hideNodeNames());
    return hideNodeIdsAction;
}
Also used : HideNodeNamesAction(org.knime.workbench.editor2.actions.HideNodeNamesAction) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart)

Aggregations

WorkflowEditor (org.knime.workbench.editor2.WorkflowEditor)3 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)3 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)3 Point (org.eclipse.draw2d.geometry.Point)2 AbstractEditPart (org.eclipse.gef.editparts.AbstractEditPart)2 RequestType (org.knime.workbench.editor2.CreateDropRequest.RequestType)2 CreateSpaceAction (org.knime.workbench.editor2.actions.CreateSpaceAction)2 URI (java.net.URI)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 EditPart (org.eclipse.gef.EditPart)1 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 IEditorPart (org.eclipse.ui.IEditorPart)1 PartInitException (org.eclipse.ui.PartInitException)1 EditorUIInformation (org.knime.core.node.workflow.EditorUIInformation)1 WorkflowCipherPrompt (org.knime.core.node.workflow.WorkflowCipherPrompt)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)1