diff options
author | Maged Elaasar | 2017-03-24 13:57:14 +0000 |
---|---|---|
committer | Florian Noyrit | 2017-03-24 14:23:43 +0000 |
commit | bed34aa30cdedbba9d0360f6e66af7c7a3010620 (patch) | |
tree | cd0b38dcccd4760896b4d440b7e286957ff2abdb /plugins/infra/core/org.eclipse.papyrus.infra.core/src/org | |
parent | 172c9b0b63ba3be2c93ff710a8b7b4d288db633e (diff) | |
download | org.eclipse.papyrus-bed34aa30cdedbba9d0360f6e66af7c7a3010620.tar.gz org.eclipse.papyrus-bed34aa30cdedbba9d0360f6e66af7c7a3010620.tar.xz org.eclipse.papyrus-bed34aa30cdedbba9d0360f6e66af7c7a3010620.zip |
Bug 510451 - multiple fixes in architecture framework support
- Fix a typo in the name of the property ADElement::description
- Fixed failing test cases
- Enabled NLS markers in architecture framework genmodels
- Changed the order of the switch architecture context menu actions
- Removed confusing log message about elementtypeset registerd but not
bound
- Fixed new model wizard load template combo box
- Fix AF API working when layout is saved locally
Change-Id: Ifb509afcdffca348cd028094e181677b8f6d9ee4
Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core/src/org')
-rw-r--r-- | plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java index 1cdf419f83f..b546912a600 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/sasheditor/DiModelUtils.java @@ -8,8 +8,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.papyrus.infra.core.architecture.ArchitectureDescription; -import org.eclipse.papyrus.infra.core.architecture.ArchitecturePackage; import org.eclipse.papyrus.infra.core.architecture.ArchitectureDescriptionPreferences; +import org.eclipse.papyrus.infra.core.architecture.ArchitectureFactory; +import org.eclipse.papyrus.infra.core.architecture.ArchitecturePackage; import org.eclipse.papyrus.infra.core.resource.IModel; import org.eclipse.papyrus.infra.core.resource.ModelSet; @@ -47,44 +48,81 @@ public class DiModelUtils { } /** - * Returns the DI Resource associated to the model set. May be null. + * Returns the DI Resource (.di) associated to the model set. May be null. * * @param modelSet * @return */ public static Resource getDiResource(ModelSet modelSet) { - IModel diModel = modelSet.getModel(SashModel.MODEL_ID); - if (diModel instanceof SashModel) { - return ((SashModel) diModel).getResource(); + IModel diModel = modelSet.getModel(DiModel.DI_MODEL_ID); + if (diModel instanceof DiModel) { + return ((DiModel) diModel).getResource(); } return null; } /** + * Gets an architecture description element if available in the given model set + * + * @param modelSet the given model set + * @return an architecture description (can be null) * @since 2.3 */ public static ArchitectureDescription getArchitectureDescription(ModelSet modelSet) { - ArchitectureDescription result = null; + Resource resource = getDiResource(modelSet); + return (ArchitectureDescription) EcoreUtil.getObjectByType( + resource.getContents(), ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION); + } + /** + * Gets an architecture description element if available in the given model set or adds one if not available + * + * @param modelSet the given model set + * @return an architecture description + * @since 2.3 + */ + public static ArchitectureDescription getOrAddArchitectureDescription(ModelSet modelSet) { Resource resource = getDiResource(modelSet); - if (resource != null) { - result = (ArchitectureDescription) EcoreUtil.getObjectByType(resource.getContents(), ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION); + ArchitectureDescription description = (ArchitectureDescription) + EcoreUtil.getObjectByType(resource.getContents(), + ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION); + if (description == null) { + description = ArchitectureFactory.eINSTANCE.createArchitectureDescription(); + resource.getContents().add(description); } - - return result; + return description; } /** + * Gets an architecture description preferences element if available in the given model set + * + * @param modelSet the given model set + * @return an architecture description preferences (can be null) * @since 2.3 */ public static ArchitectureDescriptionPreferences getArchitectureDescriptionPreferences(ModelSet modelSet) { - ArchitectureDescriptionPreferences result = null; + Resource resource = getDiResource(modelSet); + return (ArchitectureDescriptionPreferences) EcoreUtil.getObjectByType( + resource.getContents(), ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION_PREFERENCES); + } + /** + * Gets an architecture description preferences element if available in the given model set + * + * @param modelSet the given model set + * @return an architecture description preferences (can be null) + * @since 2.3 + */ + public static ArchitectureDescriptionPreferences getOrAddArchitectureDescriptionPreferences(ModelSet modelSet) { Resource resource = getDiResource(modelSet); - if (resource != null) { - result = (ArchitectureDescriptionPreferences) EcoreUtil.getObjectByType(resource.getContents(), ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION_PREFERENCES); + ArchitectureDescriptionPreferences preferences = (ArchitectureDescriptionPreferences) + EcoreUtil.getObjectByType(resource.getContents(), + ArchitecturePackage.Literals.ARCHITECTURE_DESCRIPTION_PREFERENCES); + if (preferences == null) { + preferences = ArchitectureFactory.eINSTANCE.createArchitectureDescriptionPreferences(); + resource.getContents().add(preferences); } - - return result; + return preferences; } + } |