diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.classpath b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..eca7bdba8f03f22510b7980a94dbfe10c16c0901 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.project b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.project new file mode 100644 index 0000000000000000000000000000000000000000..76c5ba3e8f0cba996a74131ddb17d91ad8837997 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>fr.centralesupelec.edf.riseclipse.cim.cim17.util</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.settings/org.eclipse.jdt.core.prefs b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..0c68a61dca867ceb49e79d2402935261ec3e3809 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/META-INF/MANIFEST.MF b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..f32b498ca0f575dcbd73d0da132f13a37d46d7e0 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: fr.centralesupelec.edf.riseclipse.cim.cim17.util;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Vendor: %providerName +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.ecore.xmi;visibility:=reexport, + fr.centralesupelec.edf.riseclipse;bundle-version="1.0.0", + fr.centralesupelec.edf.riseclipse.util;bundle-version="1.0.0", + fr.centralesupelec.edf.riseclipse.cim.headerModel;bundle-version="1.0.0", + fr.centralesupelec.edf.riseclipse.cim.util;bundle-version="1.0.0" +Bundle-ActivationPolicy: lazy +Export-Package: fr.centralesupelec.edf.riseclipse.cim.cim17.util diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/build.properties b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..0053d4b929bbd5ccbf6cef97890f1c548b1964d4 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/build.properties @@ -0,0 +1,18 @@ +# Copyright (c) 2016 CentraleSupélec & EDF. +# 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 +# +# This file is part of the RiseClipse tool +# +# Contributors: +# Computer Science Department, CentraleSupélec : initial implementation +# Contacts: +# Dominique.Marcadet@centralesupelec.fr +# + +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/plugin.properties b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/plugin.properties new file mode 100644 index 0000000000000000000000000000000000000000..6dd78e5f5d72ba208b5dd9ee0a8e0725e4de96cc --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/plugin.properties @@ -0,0 +1,16 @@ +# Copyright (c) 2016 CentraleSupélecec & EDF. +# 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 +# +# This file is part of the RiseClipse tool +# +# Contributors: +# Computer Science Department, CentraleSupélec : initial implementation +# Contacts: +# Dominique.Marcadet@centralesupelec.fr +# + +pluginName = RiseClipse Iec61970cim17 general Metamodel +providerName = CentraleSupélec & EDF diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimConstants.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..69b3a5817c86e09f9574e52aeb91b285f8808f6d --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimConstants.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + + +public class CimConstants extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimConstants { + + // CimPackage is specific to each concrete Cim17 metamodel, so we cannot get it here, + // but we prefer to have a generic Cim17 package + //public static final String cimURI = CimPackage.eNS_URI; + public static final String cimURI = "http://iec.ch/TC57/2016/CIM-schema-cim17"; + public static final String cimURISharp = cimURI + "#"; +} diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceFactoryImpl.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceFactoryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a7e644ae4d46d32de3a6115e8f3cb85520301cd5 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceFactoryImpl.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + +import fr.centralesupelec.edf.riseclipse.cim.cim17.util.CimResourceHandler; + +/** + * <!-- begin-user-doc --> + * The <b>Resource Factory</b> associated with the package. + * <!-- end-user-doc --> + * @see fr.centralesupelec.edf.riseclipse.cim.cim17.iec61970cim17v16.cim.util.CimResourceImpl + * @generated NOT + */ +public abstract class CimResourceFactoryImpl extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimResourceFactoryImpl { + + @Override + protected CimResourceHandler createCimResourceHandler() { + return new CimResourceHandler(); + } + +} //CimResourceFactoryImpl diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceHandler.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..d8a79870aaa107ec46e52cad6e1602a76014b99f --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceHandler.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + +import java.io.OutputStream; +import java.util.Map; + +import org.eclipse.emf.ecore.xmi.XMLResource; + +public class CimResourceHandler extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimResourceHandler { + + static final String xmlDeclaration = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"; + + @Override + public void preSave( XMLResource resource, OutputStream outputStream, Map< ?, ? > options ) { + super.preSave( resource, outputStream, options, CimConstants.cimURI ); + } + +} diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceImpl.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..782d8b6fa8d637a960ec865d97ef3367ea2ca8ce --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimResourceImpl.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.xmi.XMLHelper; +import org.eclipse.emf.ecore.xmi.XMLSave; + +/** + * <!-- begin-user-doc --> + * The <b>Resource </b> associated with the package. + * <!-- end-user-doc --> + * @see fr.centralesupelec.edf.riseclipse.cim.cim17.iec61970cim17v16.cim.util.CimResourceFactoryImpl + * @generated + */ +public abstract class CimResourceImpl extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimResourceImpl { + + /** + * Creates an instance of the resource. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param uri the URI of the new resource. + * @generated NOT + */ + public CimResourceImpl( URI uri ) { + super( uri ); + } + + @Override + protected XMLSave createXMLSave() { + return new CimXMLSaveImpl( createXMLHelper() ); + } + + @Override + protected XMLHelper createXMLHelper() { + return new CimXMLHelperImpl( this ); + } + +} // CimResourceImpl diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHandler.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..198a79cada693b0a3f32c4e6705f393bdf9b0ff5 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHandler.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.xmi.XMLHelper; +import org.eclipse.emf.ecore.xmi.XMLResource; + +public abstract class CimXMLHandler extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimXMLHandler { + + public CimXMLHandler( XMLResource xmiResource, XMLHelper helper, Map< ?, ? > options ) { + super( CimConstants.cimURI, xmiResource, helper, options ); + } + + @Override + protected boolean setEnumValue( EObject object, EStructuralFeature feature, String resource ) { + if( resource.startsWith( CimConstants.cimURISharp ) ) { + int enumNameLength = feature.getEType().getName().length(); + // do not call fr.centralesupelec.riseclipse.cim.util.cimxml.CimXMLHandler.setFeatureValue to avoid infinite recursion + // call instead org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler.setFeatureValue + // We use the fact that SAXXMLHandler.setFeatureValue( EObject, EStructuralFeature, Object ) call + // SAXXMLHandler.setFeatureValue( EObject, EStructuralFeature, Object, -1 ) + super.setFeatureValue( object, feature, + resource.substring( CimConstants.cimURISharp.length() + enumNameLength + 1 ), -1 ); + return true; + } + return false; + } + +} diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHelperImpl.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHelperImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2d1b7fb87d48bf249aab15d671e3f2fbc1cef573 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLHelperImpl.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + + +public class CimXMLHelperImpl extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimXMLHelperImpl { + + public CimXMLHelperImpl( CimResourceImpl cimResourceImpl ) { + super( cimResourceImpl ); + } + + @Override + public String getURI( String prefix ) { + String uri = super.getURI( prefix ); + if( CimConstants.cimURISharp.equals( uri )) return CimConstants.cimURI; + return uri; + } + +} diff --git a/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLSaveImpl.java b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLSaveImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..105a11fd0a3b49baf0f5f3e0195c6c1836358f92 --- /dev/null +++ b/fr.centralesupelec.edf.riseclipse.cim.cim17.util/src/fr/centralesupelec/edf/riseclipse/cim/cim17/util/CimXMLSaveImpl.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2016 CentraleSupélec & EDF. + * 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 + * + * This file is part of the RiseClipse tool + * + * Contributors: + * Computer Science Department, CentraleSupélec : initial implementation + * Contacts: + * Dominique.Marcadet@centralesupelec.fr + * + */ +package fr.centralesupelec.edf.riseclipse.cim.cim17.util; + +import java.util.Map; + +import org.eclipse.emf.ecore.xmi.XMLHelper; + +public class CimXMLSaveImpl extends fr.centralesupelec.edf.riseclipse.cim.util.cimxml.CimXMLSaveImpl { + + public CimXMLSaveImpl( XMLHelper helper ) { + super( CimConstants.cimURI, helper ); + } + + public CimXMLSaveImpl( Map< ?, ? > options, XMLHelper helper, String encoding ) { + super( CimConstants.cimURI, options, helper, encoding ); + } + + public CimXMLSaveImpl( Map< ?, ? > options, XMLHelper helper, String encoding, String xmlVersion ) { + super( CimConstants.cimURI, options, helper, encoding, xmlVersion ); + } + +}