use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.
the class WidgetTree method removeWidget.
/**
* Remove widget from existing model & tree
* @param removed_widget
*/
private void removeWidget(final Widget removed_widget) {
if (removed_widget instanceof TabsWidget) {
final ArrayWidgetProperty<TabItemProperty> tabs = ((TabsWidget) removed_widget).propTabs();
tabs.removePropertyListener(tabs_property_listener);
removeTabs(tabs.getValue());
}
removed_widget.propName().removePropertyListener(name_listener);
final ChildrenProperty children = ChildrenProperty.getChildren(removed_widget);
if (children != null) {
children.removePropertyListener(children_listener);
for (Widget child : children.getValue()) removeWidget(child);
}
final TreeItem<WidgetOrTab> item = widget2tree.remove(removed_widget);
item.getParent().getChildren().remove(item);
}
use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.
the class ModelWriter method writeWidget.
/**
* Write widget
* @param widget Widget to write
* @throws Exception on error
*/
protected void writeWidget(final Widget widget) throws Exception {
// 'protected' to allow unit test calls
writer.writeStartElement(XMLTags.WIDGET);
writer.writeAttribute(XMLTags.TYPE, widget.getType());
writer.writeAttribute(XMLTags.VERSION, widget.getVersion().toString());
writeWidgetProperties(widget);
ChildrenProperty children = ChildrenProperty.getChildren(widget);
if (children != null)
children.writeToXML(this, writer);
writer.writeEndElement();
}
use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.
the class ModelReader method readWidget.
/**
* Read widget from XML
* @param widget_xml Widget's XML element
* @return Widget
* @throws Exception on error
*/
private Widget readWidget(final Element widget_xml) throws Exception {
String type = widget_xml.getAttribute(XMLTags.TYPE);
if (type.isEmpty()) {
// Fall back to legacy opibuilder:
// <widget typeId="org.csstudio.opibuilder.widgets.Label" version="1.0.0">
type = widget_xml.getAttribute("typeId");
if (type.isEmpty())
throw new Exception("Missing widget type");
}
final Widget widget = createWidget(type, widget_xml);
final ChildrenProperty children = ChildrenProperty.getChildren(widget);
if (children != null)
readWidgets(children, widget_xml);
return widget;
}
use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.
the class UpdateWidgetOrderAction method moveTo.
private void moveTo(final int index) {
final ChildrenProperty children = ChildrenProperty.getParentsChildren(widget);
children.removeChild(widget);
if (index < 0)
children.addChild(widget);
else
children.addChild(index, widget);
}
use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.
the class DisplayMacroExpander method expand.
private static void expand(final ChildrenProperty widgets, MacroValueProvider input) throws Exception {
for (Widget widget : widgets.getValue()) {
final Optional<WidgetProperty<Macros>> macros = widget.checkProperty(CommonWidgetProperties.propMacros);
if (macros.isPresent())
macros.get().getValue().expandValues(input);
// Recurse
final ChildrenProperty children = ChildrenProperty.getChildren(widget);
if (children != null)
expand(children, widget.getMacrosOrProperties());
}
}
Aggregations