use of org.knime.workbench.ui.metainfo.model.MetaGUIElement in project knime-core by knime.
the class WorkflowSetMetaInfoEditor method createPartControl.
/**
* {@inheritDoc}
*/
@Override
public void createPartControl(final Composite parent) {
m_toolkit = new FormToolkit(parent.getDisplay());
m_form = m_toolkit.createScrolledForm(parent);
m_form.setText(getPartName());
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = true;
m_form.getBody().setLayout(layout);
// content composite
Composite content = m_toolkit.createComposite(m_form.getBody());
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 20;
layout.makeColumnsEqualWidth = false;
content.setLayout(layout);
// placeholder composite
m_toolkit.createComposite(m_form.getBody());
GridData layoutData = new GridData();
layoutData.minimumWidth = 100;
layoutData.widthHint = 100;
layoutData.verticalAlignment = SWT.TOP;
for (MetaGUIElement element : m_elements) {
LOGGER.debug("element " + element.getLabel());
Label label = m_toolkit.createLabel(content, element.getLabel() + ": ");
label.setLayoutData(layoutData);
element.createGUIElement(m_toolkit, content);
element.addListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
setDirty(true);
}
});
}
m_form.reflow(true);
}
use of org.knime.workbench.ui.metainfo.model.MetaGUIElement in project knime-core by knime.
the class WorkflowSetMetaInfoEditor method doSave.
/**
* {@inheritDoc}
*/
@Override
public void doSave(final IProgressMonitor monitor) {
try {
URI path = ((IURIEditorInput) getEditorInput()).getURI();
File inputFile = new File(path);
SAXTransformerFactory fac = (SAXTransformerFactory) TransformerFactory.newInstance();
TransformerHandler handler = fac.newTransformerHandler();
Transformer t = handler.getTransformer();
t.setOutputProperty(OutputKeys.METHOD, "xml");
t.setOutputProperty(OutputKeys.INDENT, "yes");
OutputStream out = new FileOutputStream(inputFile);
handler.setResult(new StreamResult(out));
handler.startDocument();
AttributesImpl atts = new AttributesImpl();
atts.addAttribute(null, null, "nrOfElements", "CDATA", "" + m_elements.size());
handler.startElement(null, null, "KNIMEMetaInfo", atts);
monitor.beginTask("Saving meta information...", m_elements.size());
for (MetaGUIElement element : m_elements) {
element.saveTo(handler);
monitor.worked(1);
}
handler.endElement(null, null, "KNIMEMetaInfo");
handler.endDocument();
out.close();
setDirty(false);
} catch (Exception e) {
LOGGER.error("An error ocurred while saving " + getEditorInput().toString(), e);
} finally {
monitor.done();
}
}
Aggregations