Search in sources :

Example 1 with PropertiesSelectDialog

use of org.csstudio.opibuilder.visualparts.PropertiesSelectDialog in project yamcs-studio by yamcs.

the class CopyPropertiesAction method run.

@Override
public void run() {
    PropertiesSelectDialog dialog = new PropertiesSelectDialog(null, getSelectedWidgetModels().get(0));
    if (dialog.open() == Window.OK) {
        List<String> propList = dialog.getOutput();
        if (!propList.isEmpty()) {
            AbstractWidgetModel widget = getSelectedWidgetModels().get(0);
            Element widgetElement = XMLUtil.widgetToXMLElement(widget);
            Element propertisElement = new Element(PROPID_ELEMENT);
            for (String propID : propList) {
                propertisElement.addContent(new Element(propID));
            }
            Element rootElement = new Element(ROOT_ELEMENT);
            rootElement.addContent(widgetElement);
            rootElement.addContent(propertisElement);
            XMLOutputter xmlOutputter = new XMLOutputter(Format.getRawFormat());
            String xmlString = xmlOutputter.outputString(rootElement);
            ((OPIEditor) getWorkbenchPart()).getClipboard().setContents(new Object[] { xmlString }, new Transfer[] { PropertiesCopyDataTransfer.getInstance() });
        }
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Element(org.jdom.Element) PropertiesSelectDialog(org.csstudio.opibuilder.visualparts.PropertiesSelectDialog)

Aggregations

AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 PropertiesSelectDialog (org.csstudio.opibuilder.visualparts.PropertiesSelectDialog)1 Element (org.jdom.Element)1 XMLOutputter (org.jdom.output.XMLOutputter)1