use of org.eclipse.emf.ecore.xmi.XMLResource in project mylyn.docs by eclipse.
the class OCFResourceFactoryImpl method createResource.
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri) {
XMLResource result = new OCFResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
use of org.eclipse.emf.ecore.xmi.XMLResource in project mylyn.docs by eclipse.
the class DCResourceFactoryImpl method createResource.
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri) {
XMLResource result = new DCResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
use of org.eclipse.emf.ecore.xmi.XMLResource in project InformationSystem by ObeoNetwork.
the class ClassDiagramGenerator method removeOptionalElements.
private void removeOptionalElements(Collection<GenerationInfo> generationInfos, Resource vsmFromTemplate) {
// Remove optional elements
if (vsmFromTemplate instanceof XMLResource) {
Map<EObject, AnyType> eObjectToExtensionMap = ((XMLResource) vsmFromTemplate).getEObjectToExtensionMap();
Map<String, Collection<EObject>> optionalNodes = getOptionalNodes(eObjectToExtensionMap);
for (Entry<String, Collection<EObject>> optionalNodeEntry : optionalNodes.entrySet()) {
String optionalNodeId = optionalNodeEntry.getKey();
if (optionalNodeId.startsWith("{")) {
optionalNodeId = optionalNodeId.substring(1);
}
if (optionalNodeId.endsWith("}")) {
optionalNodeId = optionalNodeId.substring(0, optionalNodeId.length() - 1);
}
// Check if we have informations on this node
boolean toBeDeleted = false;
for (GenerationInfo generationInfo : generationInfos) {
Boolean optionalNodeActivated = generationInfo.getBooleanInfos().get(optionalNodeId);
if (optionalNodeActivated == Boolean.FALSE) {
toBeDeleted = true;
break;
}
}
if (toBeDeleted) {
// Remove the node
for (EObject object : optionalNodeEntry.getValue()) {
EcoreUtil.delete(object);
}
}
}
}
}
use of org.eclipse.emf.ecore.xmi.XMLResource in project InformationSystem by ObeoNetwork.
the class AbstractTransformationTest method serialize.
protected String serialize(EObject root) throws IOException {
if (root == null)
return "";
final EObject copyRoot = root;
// Get IDs map to be able to change UUID with relative fragment
Map<String, String> idsMap = getIdsMap(copyRoot);
final StringWriter writer = new StringWriter();
final Map<String, Object> options = new HashMap<String, Object>();
options.put(XMLResource.OPTION_ENCODING, System.getProperty("file.encoding"));
// Should not throw ClassCast since uri calls for an xml resource
((XMLResource) copyRoot.eResource()).save(writer, options);
String result = writer.toString();
writer.flush();
// Replace Ids
for (Entry<String, String> entry : idsMap.entrySet()) {
result = result.replaceAll(entry.getKey(), entry.getValue());
}
return result;
}
use of org.eclipse.emf.ecore.xmi.XMLResource in project jbpm by kiegroup.
the class BPMN2ColorTest method testColorAttributes.
@SuppressWarnings("unchecked")
public void testColorAttributes() throws Exception {
XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
inResource.setEncoding("UTF-8");
DocumentRoot documentRoot = ColorFactory.eINSTANCE.createDocumentRoot();
documentRoot.setBackgroundColor("#FFFFFF");
documentRoot.setBorderColor("#000000");
documentRoot.setColor("#AAAAAA");
inResource.getContents().add(documentRoot);
DocumentRoot outRoot = (DocumentRoot) inResource.getContents().get(0);
assertNotNull(outRoot);
assertEquals(outRoot.getBackgroundColor(), "#FFFFFF");
assertEquals(outRoot.getBorderColor(), "#000000");
assertEquals(outRoot.getColor(), "#AAAAAA");
}
Aggregations