Search in sources :

Example 1 with WorkflowEditorAdapter

use of org.knime.workbench.ui.navigator.WorkflowEditorAdapter in project knime-core by knime.

the class DeleteAction method closeOpenWorkflows.

private void closeOpenWorkflows(final List<IContainer> allWorkflows) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    for (IContainer wf : allWorkflows) {
        NodeContainer wfm = ProjectWorkflowMap.getWorkflow(wf.getLocationURI());
        if (wfm != null) {
            for (IEditorReference editRef : page.getEditorReferences()) {
                IEditorPart editor = editRef.getEditor(false);
                if (editor == null) {
                    // got closed in the mean time
                    continue;
                }
                WorkflowEditorAdapter wea = (WorkflowEditorAdapter) editor.getAdapter(WorkflowEditorAdapter.class);
                NodeContainer editWFM = null;
                if (wea != null) {
                    editWFM = wea.getWorkflowManager();
                }
                if (wfm == editWFM) {
                    page.closeEditor(editor, false);
                }
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) WorkflowEditorAdapter(org.knime.workbench.ui.navigator.WorkflowEditorAdapter) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) NodeContainer(org.knime.core.node.workflow.NodeContainer) IEditorPart(org.eclipse.ui.IEditorPart) IContainer(org.eclipse.core.resources.IContainer)

Aggregations

IContainer (org.eclipse.core.resources.IContainer)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 NodeContainer (org.knime.core.node.workflow.NodeContainer)1 WorkflowEditorAdapter (org.knime.workbench.ui.navigator.WorkflowEditorAdapter)1