diff options
Diffstat (limited to 'plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/resource/TableResourceFactory.java')
-rw-r--r-- | plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/resource/TableResourceFactory.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/resource/TableResourceFactory.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/resource/TableResourceFactory.java new file mode 100644 index 00000000000..0777c8a5fc7 --- /dev/null +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/resource/TableResourceFactory.java @@ -0,0 +1,66 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.nattable.resource; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMIResource; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.eclipse.gmf.runtime.emf.core.internal.util.EMFCoreConstants; + +/** + * The resource factory for the properties files. + * + * @since 3.0 + */ +@SuppressWarnings("restriction") +public class TableResourceFactory extends XMIResourceFactoryImpl { + + /** The save options. */ + private static final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); + + static { + saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); + saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED); + saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true); + saveOptions.put(XMIResource.OPTION_ENCODING,"UTF-8"); //$NON-NLS-1$ + saveOptions.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE); + saveOptions.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD); + } + + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl#createResource(org.eclipse.emf.common.util.URI) + */ + @Override + public Resource createResource(final URI uri) { + + final XMIResource resource = new TableResource(uri); + + if (!resource.getEncoding().equals(EMFCoreConstants.XMI_ENCODING)) { + resource.setEncoding(EMFCoreConstants.XMI_ENCODING); + } + + resource.getDefaultSaveOptions().putAll(saveOptions); + + return resource; + } + +} |