Search in sources :

Example 51 with IWorkbench

use of org.eclipse.ui.IWorkbench in project knime-core by knime.

the class UpdateMetaNodeLinkCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    UpdateMetaNodeTemplateRunnable updateRunner = null;
    try {
        IWorkbench wb = PlatformUI.getWorkbench();
        IProgressService ps = wb.getProgressService();
        WorkflowManager hostWFM = getHostWFM();
        updateRunner = new UpdateMetaNodeTemplateRunnable(hostWFM, m_ids);
        ps.busyCursorWhile(updateRunner);
        m_newIDs = updateRunner.getNewIDs();
        m_undoPersistors = updateRunner.getUndoPersistors();
        assert m_newIDs.size() == m_undoPersistors.size();
    } catch (Exception ex) {
        // if fails notify the user
        LOGGER.debug("Node cannot be created.", ex);
        MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Node cannot be created.", "The selected node could not be created " + "due to the following reason:\n" + ex.getMessage());
        return;
    } finally {
        if (updateRunner != null) {
            updateRunner.discard();
        }
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) UpdateMetaNodeTemplateRunnable(org.knime.workbench.editor2.UpdateMetaNodeTemplateRunnable) IProgressService(org.eclipse.ui.progress.IProgressService) WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

Example 52 with IWorkbench

use of org.eclipse.ui.IWorkbench in project knime-core by knime.

the class CreateMetaNodeTemplateCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    // Add node to workflow and get the container
    LoadMetaNodeTemplateRunnable loadRunnable = null;
    try {
        IWorkbench wb = PlatformUI.getWorkbench();
        IProgressService ps = wb.getProgressService();
        // this one sets the workflow manager in the editor
        loadRunnable = new LoadMetaNodeTemplateRunnable(getHostWFM(), m_templateKNIMEFolder);
        ps.run(false, true, loadRunnable);
        MetaNodeLinkUpdateResult result = loadRunnable.getLoadResult();
        m_container = (NodeContainer) result.getLoadedInstance();
        if (m_container == null) {
            throw new RuntimeException("No template returned by load routine, see log for details");
        }
        // create extra info and set it
        NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(m_location.x, m_location.y, -1, -1).setHasAbsoluteCoordinates(false).setSnapToGrid(m_snapToGrid).setIsDropLocation(true).build();
        m_container.setUIInformation(info);
    } catch (Throwable t) {
        Throwable cause = t;
        while ((cause.getCause() != null) && (cause.getCause() != cause)) {
            cause = cause.getCause();
        }
        String error = "The selected node could not be created";
        if (cause instanceof FileNotFoundException) {
            error += " because a file could not be found: " + cause.getMessage();
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Node cannot be created.", error);
        } else if (cause instanceof IOException) {
            error += " because of an I/O error: " + cause.getMessage();
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Node cannot be created.", error);
        } else if (cause instanceof InvalidSettingsException) {
            error += " because the metanode contains invalid settings: " + cause.getMessage();
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Node cannot be created.", error);
        } else if (cause instanceof UnsupportedWorkflowVersionException) {
            error += " because the metanode version is incompatible: " + cause.getMessage();
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Node cannot be created.", error);
        } else if ((cause instanceof CanceledExecutionException) || (cause instanceof InterruptedException)) {
            LOGGER.info("Metanode loading was canceled by the user", cause);
        } else {
            LOGGER.error(String.format("Metanode loading failed with %s: %s", cause.getClass().getSimpleName(), cause.getMessage()), cause);
            error += ": " + cause.getMessage();
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Node cannot be created.", error);
        }
    }
}
Also used : UnsupportedWorkflowVersionException(org.knime.core.node.workflow.UnsupportedWorkflowVersionException) LoadMetaNodeTemplateRunnable(org.knime.workbench.editor2.LoadMetaNodeTemplateRunnable) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) IWorkbench(org.eclipse.ui.IWorkbench) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IProgressService(org.eclipse.ui.progress.IProgressService) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) MetaNodeLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.MetaNodeLinkUpdateResult)

Example 53 with IWorkbench

use of org.eclipse.ui.IWorkbench in project knime-core by knime.

the class CreateWorkflowGroupAction method run.

/**
 * {@inheritDoc}
 */
@Override
public void run() {
    NewWorkflowGroupProjectWizard wizard = new NewWorkflowGroupProjectWizard();
    IWorkbench workbench = PlatformUI.getWorkbench();
    ISelection selection = workbench.getActiveWorkbenchWindow().getSelectionService().getSelection();
    if (selection instanceof IStructuredSelection) {
        wizard.init(workbench, (IStructuredSelection) selection);
    }
    WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
    dialog.open();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) ISelection(org.eclipse.jface.viewers.ISelection) NewWorkflowGroupProjectWizard(org.knime.workbench.ui.wizards.workflowgroup.NewWorkflowGroupProjectWizard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 54 with IWorkbench

use of org.eclipse.ui.IWorkbench in project yamcs-studio by yamcs.

the class Application method stop.

@Override
public void stop() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        return;
    }
    Display display = workbench.getDisplay();
    display.syncExec(() -> {
        if (!display.isDisposed()) {
            workbench.close();
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Display(org.eclipse.swt.widgets.Display)

Example 55 with IWorkbench

use of org.eclipse.ui.IWorkbench in project yamcs-studio by yamcs.

the class YamcsStudioWorkbenchAdvisor method postStartup.

@Override
public void postStartup() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    PreferenceManager pm = workbench.getPreferenceManager();
    pm.remove("org.eclipse.help.ui.browsersPreferencePage");
    pm.remove("org.eclipse.team.ui.TeamPreferences");
    YamcsUIPlugin.getDefault().postWorkbenchStartup(workbench);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) PreferenceManager(org.eclipse.jface.preference.PreferenceManager)

Aggregations

IWorkbench (org.eclipse.ui.IWorkbench)105 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)32 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)31 IEditorPart (org.eclipse.ui.IEditorPart)21 PartInitException (org.eclipse.ui.PartInitException)20 WizardDialog (org.eclipse.jface.wizard.WizardDialog)15 CoreException (org.eclipse.core.runtime.CoreException)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 Shell (org.eclipse.swt.widgets.Shell)11 IResource (org.eclipse.core.resources.IResource)9 ISelection (org.eclipse.jface.viewers.ISelection)9 Display (org.eclipse.swt.widgets.Display)8 ArrayList (java.util.ArrayList)7 IFile (org.eclipse.core.resources.IFile)7 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)7 IProject (org.eclipse.core.resources.IProject)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 TableEditorInput (com.cubrid.common.ui.cubrid.table.editor.TableEditorInput)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5