diff --git a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java index 30ccd9c3c23593eb71c38145875e965e975fd2de..4919db5d3e199fa219916b9eb24c954ac5ab68e4 100644 --- a/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java +++ b/de.hftstuttgart.buildingphysics.application/src/de/hftstuttgart/buildingphysics/application/handlers/NewHandler.java @@ -12,6 +12,7 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.XMLResource; import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; import org.eclipse.swt.widgets.Shell; @@ -27,19 +28,25 @@ public class NewHandler { if (pathToNewCatalog != null) { // create new catalog with resource at above path final AdapterFactoryEditingDomain domain = HandlerUtils.createEditingDomain(); - final Resource energyCatalogResource = domain.createResource("file://" + pathToNewCatalog); - final EObject energyCatalog = EcoreUtil.create(BuildingPhysicsPackage.eINSTANCE.getBuildingPhysicsCatalog()); - energyCatalogResource.getContents().add(energyCatalog); + final Resource catalogResource = domain.createResource("file://" + pathToNewCatalog); + + // assume default XMI factory was used to create an XML resource + if (catalogResource instanceof XMLResource) { + ((XMLResource)catalogResource).setEncoding("UTF-8"); + } + + final EObject catalog = EcoreUtil.create(BuildingPhysicsPackage.eINSTANCE.getBuildingPhysicsCatalog()); + catalogResource.getContents().add(catalog); // store new (empty) resource at selected path try { - energyCatalogResource.save(null); + catalogResource.save(null); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - HandlerUtils.createNewPartWithCatalog(application.getContext(), partService, energyCatalogResource); + HandlerUtils.createNewPartWithCatalog(application.getContext(), partService, catalogResource); } } } \ No newline at end of file