use of org.csstudio.opibuilder.script.RuleData in project yamcs-studio by yamcs.
the class RulesInputDialog method createActions.
/**
* Creates the actions.
*/
private void createActions() {
addAction = new Action("Add") {
@Override
public void run() {
RuleDataEditDialog dialog = new RuleDataEditDialog(getShell(), new RuleData(widgetModel));
if (dialog.open() == OK) {
ruleDataList.add(dialog.getOutput());
rulesViewer.refresh();
}
}
};
addAction.setToolTipText("Add a Rule");
addAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/add.gif"));
editAction = new Action("Edit") {
@Override
public void run() {
invokeRuleDataDialog();
}
};
editAction.setToolTipText("Edit Selected Rule");
editAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/edit.gif"));
editAction.setEnabled(false);
copyAction = new Action("Copy") {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) rulesViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof RuleData) {
RuleData ruleData = ((RuleData) selection.getFirstElement()).getCopy();
ruleDataList.add(ruleData);
setRulesViewerSelection(ruleData);
}
}
};
copyAction.setToolTipText("Copy Selected Rule");
copyAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/copy.gif"));
copyAction.setEnabled(false);
removeAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) rulesViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof RuleData) {
ruleDataList.remove((RuleData) selection.getFirstElement());
setRulesViewerSelection(null);
this.setEnabled(false);
}
}
};
removeAction.setToolTipText("Remove Selected Rule");
removeAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/delete.gif"));
removeAction.setEnabled(false);
moveUpAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) rulesViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof RuleData) {
RuleData ruleData = (RuleData) selection.getFirstElement();
int i = ruleDataList.indexOf(ruleData);
if (i > 0) {
ruleDataList.remove(ruleData);
ruleDataList.add(i - 1, ruleData);
setRulesViewerSelection(ruleData);
}
}
}
};
moveUpAction.setText("Move Rule Up");
moveUpAction.setToolTipText("Move Selected Rule up");
moveUpAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/search_prev.gif"));
moveUpAction.setEnabled(false);
moveDownAction = new Action() {
@Override
public void run() {
IStructuredSelection selection = (IStructuredSelection) rulesViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof RuleData) {
RuleData ruleData = (RuleData) selection.getFirstElement();
int i = ruleDataList.indexOf(ruleData);
if (i < ruleDataList.size() - 1) {
ruleDataList.remove(ruleData);
ruleDataList.add(i + 1, ruleData);
setRulesViewerSelection(ruleData);
}
}
}
};
moveDownAction.setText("Move Rule Down");
moveDownAction.setToolTipText("Move Selected Rule Down");
moveDownAction.setImageDescriptor(CustomMediaFactory.getInstance().getImageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
"icons/search_next.gif"));
moveDownAction.setEnabled(false);
}
use of org.csstudio.opibuilder.script.RuleData in project yamcs-studio by yamcs.
the class RulesProperty method writeToXML.
@Override
public void writeToXML(Element propElement) {
for (RuleData ruleData : ((RulesInput) getPropertyValue()).getRuleDataList()) {
Element ruleElement = new Element(XML_ELEMENT_RULE);
ruleElement.setAttribute(XML_ATTRIBUTE_NAME, ruleData.getName());
ruleElement.setAttribute(XML_ATTRIBUTE_PROPID, ruleData.getPropId());
ruleElement.setAttribute(XML_ATTRIBUTE_OUTPUTEXPRESSION, Boolean.toString(ruleData.isOutputExpValue()));
for (Expression exp : ruleData.getExpressionList()) {
Element expElement = new Element(XML_ELEMENT_EXPRESSION);
expElement.setAttribute(XML_ATTRIBUTE_BOOLEXP, exp.getBooleanExpression());
Element valueElement = new Element(XML_ELEMENT_VALUE);
if (ruleData.isOutputExpValue())
valueElement.setText(exp.getValue().toString());
else {
Object savedValue = ruleData.getProperty().getPropertyValue();
ruleData.getProperty().setPropertyValue_IgnoreOldValue(exp.getValue());
ruleData.getProperty().writeToXML(valueElement);
ruleData.getProperty().setPropertyValue_IgnoreOldValue(savedValue);
}
expElement.addContent(valueElement);
ruleElement.addContent(expElement);
}
for (PVTuple pv : ruleData.getPVList()) {
Element pvElement = new Element(XML_ELEMENT_PV);
pvElement.setText(pv.pvName);
pvElement.setAttribute(XML_ATTRIBUTE_TRIGGER, Boolean.toString(pv.trigger));
ruleElement.addContent(pvElement);
}
propElement.addContent(ruleElement);
}
}
Aggregations