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();
}
}
}
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);
}
}
}
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();
}
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();
}
});
}
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);
}
Aggregations