Revision 430

View differences:

branches/modelio3.5.x/src/main/java/org/modelio/module/javadesigner/utils/JavaDesignerUtils.java
12 12
import java.util.Set;
13 13
import java.util.StringTokenizer;
14 14
import java.util.Vector;
15

  
15 16
import org.eclipse.swt.widgets.Display;
16 17
import org.modelio.api.modelio.model.IModelingSession;
17 18
import org.modelio.api.module.IModule;
......
45 46
import org.modelio.module.javadesigner.dialog.modelselector.ModelExplorer;
46 47
import org.modelio.module.javadesigner.impl.JavaDesignerModule;
47 48
import org.modelio.vcore.smkernel.mapi.MObject;
48
import org.modelio.vcore.smkernel.mapi.MStatus;
49 49

  
50 50
public class JavaDesignerUtils {
51 51
    public static final String BOOLEAN = "boolean"; // $NON-NLS-1$
......
542 542
                }
543 543
            }
544 544
        }
545
        
546
        // Remove read only elements from the list
547
        if ("TRUE".equalsIgnoreCase (module.getModuleContext().getConfiguration().getParameterValue (JavaDesignerParameters.READONLYELEMENTNOTGENERATED))) {
548
            for (NameSpace element : new HashSet<> (allElements)) {
549
                MStatus status = element.getStatus ();
550
                if (status == null || !status.isModifiable ()) {
551
                    allElements.remove (element);
552
                }
553
            }
554
        }
555 545
        return allElements;
556 546
    }
557 547

  
branches/modelio3.5.x/src/main/java/org/modelio/module/javadesigner/impl/JavaDesignerSession.java
10 10
import org.modelio.api.module.context.IModuleContext;
11 11
import org.modelio.api.module.context.configuration.IModuleUserConfiguration;
12 12
import org.modelio.api.module.lifecycle.DefaultModuleLifeCycleHandler;
13
import org.modelio.api.module.lifecycle.IModuleLifeCycleHandler;
14 13
import org.modelio.api.module.lifecycle.ModuleException;
15 14
import org.modelio.module.javadesigner.api.ISessionWithHandler;
16 15
import org.modelio.module.javadesigner.api.JavaDesignerParameters;
......
21 20
import org.modelio.module.javadesigner.utils.JavaDesignerUtils;
22 21
import org.modelio.vbasic.version.Version;
23 22

  
24
public class JavaDesignerSession extends DefaultModuleLifeCycleHandler implements ISessionWithHandler, IModuleLifeCycleHandler {
23
public class JavaDesignerSession extends DefaultModuleLifeCycleHandler implements ISessionWithHandler {
25 24
    protected IModelChangeHandler modelChangeHandler = null;
26 25

  
27 26
    protected IStatusChangeHandler statusChangeHandler = null;
......
74 73
        configuration.setParameterValue (JavaDesignerParameters.JAVADOCOPTIONS, "-private"); //$NON-NLS-1$
75 74
        configuration.setParameterValue (JavaDesignerParameters.JAVAHGENERATIONPATH, "$(Project)/src"); //$NON-NLS-1$
76 75
        configuration.setParameterValue (JavaDesignerParameters.JDKPATH, jdkPath);
77
        configuration.setParameterValue (JavaDesignerParameters.LOCKGENERATEDFILES, "true"); //$NON-NLS-1$
78 76
        configuration.setParameterValue (JavaDesignerParameters.PACKAGEJARINRAMC, "false"); //$NON-NLS-1$
79 77
        configuration.setParameterValue (JavaDesignerParameters.PACKAGESRCINRAMC, "false"); //$NON-NLS-1$
80 78
        configuration.setParameterValue (JavaDesignerParameters.PRIVATEACCESSORVISIBILITY, JavaDesignerParameters.AccessorVisibility.Public.toString ());
......
83 81
        configuration.setParameterValue (JavaDesignerParameters.PROTECTEDMODIFIERVISIBILITY, JavaDesignerParameters.AccessorVisibility.Public.toString ());
84 82
        configuration.setParameterValue (JavaDesignerParameters.PUBLICACCESSORVISIBILITY, "Public"); //$NON-NLS-1$
85 83
        configuration.setParameterValue (JavaDesignerParameters.PUBLICMODIFIERVISIBILITY, "Public"); //$NON-NLS-1$
86
        configuration.setParameterValue (JavaDesignerParameters.READONLYELEMENTNOTGENERATED, "false"); //$NON-NLS-1$
87 84
        configuration.setParameterValue (JavaDesignerParameters.RETRIEVEDEFAULTBEHAVIOUR, JavaDesignerParameters.RetrieveMode.Ask.toString ());
88 85
        configuration.setParameterValue (JavaDesignerParameters.RUNPARAMETERS, ""); //$NON-NLS-1$
89 86
        configuration.setParameterValue (JavaDesignerParameters.USEEXTERNALEDITION, "false"); //$NON-NLS-1$
branches/modelio3.5.x/src/main/java/org/modelio/module/javadesigner/api/JavaDesignerParameters.java
58 58

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

  
61
    public static final String LOCKGENERATEDFILES = "LockGeneratedFiles";
62

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

  
65 63
    public static final String PACKAGESRCINRAMC = "PackageSrcInRamc";
......
76 74

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

  
79
    public static final String READONLYELEMENTNOTGENERATED = "ReadOnlyElementNotGenerated";
80

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

  
83 79
    public static final String RUNPARAMETERS = "RunParameters";
branches/modelio3.5.x/src/main/java/org/modelio/module/javadesigner/generator/GenerateProgressBar.java
153 153
			}
154 154
		} catch (IOException e) {
155 155
			this.report.addError (e.getMessage (), element, "");
156
		} finally {
157
			if (javaConfig.LOCKGENERATEDFILES && !element.getStatus ().isModifiable ()) {
158
				targetFile.setReadOnly ();
159
			}
160 156
		}
