use of org.csstudio.opibuilder.model.AbstractContainerModel in project yamcs-studio by yamcs.
the class FixedPointsConnectionRouter method getScrollPaneImpl.
private ScrollPane getScrollPaneImpl() {
if (connectionModel != null) {
if (connectionModel.getScrollPane() != null) {
return connectionModel.getScrollPane();
} else {
// are both connected widgets defined - this should be always true
if ((connectionModel.getSource() == null) || (connectionModel.getTarget() == null))
return null;
AbstractContainerModel sourceModel = connectionModel.getSource().getParent();
AbstractContainerModel targetModel = connectionModel.getTarget().getParent();
// if one of them is null, then at least one end if the connection is in the top-most container. No translation.
if ((sourceModel == null) || (targetModel == null))
return null;
// otherwise, see if any of them is scrollable
AbstractScrollableEditpart sourceEditpart = getScrollable(sourceModel.getEditPart());
AbstractScrollableEditpart targetEditpart = getScrollable(targetModel.getEditPart());
// if one of them is not linking container, then return null
if ((sourceEditpart == null) || (targetEditpart == null))
return null;
// now we have two options:
// - one linking container is inside the other
// - they are not one inside the other, but they have common parent
// option one?
ScrollPane scrollPane = getScrollPaneForContained(sourceEditpart, targetEditpart);
if (scrollPane != null)
return scrollPane;
// option two
return getCommonScrollableParent(sourceEditpart, targetEditpart);
}
}
return null;
}
use of org.csstudio.opibuilder.model.AbstractContainerModel in project yamcs-studio by yamcs.
the class WidgetXYLayoutEditPolicy method createAddCommand.
@SuppressWarnings("deprecation")
@Override
protected Command createAddCommand(EditPart child, Object constraint) {
if (!(child instanceof AbstractBaseEditPart) || !(constraint instanceof Rectangle))
return super.createAddCommand(child, constraint);
AbstractContainerModel container = (AbstractContainerModel) getHost().getModel();
AbstractWidgetModel widget = (AbstractWidgetModel) child.getModel();
CompoundCommand result = new CompoundCommand("Adding widgets to container");
result.add(new AddWidgetCommand(container, widget, (Rectangle) constraint));
return result;
}
use of org.csstudio.opibuilder.model.AbstractContainerModel in project yamcs-studio by yamcs.
the class XMLUtil method XMLElementToWidgetSub.
private static AbstractWidgetModel XMLElementToWidgetSub(Element element, DisplayModel displayModel, List<IPath> trace, final MacrosInput macrosInput_) throws Exception {
if (element == null)
return null;
AbstractWidgetModel result = null;
if (WIDGET_TAGS.contains(element.getName())) {
result = fillWidgets(element, displayModel);
if (result instanceof AbstractContainerModel)
fillLinkingContainersSub((AbstractContainerModel) result, trace, macrosInput_);
fillConnections(element, displayModel);
return result;
} else {
String errorMessage = "Unknown Tag: " + element.getName();
ConsoleService.getInstance().writeError(errorMessage);
return null;
}
}
use of org.csstudio.opibuilder.model.AbstractContainerModel in project yamcs-studio by yamcs.
the class XMLUtil method fillWidgets.
/**
* Convert XML Element to a widget model.
*
* @param element
* @param displayModel
* the root display model. If root of the element is a display, use this display model as root model
* instead of creating a new one. If this is null, a new one will be created.
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public static AbstractWidgetModel fillWidgets(Element element, DisplayModel displayModel) throws Exception {
if (element == null)
return null;
AbstractWidgetModel rootWidgetModel = null;
// Determine root widget model
if (element.getName().equals(XMLTAG_DISPLAY)) {
if (displayModel != null)
rootWidgetModel = displayModel;
else
rootWidgetModel = new DisplayModel(null);
} else if (element.getName().equals(XMLTAG_WIDGET)) {
String typeId = element.getAttributeValue(XMLATTR_TYPEID);
WidgetDescriptor desc = WidgetsService.getInstance().getWidgetDescriptor(typeId);
if (desc != null)
rootWidgetModel = desc.getWidgetModel();
if (rootWidgetModel == null) {
String errorMessage = NLS.bind("Fail to load the widget: {0}\n " + "The widget may not exist, as a consequence, the widget will be ignored.", typeId);
ErrorHandlerUtil.handleError(errorMessage, new Exception("Widget does not exist."));
return null;
}
} else if (element.getName().equals(XMLTAG_CONNECTION)) {
rootWidgetModel = new ConnectionModel(displayModel);
} else {
String errorMessage = "Unknown Tag: " + element.getName();
ConsoleService.getInstance().writeError(errorMessage);
return null;
}
setPropertiesFromXML(element, rootWidgetModel);
if (rootWidgetModel instanceof AbstractContainerModel) {
AbstractContainerModel container = (AbstractContainerModel) rootWidgetModel;
List children = element.getChildren();
Iterator iterator = children.iterator();
while (iterator.hasNext()) {
Element subElement = (Element) iterator.next();
if (subElement.getName().equals(XMLTAG_WIDGET))
container.addChild(fillWidgets(subElement, displayModel));
}
}
if (displayModel != null)
rootWidgetModel.processVersionDifference(displayModel.getBOYVersion());
return rootWidgetModel;
}
Aggregations