use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class ArrayModel method addChild.
@Override
public synchronized void addChild(AbstractWidgetModel child, boolean changeParent) {
if (!getChildren().isEmpty())
return;
// child should not be scalable because their size are layoutted by the array figure.
child.setScaleOptions(false, false, false);
super.addChild(child, changeParent);
for (int i = 1; i < getVisibleElementsCount(); i++) {
try {
AbstractWidgetModel clone = XMLUtil.XMLElementToWidget(XMLUtil.widgetToXMLElement(child));
super.addChild(clone, changeParent);
} catch (Exception e) {
ErrorHandlerUtil.handleError("Failed to generate copy of the element widget in array widget.", e);
}
}
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class GroupingContainerModel method rotate90.
@Override
public void rotate90(boolean clockwise) {
boolean oldLock = isLocked();
setPropertyValue(PROP_LOCK_CHILDREN, false);
Point center = new Point(getWidth() / 2, getHeight() / 2);
for (AbstractWidgetModel abstractWidgetModel : getChildren()) {
abstractWidgetModel.rotate90(clockwise, center);
}
Point oldLoc = getLocation();
super.rotate90(clockwise);
Point newLoc = getLocation();
int dx = newLoc.x - oldLoc.x;
int dy = newLoc.y - oldLoc.y;
// move back
for (AbstractWidgetModel abstractWidgetModel : getChildren()) {
abstractWidgetModel.setLocation(abstractWidgetModel.getLocation().translate(-dx, -dy));
}
setPropertyValue(PROP_LOCK_CHILDREN, oldLock);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class PastePropertiesAction method createPasteCommand.
public Command createPasteCommand() {
PropertiesCopyData propData = getPropetiesCopyDataFromClipboard();
CompoundCommand cmd = new CompoundCommand("Paste Properties");
for (AbstractWidgetModel targetWidget : getSelectedWidgetModels()) {
for (String prop_id : propData.getPropIDList()) {
if (targetWidget.getAllPropertyIDs().contains(prop_id)) {
cmd.add(new SetWidgetPropertyCommand(targetWidget, prop_id, propData.getWidgetModel().getPropertyValue(prop_id)));
}
}
}
return cmd;
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class PasteWidgetsAction method getWidgetsIntrinsicRelativePositions.
private List<Point> getWidgetsIntrinsicRelativePositions(List<AbstractWidgetModel> widgets) {
PointList pointList = new PointList(widgets.size());
for (AbstractWidgetModel widgetModel : widgets) {
pointList.addPoint(widgetModel.getLocation());
}
Point upperLeftCorner = pointList.getBounds().getLocation();
List<Point> result = new ArrayList<Point>(widgets.size());
for (int i = 0; i < widgets.size(); i++) {
result.add(pointList.getPoint(i).translate(-upperLeftCorner.x, -upperLeftCorner.y));
}
return result;
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class PropertiesCopyDataTransfer method nativeToJava.
@Override
protected Object nativeToJava(TransferData transferData) {
if (!isSupportedType(transferData))
return null;
byte[] bytes = (byte[]) super.nativeToJava(transferData);
if (bytes == null)
return null;
try {
SAXBuilder saxBuilder = new SAXBuilder();
// $NON-NLS-1$
Document doc = saxBuilder.build(new ByteArrayInputStream(bytes));
Element root = doc.getRootElement();
List<String> propIDList = new ArrayList<String>();
AbstractWidgetModel widgetModel = null;
for (Object o : root.getChildren()) {
if (o instanceof Element) {
Element e = (Element) o;
if (e.getName().equals(CopyPropertiesAction.PROPID_ELEMENT))
for (Object po : e.getChildren()) {
Element pe = (Element) po;
propIDList.add(pe.getName());
}
else
widgetModel = XMLUtil.XMLElementToWidget(e);
}
}
return new PropertiesCopyData(widgetModel, propIDList);
} catch (Exception e) {
// $NON-NLS-1$
OPIBuilderPlugin.getLogger().log(Level.WARNING, "Failed to transfer XML to widget", e);
}
return null;
}
Aggregations