Search in sources :

Example 1 with OpenDisplayAction

use of org.csstudio.opibuilder.widgetActions.OpenDisplayAction in project yamcs-studio by yamcs.

the class OPIRunnerContextMenuProvider method addWidgetActionToMenu.

/**
 * Adds the defined {@link AbstractWidgetAction}s to the given {@link IMenuManager}.
 *
 * @param menu
 *            The {@link IMenuManager}
 */
private void addWidgetActionToMenu(final IMenuManager menu) {
    List<?> selectedEditParts = ((IStructuredSelection) getViewer().getSelection()).toList();
    if (selectedEditParts.size() == 1) {
        if (selectedEditParts.get(0) instanceof AbstractBaseEditPart) {
            AbstractBaseEditPart editPart = (AbstractBaseEditPart) selectedEditParts.get(0);
            AbstractWidgetModel widget = editPart.getWidgetModel();
            // add menu Open, Open in New Tab and Open in New Window
            List<AbstractWidgetAction> hookedActions = editPart.getHookedActions();
            if (hookedActions != null && hookedActions.size() == 1) {
                AbstractWidgetAction hookedAction = hookedActions.get(0);
                if (hookedAction instanceof OpenDisplayAction) {
                    final OpenDisplayAction original_action = (OpenDisplayAction) hookedAction;
                    menu.add(new OpenRelatedDisplayAction(original_action, OpenDisplayTarget.DEFAULT));
                    menu.add(new OpenRelatedDisplayAction(original_action, OpenDisplayTarget.NEW_TAB));
                    menu.add(new OpenRelatedDisplayAction(original_action, OpenDisplayTarget.NEW_WINDOW));
                    menu.add(new OpenRelatedDisplayAction(original_action, OpenDisplayTarget.NEW_SHELL));
                }
            }
            ActionsInput ai = widget.getActionsInput();
            if (ai != null) {
                List<AbstractWidgetAction> widgetActions = ai.getActionsList();
                if (!widgetActions.isEmpty()) {
                    MenuManager actionMenu = new MenuManager("Actions", "actions");
                    for (AbstractWidgetAction action : widgetActions) {
                        actionMenu.add(new WidgetActionMenuAction(action));
                    }
                    menu.add(actionMenu);
                }
            }
        }
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) WidgetActionMenuAction(org.csstudio.opibuilder.actions.WidgetActionMenuAction) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) OpenDisplayAction(org.csstudio.opibuilder.widgetActions.OpenDisplayAction) ActionsInput(org.csstudio.opibuilder.widgetActions.ActionsInput) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) OpenRelatedDisplayAction(org.csstudio.opibuilder.actions.OpenRelatedDisplayAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AbstractWidgetAction(org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)

Example 2 with OpenDisplayAction

use of org.csstudio.opibuilder.widgetActions.OpenDisplayAction in project yamcs-studio by yamcs.

the class NativeButtonEditPart method hookMouseClickAction.

@Override
protected void hookMouseClickAction() {
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            List<AbstractWidgetAction> actions = getHookedActions();
            if (actions != null) {
                for (AbstractWidgetAction action : actions) {
                    if (action instanceof OpenDisplayAction)
                        ((OpenDisplayAction) action).runWithModifiers((e.stateMask & SWT.CTRL) != 0, (e.stateMask & SWT.SHIFT) != 0);
                    else
                        action.run();
                }
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) OpenDisplayAction(org.csstudio.opibuilder.widgetActions.OpenDisplayAction) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) AbstractWidgetAction(org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)

Example 3 with OpenDisplayAction

use of org.csstudio.opibuilder.widgetActions.OpenDisplayAction in project yamcs-studio by yamcs.

the class Draw2DButtonEditPartDelegate method hookMouseClickAction.

/* (non-Javadoc)
     * @see org.csstudio.opibuilder.widgets.editparts.IButtonEditPartDelegate#hookMouseClickAction()
     */
@Override
public void hookMouseClickAction() {
    ((ActionButtonFigure) editpart.getFigure()).addActionListener(new ButtonActionListener() {

        @Override
        public void actionPerformed(int mouseEventState) {
            List<AbstractWidgetAction> actions = editpart.getHookedActions();
            if (actions != null) {
                for (AbstractWidgetAction action : actions) {
                    if (action instanceof OpenDisplayAction)
                        ((OpenDisplayAction) action).runWithModifiers((mouseEventState & SWT.CONTROL) != 0, (mouseEventState & SWT.SHIFT) != 0);
                    else
                        action.run();
                }
            }
        }
    });
}
Also used : OpenDisplayAction(org.csstudio.opibuilder.widgetActions.OpenDisplayAction) List(java.util.List) ActionButtonFigure(org.csstudio.swt.widgets.figures.ActionButtonFigure) ButtonActionListener(org.csstudio.swt.widgets.figures.ActionButtonFigure.ButtonActionListener) AbstractWidgetAction(org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)

Example 4 with OpenDisplayAction

use of org.csstudio.opibuilder.widgetActions.OpenDisplayAction in project yamcs-studio by yamcs.

the class NativeButtonEditPartDelegate method hookMouseClickAction.

@Override
public void hookMouseClickAction() {
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            List<AbstractWidgetAction> actions = editpart.getHookedActions();
            if (actions != null) {
                for (AbstractWidgetAction action : actions) {
                    if (action instanceof OpenDisplayAction)
                        ((OpenDisplayAction) action).runWithModifiers((e.stateMask & SWT.CTRL) != 0, (e.stateMask & SWT.SHIFT) != 0);
                    else
                        action.run();
                }
            }
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) OpenDisplayAction(org.csstudio.opibuilder.widgetActions.OpenDisplayAction) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) AbstractWidgetAction(org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)