161 157
	}
162 158

  
branches/modelio3.5.x/src/main/java/org/modelio/module/javadesigner/generator/JavaConfiguration.java
35 35

  
36 36
    public String ENCODING;
37 37

  
38
    public boolean LOCKGENERATEDFILES;
39

  
40 38
    public String COPYRIGHTFILE;
41 39

  
42 40
    public boolean JAVA8COMPATIBILITY;
......
60 58
        this.GENERATEJAVADOC = getBooleanParameterValue (JavaDesignerParameters.GENERATEJAVADOC);
61 59
        // TAS added: do not generate JavaDoc markers in ModelDriven.
62 60
        this.GENERATEJAVADOC_MARKERS = getBooleanParameterValue (JavaDesignerParameters.GENERATEJAVADOC_MARKERS);
63
        this.LOCKGENERATEDFILES = getBooleanParameterValue (JavaDesignerParameters.LOCKGENERATEDFILES);
64 61
        this.COPYRIGHTFILE = getStringParameterValue (JavaDesignerParameters.COPYRIGHTFILE);
65 62
        this.JAVA8COMPATIBILITY = getStringParameterValue (JavaDesignerParameters.JAVACOMPATIBILITY).equals (JavaDesignerParameters.CompatibilityLevel.Java8.toString ());
66 63
        
