use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.
the class WidgetTree method removeWidgetListeners.
/**
* Recursively remove model widget listeners
* @param container Widgets to unlink
*/
private void removeWidgetListeners(final Widget widget) {
if (widget instanceof TabsWidget) {
final ArrayWidgetProperty<TabItemProperty> tabs = ((TabsWidget) widget).propTabs();
tabs.removePropertyListener(tabs_property_listener);
for (TabItemProperty tab : tabs.getValue()) {
tab.children().removePropertyListener(children_listener);
tab.name().removePropertyListener(tab_name_listener);
}
}
widget.propName().removePropertyListener(name_listener);
final ChildrenProperty children = ChildrenProperty.getChildren(widget);
if (children != null) {
children.removePropertyListener(children_listener);
for (Widget child : children.getValue()) removeWidgetListeners(child);
}
}
use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.
the class TabsRepresentation method removeTabs.
private void removeTabs(final List<TabItemProperty> removed) {
for (TabItemProperty item : removed) {
item.children().removePropertyListener(tab_children_listener);
item.name().removePropertyListener(tab_title_listener);
for (Tab tab : jfx_node.getTabs()) if (tab.getUserData() == item) {
jfx_node.getTabs().remove(tab);
break;
}
}
}
use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.
the class JFXBaseRepresentation method createComponents.
/**
* {@inheritDoc}
*/
@Override
public Parent createComponents(final Parent parent) throws Exception {
jfx_node = createJFXNode();
if (jfx_node != null) {
// Order JFX children same as model widgets within their container
int index = -1;
final Optional<Widget> container = model_widget.getParent();
if (container.isPresent()) {
if (container.get() instanceof TabsWidget) {
// Locate model_widget inside one of the Tab's children
final List<TabItemProperty> tabs = ((TabsWidget) container.get()).propTabs().getValue();
for (TabItemProperty tab : tabs) {
final int i = tab.children().getValue().indexOf(model_widget);
if (i >= 0) {
index = i;
break;
}
}
} else
index = container.get().getProperty(ChildrenProperty.DESCRIPTOR).getValue().indexOf(model_widget);
}
if (index < 0)
JFXRepresentation.getChildren(parent).add(jfx_node);
else
JFXRepresentation.getChildren(parent).add(index, jfx_node);
if (toolkit.isEditMode()) {
// Any visible item can be 'clicked' to allow editor to 'select' it
final EventHandler<MouseEvent> detect_click = event -> {
if (event.isPrimaryButtonDown()) {
event.consume();
toolkit.fireClick(model_widget, event.isControlDown());
}
};
if (isFilteringEditModeClicks())
jfx_node.addEventFilter(MouseEvent.MOUSE_PRESSED, detect_click);
else
jfx_node.addEventHandler(MouseEvent.MOUSE_PRESSED, detect_click);
} else
jfx_node.setOnContextMenuRequested((event) -> {
event.consume();
toolkit.fireContextMenu(model_widget);
});
}
registerListeners();
updateChanges();
return getChildParent(parent);
}
use of org.csstudio.display.builder.model.widgets.TabsWidget.TabItemProperty in project org.csstudio.display.builder by kasemir.
the class ChildrenProperty method getParentsChildren.
/**
* Get the 'children' list of a widget's parent.
*
* <p>This is either the children list of a plain parent,
* or the children list inside a TabWidget's tab.
*
* @param widget Widget where parent (plain or TabWidget) is checked for
* @return {@link ChildrenProperty} that contains the widget
* @throws NoSuchElementException if widget has no parent
* @throws IllegalArgumentException If no tab of parent {@link TabWidget} contains the widget,
* @throws IllegalStateException If parent has no children
*/
public static ChildrenProperty getParentsChildren(final Widget widget) {
final Widget parent = widget.getParent().get();
if (parent instanceof TabsWidget) {
final List<TabItemProperty> tabs = ((TabsWidget) parent).propTabs().getValue();
for (TabItemProperty tab : tabs) {
final ChildrenProperty children = tab.children();
if (children.getValue().contains(widget))
return children;
}
throw new IllegalArgumentException("Cannot locate " + widget + " in " + parent);
}
final Optional<WidgetProperty<List<Widget>>> children = parent.checkProperty(DESCRIPTOR);
if (children.isPresent())
return (ChildrenProperty) children.get();
throw new IllegalStateException("Parent of " + widget + " has no 'children': " + parent);
}
Aggregations