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);
}
}
}
}
}
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();
}
}
}
});
}
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();
}
}
}
});
}
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();
}
}
}
});
}
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();
}
Aggregations