Search in sources :

Example 1 with IOPIRuntime

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);
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) OPIShell(org.csstudio.opibuilder.runmode.OPIShell) IPath(org.eclipse.core.runtime.IPath) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IOPIRuntime(org.csstudio.opibuilder.runmode.IOPIRuntime) PartInitException(org.eclipse.ui.PartInitException) WorkbenchException(org.eclipse.ui.WorkbenchException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with IOPIRuntime

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));
}
Also used : DisplayMode(org.csstudio.opibuilder.runmode.RunModeService.DisplayMode) IOPIRuntime(org.csstudio.opibuilder.runmode.IOPIRuntime)

Aggregations

IOPIRuntime (org.csstudio.opibuilder.runmode.IOPIRuntime)2 OPIShell (org.csstudio.opibuilder.runmode.OPIShell)1 DisplayMode (org.csstudio.opibuilder.runmode.RunModeService.DisplayMode)1 IPath (org.eclipse.core.runtime.IPath)1 Shell (org.eclipse.swt.widgets.Shell)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1 WorkbenchException (org.eclipse.ui.WorkbenchException)1