Search in sources :

Example 16 with AbstractExplorerFileStore

use of org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore in project knime-core by knime.

the class MetaNodeTemplateDropTargetListener method handleDrop.

/**
 * {@inheritDoc}
 */
@Override
protected void handleDrop() {
    ContentObject obj = getDragResources(getCurrentEvent());
    AbstractExplorerFileStore store = obj.getObject();
    if (AbstractExplorerFileStore.isWorkflowTemplate(store)) {
        getFactory().setSourceFileStore(store);
        super.handleDrop();
    }
}
Also used : AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) ContentObject(org.knime.workbench.explorer.view.ContentObject)

Example 17 with AbstractExplorerFileStore

use of org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore in project knime-core by knime.

the class RevealMetaNodeTemplateAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodes) {
    List<NodeID> candidateList = new ArrayList<NodeID>();
    List<AbstractExplorerFileStore> templates = new ArrayList<AbstractExplorerFileStore>();
    for (NodeContainerEditPart p : nodes) {
        Object model = p.getModel();
        if (model instanceof WorkflowManagerUI) {
            NodeContext.pushContext(Wrapper.unwrapNC(p.getNodeContainer()));
            try {
                WorkflowManager wm = Wrapper.unwrapWFM((UI) model);
                MetaNodeTemplateInformation i = wm.getTemplateInformation();
                if (Role.Link.equals(i.getRole())) {
                    candidateList.add(wm.getID());
                    AbstractExplorerFileStore template = ExplorerFileSystem.INSTANCE.getStore(i.getSourceURI());
                    if (template != null) {
                        templates.add(template);
                    }
                }
            } finally {
                NodeContext.removeLastContext();
            }
        }
    }
    List<Object> treeObjects = ContentDelegator.getTreeObjectList(templates);
    if (treeObjects != null && treeObjects.size() > 0) {
        IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
        for (IViewReference view : views) {
            if (ExplorerView.ID.equals(view.getId())) {
                ExplorerView explorerView = (ExplorerView) view.getView(true);
                explorerView.getViewer().setSelection(new StructuredSelection(treeObjects), true);
            }
        }
    }
}
Also used : ExplorerView(org.knime.workbench.explorer.view.ExplorerView) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) IViewReference(org.eclipse.ui.IViewReference) NodeID(org.knime.core.node.workflow.NodeID) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 18 with AbstractExplorerFileStore

use of org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore in project knime-core by knime.

the class SaveAsMetaNodeTemplateAction method getDefaultSaveLocation.

private ContentObject getDefaultSaveLocation(final WorkflowManager arg) {
    final NodeID id = arg.getID();
    URI uri = DisconnectMetaNodeLinkCommand.RECENTLY_USED_URIS.get(id);
    if (uri == null || !ExplorerFileSystem.SCHEME.equals(uri.getScheme())) {
        return null;
    }
    final AbstractExplorerFileStore oldTemplateFileStore = ExplorerFileSystem.INSTANCE.getStore(uri);
    final AbstractExplorerFileStore parent = oldTemplateFileStore == null ? null : oldTemplateFileStore.getParent();
    if (parent != null) {
        return ContentObject.forFile(parent);
    }
    return null;
}
Also used : AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) NodeID(org.knime.core.node.workflow.NodeID) URI(java.net.URI)

Example 19 with AbstractExplorerFileStore

use of org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore in project knime-core by knime.

the class NewProjectWizardIntroAction method run.

/**
 * {@inheritDoc}
 */
@Override
public void run(final IIntroSite site, final Properties params) {
    try {
        // close the intro page
        IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
        IIntroPart introPart = introManager.getIntro();
        if (introPart != null) {
            introManager.closeIntro(introPart);
        }
        if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length == 0) {
            PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {

                @Override
                public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    try {
                        // call static method on NewProjectWizard
                        AbstractExplorerFileStore workspaceRoot = null;
                        for (AbstractContentProvider cp : ExplorerMountTable.getMountedContent().values()) {
                            if (cp.getFileStore("/") instanceof LocalWorkspaceFileStore) {
                                workspaceRoot = cp.getFileStore("/");
                                break;
                            }
                        }
                        if (workspaceRoot == null) {
                            throw new IllegalArgumentException("Could not find workspace");
                        }
                        AbstractExplorerFileStore newWorkflow = workspaceRoot.getChild("KNIME_project");
                        NewWorkflowWizard.createNewWorkflow(newWorkflow, monitor);
                    } catch (CoreException ce) {
                        throw new InvocationTargetException(ce);
                    }
                }
            });
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : LocalWorkspaceFileStore(org.knime.workbench.explorer.localworkspace.LocalWorkspaceFileStore) IIntroManager(org.eclipse.ui.intro.IIntroManager) IIntroPart(org.eclipse.ui.intro.IIntroPart) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) AbstractExplorerFileStore(org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider)

Aggregations

AbstractExplorerFileStore (org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore)19 URI (java.net.URI)6 AbstractContentProvider (org.knime.workbench.explorer.view.AbstractContentProvider)6 CoreException (org.eclipse.core.runtime.CoreException)5 LocalExplorerFileStore (org.knime.workbench.explorer.filesystem.LocalExplorerFileStore)5 ArrayList (java.util.ArrayList)4 Shell (org.eclipse.swt.widgets.Shell)4 NodeID (org.knime.core.node.workflow.NodeID)4 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)4 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)4 ContentObject (org.knime.workbench.explorer.view.ContentObject)4 File (java.io.File)3 IOException (java.io.IOException)3 ReferencedFile (org.knime.core.internal.ReferencedFile)3 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)3 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)3 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)3 SpaceResourceSelectionDialog (org.knime.workbench.explorer.dialogs.SpaceResourceSelectionDialog)3 AbstractExplorerFileInfo (org.knime.workbench.explorer.filesystem.AbstractExplorerFileInfo)3 RemoteExplorerFileStore (org.knime.workbench.explorer.filesystem.RemoteExplorerFileStore)3