use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction in project yamcs-studio by yamcs.
the class ActionsProperty method readValueFromXML.
@Override
public ActionsInput readValueFromXML(Element propElement) {
ActionsInput result = new ActionsInput();
result.setHookUpFirstActionToWidget(Boolean.parseBoolean(propElement.getAttributeValue(XML_ATTRIBUTE_HOOK_FIRST)));
if (propElement.getAttribute(XML_ATTRIBUTE_HOOK_ALL) != null)
result.setHookUpAllActionsToWidget(Boolean.parseBoolean(propElement.getAttributeValue(XML_ATTRIBUTE_HOOK_ALL)));
for (Object oe : propElement.getChildren(XML_ELEMENT_ACTION)) {
Element se = (Element) oe;
AbstractWidgetAction action = WidgetActionFactory.createWidgetAction(ActionType.parseAction(se.getAttributeValue(XML_ATTRIBUTE_ACTION_TYPE)));
if (action != null) {
List<?> children = se.getChildren();
Iterator<?> iterator = children.iterator();
Set<String> propIdSet = action.getAllPropertyIDs();
while (iterator.hasNext()) {
Element subElement = (Element) iterator.next();
// handle property
if (propIdSet.contains(subElement.getName())) {
String propId = subElement.getName();
try {
action.setPropertyValue(propId, action.getProperty(propId).readValueFromXML(subElement));
} catch (Exception e) {
String errorMessage = "Failed to read the " + propId + " property for " + action.getDescription() + ". " + "The default property value will be setted instead. \n" + e;
OPIBuilderPlugin.getLogger().log(Level.WARNING, errorMessage, e);
ConsoleService.getInstance().writeWarning(errorMessage);
}
}
}
result.getActionsList().add(action);
}
}
return result;
}
use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction 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.AbstractWidgetAction in project yamcs-studio by yamcs.
the class AbstractBaseEditPart method deactivate.
@Override
public void deactivate() {
if (isActive()) {
doDeActivate();
ActionsInput input = getWidgetModel().getActionsInput();
for (AbstractWidgetAction a : input.getActionsList()) {
a.dispose();
}
super.deactivate();
// remove listener from all properties.
for (String id : getWidgetModel().getAllPropertyIDs()) {
getWidgetModel().getProperty(id).removeAllPropertyChangeListeners();
}
if (executionMode == ExecutionMode.RUN_MODE) {
// remove script listeners before stopping PV.
for (ScriptData scriptData : scriptDataList) {
ScriptService.getInstance().unRegisterScript(scriptData);
}
if (hasStartedPVs) {
// we should not attempt to stop those pvs; this can happen with linking container
for (Object pv : pvMap.values().toArray()) {
((IPV) pv).stop();
}
}
}
propertyListenerMap.clear();
// propertyListenerMap = null;
}
}
use of org.csstudio.opibuilder.widgetActions.AbstractWidgetAction 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.AbstractWidgetAction in project yamcs-studio by yamcs.
the class ActionsInputDialog method refreshGUIOnSelection.
/**
* Refreshes the enabled-state of the actions.
*/
private void refreshGUIOnSelection() {
IStructuredSelection selection = (IStructuredSelection) actionsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof AbstractWidgetAction) {
removeAction.setEnabled(true);
moveUpAction.setEnabled(true);
moveDownAction.setEnabled(true);
copyAction.setEnabled(true);
propertiesViewer.setInput(((AbstractWidgetAction) selection.getFirstElement()).getAllProperties());
propertiesViewer.getTable().setEnabled(true);
} else {
removeAction.setEnabled(false);
moveUpAction.setEnabled(false);
moveDownAction.setEnabled(false);
propertiesViewer.getTable().setEnabled(false);
copyAction.setEnabled(false);
}
}
Aggregations