branches/modelio3.5.x/src/main/conf/module.properties
321 321
parameter.JavaDocOptions.label                        = Generation options
322 322
parameter.JavahGenerationPath.description             = Path of the .h files generated by "javah", needed to implement native methods.
323 323
parameter.JavahGenerationPath.label                   = Native .h files generation path
324
parameter.LockGeneratedFiles.description              = All sources files generated from read only model elements will also be read only, to avoid unwanted modifications.\r\nYou must generate again after getting a lock in order to make the according files writable.
325
parameter.LockGeneratedFiles.label                    = Generate read only files
326 324
parameter.PackageJarInRamc.description                = If checked, Java ARchives are included in packaged model components.
327 325
parameter.PackageJarInRamc.label                      = Add Jar files in model component
328 326
parameter.PackageSrcInRamc.description                = If checked, Java source files are included in packaged model components.
......
369 367
parameter.ReadOnlyBehaviour.Overwrite.label           = Overwrite
370 368
parameter.ReadOnlyBehaviour.description               = What to do during generation of a non modifiable element if the file on disk has been modified since last generation:\r\n- "Overwrite" the file;\r\n- "Backup" the modified file into a .mine file;\r\n- "Ignore" the element and keep the modified file;\r\n- "Cancel" generation.
371 369
parameter.ReadOnlyBehaviour.label                     = Non modifiable element generation behaviour
372
parameter.ReadOnlyElementNotGenerated.description     = Deactivate Java source generation for non modifiable elements. If this tickbox is checked, the Java file is not generated if the element has not been locked by the user.\r\nHowever, generation is carried out recursively on all sub-elements. In this way, you can run the generation command on the non modifiable root package, in order to only generated elements that have been locked.
373
parameter.ReadOnlyElementNotGenerated.label           = Do not generate non modifiable elements
374 370
parameter.RetrieveDefaultBehaviour.Ask.label          = Ask
375 371
parameter.RetrieveDefaultBehaviour.Keep.label         = Keep
376 372
parameter.RetrieveDefaultBehaviour.Retrieve.label     = Retrieve
branches/modelio3.5.x/src/main/conf/module.xml
630 630
        <Parameter id="PackageJarInRamc" group="%group.ModelComponents.label" uid="01ec25e8-0000-0780-0000-000000000000" type="Boolean" default-value="" label="%parameter.PackageJarInRamc.label">
631 631
            <Description>%parameter.PackageJarInRamc.description</Description>
632 632
        </Parameter>
633
        <Parameter id="ReadOnlyElementNotGenerated" group="%group.Subversion.label" uid="01ec25e8-0000-0721-0000-000000000000" type="Boolean" default-value="" label="%parameter.ReadOnlyElementNotGenerated.label">
634
            <Description>%parameter.ReadOnlyElementNotGenerated.description</Description>
635
        </Parameter>
636
        <Parameter id="LockGeneratedFiles" group="%group.Subversion.label" uid="2c5d9a32-8425-11df-a692-002564c97630" type="Boolean" default-value="" label="%parameter.LockGeneratedFiles.label">
637
            <Description>%parameter.LockGeneratedFiles.description</Description>
638
        </Parameter>
639 633
    </Parameters>
640 634
    <Gui>
641 635
        <Commands>
