Search in sources :

Example 6 with AbstractContentProvider

use of org.knime.workbench.explorer.view.AbstractContentProvider in project knime-core by knime.

the class IntroPage method mountServer.

private void mountServer() {
    String s = ExplorerActivator.getDefault().getPreferenceStore().getString(PreferenceConstants.P_EXPLORER_MOUNT_POINT_XML);
    List<MountSettings> mountSettingsList = MountSettings.parseSettings(s, true);
    Set<String> idSet = new LinkedHashSet<>();
    for (MountSettings settings : mountSettingsList) {
        idSet.add(settings.getFactoryID());
    }
    List<String> contentProviderIDs = new ArrayList<String>(idSet);
    List<String> mountIDs = new ArrayList<String>(mountSettingsList.size());
    for (MountSettings settings : mountSettingsList) {
        mountIDs.add(settings.getMountID());
    }
    EditMountPointDialog dlg = new EditMountPointDialog(Display.getDefault().getActiveShell(), ExplorerMountTable.getAddableContentProviders(contentProviderIDs), mountIDs);
    if (dlg.open() != Window.OK) {
        return;
    }
    AbstractContentProvider newCP = dlg.getContentProvider();
    if (newCP != null) {
        MountSettings mountSettings = new MountSettings(newCP);
        if (mountSettings.getDefaultMountID() == null) {
            mountSettings.setDefaultMountID(dlg.getDefaultMountID());
        }
        mountSettingsList.add(mountSettings);
        // store new mount point settings
        String settingsString = MountSettings.getSettingsString(mountSettingsList);
        ExplorerActivator.getDefault().getPreferenceStore().setValue(PreferenceConstants.P_EXPLORER_MOUNT_POINT_XML, settingsString);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EditMountPointDialog(org.knime.workbench.explorer.view.preferences.EditMountPointDialog) ArrayList(java.util.ArrayList) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider) MountSettings(org.knime.workbench.explorer.view.preferences.MountSettings)

Example 7 with AbstractContentProvider

use of org.knime.workbench.explorer.view.AbstractContentProvider in project knime-core by knime.

the class SaveAsMetaNodeTemplateAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of
 *         <code>WorkflowManager</code> and there is no link associated
 *         with it, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    if (getManager().isWriteProtected()) {
        return false;
    }
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    Object model = nodes[0].getModel();
    if (model instanceof WorkflowManagerUI) {
        WorkflowManagerUI wm = (WorkflowManagerUI) model;
        switch(Wrapper.unwrapWFM(wm).getTemplateInformation().getRole()) {
            case None:
                break;
            default:
                return false;
        }
        for (AbstractContentProvider p : ExplorerMountTable.getMountedContent().values()) {
            if (p.canHostMetaNodeTemplates()) {
                return true;
            }
        }
    }
    return false;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider) ContentObject(org.knime.workbench.explorer.view.ContentObject)

Example 8 with AbstractContentProvider

use of org.knime.workbench.explorer.view.AbstractContentProvider in project knime-core by knime.

the class SaveAsSubNodeTemplateAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of
 *         <code>SubNodeContainer</code> and there is no link associated
 *         with it, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    if (getManager().isWriteProtected()) {
        return false;
    }
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    Object model = nodes[0].getModel();
    if (Wrapper.wraps(model, SubNodeContainer.class)) {
        SubNodeContainer snc = unwrap((UI) model, SubNodeContainer.class);
        switch(snc.getTemplateInformation().getRole()) {
            case None:
                break;
            default:
                return false;
        }
        for (AbstractContentProvider p : ExplorerMountTable.getMountedContent().values()) {
            if (p.canHostMetaNodeTemplates()) {
                return true;
            }
        }
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider) ContentObject(org.knime.workbench.explorer.view.ContentObject)

Example 9 with AbstractContentProvider

use of org.knime.workbench.explorer.view.AbstractContentProvider 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

AbstractContentProvider (org.knime.workbench.explorer.view.AbstractContentProvider)9 AbstractExplorerFileStore (org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore)6 ContentObject (org.knime.workbench.explorer.view.ContentObject)5 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)4 ArrayList (java.util.ArrayList)3 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)3 SpaceResourceSelectionDialog (org.knime.workbench.explorer.dialogs.SpaceResourceSelectionDialog)3 IOException (java.io.IOException)2 URI (java.net.URI)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 Shell (org.eclipse.swt.widgets.Shell)2 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)2 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)2 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)2 Validator (org.knime.workbench.explorer.dialogs.Validator)2 AbstractExplorerFileInfo (org.knime.workbench.explorer.filesystem.AbstractExplorerFileInfo)2 LocalExplorerFileStore (org.knime.workbench.explorer.filesystem.LocalExplorerFileStore)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1