Search in sources :

Example 1 with TabItemProperty

use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.

the class TabsRepresentation method addTabs.

private void addTabs(final List<TabItemProperty> added) {
    for (TabItemProperty item : added) {
        final String name = item.name().getValue();
        final Pane content = new Pane();
        // 'Tab's are added with a Label as 'graphic'
        // because that label allows setting the font.
        // Quirk: Tabs will not show the label unless there's also a non-empty text
        final Tab tab = new Tab(" ", content);
        final Label label = new Label(name);
        tab.setGraphic(label);
        // !!
        tab.setClosable(false);
        tab.setUserData(item);
        final int index = jfx_node.getTabs().size();
        jfx_node.getTabs().add(tab);
        addChildren(index, item.children().getValue());
        item.name().addPropertyListener(tab_title_listener);
        item.children().addPropertyListener(tab_children_listener);
    }
}
Also used : TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty) Tab(javafx.scene.control.Tab) Label(javafx.scene.control.Label) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane)

Example 2 with TabItemProperty

use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.

the class WidgetTree method removeTabs.

private void removeTabs(final List<TabItemProperty> removed) {
    for (TabItemProperty tab : removed) {
        tab.children().removePropertyListener(children_listener);
        tab.name().removePropertyListener(tab_name_listener);
        final TreeItem<WidgetOrTab> tab_item = tab_name2tree.remove(tab.name());
        tab_item.getParent().getChildren().remove(tab_item);
    }
}
Also used : TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty)

Example 3 with TabItemProperty

use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty 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 4 with TabItemProperty

use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.

the class WidgetTree method addTabs.

private void addTabs(final List<TabItemProperty> added) {
    for (TabItemProperty tab : added) {
        final TreeItem<WidgetOrTab> widget_item = widget2tree.get(tab.getWidget());
        final TreeItem<WidgetOrTab> tab_item = new TreeItem<>(WidgetOrTab.of(tab));
        widget_item.getChildren().add(tab_item);
        tab_name2tree.put(tab.name(), tab_item);
        tab.name().addPropertyListener(tab_name_listener);
        for (Widget child : tab.children().getValue()) addWidget(child, -1);
        tab.children().addPropertyListener(children_listener);
    }
}
Also used : TabItemProperty(org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty) TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Example 5 with TabItemProperty

use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.

the class WidgetTree method addWidget.

/**
 * Add widget to existing model & tree
 *  @param added_widget Widget to add
 *  @param index Index of widget within parent. -1 to add at end
 */
private void addWidget(final Widget added_widget, final int index) {
    // Have widget and its parent in model
    final Widget widget_parent = added_widget.getParent().get();
    // Determine parent tree item
    TreeItem<WidgetOrTab> item_parent = null;
    if (widget_parent instanceof TabsWidget) {
        for (TabItemProperty tab : ((TabsWidget) widget_parent).propTabs().getValue()) if (tab.children().getValue().contains(added_widget)) {
            item_parent = tab_name2tree.get(tab.name());
            break;
        }
    } else
        item_parent = widget2tree.get(widget_parent);
    Objects.requireNonNull(item_parent, "Cannot obtain parent item for " + added_widget);
    // Create Tree item
    final TreeItem<WidgetOrTab> item = new TreeItem<>(WidgetOrTab.of(added_widget));
    widget2tree.put(added_widget, item);
    item.setExpanded(true);
    if (index >= 0)
        // Add at same index into Tree
        item_parent.getChildren().add(index, item);
    else
        // Append to end
        item_parent.getChildren().add(item);
    added_widget.propName().addPropertyListener(name_listener);
    if (added_widget instanceof TabsWidget) {
        final ArrayWidgetProperty<TabItemProperty> tabs = ((TabsWidget) added_widget).propTabs();
        addTabs(tabs.getValue());
        tabs.addPropertyListener(tabs_property_listener);
    } else {
        final ChildrenProperty children = ChildrenProperty.getChildren(added_widget);
        if (children != null) {
            children.addPropertyListener(children_listener);
            for (Widget child : children.getValue()) addWidget(child, -1);
        }
    }
}
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) TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget)

Aggregations

TabItemProperty (org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty)9 TabsWidget (org.csstudio.display.builder.model.widgets.TabsWidget)6 Widget (org.csstudio.display.builder.model.Widget)5 ChildrenProperty (org.csstudio.display.builder.model.ChildrenProperty)4 Tab (javafx.scene.control.Tab)2 TreeItem (javafx.scene.control.TreeItem)2 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 EventHandler (javafx.event.EventHandler)1 Node (javafx.scene.Node)1 Parent (javafx.scene.Parent)1 Label (javafx.scene.control.Label)1 TabPane (javafx.scene.control.TabPane)1 MouseEvent (javafx.scene.input.MouseEvent)1 Pane (javafx.scene.layout.Pane)1 DirtyFlag (org.csstudio.display.builder.model.DirtyFlag)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)1 CommonWidgetProperties (org.csstudio.display.builder.model.properties.CommonWidgetProperties)1