use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.
the class NodeContainerEditPart method openSubWorkflowEditor.
public void openSubWorkflowEditor() {
WorkflowCipherPrompt prompt = new GUIWorkflowCipherPrompt();
Object obj = getModel();
WorkflowManagerUI wm;
if (obj instanceof WorkflowManagerUI) {
wm = (WorkflowManagerUI) getModel();
} else if (obj instanceof SubNodeContainerUI) {
wm = ((SubNodeContainerUI) obj).getWorkflowManager();
} else {
return;
}
// if workflow manager is encrypted, try unlocking it
if (wm.isEncrypted()) {
if (!Wrapper.unwrapWFM(wm).unlock(prompt)) {
return;
}
}
// open new editor for subworkflow
LOGGER.debug("opening new editor for sub-workflow");
try {
final WorkflowEditor parent = (WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
WorkflowManagerInput input = new WorkflowManagerInput(wm, parent);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, "org.knime.workbench.editor.WorkflowEditor");
} catch (PartInitException e) {
LOGGER.error("Error while opening new editor", e);
}
return;
}
use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.
the class LoadWorkflowRunnable method postLoadCheckForMetaNodeUpdates.
static void postLoadCheckForMetaNodeUpdates(final WorkflowEditor editor, final WorkflowManager parent, final List<NodeID> links) {
StringBuilder m = new StringBuilder("The workflow contains ");
if (links.size() == 1) {
m.append("one metanode link (\"");
m.append(parent.findNodeContainer(links.get(0)).getNameWithID());
m.append("\").");
} else {
m.append(links.size()).append(" metanode links.");
}
m.append("\n\n").append("Do you want to check for updates now?");
final String message = m.toString();
final AtomicBoolean result = new AtomicBoolean(false);
final IPreferenceStore corePrefStore = KNIMEUIPlugin.getDefault().getPreferenceStore();
final String pKey = PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD;
String pref = corePrefStore.getString(pKey);
boolean showInfoMsg = true;
if (MessageDialogWithToggle.ALWAYS.equals(pref)) {
result.set(true);
showInfoMsg = false;
} else if (MessageDialogWithToggle.NEVER.equals(pref)) {
result.set(false);
} else {
final Display display = Display.getDefault();
display.syncExec(new Runnable() {
@Override
public void run() {
Shell activeShell = display.getActiveShell();
MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoCancelQuestion(activeShell, "Metanode Link Update", message, "Remember my decision", false, corePrefStore, pKey);
switch(dlg.getReturnCode()) {
case IDialogConstants.YES_ID:
result.set(true);
break;
default:
result.set(false);
}
}
});
}
if (result.get()) {
new CheckUpdateMetaNodeLinkAllAction(editor, showInfoMsg).run();
}
}
use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.
the class WorkflowEditor method updateTempRemoteWorkflowMessage.
/**
* Places the message at the top of the editor - above all other contents.
*/
private void updateTempRemoteWorkflowMessage() {
WorkflowFigure workflowFigure = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getFigure();
if (isTempRemoteWorkflowEditor()) {
URI origRemoteLocation = m_origRemoteLocation;
WorkflowEditor parentEditor = m_parentEditor;
while (origRemoteLocation == null && parentEditor != null) {
origRemoteLocation = parentEditor.m_origRemoteLocation;
parentEditor = parentEditor.m_parentEditor;
}
workflowFigure.setMessage(" This is a temporary copy of \"" + URIUtil.toDecodedString(origRemoteLocation) + "\".\n Use \"Save\" to upload it back to its original location on the server or \"Save As...\" to " + "store it in a different location.");
} else if (!getWorkflowManager().isPresent()) {
workflowFigure.setMessage("This is a remotely opened job workflow. It can neither be stored locally nor edited." + " It also just represents a static snapshot of the job workflow and won't get" + " updated automatically (use context menu to refresh).");
} else {
workflowFigure.setMessage(null);
}
List<IEditorPart> subEditors = getSubEditors();
for (IEditorPart ep : subEditors) {
if (ep instanceof WorkflowEditor) {
((WorkflowEditor) ep).updateTempRemoteWorkflowMessage();
}
}
}
use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.
the class NewWorkflowContainerEditPolicy method handleNodeDrop.
/**
* @param manager the workflow manager
* @param factory the ndoe factory
* @param request the drop request
*/
private Command handleNodeDrop(final WorkflowManager manager, final NodeFactory<? extends NodeModel> factory, final CreateDropRequest request) {
RequestType requestType = request.getRequestType();
Point location = request.getLocation();
boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
if (requestType.equals(RequestType.CREATE)) {
// create a new node
return new CreateNodeCommand(manager, factory, location, snapToGrid);
} else {
AbstractEditPart editPart = request.getEditPart();
if (requestType.equals(RequestType.INSERT)) {
// insert new node into connection
InsertNodeCommand insertCommand = new InsertNodeCommand(manager, factory, location, snapToGrid, (ConnectionContainerEditPart) editPart);
if (request.createSpace()) {
CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
} else {
return insertCommand;
}
} else if (requestType.equals(RequestType.REPLACE)) {
// replace node with a node
return new ReplaceNodeCommand(manager, factory, location, snapToGrid, (NodeContainerEditPart) editPart);
} else {
return null;
}
}
}
use of org.knime.workbench.editor2.WorkflowEditor in project knime-core by knime.
the class NewWorkflowContainerEditPolicy method handleMetaNodeTemplateDrop.
/**
* @param manager the workflow manager
* @param request the drop request
* @param filestore the location of the metanode template
*/
private Command handleMetaNodeTemplateDrop(final WorkflowManager manager, final CreateDropRequest request, final AbstractExplorerFileStore filestore) {
RequestType requestType = request.getRequestType();
Point location = request.getLocation();
boolean snapToGrid = WorkflowEditor.getActiveEditorSnapToGrid();
if (requestType.equals(RequestType.CREATE)) {
// create metanode from template
return new CreateMetaNodeTemplateCommand(manager, filestore, location, snapToGrid);
} else {
AbstractEditPart editPart = request.getEditPart();
if (requestType.equals(RequestType.INSERT)) {
// insert metanode from template into connection
InsertMetaNodeTempalteCommand insertCommand = new InsertMetaNodeTempalteCommand(manager, filestore, location, snapToGrid, (ConnectionContainerEditPart) editPart);
if (request.createSpace()) {
CreateSpaceAction csa = new CreateSpaceAction((WorkflowEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(), request.getDirection(), request.getDistance());
return insertCommand.chain(csa.createCompoundCommand(csa.selectedParts()));
} else {
return insertCommand;
}
} else if (requestType.equals(RequestType.REPLACE)) {
// replace node with metanode from template
return new ReplaceMetaNodeTemplateCommand(manager, filestore, location, snapToGrid, (NodeContainerEditPart) editPart);
} else {
return null;
}
}
}
Aggregations