use of org.csstudio.opibuilder.widgets.model.TabModel.TabProperty in project yamcs-studio by yamcs.
the class TabItem method getCopy.
/**
* @return A copy of this tab.
* @throws Exception
*/
public TabItem getCopy() throws Exception {
String xmlString = XMLUtil.widgetToXMLString(groupingContainerModel, false);
GroupingContainerModel newGroupingContainerModel = (GroupingContainerModel) XMLUtil.XMLStringToWidget(xmlString);
Map<TabProperty, Object> newPropertyMap = new HashMap<TabProperty, Object>();
for (Entry<TabProperty, Object> entry : propertyMap.entrySet()) {
newPropertyMap.put(entry.getKey(), entry.getValue());
}
return new TabItem(newGroupingContainerModel, newPropertyMap);
}
use of org.csstudio.opibuilder.widgets.model.TabModel.TabProperty in project yamcs-studio by yamcs.
the class TabEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// init tabs
int i = 0;
for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
if (child instanceof GroupingContainerModel) {
child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, true);
child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, false);
getTabFigure().addTab((String) getWidgetModel().getPropertyValue(TabModel.makeTabPropID(TabProperty.TITLE.propIDPre, i)));
tabItemList.add(i, new TabItem(getWidgetModel(), i, (GroupingContainerModel) child));
for (TabProperty tabProperty : TabProperty.values()) setTabProperty(i, tabProperty, getWidgetModel().getPropertyValue(TabModel.makeTabPropID(tabProperty.propIDPre, i)));
i++;
}
}
IWidgetPropertyChangeHandler relocContainerHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, relocContainerHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, relocContainerHandler);
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setHorizontal((Boolean) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_HORIZONTAL_TABS, horizontalHandler);
IWidgetPropertyChangeHandler activeTabHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setActiveTabIndex((Integer) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_ACTIVE_TAB, activeTabHandler);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setMinimumTabHeight((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_MINIMUM_TAB_HEIGHT, handler);
IWidgetPropertyChangeHandler updateTabAreaSizeHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
updateTabAreaSize();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_BORDER_WIDTH, updateTabAreaSizeHandler);
registerTabPropertyChangeHandlers();
registerTabsAmountChangeHandler();
}
use of org.csstudio.opibuilder.widgets.model.TabModel.TabProperty in project yamcs-studio by yamcs.
the class TabEditPart method registerTabsAmountChangeHandler.
private void registerTabsAmountChangeHandler() {
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
TabModel model = getWidgetModel();
TabFigure figure = (TabFigure) refreshableFigure;
int currentTabAmount = figure.getTabAmount();
// add tabs
if ((Integer) newValue > currentTabAmount) {
for (int i = 0; i < (Integer) newValue - currentTabAmount; i++) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i + currentTabAmount);
model.setPropertyVisible(propID, true);
}
addTab();
}
} else if ((Integer) newValue < currentTabAmount) {
// remove tabs
for (int i = currentTabAmount - 1; i >= (Integer) newValue; i--) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i);
model.setPropertyVisible(propID, false);
}
removeTab();
}
setActiveTabIndex(0);
}
return true;
}
};
getWidgetModel().getProperty(TabModel.PROP_TAB_COUNT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
}
use of org.csstudio.opibuilder.widgets.model.TabModel.TabProperty in project yamcs-studio by yamcs.
the class TabEditPart method removeTab.
public synchronized void removeTab(int index) {
// setActiveTabIndex(index > 0 ? index-1 : getWidgetModel().getChildren().size()-1);
if (index < 0 || index >= getTabItemCount())
throw new IllegalArgumentException();
getWidgetModel().removeChild(getWidgetModel().getChildren().get(index));
getTabFigure().removeTab(index);
tabItemList.remove(index);
// left shift tab's properties
for (int j = index; j < getWidgetModel().getChildren().size(); j++) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID1 = TabModel.makeTabPropID(tabProperty.propIDPre, j);
String propID2 = TabModel.makeTabPropID(tabProperty.propIDPre, j + 1);
getWidgetModel().setPropertyValue(propID1, getWidgetModel().getPropertyValue(propID2));
}
}
// updateTabItemsWithModel();
// update property sheet
getWidgetModel().setPropertyValue(TabModel.PROP_TAB_COUNT, getWidgetModel().getChildren().size(), false);
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, getWidgetModel().getChildren().size());
getWidgetModel().setPropertyVisible(propID, false);
}
// update active tab index to the new added tab
updateTabAreaSize();
setActiveTabIndex(index >= getWidgetModel().getChildren().size() ? index - 1 : index);
}
Aggregations