use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class WidgetDeleteCommand method getAllConnections.
private List<ConnectionModel> getAllConnections(AbstractWidgetModel widget, boolean source) {
List<ConnectionModel> result = new ArrayList<ConnectionModel>();
result.addAll(source ? widget.getSourceConnections() : widget.getTargetConnections());
if (widget instanceof AbstractContainerModel) {
for (AbstractWidgetModel child : ((AbstractContainerModel) widget).getAllDescendants()) {
result.addAll(source ? child.getSourceConnections() : child.getTargetConnections());
}
}
return result;
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class ContainerTreeEditpart method activate.
@Override
public void activate() {
super.activate();
childrenPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getOldValue() instanceof Integer) {
addChild(createChild(evt.getNewValue()), ((Integer) evt.getOldValue()).intValue());
} else if (evt.getOldValue() instanceof AbstractWidgetModel) {
EditPart child = (EditPart) getViewer().getEditPartRegistry().get(evt.getOldValue());
if (child != null)
removeChild(child);
} else
refreshChildren();
refreshVisuals();
}
};
getWidgetModel().getChildrenProperty().addPropertyChangeListener(childrenPropertyChangeListener);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class XMLUtil method fillLinkingContainersSub.
private static void fillLinkingContainersSub(AbstractContainerModel container, List<IPath> trace, final MacrosInput macrosInput_) throws Exception {
if (container instanceof AbstractLinkingContainerModel) {
AbstractLinkingContainerModel linkingContainer = (AbstractLinkingContainerModel) container;
List<IPath> tempTrace = new ArrayList<>();
tempTrace.addAll(trace);
fillLinkingContainerSub(linkingContainer, tempTrace, macrosInput_);
}
for (AbstractWidgetModel w : container.getAllDescendants()) {
if (w instanceof AbstractLinkingContainerModel) {
AbstractLinkingContainerModel linkingContainer = (AbstractLinkingContainerModel) w;
List<IPath> tempTrace = new ArrayList<>();
tempTrace.addAll(trace);
fillLinkingContainerSub(linkingContainer, tempTrace, macrosInput_);
}
}
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class XMLUtil method XMLElementToWidgetSub.
private static AbstractWidgetModel XMLElementToWidgetSub(Element element, DisplayModel displayModel, List<IPath> trace, 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 {
var errorMessage = "Unknown Tag: " + element.getName();
OPIBuilderPlugin.getLogger().log(Level.SEVERE, errorMessage);
return null;
}
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel 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)) {
var typeId = element.getAttributeValue(XMLATTR_TYPEID);
var desc = WidgetsService.getInstance().getWidgetDescriptor(typeId);
if (desc != null) {
rootWidgetModel = desc.getWidgetModel();
}
if (rootWidgetModel == null) {
var errorMessage = NLS.bind("Unknown widget: {0}", typeId);
ErrorHandlerUtil.handleError(errorMessage, new Exception("Widget does not exist."));
return null;
}
} else if (element.getName().equals(XMLTAG_CONNECTION)) {
rootWidgetModel = new ConnectionModel(displayModel);
} else {
var errorMessage = "Unknown Tag: " + element.getName();
OPIBuilderPlugin.getLogger().log(Level.SEVERE, errorMessage);
return null;
}
setPropertiesFromXML(element, rootWidgetModel);
if (rootWidgetModel instanceof AbstractContainerModel) {
var container = (AbstractContainerModel) rootWidgetModel;
var children = element.getChildren();
var iterator = children.iterator();
while (iterator.hasNext()) {
var 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