use of org.csstudio.display.builder.model.WidgetProperty in project org.csstudio.display.builder by kasemir.
the class PointsBinding method selectionChanged.
@Override
public void selectionChanged(final List<Widget> widgets) {
if (widgets != null && widgets.size() == 1) {
final Widget w = widgets.get(0);
Optional<WidgetProperty<Points>> prop = w.checkProperty(propPoints);
if (prop.isPresent()) {
createEditor(w);
return;
}
}
// Not exactly one widget with "points" -> No editor
disposeEditor();
}
use of org.csstudio.display.builder.model.WidgetProperty in project org.csstudio.display.builder by kasemir.
the class WidgetInfoDialog method createProperties.
private Tab createProperties(final Widget widget) {
// Use text field to allow copying the name (for use in scripts)
// and value, but not the localized description and category
// which are just for information
final TableColumn<WidgetProperty<?>, String> cat = new TableColumn<>(Messages.WidgetInfoDialog_Category);
cat.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getCategory().getDescription()));
final TableColumn<WidgetProperty<?>, String> descr = new TableColumn<>(Messages.WidgetInfoDialog_Property);
descr.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getDescription()));
final TableColumn<WidgetProperty<?>, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
name.setCellFactory(TextFieldTableCell.forTableColumn());
name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue().getName()));
final TableColumn<WidgetProperty<?>, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
value.setCellFactory(TextFieldTableCell.forTableColumn());
value.setCellValueFactory(param -> new ReadOnlyStringWrapper(Objects.toString(param.getValue().getValue())));
final TableView<WidgetProperty<?>> table = new TableView<>(FXCollections.observableArrayList(widget.getProperties()));
table.getColumns().add(cat);
table.getColumns().add(descr);
table.getColumns().add(name);
table.getColumns().add(value);
table.setEditable(true);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
return new Tab(Messages.WidgetInfoDialog_TabProperties, table);
}
use of org.csstudio.display.builder.model.WidgetProperty in project org.csstudio.display.builder by kasemir.
the class RulesWidgetProperty method writeToXML.
@Override
public void writeToXML(final ModelWriter model_writer, final XMLStreamWriter writer) throws Exception {
logger.log(Level.FINE, "Write " + value.size() + " rules to XML");
for (final RuleInfo info : value) {
// <rule name="name" prop_id="prop" out_exp="true">
writer.writeStartElement(XMLTags.RULE);
writer.writeAttribute(XMLTags.NAME, info.getName());
writer.writeAttribute("prop_id", info.getPropID());
writer.writeAttribute("out_exp", String.valueOf(info.getPropAsExprFlag()));
for (final ExpressionInfo<?> expr : info.getExpressions()) {
// <exp bool_exp="foo==1">
writer.writeStartElement("exp");
writer.writeAttribute("bool_exp", expr.getBoolExp());
if (info.getPropAsExprFlag()) {
// <expression>
writer.writeStartElement("expression");
if (!(expr.getPropVal() instanceof String)) {
logger.log(Level.SEVERE, "Mismatch of rules output expression flag with expression value type, expected String, got ", expr.getPropVal().getClass());
writer.writeCharacters("ERROR");
}
// some string of the value or expression
writer.writeCharacters((String) expr.getPropVal());
} else {
// <value>
writer.writeStartElement("value");
if (!(expr.getPropVal() instanceof WidgetProperty<?>)) {
logger.log(Level.SEVERE, "Mismatch of rules output expression flag with expression value type, expected Widget Property, got ", expr.getPropVal().getClass());
writer.writeCharacters("ERROR");
}
// write the property
((WidgetProperty<?>) expr.getPropVal()).writeToXML(model_writer, writer);
}
// </value> or </expression>
writer.writeEndElement();
// </exp>
writer.writeEndElement();
}
for (final ScriptPV pv : info.getPVs()) {
// <pv trig="true">
writer.writeStartElement(XMLTags.PV_NAME);
if (!pv.isTrigger())
writer.writeAttribute(XMLTags.TRIGGER, Boolean.FALSE.toString());
// some string of the pv name
writer.writeCharacters(pv.getName());
// </pv>
writer.writeEndElement();
}
// </rule>
writer.writeEndElement();
}
}
use of org.csstudio.display.builder.model.WidgetProperty in project org.csstudio.display.builder by kasemir.
the class XYPlotWidgetRuntime method stop.
@Override
public void stop() {
// Disconnect Marker PVs and listeners
for (Map.Entry<WidgetProperty<?>, WidgetPropertyListener<?>> entry : marker_prop_listeners.entrySet()) entry.getKey().removePropertyListener(entry.getValue());
marker_prop_listeners.clear();
for (Map.Entry<RuntimePV, RuntimePVListener> entry : marker_pv_listeners.entrySet()) entry.getKey().removeListener(entry.getValue());
marker_pv_listeners.clear();
for (RuntimePV pv : marker_pvs) {
removePV(pv);
PVFactory.releasePV(pv);
}
marker_pvs.clear();
for (PVNameToValueBinding binding : bindings) binding.dispose();
super.stop();
}
use of org.csstudio.display.builder.model.WidgetProperty in project org.csstudio.display.builder by kasemir.
the class ImageWidgetRuntime method bindROI.
/**
* Bind an ROI PV to an ROI value
* @param name_prop Property for the PV name
* @param value_prop Property for the value
*/
private void bindROI(final WidgetProperty<String> name_prop, final WidgetProperty<Double> value_prop) {
final String pv_name = name_prop.getValue();
if (pv_name.isEmpty())
return;
logger.log(Level.FINER, "Connecting {0} to ROI PV {1}", new Object[] { widget, pv_name });
try {
final RuntimePV pv = PVFactory.getPV(pv_name);
addPV(pv);
roi_pvs.add(pv);
// Write value changes to the PV
final WidgetPropertyListener<Double> prop_listener = (prop, old, value) -> {
try {
if (value == VTypeUtil.getValueNumber(pv.read()).doubleValue())
return;
// System.out.println("Writing " + value_prop + " to PV " + pv_name);
pv.write(value);
} catch (Exception ex) {
logger.log(Level.WARNING, "Error writing ROI value to PV " + pv_name, ex);
}
};
value_prop.addPropertyListener(prop_listener);
roi_prop_listeners.put(value_prop, prop_listener);
// Write PV updates to the value
final RuntimePVListener pv_listener = new RuntimePVListener() {
@Override
public void valueChanged(final RuntimePV pv, final VType value) {
final double number = VTypeUtil.getValueNumber(value).doubleValue();
if (number == value_prop.getValue())
return;
// System.out.println("Writing from PV " + pv_name + " to " + value_prop);
value_prop.setValue(number);
}
};
pv.addListener(pv_listener);
roi_pv_listeners.put(pv, pv_listener);
} catch (Exception ex) {
logger.log(Level.WARNING, "Error connecting ROI PV " + pv_name, ex);
}
}
Aggregations