Revision 451

View differences:

branches/modelio4.0.x/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" output="target/classes" path="src/main/java">
4
		<attributes>
5
			<attribute name="optional" value="true"/>
6
			<attribute name="maven.pomderived" value="true"/>
7
		</attributes>
8
	</classpathentry>
9
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10
		<attributes>
11
			<attribute name="maven.pomderived" value="true"/>
12
		</attributes>
13
	</classpathentry>
14
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15
		<attributes>
16
			<attribute name="optional" value="true"/>
17
			<attribute name="maven.pomderived" value="true"/>
18
			<attribute name="test" value="true"/>
19
		</attributes>
20
	</classpathentry>
21
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
22
		<attributes>
23
			<attribute name="maven.pomderived" value="true"/>
24
		</attributes>
25
	</classpathentry>
26
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
27
		<attributes>
28
			<attribute name="maven.pomderived" value="true"/>
29
		</attributes>
30
	</classpathentry>
31
	<classpathentry kind="output" path="target/classes"/>
32
</classpath>
0 33

  
branches/modelio4.0.x/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>javadesigner</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.m2e.core.maven2Builder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
	</buildSpec>
19
	<natures>
20
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
22
	</natures>
23
</projectDescription>
0 24

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/IJavaDesignerPeerModule.java
1
package org.modelio.module.javadesigner.api;
2

  
3
import java.io.File;
4
import java.util.Collection;
5
import org.modelio.api.module.IPeerModule;
6
import org.modelio.metamodel.mmextensions.infrastructure.ElementNotUniqueException;
7
import org.modelio.metamodel.mmextensions.infrastructure.ExtensionNotFoundException;
8
import org.modelio.metamodel.uml.statik.Artifact;
9
import org.modelio.metamodel.uml.statik.AssociationEnd;
10
import org.modelio.metamodel.uml.statik.Attribute;
11
import org.modelio.metamodel.uml.statik.Classifier;
12
import org.modelio.metamodel.uml.statik.NameSpace;
13
import org.modelio.metamodel.uml.statik.Package;
14

  
15
public interface IJavaDesignerPeerModule extends IPeerModule {
16
    public static final String MODULE_NAME = "JavaDesigner";
17

  
18
    void generate(final NameSpace element);
19

  
20
    void generate(final Collection<NameSpace> elements);
21

  
22
    void generateAntFile(final Artifact artifact);
23

  
24
    String executeTarget(final Artifact artifact, final String target);
25

  
26
    void updateModel(final Collection<NameSpace> elements);
27

  
28
    void generate(final NameSpace element, final boolean withGUI);
29

  
30
    void generate(final Collection<NameSpace> elements, final boolean withGUI);
31

  
32
    void generateAntFile(final Artifact artifact, final boolean withGUI);
33

  
34
    String executeTarget(final Artifact artifact, final String target, final boolean withGUI);
35

  
36
    void updateModel(final Collection<NameSpace> elements, final boolean withGUI);
37

  
38
    File getFilename(final NameSpace element);
39

  
40
    /**
41
     * Update all the accessors corresponding to this element (type, card, name...).
42
     * @throws ElementNotUniqueException
43
     * @param theAttribute The model element to synchronize accessors from.
44
     * @param createNewAccessors Indicates whereas the method should create accessors if necessary, or only synchronize the existing ones.
45
     * @return true if something changed in the model.
46
     */
47
    boolean updateAccessors(final Attribute theAttribute, final boolean createNewAccessors) throws CustomException, ElementNotUniqueException, ExtensionNotFoundException;
48

  
49
    /**
50
     * Update all the accessors corresponding to this element (type, card, name...).
51
     * @throws ElementNotUniqueException
52
     * @param theAssociationEnd The model element to synchronize accessors from.
53
     * @param createNewAccessors Indicates whereas the method should create accessors if necessary, or only synchronize the existing ones.
54
     * @return true if something changed in the model.
55
     */
56
    boolean updateAccessors(final AssociationEnd theAssociationEnd, final boolean createNewAccessors) throws CustomException, ElementNotUniqueException, ExtensionNotFoundException;
57

  
58
    /**
59
     * Check all operations, and deletes getters and setters that are no more linked to Attributes/AssociationEnds.
60
     * @return True if at least one operation was deleted.
61
     */
62
    boolean deleteAccessors(final Classifier theClassifier);
63

  
64
    void generateJavaDoc(final Package element, final boolean withGUI);
65

  
66
}
0 67

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerNoteTypes.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public interface JavaDesignerNoteTypes {
5
    public static final String ASSOCIATIONEND_JAVAINITVALUE = "JavaInitValue";
6

  
7
    public static final String ASSOCIATIONEND_JAVAINITVALUECOMMENT = "JavaInitValueComment";
8

  
9
    public static final String ATTRIBUTE_JAVAINITVALUECOMMENT = "JavaInitValueComment";
10

  
11
    public static final String CLASS_JAVAANNOTATION = "JavaAnnotation";
12

  
13
    public static final String CLASS_JAVABOTTOM = "JavaBottom";
14

  
15
    public static final String CLASS_JAVACODE = "JavaCode";
16

  
17
    public static final String CLASS_JAVACOMMENT = "JavaComment";
18

  
19
    public static final String CLASS_JAVADOC = "Javadoc";
20

  
21
    public static final String CLASS_JAVAHEADER = "JavaHeader";
22

  
23
    public static final String CLASS_JAVAMEMBERS = "JavaMembers";
24

  
25
    public static final String CLASS_JAVATOP = "JavaTop";
26

  
27
    public static final String DATATYPE_JAVABOTTOM = "JavaBottom";
28

  
29
    public static final String DATATYPE_JAVACOMMENT = "JavaComment";
30

  
31
    public static final String DATATYPE_JAVADOC = "Javadoc";
32

  
33
    public static final String DATATYPE_JAVAHEADER = "JavaHeader";
34

  
35
    public static final String DATATYPE_JAVAMEMBERS = "JavaMembers";
36

  
37
    public static final String DATATYPE_JAVAANNOTATION = "JavaAnnotation";
38

  
39
    public static final String DATATYPE_JAVATOP = "JavaTop";
40

  
41
    public static final String DEPENDENCY_SEEJAVADOC = "SeeJavadoc";
42

  
43
    public static final String ELEMENTIMPORT_JAVADOC = "Javadoc";
44

  
45
    public static final String ENUMERATIONLITERAL_JAVAANNOTATION = "JavaAnnotation";
46

  
47
    public static final String ENUMERATIONLITERAL_JAVACODE = "JavaCode";
48

  
49
    public static final String ENUMERATIONLITERAL_JAVACOMMENT = "JavaComment";
50

  
51
    public static final String ENUMERATIONLITERAL_JAVADOC = "Javadoc";
52

  
53
    public static final String ENUMERATIONLITERAL_JAVAINITVALUECOMMENT = "JavaInitValueComment";
54

  
55
    public static final String ENUMERATION_JAVAANNOTATION = "JavaAnnotation";
56

  
57
    public static final String ENUMERATION_JAVACOMMENT = "JavaComment";
58

  
59
    public static final String ENUMERATION_JAVADOC = "Javadoc";
60

  
61
    public static final String ENUMERATION_JAVAMEMBERS = "JavaMembers";
62

  
63
    public static final String FEATURE_JAVAANNOTATION = "JavaAnnotation";
64

  
65
    public static final String FEATURE_JAVACOMMENT = "JavaComment";
66

  
67
    public static final String FEATURE_JAVADOC = "Javadoc";
68

  
69
    public static final String INTERFACE_JAVAANNOTATION = "JavaAnnotation";
70

  
71
    public static final String INTERFACE_JAVABOTTOM = "JavaBottom";
72

  
73
    public static final String INTERFACE_JAVACODE = "JavaCode";
74

  
75
    public static final String INTERFACE_JAVACOMMENT = "JavaComment";
76

  
77
    public static final String INTERFACE_JAVADOC = "Javadoc";
78

  
79
    public static final String INTERFACE_JAVAHEADER = "JavaHeader";
80

  
81
    public static final String INTERFACE_JAVAMEMBERS = "JavaMembers";
82

  
83
    public static final String INTERFACE_JAVATOP = "JavaTop";
84

  
85
    public static final String JARFILE_ANTTARGET = "AntTarget";
86

  
87
    public static final String OPERATION_JAVACODE = "JavaCode";
88

  
89
    public static final String OPERATION_JAVARETURNED = "JavaReturned";
90

  
91
    public static final String OPERATION_JAVASUPER = "JavaSuper";
92

  
93
    public static final String PACKAGE_JAVAANNOTATION = "JavaAnnotation";
94

  
95
    public static final String PARAMETER_JAVAANNOTATION = "JavaAnnotation";
96

  
97
    public static final String PARAMETER_JAVADOC = "Javadoc";
98

  
99
}
0 100

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerProperties.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public interface JavaDesignerProperties {
5
    public static final String JAVA_LASTGENERATED = "Java.LastGenerated";
6

  
7
}
0 8

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerTagTypes.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public interface JavaDesignerTagTypes {
5
    public static final String ASSOCIATIONEND_JAVAARRAYDIMENSION = "JavaArrayDimension";
6

  
7
    public static final String ASSOCIATIONEND_JAVABIND = "JavaBind";
8

  
9
    public static final String ASSOCIATIONEND_JAVAFILTERACCESSOR = "JavaFilterAccessor";
10

  
11
    public static final String ASSOCIATIONEND_JAVAFINAL = "JavaFinal";
12

  
13
    public static final String ASSOCIATIONEND_JAVAFULLNAME = "JavaFullName";
14

  
15
    public static final String ASSOCIATIONEND_JAVAGENERATEACCESSOR = "JavaGenerateAccessor";
16

  
17
    public static final String ASSOCIATIONEND_JAVAIMPLEMENTATIONTYPE = "JavaImplementationType";
18

  
19
    public static final String ASSOCIATIONEND_JAVANOACCESSOR = "JavaNoAccessor";
20

  
21
    public static final String ASSOCIATIONEND_JAVAPUBLIC = "JavaPublic";
22

  
23
    public static final String ASSOCIATIONEND_JAVATRANSIENT = "JavaTransient";
24

  
25
    public static final String ASSOCIATIONEND_JAVATYPEEXPR = "JavaTypeExpr";
26

  
27
    public static final String ASSOCIATIONEND_JAVAVOLATILE = "JavaVolatile";
28

  
29
    public static final String ATTRIBUTE_JAVAARRAYDIMENSION = "JavaArrayDimension";
30

  
31
    public static final String ATTRIBUTE_JAVABIND = "JavaBind";
32

  
33
    /**
34
     * Compatibility mode : tag still handled at generation.
35
     */
36
    @Deprecated
37
    public static final String ATTRIBUTE_JAVABYTE = "JavaByte";
38

  
39
    public static final String ATTRIBUTE_JAVAECLIPSENLS = "JavaEclipseNLS";
40

  
41
    public static final String ATTRIBUTE_JAVAFILTERACCESSOR = "JavaFilterAccessor";
42

  
43
    public static final String ATTRIBUTE_JAVAFINAL = "JavaFinal";
44

  
45
    public static final String ATTRIBUTE_JAVAFULLNAME = "JavaFullName";
46

  
47
    public static final String ATTRIBUTE_JAVAGENERATEACCESSOR = "JavaGenerateAccessor";
48

  
49
    public static final String ATTRIBUTE_JAVAIMPLEMENTATIONTYPE = "JavaImplementationType";
50

  
51
    /**
52
     * Compatibility mode : tag still handled at generation.
53
     */
54
    @Deprecated
55
    public static final String ATTRIBUTE_JAVALONG = "JavaLong";
56

  
57
    public static final String ATTRIBUTE_JAVANOACCESSOR = "JavaNoAccessor";
58

  
59
    public static final String ATTRIBUTE_JAVAPUBLIC = "JavaPublic";
60

  
61
    /**
62
     * Compatibility mode : tag still handled at generation.
63
     */
64
    @Deprecated
65
    public static final String ATTRIBUTE_JAVASHORT = "JavaShort";
66

  
67
    public static final String ATTRIBUTE_JAVATRANSIENT = "JavaTransient";
68

  
69
    public static final String ATTRIBUTE_JAVATYPEEXPR = "JavaTypeExpr";
70

  
71
    public static final String ATTRIBUTE_JAVAVOLATILE = "JavaVolatile";
72

  
73
    public static final String ATTRIBUTE_JAVAWRAPPER = "JavaWrapper";
74

  
75
    public static final String CLASS_JAVABEAN = "JavaBean";
76

  
77
    public static final String CLASS_JAVABEANRESOURCE = "JavaBeanResource";
78

  
79
    public static final String CLASS_JAVAEXTENDS = "JavaExtends";
80

  
81
    public static final String CLASS_JAVAEXTERN = "JavaExtern";
82

  
83
    public static final String CLASS_JAVAFILENAME = "JavaFileName";
84

  
85
    public static final String CLASS_JAVAIMPLEMENTS = "JavaImplements";
86

  
87
    public static final String CLASS_JAVAIMPORT = "JavaImport";
88

  
89
    public static final String CLASS_JAVANAME = "JavaName";
90

  
91
    public static final String CLASS_JAVANOACCESSOR = "JavaNoAccessor";
92

  
93
    public static final String CLASS_JAVANOIMPORT = "JavaNoImport";
94

  
95
    public static final String CLASS_JAVANONPUBLIC = "JavaNonPublic";
96

  
97
    public static final String CLASS_JAVASTATIC = "JavaStatic";
98

  
99
    public static final String DATATYPE_JAVAEXTENDS = "JavaExtends";
100

  
101
    public static final String DATATYPE_JAVAEXTERN = "JavaExtern";
102

  
103
    public static final String DATATYPE_JAVAIMPORT = "JavaImport";
104

  
105
    public static final String DATATYPE_JAVANAME = "JavaName";
106

  
107
    public static final String DATATYPE_JAVANOIMPORT = "JavaNoImport";
108

  
109
    public static final String DATATYPE_JAVASTATIC = "JavaStatic";
110

  
111
    public static final String ELEMENTIMPORT_JAVAFULLNAME = "JavaFullName";
112

  
113
    public static final String ENUMERATIONLITERAL_JAVAARGUMENTS = "JavaArguments";
114

  
115
    public static final String ENUMERATION_JAVAIMPLEMENTS = "JavaImplements";
116

  
117
    public static final String ENUMERATION_JAVAIMPORT = "JavaImport";
118

  
119
    public static final String ENUMERATION_JAVANOIMPORT = "JavaNoImport";
120

  
121
    public static final String ENUMERATION_JAVASTATIC = "JavaStatic";
122

  
123
    public static final String FEATURE_JAVANAME = "JavaName";
124

  
125
    public static final String FEATURE_JAVANOINITVALUE = "JavaNoInitValue";
126

  
127
    public static final String FEATURE_JAVANOINVARIANT = "JavaNoInvariant";
128

  
129
    public static final String GENERALIZATION_JAVABIND = "JavaBind";
130

  
131
    public static final String GENERALIZATION_JAVAFULLNAME = "JavaFullName";
132

  
133
    public static final String GENERALIZATION_JAVANOCODE = "JavaNoCode";
134

  
135
    public static final String INTERFACEREALIZATION_JAVABIND = "JavaBind";
136

  
137
    public static final String INTERFACEREALIZATION_JAVAFULLNAME = "JavaFullName";
138

  
139
    public static final String INTERFACEREALIZATION_JAVANOCODE = "JavaNoCode";
140

  
141
    public static final String INTERFACE_JAVABEAN = "JavaBean";
142

  
143
    public static final String INTERFACE_JAVABEANRESOURCE = "JavaBeanResource";
144

  
145
    public static final String INTERFACE_JAVADOCUMENTEDANNOTATION = "JavaDocumentedAnnotation";
146

  
147
    public static final String INTERFACE_JAVAEXTENDS = "JavaExtends";
148

  
149
    public static final String INTERFACE_JAVAEXTERN = "JavaExtern";
150

  
151
    public static final String INTERFACE_JAVAFILENAME = "JavaFileName";
152

  
153
    public static final String INTERFACE_JAVAIMPLEMENTS = "JavaImplements";
154

  
155
    public static final String INTERFACE_JAVAIMPORT = "JavaImport";
156

  
157
    public static final String INTERFACE_JAVAINHERITEDANNOTATION = "JavaInheritedAnnotation";
158

  
159
    public static final String INTERFACE_JAVANAME = "JavaName";
160

  
161
    public static final String INTERFACE_JAVANOACCESSOR = "JavaNoAccessor";
162

  
163
    public static final String INTERFACE_JAVANOIMPORT = "JavaNoImport";
164

  
165
    public static final String INTERFACE_JAVANONPUBLIC = "JavaNonPublic";
166

  
167
    public static final String INTERFACE_JAVARETENTIONANNOTATION = "JavaRetentionAnnotation";
168

  
169
    public static final String INTERFACE_JAVASTATIC = "JavaStatic";
170

  
171
    public static final String INTERFACE_JAVATARGETANNOTATION = "JavaTargetAnnotation";
172

  
173
    public static final String JARFILE_ANTFILEPATH = "AntFilePath";
174

  
175
    public static final String JARFILE_JAVAMAINCLASS = "JavaMainClass";
176

  
177
    public static final String JARFILE_JAVASOURCESPATH = "JavaSourcesPath";
178

  
179
    public static final String JAVAANNOTATION_JAVADOCUMENTEDANNOTATION = "JavaDocumentedAnnotation";
180

  
181
    public static final String JAVAANNOTATION_JAVAINHERITEDANNOTATION = "JavaInheritedAnnotation";
182

  
183
    public static final String JAVAANNOTATION_JAVARETENTIONANNOTATION = "JavaRetentionAnnotation";
184

  
185
    public static final String JAVAANNOTATION_JAVATARGETANNOTATION = "JavaTargetAnnotation";
186

  
187
    public static final String JAVACOMPONENT_GENERATIONPATH = "GenerationPath";
188

  
189
    public static final String MODELELEMENT_JAVALASTGENERATED = "JavaLastGenerated";
190

  
191
    public static final String MODELELEMENT_JAVANOCODE = "JavaNoCode";
192

  
193
    public static final String MODELELEMENT__TODELETE = "_toDelete";
194

  
195
    public static final String OBJECT__TOGENERATE = "_toGenerate";
196

  
197
    public static final String OPERATION_JAVANATIVE = "JavaNative";
198

  
199
    public static final String OPERATION_JAVASTRICT = "JavaStrict";
200

  
201
    public static final String OPERATION_JAVASYNCHRONIZED = "JavaSynchronized";
202

  
203
    public static final String OPERATION_JAVATEMPLATEPARAMETERS = "JavaTemplateParameters";
204

  
205
    public static final String OPERATION_JAVATHROWNEXCEPTION = "JavaThrownException";
206

  
207
    public static final String PACKAGE_JAVABEANRESOURCE = "JavaBeanResource";
208

  
209
    public static final String PACKAGE_JAVAEXTERN = "JavaExtern";
210

  
211
    public static final String PACKAGE_JAVAIMPORT = "JavaImport";
212

  
213
    public static final String PACKAGE_JAVANAME = "JavaName";
214

  
215
    public static final String PACKAGE_JAVANOPACKAGE = "JavaNoPackage";
216

  
217
    public static final String PACKAGE_JAVAROOT = "JavaRoot";
218

  
219
    public static final String PARAMETER_JAVAARRAYDIMENSION = "JavaArrayDimension";
220

  
221
    public static final String PARAMETER_JAVABIND = "JavaBind";
222

  
223
    public static final String PARAMETER_JAVABYTE = "JavaByte";
224

  
225
    public static final String PARAMETER_JAVAFINAL = "JavaFinal";
226

  
227
    public static final String PARAMETER_JAVAFULLNAME = "JavaFullName";
228

  
229
    public static final String PARAMETER_JAVALONG = "JavaLong";
230

  
231
    public static final String PARAMETER_JAVASHORT = "JavaShort";
232

  
233
    public static final String PARAMETER_JAVATYPEEXPR = "JavaTypeExpr";
234

  
235
    public static final String PARAMETER_JAVAVARARGS = "JavaVarArgs";
236

  
237
    public static final String PARAMETER_JAVAWRAPPER = "JavaWrapper";
238

  
239
    public static final String PROJECT_JAVAMODULE = "JavaModule";
240

  
241
    public static final String RAISEDEXCEPTION_JAVAFULLNAME = "JavaFullName";
242

  
243
    public static final String TEMPLATEPARAMETER_JAVAEXTENDS = "JavaExtends";
244

  
245
    public static final String TEMPLATEPARAMETER_JAVAFULLNAME = "JavaFullName";
246

  
247
    public static final String JAVAASSOCIATIONENDPROPERTY_JAVAGETTERVISIBILITY = "JavaGetterVisibility";
248

  
249
    public static final String JAVAASSOCIATIONENDPROPERTY_JAVASETTERVISIBILITY = "JavaSetterVisibility";
250

  
251
    public static final String JAVAATTRIBUTEPROPERTY_JAVAGETTERVISIBILITY = "JavaGetterVisibility";
252

  
253
    public static final String JAVAATTRIBUTEPROPERTY_JAVASETTERVISIBILITY = "JavaSetterVisibility";
254

  
255
    public static final String JAVACOMPONENT_COPYRIGHTFILE = "CopyrightFile";
256

  
257
}
0 258

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/ISessionWithHandler.java
1
package org.modelio.module.javadesigner.api;
2

  
3
import org.modelio.api.modelio.model.event.IModelChangeHandler;
4

  
5
public interface ISessionWithHandler {
6

  
7
    IModelChangeHandler getModelChangeHandler();
8

  
9
}
0 10

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerParameters.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public interface JavaDesignerParameters {
5
    public static final String ACCESSIBLECLASSES = "AccessibleClasses";
6

  
7
    public static final String ACCESSORSGENERATION = "AccessorsGeneration";
8

  
9
    public static final String AUTOMATICALLYOPENJAVADOC = "AutomaticallyOpenJavadoc";
10

  
11
    public static final String COMPILATIONOPTIONS = "CompilationOptions";
12

  
13
    public static final String COMPILATIONPATH = "CompilationPath";
14

  
15
    public static final String CUSTOMIZATIONFILE = "CustomizationFile";
16

  
17
    public static final String DESCRIPTIONASJAVADOC = "DescriptionAsJavadoc";
18

  
19
    public static final String ENCODING = "Encoding";
20

  
21
    public static final String ERRORONFIRSTWARNING = "ErrorOnFirstWarning";
22

  
23
    public static final String EXTERNALEDITORCOMMANDLINE = "ExternalEditorCommandLine";
24

  
25
    public static final String FRIENDLYACCESSORVISIBILITY = "FriendlyAccessorVisibility";
26

  
27
    public static final String FRIENDLYMODIFIERVISIBILITY = "FriendlyModifierVisibility";
28

  
29
    public static final String FULLNAMEGENERATION = "FullNameGeneration";
30

  
31
    public static final String GENDOCPATH = "GenDocPath";
32

  
33
    public static final String GENERATEDEFAULTRETURN = "GenerateDefaultReturn";
34

  
35
    public static final String GENERATEFINALPARAMETERS = "GenerateFinalParameters";
36

  
37
    public static final String GENERATEINVARIANTS = "GenerateInvariants";
38

  
39
    public static final String GENERATEJAVADOC = "GenerateJavadoc";
40

  
41
    public static final String GENERATEJAVADOC_MARKERS = "GenerateJavadocMarkers";
42

  
43
    public static final String GENERATEPREPOSTCONDITIONS = "GeneratePrePostConditions";
44

  
45
    public static final String GENERATIONMODE = "GenerationMode";
46

  
47
    public static final String GENERATIONPATH = "GenerationPath";
48

  
49
    public static final String INTERFACEIMPLEMENTATION = "InterfaceImplementation";
50

  
51
    public static final String INVARIANTSNAME = "InvariantsName";
52

  
53
    public static final String JARFILEPATH = "JarFilePath";
54

  
55
    public static final String JAVADOCOPTIONS = "JavaDocOptions";
56

  
57
    public static final String JAVAHGENERATIONPATH = "JavahGenerationPath";
58

  
59
    public static final String JDKPATH = "JDKPath";
60

  
61
    public static final String PACKAGEJARINRAMC = "PackageJarInRamc";
62

  
63
    public static final String PACKAGESRCINRAMC = "PackageSrcInRamc";
64

  
65
    public static final String PRIVATEACCESSORVISIBILITY = "PrivateAccessorVisibility";
66

  
67
    public static final String PRIVATEMODIFIERVISIBILITY = "PrivateModifierVisibility";
68

  
69
    public static final String PROTECTEDACCESSORVISIBILITY = "ProtectedAccessorVisibility";
70

  
71
    public static final String PROTECTEDMODIFIERVISIBILITY = "ProtectedModifierVisibility";
72

  
73
    public static final String PUBLICACCESSORVISIBILITY = "PublicAccessorVisibility";
74

  
75
    public static final String PUBLICMODIFIERVISIBILITY = "PublicModifierVisibility";
76

  
77
    public static final String RETRIEVEDEFAULTBEHAVIOUR = "RetrieveDefaultBehaviour";
78

  
79
    public static final String RUNPARAMETERS = "RunParameters";
80

  
81
    public static final String USEEXTERNALEDITION = "UseExternalEdition";
82

  
83
    public static final String USEJAVAH = "UseJavah";
84

  
85
    public static final String COPYRIGHTFILE = "CopyrightFile";
86

  
87
    public static final String COMPONENTSUBPATH = "ComponentSubPath";
88

  
89
    public static final String JAVACOMPATIBILITY = "JavaCompatibility";
90

  
91
    enum AccessorsGenerationMode {
92
        Always,
93
        Smart,
94
        Never;
95
    }
96

  
97
    enum InterfaceImplementationMode {
98
        Ask,
99
        Always,
100
        Never;
101
    }
102

  
103
    enum AccessorVisibility {
104
        Public,
105
        Protected,
106
        Friendly,
107
        Private;
108
    }
109

  
110
    enum AccessMode {
111
        Read,
112
        Write,
113
        ReadWrite,
114
        None,
115
        Default;
116
    }
117

  
118
    enum DefaultVisibility {
119
        Public,
120
        Protected,
121
        Friendly,
122
        Private,
123
        Default;
124
    }
125

  
126
    enum RetrieveMode {
127
        Ask,
128
        Retrieve,
129
        Keep;
130

  
131
        public static RetrieveMode fromString(String value) {
132
            if (value.contentEquals (JavaDesignerParameters.RetrieveMode.Retrieve.toString ())) {
133
                return RetrieveMode.Retrieve;
134
            } else if (value.contentEquals (JavaDesignerParameters.RetrieveMode.Keep.toString ())) {
135
                return RetrieveMode.Keep;
136
            } else {
137
                return RetrieveMode.Ask;
138
            }
139
        }
140

  
141
    }
142

  
143
    enum GenerationMode {
144
        RoundTrip,
145
        ModelDriven,
146
        Release;
147
    }
148

  
149
    enum Encodings {
150
        ISO_8859_1,
151
        US_ASCII,
152
        UTF_8,
153
        UTF_16BE,
154
        UTF_16LE,
155
        UTF_16;
156
    }
157

  
158
    enum CompatibilityLevel {
159
        Java7,
160
        Java8;
161
    }
162

  
163
}
0 164

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/IRefreshService.java
1
package org.modelio.module.javadesigner.api;
2

  
3
import java.util.Collection;
4
import org.modelio.metamodel.uml.statik.NameSpace;
5

  
6
public interface IRefreshService {
7
    void refresh(final Collection<NameSpace> elements);
8

  
9
}
0 10

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/CustomException.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public class CustomException extends Exception {
5
    private static final long serialVersionUID = -7541197429555898819L;
6

  
7
    /**
8
     * Default constructor.
9
     * @param message Describes the exception causes
10
     */
11
    public CustomException(final String message) {
12
        super (message);
13
    }
14

  
15
}
0 16

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerStereotypes.java
1
package org.modelio.module.javadesigner.api;
2

  
3

  
4
public interface JavaDesignerStereotypes {
5
    public static final String JARFILE = "JarFile";
6

  
7
    public static final String JAVAANNOTATION = "JavaAnnotation";
8

  
9
    public static final String JAVACLASS = "JavaClass";
10

  
11
    public static final String JAVADATATYPE = "JavaDataType";
12

  
13
    public static final String JAVADOCINVARIANT = "JavaDocInvariant";
14

  
15
    public static final String JAVAENUMERATION = "JavaEnumeration";
16

  
17
    public static final String JAVAFILEGROUP = "JavaFileGroup";
18

  
19
    public static final String JAVAGETTER = "JavaGetter";
20

  
21
    public static final String JAVAINTERFACE = "JavaInterface";
22

  
23
    public static final String JAVAINVARIANT = "JavaInvariant";
24

  
25
    public static final String JAVAPACKAGE = "JavaPackage";
26

  
27
    public static final String JAVACOMPONENT = "JavaComponent";
28

  
29
    public static final String JAVAPOSTCONDITION = "JavaPostCondition";
30

  
31
    public static final String JAVAPRECONDITION = "JavaPreCondition";
32

  
33
    public static final String JAVARESOURCE = "JavaResource";
34

  
35
    public static final String JAVASETTER = "JavaSetter";
36

  
37
    public static final String JAVASTATIC = "JavaStatic";
38

  
39
    public static final String SEEJAVADOC = "SeeJavadoc";
40

  
41
    public static final String JAVAASSOCIATIONENDPROPERTY = "JavaAssociationEndProperty";
42

  
43
    public static final String JAVAATTRIBUTEPROPERTY = "JavaAttributeProperty";
44

  
45
}
0 46

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/DoubleMap.java
1
package org.modelio.module.javadesigner.custom;
2

  
3
import java.util.Collection;
4
import java.util.Collections;
5
import java.util.HashMap;
6
import java.util.LinkedList;
7
import java.util.List;
8
import java.util.Map;
9
import java.util.Set;
10

  
11
public class DoubleMap<K, V> implements Map<K,V> {
12
    /**
13
     * Main delegated map.
14
     * Has a 1 -> 1 relationship between key and value.
15
     */
16
    private Map<K, V> delegated;
17

  
18
    /**
19
     * The reverse delegated map.
20
     * Has a 1 -> * relationship between the value and the key.
21
     */
22
    private Map<V, List<K>> reverseDelegated;
23

  
24
    /**
25
     * Creates a new instance with hashmaps.
26
     */
27
    public DoubleMap() {
28
        this.delegated = new HashMap<>();
29
        this.reverseDelegated = new HashMap<>();
30
    }
31

  
32
    @Override
33
    public void clear() {
34
        this.delegated.clear();
35
        this.reverseDelegated.clear();
36
    }
37

  
38
    @Override
39
    public boolean containsKey(final Object key) {
40
        return this.delegated.containsKey(key);
41
    }
42

  
43
    @Override
44
    public boolean containsValue(final Object value) {
45
        // Should be faster this way.
46
        return this.reverseDelegated.containsKey(value);
47
    }
48

  
49
    @Override
50
    public Set<java.util.Map.Entry<K,V>> entrySet() {
51
        return this.delegated.entrySet();
52
    }
53

  
54
    @Override
55
    public V get(final Object key) {
56
        return this.delegated.get(key);
57
    }
58

  
59
    @Override
60
    public boolean isEmpty() {
61
        return this.delegated.isEmpty();
62
    }
63

  
64
    @Override
65
    public Set<K> keySet() {
66
        return this.delegated.keySet();
67
    }
68

  
69
    @Override
70
    public V put(final K key, final V value) {
71
        V oldValue = this.delegated.put(key, value);
72
        if (oldValue != null) {
73
          List<K> keyList = this.reverseDelegated.get(oldValue);
74
          if (keyList != null) {
75
            keyList.remove(key);
76
          }
77
        }
78
        if (value != null) {
79
          List<K> keyList = this.reverseDelegated.get(value);
80
          if (keyList == null) {
81
            keyList = new LinkedList<>();
82
            this.reverseDelegated.put(value, keyList);
83
          }
84
          if (!keyList.contains(key)) {
85
            keyList.add(key);
86
          }
87
        }
88
        return oldValue;
89
    }
90

  
91
    @Override
92
    public void putAll(final Map<? extends K,? extends V> t) {
93
        for (K key : t.keySet()) {
94
          V value = t.get(key);
95
          put(key, value);
96
        }
97
    }
98

  
99
    @Override
100
    public V remove(final Object key) {
101
        V value = this.delegated.remove(key);
102
        if (value != null) {
103
          this.reverseDelegated.remove(value);
104
        }
105
        return value;
106
    }
107

  
108
    @Override
109
    public int size() {
110
        return this.delegated.size();
111
    }
112

  
113
    @Override
114
    public Collection<V> values() {
115
        return this.delegated.values();
116
    }
117

  
118
    /**
119
     * Gets all keys for a given value.
120
     * @param value The queried value.
121
     * @return A non-modifiable list of keys, maybe <code>null</code>.
122
     */
123
    public List<K> keysForValue(final V value) {
124
        List<K> result = this.reverseDelegated.get(value);
125
        if (result != null) {
126
          result = Collections.unmodifiableList(result);
127
        }
128
        return result;
129
    }
130

  
131
}
0 132

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/CustomFileException.java
1
package org.modelio.module.javadesigner.custom;
2

  
3

  
4
public class CustomFileException extends Exception {
5
    private static final long serialVersionUID = 5967328584333658971L;
6

  
7
    public CustomFileException(final String message) {
8
        super (message);
9
    }
10

  
11
}
0 12

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/JavaElement.java
1
package org.modelio.module.javadesigner.custom;
2

  
3
import java.util.HashMap;
4
import java.util.Map.Entry;
5

  
6
class JavaElement {
7
    private String defaultGetterPattern;
8

  
9
    private String defaultSetterPattern;
10

  
11
    private String defaultInterfaceContainer;
12

  
13
    private String defaultImplementationContainer;
14

  
15
    private String defaultInterfaceContainerImport;
16

  
17
    private String defaultImplementationContainerImport;
18

  
19
    private HashMap<String, String> getterVariants;
20

  
21
    private HashMap<String, String> setterVariants;
22

  
23
    public JavaElement() {
24
        this.getterVariants = new HashMap<> ();
25
        this.setterVariants = new HashMap<> ();
26
        this.defaultGetterPattern = "";
27
        this.defaultSetterPattern = "";
28
        this.defaultInterfaceContainer = "";
29
        this.defaultImplementationContainer = "";
30
        this.defaultInterfaceContainerImport = "";
31
        this.defaultImplementationContainerImport = "";
32
    }
33

  
34
    private String getDefaultGetterPattern() {
35
        return this.defaultGetterPattern;
36
    }
37

  
38
    public String getGetterPattern(final String elementType) {
39
        String variantPattern = this.getterVariants.get (elementType);
40
        
41
        if (variantPattern == null) {
42
            return getDefaultGetterPattern ();
43
        }
44
        return variantPattern;
45
    }
46

  
47
    public void setDefaultGetterPattern(final String defaultGetterPattern) {
48
        this.defaultGetterPattern = defaultGetterPattern;
49
    }
50

  
51
    private String getDefaultSetterPattern() {
52
        return this.defaultSetterPattern;
53
    }
54

  
55
    public String getSetterPattern(final String elementType) {
56
        String variantPattern = this.setterVariants.get (elementType);
57
        
58
        if (variantPattern == null) {
59
            return getDefaultSetterPattern ();
60
        }
61
        return variantPattern;
62
    }
63

  
64
    public void setDefaultSetterPattern(final String defaultSetterPattern) {
65
        this.defaultSetterPattern = defaultSetterPattern;
66
    }
67

  
68
    public String getDefaultInterfaceContainer() {
69
        return this.defaultInterfaceContainer;
70
    }
71

  
72
    public void setDefaultInterfaceContainer(final String defaultInterfaceContainer) {
73
        this.defaultInterfaceContainer = defaultInterfaceContainer;
74
    }
75

  
76
    public String getDefaultImplementationContainer() {
77
        return this.defaultImplementationContainer;
78
    }
79

  
80
    public void setDefaultImplementationContainer(final String defaultImplementationContainer) {
81
        this.defaultImplementationContainer = defaultImplementationContainer;
82
    }
83

  
84
    public String getDefaultImplementationContainerImport() {
85
        return this.defaultInterfaceContainerImport;
86
    }
87

  
88
    public void setDefaultInterfaceContainerImport(final String defaultInterfaceContainerImport) {
89
        this.defaultInterfaceContainerImport = defaultInterfaceContainerImport;
90
    }
91

  
92
    public void setDefaultImplementationContainerImport(final String defaultImplementationContainerImport) {
93
        this.defaultImplementationContainerImport = defaultImplementationContainerImport;
94
    }
95

  
96
    @Override
97
    public String toString() {
98
        String ret = "\tdefaultInterfaceContainer=\"" +
99
                this.defaultInterfaceContainer + "\"\n";
100
        ret += "\tdefaultInterfaceContainerImport=\"" +
101
                this.defaultInterfaceContainerImport + "\"\n";
102
        ret += "\tdefaultImplementationContainer=\"" +
103
                this.defaultImplementationContainer + "\"\n";
104
        ret += "\tdefaultImplementationContainerImport=\"" +
105
                this.defaultImplementationContainerImport + "\"\n";
106
        ret += "\tdefaultGetterPattern=\"" + this.defaultGetterPattern + "\"\n";
107
        for (Entry<String, String> element : this.getterVariants.entrySet ()) {
108
            ret += "\t" + element.getKey () + " -> " + element.getValue () +
109
                    "\n";
110
        }
111
        ret += "\tdefaultSetterPattern=\"" + this.defaultSetterPattern + "\"\n";
112
        for (Entry<String, String> element : this.setterVariants.entrySet ()) {
113
            ret += "\t" + element.getKey () + " -> " + element.getValue () +
114
                    "\n";
115
        }
116
        return ret;
117
    }
118

  
119
    public void addGetterVariant(final String type, final String variantPattern) {
120
        this.getterVariants.put (type, variantPattern);
121
    }
122

  
123
    public void addSetterVariant(final String type, final String variantPattern) {
124
        this.setterVariants.put (type, variantPattern);
125
    }
126

  
127
}
0 128

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/JavaCustomType.java
1
package org.modelio.module.javadesigner.custom;
2

  
3

  
4
class JavaCustomType {
5
    private String id;
6

  
7
    private String javaType;
8

  
9
    private String wrappedType;
10

  
11
    private String javaImport;
12

  
13
    JavaCustomType(final String id) {
14
        this.id = id;
15
        this.javaType = "";
16
        this.wrappedType = "";
17
        this.javaImport = "";
18
    }
19

  
20
    public String getJavaType() {
21
        return this.javaType;
22
    }
23

  
24
    public void setJavaType(final String javaType) {
25
        this.javaType = javaType;
26
    }
27

  
28
    public String computeType(final boolean useWrapper) {
29
        if (useWrapper && this.wrappedType != null &&
30
                this.wrappedType.length () != 0) {
31
            return this.wrappedType;
32
        }
33
        return this.javaType;
34
    }
35

  
36
    public String getWrappedType() {
37
        return this.wrappedType;
38
    }
39

  
40
    public void setWrappedType(final String wrappedType) {
41
        this.wrappedType = wrappedType;
42
    }
43

  
44
    public String getId() {
45
        return this.id;
46
    }
47

  
48
    @Override
49
    public String toString() {
50
        return "id=\"" + this.id + "\" javaType=\"" + this.javaType +
51
                                "\" wrappedType=\"" + this.wrappedType + "\" javaImport=\"" +
52
                                this.javaImport + "\"";
53
    }
54

  
55
    public String getJavaImport() {
56
        return this.javaImport;
57
    }
58

  
59
    public void setJavaImport(final String javaImport) {
60
        this.javaImport = javaImport;
61
    }
62

  
63
}
0 64

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/JavaElements.java
1
package org.modelio.module.javadesigner.custom;
2

  
3
import java.util.HashMap;
4
import java.util.Map.Entry;
5
import org.modelio.module.javadesigner.custom.JavaTypeManager.JavaBaseElements;
6
import org.modelio.module.javadesigner.custom.JavaTypeManager.JavaMultiplicity;
7

  
8
class JavaElements {
9
    private JavaBaseElements baseElement;
10

  
11
    private HashMap<JavaMultiplicity, JavaElement> elements;
12

  
13
    public JavaElements(final JavaBaseElements baseElement) {
14
        this.elements = new HashMap<> ();
15
        this.baseElement = baseElement;
16
    }
17

  
18
    public JavaElement getJavaElementForMultiplicity(final JavaMultiplicity multiplicity) {
19
        return this.elements.get (multiplicity);
20
    }
21

  
22
    public void addJavaElementForMultiplicity(final JavaMultiplicity multiplicity, final JavaElement element) {
23
        this.elements.put (multiplicity, element);
24
    }
25

  
26
    public JavaBaseElements getBaseElement() {
27
        return this.baseElement;
28
    }
29

  
30
    @Override
31
    public String toString() {
32
        String ret = this.baseElement + "\n";
33
        
34
        for (Entry<JavaMultiplicity, JavaElement> element : this.elements.entrySet ()) {
35
            ret += element.getKey () + ": \n" + element.getValue ();
36
        }
37
        return ret;
38
    }
39

  
40
}
0 41

  
branches/modelio4.0.x/src/main/java/org/modelio/module/javadesigner/custom/JavaTypeManager.java
1
package org.modelio.module.javadesigner.custom;
2

  
3
import java.io.File;
4
import java.io.FileNotFoundException;
5
import java.io.IOException;
6
import java.nio.file.Path;
7
import java.util.ArrayList;
8
import java.util.HashMap;
9
import java.util.Iterator;
10
import java.util.List;
11
import javax.xml.parsers.ParserConfigurationException;
12
import javax.xml.parsers.SAXParser;
13
import javax.xml.parsers.SAXParserFactory;
14
import org.modelio.api.modelio.model.IModelingSession;
15
import org.modelio.api.modelio.model.IUMLTypes;
16
import org.modelio.api.module.IModule;
17
import org.modelio.metamodel.uml.infrastructure.ModelElement;
18
import org.modelio.metamodel.uml.infrastructure.Note;
19
import org.modelio.metamodel.uml.infrastructure.TagParameter;
20
import org.modelio.metamodel.uml.infrastructure.TaggedValue;
21
import org.modelio.metamodel.uml.statik.AssociationEnd;
22
import org.modelio.metamodel.uml.statik.Attribute;
23
import org.modelio.metamodel.uml.statik.Classifier;
24
import org.modelio.metamodel.uml.statik.GeneralClass;
25
import org.modelio.metamodel.uml.statik.Operation;
26
import org.modelio.metamodel.uml.statik.Parameter;
27
import org.modelio.metamodel.uml.statik.VisibilityMode;
28
import org.modelio.module.javadesigner.api.CustomException;
29
import org.modelio.module.javadesigner.api.IJavaDesignerPeerModule;
30
import org.modelio.module.javadesigner.api.JavaDesignerNoteTypes;
31
import org.modelio.module.javadesigner.api.JavaDesignerTagTypes;
32
import org.modelio.module.javadesigner.i18n.Messages;
33
import org.modelio.module.javadesigner.utils.IOtherProfileElements;
34
import org.modelio.module.javadesigner.utils.JavaDesignerUtils;
35
import org.modelio.module.javadesigner.utils.ModelUtils;
36
import org.xml.sax.SAXException;
37

  
38
public class JavaTypeManager {
39
     static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
40

  
41
     static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
42

  
43
     static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
44

  
45
    private ArrayList<String> containersWithKeyList;
46

  
47
    private HashMap<String, JavaCustomType> modelTypes;
48

  
49
    private HashMap<JavaBaseElements, JavaElements> javaElements;
50

  
51
    private static final JavaTypeManager INSTANCE = new JavaTypeManager ();
52

  
53
    private DoubleMap<VisibilityMode,VisibilityMode> propertyVisibility;
54

  
55
    private JavaTypeManager() {
56
        super ();
57
        
58
        // Fill the list of containers with two parameters: key, type
59
        this.containersWithKeyList = new ArrayList<> ();
60
        this.containersWithKeyList.add ("Map");
61
        this.containersWithKeyList.add ("SortedMap");
62
        this.containersWithKeyList.add ("Hashtable");
63
        this.containersWithKeyList.add ("ConcurrentHashMap");
64
        this.containersWithKeyList.add ("EnumMap");
65
        this.containersWithKeyList.add ("HashMap");
66
        this.containersWithKeyList.add ("IdentityHashMap");
67
        this.containersWithKeyList.add ("LinkedHashMap");
68
        this.containersWithKeyList.add ("TreeMap");
69
        this.containersWithKeyList.add ("WeakHashMap");
70
    }
71

  
72
    public static JavaTypeManager getInstance() {
73
        
74
        return INSTANCE;
75
    }
76

  
77
    /**
78
     * Start the XML parsing of the file in argument.
79
     * @param initialPath The custom file to parse. Might be relative to the module resource path, or use $(Project).
80
     * @throws org.modelio.module.javadesigner.custom.CustomFileException If an error has occurred during the loading.
81
     */
82
    public void loadCustomizationFile(IModule module, String initialPath) throws CustomFileException {
83
        File configFile;
84
        
85
        // Check $(Project)
86
        if (initialPath.startsWith("$(Project)")) {
87
            String projectSpacePath = module.getModuleContext().getProjectStructure().getPath().toAbsolutePath().toString();
88
            configFile = new File(projectSpacePath + initialPath.substring(10));
89
        } else {
90
            configFile = new File(initialPath);
91
        }
92
        
93
        // Try a relative file if the given one doesn't exist
94
        Path resourcePath = module.getModuleContext().getConfiguration().getModuleResourcesPath ();
95
        if (!configFile.exists()) {
96
            configFile = new File (resourcePath + File.separator + configFile); //$NON-NLS-1$
97
        }
98
        
99
        // Get the schema file
100
        File schemaFile = new File (resourcePath +
101
                File.separator + "res" + //$NON-NLS-1$
102
                File.separator + "custom" + //$NON-NLS-1$
103
                File.separator + "customFile.xsd"); //$NON-NLS-1$
104
        
105
        loadCustomizationFile (configFile, schemaFile);
106
    }
107

  
108
    /**
109
     * Start the XML parsing of the file in argument.
110
     * @param configFile The file to parse.
111
     * @param schemaSource The XSD file used for validating.
112
     * @throws org.modelio.module.javadesigner.custom.CustomFileException If an error has occurred during the loading.
113
     */
114
    private void loadCustomizationFile(final File configFile, final File schemaSource) throws CustomFileException {
115
        // Reset all data
116
        this.modelTypes = null;
117
        this.javaElements = null;
118
        
119
        // Use an instance of ourselves as the SAX event handler
120
        CustomFileLoader handler = new CustomFileLoader ();
121
        
122
        // Use the validating parser
123
        SAXParserFactory factory = SAXParserFactory.newInstance ();
124
        if (schemaSource != null) {
125
            factory.setValidating (true);
126
        }
127
        factory.setNamespaceAware (true);
128
        
129
        try {
130
            // Parse the input
131
            SAXParser saxParser = factory.newSAXParser ();
132
        
133
            if (schemaSource != null) {
134
                saxParser.setProperty (JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
135
                saxParser.setProperty (JAXP_SCHEMA_SOURCE, schemaSource);
136
            }
137
        
138
            saxParser.parse (configFile, handler);
139
        
140
            // Save data from the handler
141
            this.modelTypes = handler.getModelTypes ();
142
            this.javaElements = handler.getJavaElements ();
143
            this.propertyVisibility = handler.getPropertyVisibilityMap();
144
        
145
        } catch (SAXException e) {
146
            throw new CustomFileException ("Error when parsing file \"" +
147
                    configFile.getAbsolutePath () + "\": " + e.getMessage ());
148
        } catch (FileNotFoundException e) {
149
            throw new CustomFileException ("Customization file not found: \"" +
150
                    configFile.getAbsolutePath () + "\" does not exist");
151
        } catch (IOException e) {
152
            throw new CustomFileException ("Error when loading file: \"" +
153
                    configFile.getAbsolutePath () + "\"");
154
        } catch (ParserConfigurationException e) {
155
            throw new CustomFileException ("Error when loading file: \"" +
156
                    configFile.getAbsolutePath () + "\"");
157
        }
158
    }
159

  
160
    /**
161
     * Get the equivalent to the base UML type from the current loaded customization file.
162
     * @param key The base type, corresponding to the UML type in most cases.
163
     * @param useWrapper Indicates if the type must be wrapped.
164
     * @return The java translation of the base type.
165
     * @throws org.modelio.module.javadesigner.custom.CustomFileException If no customization file is loaded.
166
     */
167
    private String translateType(final String key, final boolean useWrapper) throws CustomFileException {
168
        if (this.modelTypes == null) {
169
            throw new CustomFileException ("No customization file loaded");
170
        }
171
        
172
        JavaCustomType javaType = this.modelTypes.get (key);
173
        if (javaType != null) {
174
            // get the translation type from the config file
175
            return javaType.computeType (useWrapper);
176
        }
177
        
178
        // If no type is found, return nothing
179
        return "";
180
    }
181

  
182
    private JavaElement getElementFromTypeAndMultiplicity(final JavaMultiplicity javaMultiplicity, final JavaBaseElements baseElement) throws CustomFileException {
183
        if (this.javaElements == null) {
184
            throw new CustomFileException ("No customization file loaded");
185
        }
186
        
187
        JavaElements typeContent = this.javaElements.get (baseElement);
188
        if (typeContent != null) {
189
            return typeContent.getJavaElementForMultiplicity (javaMultiplicity);
190
        }
191
        return null;
192
    }
193

  
194
    public String getDefaultInterfaceTranslateClass(final JavaMultiplicity javaMultiplicity, final JavaBaseElements baseElement) throws CustomFileException {
195
        JavaElement computedElement = getElementFromTypeAndMultiplicity (javaMultiplicity, baseElement);
196
        if (computedElement != null) {
197
            return computedElement.getDefaultInterfaceContainer ();
198
        }
199
        return "";
200
    }
201

  
202
    private String getDefaultImplementationTranslateClass(final JavaMultiplicity javaMultiplicity, final JavaBaseElements baseElement) throws CustomFileException {
203
        JavaElement computedElement = getElementFromTypeAndMultiplicity (javaMultiplicity, baseElement);
204
        if (computedElement != null) {
205
            return computedElement.getDefaultImplementationContainer ();
206
        }
207
        return "";
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff