Search in sources :

Example 1 with ChildrenProperty

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);
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Example 2 with ChildrenProperty

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();
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty)

Example 3 with ChildrenProperty

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;
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) Widget(org.csstudio.display.builder.model.Widget) ParseAgainException(org.csstudio.display.builder.model.WidgetConfigurator.ParseAgainException) WidgetTypeException(org.csstudio.display.builder.model.WidgetFactory.WidgetTypeException)

Example 4 with ChildrenProperty

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);
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty)

Example 5 with ChildrenProperty

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());
    }
}
Also used : WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) Widget(org.csstudio.display.builder.model.Widget)

Aggregations

ChildrenProperty (org.csstudio.display.builder.model.ChildrenProperty)17 Widget (org.csstudio.display.builder.model.Widget)12 TabsWidget (org.csstudio.display.builder.model.widgets.TabsWidget)4 Point2D (javafx.geometry.Point2D)3 Rectangle2D (javafx.geometry.Rectangle2D)3 ArrayWidget (org.csstudio.display.builder.model.widgets.ArrayWidget)3 GroupWidget (org.csstudio.display.builder.model.widgets.GroupWidget)3 TabItemProperty (org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty)3 AddWidgetAction (org.csstudio.display.builder.editor.undo.AddWidgetAction)2 Matcher (java.util.regex.Matcher)1 TreeItem (javafx.scene.control.TreeItem)1 GroupWidgetsAction (org.csstudio.display.builder.editor.undo.GroupWidgetsAction)1 UpdateWidgetLocationAction (org.csstudio.display.builder.editor.undo.UpdateWidgetLocationAction)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 ParseAgainException (org.csstudio.display.builder.model.WidgetConfigurator.ParseAgainException)1 WidgetTypeException (org.csstudio.display.builder.model.WidgetFactory.WidgetTypeException)1 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)1 Macros (org.csstudio.display.builder.model.macros.Macros)1 CommonWidgetProperties.propMacros (org.csstudio.display.builder.model.properties.CommonWidgetProperties.propMacros)1 ActionButtonWidget (org.csstudio.display.builder.model.widgets.ActionButtonWidget)1