use of org.csstudio.opibuilder.widgets.model.GroupingContainerModel in project yamcs-studio by yamcs.
the class TabEditPart method addTab.
/**
*Add a TabItem to the index;
* @param index
* @param tabItem
*/
public synchronized void addTab(int index, TabItem tabItem) {
if (index < 0 || index > getTabItemCount())
throw new IllegalArgumentException();
if (index >= TabModel.MAX_TABS_AMOUNT)
return;
GroupingContainerModel groupingContainerModel = tabItem.getGroupingContainerModel();
getWidgetModel().addChild(index, groupingContainerModel);
getTabFigure().addTab((String) tabItem.getPropertyValue(TabProperty.TITLE), index);
tabItemList.add(index, tabItem);
initTabLabel(index, tabItem);
rightShiftTabProperties(index);
// apply tab properties from TabItem to TabModel
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, index);
getWidgetModel().setPropertyValue(propID, tabItem.getPropertyValue(tabProperty));
}
// 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() - 1);
getWidgetModel().setPropertyVisible(propID, true);
}
// update active tab index to the new added tab
updateTabAreaSize();
setActiveTabIndex(index);
}
use of org.csstudio.opibuilder.widgets.model.GroupingContainerModel 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.GroupingContainerModel in project yamcs-studio by yamcs.
the class LockUnlockChildrenAction method run.
@Override
public void run(IAction action) {
final GroupingContainerModel containerModel = getSelectedContainer();
Command cmd = createLockUnlockCommand(containerModel);
execute(cmd);
}
use of org.csstudio.opibuilder.widgets.model.GroupingContainerModel in project yamcs-studio by yamcs.
the class CreateGroupAction method run.
@Override
public void run(IAction action) {
var originalSelectedWidgets = getSelectedWidgetModels();
var compoundCommand = new CompoundCommand("Create Group");
List<AbstractWidgetModel> selectedWidgets = new ArrayList<>();
selectedWidgets.addAll(originalSelectedWidgets);
// remove the selected widgets which are children of another selected widget.
for (var widget : originalSelectedWidgets) {
if (widget instanceof DisplayModel) {
selectedWidgets.remove(widget);
continue;
}
if (widget instanceof AbstractContainerModel) {
for (var child : originalSelectedWidgets) {
if (((AbstractContainerModel) widget).getChildren().contains(child)) {
selectedWidgets.remove(child);
}
}
}
}
var minDepth = Integer.MAX_VALUE;
int minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE;
var minDepthWidget = selectedWidgets.get(0);
for (var widget : selectedWidgets) {
var leftX = widget.getLocation().x;
var upY = widget.getLocation().y;
var rightX = widget.getLocation().x + widget.getSize().width;
var bottomY = widget.getLocation().y + widget.getSize().height;
var depth = widget.getNestedDepth();
if (leftX < minX) {
minX = leftX;
}
if (upY < minY) {
minY = upY;
}
if (rightX > maxX) {
maxX = rightX;
}
if (bottomY > maxY) {
maxY = bottomY;
}
if (minDepth > depth) {
minDepth = depth;
minDepthWidget = widget;
}
}
// Orphan order should be reversed so that undo operation has the correct order.
var widgetsArray = selectedWidgets.toArray(new AbstractWidgetModel[selectedWidgets.size()]);
for (var i = widgetsArray.length - 1; i >= 0; i--) {
compoundCommand.add(new OrphanChildCommand(widgetsArray[i].getParent(), widgetsArray[i]));
}
var groupingContainerModel = new GroupingContainerModel();
SchemaService.getInstance().applySchema(groupingContainerModel);
// the parent should be the widget with minimum nested depth
var parent = minDepthWidget.getParent();
var borderWidth = 0;
if (groupingContainerModel.getBorderStyle() == BorderStyle.GROUP_BOX) {
borderWidth = 30;
}
groupingContainerModel.setPropertyValue(GroupingContainerModel.PROP_LOCK_CHILDREN, true);
groupingContainerModel.setPropertyValue(GroupingContainerModel.PROP_SHOW_SCROLLBAR, false);
compoundCommand.add(new WidgetCreateCommand(groupingContainerModel, parent, new Rectangle(minX, minY, maxX - minX + borderWidth, maxY - minY + borderWidth), false));
for (var widget : selectedWidgets) {
compoundCommand.add(new AddWidgetCommand(groupingContainerModel, widget, new Rectangle(widget.getLocation().translate(-minX, -minY), widget.getSize())));
}
execute(compoundCommand);
}
use of org.csstudio.opibuilder.widgets.model.GroupingContainerModel in project yamcs-studio by yamcs.
the class SelectAllInGroupAction method run.
@Override
public void run(IAction action) {
GroupingContainerModel containerModel = getContainerModel();
containerModel.selectWidgets(containerModel.getChildren(), false);
}
Aggregations