use of eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ClassType in project hale by halestudio.
the class TextEntityTray method createContents.
/**
* @see org.eclipse.jface.dialogs.DialogTray#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().applyTo(page);
Label label = new Label(page, SWT.NONE);
ObjectFactory of = new ObjectFactory();
JAXBElement<?> element = null;
if (entity instanceof PropertyType) {
element = of.createProperty((PropertyType) entity);
} else if (entity instanceof ClassType) {
element = of.createClass((ClassType) entity);
}
String text;
if (element != null) {
try {
JAXBContext jc = JAXBContext.newInstance(JaxbAlignmentIO.ALIGNMENT_CONTEXT, ObjectFactory.class.getClassLoader());
Marshaller m = jc.createMarshaller();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
m.marshal(element, doc);
text = XmlUtil.serialize((Element) doc.getFirstChild());
} catch (Exception e) {
text = e.getLocalizedMessage();
}
} else {
text = "###";
}
label.setText(text);
return page;
}
use of eu.esdihumboldt.hale.common.align.io.impl.internal.generated.ClassType in project hale by halestudio.
the class DOMEntityDefinitionHelper method typeFromDOM.
/**
* Converts the given element to a type entity definition. If any exception
* occurs <code>null</code> is returned.
*
* @param fragment the fragment to convert
* @param types the type index to use for unmarshalling
* @param ssid the schema space to use for unmarshalling
* @return the type entity definition or <code>null</code>
*/
public static TypeEntityDefinition typeFromDOM(Element fragment, TypeIndex types, SchemaSpaceID ssid) {
try {
JAXBContext jc = JAXBContext.newInstance(JaxbAlignmentIO.ALIGNMENT_CONTEXT, ClassType.class.getClassLoader());
Unmarshaller u = jc.createUnmarshaller();
// it will debug problems while unmarshalling
u.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
JAXBElement<ClassType> root = u.unmarshal(fragment, ClassType.class);
return resolver.resolveType(root.getValue(), types, ssid).getDefinition();
} catch (Exception e) {
return null;
}
}
Aggregations