use of org.csstudio.opibuilder.runmode.RunnerInput in project yamcs-studio by yamcs.
the class OPIEditor method init.
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
// in the mode of "no edit", open OPI in runtime and close this editor immediately.
if (PreferencesHelper.isNoEdit()) {
setSite(site);
setInput(input);
final IPath path = ResourceUtil.getPathInEditor(input);
RunModeService.openDisplayInView(site.getPage(), new RunnerInput(path, null), DisplayMode.NEW_TAB);
Display.getDefault().asyncExec(() -> getSite().getPage().closeEditor(OPIEditor.this, false));
} else {
super.init(site, input);
}
}
use of org.csstudio.opibuilder.runmode.RunnerInput in project yamcs-studio by yamcs.
the class RunOPIAction method run.
@Override
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart activeEditor = page.getActiveEditor();
if (activeEditor != null) {
// TODO: Should perform the 'save' in background, then return to UI thread when done..
if (PreferencesHelper.isAutoSaveBeforeRunning() && activeEditor.isDirty()) {
activeEditor.doSave(null);
}
}
if (runtime_page == null) {
// (Re-)create runtime window
runtime_page = createRuntimePage();
} else {
runtime_page.getWorkbenchWindow().getShell().setActive();
}
if (activeEditor instanceof OPIEditor) {
// DisplayModel displayModel = ((OPIEditor) activeEditor).getDisplayModel();
// Rectangle bounds = new Rectangle(displayModel.getLocation(), displayModel.getSize());
IEditorInput input = activeEditor.getEditorInput();
IPath path = ResourceUtil.getPathInEditor(input);
RunnerInput new_input = new RunnerInput(path, null);
// because RunModeService would only pop old content back to the front.
for (IViewReference view_ref : runtime_page.getViewReferences()) {
if (view_ref.getId().startsWith(OPIView.ID)) {
IViewPart view = view_ref.getView(true);
if (view instanceof OPIView) {
OPIView opi_view = (OPIView) view;
if (new_input.equals(opi_view.getOPIInput())) {
try {
opi_view.setOPIInput(new_input);
} catch (PartInitException ex) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, "Failed to update existing runtime for " + new_input.getName(), ex);
}
break;
}
}
}
}
RunModeService.openDisplayInView(runtime_page, new_input, DisplayMode.NEW_TAB);
}
} catch (Exception ex) {
ExceptionDetailsErrorDialog.openError(page.getWorkbenchWindow().getShell(), "Cannot launch display runtime", ex);
}
}
Aggregations