use of org.csstudio.opibuilder.datadefinition.PropertiesCopyData 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.datadefinition.PropertiesCopyData 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