branches/modelio3.5.x/src/main/conf/module_fr.properties
290 290
parameter.JavahGenerationPath.label                   = R\u00E9pertoire de g\u00E9n\u00E9ration des fichiers .h natifs
291 291
parameter.JDKPath.description                         = Le r\u00E9pertoire racine du Kit de D\u00E9veloppement Java (JDK).\r\nVous devez avoir un JDK afin de d\u00E9velopper un nouveau programme (compilation, g\u00E9n\u00E9ration de la JavaDoc...).\r\nEx : "C:/Program Files/Java/jdk1.6.0"
292 292
parameter.JDKPath.label                               = JDK
293
parameter.LockGeneratedFiles.description              = Tous les fichiers source g\u00E9n\u00E9r\u00E9s \u00E0 partir d'\u00E9l\u00E9ments non modifiables seront en lecture seule, afin d'\u00E9viter les modifications non d\u00E9sir\u00E9es.\r\nAttention, vous devez g\u00E9n\u00E9rer vos fichiers apr\u00E8s avoir pris des verrous sur des \u00E9l\u00E9ments, et ainsi rendre les fichiers correspondant \u00E9ditables.
294
parameter.LockGeneratedFiles.label                    = G\u00E9n\u00E9rer les fichiers en lecture seule
295 293
parameter.PackageJarInRamc.description                = Active l'int\u00E9gration des archives "jar" aux composants de mod\u00E8le packag\u00E9s.
296 294
parameter.PackageJarInRamc.label                      = Ajouter les Jar aux composants de mod\u00E8le
297 295
parameter.PackageSrcInRamc.description                = Active l'int\u00E9gration des fichiers sources java aux composants de mod\u00E8le packag\u00E9s.
......
338 336
parameter.ReadOnlyBehaviour.Ignore.label              = Ignorer
339 337
parameter.ReadOnlyBehaviour.label                     = Comportement \u00E0 la g\u00E9n\u00E9ration d'\u00E9l\u00E9ment non modifiable
340 338
parameter.ReadOnlyBehaviour.Overwrite.label           = Remplacer
341
parameter.ReadOnlyElementNotGenerated.description     = D\u00E9sactive la g\u00E9n\u00E9ration des sources java pour les \u00E9l\u00E9ments non modifiables. Si la case est coch\u00E9e, les fichiers Java ne sont pas g\u00E9n\u00E9r\u00E9s pour les \u00E9l\u00E9ments dont le verrou n'a pas \u00E9t\u00E9 pris.\r\nIl est cependant possible de lancer la g\u00E9n\u00E9ration r\u00E9cursivement sur tous les sous \u00E9l\u00E9ments. Ainsi, en lan\u00E7ant la g\u00E9n\u00E9ration sur le package racine non modifiable, seuls les sous \u00E9l\u00E9ments dont le verrou a \u00E9t\u00E9 pris seront g\u00E9n\u00E9r\u00E9s.
342
parameter.ReadOnlyElementNotGenerated.label           = Ne pas g\u00E9n\u00E9rer les \u00E9l\u00E9ments non modifiables
343 339
parameter.RetrieveDefaultBehaviour.Ask.label          = Demander
344 340
parameter.RetrieveDefaultBehaviour.description        = Ce qui doit \u00EAtre fait lors d'une g\u00E9n\u00E9ration si le fichier sur le disque a \u00E9t\u00E9 modifi\u00E9 depuis la derni\u00E8re g\u00E9n\u00E9ration:\r\n- "Demander" confirmation \u00E0 l'utilisateur.\r\n- "Conserver" le mod\u00E8le et \u00E9craser le fichier modifi\u00E9.\r\n- "Mettre \u00E0 jour" le mod\u00E8le \u00E0 partir du contenu du fichier.
345 341
parameter.RetrieveDefaultBehaviour.Keep.label         = Conserver
branches/modelio3.5.x/src/main/resources/org/modelio/module/javadesigner/i18n/messages_fr.properties
341 341
Ui.Parameter.JavaDocOptions.Label                    = Options de g\u00E9n\u00E9ration
342 342
Ui.Parameter.JavahGenerationPath.Description         = R\u00E9pertoire des fichiers .h g\u00E9n\u00E9r\u00E9s par "javah", n\u00E9cessaires aux m\u00E9thodes natives.
343 343
Ui.Parameter.JavahGenerationPath.Label               = R\u00E9pertoire de g\u00E9n\u00E9ration des fichiers .h natifs
344
Ui.Parameter.LockGeneratedFiles.Description          = Tous les fichiers source g\u00E9n\u00E9r\u00E9s \u00E0 partir d'\u00E9l\u00E9ments non modifiables seront en lecture seule, afin d'\u00E9viter les modifications non d\u00E9sir\u00E9es.\r\nAttention, vous devez g\u00E9n\u00E9rer vos fichiers apr\u00E8s avoir pris des verrous sur des \u00E9l\u00E9ments, et ainsi rendre les fichiers correspondant \u00E9ditables.
345
Ui.Parameter.LockGeneratedFiles.Label                = G\u00E9n\u00E9rer les fichiers en lecture seule
346 344
Ui.Parameter.PackageJarInRamc.Description            = Active l'int\u00E9gration des archives "jar" aux composants de mod\u00E8le packag\u00E9s.
347 345
Ui.Parameter.PackageJarInRamc.Label                  = Ajouter les Jar aux composants de mod\u00E8le
348 346
Ui.Parameter.PackageSrcInRamc.Description            = Active l'int\u00E9gration des fichiers sources java aux composants de mod\u00E8le packag\u00E9s.
......
361 359
Ui.Parameter.PublicAccessorVisibility.Label          = Visibilit\u00E9 des getters g\u00E9n\u00E9r\u00E9s \u00E0 partir d'un \u00E9l\u00E9ment "Public"
362 360
Ui.Parameter.PublicModifierVisibility.Description    = A chaque cr\u00E9ation de setter pour un attribut "Public", sa visibilit\u00E9 prendra cette valeur.
363 361
Ui.Parameter.PublicModifierVisibility.Label          = Visibilit\u00E9 des setters g\u00E9n\u00E9r\u00E9s \u00E0 partir d'un \u00E9l\u00E9ment "Public"
364
Ui.Parameter.ReadOnlyElementNotGenerated.Description = D\u00E9sactive la g\u00E9n\u00E9ration des sources java pour les \u00E9l\u00E9ments en lecture seule. Si la case est coch\u00E9e, les fichiers Java ne sont pas g\u00E9n\u00E9r\u00E9s pour les \u00E9l\u00E9ments qui n'ont pas \u00E9t\u00E9s pris en check-out.\r\nIl est cependant possible de lancer la g\u00E9n\u00E9ration r\u00E9cursivement sur tous les sous \u00E9l\u00E9ments. Ainsi, en lan\u00E7ant la g\u00E9n\u00E9ration sur le package racine en lecture seule, seuls les sous \u00E9l\u00E9ments pris en check-out seront g\u00E9n\u00E9r\u00E9s.
365
Ui.Parameter.ReadOnlyElementNotGenerated.Label       = Ne pas g\u00E9n\u00E9rer les \u00E9l\u00E9ments non modifiables
366 362
Ui.Parameter.RetrieveDefaultBehaviour.Description    = Ce qui doit \u00EAtre fait lors d'une g\u00E9n\u00E9ration si le fichier sur le disque a \u00E9t\u00E9 modifi\u00E9 depuis la derni\u00E8re g\u00E9n\u00E9ration:\r\n- "Demander" confirmation \u00E0 l'utilisateur.\r\n- "Conserver" le mod\u00E8le et \u00E9craser le fichier modifi\u00E9.\r\n- "Mettre \u00E0 jour" le mod\u00E8le \u00E0 partir du contenu du fichier.
367 363
Ui.Parameter.RetrieveDefaultBehaviour.Label          = Comportement par d\u00E9faut pour la r\u00E9cup\u00E9ration de fichier
368 364
Ui.Parameter.RetrieveMode.Ask                        = Demander
branches/modelio3.5.x/src/main/resources/org/modelio/module/javadesigner/i18n/messages.properties
354 354
Ui.Parameter.JavaDocOptions.Label                    = Generation options
355 355
Ui.Parameter.JavahGenerationPath.Description         = Path of the .h files generated by "javah", needed to implement native methods.
356 356
Ui.Parameter.JavahGenerationPath.Label               = Native .h files generation path
357
Ui.Parameter.LockGeneratedFiles.Description          = All sources files generated from read only model elements will also be read only, to avoid unwanted modifications.\r\nYou must generate again after getting a lock in order to make the according files writable.
358
Ui.Parameter.LockGeneratedFiles.Label                = Generate read only files
359 357
Ui.Parameter.PackageJarInRamc.Description            = If checked, Java ARchives are included in packaged model components.
360 358
Ui.Parameter.PackageJarInRamc.Label                  = Add Jar files in model component
361 359
Ui.Parameter.PackageSrcInRamc.Description            = If checked, Java source files are included in packaged model components.
......
374 372
Ui.Parameter.PublicAccessorVisibility.Label          = Visibility for getters generated from "Public" elements
375 373
Ui.Parameter.PublicModifierVisibility.Description    = Each time a setter is created from a "Public" attribute, its visibility will be set to this value.
376 374
Ui.Parameter.PublicModifierVisibility.Label          = Visibility for setters generated from "Public" elements
377
Ui.Parameter.ReadOnlyElementNotGenerated.Description = Deactivate Java source generation for elements in read only mode. If this tickbox is checked, the Java file is not generated if the element has not been checked-out.\r\nHowever, generation is carried out recursively on all sub-elements. In this way, you can run the generation command on the root package in read only mode, in order to only generated elements that have been checked-out.
378
Ui.Parameter.ReadOnlyElementNotGenerated.Label       = Do not generate read-only elements
379 375
Ui.Parameter.RetrieveDefaultBehaviour.Description    = What to do during generation if the file on disk has been modified since last generation:\r\n- "Ask" the user confirmation.\r\n- "Keep" the model and overwrite the modified file.\r\n- "Retrieve" the file content.
380 376
Ui.Parameter.RetrieveDefaultBehaviour.Label          = Default behavior for file retrieving
381 377
Ui.Parameter.RetrieveMode.Ask                        = Ask

Also available in: Unified diff