Search in sources :

Example 1 with RefreshOPIAction

use of org.csstudio.opibuilder.actions.RefreshOPIAction in project yamcs-studio by yamcs.

the class OPIRuntimeDelegate method init.

public void init(final IWorkbenchPartSite site, final IEditorInput input) throws PartInitException {
    this.site = site;
    setEditorInput(input);
    if (viewer != null) {
        viewer.getControl().removePaintListener(errorMessagePaintListener);
    }
    displayModel = new DisplayModel(getOPIFilePath());
    displayModel.setOpiRuntime(opiRuntime);
    displayModelFilled = false;
    InputStream inputStream = null;
    try {
        if (input instanceof IRunnerInput) {
            final IRunnerInput run_input = (IRunnerInput) input;
            if (ResourceUtil.isURL(run_input.getPath().toString())) {
                // TODO Part of
                // https://github.com/ControlSystemStudio/cs-studio/issues/735:
                // One *.opi was loaded in a job, other *.opi
                // in UI thread, merging both..
                final Display display = site.getShell().getDisplay();
                fillDisplayModelInJob(input, display, site);
            } else
                inputStream = run_input.getInputStream();
            displayOpenManager = run_input.getDisplayOpenManager();
        } else {
            inputStream = ResourceUtil.getInputStreamFromEditorInput(input);
        }
        if (inputStream != null) {
            MacrosInput macrosInput = null;
            if (input instanceof IRunnerInput) {
                macrosInput = ((IRunnerInput) input).getMacrosInput();
            }
            XMLUtil.fillDisplayModelFromInputStream(inputStream, displayModel, null, macrosInput);
            displayModelFilled = true;
            if (input instanceof IRunnerInput)
                addRunnerInputMacros(input);
        }
    } catch (Exception e) {
        ErrorHandlerUtil.handleError("Failed to open opi file: " + input, e, true, true);
        throw new PartInitException("Failed to run OPI file: " + input, e);
    }
    // if it was an opened editor
    if (viewer != null && displayModelFilled) {
        viewer.setContents(displayModel);
        updateEditorTitle();
        displayModel.setViewer(viewer);
        displayModel.setOpiRuntime(opiRuntime);
    }
    getActionRegistry().registerAction(new RefreshOPIAction(opiRuntime));
    getActionRegistry().registerAction(new PrintDisplayAction(opiRuntime));
    // hide close button
    hideCloseButton(site);
}
Also used : MacrosInput(org.csstudio.opibuilder.util.MacrosInput) RefreshOPIAction(org.csstudio.opibuilder.actions.RefreshOPIAction) DisplayModel(org.csstudio.opibuilder.model.DisplayModel) InputStream(java.io.InputStream) PartInitException(org.eclipse.ui.PartInitException) PrintDisplayAction(org.csstudio.opibuilder.actions.PrintDisplayAction) PartInitException(org.eclipse.ui.PartInitException) Display(org.eclipse.swt.widgets.Display)

Example 2 with RefreshOPIAction

use of org.csstudio.opibuilder.actions.RefreshOPIAction in project yamcs-studio by yamcs.

the class OPIShell method registerWithView.

/**
 * In order for the right-click menu to work, this shell must be registered with a view. Register the context menu
 * against the view. Make the view the default.
 *
 * @param view
 */
public void registerWithView(IViewPart view) {
    this.view = view;
    actionRegistry.registerAction(new RefreshOPIAction(this));
    actionRegistry.registerAction(new PrintDisplayAction(this));
    OPIRunnerContextMenuProvider contextMenuProvider = new OPIRunnerContextMenuProvider(viewer, this);
    getSite().registerContextMenu(contextMenuProvider, viewer);
    viewer.setContextMenu(contextMenuProvider);
}
Also used : RefreshOPIAction(org.csstudio.opibuilder.actions.RefreshOPIAction) PrintDisplayAction(org.csstudio.opibuilder.actions.PrintDisplayAction)

Aggregations

PrintDisplayAction (org.csstudio.opibuilder.actions.PrintDisplayAction)2 RefreshOPIAction (org.csstudio.opibuilder.actions.RefreshOPIAction)2 InputStream (java.io.InputStream)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1 MacrosInput (org.csstudio.opibuilder.util.MacrosInput)1 Display (org.eclipse.swt.widgets.Display)1 PartInitException (org.eclipse.ui.PartInitException)1