Example 5 with OpenDisplayAction

use of org.csstudio.opibuilder.widgetActions.OpenDisplayAction in project yamcs-studio by yamcs.

the class ScriptUtil method openOPI.

/**
 * Open an OPI.
 *
 * @param widget
 *            the widget to which the script is attached.
 * @param opiPath
 *            the path of the OPI. It can be either an absolute path or a relative path to the Display file of the
 *            widget.
 * @param target
 *            target place of the new OPI. 0: new tab; 1: replace current one; 2: new window; 3: view on left; 4:
 *            view on right; 5: view on top; 6: view on bottom; 7: detached view; 8: new shell
 * @param macrosInput
 *            the macrosInput. null if no macros needed.
 */
public static final void openOPI(AbstractBaseEditPart widget, String opiPath, int target, MacrosInput macrosInput) {
    final OpenDisplayAction action = new OpenDisplayAction();
    // Map target IDs of this API to DisplayMode
    final DisplayMode mode;
    switch(target) {
        case 0:
            mode = DisplayMode.NEW_TAB;
            break;
        case 2:
            mode = DisplayMode.NEW_WINDOW;
            break;
        case 3:
            mode = DisplayMode.NEW_TAB_LEFT;
            break;
        case 4:
            mode = DisplayMode.NEW_TAB_RIGHT;
            break;
        case 5:
            mode = DisplayMode.NEW_TAB_TOP;
            break;
        case 6:
            mode = DisplayMode.NEW_TAB_BOTTOM;
            break;
        case 7:
            mode = DisplayMode.NEW_TAB_DETACHED;
            break;
        case 8:
            mode = DisplayMode.NEW_SHELL;
            break;
        default:
            mode = DisplayMode.REPLACE;
    }
    action.setWidgetModel(widget.getWidgetModel());
    action.setPropertyValue(OpenDisplayAction.PROP_PATH, opiPath);
    action.setPropertyValue(OpenDisplayAction.PROP_MACROS, macrosInput);
    action.setPropertyValue(OpenDisplayAction.PROP_MODE, mode.ordinal());
    action.run();
}
Also used : DisplayMode(org.csstudio.opibuilder.runmode.RunModeService.DisplayMode) OpenDisplayAction(org.csstudio.opibuilder.widgetActions.OpenDisplayAction)

Aggregations

OpenDisplayAction (org.csstudio.opibuilder.widgetActions.OpenDisplayAction)5 AbstractWidgetAction (org.csstudio.opibuilder.widgetActions.AbstractWidgetAction)4 List (java.util.List)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 OpenRelatedDisplayAction (org.csstudio.opibuilder.actions.OpenRelatedDisplayAction)1 WidgetActionMenuAction (org.csstudio.opibuilder.actions.WidgetActionMenuAction)1 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 DisplayMode (org.csstudio.opibuilder.runmode.RunModeService.DisplayMode)1 ActionsInput (org.csstudio.opibuilder.widgetActions.ActionsInput)1 ActionButtonFigure (org.csstudio.swt.widgets.figures.ActionButtonFigure)1 ButtonActionListener (org.csstudio.swt.widgets.figures.ActionButtonFigure.ButtonActionListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1