use of org.csstudio.opibuilder.widgetActions.ActionsInput 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.ActionsInput 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.ActionsInput 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.ActionsInput in project yamcs-studio by yamcs.
the class ActionButtonEditPart method getHookedActionsForButton.
/**
* A shared static method for all button widgets.
*
* @param widgetModel
* @param isSelected
* @return
*/
public static List<AbstractWidgetAction> getHookedActionsForButton(ActionButtonModel widgetModel, boolean isSelected) {
int actionIndex;
if (widgetModel.isToggleButton()) {
if (isSelected) {
actionIndex = widgetModel.getActionIndex();
} else
actionIndex = widgetModel.getReleasedActionIndex();
} else
actionIndex = widgetModel.getActionIndex();
ActionsInput actionsInput = widgetModel.getActionsInput();
if (actionsInput.getActionsList().size() <= 0)
return null;
if (actionsInput.isHookUpAllActionsToWidget())
return actionsInput.getActionsList();
if (actionIndex >= 0 && actionsInput.getActionsList().size() > actionIndex) {
return widgetModel.getActionsInput().getActionsList().subList(actionIndex, actionIndex + 1);
}
if (actionIndex == -1)
return actionsInput.getActionsList();
return null;
}
use of org.csstudio.opibuilder.widgetActions.ActionsInput in project yamcs-studio by yamcs.
the class ActionsInputDialog method getOutput.
public ActionsInput getOutput() {
ActionsInput actionsInput = new ActionsInput(actionsList);
actionsInput.setHookUpFirstActionToWidget(hookedUpFirstActionToWidget);
actionsInput.setHookUpAllActionsToWidget(hookedUpAllActionsToWidget);
return actionsInput;
}
Aggregations