use of org.csstudio.opibuilder.runmode.IOPIRuntime in project yamcs-studio by yamcs.
the class EditOPIAction method run.
@Override
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
IOPIRuntime opiRuntime = OPIShell.getOPIShellForShell(shell);
if (opiRuntime == null) {
// if the selected object isn't an OPIShell so grab the
// OPIView or OPIRunner currently selected
IWorkbenchPart part = page.getActivePart();
if (part instanceof IOPIRuntime) {
opiRuntime = (IOPIRuntime) part;
}
}
IWorkbenchWindow targetWindow = null;
for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
if (window.getActivePage().getPerspective().getId().equals(OPIEditorPerspective.ID)) {
targetWindow = window;
}
}
if (targetWindow == null) {
try {
targetWindow = PlatformUI.getWorkbench().openWorkbenchWindow(OPIEditorPerspective.ID, null);
} catch (WorkbenchException e) {
throw new RuntimeException(e);
}
}
targetWindow.getShell().setActive();
if (opiRuntime != null) {
IPath path = opiRuntime.getDisplayModel().getOpiFilePath();
page = targetWindow.getActivePage();
if (page != null) {
try {
IEditorInput editorInput = ResourceUtil.editorInputFromPath(path);
page.openEditor(editorInput, OPI_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
} catch (PartInitException e) {
ErrorHandlerUtil.handleError("Failed to open current OPI in editor", e);
}
}
}
}
use of org.csstudio.opibuilder.runmode.IOPIRuntime in project yamcs-studio by yamcs.
the class OpenDisplayAction method openOPI.
private void openOPI(final IPath absolutePath, final boolean ctrlPressed, final boolean shiftPressed) {
DisplayMode mode = getDisplayMode();
if (ctrlPressed && !shiftPressed)
mode = DisplayMode.NEW_TAB;
else if (!ctrlPressed && shiftPressed)
mode = DisplayMode.NEW_WINDOW;
else if (ctrlPressed && shiftPressed)
mode = DisplayMode.NEW_SHELL;
final IOPIRuntime runtime = getWidgetModel().getRootDisplayModel().getOpiRuntime();
RunModeService.openDisplay(absolutePath, Optional.ofNullable(getMacrosInput()), mode, Optional.ofNullable(runtime));
}
Aggregations