use of org.csstudio.opibuilder.widgets.model.TabModel.PROP_TAB_COUNT in project yamcs-studio by yamcs.
the class TabEditPart method registerTabsAmountChangeHandler.
private void registerTabsAmountChangeHandler() {
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
var model = getWidgetModel();
var figure = (TabFigure) refreshableFigure;
var currentTabAmount = figure.getTabAmount();
// add tabs
if ((Integer) newValue > currentTabAmount) {
for (var i1 = 0; i1 < (Integer) newValue - currentTabAmount; i1++) {
for (var tabProperty1 : TabProperty.values()) {
var propID1 = TabModel.makeTabPropID(tabProperty1.propIDPre, i1 + currentTabAmount);
model.setPropertyVisible(propID1, true);
}
addTab();
}
} else if ((Integer) newValue < currentTabAmount) {
// remove tabs
for (var i2 = currentTabAmount - 1; i2 >= (Integer) newValue; i2--) {
for (var tabProperty2 : TabProperty.values()) {
var propID2 = TabModel.makeTabPropID(tabProperty2.propIDPre, i2);
model.setPropertyVisible(propID2, false);
}
removeTab();
}
setActiveTabIndex(0);
}
return true;
};
getWidgetModel().getProperty(PROP_TAB_COUNT).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Aggregations