Search in sources :

Example 1 with PrintDisplayAction

use of org.csstudio.opibuilder.actions.PrintDisplayAction 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 PrintDisplayAction

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

the class OPIEditor method createActions.

@SuppressWarnings("unchecked")
@Override
protected void createActions() {
    super.createActions();
    ((IContextService) getEditorSite().getService(IContextService.class)).activateContext(// $NON-NLS-1$
    "org.csstudio.opibuilder.opiEditor");
    ActionRegistry registry = getActionRegistry();
    IAction action;
    action = new CopyTemplateAction(this);
    registry.registerAction(action);
    action = new MatchWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new MatchHeightAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new DirectEditAction((IWorkbenchPart) this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    String id = ActionFactory.DELETE.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.delete");
    action = new PasteWidgetsAction(this);
    registry.registerAction(action);
    action = new CopyWidgetsAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new CutWidgetsAction(this, (DeleteAction) registry.getAction(ActionFactory.DELETE.getId()));
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new PrintDisplayAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    id = ActionFactory.SELECT_ALL.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.selectAll");
    id = ActionFactory.UNDO.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.undo");
    id = ActionFactory.REDO.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.redo");
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    for (DistributeType dt : DistributeType.values()) {
        action = new DistributeWidgetsAction((IWorkbenchPart) this, dt);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    for (OrderType orderType : OrderType.values()) {
        action = new ChangeOrderAction((IWorkbenchPart) this, orderType);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    for (OrientationType orientationType : OrientationType.values()) {
        action = new ChangeOrientationAction(this, orientationType);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    action = new RunOPIAction();
    registry.registerAction(action);
    PastePropertiesAction pastePropAction = new PastePropertiesAction(this);
    registry.registerAction(pastePropAction);
    getSelectionActions().add(pastePropAction.getId());
    action = new CopyPropertiesAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new ReplaceWidgetsAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
}
Also used : CutWidgetsAction(org.csstudio.opibuilder.actions.CutWidgetsAction) CopyPropertiesAction(org.csstudio.opibuilder.actions.CopyPropertiesAction) MatchHeightAction(org.eclipse.gef.ui.actions.MatchHeightAction) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) ChangeOrientationAction(org.csstudio.opibuilder.actions.ChangeOrientationAction) OrderType(org.csstudio.opibuilder.actions.ChangeOrderAction.OrderType) OrientationType(org.csstudio.opibuilder.actions.ChangeOrientationAction.OrientationType) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) IContextService(org.eclipse.ui.contexts.IContextService) ChangeOrderAction(org.csstudio.opibuilder.actions.ChangeOrderAction) RunOPIAction(org.csstudio.opibuilder.actions.RunOPIAction) IAction(org.eclipse.jface.action.IAction) RunOPIAction(org.csstudio.opibuilder.actions.RunOPIAction) PasteWidgetsAction(org.csstudio.opibuilder.actions.PasteWidgetsAction) CopyTemplateAction(org.eclipse.gef.ui.actions.CopyTemplateAction) MatchWidthAction(org.eclipse.gef.ui.actions.MatchWidthAction) CopyWidgetsAction(org.csstudio.opibuilder.actions.CopyWidgetsAction) AlignmentAction(org.eclipse.gef.ui.actions.AlignmentAction) DistributeType(org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType) ReplaceWidgetsAction(org.csstudio.opibuilder.actions.ReplaceWidgetsAction) DistributeWidgetsAction(org.csstudio.opibuilder.actions.DistributeWidgetsAction) PastePropertiesAction(org.csstudio.opibuilder.actions.PastePropertiesAction) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction) PrintDisplayAction(org.csstudio.opibuilder.actions.PrintDisplayAction)

Example 3 with PrintDisplayAction

use of org.csstudio.opibuilder.actions.PrintDisplayAction 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)3 RefreshOPIAction (org.csstudio.opibuilder.actions.RefreshOPIAction)2 InputStream (java.io.InputStream)1 ChangeOrderAction (org.csstudio.opibuilder.actions.ChangeOrderAction)1 OrderType (org.csstudio.opibuilder.actions.ChangeOrderAction.OrderType)1 ChangeOrientationAction (org.csstudio.opibuilder.actions.ChangeOrientationAction)1 OrientationType (org.csstudio.opibuilder.actions.ChangeOrientationAction.OrientationType)1 CopyPropertiesAction (org.csstudio.opibuilder.actions.CopyPropertiesAction)1 CopyWidgetsAction (org.csstudio.opibuilder.actions.CopyWidgetsAction)1 CutWidgetsAction (org.csstudio.opibuilder.actions.CutWidgetsAction)1 DistributeWidgetsAction (org.csstudio.opibuilder.actions.DistributeWidgetsAction)1 DistributeType (org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType)1 PastePropertiesAction (org.csstudio.opibuilder.actions.PastePropertiesAction)1 PasteWidgetsAction (org.csstudio.opibuilder.actions.PasteWidgetsAction)1 ReplaceWidgetsAction (org.csstudio.opibuilder.actions.ReplaceWidgetsAction)1 RunOPIAction (org.csstudio.opibuilder.actions.RunOPIAction)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1 MacrosInput (org.csstudio.opibuilder.util.MacrosInput)1 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)1 AlignmentAction (org.eclipse.gef.ui.actions.AlignmentAction)1