use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction in project yamcs-studio by yamcs.
the class ActionsInputDialog method createActions.
/**
* Creates the actions.
*/
private void createActions() {
addAction = new Action("Add") {
@Override
public void run() {
}
};
addAction.setMenuCreator(new IMenuCreator() {
private Menu menu;
@Override
public void dispose() {
if (menu != null) {
menu.dispose();
menu = null;
}
}
@Override
public Menu getMenu(final Control parent) {
if (menu != null) {
menu.dispose();
}
menu = createMenu(parent, false);
return menu;
}
@Override
public Menu getMenu(final Menu parent) {
return null;
}
});
addAction.setToolTipText("Add an action");
addAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/add.gif"));
copyAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) actionsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof AbstractWidgetAction) {
AbstractWidgetAction newAction = ((AbstractWidgetAction) selection.getFirstElement()).getCopy();
actionsInput.addAction(newAction);
actionsViewer.setSelection(new StructuredSelection(newAction));
refreshActionsViewer(newAction);
}
}
};
copyAction.setText("Copy Action");
copyAction.setToolTipText("Copy the selected action");
copyAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/copy.gif"));
copyAction.setEnabled(false);
removeAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) actionsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof AbstractWidgetAction) {
actionsList.remove((AbstractWidgetAction) selection.getFirstElement());
refreshActionsViewer(null);
this.setEnabled(false);
}
}
};
removeAction.setText("Remove Action");
removeAction.setToolTipText("Remove the selected action from the list");
removeAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/delete.gif"));
removeAction.setEnabled(false);
moveUpAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) actionsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof AbstractWidgetAction) {
AbstractWidgetAction widgetAction = (AbstractWidgetAction) selection.getFirstElement();
int i = actionsList.indexOf(widgetAction);
if (i > 0) {
actionsList.remove(widgetAction);
actionsList.add(i - 1, widgetAction);
refreshActionsViewer(widgetAction);
}
}
}
};
moveUpAction.setText("Move Up Action");
moveUpAction.setToolTipText("Move up the selected action");
moveUpAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/search_prev.gif"));
moveUpAction.setEnabled(false);
moveDownAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) actionsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof AbstractWidgetAction) {
AbstractWidgetAction widgetAction = (AbstractWidgetAction) selection.getFirstElement();
int i = actionsList.indexOf(widgetAction);
if (i < actionsList.size() - 1) {
actionsList.remove(widgetAction);
actionsList.add(i + 1, widgetAction);
refreshActionsViewer(widgetAction);
}
}
}
};
moveDownAction.setText("Move Down Action");
moveDownAction.setToolTipText("Move down the selected action");
moveDownAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/search_next.gif"));
moveDownAction.setEnabled(false);
}
use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction 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.AbstractWidgetAction in project yamcs-studio by yamcs.
the class MenuButtonEditPart method showMenu.
/**
* Show Menu
*
* @param point
* the location of the mouse-event in the OPI display
* @param absolutX
* The x coordinate of the mouse on the monitor
* @param absolutY
* The y coordinate of the mouse on the monitor
*/
private void showMenu(final Point point, final int absolutX, final int absolutY) {
if (getExecutionMode().equals(ExecutionMode.RUN_MODE)) {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MenuManager menuManager = new MenuManager();
for (AbstractWidgetAction action : getWidgetModel().getActionsInput().getActionsList()) {
menuManager.add(new WidgetActionMenuAction(action));
}
Menu menu = menuManager.createContextMenu(shell);
/*
* We need to position the menu in absolute monitor coordinates.
* First we calculate the coordinates of the display, then add the
* widget coordinates to these so that the menu opens on the
* bottom left of the widget.
*/
int x = absolutX - point.x;
int y = absolutY - point.y;
x += getWidgetModel().getLocation().x;
y += getWidgetModel().getLocation().y + getWidgetModel().getSize().height;
menu.setLocation(x, y);
menu.setVisible(true);
}
}
use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction 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.AbstractWidgetAction in project yamcs-studio by yamcs.
the class ActionsProperty method writeToXML.
@Override
public void writeToXML(Element propElement) {
ActionsInput actionsInput = (ActionsInput) getPropertyValue();
// //$NON-NLS-1$
propElement.setAttribute(XML_ATTRIBUTE_HOOK_FIRST, "" + actionsInput.isFirstActionHookedUpToWidget());
// //$NON-NLS-1$
propElement.setAttribute(XML_ATTRIBUTE_HOOK_ALL, "" + actionsInput.isHookUpAllActionsToWidget());
for (AbstractWidgetAction action : actionsInput.getActionsList()) {
Element actionElement = new Element(XML_ELEMENT_ACTION);
actionElement.setAttribute(XML_ATTRIBUTE_ACTION_TYPE, action.getActionType().toString());
for (AbstractWidgetProperty property : action.getAllProperties()) {
Element propEle = new Element(property.getPropertyID());
property.writeToXML(propEle);
actionElement.addContent(propEle);
}
propElement.addContent(actionElement);
}
}
Aggregations