Search in sources :

Example 16 with ChildrenProperty

use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.

the class ToolkitRepresentation method disposeChildren.

/**
 * Remove toolkit widgets for container
 *  @param container Container which should no longer be represented, recursing into children
 *  @return Parent toolkit item (Group, Container, ..) that used to host the container items
 */
private TWP disposeChildren(final Widget container, final ChildrenProperty children) {
    for (Widget widget : children.getValue()) {
        // First dispose child widgets, then the container
        final ChildrenProperty grandkids = ChildrenProperty.getChildren(widget);
        if (grandkids != null)
            disposeChildren(widget, grandkids);
        disposeWidget(widget);
    }
    final TWP parent = container.clearUserData(Widget.USER_DATA_TOOLKIT_PARENT);
    return parent;
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) Widget(org.csstudio.display.builder.model.Widget)

Example 17 with ChildrenProperty

use of org.csstudio.display.builder.model.ChildrenProperty in project org.csstudio.display.builder by kasemir.

the class CreateGroupAction method run.

@Override
public void run() {
    editor.getWidgetSelectionHandler().clear();
    // Create group that surrounds the original widget boundaries
    final GroupWidget group = new GroupWidget();
    // Get bounds of widgets relative to their container,
    // which might be a group within the display
    // or the display itself
    final Rectangle2D rect = GeometryTools.getBounds(widgets);
    // Inset depends on representation and changes with group style and font.
    // Can be obtained via group.runtimePropInsets() _after_ the group has
    // been represented. For this reason Style.NONE is used, where the inset
    // is always 0. An alternative could be Style.LINE, with an inset of 1.
    final int inset = 0;
    group.propStyle().setValue(Style.NONE);
    group.propTransparent().setValue(true);
    group.propX().setValue((int) rect.getMinX() - inset);
    group.propY().setValue((int) rect.getMinY() - inset);
    group.propWidth().setValue((int) rect.getWidth() + 2 * inset);
    group.propHeight().setValue((int) rect.getHeight() + 2 * inset);
    group.propName().setValue(org.csstudio.display.builder.model.Messages.GroupWidget_Name);
    final ChildrenProperty parent_children = ChildrenProperty.getParentsChildren(widgets.get(0));
    final UndoableActionManager undo = editor.getUndoableActionManager();
    undo.execute(new GroupWidgetsAction(parent_children, group, widgets, (int) rect.getMinX(), (int) rect.getMinY()));
    editor.getWidgetSelectionHandler().toggleSelection(group);
}
Also used : ChildrenProperty(org.csstudio.display.builder.model.ChildrenProperty) UndoableActionManager(org.csstudio.display.builder.util.undo.UndoableActionManager) Rectangle2D(javafx.geometry.Rectangle2D) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget) GroupWidgetsAction(org.csstudio.display.builder.editor.undo.GroupWidgetsAction)

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