From b3141df23ca644573f8b2813ad8859722d418bd9 Mon Sep 17 00:00:00 2001 From: Nicolas FAUVERGUE Date: Thu, 24 Nov 2016 12:20:54 +0100 Subject: Bug 496905: [Diagram][ModelExplorer][Table][Dialog] Papyrus must integrate the internationalization feature provided by UML. https://bugs.eclipse.org/bugs/show_bug.cgi?id=496905 Commit of infra for internationalization. Change-Id: I1b1859bf111e1ef7a7522212fbe639cf2bd13890 Signed-off-by: Nicolas FAUVERGUE --- .../META-INF/MANIFEST.MF | 140 +- .../cdo/org.eclipse.papyrus.cdo.core/pom.xml | 26 +- .../cdo/core/resource/CDOAwareModelSet.java | 3 +- .../.project | 35 + .../build.properties | 7 + .../epl-v10.html | 304 ++++ .../feature.properties | 132 ++ .../feature.xml | 29 + .../license.html | 107 ++ .../pom.xml | 12 + .../org.eclipse.papyrus.sdk.feature/feature.xml | 4 + features/papyrus-main-features/pom.xml | 1 + .../META-INF/MANIFEST.MF | 3 +- .../editor/commands/RenameNestedEditorCommand.java | 268 ++-- .../META-INF/MANIFEST.MF | 3 +- .../facet/custom/ui/internal/query/LabelQuery.java | 285 ++-- .../META-INF/MANIFEST.MF | 2 +- .../core/org.eclipse.papyrus.infra.core/pom.xml | 2 +- .../resource/AbstractModelWithSharedResource.java | 5 +- .../core/resource/AdjunctResourceModelSnippet.java | 28 +- .../papyrus/infra/core/resource/ModelSet.java | 10 +- .../infra/core/resource/PapyrusProjectScope.java | 124 ++ .../META-INF/MANIFEST.MF | 3 +- .../internal/ControlledResourceTracker.java | 36 +- .../emf/commands/AddEAnnotationDetailCommand.java | 69 + .../infra/emf/commands/AddToResourceCommand.java | 71 +- .../META-INF/MANIFEST.MF | 3 +- .../handlers/ReferencedModelReadOnlyHandler.java | 4 +- .../META-INF/MANIFEST.MF | 3 +- .../papyrus/commands/RenameDiagramHandler.java | 450 +++--- .../META-INF/MANIFEST.MF | 3 +- .../META-INF/MANIFEST.MF | 3 +- .../gmfdiag/hyperlink/ui/AdvancedHLManager.java | 5 +- .../META-INF/MANIFEST.MF | 3 +- .../handlers/RenameDiagramHandler.java | 56 +- .../META-INF/MANIFEST.MF | 4 +- .../model/notation/ui/SingleDiagram.xwt | 1 + .../databinding/DiagramLabelObservableValue.java | 219 +++ .../properties/modelelement/GMFModelElement.java | 21 +- .../.classpath | 7 + .../.project | 52 + .../.settings/org.eclipse.jdt.core.prefs | 296 ++++ .../.settings/org.eclipse.jdt.ui.prefs | 68 + .../.settings/org.eclipse.pde.api.tools.prefs | 98 ++ .../META-INF/MANIFEST.MF | 28 + .../about.html | 28 + .../build.properties | 22 + .../model/environment.xmi | 12 + .../model/general/internationalization.ctx | 22 + .../general/ui/SingleInternationalization.xwt | 17 + .../plugin.properties | 4 + .../plugin.xml | 24 + .../pom.xml | 12 + .../welcome/internationalization/Activator.java | 77 + .../InternationalizationWelcomeModelElement.java | 115 ++ ...rnationalizationWelcomeModelElementFactory.java | 51 + .../modelelements/LanguageObservableValue.java | 174 +++ ...ernationalizationPreferenceObservableValue.java | 171 +++ .../UseInternationalizationObservableValue.java | 165 +++ .../widgets/LanguageDialog.java | 55 + .../widgets/editors/LanguageDialog.java | 266 ++++ .../.classpath | 7 + .../.project | 52 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 21 + .../about.html | 28 + .../build.properties | 11 + .../plugin.properties | 4 + .../plugin.xml | 9 + .../pom.xml | 12 + .../internationalization/common/Activator.java | 153 ++ ...ocaleInternationalizationPreferenceCommand.java | 98 ++ .../UseInternationalizationPreferenceCommand.java | 98 ++ .../common/editor/IInternationalizationEditor.java | 34 + ...nternationalizationAnnotationResourceUtils.java | 49 + .../InternationalizationPreferencesConstants.java | 41 + .../InternationalizationPreferencesUtils.java | 296 ++++ .../common/utils/LocaleNameResolver.java | 57 + .../.classpath | 7 + .../.project | 52 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 22 + .../about.html | 28 + .../build.properties | 9 + .../plugin.properties | 4 + .../plugin.xml | 22 + .../pom.xml | 12 + .../controlmode/Activator.java | 78 + .../commands/ControlPropertiesCommand.java | 328 +++++ .../CreatePropertiesControlResourceCommand.java | 257 ++++ ...ternationalizationAnnotationControlCommand.java | 111 ++ .../RemovePropertiesControlResourceCommand.java | 243 ++++ ...ationalizationAnnotationControlParticipant.java | 183 +++ .../participants/PropertiesControlParticipant.java | 159 +++ .../PropertiesUncontrolParticipant.java | 249 ++++ .../controlmode/utils/ControlPropertiesUtils.java | 25 + .../.classpath | 8 + .../.project | 52 + .../META-INF/MANIFEST.MF | 18 + .../about.html | 28 + .../build.properties | 12 + .../icons/full/obj16/InternationalizationEntry.gif | Bin 0 -> 129 bytes .../full/obj16/InternationalizationLibrary.gif | Bin 0 -> 129 bytes .../plugin.properties | 25 + .../plugin.xml | 22 + .../pom.xml | 12 + .../provider/InternationalizationEditPlugin.java | 96 ++ .../InternationalizationEntryItemProvider.java | 171 +++ ...rnationalizationItemProviderAdapterFactory.java | 243 ++++ .../InternationalizationLibraryItemProvider.java | 141 ++ ...lizationNotationItemProviderAdapterFactory.java | 57 + .../.classpath | 7 + .../.project | 52 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 22 + .../about.html | 28 + .../build.properties | 11 + .../plugin.properties | 4 + .../plugin.xml | 23 + .../pom.xml | 12 + .../infra/internationalization/ui/Activator.java | 77 + .../ui/dialogs/InternationalizationDialog.java | 251 ++++ .../InternationalizationCommandHandler.java | 167 +++ .../.classpath | 7 + .../.project | 52 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 25 + .../about.html | 28 + .../build.properties | 11 + .../plugin.properties | 4 + .../plugin.xml | 9 + .../pom.xml | 12 + .../internationalization/utils/Activator.java | 77 + .../commands/InternationalizationPasteCommand.java | 84 ++ .../utils/utils/InternationalizationConstants.java | 30 + .../utils/utils/LabelInternationalization.java | 229 +++ .../LabelInternationalizationPreferencesUtils.java | 64 + .../utils/LabelInternationalizationUtils.java | 259 ++++ .../.classpath | 8 + .../.project | 52 + .../.settings/org.eclipse.core.resources.prefs | 5 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 29 + .../about.html | 28 + .../build.properties | 13 + .../model/Internationalization.ecore | 13 + .../model/Internationalization.genmodel | 21 + .../plugin.properties | 4 + .../plugin.xml | 32 + .../pom.xml | 50 + .../InternationalizationEntry.java | 86 ++ .../InternationalizationFactory.java | 61 + .../InternationalizationLibrary.java | 51 + .../InternationalizationPackage.java | 274 ++++ .../impl/InternationalizationEntryImpl.java | 236 ++++ .../impl/InternationalizationFactoryImpl.java | 120 ++ .../impl/InternationalizationLibraryImpl.java | 146 ++ .../impl/InternationalizationPackageImpl.java | 252 ++++ .../util/InternationalizationAdapterFactory.java | 147 ++ .../util/InternationalizationSwitch.java | 145 ++ .../infra/internationalization/Activator.java | 77 + ...ternationalizationPreferenceCommandFactory.java | 211 +++ .../commands/ResetNameCommand.java | 108 ++ .../commands/ResetNameTransactionalCommand.java | 89 ++ ...nternationalizationPreferenceModelProvider.java | 78 + ...nternationalizationPreferenceModelProvider.java | 56 + .../InternationalizationModelResource.java | 1494 ++++++++++++++++++++ .../InternationalizationPreferenceModel.java | 606 ++++++++ ...ionalizationPreferenceModelProviderManager.java | 252 ++++ .../PropertiesAdjunctResourceModelSnippet.java | 119 ++ .../utils/EntryPartLabelSynchronizer.java | 167 +++ .../InternationalizationPreferenceModelUtils.java | 61 + .../utils/PreferencePartLabelSynchronizer.java | 171 +++ .../utils/PropertiesFilesUtils.java | 353 +++++ .../utils/QualifiedNameUtils.java | 162 +++ .../utils/ResourceBundleAndURI.java | 87 ++ .../images/InternationalizationPreferences.png | Bin 0 -> 15707 bytes .../images/LabelsInternationalizationExample.png | Bin 0 -> 10402 bytes .../mediawiki/images/PropertiesModelExplorer.png | Bin 0 -> 6347 bytes .../site/mediawiki/internationalizationDev-toc.xml | 22 + .../site/mediawiki/internationalizationDev.html | 266 ++++ .../mediawiki/internationalizationDev.mediawiki | 197 +++ plugins/infra/internationalization/pom.xml | 26 + .../META-INF/MANIFEST.MF | 4 +- .../common/editor/AbstractEMFNattableEditor.java | 48 +- .../factory/AbstractNattableEditorFactory.java | 470 +++--- .../common/handlers/RenameTableHandler.java | 355 ++--- .../META-INF/MANIFEST.MF | 3 +- .../model/nattable/provider/TableItemProvider.java | 793 +++++------ .../META-INF/MANIFEST.MF | 3 +- .../modelexplorer/handlers/RenameTableHandler.java | 48 +- .../META-INF/MANIFEST.MF | 4 +- .../model/ui/EObjectInFlatTable.xwt | 9 +- .../model/ui/EObjectInTreeTable.xwt | 11 +- .../model/ui/SingleTable.xwt | 9 +- .../modelelement/NatTableModelElement.java | 11 +- .../observable/TableLabelObservableValue.java | 216 +++ .../infra/nattable/properties/utils/Constants.java | 3 + .../META-INF/MANIFEST.MF | 3 +- .../manager/table/INattableModelManager.java | 8 + .../manager/table/NattableModelManager.java | 12 +- .../nattable/provider/TableLabelProvider.java | 143 +- .../META-INF/MANIFEST.MF | 3 +- .../infra/onefile/model/impl/PapyrusFile.java | 42 +- .../infra/onefile/model/impl/SubResourceFile.java | 15 +- .../papyrus/infra/onefile/utils/OneFileUtils.java | 60 +- plugins/infra/pom.xml | 1 + .../META-INF/MANIFEST.MF | 3 +- .../pom.xml | 2 +- .../commands/CreateControlResource.java | 16 +- .../commands/RemoveControlResourceCommand.java | 28 +- .../META-INF/MANIFEST.MF | 3 +- .../PapyrusCopyFilesAndFoldersOperation.java | 33 +- .../META-INF/MANIFEST.MF | 3 +- .../policy/ViewPrototypeLabelProvider.java | 9 +- 215 files changed, 16641 insertions(+), 1577 deletions(-) create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/.project create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/build.properties create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/epl-v10.html create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.properties create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.xml create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/license.html create mode 100644 features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/pom.xml create mode 100644 plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java create mode 100644 plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddEAnnotationDetailCommand.java create mode 100644 plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.ui.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.pde.api.tools.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/environment.xmi create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/internationalization.ctx create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/ui/SingleInternationalization.xwt create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElement.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElementFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/LanguageObservableValue.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/PrivateInternationalizationPreferenceObservableValue.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/UseInternationalizationObservableValue.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/LanguageDialog.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/editors/LanguageDialog.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/LocaleInternationalizationPreferenceCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/UseInternationalizationPreferenceCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/editor/IInternationalizationEditor.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationAnnotationResourceUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesConstants.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/LocaleNameResolver.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/ControlPropertiesCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/CreatePropertiesControlResourceCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/InternationalizationAnnotationControlCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/RemovePropertiesControlResourceCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/InternationalizationAnnotationControlParticipant.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesControlParticipant.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesUncontrolParticipant.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/utils/ControlPropertiesUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationEntry.gif create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationLibrary.gif create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEditPlugin.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEntryItemProvider.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationItemProviderAdapterFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationLibraryItemProvider.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src/org/eclipse/papyrus/infra/internationalization/edit/provider/InternationalizationNotationItemProviderAdapterFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/dialogs/InternationalizationDialog.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/handlers/InternationalizationCommandHandler.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/commands/InternationalizationPasteCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/InternationalizationConstants.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationPreferencesUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.classpath create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.project create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.core.resources.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/about.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/build.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.ecore create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.genmodel create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.properties create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/pom.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationEntry.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationLibrary.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationPackage.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationEntryImpl.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationFactoryImpl.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationLibraryImpl.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationPackageImpl.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationAdapterFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationSwitch.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/Activator.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/InternationalizationPreferenceCommandFactory.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameTransactionalCommand.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/AbstractInternationalizationPreferenceModelProvider.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/IInternationalizationPreferenceModelProvider.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModel.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModelProviderManager.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelsnippet/PropertiesAdjunctResourceModelSnippet.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/InternationalizationPreferenceModelUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PropertiesFilesUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/ResourceBundleAndURI.java create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/InternationalizationPreferences.png create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/LabelsInternationalizationExample.png create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/PropertiesModelExplorer.png create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev-toc.xml create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.html create mode 100644 plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.mediawiki create mode 100644 plugins/infra/internationalization/pom.xml create mode 100644 plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/observable/TableLabelObservableValue.java diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF index 80641f36eb4..3cebc626ea7 100644 --- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF +++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF @@ -1,70 +1,70 @@ -Manifest-Version: 1.0 -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.emf.ecore;visibility:=reexport, - org.eclipse.emf.ecore.xmi;visibility:=reexport, - org.eclipse.emf.cdo.explorer;bundle-version="[4.3.0,5.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.core;bundle-version="1.2.0";visibility:=reexport, - org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0", - org.eclipse.papyrus.infra.services.resourceloading;bundle-version="1.2.0";visibility:=reexport, - org.eclipse.papyrus.infra.emf;bundle-version="1.2.0", - org.eclipse.papyrus.infra.emf.readonly;bundle-version="1.2.0";visibility:=reexport, - org.eclipse.emf.workspace;bundle-version="[1.5.1,2.0.0)", - org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0", - org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)", - org.eclipse.emf.cdo.dawn.gmf;bundle-version="[2.1.0,3.0.0)", - org.eclipse.emf.transaction;bundle-version="[1.4.0,2.0.0)";visibility:=reexport, - org.eclipse.gmf.runtime.notation;bundle-version="[1.5.0,2.0.0)", - org.eclipse.equinox.security;bundle-version="[1.1.100,2.0.0)", - org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", - com.google.guava;bundle-version="11.0.0", - org.eclipse.papyrus.infra.services.controlmode;bundle-version="1.2.0", - org.eclipse.gmf.runtime.emf.commands.core;bundle-version="[1.7.0,2.0.0)", - org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.7.0,2.0.0)", - org.eclipse.papyrus.infra.services.localizer;bundle-version="1.2.0", - org.eclipse.net4j;bundle-version="[4.3.0,5.0.0)", - org.eclipse.emf.cdo.admin;bundle-version="[4.1.200,5.0.0)", - org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0" -Export-Package: org.eclipse.papyrus.cdo.core, - org.eclipse.papyrus.cdo.core.admin, - org.eclipse.papyrus.cdo.core.exporter, - org.eclipse.papyrus.cdo.core.importer, - org.eclipse.papyrus.cdo.core.resource, - org.eclipse.papyrus.cdo.core.util, - org.eclipse.papyrus.cdo.internal.core; x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui, - org.eclipse.papyrus.cdo.ui.tests, - org.eclipse.papyrus.cdo.uml.diagram.ui, - org.eclipse.papyrus.cdo.uml.ui, - org.eclipse.papyrus.cdo.ui.customization.properties, - org.eclipse.papyrus.cdo.uml.ui.tests, - org.eclipse.papyrus.cdo.uml.search.ui, - org.eclipse.papyrus.cdo.uml.search.ui.tests, - org.eclipse.papyrus.cdo.ui.hyperlink", - org.eclipse.papyrus.cdo.internal.core.controlmode;x-friends:="org.eclipse.papyrus.cdo.ui, - org.eclipse.papyrus.cdo.core.tests", - org.eclipse.papyrus.cdo.internal.core.exporter;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.expressions;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.importer;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.l10n;x-internal:=true, - org.eclipse.papyrus.cdo.internal.core.repositories;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.repositories.impl;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.repositories.util;x-friends:="org.eclipse.papyrus.cdo.core.tests, - org.eclipse.papyrus.cdo.ui", - org.eclipse.papyrus.cdo.internal.core.resource;x-internal:=true, - org.eclipse.papyrus.cdo.internal.core.services.localizer;x-internal:=true -Bundle-Vendor: %providerName -Bundle-ActivationPolicy: lazy -Bundle-ClassPath: . -Bundle-Version: 1.2.0.qualifier -Bundle-Localization: plugin -Bundle-Name: %pluginName -Bundle-Activator: org.eclipse.papyrus.cdo.internal.core.Activator -Bundle-ManifestVersion: 2 -Bundle-Description: %pluginDescription -Bundle-SymbolicName: org.eclipse.papyrus.cdo.core;singleton:=true -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Manifest-Version: 1.0 +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.ecore.xmi;visibility:=reexport, + org.eclipse.emf.cdo.explorer;bundle-version="[4.3.0,5.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.core;bundle-version="1.2.0";visibility:=reexport, + org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0", + org.eclipse.papyrus.infra.services.resourceloading;bundle-version="1.2.0";visibility:=reexport, + org.eclipse.papyrus.infra.emf;bundle-version="1.2.0", + org.eclipse.papyrus.infra.emf.readonly;bundle-version="1.2.0";visibility:=reexport, + org.eclipse.emf.workspace;bundle-version="[1.5.1,2.0.0)", + org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.2.0", + org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)", + org.eclipse.emf.cdo.dawn.gmf;bundle-version="[2.1.0,3.0.0)", + org.eclipse.emf.transaction;bundle-version="[1.4.0,2.0.0)";visibility:=reexport, + org.eclipse.gmf.runtime.notation;bundle-version="[1.5.0,2.0.0)", + org.eclipse.equinox.security;bundle-version="[1.1.100,2.0.0)", + org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", + com.google.guava;bundle-version="11.0.0", + org.eclipse.papyrus.infra.services.controlmode;bundle-version="1.2.0", + org.eclipse.gmf.runtime.emf.commands.core;bundle-version="[1.7.0,2.0.0)", + org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.services.localizer;bundle-version="1.2.0", + org.eclipse.net4j;bundle-version="[4.3.0,5.0.0)", + org.eclipse.emf.cdo.admin;bundle-version="[4.1.200,5.0.0)", + org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0" +Export-Package: org.eclipse.papyrus.cdo.core, + org.eclipse.papyrus.cdo.core.admin, + org.eclipse.papyrus.cdo.core.exporter, + org.eclipse.papyrus.cdo.core.importer, + org.eclipse.papyrus.cdo.core.resource, + org.eclipse.papyrus.cdo.core.util, + org.eclipse.papyrus.cdo.internal.core; x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui, + org.eclipse.papyrus.cdo.ui.tests, + org.eclipse.papyrus.cdo.uml.diagram.ui, + org.eclipse.papyrus.cdo.uml.ui, + org.eclipse.papyrus.cdo.ui.customization.properties, + org.eclipse.papyrus.cdo.uml.ui.tests, + org.eclipse.papyrus.cdo.uml.search.ui, + org.eclipse.papyrus.cdo.uml.search.ui.tests, + org.eclipse.papyrus.cdo.ui.hyperlink", + org.eclipse.papyrus.cdo.internal.core.controlmode;x-friends:="org.eclipse.papyrus.cdo.ui, + org.eclipse.papyrus.cdo.core.tests", + org.eclipse.papyrus.cdo.internal.core.exporter;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.expressions;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.importer;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.l10n;x-internal:=true, + org.eclipse.papyrus.cdo.internal.core.repositories;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.repositories.impl;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.repositories.util;x-friends:="org.eclipse.papyrus.cdo.core.tests, + org.eclipse.papyrus.cdo.ui", + org.eclipse.papyrus.cdo.internal.core.resource;x-internal:=true, + org.eclipse.papyrus.cdo.internal.core.services.localizer;x-internal:=true +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: . +Bundle-Version: 2.0.0.qualifier +Bundle-Localization: plugin +Bundle-Name: %pluginName +Bundle-Activator: org.eclipse.papyrus.cdo.internal.core.Activator +Bundle-ManifestVersion: 2 +Bundle-Description: %pluginDescription +Bundle-SymbolicName: org.eclipse.papyrus.cdo.core;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/pom.xml b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/pom.xml index 0c46d1947dc..0aeea61111e 100644 --- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/pom.xml +++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/pom.xml @@ -1,14 +1,14 @@ - - - 4.0.0 - - org.eclipse.papyrus.extra.releng - org.eclipse.papyrus - 3.0.0-SNAPSHOT - ../../../releng/extra - - org.eclipse.papyrus.cdo.core - org.eclipse.papyrus - 1.2.0-SNAPSHOT - eclipse-plugin + + + 4.0.0 + + org.eclipse.papyrus.extra.releng + org.eclipse.papyrus + 3.0.0-SNAPSHOT + ../../../releng/extra + + org.eclipse.papyrus.cdo.core + org.eclipse.papyrus + 2.0.0-SNAPSHOT + eclipse-plugin \ No newline at end of file diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java index f4ffeb54788..cf5e38ef10f 100644 --- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java +++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java @@ -13,6 +13,7 @@ * Christian W. Damus (CEA) - bug 437052 * Christian W. Damus - bug 436998 * Eike Stepper (CEA) - bug 466520 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.cdo.core.resource; @@ -386,7 +387,7 @@ public class CDOAwareModelSet extends OnDemandLoadingModelSet { } @Override - protected boolean deleteResource(URI uri) { + public boolean deleteResource(URI uri) { Resource res = getResource(uri, false); boolean result = res instanceof CDOResource; diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/.project b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/.project new file mode 100644 index 00000000000..1357edd30cd --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/.project @@ -0,0 +1,35 @@ + + + org.eclipse.papyrus.infra.internationalization.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + + org.eclipse.pde.FeatureNature + org.eclipse.oomph.version.VersionNature + + diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/build.properties b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/build.properties new file mode 100644 index 00000000000..b9ce3341aac --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/build.properties @@ -0,0 +1,7 @@ +bin.includes = feature.xml,\ + build.properties,\ + epl-v10.html,\ + license.html,\ + feature.properties +src.includes = epl-v10.html,\ + license.html diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/epl-v10.html b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/epl-v10.html new file mode 100644 index 00000000000..cb1073a4bad --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/epl-v10.html @@ -0,0 +1,304 @@ + + + + + + +Eclipse Public License - Version 1.0 + + + + + +
+ +

Eclipse Public License - v 1.0 +

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and
+b) in the case of each subsequent Contributor:

+ +

i) +changes to the Program, and

+ +

ii) +additions to the Program;

+ +

where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program.

+ +

"Contributor" means any person or +entity that distributes the Program.

+ +

"Licensed Patents " mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions +distributed in accordance with this Agreement.

+ +

"Recipient" means anyone who +receives the Program under this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.

+ +

b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.

+ +

d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that: +

+ +

a) +it complies with the terms and conditions of this Agreement; and

+ +

b) +its license agreement:

+ +

i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose;

+ +

ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits;

+ +

iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and

+ +

iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.

+ +

When the Program is made available in source +code form:

+ +

a) +it must be made available under this Agreement; and

+ +

b) a +copy of this Agreement must be included with each copy of the Program.

+ +

Contributors may not remove or alter any +copyright notices contained within the Program.

+ +

Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor ("Commercial +Contributor") hereby agrees to defend and indemnify every other +Contributor ("Indemnified Contributor") against any losses, damages and +costs (collectively "Losses") arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.

+ +

For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed.

+ +

All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.

+ +

This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.

+ +

+ +
+ + + + \ No newline at end of file diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.properties b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.properties new file mode 100644 index 00000000000..11ac9ede269 --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.properties @@ -0,0 +1,132 @@ +# NLS_MESSAGEFORMAT_VAR + +# "licenseURL" property - URL of the "Feature License" +# do not translate value - just change to point to a locale-specific HTML page +licenseURL=license.html + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ +Eclipse Foundation Software User Agreement\n\ +April 9, 2014\n\ +\n\ +Usage Of Content\n\ +\n\ +THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ +OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ +USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ +AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ +NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ +AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ +AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ +OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ +TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ +OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ +BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ +\n\ +Applicable Licenses\n\ +\n\ +Unless otherwise indicated, all Content made available by the\n\ +Eclipse Foundation is provided to you under the terms and conditions of\n\ +the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\ +provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ +For purposes of the EPL, "Program" will mean the Content.\n\ +\n\ +Content includes, but is not limited to, source code, object code,\n\ +documentation and other files maintained in the Eclipse Foundation source code\n\ +repository ("Repository") in software modules ("Modules") and made available\n\ +as downloadable archives ("Downloads").\n\ +\n\ +\t- Content may be structured and packaged into modules to facilitate delivering,\n\ +\t extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ +\t plug-in fragments ("Fragments"), and features ("Features").\n\ +\t- Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\ +\t in a directory named "plugins".\n\ +\t- A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ +\t Each Feature may be packaged as a sub-directory in a directory named "features".\n\ +\t Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ +\t numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ +\t- Features may also include other Features ("Included Features"). Within a Feature, files\n\ +\t named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ +\n\ +The terms and conditions governing Plug-ins and Fragments should be\n\ +contained in files named "about.html" ("Abouts"). The terms and\n\ +conditions governing Features and Included Features should be contained\n\ +in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ +Licenses may be located in any directory of a Download or Module\n\ +including, but not limited to the following locations:\n\ +\n\ +\t- The top-level (root) directory\n\ +\t- Plug-in and Fragment directories\n\ +\t- Inside Plug-ins and Fragments packaged as JARs\n\ +\t- Sub-directories of the directory named "src" of certain Plug-ins\n\ +\t- Feature directories\n\ +\n\ +Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ +Provisioning Technology (as defined below), you must agree to a license ("Feature \n\ +Update License") during the installation process. If the Feature contains\n\ +Included Features, the Feature Update License should either provide you\n\ +with the terms and conditions governing the Included Features or inform\n\ +you where you can locate them. Feature Update Licenses may be found in\n\ +the "license" property of files named "feature.properties" found within a Feature.\n\ +Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\ +terms and conditions (or references to such terms and conditions) that\n\ +govern your use of the associated Content in that directory.\n\ +\n\ +THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\ +TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ +SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ +\n\ +\t- Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\ +\t- Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ +\t- Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ +\t- Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ +\t- Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ +\n\ +IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ +TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\ +is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ +govern that particular Content.\n\ +\n\ +\n\Use of Provisioning Technology\n\ +\n\ +The Eclipse Foundation makes available provisioning software, examples of which include,\n\ +but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\ +the purpose of allowing users to install software, documentation, information and/or\n\ +other materials (collectively "Installable Software"). This capability is provided with\n\ +the intent of allowing such users to install, extend and update Eclipse-based products.\n\ +Information about packaging Installable Software is available at\n\ +http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\ +\n\ +You may use Provisioning Technology to allow other parties to install Installable Software.\n\ +You shall be responsible for enabling the applicable license agreements relating to the\n\ +Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\ +in accordance with the Specification. By using Provisioning Technology in such a manner and\n\ +making it available in accordance with the Specification, you further acknowledge your\n\ +agreement to, and the acquisition of all necessary rights to permit the following:\n\ +\n\ +\t1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\ +\t the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\ +\t extending or updating the functionality of an Eclipse-based product.\n\ +\t2. During the Provisioning Process, the Provisioning Technology may cause third party\n\ +\t Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\ +\t3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\ +\t govern the use of the Installable Software ("Installable Software Agreement") and such\n\ +\t Installable Software Agreement shall be accessed from the Target Machine in accordance\n\ +\t with the Specification. Such Installable Software Agreement must inform the user of the\n\ +\t terms and conditions that govern the Installable Software and must solicit acceptance by\n\ +\t the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\ +\t indication of agreement by the user, the provisioning Technology will complete installation\n\ +\t of the Installable Software.\n\ +\n\ +Cryptography\n\ +\n\ +Content may contain encryption software. The country in which you are\n\ +currently may have restrictions on the import, possession, and use,\n\ +and/or re-export to another country, of encryption software. BEFORE\n\ +using any encryption software, please check the country's laws,\n\ +regulations and policies concerning the import, possession, or use, and\n\ +re-export of encryption software, to see if this is permitted.\n\ +\n\ +Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n +########### end of license property ########################################## diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.xml b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.xml new file mode 100644 index 00000000000..632b1d82aac --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/feature.xml @@ -0,0 +1,29 @@ + + + + Copyright (c) 2016 CEA LIST +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 + + + + %license + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/license.html b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/license.html new file mode 100644 index 00000000000..c3d34c3c21e --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/license.html @@ -0,0 +1,107 @@ + + + + + +Eclipse Foundation Software User Agreement + + + +

Eclipse Foundation Software User Agreement

+

April 9, 2014

+ +

Usage Of Content

+ +

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

+ +

Applicable Licenses

+ +

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. + For purposes of the EPL, "Program" will mean the Content.

+ +

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code + repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").

+ + + +

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:

+ + + +

Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.

+ +

THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

+ + + +

IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

+ + +

Use of Provisioning Technology

+ +

The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse + Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or + other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to + install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html + ("Specification").

+ +

You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the + applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology + in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the + Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:

+ +
    +
  1. A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology + on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based + product.
  2. +
  3. During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be + accessed and copied to the Target Machine.
  4. +
  5. Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable + Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target + Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern + the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such + indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.
  6. +
+ +

Cryptography

+ +

Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.

+ +

Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.

+ + diff --git a/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/pom.xml b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/pom.xml new file mode 100644 index 00000000000..41a8d968098 --- /dev/null +++ b/features/papyrus-main-features/org.eclipse.papyrus.infra.internationalization.feature/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus + org.eclipse.papyrus.features + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.feature + 1.0.0-SNAPSHOT + eclipse-feature + \ No newline at end of file diff --git a/features/papyrus-main-features/org.eclipse.papyrus.sdk.feature/feature.xml b/features/papyrus-main-features/org.eclipse.papyrus.sdk.feature/feature.xml index a5d447dc29d..59fd99edd00 100644 --- a/features/papyrus-main-features/org.eclipse.papyrus.sdk.feature/feature.xml +++ b/features/papyrus-main-features/org.eclipse.papyrus.sdk.feature/feature.xml @@ -117,6 +117,10 @@ http://www.eclipse.org/legal/epl-v10.html + + org.eclipse.papyrus.infra.feature org.eclipse.papyrus.infra.gmfdiag.css.feature org.eclipse.papyrus.infra.gmfdiag.feature + org.eclipse.papyrus.infra.internationalization.feature org.eclipse.papyrus.infra.nattable.feature org.eclipse.papyrus.infra.services.feature org.eclipse.papyrus.infra.ui.feature diff --git a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF index 72779849904..74335c6544c 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF +++ b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF @@ -2,7 +2,8 @@ Manifest-Version: 1.0 Export-Package: org.eclipse.papyrus.editor Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="[1.8.0,2.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)" + org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 2.0.0.qualifier diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java index 2f963b10320..ed198c75175 100644 --- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java +++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java @@ -1,124 +1,144 @@ -/** - * - */ -package org.eclipse.papyrus.editor.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.editor.Activator; -import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.core.services.ServicesRegistry; -import org.eclipse.papyrus.infra.core.utils.ServiceUtils; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; - -/** - * A command to be used with the Eclipse Commands Framework. - * This command is to be used with {@link SashWindowsContainer} implemented with the Di model. - * This command allows to rename a nested editor. - * - * This command use a Transaction. - * TODO Move to gmf adapter. - * - * @author cedric dumoulin - * - */ -public class RenameNestedEditorCommand extends AbstractHandler { - - /** - * Check if the Command is enabled. - */ - @Override - public void setEnabled(Object evaluationContext) { - // System.out.println("call to CloseDiagramCommand.setEnable(" + evaluationContext + ")"); - } - - /** - * Execute the command. This method is called when the action is triggered. - * - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - // try { - // IEditorPart part = HandlerUtil.getActiveEditor(event); - // IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); - // ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); - // IPage sashPage = container.getActiveSashWindowsPage(); - // - // if(sashPage instanceof IEditorPage ) - // { - // IEditorPage editorPage = (IEditorPage)sashPage; - // execute(editorPage.getRawModel(), editorPage.getIEditorPart()); - // } - // // Bug from sash Di to be corrected - // if(pageIdentifier instanceof PageRef) - // { - // pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); - // } - // execute(sashPage.getRawModel(), sashPage.); - // - // } catch (NullPointerException e) { - // // PageMngr can't be found - // return null; - // } - - - - return null; - } - - /** - * Close selected page. - * - * @param pageMngr - */ - public void execute(final Diagram diagram, final IEditorPart editorPart) { - TransactionalEditingDomain editingDomain = null; - - if (editorPart instanceof IAdaptable) { - ServicesRegistry registry = (ServicesRegistry) ((IAdaptable) editorPart).getAdapter(ServicesRegistry.class); - - if (registry == null) { - editingDomain = (TransactionalEditingDomain) ((IAdaptable) editorPart).getAdapter(TransactionalEditingDomain.class); - } else { - try { - editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry); - } catch (ServiceException ex) { - Activator.log.error(ex); - } - } - } - - - if (editingDomain != null) { - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null); - if (dialog.open() == Window.OK) { - final String name = dialog.getValue(); - if (name != null && name.length() > 0) { - - Command command = new RecordingCommand(editingDomain) { - - - @Override - protected void doExecute() { - diagram.setName(name); - } - }; - - editingDomain.getCommandStack().execute(command); - } - } - } - } - -} +/***************************************************************************** + * Copyright (c) 2016 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.editor.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.editor.Activator; +import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtils; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; + +/** + * A command to be used with the Eclipse Commands Framework. + * This command is to be used with {@link SashWindowsContainer} implemented with the Di model. + * This command allows to rename a nested editor. + * + * This command use a Transaction. + * TODO Move to gmf adapter. + * + * @author cedric dumoulin + * + */ +public class RenameNestedEditorCommand extends AbstractHandler { + + /** + * Check if the Command is enabled. + */ + @Override + public void setEnabled(Object evaluationContext) { + // System.out.println("call to CloseDiagramCommand.setEnable(" + evaluationContext + ")"); + } + + /** + * Execute the command. This method is called when the action is triggered. + * + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + // try { + // IEditorPart part = HandlerUtil.getActiveEditor(event); + // IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class); + // ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class); + // IPage sashPage = container.getActiveSashWindowsPage(); + // + // if(sashPage instanceof IEditorPage ) + // { + // IEditorPage editorPage = (IEditorPage)sashPage; + // execute(editorPage.getRawModel(), editorPage.getIEditorPart()); + // } + // // Bug from sash Di to be corrected + // if(pageIdentifier instanceof PageRef) + // { + // pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier(); + // } + // execute(sashPage.getRawModel(), sashPage.); + // + // } catch (NullPointerException e) { + // // PageMngr can't be found + // return null; + // } + + + + return null; + } + + /** + * Close selected page. + * + * @param pageMngr + */ + public void execute(final Diagram diagram, final IEditorPart editorPart) { + TransactionalEditingDomain editingDomain = null; + + if (editorPart instanceof IAdaptable) { + ServicesRegistry registry = (ServicesRegistry) ((IAdaptable) editorPart).getAdapter(ServicesRegistry.class); + + if (registry == null) { + editingDomain = (TransactionalEditingDomain) ((IAdaptable) editorPart).getAdapter(TransactionalEditingDomain.class); + } else { + try { + editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry); + } catch (ServiceException ex) { + Activator.log.error(ex); + } + } + } + + if (editingDomain != null) { + // If the diagram label is available, modify this one. + final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(diagram); + if(null != diagramLabel){ + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename diagram label", "New label:", diagramLabel, null); //$NON-NLS-1$ //$NON-NLS-2$ + if (Window.OK == dialog.open()) { + final String label = dialog.getValue(); + editingDomain.getCommandStack().execute(LabelInternationalization.getInstance().getSetDiagramLabelCommand(editingDomain, diagram, label, null)); + } + }else{ + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$ + if (dialog.open() == Window.OK) { + final String name = dialog.getValue(); + if (name != null && name.length() > 0) { + + Command command = new RecordingCommand(editingDomain) { + + + @Override + protected void doExecute() { + diagram.setName(name); + } + }; + + editingDomain.getCommandStack().execute(command); + } + } + } + } + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF index 95629903d82..ebb63f5503d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/META-INF/MANIFEST.MF @@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.papyrus.emf.facet.custom.core;bundle-version="[2.0.0 org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)", org.eclipse.papyrus.emf.facet.util.swt;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.emf.facet.util.jface.ui;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.emf.facet.common.ui;bundle-version="[1.2.0,2.0.0)" + org.eclipse.papyrus.emf.facet.common.ui;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.edit;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy Bundle-Version: 2.0.0.qualifier diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java index 9961cae90ec..156d2ceab6a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java @@ -1,141 +1,144 @@ -/** - * Copyright (c) 2011, 2014 Mia-Software, CEA, and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model - * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework - * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning - * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List, List) - * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider - * Christian W. Damus (CEA) - bug 410346 - */ -package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.ETypedElement; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.IItemLabelProvider; -import org.eclipse.emf.edit.provider.ReflectiveItemProvider; -import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; -import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; -import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; -import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; -import org.eclipse.papyrus.emf.facet.util.emf.core.ModelUtils; - -public class LabelQuery implements IJavaQuery2 { - - private static final String NAME = "name"; //$NON-NLS-1$ - - public String evaluate(final EObject source, - final IParameterValueList2 parameterValues, - final IFacetManager facetManager) - throws DerivedTypedElementException { - ETypedElement sfParam = null; - if (parameterValues != null) { - sfParam = (ETypedElement) parameterValues - .getParameterValueByName("eStructuralFeature").getValue(); //$NON-NLS-1$ - } - String result = null; - if (sfParam == null) { - final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory( - ComposedAdapterFactory.Descriptor.Registry.INSTANCE); - - try { - final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(source, IItemLabelProvider.class); - // We don't want to use a ReflectiveItemProvider because it provides - // a string prefixed with the eObject's meta-class name. - if (itemLabelProvider instanceof ReflectiveItemProvider) { - result = LabelQuery.getDefaultName(source); - } else if (itemLabelProvider == null) { - result = ModelUtils.getDefaultName(source); - } else { - result = itemLabelProvider.getText(source); - } - } finally { - // Dispose the adapter factory because it added an adapter that would leak, as nobody else will ever use it - adapterFactory.dispose(); - } - } else { - try { - if (sfParam instanceof EAttribute && sfParam.getUpperBound() == 1) { - final Object object = facetManager.getOrInvoke(source, sfParam, Object.class); - final String objectLabel = getObjectLabel(object, facetManager); - result = sfParam.getName() + " = " + objectLabel; //$NON-NLS-1$ - } else { - result = sfParam.getName(); - } - } catch (final Exception e) { - throw new DerivedTypedElementException(e); - } - } - return result; - } - - private String getObjectLabel(final Object object, - final IFacetManager facetManager) - throws DerivedTypedElementException { - String result; - if (object instanceof EObject) { - final EObject eObject = (EObject) object; - result = evaluate(eObject, null, facetManager); - } else { - result = String.valueOf(object); - } - return result; - } - - /** - * @return a default name based on a string feature of the given {@link EObject} - */ - // from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils - public static String getDefaultName(final EObject eObject) { - String result = ""; //$NON-NLS-1$ - // find a feature that can be used as a name - final EStructuralFeature feature = LabelQuery.getLabelFeature(eObject - .eClass()); - if (feature != null) { - result = (String) eObject.eGet(feature); - } - return result; - } - - /** - * This method searches for a structural feature that can be used as a name - * - * @param eClass - * in which class to search a structural feature that can be used as - * a name - * @return an EStructuralFeature - */ - // Copied from org.eclipse.emf.edit.provider.ReflectiveItemProvider to org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils - // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils - private static EStructuralFeature getLabelFeature(final EClass eClass) { - EAttribute result = null; - for (final EAttribute eAttribute : eClass.getEAllAttributes()) { - if (!eAttribute.isMany() - && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) { - if (LabelQuery.NAME.equalsIgnoreCase(eAttribute - .getName())) { - result = eAttribute; - break; - } else if (result == null) { - result = eAttribute; - } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class - && result.getEAttributeType().getInstanceClass() != String.class) { - result = eAttribute; - } - } - } - return result; - } - -} +/** + * Copyright (c) 2011, 2014 Mia-Software, CEA, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List, List) + * Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider + * Christian W. Damus (CEA) - bug 410346 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + */ +package org.eclipse.papyrus.emf.facet.custom.ui.internal.query; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.ReflectiveItemProvider; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.emf.facet.util.emf.core.ModelUtils; +import org.eclipse.papyrus.infra.internationalization.edit.provider.InternationalizationNotationItemProviderAdapterFactory; + +public class LabelQuery implements IJavaQuery2 { + + private static final String NAME = "name"; //$NON-NLS-1$ + + public String evaluate(final EObject source, + final IParameterValueList2 parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + ETypedElement sfParam = null; + if (parameterValues != null) { + sfParam = (ETypedElement) parameterValues + .getParameterValueByName("eStructuralFeature").getValue(); //$NON-NLS-1$ + } + String result = null; + if (sfParam == null) { + final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory( + ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + adapterFactory.insertAdapterFactory(new InternationalizationNotationItemProviderAdapterFactory()); + + try { + final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory.adapt(source, IItemLabelProvider.class); + // We don't want to use a ReflectiveItemProvider because it provides + // a string prefixed with the eObject's meta-class name. + if (itemLabelProvider instanceof ReflectiveItemProvider) { + result = LabelQuery.getDefaultName(source); + } else if (itemLabelProvider == null) { + result = ModelUtils.getDefaultName(source); + } else { + result = itemLabelProvider.getText(source); + } + } finally { + // Dispose the adapter factory because it added an adapter that would leak, as nobody else will ever use it + adapterFactory.dispose(); + } + } else { + try { + if (sfParam instanceof EAttribute && sfParam.getUpperBound() == 1) { + final Object object = facetManager.getOrInvoke(source, sfParam, Object.class); + final String objectLabel = getObjectLabel(object, facetManager); + result = sfParam.getName() + " = " + objectLabel; //$NON-NLS-1$ + } else { + result = sfParam.getName(); + } + } catch (final Exception e) { + throw new DerivedTypedElementException(e); + } + } + return result; + } + + private String getObjectLabel(final Object object, + final IFacetManager facetManager) + throws DerivedTypedElementException { + String result; + if (object instanceof EObject) { + final EObject eObject = (EObject) object; + result = evaluate(eObject, null, facetManager); + } else { + result = String.valueOf(object); + } + return result; + } + + /** + * @return a default name based on a string feature of the given {@link EObject} + */ + // from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils + public static String getDefaultName(final EObject eObject) { + String result = ""; //$NON-NLS-1$ + // find a feature that can be used as a name + final EStructuralFeature feature = LabelQuery.getLabelFeature(eObject + .eClass()); + if (feature != null) { + result = (String) eObject.eGet(feature); + } + return result; + } + + /** + * This method searches for a structural feature that can be used as a name + * + * @param eClass + * in which class to search a structural feature that can be used as + * a name + * @return an EStructuralFeature + */ + // Copied from org.eclipse.emf.edit.provider.ReflectiveItemProvider to org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils + // Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils + private static EStructuralFeature getLabelFeature(final EClass eClass) { + EAttribute result = null; + for (final EAttribute eAttribute : eClass.getEAllAttributes()) { + if (!eAttribute.isMany() + && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) { + if (LabelQuery.NAME.equalsIgnoreCase(eAttribute + .getName())) { + result = eAttribute; + break; + } else if (result == null) { + result = eAttribute; + } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class + && result.getEAttributeType().getInstanceClass() != String.class) { + result = eAttribute; + } + } + } + return result; + } + +} diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF index be0b3be7e36..8725c017613 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/META-INF/MANIFEST.MF @@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.emf.workspace;bundle-version="[1.5.0,2.0.0)", org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.infra.core.Activator diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml index 2524dc5f316..5511a52363f 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/pom.xml @@ -7,6 +7,6 @@ 0.0.1-SNAPSHOT org.eclipse.papyrus.infra.core - 2.2.0-SNAPSHOT + 2.3.0-SNAPSHOT eclipse-plugin
\ No newline at end of file diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java index 884a997c7e4..2f2eaf40748 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java @@ -9,6 +9,7 @@ * Contributors: * LIFL - Initial API and implementation * Christian W. Damus - bugs 485220, 496299 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.core.resource; @@ -46,8 +47,10 @@ public abstract class AbstractModelWithSharedResource extends /** * Model kind. + * + * @since 2.0 */ - private ModelKind modelKind; + protected ModelKind modelKind; /** * diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java index 46a6003edc5..9b2709a4e9a 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AdjunctResourceModelSnippet.java @@ -8,6 +8,7 @@ * * Contributors: * Christian W. Damus - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ @@ -89,16 +90,29 @@ public class AdjunctResourceModelSnippet implements IModelSnippet { if (converter.exists(adjunctURI, Collections.emptyMap())) { // Best effort load. This must not interfere with other // resource set operations - try { - resourceSet.getResource(adjunctURI, true); - } catch (Exception e) { - Activator.log.error( - String.format("Failed to load %s resource", model.getModelFileExtension()), //$NON-NLS-1$ - e); - } + loadResource(model, resourceSet, adjunctURI); } } } } + /** + * This allows to load the model. + * + * @param model The {@link EMFLogicalModel}. + * @param resourceSet The resource set. + * @param adjunctURI The adjunct URI. + * + * @since 2.3 + */ + protected void loadResource(final EMFLogicalModel model, final ResourceSet resourceSet, final URI adjunctURI){ + try { + resourceSet.getResource(adjunctURI, true); + } catch (final Exception e) { + Activator.log.error( + String.format("Failed to load %s resource", model.getModelFileExtension()), //$NON-NLS-1$ + e); + } + } + } diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java index 85a7c146bca..b66c3aa0526 100644 --- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/ModelSet.java @@ -17,6 +17,7 @@ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952 * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998 * Christian W. Damus - bugs 436998, 468030, 485220 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.core.resource; @@ -853,7 +854,14 @@ public class ModelSet extends ResourceSetImpl { return result; } - protected boolean deleteResource(URI uri) { + /** + * This allows to delete a resource from the uri. + * + * @param uri The uri of the resource to delete. + * @return true if the resource is deleted, false otherwise. + * @since 2.3 + */ + public boolean deleteResource(final URI uri) { boolean result = false; try { diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java new file mode 100644 index 00000000000..635d3388e7f --- /dev/null +++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/PapyrusProjectScope.java @@ -0,0 +1,124 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.core.resource; + +import org.eclipse.core.internal.preferences.AbstractScope; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; + +/** + * This papyrus scope for the papyrus project preference store. + * This need to manage the preference for the papyrus project with the papyrus project name (to retrieve the correct name). + * + * @since 2.2 + */ +@SuppressWarnings("restriction") +public class PapyrusProjectScope extends AbstractScope { + + /** + * String constant (value of "papyrusProject") used for the scope name for this preference scope. + */ + public static final String SCOPE = "papyrusProject"; //$NON-NLS-1$ + + /** + * The papyrus project name. + */ + private String papyrusProjectName; + + /** + * The context project. + */ + private IProject context; + + /** + * Constructor. + * + * @param project + * The project. + * @param papyrusProjectName + * The name of the '.di' file. + */ + public PapyrusProjectScope(final IProject project, final String papyrusProjectName) { + this.context = project; + this.papyrusProjectName = papyrusProjectName; + } + + /** + * Default path hierarchy for nodes is //. + * + * @param qualifier The qualifier. + * @return The path hierarchy. + */ + @Override + public IEclipsePreferences getNode(final String qualifier) { + if (qualifier == null) + throw new IllegalArgumentException(); + final StringBuilder node = new StringBuilder(context.getName()); + node.append("/"); //$NON-NLS-1$ + node.append(papyrusProjectName); + return (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(SCOPE).node(node.toString()).node(qualifier); + } + + /** + * The papyrus scope name. + * + * @return The papyrus scope name. + */ + @Override + public String getName() { + return SCOPE; + } + + /** + * The location of the scope. + * + * @return The location of the scope. + */ + @Override + public IPath getLocation() { + // This must not be save + return null; + } + + /** + * This allows to determinate if the object in parameter is equals to the current. + * + * @param obj The object to compare. + * @return true if this is equals, false otherwise. + */ + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (!(obj instanceof PapyrusProjectScope)) + return false; + PapyrusProjectScope other = (PapyrusProjectScope) obj; + return context.equals(other.context) && papyrusProjectName.equals(other.papyrusProjectName); + } + + /** + * This allows to define the int hash code. + * + * @return The int representing the hascode. + */ + @Override + public int hashCode() { + return super.hashCode() + context.getFullPath().hashCode() + "/".hashCode() + papyrusProjectName.hashCode(); //$NON-NLS-1$ + } + +} diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF index 0436405a78f..d858787d465 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Require-Bundle: org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)" org.eclipse.gmf.runtime.common.core;bundle-version="[1.7.0,2.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.infra.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)";visibility:=reexport + org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 3.0.0.qualifier diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/internal/ControlledResourceTracker.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/internal/ControlledResourceTracker.java index d99fc22337e..a3db4d85c2e 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/internal/ControlledResourceTracker.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/internal/ControlledResourceTracker.java @@ -9,6 +9,7 @@ * Contributors: * Christian W. Damus (CEA) - Initial API and implementation * Christian W. Damus - bugs 463631, 485220 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * */ package org.eclipse.papyrus.infra.emf.readonly.internal; @@ -31,6 +32,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.emf.transaction.TransactionalEditingDomainEvent; import org.eclipse.emf.transaction.TransactionalEditingDomainListener; import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.pde.internal.ui.util.LocaleUtil; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Iterables; @@ -45,6 +47,7 @@ import com.google.common.collect.Sets; * is necessary to ensure that the ephemeral states during controlling and uncontrolling a sub-model don't fool the editing domain into thinking * we're making changes to a read-only resource, triggering roll-back. */ +@SuppressWarnings("restriction") public class ControlledResourceTracker extends AdapterImpl implements TransactionalEditingDomainListener { // A resource may be a sub-unit of multiple parent units (it can have multiple roots that are @@ -108,7 +111,7 @@ public class ControlledResourceTracker extends AdapterImpl implements Transactio for (URI next = units.poll(); next != null; next = units.poll()) { if (isRoot(next)) { - result.add(next); + result.add(getFinalURI(uri, next)); } else { Iterables.addAll(units, get(next)); } @@ -116,6 +119,37 @@ public class ControlledResourceTracker extends AdapterImpl implements Transactio return result; } + + /** + * Get the URI modified if necessary (for example, the properties file can have a locale at the end of the file). + * + * @param uri + * The URI of a resource that potentially is in a sub-model unit. + * @param initialURI + * The initial URI of the sub model unit. + * @return The modified URI (or not modified if don't needed). + */ + private URI getFinalURI(final URI uri, final URI initialURI) { + URI result = initialURI; + + // If this is a properties file, check if a locale is available at the end of the URI + if (uri.fileExtension().equals("properties")) { //$NON-NLS-1$ + // Get the last segment + final String lastSegment = initialURI.lastSegment(); + // Try to remove existing localization + final String withoutLocalization = LocaleUtil.trimLocalization(lastSegment); + + // If the initial last segment and the segment without localization are not equals, localization exist + if (!lastSegment.equals(withoutLocalization)) { + // Remove the last segment + result = initialURI.trimSegments(1); + // Add the modified last segment + result = result.appendSegment(withoutLocalization); + } + } + + return result; + } /** * Queries whether the given URI (without extension, thus representing the set of Papyrus resources comprising diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddEAnnotationDetailCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddEAnnotationDetailCommand.java new file mode 100644 index 00000000000..4b490bccf42 --- /dev/null +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddEAnnotationDetailCommand.java @@ -0,0 +1,69 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.emf.commands; + +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; + +/** + * This allows to add a detail into the annotation. + */ +public class AddEAnnotationDetailCommand extends RecordingCommand { + + /** + * The owner annotation. + */ + private EAnnotation eAnnotation; + + /** + * The key to add. + */ + private String detailKey; + + /** + * The value of the detail key. + */ + private String value; + + /** + * Constructor. + * + * @param domain + * The editing domain. + * @param annotation + * The owner annotation. + * @param detailKey + * The key to add. + * @param value + * The value of the detail key. + */ + public AddEAnnotationDetailCommand(final TransactionalEditingDomain domain, final EAnnotation annotation, final String detailKey, final String value) { + super(domain); + this.eAnnotation = annotation; + this.detailKey = detailKey; + this.value = value; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + */ + @Override + protected void doExecute() { + eAnnotation.getDetails().put(detailKey, value); + } + +} diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java index 76f2b533692..9daa7d391c3 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012 CEA LIST. + * Copyright (c) 2016 CEA LIST. * * * All rights reserved. This program and the accompanying materials @@ -8,21 +8,24 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation * *****************************************************************************/ package org.eclipse.papyrus.infra.emf.commands; -import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; /** - * * This command allows to add an EObject to a resource - * */ -public class AddToResourceCommand extends AbstractCommand { +public class AddToResourceCommand extends AbstractTransactionalCommand { /** * the resource @@ -38,63 +41,27 @@ public class AddToResourceCommand extends AbstractCommand { * * Constructor. * + * @param domain + * The editing domain. * @param resource * the resource * @param toAdd * the object to add to the resource */ - public AddToResourceCommand(final Resource resource, final EObject toAdd) { + public AddToResourceCommand(final TransactionalEditingDomain domain, final Resource resource, final EObject toAdd) { + super(domain, "Add an object to a resource", null); this.resource = resource; this.toAdd = toAdd; - setLabel("Add an object to a resource"); - } - - /** - * - * @see org.eclipse.emf.common.command.Command#execute() - * - */ - public void execute() { - this.resource.getContents().add(this.toAdd); } /** - * - * @see org.eclipse.emf.common.command.Command#redo() - * - */ - public void redo() { - execute(); - } - - /** - * - * @see org.eclipse.emf.common.command.AbstractCommand#prepare() - * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) */ @Override - protected boolean prepare() { - return true; - } - - - /** - * - * @see org.eclipse.emf.common.command.AbstractCommand#undo() - * - */ - @Override - public void undo() { - this.resource.getContents().remove(this.toAdd); - } - - /** - * - * @see org.eclipse.emf.common.command.AbstractCommand#canExecute() - * - */ - @Override - public boolean canExecute() { - return super.canExecute() && this.resource != null; + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + this.resource.getContents().add(this.toAdd); + return CommandResult.newOKCommandResult(); } } diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF index 1926a6e9290..f4286b65a70 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)";visibili org.eclipse.papyrus.emf.facet.custom.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.emf.readonly;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport + org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %pluginProvider Bundle-ActivationPolicy: lazy Bundle-Version: 2.0.0.qualifier diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/internal/emf/readonly/handlers/ReferencedModelReadOnlyHandler.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/internal/emf/readonly/handlers/ReferencedModelReadOnlyHandler.java index d08fdc7296f..62b05b49265 100644 --- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/internal/emf/readonly/handlers/ReferencedModelReadOnlyHandler.java +++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/internal/emf/readonly/handlers/ReferencedModelReadOnlyHandler.java @@ -9,6 +9,7 @@ * Contributors: * Christian W. Damus (CEA) - Initial API and implementation * Christian W. Damus - bug 463631 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * */ package org.eclipse.papyrus.infra.ui.internal.emf.readonly.handlers; @@ -188,7 +189,8 @@ public class ReferencedModelReadOnlyHandler extends AbstractReadOnlyHandler impl Set rootURIs = resolveRootResourceURIs(modelSet, uri); if (!rootURIs.isEmpty()) { - result = modelSet.isUserModelResource(rootURIs.iterator().next()) + URI next = rootURIs.iterator().next(); + result = modelSet.isUserModelResource(next) && !rootURIs.contains(modelSet.getURIWithoutExtension()); } } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF index a3d544e8994..247d2fbd75d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Require-Bundle: org.eclipse.emf.transaction.ui;bundle-version="[1.4.0,2.0.0)", org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="[1.7.0,2.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport + org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Export-Package: org.eclipse.papyrus.commands, org.eclipse.papyrus.commands.util, org.eclipse.papyrus.commands.wrappers diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java index 2ed0050da80..775298271b8 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java @@ -1,218 +1,232 @@ -/***************************************************************************** - * Copyright (c) 2013, 2016 Cedric Dumoulin, Christian W. Damus, and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation - * Christian W. Damus - bug 485220 - * - *****************************************************************************/ -package org.eclipse.papyrus.commands; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.expressions.IEvaluationContext; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.commands.messages.Messages; -import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; - -/** - * This handler allows to rename a gmf diagram. - * The handler is activated when the current selection denote a gmf diagram. - * - *
- * There is another RenameHandler in Papyrus (for modelexplorer): - * /org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java - * - * @author cedric dumoulin - * - */ -public class RenameDiagramHandler extends AbstractHandler { - - /** - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * @param event - * @return - * @throws ExecutionException - * - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - executeTransaction(event); - - return null; - } - - /** - * Execute as transaction - * - * @param event - */ - private void executeTransaction(ExecutionEvent event) { - - // Get requested objects - final Diagram notationDiagramHelper; - TransactionalEditingDomain editingDomain; - try { - IEvaluationContext context = getIEvaluationContext(event); - notationDiagramHelper = lookupNotationDiagramChecked(context); - editingDomain = lookupTransactionalEditingDomain(context); - } catch (NotFoundException e) { - // silently fails - return; - } catch (ServiceException e) { - // silently fails - return; - } - - // Open the dialog to ask the new name - String currentName = notationDiagramHelper.getName(); - String newName = null; - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null); - if (dialog.open() == Window.OK) { - newName = dialog.getValue(); - if (newName == null || newName.length() <= 0) { - return; - } - } else { - // cancelled - return; - } - - final String name = newName; - Command cmd = new RecordingCommand(editingDomain, getCommandName()) { - - @Override - protected void doExecute() { - // Rename the diagram ! - notationDiagramHelper.setName(name); - } - - - }; - - editingDomain.getCommandStack().execute(cmd); - - } - - /** - * Get the name used in the {@link RecordingCommand}. This name will be visible in - * undo/redo. - * - * @return The command name to show. - */ - public String getCommandName() { - return Messages.RenameDiagramHandler_RenameDiagram; - } - - protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) throws NotFoundException { - try { - return (IEvaluationContext) event.getApplicationContext(); - } catch (ClassCastException e) { - throw new NotFoundException("IEvaluationContext can't be found."); //$NON-NLS-1$ - } - - } - - // /** - // * - // * @return - // * @throws NotFoundException - // */ - // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { - // - // return lookupLayersViewChecked().getLayerStackMngrChecked(); - // - // } - - /** - * Get the notation diagram helper. - * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. - * - * @return The - * @throws NotFoundException - * @throws ServiceException - */ - protected Diagram lookupNotationDiagramChecked(IEvaluationContext context) throws NotFoundException, ServiceException { - - - // Get page from the event ! - IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(ISashWindowsContainer.class, context).getActiveEditor(); - - if (!(editor instanceof DiagramDocumentEditor)) { - throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$ - } - DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor; - - Diagram diagram = diagramEditor.getDiagram(); - if (diagram == null) { - throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$ - } - - // Return a new instance of the Helper - return diagram; - } - - /** - * Try to lookup the TransactionalEditingDomain. - * - * @return - * @throws ServiceException - * If the Editing domain can't be found. - */ - protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException { - - // Get page from the event ! - // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); - - return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); - } - - /** - * Called by framework. Need to set the enabled flag. - * - * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) - * - * @param evaluationContext - */ - @Override - public void setEnabled(Object evaluationContext) { - - if (!(evaluationContext instanceof IEvaluationContext)) { - setBaseEnabled(false); - return; - } - - IEvaluationContext context = (IEvaluationContext) evaluationContext; - - try { - // Try to get the diagram - lookupNotationDiagramChecked(context); - - // ok, we got it. - setBaseEnabled(true); - - } catch (ServiceException e) { - // Can't find ServiceRegistry: disable - setBaseEnabled(false); - } catch (NotFoundException e) { - // Can't find ServiceRegistry: disable - setBaseEnabled(false); - } - - } -} +/***************************************************************************** + * Copyright (c) 2013, 2016 Cedric Dumoulin, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation + * Christian W. Damus - bug 485220 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.commands.messages.Messages; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; + +/** + * This handler allows to rename a gmf diagram. + * The handler is activated when the current selection denote a gmf diagram. + * + *
+ * There is another RenameHandler in Papyrus (for modelexplorer): + * /org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java + * + * @author cedric dumoulin + * + */ +public class RenameDiagramHandler extends AbstractHandler { + + /** + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * @param event + * @return + * @throws ExecutionException + * + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + executeTransaction(event); + + return null; + } + + /** + * Execute as transaction + * + * @param event + */ + private void executeTransaction(ExecutionEvent event) { + + // Get requested objects + final Diagram notationDiagramHelper; + TransactionalEditingDomain editingDomain; + try { + IEvaluationContext context = getIEvaluationContext(event); + notationDiagramHelper = lookupNotationDiagramChecked(context); + editingDomain = lookupTransactionalEditingDomain(context); + } catch (NotFoundException e) { + // silently fails + return; + } catch (ServiceException e) { + // silently fails + return; + } + + // If the diagram label is available, modify this one. + Command cmd = null; + final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(notationDiagramHelper); + if(null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(notationDiagramHelper)){ + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename diagram label", "New label:", diagramLabel, null); //$NON-NLS-1$ //$NON-NLS-2$ + if (Window.OK == dialog.open()) { + final String label = dialog.getValue(); + cmd = LabelInternationalization.getInstance().getSetDiagramLabelCommand(editingDomain, notationDiagramHelper, label, null); + } + }else{ + // Open the dialog to ask the new name + String currentName = notationDiagramHelper.getName(); + String newName = null; + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null); + if (dialog.open() == Window.OK) { + newName = dialog.getValue(); + if (newName == null || newName.length() <= 0) { + return; + } + } else { + // cancelled + return; + } + + final String name = newName; + cmd = new RecordingCommand(editingDomain, getCommandName()) { + + @Override + protected void doExecute() { + // Rename the diagram ! + notationDiagramHelper.setName(name); + } + + + }; + } + + editingDomain.getCommandStack().execute(cmd); + + } + + /** + * Get the name used in the {@link RecordingCommand}. This name will be visible in + * undo/redo. + * + * @return The command name to show. + */ + public String getCommandName() { + return Messages.RenameDiagramHandler_RenameDiagram; + } + + protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) throws NotFoundException { + try { + return (IEvaluationContext) event.getApplicationContext(); + } catch (ClassCastException e) { + throw new NotFoundException("IEvaluationContext can't be found."); //$NON-NLS-1$ + } + + } + + // /** + // * + // * @return + // * @throws NotFoundException + // */ + // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { + // + // return lookupLayersViewChecked().getLayerStackMngrChecked(); + // + // } + + /** + * Get the notation diagram helper. + * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. + * + * @return The + * @throws NotFoundException + * @throws ServiceException + */ + protected Diagram lookupNotationDiagramChecked(IEvaluationContext context) throws NotFoundException, ServiceException { + + + // Get page from the event ! + IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(ISashWindowsContainer.class, context).getActiveEditor(); + + if (!(editor instanceof DiagramDocumentEditor)) { + throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$ + } + DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor; + + Diagram diagram = diagramEditor.getDiagram(); + if (diagram == null) { + throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$ + } + + // Return a new instance of the Helper + return diagram; + } + + /** + * Try to lookup the TransactionalEditingDomain. + * + * @return + * @throws ServiceException + * If the Editing domain can't be found. + */ + protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException { + + // Get page from the event ! + // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); + + return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); + } + + /** + * Called by framework. Need to set the enabled flag. + * + * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) + * + * @param evaluationContext + */ + @Override + public void setEnabled(Object evaluationContext) { + + if (!(evaluationContext instanceof IEvaluationContext)) { + setBaseEnabled(false); + return; + } + + IEvaluationContext context = (IEvaluationContext) evaluationContext; + + try { + // Try to get the diagram + lookupNotationDiagramChecked(context); + + // ok, we got it. + setBaseEnabled(true); + + } catch (ServiceException e) { + // Can't find ServiceRegistry: disable + setBaseEnabled(false); + } catch (NotFoundException e) { + // Can't find ServiceRegistry: disable + setBaseEnabled(false); + } + + } +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF index ddf6a8377e7..501ee1c8008 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF @@ -68,7 +68,8 @@ Require-Bundle: org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)", org.eclipse.papyrus.infra.services.edit.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.emf.gmf, org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)" + org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF index 1d5325c5559..35c570d064d 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF @@ -3,7 +3,8 @@ Require-Bundle: org.eclipse.papyrus.infra.hyperlink;bundle-version="[3.0.0,4.0.0 org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)" + org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Export-Package: org.eclipse.papyrus.infra.gmfdiag.hyperlink, org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies, org.eclipse.papyrus.infra.gmfdiag.hyperlink.helper, diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java index aa68cc88e94..c93e62acfcd 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java @@ -12,6 +12,8 @@ * Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 363827 - [Improvement] Diagram creation, remember the latest tab chosen * Vincent Lorenzo (CEA-LIST) Vincent.lorenzo@cea.fr (refactoring of the hyperlink) * Christian W. Damus - bug 488965 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui; @@ -30,6 +32,7 @@ import org.eclipse.papyrus.infra.gmfdiag.hyperlink.object.HyperLinkEditor; import org.eclipse.papyrus.infra.hyperlink.helper.HyperLinkHelperFactory; import org.eclipse.papyrus.infra.hyperlink.ui.AbstractHyperLinkTab; import org.eclipse.papyrus.infra.hyperlink.ui.HyperLinkManagerShell; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry; import org.eclipse.swt.widgets.Shell; @@ -81,7 +84,7 @@ public class AdvancedHLManager extends HyperLinkManagerShell { HyperLinkEditor hyperLinkEditor = new HyperLinkEditor(); hyperLinkEditor.setObject(diagrams.get(i)); hyperLinkEditor.setIsDefault(true); - hyperLinkEditor.setTooltipText(diagrams.get(i).getName()); + hyperLinkEditor.setTooltipText(LabelInternationalization.getInstance().getDiagramLabel(diagrams.get(i))); hyperLinkDiagrams.add(hyperLinkEditor); } return hyperLinkDiagrams; diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF index 60578c27e04..6c76cfaf435 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF @@ -3,7 +3,8 @@ Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0, org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)" + org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 1.2.0.qualifier diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java index c8b292288bb..a318f4d1a89 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java @@ -10,6 +10,7 @@ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation * Christian W. Damus - bug 485220 * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.handlers; @@ -31,6 +32,8 @@ import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.window.Window; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.gmfdiag.modelexplorer.messages.Messages; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils; import org.eclipse.papyrus.views.modelexplorer.DirectEditorEditingSupport; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; import org.eclipse.swt.widgets.Display; @@ -51,18 +54,27 @@ public class RenameDiagramHandler extends AbstractDiagramCommandHandler { if (editingDomain != null && diagrams.size() == 1) { final Diagram diag = diagrams.get(0); - final String currentName = diag.getName(); - if (currentName != null) { - - AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameDiagramCommand", null) { //$NON-NLS-1$ - + + final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(diag); + if(null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(diag)){ + AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "ChangeDiagramLabelCommand", null) { //$NON-NLS-1$ + + /** + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + * + * @param monitor + * @param info + * @return + * @throws ExecutionException + */ @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null); - if (dialog.open() == Window.OK) { - final String name = dialog.getValue(); - if (name != null && name.length() > 0) { - diag.setName(name); + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename diagram label...", "New label:", diagramLabel, null); //$NON-NLS-1$ //$NON-NLS-2$ + if (Window.OK == dialog.open()) { + final String label = dialog.getValue(); + if (label != null && label.length() > 0) { + LabelInternationalization.getInstance().setDiagramLabel(diag, label, null); } return CommandResult.newOKCommandResult(); } else { @@ -71,6 +83,28 @@ public class RenameDiagramHandler extends AbstractDiagramCommandHandler { } }; return new GMFtoEMFCommandWrapper(cmd); + }else{ + final String currentName = diag.getName(); + if (currentName != null) { + + AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameDiagramCommand", null) { //$NON-NLS-1$ + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null); + if (dialog.open() == Window.OK) { + final String name = dialog.getValue(); + if (name != null && name.length() > 0) { + diag.setName(name); + } + return CommandResult.newOKCommandResult(); + } else { + return CommandResult.newCancelledCommandResult(); + } + } + }; + return new GMFtoEMFCommandWrapper(cmd); + } } } return UnexecutableCommand.INSTANCE; diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF index 219350da220..76b8f339ba2 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF @@ -4,7 +4,9 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.properties.extension, Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.core.databinding.beans;bundle-version="[1.3.0,2.0.0)", org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)" + org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.infra.gmfdiag.properties.constraint" Bundle-Version: 3.0.0.qualifier diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt index 840b846b6db..db294948335 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt @@ -11,6 +11,7 @@ + diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java new file mode 100644 index 00000000000..3b1ddfc7109 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java @@ -0,0 +1,219 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.properties.databinding; + +import org.eclipse.core.databinding.observable.Diffs; +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.core.databinding.observable.value.ValueDiff; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.gmfdiag.properties.Activator; +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; + +/** + * The observable value for the label of the {@link Diagram}. + */ +@SuppressWarnings("rawtypes") +public class DiagramLabelObservableValue extends AbstractObservableValue implements IObserving, ReferenceCountedObservable { + + /** + * The support reference counting on behalf of an {@code observable}. + */ + private final ReferenceCountedObservable.Support refCount = new ReferenceCountedObservable.Support(this); + + /** + * The diagram instance. + */ + protected Diagram diagram; + + /** + * The editing domain on which the commands will be executed. + */ + protected EditingDomain domain; + + /** + * The listener for the entry modification. + */ + protected Adapter listener; + + /** + * The internationalization entry corresponding to the diagram. + */ + protected InternationalizationEntry entry; + + /** + * Constructor. + * + * @param diagram + * The diagram. + * @param domain + * The editing domain. + */ + public DiagramLabelObservableValue(final Diagram diagram, final EditingDomain domain) { + this(Realm.getDefault(), diagram, domain); + } + + /** + * Constructor. + * + * @param realm + * The current Realm. + * @param diagram + * The diagram. + * @param domain + * The editing domain. + */ + public DiagramLabelObservableValue(final Realm realm, final Diagram diagram, final EditingDomain domain) { + super(realm); + this.diagram = diagram; + this.domain = domain; + this.entry = LabelInternationalizationUtils.getInternationalizationEntry(diagram, diagram); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.AbstractObservable#dispose() + */ + @Override + public synchronized void dispose() { + if (null != listener) { + entry.eAdapters().remove(listener); + listener = null; + } + + entry = null; + diagram = null; + super.dispose(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.IObserving#getObserved() + */ + public Object getObserved() { + return diagram; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.ChangeManager#firstListenerAdded() + */ + @Override + protected void firstListenerAdded() { + if (null != entry) { + if (null == listener) { + listener = new AdapterImpl() { + @Override + public void notifyChanged(Notification notification) { + if (InternationalizationPackage.eINSTANCE.getInternationalizationEntry_Value() == notification.getFeature() && !notification.isTouch()) { + final ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue()); + getRealm().exec(new Runnable() { + @SuppressWarnings("unchecked") + public void run() { + fireValueChange(diff); + } + }); + } + } + }; + } + entry.eAdapters().add(listener); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + */ + @Override + protected Object doGetValue() { + return LabelInternationalization.getInstance().getDiagramLabelWithoutName(diagram); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object) + */ + @Override + protected void doSetValue(final Object value) { + try { + + // Remove the listener on entry + if (null != entry && null != listener) { + entry.eAdapters().remove(listener); + } + + final Command emfCommand = LabelInternationalization.getInstance().getSetDiagramLabelCommand(domain, diagram, (String) value, null); + domain.getCommandStack().execute(emfCommand); + + // Get the entry after the modification and try to apply listener if possible + this.entry = LabelInternationalizationUtils.getInternationalizationEntry(diagram, diagram); + firstListenerAdded(); + } catch (Exception ex) { + Activator.log.error(ex); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + */ + public Object getValueType() { + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#retain() + */ + public void retain() { + refCount.retain(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#release() + */ + public void release() { + refCount.release(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#autorelease() + */ + public void autorelease() { + refCount.autorelease(); + } + +} diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java index 27f0fb0c118..4d4cefbddf0 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java @@ -10,6 +10,7 @@ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 454891 * Christian W. Damus - bug 485220 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement; @@ -34,9 +35,11 @@ import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; import org.eclipse.papyrus.infra.gmfdiag.properties.Activator; +import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.DiagramLabelObservableValue; import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.GradientObservableValue; import org.eclipse.papyrus.infra.gmfdiag.properties.provider.ModelContentProvider; import org.eclipse.papyrus.infra.gmfdiag.properties.util.LegacyOwnerObservable; +import org.eclipse.papyrus.infra.internationalization.utils.utils.InternationalizationConstants; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker; @@ -81,15 +84,23 @@ public class GMFModelElement extends EMFModelElement { @Override protected boolean isFeatureEditable(String propertyPath) { - if (propertyPath.endsWith("owner")) { - return true; + boolean result = true; + if(InternationalizationConstants.LABEL_PROPERTY_PATH.equals(propertyPath)){ //$NON-NLS-1$ + result = true; + }else if (propertyPath.endsWith("owner")) { //$NON-NLS-1$ + result = true; + }else{ + result = super.isFeatureEditable(propertyPath); } - return super.isFeatureEditable(propertyPath); + return result; } @Override protected IObservable doGetObservable(String propertyPath) { - if (propertyPath.endsWith("owner")) { + if(InternationalizationConstants.LABEL_PROPERTY_PATH.equals(propertyPath)){ //$NON-NLS-1$ + Diagram diagram = (Diagram) source; + return new DiagramLabelObservableValue(diagram, getDomain()); + }else if (propertyPath.endsWith("owner")) { Diagram diagram = (Diagram) source; Style style = diagram.getStyle(StylePackage.Literals.PAPYRUS_VIEW_STYLE); if (style != null) { @@ -198,7 +209,7 @@ public class GMFModelElement extends EMFModelElement { } return super.getContentProvider(propertyPath); } - + /** * Gets the root EObject from the given one * diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.project new file mode 100644 index 00000000000..ae67e3eb938 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.editor.welcome.internationalization + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + org.eclipse.oomph.version.VersionNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..8ddd9a88d57 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,296 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=260 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=false +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=260 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=5 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.ui.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..954281dbc31 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,68 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=false +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=false +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_type_arguments=false +cleanup_profile=_Papyrus +cleanup_settings_version=2 +eclipse.preferences.version=1 +formatter_profile=_Papyrus +formatter_settings_version=12 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.pde.api.tools.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 00000000000..23fb95e120f --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,98 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Ignore +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_ANNOTATION=Ignore +INVALID_JAVADOC_TAG=Ignore +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +MISSING_EE_DESCRIPTIONS=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=Enabled +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Warning +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..2dd006251fb --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.infra.editor.welcome.internationalization, + org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements, + org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets, + org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets.editors +Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.ui;bundle-version="[3.107.0,4.0.0)";visibility:=reexport, + org.eclipse.core.databinding.observable;bundle-version="[1.6.0,2.0.0)";visibility:=reexport, + org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.4.0,2.0.0)";visibility:=reexport, + org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.4.0,2.0.0)", + ca.odell.glazedlists;bundle-version="[1.9.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.services.navigation;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.editor.welcome;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.ui;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)" +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Localization: plugin +Bundle-Name: %pluginName +Bundle-Activator: org.eclipse.papyrus.infra.editor.welcome.internationalization.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.infra.editor.welcome.internationalization;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/about.html new file mode 100644 index 00000000000..dd3c089a94c --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

November 14, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/build.properties new file mode 100644 index 00000000000..631423469dc --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/build.properties @@ -0,0 +1,22 @@ +# +# Copyright (c) 2015 Christian W. Damus and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Christian W. Damus - Initial API and implementation +# + +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties,\ + model/,\ + plugin.xml +output.. = bin/ +src.includes = about.html +source.. = src/ +bin.. = bin/ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/environment.xmi b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/environment.xmi new file mode 100644 index 00000000000..f0090784c71 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/environment.xmi @@ -0,0 +1,12 @@ + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/internationalization.ctx b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/internationalization.ctx new file mode 100644 index 00000000000..04954fd8771 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/internationalization.ctx @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/ui/SingleInternationalization.xwt b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/ui/SingleInternationalization.xwt new file mode 100644 index 00000000000..66a074b448a --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/model/general/ui/SingleInternationalization.xwt @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.properties new file mode 100644 index 00000000000..556958d2ac1 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName=Papyrus Internationalization for Editor Welcome Page +providerName=Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.xml new file mode 100644 index 00000000000..e5b77e9ba22 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/plugin.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/pom.xml new file mode 100644 index 00000000000..b0450dffe5c --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus + org.eclipse.papyrus.infra-internationalization + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.editor.welcome.internationalization + 1.0.0-SNAPSHOT + eclipse-plugin + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/Activator.java new file mode 100644 index 00000000000..06e75c1c076 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/Activator.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.editor.welcome.internationalization"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElement.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElement.java new file mode 100644 index 00000000000..8696a73b925 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElement.java @@ -0,0 +1,115 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements; + +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; + +/** + * The internationalization welcome model element. + */ +public class InternationalizationWelcomeModelElement extends EMFModelElement { + + /** + * The private storage identifier. + */ + private final String PRIVATE_STORAGE = "privateStorage"; //$NON-NLS-1$ + + /** + * The useInternationalization identifier. + */ + private final String USE_INTERNATIONALIZATION = "useInternationalization"; //$NON-NLS-1$ + + /** + * The language identifier. + */ + private final String LANGUAGE = "language"; //$NON-NLS-1$ + + /** + * Constructor. + * + * @param source + * The source eObject. + * @param domain + * The current editing domain. + */ + public InternationalizationWelcomeModelElement(final EObject source, final EditingDomain domain) { + super(source, domain); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement#doGetObservable(java.lang.String) + */ + @Override + protected IObservable doGetObservable(final String propertyPath) { + IObservable result = null; + + switch (propertyPath) { + case PRIVATE_STORAGE: + result = new PrivateInternationalizationPreferenceObservableValue(domain); + break; + case USE_INTERNATIONALIZATION: + result = new UseInternationalizationObservableValue(domain); + break; + case LANGUAGE: + result = new LanguageObservableValue(domain); + break; + default: + break; + } + + return null != result ? result : super.doGetObservable(propertyPath); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement#isFeatureEditable(java.lang.String) + */ + @Override + protected boolean isFeatureEditable(final String propertyPath) { + boolean result; + + switch (propertyPath) { + case PRIVATE_STORAGE: + result = true; + break; + case USE_INTERNATIONALIZATION: + result = true; + break; + case LANGUAGE: + result = true; + break; + default: + result = super.isFeatureEditable(propertyPath); + break; + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement#isElementEditable() + */ + @Override + protected boolean isElementEditable() { + return true; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElementFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElementFactory.java new file mode 100644 index 00000000000..5dd2bdcc913 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/InternationalizationWelcomeModelElementFactory.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.editor.welcome.internationalization.Activator; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.properties.contexts.DataContextElement; +import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractEMFModelElementFactory; + +/** + * The internationalization welcome model element factory for the welcome properties of the internationalization. + */ +public class InternationalizationWelcomeModelElementFactory extends AbstractEMFModelElementFactory { + + /** + * Constructor. + */ + public InternationalizationWelcomeModelElementFactory() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElementFactory#doCreateFromSource(java.lang.Object, org.eclipse.papyrus.infra.properties.contexts.DataContextElement) + */ + @Override + protected InternationalizationWelcomeModelElement doCreateFromSource(final Object sourceElement, final DataContextElement context) { + final EObject source = EMFHelper.getEObject(sourceElement); + if (null == source) { + Activator.log.warn("Unable to resolve the selected element to an EObject"); //$NON-NLS-1$ + return null; + } + + final EditingDomain domain = EMFHelper.resolveEditingDomain(source); + return new InternationalizationWelcomeModelElement(source, domain); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/LanguageObservableValue.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/LanguageObservableValue.java new file mode 100644 index 00000000000..062a8556070 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/LanguageObservableValue.java @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.commands.AddEAnnotationDetailCommand; +import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand; +import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand; +import org.eclipse.papyrus.infra.emf.commands.RemoveFromResourcecommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource; +import org.eclipse.papyrus.infra.internationalization.common.command.LocaleInternationalizationPreferenceCommand; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationAnnotationResourceUtils; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationPreferenceModel; +import org.eclipse.papyrus.infra.internationalization.ui.Activator; +import org.eclipse.papyrus.infra.internationalization.utils.InternationalizationPreferenceModelUtils; + +/** + * The observable value for the language internationalization preference and annotation detail. + */ +public class LanguageObservableValue extends AbstractObservableValue implements IObserving { + + /** + * The editing domain to execute the command. + */ + private EditingDomain domain; + + /** + * Constructor. + * + * @param domain + * The editing domain. + */ + public LanguageObservableValue(final EditingDomain domain) { + super(); + this.domain = domain; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.IObserving#getObserved() + */ + @Override + public Object getObserved() { + final InternationalizationPreferenceModel model = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + return model.getPrivateResourceURI(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + */ + @Override + public Object getValueType() { + return String.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + */ + @Override + protected String doGetValue() { + final InternationalizationPreferenceModel model = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + return InternationalizationPreferencesUtils.getLocalePreference(model.getPrivateResourceURI()).toString(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object) + */ + @Override + protected void doSetValue(final String value) { + final Command command = getSetCommand(value); + domain.getCommandStack().execute(command); + } + + /** + * Returns the command used to edit the value. + * + * @param value + * The new value + * @return + * The Set command used to edit the value + */ + protected Command getSetCommand(final String value) { + boolean needCreateAnnotation = true; + + final InternationalizationPreferenceModel model = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + final Resource resource = model.getResource(); + + // Search the internationalization annotation in the notation resource + EAnnotation annotation = InternationalizationAnnotationResourceUtils.getInternationalizationAnnotation(resource); + + final CompoundCommand compoundCommand = new CompoundCommand("Create internationalization command"); //$NON-NLS-1$ + + if (null != annotation) { + if (annotation.getDetails().containsKey(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE)) { + try { + final TransactionalEditingDomain domainForResource = ServiceUtilsForResource.getInstance().getTransactionalEditingDomain(resource); + + // Remove the details from annotation + compoundCommand.append(new RemoveEAnnotationDetailCommand(domainForResource, annotation, InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE)); + + // If the detail is the only one, delete the annotation + if (1 == annotation.getDetails().size()) { + compoundCommand.append(new RemoveFromResourcecommand(domainForResource, resource, annotation)); + } else { + needCreateAnnotation = false; + } + } catch (final ServiceException e) { + Activator.log.error(e); + } + } else { + needCreateAnnotation = false; + } + } + + if (null != value) { + // Create the annotation if the internationalization value + // is not false + if (needCreateAnnotation) { + annotation = EcoreFactory.eINSTANCE.createEAnnotation(); + annotation + .setSource(InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL); + annotation.getDetails().put(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE, + value); + compoundCommand.append(new GMFtoEMFCommandWrapper(new AddToResourceCommand(((ModelSet) resource.getResourceSet()).getTransactionalEditingDomain(), resource, annotation))); + } else { + try { + final TransactionalEditingDomain domainForResource = ServiceUtilsForResource.getInstance().getTransactionalEditingDomain(resource); + + compoundCommand.append(new AddEAnnotationDetailCommand(domainForResource, annotation, InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE, value)); + } catch (final ServiceException e) { + Activator.log.error(e); + } + } + + // Manage the preference by command + compoundCommand.append(new LocaleInternationalizationPreferenceCommand(model.getPrivateResourceURI(), + value)); + } + + return !compoundCommand.getCommandList().isEmpty() ? compoundCommand : UnexecutableCommand.INSTANCE; + } +} \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/PrivateInternationalizationPreferenceObservableValue.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/PrivateInternationalizationPreferenceObservableValue.java new file mode 100644 index 00000000000..8ec4e6ad70b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/PrivateInternationalizationPreferenceObservableValue.java @@ -0,0 +1,171 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements; + +import static org.eclipse.core.databinding.observable.Diffs.createValueDiff; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Objects; + +import org.eclipse.core.databinding.observable.Diffs; +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.editor.welcome.internationalization.Activator; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet; +import org.eclipse.papyrus.infra.internationalization.commands.InternationalizationPreferenceCommandFactory; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationPreferenceModel; +import org.eclipse.papyrus.infra.internationalization.utils.InternationalizationPreferenceModelUtils; +import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; + +/** + * Encapsulation of the "shared layout" property of the Papyrus Editor. + */ +public class PrivateInternationalizationPreferenceObservableValue extends AbstractObservableValue implements PropertyChangeListener { + + /** + * The internationalization preference model. + */ + private InternationalizationPreferenceModel internationalizationPrefModel; + + /** + * The current editing domain. + */ + protected final EditingDomain domain; + + /** + * Constructor. + * + * @param domain + * The current editing domain. + */ + public PrivateInternationalizationPreferenceObservableValue(final EditingDomain domain) { + this(Realm.getDefault(), domain); + } + + /** + * Constructor. + * + * @param realm + * The {@link Realm}. + * @param domain + * The current editing domain. + */ + public PrivateInternationalizationPreferenceObservableValue(final Realm realm, final EditingDomain domain) { + super(realm); + + this.domain = domain; + + internationalizationPrefModel = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + if (null != internationalizationPrefModel) { + internationalizationPrefModel.addPropertyChangeListener(InternationalizationPreferenceModel.PROPERTY_LEGACY_MODE, this); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.AbstractObservable#dispose() + */ + @Override + public synchronized void dispose() { + if (null != internationalizationPrefModel) { + internationalizationPrefModel.removePropertyChangeListener(InternationalizationPreferenceModel.PROPERTY_LEGACY_MODE, this); + internationalizationPrefModel = null; + } + + super.dispose(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + */ + @Override + protected Boolean doGetValue() { + return internationalizationPrefModel.isLegacyMode(); + } + + /** + * Get the command for the private storage. + * + * @param factory + * The factory to create the command. + * @return The command to manage the private storage. + */ + protected Command getToggleCommand(final InternationalizationPreferenceCommandFactory factory) { + return factory.createTogglePrivateStorageCommand(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + */ + @Override + public Object getValueType() { + return Boolean.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object) + */ + @Override + protected void doSetValue(final Boolean value) { + Boolean oldValue = getValue(); + if (!Objects.equals(oldValue, value)) { + IMultiDiagramEditor editor; + + try { + editor = ServiceUtilsForResourceSet.getInstance().getService(IMultiDiagramEditor.class, domain.getResourceSet()); + final ModelSet modelSet = (ModelSet) editor.getAdapter(EditingDomain.class).getResourceSet(); + final Command command = getToggleCommand(new InternationalizationPreferenceCommandFactory(modelSet)); + if (command.canExecute()) { + // Don't do this in an undoable command on the history + try { + domain.getCommandStack().execute(command); + fireValueChange(Diffs.createValueDiff(oldValue, value)); + } catch (Exception e) { + Activator.log.error("Failed to toggle editor page layout option", e); //$NON-NLS-1$ + } + } + } catch (final ServiceException e) { + throw new IllegalStateException("No editor available in the service registry", e); //$NON-NLS-1$ + } + } + } + + /** + * {@inheritDoc} + * + * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getSource() == internationalizationPrefModel) { + switch (evt.getPropertyName()) { + case InternationalizationPreferenceModel.PROPERTY_LEGACY_MODE: + fireValueChange(createValueDiff(!(Boolean) evt.getOldValue(), !(Boolean) evt.getNewValue())); + break; + } + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/UseInternationalizationObservableValue.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/UseInternationalizationObservableValue.java new file mode 100644 index 00000000000..d90e174f181 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/modelelements/UseInternationalizationObservableValue.java @@ -0,0 +1,165 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.modelelements; + +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.commands.AddEAnnotationDetailCommand; +import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand; +import org.eclipse.papyrus.infra.emf.commands.RemoveEAnnotationDetailCommand; +import org.eclipse.papyrus.infra.emf.commands.RemoveFromResourcecommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource; +import org.eclipse.papyrus.infra.internationalization.common.command.UseInternationalizationPreferenceCommand; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationAnnotationResourceUtils; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationPreferenceModel; +import org.eclipse.papyrus.infra.internationalization.ui.Activator; +import org.eclipse.papyrus.infra.internationalization.utils.InternationalizationPreferenceModelUtils; + +/** + * The observable value for the use internationalization preference and annotation detail. + */ +public class UseInternationalizationObservableValue extends AbstractObservableValue { + + /** + * The editing domain to execute the command. + */ + private EditingDomain domain; + + /** + * Constructor. + * + * @param domain + * The editing domain. + */ + public UseInternationalizationObservableValue(final EditingDomain domain) { + super(); + this.domain = domain; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + */ + @Override + public Object getValueType() { + return Boolean.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + */ + @Override + protected Boolean doGetValue() { + final InternationalizationPreferenceModel model = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + return InternationalizationPreferencesUtils.getInternationalizationPreference(model.getPrivateResourceURI()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object) + */ + @Override + protected void doSetValue(final Boolean value) { + final Command command = getSetCommand(value); + domain.getCommandStack().execute(command); + } + + /** + * Returns the command used to edit the value. + * + * @param value + * The new value + * @return + * The Set command used to edit the value + */ + protected Command getSetCommand(final Boolean value) { + boolean needCreateAnnotation = true; + + final InternationalizationPreferenceModel model = InternationalizationPreferenceModelUtils.getInternationalizationPreferenceModel((ModelSet) domain.getResourceSet()); + final Resource resource = model.getResource(); + + // Search the internationalization annotation in the notation resource + EAnnotation annotation = InternationalizationAnnotationResourceUtils.getInternationalizationAnnotation(resource); + + final CompoundCommand compoundCommand = new CompoundCommand("Create internationalization command"); //$NON-NLS-1$ + + if (null != annotation) { + if (annotation.getDetails().containsKey(InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL)) { + try { + final TransactionalEditingDomain domainForResource = ServiceUtilsForResource.getInstance().getTransactionalEditingDomain(resource); + + // Remove the details from annotation + compoundCommand.append(new RemoveEAnnotationDetailCommand(domainForResource, annotation, InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL)); + + // If the detail is the only one, delete the annotation + if (1 == annotation.getDetails().size()) { + compoundCommand.append(new RemoveFromResourcecommand(domainForResource, resource, annotation)); + } else { + needCreateAnnotation = false; + } + } catch (final ServiceException e) { + Activator.log.error(e); + } + + // Remove the preference by command + compoundCommand.append(new UseInternationalizationPreferenceCommand(model.getPrivateResourceURI(), false)); + } else { + needCreateAnnotation = false; + } + } + + if (value) { + // Create the annotation if the internationalization value + // is not false + if (needCreateAnnotation) { + annotation = EcoreFactory.eINSTANCE.createEAnnotation(); + annotation.setSource(InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL); + annotation.getDetails().put( + InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL, + Boolean.toString(value)); + compoundCommand.append(new GMFtoEMFCommandWrapper(new AddToResourceCommand(((ModelSet) resource.getResourceSet()).getTransactionalEditingDomain(), resource, annotation))); + } else { + try { + final TransactionalEditingDomain domainForResource = ServiceUtilsForResource.getInstance().getTransactionalEditingDomain(resource); + + compoundCommand.append(new AddEAnnotationDetailCommand(domainForResource, annotation, InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL, Boolean.toString(value))); + } catch (final ServiceException e) { + Activator.log.error(e); + } + } + + // Manage the preference by command + compoundCommand.append(new UseInternationalizationPreferenceCommand(model.getPrivateResourceURI(), + value)); + } + + return !compoundCommand.getCommandList().isEmpty() ? compoundCommand : UnexecutableCommand.INSTANCE; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/LanguageDialog.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/LanguageDialog.java new file mode 100644 index 00000000000..240b2ed864f --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/LanguageDialog.java @@ -0,0 +1,55 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets; + +import org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor; +import org.eclipse.swt.widgets.Composite; + +/** + * The language property dialog widget for the internationalization. + */ +public class LanguageDialog extends AbstractPropertyEditor { + + /** + * The LanguageDialog widget. + */ + protected org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets.editors.LanguageDialog editor; + + /** + * Constructor. + * + * @param parent + * The composite in which the widget will be displayed. + * @param style + * The style for the widget. + */ + public LanguageDialog(final Composite parent, final int style) { + setEditor(createLanguageDialogEditor(parent, style)); + } + + /** + * Creates the language dialog. + * + * @param parent + * The composite in which the widget will be displayed. + * @param style + * The style for the widget. + * @return The language dialog. + */ + protected org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets.editors.LanguageDialog createLanguageDialogEditor( + final Composite parent, final int style) { + return editor = new org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets.editors.LanguageDialog(parent, style); + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/editors/LanguageDialog.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/editors/LanguageDialog.java new file mode 100644 index 00000000000..c5a7a4820c7 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.editor.welcome.internationalization/src/org/eclipse/papyrus/infra/editor/welcome/internationalization/widgets/editors/LanguageDialog.java @@ -0,0 +1,266 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.editor.welcome.internationalization.widgets.editors; + +import java.util.Locale; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.emf.common.util.URI; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.ui.dialogs.InternationalizationDialog; +import org.eclipse.papyrus.infra.widgets.Activator; +import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor; +import org.eclipse.papyrus.infra.widgets.messages.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Widget; + +/** + * This allows to define the language editor. + */ +public class LanguageDialog extends AbstractValueEditor implements SelectionListener { + + /** + * The CLabel displaying the current value. + */ + protected final CLabel currentValueLabel; + + /** + * The Button used to modify the value. + */ + protected Button modifyValuesButton; + + /** + * The dialog used to select the internationalization value. + */ + protected final InternationalizationDialog dialog; + + /** + * The current value for this editor + */ + protected Object value; + + /** + * Boolean to determinate if the editors are read-only. + */ + protected boolean readOnly; + + /** + * Constructs a new LanguageDialog in the given parent Composite. The style + * will be applied to the CLabel displaying the current value. + * + * @param parent + * The parent composite. + * @param style + * The style of the composites. + */ + public LanguageDialog(final Composite parent, final int style) { + super(parent, style); + final GridData gridData = getDefaultLayoutData(); + + currentValueLabel = factory.createCLabel(this, null, factory.getBorderStyle() | style); + currentValueLabel.setLayoutData(gridData); + currentValueLabel.addMouseListener(new MouseAdapter() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + editAction(); + } + + }); + + dialog = createDialog(parent.getShell()); + + createButton(); + updateControls(); + controlDecoration = new ControlDecoration(currentValueLabel, SWT.TOP | SWT.LEFT); + + gridData.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); + } + + /** + * This allows to create the internationalization language dialog. + * + * @param shell + * The parent shell. + * @return The created dialog. + */ + protected InternationalizationDialog createDialog(final Shell shell) { + return new InternationalizationDialog(shell, null, false); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor#setModelObservable(org.eclipse.core.databinding.observable.value.IObservableValue) + */ + @SuppressWarnings("rawtypes") + @Override + public void setModelObservable(final IObservableValue modelProperty) { + super.setModelObservable(modelProperty); + + if (modelProperty instanceof IObserving) { + Object observed = ((IObserving) modelProperty).getObserved(); + if (observed instanceof URI) { + URI resourceURI = (URI) observed; + dialog.setResourceURI(resourceURI); + + final String localeAsString = InternationalizationPreferencesUtils.getLocalePreference(resourceURI).toString(); + currentValueLabel.setText(localeAsString); + } + } + } + + /** + * This allow to create the buttons. + */ + protected void createButton() { + ((GridLayout) getLayout()).numColumns += 1; + + modifyValuesButton = factory.createButton(this, null, SWT.PUSH); + modifyValuesButton.setImage(Activator.getDefault().getImage("/icons/Edit_12x12.gif")); //$NON-NLS-1$ + modifyValuesButton.setToolTipText(Messages.ReferenceDialog_EditValue); + modifyValuesButton.addSelectionListener(this); + } + + /** + * The action executed when the "edit" button is selected Edits the object + * that is currently selected + */ + protected void editAction() { + int result = dialog.open(); + if (Window.OK == result) { + final Locale newValue = dialog.getLocaleValue(); + if (null != newValue) { + setValue(newValue.toString()); + } + } + } + + /** + * This allows to update the controls. + */ + protected void updateControls() { + modifyValuesButton.setEnabled(!readOnly); + } + + /** + * This allows to update the label text. + */ + protected void updateLabel() { + currentValueLabel.setText((String) getValue()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor#getValue() + */ + @Override + public Object getValue() { + if (modelProperty != null) { + return modelProperty.getValue(); + } + return value; + } + + /** + * Set the value. + * + * @param value + * The value to set. + */ + @SuppressWarnings("unchecked") + protected void setValue(final Object value) { + this.value = value; + try { + if (modelProperty != null) { + modelProperty.setValue(value); + } + } catch (Exception e) { + // Do nothing + } + + updateLabel(); + commit(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.AbstractEditor#getEditableType() + */ + @Override + public Object getEditableType() { + return Object.class; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.AbstractEditor#setReadOnly(boolean) + */ + @Override + public void setReadOnly(final boolean readOnly) { + this.readOnly = readOnly; + updateControls(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.widgets.editors.AbstractEditor#isReadOnly() + */ + @Override + public boolean isReadOnly() { + return readOnly; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(final SelectionEvent e) { + Widget widget = e.widget; + if (widget == modifyValuesButton) { + editAction(); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + // Do nothing + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.project new file mode 100644 index 00000000000..89db6d88791 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization.common + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/.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/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..d0413afa7d4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization.common;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization.common, + org.eclipse.papyrus.infra.internationalization.common.command, + org.eclipse.papyrus.infra.internationalization.common.editor, + org.eclipse.papyrus.infra.internationalization.common.utils +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)", + org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", + org.eclipse.ui.workbench;bundle-version="[3.108.0,4.0.0)", + org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", + org.eclipse.jface;bundle-version="[3.12.0,4.0.0)" +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.common.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/build.properties new file mode 100644 index 00000000000..2964bc2d7b1 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/build.properties @@ -0,0 +1,11 @@ +# + +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ +src.includes = about.html diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.properties new file mode 100644 index 00000000000..a4775a24081 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Papyrus Internationalization Common +providerName = Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.xml new file mode 100644 index 00000000000..7ac51d15095 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/plugin.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/pom.xml new file mode 100644 index 00000000000..8f8eae08258 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.common + 1.0.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/Activator.java new file mode 100644 index 00000000000..ae1975d5007 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/Activator.java @@ -0,0 +1,153 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.papyrus.infra.core.resource.PapyrusProjectScope; +import org.eclipse.papyrus.infra.ui.preferences.PapyrusScopedPreferenceStore; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.internationalization.common"; //$NON-NLS-1$ + + /** + * The internationalization preference node label. + */ + public static final String INTERNATIONALIZATION_NODE_LABEL = "internationalization"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * Storage for preferences. Use a list of preference store (one preference + * store by internationalization of a project). + */ + private List preferencesStore; + + /** + * The constructor + */ + public Activator() { + preferencesStore = new ArrayList(0); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Get the preference store and create it if necessary. + * + * @param project + * The current project + * @param papyrusProjectName + * The current papyrus project name. + * @return The preference store. + */ + public IPreferenceStore getInternationalizationPreferenceStore(final IProject project, + final String papyrusProjectName) { + IPreferenceStore result = null; + final IScopeContext scope = new PapyrusProjectScope(project, papyrusProjectName); + if (!preferencesStore.isEmpty()) { + final IEclipsePreferences scopePreferenceNode = scope.getNode(INTERNATIONALIZATION_NODE_LABEL); + final Iterator preferenceStoreIterator = preferencesStore.iterator(); + while (preferenceStoreIterator.hasNext() && null == result) { + final IPreferenceStore preferenceStore = preferenceStoreIterator.next(); + if (preferenceStore instanceof PapyrusScopedPreferenceStore) { + final IEclipsePreferences[] preferenceNodes = ((PapyrusScopedPreferenceStore) preferenceStore) + .getPreferenceNodes(false); + for (int index = 0; index < preferenceNodes.length && null == result; index++) { + if (preferenceNodes[index].equals(scopePreferenceNode)) { + result = preferenceStore; + } + } + } + } + } + + if (null == result) { + result = new PapyrusScopedPreferenceStore(scope, INTERNATIONALIZATION_NODE_LABEL); + preferencesStore.add(result); // $NON-NLS-1$ + } + + return result; + } + + /** + * Get the first preference store if existing, else a scoped preference + * store must be created and added to the list of preferences store. + * + * @return The preference store. + */ + public IPreferenceStore getInternationalizationPreferenceStore() { + // Create the preference store lazily. + if (preferencesStore.isEmpty()) { + preferencesStore.add(new ScopedPreferenceStore(InstanceScope.INSTANCE, getBundle().getSymbolicName())); + } + return preferencesStore.get(0); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/LocaleInternationalizationPreferenceCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/LocaleInternationalizationPreferenceCommand.java new file mode 100644 index 00000000000..4d907295efc --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/LocaleInternationalizationPreferenceCommand.java @@ -0,0 +1,98 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.command; + +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; + +/** + * The command to modify the internationalization preference. We can't use the + * RecordingCommand because the modification are not applied to a resource + * directly. + */ +public class LocaleInternationalizationPreferenceCommand extends AbstractCommand { + + /** + * The current resource URI corresponding to the internationalization + * preference. + */ + protected URI resourceURI; + + /** + * The new language value. + */ + protected String newLanguageValue; + + /** + * The old language value. + */ + protected String oldLanguageValue; + + /** + * Constructor. + * + * @param resourceURI + * The current resource URI. + * @param newLanguageValue + * The new language value. + */ + public LocaleInternationalizationPreferenceCommand(final URI resourceURI, final String newLanguageValue) { + super("Modify locale internationalization preference"); //$NON-NLS-1$ + this.resourceURI = resourceURI; + this.newLanguageValue = newLanguageValue; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#execute() + */ + @Override + public void execute() { + oldLanguageValue = InternationalizationPreferencesUtils.getLocalePreference(resourceURI).toString(); + InternationalizationPreferencesUtils.setLanguagePreference(resourceURI, newLanguageValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#undo() + */ + @Override + public void undo() { + InternationalizationPreferencesUtils.setLanguagePreference(resourceURI, oldLanguageValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#redo() + */ + @Override + public void redo() { + InternationalizationPreferencesUtils.setLanguagePreference(resourceURI, newLanguageValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + */ + @Override + protected boolean prepare() { + return null != resourceURI; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/UseInternationalizationPreferenceCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/UseInternationalizationPreferenceCommand.java new file mode 100644 index 00000000000..887e31d851c --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/command/UseInternationalizationPreferenceCommand.java @@ -0,0 +1,98 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.command; + +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; + +/** + * The command to modify the internationalization preference. We can't use the + * RecordingCommand because the modification are not applied to a resource + * directly. + */ +public class UseInternationalizationPreferenceCommand extends AbstractCommand { + + /** + * The current resource URI corresponding to the internationalization + * preference. + */ + protected URI resourceURI; + + /** + * The new boolean value. + */ + protected boolean newBooleanValue; + + /** + * The old boolean value. + */ + protected boolean oldBooleanValue; + + /** + * Constructor. + * + * @param resourceURI + * The current resource URI. + * @param newBooleanValue + * The new boolean value. + */ + public UseInternationalizationPreferenceCommand(final URI resourceURI, final boolean newBooleanValue) { + super("Modify use internationalization preference"); //$NON-NLS-1$ + this.resourceURI = resourceURI; + this.newBooleanValue = newBooleanValue; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#execute() + */ + @Override + public void execute() { + oldBooleanValue = InternationalizationPreferencesUtils.getInternationalizationPreference(resourceURI); + InternationalizationPreferencesUtils.setInternationalizationPreference(resourceURI, newBooleanValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#undo() + */ + @Override + public void undo() { + InternationalizationPreferencesUtils.setInternationalizationPreference(resourceURI, oldBooleanValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#redo() + */ + @Override + public void redo() { + InternationalizationPreferencesUtils.setInternationalizationPreference(resourceURI, newBooleanValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + */ + @Override + protected boolean prepare() { + return null != resourceURI; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/editor/IInternationalizationEditor.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/editor/IInternationalizationEditor.java new file mode 100644 index 00000000000..40b46182a1f --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/editor/IInternationalizationEditor.java @@ -0,0 +1,34 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.editor; + +/** + * Interface to define if the editor support the internationalization and the corresponding label modification. + */ +public interface IInternationalizationEditor { + + /** + * This allows to modify the part name. + * + * @param name + * The new name of the editor. + */ + public void modifyPartName(final String name); + + /** + * This allows to refresh the editor part. + */ + public void refreshEditorPart(); + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationAnnotationResourceUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationAnnotationResourceUtils.java new file mode 100644 index 00000000000..5da45e6d9fd --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationAnnotationResourceUtils.java @@ -0,0 +1,49 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.utils; + +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; + +/** + * Define the utils method corresponding to the internationalization annotation + * and its resource. + */ +public class InternationalizationAnnotationResourceUtils { + + /** + * This allows to get the annotation corresponding to the + * internationalization in the resource in parameter if exists. + * + * @param resource + * The resource to check + * @return The internationalization annotation if exists, null + * otherwise. + */ + public static EAnnotation getInternationalizationAnnotation(final Resource resource) { + EAnnotation result = null; + + for (final EObject objectContent : resource.getContents()) { + if (objectContent instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) objectContent).getSource())) { + result = (EAnnotation) objectContent; + } + } + + return result; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesConstants.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesConstants.java new file mode 100644 index 00000000000..b7bf90ed5c0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesConstants.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.utils; + +/** + * This class defines the constants for the internationalization preferences. + */ +public class InternationalizationPreferencesConstants { + + /** + * The internationalization preference label. + */ + public static final String USE_INTERNATIONALIZATION_PREFERENCE = "useInternationalization"; //$NON-NLS-1$ + + /** + * The label for the internationalization annotation. + */ + public static final String INTERNATIONALIZATION_ANNOTATION_LABEL = "Internationalization"; //$NON-NLS-1$ + + /** + * The label of the internationalization annotation detail. + */ + public static final String USE_DETAIL_ANNOTATION_LABEL = "use"; //$NON-NLS-1$ + + /** + * The language preference name. + */ + public static final String LANGUAGE_PREFERENCE = "language"; //$NON-NLS-1$ + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java new file mode 100644 index 00000000000..58cb94f1f35 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java @@ -0,0 +1,296 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.utils; + +import java.util.Locale; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.CommonPlugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.infra.internationalization.common.Activator; + +/** + * The internationalization preference utils methods which allow to get or + * change the internationalization preference value. + */ +public class InternationalizationPreferencesUtils { + + /** + * Get the preference store for the project containing the {@link EObject} + * in parameter. + * + * @param eObject + * The eObject. + * @return The preference store for the project containing the EObject. + */ + public static IPreferenceStore getPreferenceStore(final EObject eObject) { + return getPreferenceStore(getRootContainer(eObject).eResource()); + } + + /** + * Get the preference store for the project containing the {@link Resource} + * in parameter. + * + * @param resource + * The resource. + * @return The preference store for the project containing the Resource. + */ + public static IPreferenceStore getPreferenceStore(final Resource resource) { + IPreferenceStore result = null; + + if (null != resource) { + result = getPreferenceStore(resource.getURI()); + } + + return result; + } + + /** + * Get the preference store for the project containing the resource + * {@link URI} in parameter. + * + * @param resource + * The resource. + * @return The preference store for the project containing the resource URI. + */ + public static IPreferenceStore getPreferenceStore(final URI uri) { + IPreferenceStore result = null; + + if (null != uri) { + final String filePathString = CommonPlugin.resolve(uri).toFileString(); + + if (null != filePathString) { + final IFile resourceFile = ResourcesPlugin.getWorkspace().getRoot() + .getFileForLocation(new Path(filePathString)); + + if (null != resourceFile) { + final IProject currentProject = resourceFile.getProject(); + final String papyrusProjectName = uri.trimFileExtension().lastSegment(); + + if (null != currentProject && !papyrusProjectName.isEmpty()) { + result = Activator.getDefault().getInternationalizationPreferenceStore(currentProject, + papyrusProjectName); + } + } + } + } + + return result; + } + + /** + * This allows to modify the internationalization preference value. + * + * @param eObject + * The {@link EObject) corresponding (to get its resource). + * @param value + * The new preference value. + */ + public static void setInternationalizationPreference(final EObject eObject, final boolean value) { + setInternationalizationPreference(getRootContainer(eObject).eResource(), value); + } + + /** + * This allows to modify the internationalization preference value. + * + * @param resource + * The {@link Resource) to get the papyrus project preferences. + * @param value + * The new preference value. + */ + public static void setInternationalizationPreference(final Resource resource, final boolean value) { + setInternationalizationPreference(resource.getURI(), value); + } + + /** + * This allows to modify the internationalization preference value. + * + * @param resourceURI + * The resource URI to get the papyrus project preferences. + * @param value + * The new preference value. + */ + public static void setInternationalizationPreference(final URI resourceURI, final boolean value) { + final IPreferenceStore preferenceStore = getPreferenceStore(resourceURI); + + if (null != preferenceStore) { + preferenceStore.setValue(InternationalizationPreferencesConstants.USE_INTERNATIONALIZATION_PREFERENCE, + value); + } + } + + /** + * This allows to get the internationalization preference value. + * + * @param eObject + * The {@link EObject) corresponding (to get its resource). + * @return true if the preference value is set to true, + * false otherwise. + */ + public static boolean getInternationalizationPreference(final EObject eObject) { + boolean result = false; + if(null != eObject.eResource()){ + result = getInternationalizationPreference(getRootContainer(eObject).eResource()); + } + return result; + } + + /** + * This allows to get the internationalization preference value. + * + * @param resource + * The {@link Resource) to get the papyrus project preferences. + * @return true if the preference value is set to true, + * false otherwise. + */ + public static boolean getInternationalizationPreference(final Resource resource) { + return getInternationalizationPreference(resource.getURI()); + } + + /** + * This allows to get the internationalization preference value. + * + * @param resourceURI + * The resource URI to get the papyrus project preferences. + * @return true if the preference value is set to true, + * false otherwise. + */ + public static boolean getInternationalizationPreference(final URI resourceURI) { + boolean result = false; + + final IPreferenceStore preferenceStore = getPreferenceStore(resourceURI); + + if (null != preferenceStore && preferenceStore + .contains(InternationalizationPreferencesConstants.USE_INTERNATIONALIZATION_PREFERENCE)) { + result = preferenceStore + .getBoolean(InternationalizationPreferencesConstants.USE_INTERNATIONALIZATION_PREFERENCE); + } + + return result; + } + + /** + * Get the language preference (create it with the current locale if not + * existing). + * + * @param resource + * The {@link Resource) to get the papyrus project preferences. + * @return The language in the preferences. + */ + private static String getLanguagePreference(final URI uri) { + String result = null; + + final IPreferenceStore preferenceStore = getPreferenceStore(uri); + if (null != preferenceStore + && preferenceStore.contains(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE)) { + result = preferenceStore.getString(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE); + } + + return result; + } + + /** + * Get the locale preference created from the language preference. + * + * @param eObject + * The {@link EObject) corresponding (to get its resource). + * @return The locale preference. + */ + public static Locale getLocalePreference(final EObject eObject) { + return getLocalePreference(getRootContainer(eObject).eResource().getURI()); + } + + /** + * Get the locale preference created from the language preference. + * + * @param resource + * The {@link Resource) to get the papyrus project preferences. + * @return The locale preference. + */ + public static Locale getLocalePreference(final URI uri) { + final String localePreference = getLanguagePreference(uri); + + Locale result = null; + + if (null != localePreference) { + result = LocaleNameResolver.getLocaleFromString(localePreference); + } else { + result = Locale.getDefault(); + } + + return result; + } + + /** + * This allows to set the language preference. + * + * @param eObject + * The {@link EObject) corresponding (to get its resource). + * @param language + * The language to set. + */ + public static void setLanguagePreference(final EObject eObject, final String language) { + setLanguagePreference(getRootContainer(eObject).eResource(), language); + } + + /** + * This allows to set the language preference. + * + * @param resource + * The {@link Resource) to get the papyrus project preferences. + * @param language + * The language to set. + */ + public static void setLanguagePreference(final Resource resource, final String language) { + setLanguagePreference(resource.getURI(), language); + } + + /** + * This allows to set the language preference. + * + * @param resourceURI + * The resource URI to get the papyrus project preferences. + * @param language + * The language to set. + */ + public static void setLanguagePreference(final URI resourceURI, final String language) { + final IPreferenceStore preferenceStore = getPreferenceStore(resourceURI); + + if (null != preferenceStore) { + preferenceStore.setValue(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE, language); + } + } + + /** + * This allows to get the root container of the EObject in parameter. + * + * @param eObject The initial EObject. + * @return The root container. + */ + protected static EObject getRootContainer(final EObject eObject){ + EObject rootContainer = eObject; + + while(null != rootContainer.eContainer()){ + rootContainer = rootContainer.eContainer(); + } + + return rootContainer; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/LocaleNameResolver.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/LocaleNameResolver.java new file mode 100644 index 00000000000..699266d0fbf --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/LocaleNameResolver.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.common.utils; + +import java.util.Locale; + +/** + * This allows to manage easily name for the locale. + */ +public class LocaleNameResolver { + + /** + * The underscore constant. + */ + public static final String UNDERSCORE = "_"; //$NON-NLS-1$ + + /** + * This allows to get the corresponding locale from a text. + * + * @param initialString + * The initial string representing a locale. + * @return The locale corresponding locale from the text in parameter. + */ + public static final Locale getLocaleFromString(final String initialString) { + String language = ""; //$NON-NLS-1$ + String country = ""; //$NON-NLS-1$ + String variant = ""; //$NON-NLS-1$ + + if (initialString.contains(UNDERSCORE)) { + language = initialString.substring(0, initialString.indexOf(UNDERSCORE)); + final String substringFirstUnderscore = initialString.substring(initialString.indexOf(UNDERSCORE) + 1, + initialString.length()); + if (substringFirstUnderscore.contains(UNDERSCORE)) { + country = substringFirstUnderscore.substring(0, substringFirstUnderscore.indexOf(UNDERSCORE)); + variant = substringFirstUnderscore.substring(substringFirstUnderscore.indexOf(UNDERSCORE) + 1, + substringFirstUnderscore.length()); + } else { + country = substringFirstUnderscore; + } + } else { + language = initialString; + } + + return new Locale(language, country, variant); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.project new file mode 100644 index 00000000000..e931db8e813 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization.controlmode + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/.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/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..7822dbc9d6f --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization.controlmode;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization.controlmode, + org.eclipse.papyrus.infra.internationalization.controlmode.commands, + org.eclipse.papyrus.infra.internationalization.controlmode.participants +Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.ui.workbench;bundle-version="[3.108.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.107.0,4.0.0)", + org.eclipse.papyrus.infra.services.controlmode;bundle-version="[1.5.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)" +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.controlmode.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/build.properties new file mode 100644 index 00000000000..98e56b2cd5e --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/build.properties @@ -0,0 +1,9 @@ +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ +src.includes = about.html diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.properties new file mode 100644 index 00000000000..eac8c610fc4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Papyrus Internationalization Control mode +providerName = Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.xml new file mode 100644 index 00000000000..4e0e90e1adc --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/plugin.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/pom.xml new file mode 100644 index 00000000000..9a7c2a022c7 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.controlmode + 1.0.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/Activator.java new file mode 100644 index 00000000000..45547a86cce --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/Activator.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.internationalization.controlmode"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/ControlPropertiesCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/ControlPropertiesCommand.java new file mode 100644 index 00000000000..096bb538d35 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/ControlPropertiesCommand.java @@ -0,0 +1,328 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.commands; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils; +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationFactory; +import org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary; +import org.eclipse.papyrus.infra.internationalization.controlmode.Activator; +import org.eclipse.papyrus.infra.internationalization.controlmode.utils.ControlPropertiesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.commands.AbstractControlCommand; + +/** + * The control command for the properties files. + */ +public class ControlPropertiesCommand extends AbstractControlCommand { + + /** + * The Constant COMMAND_TITLE. + */ + private static final String COMMAND_TITLE = "Properties control command"; //$NON-NLS-1$ + + /** + * The old internationalization model resource. + */ + private InternationalizationModelResource internationalizationModelResource = null; + + /** + * The old notation resource. + */ + private Resource oldNotationResource = null; + + /** + * Constructor. + * + * @param request + * The request. + */ + public ControlPropertiesCommand(final ControlModeRequest request) { + this(COMMAND_TITLE, request); + } + + /** + * Constructor. + * + * @param commandTitle + * The command title. + * @param request + * The request. + */ + public ControlPropertiesCommand(final String commandTitle, final ControlModeRequest request) { + super(commandTitle, null, request); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) + throws ExecutionException { + + final Set createdResources = new HashSet(); + + @SuppressWarnings("unchecked") + final Map createdPropertiesResources = (Map) getRequest() + .getParameter(ControlPropertiesUtils.CREATED_PROPERTIES_RESOURCES); + for (final Locale locale : createdPropertiesResources.keySet()) { + // Get the new properties resource for the locale + final Resource newPropertiesResource = createdPropertiesResources.get(locale); + if (null == newPropertiesResource) { + return CommandResult.newErrorCommandResult("The properties model has not been created"); //$NON-NLS-1$ + } + + InternationalizationLibrary library = null; + for (final EObject objectContant : newPropertiesResource.getContents()) { + if (objectContant instanceof InternationalizationLibrary) { + library = (InternationalizationLibrary) objectContant; + } + } + + if (null == library) { + // The library does not exist, create it and add entries + library = InternationalizationFactory.eINSTANCE.createInternationalizationLibrary(); + newPropertiesResource.getContents().add(library); + } + + final List entries = getInternationalizationEntries(locale); + if (!entries.isEmpty()) { + + // The library exists, just add entries + for (final InternationalizationEntry entry : entries) { + library.getEntries().add(EcoreUtil.copy(entry)); + } + + final Resource oldPropertiesResource = getOldPropertiesResource(locale); + final InternationalizationLibrary oldLibrary = (InternationalizationLibrary) oldPropertiesResource + .getContents().get(0); + + oldLibrary.getEntries().removeAll(entries); + } + + createdResources.add(newPropertiesResource); + } + + return CommandResult.newOKCommandResult(createdResources); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doRedo(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected IStatus doRedo(final IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + return doExecuteWithResult(monitor, info).getStatus(); + } + + /** + * Get the internationalization entries for the diagrams and the tables of + * objects in sub model. + * + * @param locale + * The current locale to manage. + * @return The internationalization entries. + * @throws ExecutionException + * The possible execution exception. + */ + protected List getInternationalizationEntries(final Locale locale) + throws ExecutionException { + final List entries = new ArrayList(); + + getInternationalizationModelResource(); + + if (null != internationalizationModelResource) { + + // Search the EObject labels to control + final EObject targetObject = getRequest().getTargetObject(); + + InternationalizationEntry entryForKey = internationalizationModelResource + .getEntryForKey(getOldPropertiesURI(), targetObject, locale); + if (null != entryForKey) { + entries.add(entryForKey); + } + + final TreeIterator eAllContents = EcoreUtil.getAllProperContents(targetObject, true); + while (eAllContents.hasNext()) { + final EObject content = eAllContents.next(); + entryForKey = internationalizationModelResource.getEntryForKey(getOldPropertiesURI(), content, locale); + if (null != entryForKey) { + entries.add(entryForKey); + } + } + + final Resource oldNotationResource = getOldNotationResource(); + + // Search the diagrams labels to control + for (final Diagram diagram : NotationUtils.getDiagrams(oldNotationResource, + getRequest().getTargetObject())) { + entryForKey = internationalizationModelResource.getEntryForKey(getOldPropertiesURI(), diagram, locale); + if (null != entryForKey) { + entries.add(entryForKey); + } + } + + // Search the tables labels to control + for (final Table table : getTables(oldNotationResource, getRequest().getTargetObject())) { + entryForKey = internationalizationModelResource.getEntryForKey(getOldPropertiesURI(), table, locale); + if (null != entryForKey) { + entries.add(entryForKey); + } + } + } + + return entries; + } + + /** + * Gets the all the tables contained in the specified ancestor eObject. + * + * @param notationResource + * The notation resource where search tables. + * @param eObject + * The table to search in notation resource. + * + * @return all the contained tables. + */ + protected List getTables(final Resource notationResource, final EObject eObject) { + final List
tables = new LinkedList
(); + if (null != notationResource) { + for (final EObject obj : notationResource.getContents()) { + if (obj instanceof Table) { + Table table = (Table) obj; + if (EcoreUtil.isAncestor(eObject, table.getOwner())) { + tables.add(table); + } + } + } + } + return tables; + } + + /** + * Gets the old internationalization model resource. + * + * @return the old internationalization model resource. + */ + protected InternationalizationModelResource getInternationalizationModelResource() { + + if (null == internationalizationModelResource) { + try { + internationalizationModelResource = (InternationalizationModelResource) getRequest().getModelSet() + .getModelChecked(InternationalizationModelResource.MODEL_ID); + } catch (Exception e) { + Activator.log.error("Unable to retrieve old properties resource", e); //$NON-NLS-1$ + } + } + + return internationalizationModelResource; + } + + /** + * Gets the old properties resource. + * + * @param locale + * The current locale to manage. + * @return the old properties resource. + */ + private Resource getOldPropertiesResource(final Locale locale) { + Resource resource = null; + + getInternationalizationModelResource(); + + try { + resource = internationalizationModelResource.getResourceForURIAndLocale(getOldPropertiesURI(), locale); + } catch (Exception e) { + Activator.log.error("Unable to retrieve old notation resource", e); //$NON-NLS-1$ + } + + return resource; + } + + /** + * Get the old properties URI for request. + * + * @return The old properties resource URI. + * @throws ExecutionException + * The exception when the notation resource is not found. + */ + protected URI getOldPropertiesURI() throws ExecutionException { + URI uri = getRequest().getSourceURI(); + if (null != uri) { + return uri.trimFileExtension().appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + } + throw new ExecutionException("Unable to retreive URI of the old properties model"); //$NON-NLS-1$ + } + + /** + * Gets the old notation resource. + * + * @return the old notation resource + */ + private Resource getOldNotationResource() { + + if (null == oldNotationResource) { + try { + oldNotationResource = getRequest().getModelSet().getResource(getOldNotationURI(), true); + } catch (Exception e) { + Activator.log.error("Unable to retrieve old notation resource", e); //$NON-NLS-1$ + } + } + + return oldNotationResource; + } + + /** + * Get the old notation URI for request. + * + * @return The old notation resource URI. + * @throws ExecutionException + * The exception when the notation resource is not found. + */ + protected URI getOldNotationURI() throws ExecutionException { + URI uri = getRequest().getSourceURI(); + if (null != uri) { + return uri.trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION); + } + throw new ExecutionException("Unable to retreive URI of the old notation model"); //$NON-NLS-1$ + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/CreatePropertiesControlResourceCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/CreatePropertiesControlResourceCommand.java new file mode 100644 index 00000000000..e571b0c2d38 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/CreatePropertiesControlResourceCommand.java @@ -0,0 +1,257 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.internationalization.controlmode.commands; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.internationalization.common.utils.LocaleNameResolver; +import org.eclipse.papyrus.infra.internationalization.controlmode.utils.ControlPropertiesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource; + +/** + * Command used to create new controlled properties resource. This command will + * create the new resources. It will also handle correctly undo and redo. + */ +public class CreatePropertiesControlResourceCommand extends CreateControlResource { + + /** + * The locale to add in the file name. + */ + private Locale locale; + + /** + * The created resource. We need it to remove it for undo command. + */ + private Resource createdResource; + + /** + * The internationalization model resource. + */ + private InternationalizationModelResource internationalizationModelResource; + + /** + * Constructor. + * + * @param request + * {@link ControlModeRequest} used to compute the command + * @param newFileExtension + * File extension use to create the resource. If not specified + * then it should be already provided in the {@link URI} + * @param locale + * The locale to add in the file name. + */ + public CreatePropertiesControlResourceCommand(final ControlModeRequest request, final String newFileExtension, + final Locale locale) { + super(request, newFileExtension); + this.locale = locale; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.AbstractControlResourceCommand#getTargetUri() + */ + @Override + public URI getTargetUri() { + return getModifiedURI(getRequest().getNewURI()); + } + + /** + * Get the URI with the locale if not null and the extension if not null. + * + * @param initialURI + * The initial URI. + * @return The modified URI. + */ + protected URI getModifiedURI(final URI initialURI) { + URI targetURI = initialURI; + if (null != locale) { + // Get the existing file extension + final String existingFileExtension = targetURI.fileExtension(); + // Get the last segment + String lastSegment = targetURI.trimFileExtension().lastSegment(); + // Add the locale to the last segment + lastSegment = lastSegment + LocaleNameResolver.UNDERSCORE + locale.toString(); + // Replace the last segment (managing file extension + targetURI = targetURI.trimFileExtension().trimSegments(1).appendSegment(lastSegment) + .appendFileExtension(existingFileExtension); + } + if (null != newFileExtension) { + targetURI = targetURI.trimFileExtension().appendFileExtension(newFileExtension); + } + return targetURI; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @SuppressWarnings("unchecked") + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor progressMonitor, final IAdaptable info) + throws ExecutionException { + final CommandResult res = super.doExecuteWithResult(progressMonitor, info); + + // Get the created resource + createdResource = getRequest().getTargetResource(newFileExtension); + + // Manage a map of created properties resources, because several + // properties resources can be created + if (null == getRequest().getParameter(ControlPropertiesUtils.CREATED_PROPERTIES_RESOURCES)) { + getRequest().setParameter(ControlPropertiesUtils.CREATED_PROPERTIES_RESOURCES, + new HashMap()); + } + ((Map) getRequest().getParameter(ControlPropertiesUtils.CREATED_PROPERTIES_RESOURCES)) + .put(locale, createdResource); + + // Add the resource to the internationalization model resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.addResourceToModel(getRequest().getNewURI().trimFileExtension(), createdResource, locale); + } + + return res; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource#doUndo(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected IStatus doUndo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + getRequest().setTargetResource(createdResource, getFileExtension()); + + // Unload and remove the resource from the internationalization model + // resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.unload(createdResource); + modelResource.getResources().remove(createdResource); + } + + return super.doUndo(monitor, info); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource#doRedo(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected IStatus doRedo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + getRequest().setTargetResource(createdResource, getFileExtension()); + final IStatus result = super.doRedo(monitor, info); + + // Add the resource to the internationalization model resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.addResourceToModel(getRequest().getNewURI().trimFileExtension(), createdResource, locale); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource#getNewURI() + */ + @Override + protected URI getNewURI() { + return getModifiedURI(getRequest().getNewURI()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.CreateControlResource#getTargetResrource(org.eclipse.emf.ecore.EObject) + */ + @Override + protected Resource getTargetResrource(final EObject objectToUncontrol) { + Resource resultResource = null; + URI targetURI = null; + + if (null != objectToUncontrol) { + targetURI = objectToUncontrol.eResource().getURI().trimFileExtension(); + if (null != locale) { + String lastSegment = targetURI.lastSegment(); + lastSegment = lastSegment + LocaleNameResolver.UNDERSCORE + locale.toString(); + targetURI = targetURI.trimSegments(1).appendSegment(lastSegment); + } + targetURI = targetURI.appendFileExtension(getFileExtension()); + } + + if (null != targetURI) { + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + resultResource = modelResource.getResourceForURIAndLocale(objectToUncontrol.eResource().getURI() + .trimFileExtension().appendFileExtension(getFileExtension()), locale); + } + } + + return resultResource; + } + + /** + * Get the internationalization model resource. + * + * @return The internationalization model resource. + */ + protected InternationalizationModelResource getInternationalizationModelResource() { + if (null == internationalizationModelResource) { + final ModelSet modelSet = getRequest().getModelSet(); + if (null != modelSet) { + try { + internationalizationModelResource = (InternationalizationModelResource) modelSet + .getModelChecked(InternationalizationModelResource.MODEL_ID); + } catch (final NotFoundException e) { + // Do nothing + } + } + } + + return internationalizationModelResource; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.workspace.AbstractEMFOperation#dispose() + */ + @Override + public void dispose() { + internationalizationModelResource = null; + createdResource = null; + locale = null; + super.dispose(); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/InternationalizationAnnotationControlCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/InternationalizationAnnotationControlCommand.java new file mode 100644 index 00000000000..9642cd7bcec --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/InternationalizationAnnotationControlCommand.java @@ -0,0 +1,111 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.commands.AbstractControlCommand; + +/** + * The internationalization annotation in the notation file must be copied in + * the new controlled file. + */ +public class InternationalizationAnnotationControlCommand extends AbstractControlCommand { + + /** + * The Constant COMMAND_TITLE. + */ + private static final String COMMAND_TITLE = "Annotation internationalization control command"; //$NON-NLS-1$ + + /** + * The old notation resource. + */ + private Resource oldNotationResource = null; + + /** + * Constructor. + * + * @param request + * The request. + * @param oldNotationResource + * The old notation resource. + */ + public InternationalizationAnnotationControlCommand(final ControlModeRequest request, + final Resource oldNotationResource) { + super(COMMAND_TITLE, null, request); + this.oldNotationResource = oldNotationResource; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) + throws ExecutionException { + CommandResult commandResult = null; + + // Check if the old notation resource is not null + if (null == oldNotationResource) { + commandResult = CommandResult.newErrorCommandResult( + String.format("The source %s model does not exist", NotationModel.NOTATION_FILE_EXTENSION)); //$NON-NLS-1$ + } else { + // Get the new notation resource and check if this is not null + final Resource newNotationResource = getTargetResource(); + if (null == newNotationResource) { + commandResult = CommandResult.newErrorCommandResult("The notation model has not been created"); //$NON-NLS-1$ + } else { + EAnnotation annotation = null; + + // Search about the internationalization preference + for (final EObject objectContent : oldNotationResource.getContents()) { + if (objectContent instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) objectContent).getSource())) { + annotation = EcoreUtil.copy((EAnnotation) objectContent); + } + } + + // If the annotation exists, add a copy for the new notation + // resource + if (null != annotation) { + newNotationResource.getContents().add(annotation); + commandResult = CommandResult.newOKCommandResult(newNotationResource); + } + } + } + + return null != commandResult ? commandResult : CommandResult.newOKCommandResult(); + } + + /** + * Retrieve the target resource from the request + * + * @return The target resource. + */ + protected Resource getTargetResource() { + return request.getTargetResource(NotationModel.NOTATION_FILE_EXTENSION); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/RemovePropertiesControlResourceCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/RemovePropertiesControlResourceCommand.java new file mode 100644 index 00000000000..2b90119a6ff --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/commands/RemovePropertiesControlResourceCommand.java @@ -0,0 +1,243 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.internationalization.controlmode.commands; + +import java.util.Locale; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.internationalization.common.utils.LocaleNameResolver; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand; +import org.eclipse.papyrus.infra.services.controlmode.messages.Messages; + +/** + * Command used to create new controlled properties resource. This command will + * create the new resources. It will also handle correctly undo and redo. + */ +public class RemovePropertiesControlResourceCommand extends RemoveControlResourceCommand { + + /** + * The resource to remove. We need it to remove it for undo command. + */ + private Resource resourceToRemove; + + /** + * The locale to add in the file name. + */ + private Locale locale; + + /** + * The internationalization model resource. + */ + private InternationalizationModelResource internationalizationModelResource; + + /** + * Constructor. + * + * @param request + * {@link ControlModeRequest} used to compute the command + * @param newFileExtension + * File extension use to create the resource. If not specified + * then it should be already provided in the {@link URI} + * @param resourceToRemove + * The resource to remove. + * @param locale + * The locale to add in the file name. + */ + public RemovePropertiesControlResourceCommand(final ControlModeRequest request, final String fileExtension, + final Resource resourceToRemove, final Locale locale) { + super(request, fileExtension); + this.resourceToRemove = resourceToRemove; + this.locale = locale; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) + throws ExecutionException { + CommandResult commandResult = null; + EObject objectToControl = getRequest().getTargetObject(); + if (null == objectToControl) { + commandResult = CommandResult.newErrorCommandResult(CONTROL_OBJECT_ERROR); + } else { + ModelSet modelSet = getRequest().getModelSet(); + if (null == modelSet) { + commandResult = CommandResult.newErrorCommandResult(RESOURCESET_ERROR); + } else { + + // Delete resource back-end on save + modelSet.getResourcesToDeleteOnSave().add(resourceToRemove.getURI()); + + // Save source and target resource + Resource targetResource = getTargetResource(objectToControl); + if (null == targetResource) { + commandResult = CommandResult + .newErrorCommandResult(Messages.getString(TARGET_RESOURCE_ERROR, getFileExtension())); + } else { + + // The target resource needs to be saved else the resolution + // will not operate + targetResource.setModified(true); + + getRequest().setTargetResource(targetResource, getFileExtension()); + getRequest().setSourceResource(resourceToRemove, getFileExtension()); + + // remove resource set + modelSet.getResources().remove(resourceToRemove); + + // Unload and remove the resource from the + // internationalization model resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.unload(resourceToRemove.getURI()); + modelResource.getResources().remove(resourceToRemove); + } + + commandResult = CommandResult.newOKCommandResult(); + } + } + } + + return commandResult; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand#doUndo(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected IStatus doUndo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + final IStatus result = super.doUndo(monitor, info); + + // Add the resource to the internationalization model resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.addResourceToModel(getRequest().getSourceURI().trimFileExtension(), resourceToRemove, locale); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand#getSourceResource() + */ + @Override + protected Resource getSourceResource() { + return resourceToRemove; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand#doRedo(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected IStatus doRedo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + final IStatus result = super.doRedo(monitor, info); + + // Unload and remove the resource from the internationalization model + // resource + final InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + modelResource.unload(resourceToRemove.getURI()); + modelResource.getResources().remove(resourceToRemove); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.commands.RemoveControlResourceCommand#getTargetResource(org.eclipse.emf.ecore.EObject) + */ + @Override + protected Resource getTargetResource(final EObject objectToUncontrol) { + Resource resultResource = null; + URI targetURI = null; + + if (null != objectToUncontrol) { + targetURI = objectToUncontrol.eResource().getURI().trimFileExtension(); + if (null != locale) { + String lastSegment = targetURI.lastSegment(); + lastSegment = lastSegment + LocaleNameResolver.UNDERSCORE + locale.toString(); + targetURI = targetURI.trimSegments(1).appendSegment(lastSegment); + } + targetURI = targetURI.appendFileExtension(getFileExtension()); + } + + if (null != targetURI) { + InternationalizationModelResource modelResource = getInternationalizationModelResource(); + if (null != modelResource) { + resultResource = modelResource.getResourceForURIAndLocale(objectToUncontrol.eResource().getURI() + .trimFileExtension().appendFileExtension(getFileExtension()), locale); + } + } + + return resultResource; + } + + /** + * Get the internationalization model resource. + * + * @return The internationalization model resource. + */ + protected InternationalizationModelResource getInternationalizationModelResource() { + if (null == internationalizationModelResource) { + final ModelSet modelSet = getRequest().getModelSet(); + if (null != modelSet) { + try { + internationalizationModelResource = (InternationalizationModelResource) modelSet + .getModelChecked(InternationalizationModelResource.MODEL_ID); + } catch (final NotFoundException e) { + // Do nothing + } + } + } + + return internationalizationModelResource; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.workspace.AbstractEMFOperation#dispose() + */ + @Override + public void dispose() { + internationalizationModelResource = null; + resourceToRemove = null; + locale = null; + super.dispose(); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/InternationalizationAnnotationControlParticipant.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/InternationalizationAnnotationControlParticipant.java new file mode 100644 index 00000000000..4d2ebf01c6e --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/InternationalizationAnnotationControlParticipant.java @@ -0,0 +1,183 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.participants; + +import java.util.Iterator; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.controlmode.Activator; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.InternationalizationAnnotationControlCommand; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant; +import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant; + +/** + * The internationalization annotation control participant for the preference + * annotation. + */ +public class InternationalizationAnnotationControlParticipant + implements IControlCommandParticipant, IUncontrolCommandParticipant { + + /** + * The Constant PARTICIPANT_ID. + */ + private static final String PARTICIPANT_ID = "org.eclipse.papyrus.infra.internationalization.controlmode.InternationalizationAnnotationControlParticipant"; //$NON-NLS-1$ + + /** + * Constructor. + */ + public InternationalizationAnnotationControlParticipant() { + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getID() + */ + @Override + public String getID() { + return PARTICIPANT_ID; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getPriority() + */ + @Override + public int getPriority() { + return 20; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#provideUnControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public boolean provideUnControlCommand(final ControlModeRequest request) { + return false; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#getPreUncontrolCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPreUncontrolCommand(final ControlModeRequest request) { + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#getPostUncontrolCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPostUncontrolCommand(final ControlModeRequest request) { + // Don't create the notation resource since it is already handled + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#provideControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public boolean provideControlCommand(final ControlModeRequest request) { + boolean result = false; + + // Check if the annotation for the internationalization is in the + // notation file + final Iterator objectContentsIterator = getSourceResource(request).getContents().iterator(); + while (objectContentsIterator.hasNext() && !result) { + EObject objectContent = objectContentsIterator.next(); + if (objectContent instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) objectContent).getSource())) { + result = true; + } + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#getPreControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPreControlCommand(final ControlModeRequest request) { + // Don't create the notation resource since it is already handled + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#getPostControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPostControlCommand(final ControlModeRequest request) { + return new InternationalizationAnnotationControlCommand(request, getSourceResource(request)); + } + + /** + * Gets the old notation resource. + * + * @param request + * The control request. + * @return the old notation resource. + */ + protected Resource getSourceResource(final ControlModeRequest request) { + Resource oldNotationResource = null; + + try { + oldNotationResource = request.getModelSet().getResource(getOldNotationURI(request), true); + } catch (Exception e) { + Activator.log.error("Unable to retrieve old notation resource", e); //$NON-NLS-1$ + } + + return oldNotationResource; + } + + /** + * Get the old notation URI for request. + * + * @param request + * The control request. + * @return The old notation resource. + * @throws ExecutionException + * The exception when the notation resource is not found. + */ + protected URI getOldNotationURI(final ControlModeRequest request) throws ExecutionException { + URI uri = request.getSourceURI(); + + if (null != uri) { + return uri.trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION); + } + throw new ExecutionException("Unable to retreive URI of the old notation model"); //$NON-NLS-1$ + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesControlParticipant.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesControlParticipant.java new file mode 100644 index 00000000000..45a6a1eb09a --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesControlParticipant.java @@ -0,0 +1,159 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.participants; + +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.ControlPropertiesCommand; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.CreatePropertiesControlResourceCommand; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant; + +/** + * The control participant for the properties files. + */ +public class PropertiesControlParticipant implements IControlCommandParticipant { + + /** + * The Constant PARTICIPANT_ID. + */ + private static final String PARTICIPANT_ID = "org.eclipse.papyrus.infra.internationalization.controlmode.PropertiesControlParticipant"; //$NON-NLS-1$ + + /** + * The internationalization model resource. + */ + private InternationalizationModelResource internationalizationModelResource; + + /** + * Constructor. + */ + public PropertiesControlParticipant() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getID() + */ + @Override + public String getID() { + return PARTICIPANT_ID; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getPriority() + */ + @Override + public int getPriority() { + return 40; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#provideControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public boolean provideControlCommand(final ControlModeRequest request) { + boolean result = false; + + final EObject objectToControl = request.getTargetObject(); + if (null != objectToControl) { + // If there is no properties resource in the old resource, then + // there's nothing to do + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + final Map localesAndResourcesForURI = modelResource + .getLocalesAndResourcesForURI(request.getSourceURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)); + + result = null != localesAndResourcesForURI && !localesAndResourcesForURI.isEmpty(); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#getPreControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPreControlCommand(final ControlModeRequest request) { + ICommand resultCommand = UnexecutableCommand.INSTANCE; + + // Get the used locale to determinate the properties file to create + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + if (null != modelResource) { + final Set locales = modelResource.getAvailablePropertiesLocales(request.getSourceURI()); + + resultCommand = new CompositeTransactionalCommand(request.getEditingDomain(), "Create properties files"); //$NON-NLS-1$ + + // Loop on each locale to create associated properties file + for (final Locale currentLocale : locales) { + ((CompositeTransactionalCommand) resultCommand).add(new CreatePropertiesControlResourceCommand(request, + PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION, currentLocale)); + } + } + + return resultCommand; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant#getPostControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPostControlCommand(final ControlModeRequest request) { + + // Dispose the internationalizationModelResource + internationalizationModelResource = null; + + return new ControlPropertiesCommand(request); + } + + /** + * Get the internationalization model resource. + * + * @return The internationalization model resource. + */ + protected InternationalizationModelResource getInternationalizationModelResource(final ControlModeRequest request) { + if (null == internationalizationModelResource && null != request) { + final ModelSet modelSet = request.getModelSet(); + if (null != modelSet) { + try { + internationalizationModelResource = (InternationalizationModelResource) modelSet + .getModelChecked(InternationalizationModelResource.MODEL_ID); + } catch (final NotFoundException e) { + // Do nothing + } + } + } + + return internationalizationModelResource; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesUncontrolParticipant.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesUncontrolParticipant.java new file mode 100644 index 00000000000..007f94cc02f --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/participants/PropertiesUncontrolParticipant.java @@ -0,0 +1,249 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.participants; + +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.ControlPropertiesCommand; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.CreatePropertiesControlResourceCommand; +import org.eclipse.papyrus.infra.internationalization.controlmode.commands.RemovePropertiesControlResourceCommand; +import org.eclipse.papyrus.infra.internationalization.controlmode.utils.ControlPropertiesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; +import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; +import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant; + +/** + * The uncontrol participant for the properties files. + */ +public class PropertiesUncontrolParticipant implements IUncontrolCommandParticipant { + + /** + * The Constant PARTICIPANT_ID. + */ + private static final String PARTICIPANT_ID = "org.eclipse.papyrus.infra.internationalization.controlmode.PropertiesUncontrolParticipant"; //$NON-NLS-1$ + + /** + * The internationalization model resource. + */ + private InternationalizationModelResource internationalizationModelResource; + + /** + * Constructor. + */ + public PropertiesUncontrolParticipant() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getID() + */ + @Override + public String getID() { + return PARTICIPANT_ID; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IControlModeParticipant#getPriority() + */ + @Override + public int getPriority() { + return 70; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#provideUnControlCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public boolean provideUnControlCommand(final ControlModeRequest request) { + boolean result = false; + + final EObject objectToUncontrol = request.getTargetObject(); + if (null != objectToUncontrol) { + // If there is no properties resource in the old resource, then + // there's nothing to do + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + final Map localesAndResourcesForURI = modelResource + .getLocalesAndResourcesForURI(request.getSourceURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)); + + result = null != localesAndResourcesForURI && !localesAndResourcesForURI.isEmpty(); + } + + return result; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#getPreUncontrolCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPreUncontrolCommand(final ControlModeRequest request) { + boolean result = setPropertiesTargetRequest(request); + + CompositeTransactionalCommand compositeCommand = null; + + if (result) { + compositeCommand = new CompositeTransactionalCommand(request.getEditingDomain(), "Uncontrol command"); //$NON-NLS-1$ + + // Before modify properties files, check that new properties files are available + final URI newPropertiesURI = request.getNewURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + final URI sourcePropertiesURI = request.getSourceURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + final ModelSet modelSet = request.getModelSet(); + + if (null != modelSet) { + + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + if (null != modelResource) { + final Map newLocalesAndResources = modelResource + .getLocalesAndResourcesForURI(newPropertiesURI); + final Map sourceLocalesAndResources = modelResource + .getLocalesAndResourcesForURI(sourcePropertiesURI); + + for(final Locale sourceLocale : sourceLocalesAndResources.keySet()){ + if(!newLocalesAndResources.containsKey(sourceLocale)){ + // The locale is not existing for the new properties resources, we need to create it + compositeCommand.add(new CreatePropertiesControlResourceCommand(request, + PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION, sourceLocale)); + } + } + } + } + + compositeCommand.add(new ControlPropertiesCommand(request)); + } + + return null != compositeCommand ? compositeCommand : UnexecutableCommand.INSTANCE; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant#getPostUncontrolCommand(org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest) + */ + @Override + public ICommand getPostUncontrolCommand(final ControlModeRequest request) { + ICommand commandResult = UnexecutableCommand.INSTANCE; + + final Map result = getPropertiesSourceRequest(request); + if (null != result && !result.isEmpty()) { + final CompositeTransactionalCommand compositeCommand = new CompositeTransactionalCommand( + request.getEditingDomain(), "Remove properties resources"); //$NON-NLS-1$ + + for (final Entry entry : result.entrySet()) { + compositeCommand.add(new RemovePropertiesControlResourceCommand(request, + PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION, entry.getValue(), entry.getKey())); + } + + commandResult = compositeCommand; + } + + // Dispose the internationationalizationModelResource + internationalizationModelResource = null; + + return commandResult; + } + + /** + * Init target request to have the properties resources references. + * + * @param request + * The request. + */ + protected boolean setPropertiesTargetRequest(final ControlModeRequest request) { + boolean result = false; + final URI propertiesURI = request.getNewURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + final ModelSet modelSet = request.getModelSet(); + + if (null != modelSet) { + + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + if (null != modelResource) { + final Map localesAndResources = modelResource + .getLocalesAndResourcesForURI(propertiesURI); + + if (!localesAndResources.isEmpty()) { + request.setParameter(ControlPropertiesUtils.CREATED_PROPERTIES_RESOURCES, localesAndResources); + // Nothing to do but everything is ok + result = true; + } + } + } + + return result; + } + + /** + * Init source request to have the properties resources references. + * + * @param request + * The request. + */ + protected Map getPropertiesSourceRequest(final ControlModeRequest request) { + Map result = null; + final URI propertiesURI = request.getSourceURI().trimFileExtension() + .appendFileExtension(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + final ModelSet modelSet = request.getModelSet(); + + if (null != modelSet) { + final InternationalizationModelResource modelResource = getInternationalizationModelResource(request); + if (null != modelResource) { + result = modelResource.getLocalesAndResourcesForURI(propertiesURI); + } + } + + return result; + } + + /** + * Get the internationalization model resource. + * + * @return The internationalization model resource. + */ + protected InternationalizationModelResource getInternationalizationModelResource(final ControlModeRequest request) { + if (null == internationalizationModelResource && null != request) { + final ModelSet modelSet = request.getModelSet(); + if (null != modelSet) { + try { + internationalizationModelResource = (InternationalizationModelResource) modelSet + .getModelChecked(InternationalizationModelResource.MODEL_ID); + } catch (final NotFoundException e) { + // Do nothing + } + } + } + + return internationalizationModelResource; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/utils/ControlPropertiesUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/utils/ControlPropertiesUtils.java new file mode 100644 index 00000000000..11c4e3975da --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.controlmode/src/org/eclipse/papyrus/infra/internationalization/controlmode/utils/ControlPropertiesUtils.java @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.controlmode.utils; + +/** + * The control properties utils class. + */ +public class ControlPropertiesUtils { + + /** + * The created properties resources constant. + */ + public static final String CREATED_PROPERTIES_RESOURCES = "createdPropertiesResources"; //$NON-NLS-1$ +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.classpath new file mode 100644 index 00000000000..8dd013afc8b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.project new file mode 100644 index 00000000000..9b31b5cc1c8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization.edit + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..a4b66a677b2 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization.edit;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.provider.InternationalizationEditPlugin$Implementation +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization.edit.provider, + org.eclipse.papyrus.infra.internationalization.provider +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)";visibility:=reexport, + org.eclipse.emf.edit;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.gmf.runtime.notation.edit;bundle-version="[1.7.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" +Bundle-ActivationPolicy: lazy diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/build.properties new file mode 100644 index 00000000000..60f476a9c04 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/build.properties @@ -0,0 +1,12 @@ +# + +bin.includes = .,\ + icons/,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src-gen/,\ + src/ +output.. = bin/ \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationEntry.gif b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationEntry.gif new file mode 100644 index 00000000000..5a9bc7514fa Binary files /dev/null and b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationEntry.gif differ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationLibrary.gif b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationLibrary.gif new file mode 100644 index 00000000000..48e3cf22687 Binary files /dev/null and b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/icons/full/obj16/InternationalizationLibrary.gif differ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.properties new file mode 100644 index 00000000000..632eac41a11 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.properties @@ -0,0 +1,25 @@ +# + +pluginName = Papyrus Internationalization Edit Support +providerName = Eclipse Modeling Project + +_UI_CreateChild_text = {0} +_UI_CreateChild_text2 = {1} {0} +_UI_CreateChild_text3 = {1} +_UI_CreateChild_tooltip = Create New {0} Under {1} Feature +_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}. +_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent. + +_UI_PropertyDescriptor_description = The {0} of the {1} + +_UI_InternationalizationLibrary_type = Library +_UI_InternationalizationEntry_type = Entry +_UI_Unknown_type = Object + +_UI_Unknown_datatype= Value + +_UI_InternationalizationLibrary_entries_feature = Entries +_UI_InternationalizationEntry_key_feature = Key +_UI_InternationalizationEntry_value_feature = Value +_UI_Unknown_feature = Unspecified + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.xml new file mode 100644 index 00000000000..d00f5dc6637 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/plugin.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/pom.xml new file mode 100644 index 00000000000..e94fe7a47e9 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.edit + 1.0.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEditPlugin.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEditPlugin.java new file mode 100644 index 00000000000..e424a72a7a3 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEditPlugin.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.provider; + +import org.eclipse.emf.common.EMFPlugin; + +import org.eclipse.emf.common.util.ResourceLocator; + +/** + * This is the central singleton for the Internationalization edit plugin. + * + * + * @generated + */ +public final class InternationalizationEditPlugin extends EMFPlugin { + /** + * Keep track of the singleton. + * + * + * @generated + */ + public static final InternationalizationEditPlugin INSTANCE = new InternationalizationEditPlugin(); + + /** + * Keep track of the singleton. + * + * + * @generated + */ + private static Implementation plugin; + + /** + * Create the instance. + * + * + * @generated + */ + public InternationalizationEditPlugin() { + super(new ResourceLocator[] {}); + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + public static Implementation getPlugin() { + return plugin; + } + + /** + * The actual implementation of the Eclipse Plugin. + * + * + * @generated + */ + public static class Implementation extends EclipsePlugin { + /** + * Creates an instance. + * + * + * @generated + */ + public Implementation() { + super(); + + // Remember the static instance. + // + plugin = this; + } + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEntryItemProvider.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEntryItemProvider.java new file mode 100644 index 00000000000..7be66df9f88 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationEntryItemProvider.java @@ -0,0 +1,171 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry} object. + * + * + * @generated + */ +public class InternationalizationEntryItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, + IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public InternationalizationEntryItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addKeyPropertyDescriptor(object); + addValuePropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Key feature. + * + * + * @generated + */ + protected void addKeyPropertyDescriptor(Object object) { + itemPropertyDescriptors + .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), getString("_UI_InternationalizationEntry_key_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_InternationalizationEntry_key_feature", //$NON-NLS-1$//$NON-NLS-2$ + "_UI_InternationalizationEntry_type"), //$NON-NLS-1$ + InternationalizationPackage.Literals.INTERNATIONALIZATION_ENTRY__KEY, true, false, false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This adds a property descriptor for the Value feature. + * + * + * @generated + */ + protected void addValuePropertyDescriptor(Object object) { + itemPropertyDescriptors + .add(createItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), getString("_UI_InternationalizationEntry_value_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_InternationalizationEntry_value_feature", //$NON-NLS-1$//$NON-NLS-2$ + "_UI_InternationalizationEntry_type"), //$NON-NLS-1$ + InternationalizationPackage.Literals.INTERNATIONALIZATION_ENTRY__VALUE, true, false, false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null, null)); + } + + /** + * This returns InternationalizationEntry.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/InternationalizationEntry")); //$NON-NLS-1$ + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + Object labelValue = ((InternationalizationEntry) object).getKey(); + String label = labelValue == null ? null : labelValue.toString(); + return label == null || label.length() == 0 ? getString("_UI_InternationalizationEntry_type") : //$NON-NLS-1$ + getString("_UI_InternationalizationEntry_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(InternationalizationEntry.class)) { + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY: + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return InternationalizationEditPlugin.INSTANCE; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationItemProviderAdapterFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationItemProviderAdapterFactory.java new file mode 100644 index 00000000000..1b0fabfb979 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationItemProviderAdapterFactory.java @@ -0,0 +1,243 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.provider; + +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.edit.provider.ChangeNotifier; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IChangeNotifier; +import org.eclipse.emf.edit.provider.IDisposable; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.INotifyChangedListener; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; + +import org.eclipse.papyrus.infra.internationalization.util.InternationalizationAdapterFactory; + +/** + * This is the factory that is used to provide the interfaces needed to support Viewers. + * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. + * The adapters also support Eclipse property sheets. + * Note that most of the adapters are shared among multiple instances. + * + * + * @generated + */ +public class InternationalizationItemProviderAdapterFactory extends InternationalizationAdapterFactory + implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { + /** + * This keeps track of the root adapter factory that delegates to this adapter factory. + * + * + * @generated + */ + protected ComposedAdapterFactory parentAdapterFactory; + + /** + * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. + * + * + * @generated + */ + protected IChangeNotifier changeNotifier = new ChangeNotifier(); + + /** + * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. + * + * + * @generated + */ + protected Collection supportedTypes = new ArrayList<>(); + + /** + * This constructs an instance. + * + * + * @generated + */ + public InternationalizationItemProviderAdapterFactory() { + supportedTypes.add(IEditingDomainItemProvider.class); + supportedTypes.add(IStructuredItemContentProvider.class); + supportedTypes.add(ITreeItemContentProvider.class); + supportedTypes.add(IItemLabelProvider.class); + supportedTypes.add(IItemPropertySource.class); + } + + /** + * This keeps track of the one adapter used for all {@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary} instances. + * + * + * @generated + */ + protected InternationalizationLibraryItemProvider internationalizationLibraryItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary}. + * + * + * @generated + */ + @Override + public Adapter createInternationalizationLibraryAdapter() { + if (internationalizationLibraryItemProvider == null) { + internationalizationLibraryItemProvider = new InternationalizationLibraryItemProvider(this); + } + + return internationalizationLibraryItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry} instances. + * + * + * @generated + */ + protected InternationalizationEntryItemProvider internationalizationEntryItemProvider; + + /** + * This creates an adapter for a {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry}. + * + * + * @generated + */ + @Override + public Adapter createInternationalizationEntryAdapter() { + if (internationalizationEntryItemProvider == null) { + internationalizationEntryItemProvider = new InternationalizationEntryItemProvider(this); + } + + return internationalizationEntryItemProvider; + } + + /** + * This returns the root adapter factory that contains this factory. + * + * + * @generated + */ + @Override + public ComposeableAdapterFactory getRootAdapterFactory() { + return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); + } + + /** + * This sets the composed adapter factory that contains this factory. + * + * + * @generated + */ + @Override + public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { + this.parentAdapterFactory = parentAdapterFactory; + } + + /** + * + * + * @generated + */ + @Override + public boolean isFactoryForType(Object type) { + return supportedTypes.contains(type) || super.isFactoryForType(type); + } + + /** + * This implementation substitutes the factory itself as the key for the adapter. + * + * + * @generated + */ + @Override + public Adapter adapt(Notifier notifier, Object type) { + return super.adapt(notifier, this); + } + + /** + * + * + * @generated + */ + @Override + public Object adapt(Object object, Object type) { + if (isFactoryForType(type)) { + Object adapter = super.adapt(object, type); + if (!(type instanceof Class) || (((Class) type).isInstance(adapter))) { + return adapter; + } + } + + return null; + } + + /** + * This adds a listener. + * + * + * @generated + */ + @Override + public void addListener(INotifyChangedListener notifyChangedListener) { + changeNotifier.addListener(notifyChangedListener); + } + + /** + * This removes a listener. + * + * + * @generated + */ + @Override + public void removeListener(INotifyChangedListener notifyChangedListener) { + changeNotifier.removeListener(notifyChangedListener); + } + + /** + * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. + * + * + * @generated + */ + @Override + public void fireNotifyChanged(Notification notification) { + changeNotifier.fireNotifyChanged(notification); + + if (parentAdapterFactory != null) { + parentAdapterFactory.fireNotifyChanged(notification); + } + } + + /** + * This disposes all of the item providers created by this factory. + * + * + * @generated + */ + @Override + public void dispose() { + if (internationalizationLibraryItemProvider != null) { + internationalizationLibraryItemProvider.dispose(); + } + if (internationalizationEntryItemProvider != null) { + internationalizationEntryItemProvider.dispose(); + } + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationLibraryItemProvider.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationLibraryItemProvider.java new file mode 100644 index 00000000000..0f216466b71 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src-gen/org/eclipse/papyrus/infra/internationalization/provider/InternationalizationLibraryItemProvider.java @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.provider; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; + +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; + +/** + * This is the item provider adapter for a {@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary} object. + * + * + * @generated + */ +public class InternationalizationLibraryItemProvider extends ItemProviderAdapter implements IEditingDomainItemProvider, + IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public InternationalizationLibraryItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addEntriesPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Entries feature. + * + * + * @generated + */ + protected void addEntriesPropertyDescriptor(Object object) { + itemPropertyDescriptors.add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(), + getString("_UI_InternationalizationLibrary_entries_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_InternationalizationLibrary_entries_feature", //$NON-NLS-1$//$NON-NLS-2$ + "_UI_InternationalizationLibrary_type"), //$NON-NLS-1$ + InternationalizationPackage.Literals.INTERNATIONALIZATION_LIBRARY__ENTRIES, true, false, true, null, + null, null)); + } + + /** + * This returns InternationalizationLibrary.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/InternationalizationLibrary")); //$NON-NLS-1$ + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + return getString("_UI_InternationalizationLibrary_type"); //$NON-NLS-1$ + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return InternationalizationEditPlugin.INSTANCE; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src/org/eclipse/papyrus/infra/internationalization/edit/provider/InternationalizationNotationItemProviderAdapterFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src/org/eclipse/papyrus/infra/internationalization/edit/provider/InternationalizationNotationItemProviderAdapterFactory.java new file mode 100644 index 00000000000..0837214f7ed --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.edit/src/org/eclipse/papyrus/infra/internationalization/edit/provider/InternationalizationNotationItemProviderAdapterFactory.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.edit.provider; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NotationEditPlugin; +import org.eclipse.gmf.runtime.notation.provider.DiagramItemProvider; +import org.eclipse.gmf.runtime.notation.provider.NotationItemProviderAdapterFactory; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; + +/** + * This allows to re-implement the diagram adapter for the label + * internationalization call. + */ +public class InternationalizationNotationItemProviderAdapterFactory extends NotationItemProviderAdapterFactory { + + /** + * Constructor. + */ + public InternationalizationNotationItemProviderAdapterFactory() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.notation.provider.NotationItemProviderAdapterFactory#createDiagramAdapter() + */ + @Override + public Adapter createDiagramAdapter() { + if (diagramItemProvider == null) { + diagramItemProvider = new DiagramItemProvider(this) { + @Override + public String getText(Object object) { + String label = LabelInternationalization.getInstance().getDiagramLabel((Diagram) object); + return label == null || label.length() == 0 + ? NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) //$NON-NLS-1$ + : NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + }; + } + + return (Adapter) diagramItemProvider; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.project new file mode 100644 index 00000000000..215b0c7400b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization.ui + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/.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/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..bd14dc1bd0a --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization.ui;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization.ui, + org.eclipse.papyrus.infra.internationalization.ui.dialogs, + org.eclipse.papyrus.infra.internationalization.ui.handlers +Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)", + org.eclipse.ui.workbench;bundle-version="[3.108.0,4.0.0)", + org.eclipse.ui;bundle-version="[3.107.0,4.0.0)", + org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.emf;bundle-version="[2.2.0,3.0.0)", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)" +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.ui.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/build.properties new file mode 100644 index 00000000000..2964bc2d7b1 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/build.properties @@ -0,0 +1,11 @@ +# + +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ +src.includes = about.html diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.properties new file mode 100644 index 00000000000..383429a1252 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Papyrus Internationalization UI +providerName = Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.xml new file mode 100644 index 00000000000..490fd5dec9a --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/plugin.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/pom.xml new file mode 100644 index 00000000000..5bf9055d118 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.ui + 1.0.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/Activator.java new file mode 100644 index 00000000000..c7d97b28686 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/Activator.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.ui; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.internationalization.ui"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/dialogs/InternationalizationDialog.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/dialogs/InternationalizationDialog.java new file mode 100644 index 00000000000..0d99705fd8d --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/dialogs/InternationalizationDialog.java @@ -0,0 +1,251 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.ui.dialogs; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.jface.dialogs.TrayDialog; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * The dialog to manage the internationalization configuration. This will + * contains: - Checkbox to determinate if the internationalization must be used + * or not - Viewer to select the language of the internationalization + */ +public class InternationalizationDialog extends TrayDialog { + + /** + * The resource URI corresponding to the papyrus model. This is needed to + * get the preference of the papyrus model. + */ + private URI resourceURI; + + /** + * The viewer for the language selection. + */ + protected TableViewer tableViewer; + + /** + * The widget to manage the use internationalization value. + */ + protected Button useInternationalizationButton; + + /** + * Keep the internationalization use value after the dialog closed. + */ + protected boolean useInternationalizationValue; + + /** + * Keep the locale value after the dialog closed. + */ + protected Locale localeValue; + + /** + * Boolean to determinate if the use internationalization must be displayed. + */ + private boolean displayUse; + + /** + * Constructor. + * + * @param parentShell + * The parent shell. + * @param resourceURI + * The resource URI corresponding to the papyrus model (need to + * get preference of the papyrus model). + * @param displayUse + * Boolean to determinate if the use internationalization must be + * displayed. + */ + public InternationalizationDialog(final Shell parentShell, final URI resourceURI, final boolean displayUse) { + super(parentShell); + setResourceURI(resourceURI); + this.displayUse = displayUse; + } + + /** + * This allows to set the resource URI. + * + * @param resourceURI + * The resource URI to set. + */ + public void setResourceURI(final URI resourceURI) { + this.resourceURI = resourceURI; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(final Composite parent) { + final Composite composite = (Composite) super.createDialogArea(parent); + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 300; + data.heightHint = 300; + composite.setLayoutData(data); + + getShell().setText("Configure internationalization"); //$NON-NLS-1$ + getShell().setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("/icons/papyrus.png")); //$NON-NLS-1$ + + if (displayUse()) { + createUseInternationalization(composite); + } + createLanguage(composite); + initializeValues(); + + return composite; + } + + /** + * Determinates if the use internationalization checkbox must be displayed. + * + * @return true if this will be displayed, false + * otherwise. + */ + protected boolean displayUse() { + return displayUse; + } + + /** + * This allows to create the checkbox which manage the use + * internationalization button. + * + * @param parent + * The parent composite. + */ + protected void createUseInternationalization(final Composite parent) { + useInternationalizationButton = new Button(parent, SWT.CHECK); + useInternationalizationButton.setText("Use internationalization"); + } + + /** + * This allows to create the viewer to select the language which be used for + * the internationalization. + * + * @param parent + * The parent composite. + */ + protected void createLanguage(final Composite parent) { + // Create the viewer and the grid data + tableViewer = new TableViewer(parent, SWT.BORDER); + final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.minimumHeight = 200; + data.minimumWidth = 100; + tableViewer.getTable().setLayoutData(data); + + // Set its label and content providers + tableViewer.setContentProvider(new ArrayContentProvider()); + tableViewer.setLabelProvider(new LabelProvider()); + + // Set the input with the available locales + final List availableLocales = Arrays.asList(Locale.getAvailableLocales()); + availableLocales.sort(new Comparator() { + + @Override + public int compare(final Locale arg0, final Locale arg1) { + return arg0.toString().compareTo(arg1.toString()); + } + + }); + tableViewer.setInput(availableLocales); + + // Add a double click listener to close the dialog on double click + tableViewer.addDoubleClickListener(new IDoubleClickListener() { + + @Override + public void doubleClick(DoubleClickEvent event) { + setReturnCode(OK); + close(); + } + }); + } + + /** + * This allows to initialize the values of fields. + */ + protected void initializeValues() { + if (displayUse()) { + // Manage the selection change for the internationalization use + // button + useInternationalizationButton.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(final SelectionEvent e) { + useInternationalizationValue = useInternationalizationButton.getSelection(); + } + }); + // Initialize the boolean value from the preference of papyrus model + final boolean useInternationalization = InternationalizationPreferencesUtils + .getInternationalizationPreference(resourceURI); + useInternationalizationButton.setSelection(useInternationalization); + useInternationalizationValue = useInternationalization; + } + + // Manage the selection change for locale + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @Override + public void selectionChanged(final SelectionChangedEvent event) { + final ISelection selection = event.getSelection(); + final Locale localeSelected = (Locale) ((StructuredSelection) selection).getFirstElement(); + localeValue = localeSelected; + } + }); + // Initialize the locale value from the preference of papyrus model + final Locale locale = InternationalizationPreferencesUtils.getLocalePreference(resourceURI); + tableViewer.setSelection(new StructuredSelection(locale)); + tableViewer.reveal(locale); + } + + /** + * Get the use internationalization button value. + * + * @return The use internationalization button value. + */ + public boolean getUseInternationalizationValue() { + return useInternationalizationValue; + } + + /** + * Get the locale value to use for the internationalization. + * + * @return The locale value. + */ + public Locale getLocaleValue() { + return localeValue; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/handlers/InternationalizationCommandHandler.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/handlers/InternationalizationCommandHandler.java new file mode 100644 index 00000000000..93ad0a6650d --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.ui/src/org/eclipse/papyrus/infra/internationalization/ui/handlers/InternationalizationCommandHandler.java @@ -0,0 +1,167 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.ui.handlers; + +import java.util.Iterator; +import java.util.Locale; + +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand; +import org.eclipse.papyrus.infra.emf.commands.RemoveFromResourcecommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.internationalization.common.command.LocaleInternationalizationPreferenceCommand; +import org.eclipse.papyrus.infra.internationalization.common.command.UseInternationalizationPreferenceCommand; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.ui.Activator; +import org.eclipse.papyrus.infra.internationalization.ui.dialogs.InternationalizationDialog; +import org.eclipse.papyrus.infra.ui.command.AbstractCommandHandler; +import org.eclipse.ui.PlatformUI; + +/** + * The handler for the internationalization. + */ +public class InternationalizationCommandHandler extends AbstractCommandHandler { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.ui.command.AbstractCommandHandler#getCommand(org.eclipse.core.expressions.IEvaluationContext) + */ + @Override + protected Command getCommand(final IEvaluationContext context) { + Command resultCommand = UnexecutableCommand.INSTANCE; + + final EObject selectedElement = getSelectedElement(); + + final URI neededURIResource = getRootNotationURI(selectedElement); + + Resource notationResource = null; + final Iterator resources = selectedElement.eResource().getResourceSet().getResources().iterator(); + while (resources.hasNext() && null == notationResource) { + final Resource resource = resources.next(); + if (neededURIResource.equals(resource.getURI())) { // $NON-NLS-1$ + notationResource = resource; + } + } + + if (null != notationResource) { + final InternationalizationDialog dialog = new InternationalizationDialog( + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), notationResource.getURI(), true); + + if (Window.OK == dialog.open()) { + + final boolean useInternationalizationValue = dialog.getUseInternationalizationValue(); + final Locale localeValue = dialog.getLocaleValue(); + + EAnnotation annotation = null; + + // Search the internationalization annotation in the notation + // resource + for (final EObject objectContent : notationResource.getContents()) { + if (objectContent instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) objectContent).getSource())) { + annotation = (EAnnotation) objectContent; + } + } + + final CompoundCommand compoundCommand = new CompoundCommand("Create internationalization command"); //$NON-NLS-1$ + + if (null != annotation) { + // Remove the existing annotation + try { + compoundCommand.append(new RemoveFromResourcecommand( + ServiceUtilsForResource.getInstance().getTransactionalEditingDomain(notationResource), + notationResource, annotation)); + } catch (final ServiceException e) { + Activator.log.error(e); + } + compoundCommand + .append(new UseInternationalizationPreferenceCommand(notationResource.getURI(), false)); + } + + if (useInternationalizationValue && null != localeValue) { + // Create the annotation if the internationalization value + // is not false + annotation = EcoreFactory.eINSTANCE.createEAnnotation(); + annotation + .setSource(InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL); + if (useInternationalizationValue) { + annotation.getDetails().put( + InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL, + Boolean.toString(useInternationalizationValue)); + compoundCommand.append(new UseInternationalizationPreferenceCommand(notationResource.getURI(), + useInternationalizationValue)); + } + if (null != localeValue) { + annotation.getDetails().put(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE, + localeValue.toString()); + compoundCommand.append(new LocaleInternationalizationPreferenceCommand( + notationResource.getURI(), localeValue.toString())); + } + compoundCommand.append(new GMFtoEMFCommandWrapper(new AddToResourceCommand( + ((ModelSet) notationResource.getResourceSet()).getTransactionalEditingDomain(), + notationResource, annotation))); + } + + if (!compoundCommand.isEmpty()) { + resultCommand = compoundCommand; + } + } + } + + return resultCommand; + } + + /** + * Get the root notation URI (this allows to manage the control mode + * elements) + * + * @param selectedObject + * The initial selected object. + * @return The {@link URI} of the root notation. + */ + protected URI getRootNotationURI(final EObject selectedObject) { + // Get the root container of the selected object + final EObject rootContainer = EcoreUtil.getRootContainer(selectedObject); + + URI rootURI = rootContainer.eResource().getURI(); + // Remove the file extension and add the notation file extension + return rootURI.trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.ui.command.AbstractCommandHandler#setEnabled(java.lang.Object) + */ + @Override + public void setEnabled(final Object evaluationContext) { + setBaseEnabled(true); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.project new file mode 100644 index 00000000000..8fd4ddeebb4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization.utils + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/.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/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..bb0ec4e2ce5 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization.utils;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization.utils.commands, + org.eclipse.papyrus.infra.internationalization.utils.utils +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.ui.workbench, + org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.core;bundle-version="[2.0.0,3.0.0)", + org.eclipse.gmf.runtime.notation.edit;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.emf;bundle-version="[2.2.0,3.0.0)", + org.eclipse.jface;bundle-version="[3.12.0,4.0.0)", + org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)" +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.utils.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/build.properties new file mode 100644 index 00000000000..2964bc2d7b1 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/build.properties @@ -0,0 +1,11 @@ +# + +bin.includes = .,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ +src.includes = about.html diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.properties new file mode 100644 index 00000000000..eb11be415db --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Papyrus Internationalization Utils +providerName = Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.xml new file mode 100644 index 00000000000..7ac51d15095 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/plugin.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/pom.xml new file mode 100644 index 00000000000..b2e0417717d --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization.utils + 1.0.0-SNAPSHOT + eclipse-plugin + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/Activator.java new file mode 100644 index 00000000000..a3ea85f70bd --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/Activator.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.internationalization.utils"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/commands/InternationalizationPasteCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/commands/InternationalizationPasteCommand.java new file mode 100644 index 00000000000..704df3599d4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/commands/InternationalizationPasteCommand.java @@ -0,0 +1,84 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils.commands; + +import java.util.Locale; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils; + +/** + * A Command to set the internationalization of the object for the locale. + */ +public class InternationalizationPasteCommand extends RecordingCommand { + + /** + * The prefix to add. + */ + public static final String COPY_OF = "CopyOf_"; //$NON-NLS-1$ + + + /** + * The object to set the label. + */ + private EObject eObject; + + /** + * The label for the object. + */ + private String newLabel; + + /** + * The locale for the internationalization label for object. + */ + private Locale locale; + + /** + * + * Constructor. + * + * @param domain The editing domain. + * @param eObject The object to set the label. + * @param initialLabel The label for the object. + * @param locale The locale for the internationalization label for object. + */ + public InternationalizationPasteCommand(final TransactionalEditingDomain domain, final EObject eObject, final String initialLabel, final Locale locale) { + super(domain); + this.eObject = eObject; + this.newLabel = getNewLabel(initialLabel); + this.locale = locale; + } + + /** + * Get the label modified from the initial label. + * + * @param initialLabel The initial label. + * @return The modified label. + */ + private String getNewLabel(final String initialLabel){ + return new StringBuilder(COPY_OF).append(initialLabel).toString(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.transaction.RecordingCommand#doExecute() + */ + @Override + protected void doExecute() { + LabelInternationalizationUtils.setLabel(eObject, newLabel, locale); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/InternationalizationConstants.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/InternationalizationConstants.java new file mode 100644 index 00000000000..01f51b23270 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/InternationalizationConstants.java @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils.utils; + +/** + * This class defines the constants for the internationalization. + */ +public class InternationalizationConstants { + + /** + * The label property path. + */ + public static final String LABEL_PROPERTY_PATH = "label"; //$NON-NLS-1$ + + /** + * The keyword property path. + */ + public static final String KEYWORD_PROPERTY_PATH = "keyword"; //$NON-NLS-1$ +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java new file mode 100644 index 00000000000..257cca4d333 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java @@ -0,0 +1,229 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils.utils; + +import java.util.Locale; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; + +/** + * The internationalization label manager. + */ +public class LabelInternationalization { + + /** + * The singleton instance. + */ + private static LabelInternationalization instance; + + /** + * Constructor. + */ + protected LabelInternationalization() { + + } + + /** + * Get the singleton instance (create it if not existing). + * + * @return The singleton instance. + */ + public static LabelInternationalization getInstance() { + if (null == instance) { + instance = new LabelInternationalization(); + } + return instance; + } + + /** + * This allows to get the label of the diagram without the getName when the + * label is null. + * + * @param diagram + * The diagram. + * @return The label of the diagram. + */ + public String getDiagramLabelWithoutName(final Diagram diagram) { + return getDiagramLabelWithoutName(diagram, true); + } + + /** + * This allows to get the label of the diagram without the getName when the + * label is null. + * + * @param diagram + * The diagram. + * @param localize + * Boolean to determinate if the locale must be used. + * @return The label of the diagram. + */ + public String getDiagramLabelWithoutName(final Diagram diagram, final boolean localize) { + return LabelInternationalizationUtils.getLabelWithoutSubstract(diagram, localize); + } + + /** + * This allows to get the label of the diagram. + * + * @param diagram + * The diagram. + * @return The label of the diagram or the name if the label is null. + */ + public String getDiagramLabel(final Diagram diagram) { + return getDiagramLabel(diagram, true); + } + + /** + * This allows to get the label of the diagram. + * + * @param diagram + * The diagram. + * @param localize + * Boolean to determinate if the locale must be used. + * @return The label of the diagram or the name if the label is null. + */ + public String getDiagramLabel(final Diagram diagram, final boolean localize) { + String result = null; + if (null != diagram.eResource() && InternationalizationPreferencesUtils.getInternationalizationPreference(diagram)) { + result = getDiagramLabelWithoutName(diagram, localize); + } + return null != result ? result : diagram.getName(); + } + + /** + * This allows to set the diagram label. + * + * @param diagram + * The diagram. + * @param value + * The label value. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + */ + public void setDiagramLabel(final Diagram diagram, final String value, final Locale locale) { + LabelInternationalizationUtils.setLabel(diagram, value, locale); + } + + /** + * This allows to get the set diagram label command. + * + * @param domain + * The editing domain to use. + * @param diagram + * The diagram. + * @param value + * The value to set. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + * @return The command which allow to set the diagram label. + */ + public Command getSetDiagramLabelCommand(final EditingDomain domain, final Diagram diagram, final String value, + final Locale locale) { + return LabelInternationalizationUtils.getSetLabelCommand(domain, diagram, value, locale); + } + + /** + * This allows to get the label of the table without the getName when the + * label is null. + * + * @param table + * The table. + * @return The label of the table. + */ + public String getTableLabelWithoutName(final Table table) { + return getTableLabelWithoutName(table, true); + } + + /** + * This allows to get the label of the table without the getName when the + * label is null. + * + * @param table + * The table. + * @param localize + * Boolean to determinate if the locale must be used. + * @return The label of the table. + */ + public String getTableLabelWithoutName(final Table table, final boolean localize) { + return LabelInternationalizationUtils.getLabelWithoutSubstract(table, localize); + } + + /** + * This allows to get the label of the table. + * + * @param table + * The table. + * @return The label of the table or the name if the label is null. + */ + public String getTableLabel(final Table table) { + return getTableLabel(table, true); + } + + /** + * This allows to get the label of the table. + * + * @param table + * The table. + * @param localize + * Boolean to determinate if the locale must be used. + * @return The label of the table or the name if the label is null. + */ + public String getTableLabel(final Table table, final boolean localize) { + String result = null; + if (null != table.eResource() && InternationalizationPreferencesUtils.getInternationalizationPreference(table)) { + result = getTableLabelWithoutName(table, localize); + } + return null != result ? result : table.getName(); + } + + /** + * This allows to set the table label. + * + * @param table + * The table. + * @param value + * The label value. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + */ + public void setTableLabel(final Table table, final String value, final Locale locale) { + LabelInternationalizationUtils.setLabel(table, value, locale); + } + + /** + * This allows to get the set table label command. + * + * @param domain + * The editing domain to use. + * @param table + * The table. + * @param value + * The value to set. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + * @return The command which allow to set the table label. + */ + public Command getSetTableLabelCommand(final EditingDomain domain, final Table table, final String value, + final Locale locale) { + return LabelInternationalizationUtils.getSetLabelCommand(domain, table, value, locale); + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationPreferencesUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationPreferencesUtils.java new file mode 100644 index 00000000000..8ef77d9c261 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationPreferencesUtils.java @@ -0,0 +1,64 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils.utils; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; + +/** + * Open the label internationalization preferences to the others plugins with the utils plugin. + */ +public class LabelInternationalizationPreferencesUtils { + + /** + * This allows to modify the internationalization preference value. + * + * @param eObject The {@link EObject) corresponding (to get its resource). + * @param value The new preference value. + */ + public static void setInternationalizationPreference(final EObject eObject, final boolean value){ + InternationalizationPreferencesUtils.setInternationalizationPreference(eObject, value); + } + + /** + * This allows to modify the internationalization preference value. + * + * @param resource The {@link Resource) to get the papyrus project preferences. + * @param value The new preference value. + */ + public static void setInternationalizationPreference(final Resource resource, final boolean value){ + InternationalizationPreferencesUtils.setInternationalizationPreference(resource, value); + } + + /** + * This allows to get the internationalization preference value. + * + * @param eObject The {@link EObject) corresponding (to get its resource). + * @return true if the preference value is set to true, false otherwise. + */ + public static boolean getInternationalizationPreference(final EObject eObject){ + return InternationalizationPreferencesUtils.getInternationalizationPreference(eObject); + } + + /** + * This allows to get the internationalization preference value. + * + * @param resource The {@link Resource) to get the papyrus project preferences. + * @return true if the preference value is set to true, false otherwise. + */ + public static boolean getInternationalizationPreference(final Resource resource){ + return InternationalizationPreferencesUtils.getInternationalizationPreference(resource); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java new file mode 100644 index 00000000000..ee57125a72a --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java @@ -0,0 +1,259 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils.utils; + +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.NotFoundException; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.core.utils.ServiceUtils; +import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet; +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; + +/** + * This allows to manage the utils methods for the internationalization. + */ +public class LabelInternationalizationUtils { + + /** + * This allows to get the label without getting name if the label is null. + * + * @param eObject + * The object. + * @param localize + * Boolean to determinate if the localize must be used or not. + * @return The label of the object. + */ + public static String getLabelWithoutSubstract(final EObject eObject, final boolean localize) { + String result = null; + + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + if (null != internationalizationResource) { + result = internationalizationResource.getValueForEntryKey(eObject.eResource().getURI(), eObject); + } + } catch (final Exception e) { + // Do nothing + } + + return result; + } + + /** + * This allows to set the label. + * + * @param eObject + * The object. + * @param value + * The value to set. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + */ + public static void setLabel(final EObject eObject, final String value, final Locale locale) { + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + if (null != internationalizationResource) { + + Locale localeToUse = locale; + if (null == localeToUse) { + localeToUse = InternationalizationPreferencesUtils.getLocalePreference(eObject); + } + + internationalizationResource.setValue(eObject.eResource().getURI(), eObject, value, localeToUse); + } + } catch (final Exception e) { + // Do nothing + } + } + + /** + * This allows to get the set label command. + * + * @param domain + * The editing domain to use. + * @param eObject + * The object. + * @param value + * The value to set. + * @param locale + * The locale for which set the value (if null set + * it for the current locale). + * @return The command which allow to set the label. + */ + public static Command getSetLabelCommand(final EditingDomain domain, final EObject eObject, final String value, + final Locale locale) { + Command resultCommand = null; + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + if (null != internationalizationResource) { + + Locale localeToUse = locale; + if (null == localeToUse) { + localeToUse = InternationalizationPreferencesUtils.getLocalePreference(eObject); + } + + resultCommand = internationalizationResource.getSetValueCommand(domain, eObject.eResource().getURI(), + eObject, value, localeToUse); + } + } catch (final Exception e) { + // Do nothing + } + return null != resultCommand ? resultCommand : UnexecutableCommand.INSTANCE; + } + + /** + * This allows to get the {@link InternationalizationEntry} corresponding to + * the object and the key. + * + * @param eObject + * The object to search. + * @param key + * The key to search in the internationalization library. + * @return The corresponding {@link InternationalizationEntry}. + */ + public static InternationalizationEntry getInternationalizationEntry(final EObject eObject, final Object key) { + InternationalizationEntry resultEntry = null; + + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + if (null != internationalizationResource) { + resultEntry = internationalizationResource.getEntryForKey(eObject.eResource().getURI(), key, + InternationalizationPreferencesUtils.getLocalePreference(eObject)); + } + } catch (final Exception e) { + // Do nothing + } + + return resultEntry; + } + + /** + * This allows to get the {@link InternationalizationEntry} corresponding to + * the object and the key. + * + * @param eObject + * The object to search. + * @param key + * The key to search in the internationalization library. + * @param locale + * The locale of which get the value + * @return The corresponding {@link InternationalizationEntry}. + */ + public static InternationalizationEntry getInternationalizationEntry(final EObject eObject, final Object key, + final Locale locale) { + InternationalizationEntry resultEntry = null; + + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + if (null != internationalizationResource) { + + Locale localeToUse = locale; + if (null == localeToUse) { + localeToUse = InternationalizationPreferencesUtils.getLocalePreference(eObject); + } + + resultEntry = internationalizationResource.getEntryForKey(eObject.eResource().getURI(), key, locale); + } + } catch (final Exception e) { + // Do nothing + } + + return resultEntry; + } + + /** + * Get the available locales for the resource. + * + * @param resource + * The resource. + * @return The available locales of loaded properties files for resource. + */ + public static Set getAvailableLocales(final Resource resource) { + Set locales = null; + + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + resource); + + locales = internationalizationResource.getAvailablePropertiesLocales(resource.getURI()); + } catch (final Exception e) { + // Do nothing + } + + return null != locales ? locales : new HashSet(); + } + + /** + * Get the internationalizationModelResource from the model set. + * + * @param resource + * The initial resource. + * @return The internationalization model resource. + * @throws ServiceException + * The service registry exception. + * @throws NotFoundException + * The model not found exception. + */ + public static InternationalizationModelResource getInternationalizationModelResource(final Resource resource) + throws ServiceException, NotFoundException { + final ServicesRegistry servicesRegistry = ServiceUtilsForResourceSet.getInstance() + .getServiceRegistry(resource.getResourceSet()); + final ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry); + return (InternationalizationModelResource) modelSet.getModelChecked(InternationalizationModelResource.MODEL_ID); + } + + /** + * This allows to manage part label synchronizer for the object + * corresponding to the editor part. + * + * @param eObject + * The EObject (seems to be Table or Diagram). + * @param editorPart + * The editor part corresponding to the EObject. + */ + public static void managePartLabelSynchronizer(final EObject eObject, + final IInternationalizationEditor editorPart) { + try { + final InternationalizationModelResource internationalizationResource = getInternationalizationModelResource( + eObject.eResource()); + + internationalizationResource.addEditorPartForEObject(eObject, editorPart); + } catch (final Exception e) { + // Do nothing + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.classpath b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.classpath new file mode 100644 index 00000000000..e7a4ca0c29c --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.project b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.project new file mode 100644 index 00000000000..b85a6de555c --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.project @@ -0,0 +1,52 @@ + + + org.eclipse.papyrus.infra.internationalization + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.papyrus.releng.main.release/release.xml + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.oomph.version.VersionNature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.core.resources.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..a8dcccbdbbf --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +encoding//src/site/mediawiki/internationalizationDev-toc.xml=utf-8 +encoding//src/site/mediawiki/internationalizationDev.html=UTF-8 +encoding//target/site/generated-eclipse-help/internationalizationDev-toc.xml=utf-8 +encoding//target/site/generated-eclipse-help/internationalizationDev.html=UTF-8 diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..0c68a61dca8 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/.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/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..311910f0ab1 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF @@ -0,0 +1,29 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.infra.internationalization;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.papyrus.infra.internationalization, + org.eclipse.papyrus.infra.internationalization.commands, + org.eclipse.papyrus.infra.internationalization.modelresource, + org.eclipse.papyrus.infra.internationalization.modelsnippet, + org.eclipse.papyrus.infra.internationalization.util, + org.eclipse.papyrus.infra.internationalization.utils +Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.ui.workbench;bundle-version="[3.108.0,4.0.0)", + org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.core;bundle-version="[2.3.0,3.0.0)", + org.eclipse.gmf.runtime.notation.edit;bundle-version="[1.7.0,2.0.0)", + org.eclipse.papyrus.infra.emf;bundle-version="[2.2.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)", + org.eclipse.jface;bundle-version="[3.12.0,4.0.0)", + org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)", + org.eclipse.help;bundle-version="[3.8.0,4.0.0)", + org.eclipse.papyrus.infra.doc;bundle-version="[1.2.0,2.0.0)" +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.papyrus.infra.internationalization.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/about.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/about.html new file mode 100644 index 00000000000..598b3684879 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 12, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/build.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/build.properties new file mode 100644 index 00000000000..cc3850cb555 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/build.properties @@ -0,0 +1,13 @@ +# + +bin.includes = .,\ + model/,\ + META-INF/,\ + about.html,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src-gen/,\ + src/ +output.. = bin/ +src.includes = about.html diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.ecore b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.ecore new file mode 100644 index 00000000000..462ae055ec6 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.ecore @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.genmodel b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.genmodel new file mode 100644 index 00000000000..dfe7a13c995 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/model/Internationalization.genmodel @@ -0,0 +1,21 @@ + + + Internationalization.ecore + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.properties b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.properties new file mode 100644 index 00000000000..bb233bea040 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Papyrus Internationalization +providerName = Eclipse Modeling Project diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.xml new file mode 100644 index 00000000000..189b4a897ee --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/plugin.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/pom.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/pom.xml new file mode 100644 index 00000000000..19dc71f2eef --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra-internationalization + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra.internationalization + 1.0.0-SNAPSHOT + eclipse-plugin + + + + + org.eclipse.mylyn.docs + org.eclipse.mylyn.wikitext.core.maven + + src/site/mediawiki + ${project.build.directory}/site/generated-eclipse-help + + false + true + true + $1.html + $1-toc.xml + target/site/generated-eclipse-help + + + + + + eclipse-help + + + + + + org.eclipse.mylyn.docs + org.eclipse.mylyn.wikitext.mediawiki.core + ${mylyn.wikitext.version} + + + + + + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationEntry.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationEntry.java new file mode 100644 index 00000000000..8c2faecd9c9 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationEntry.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Entry'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getKey Key}
  • + *
  • {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getValue Value}
  • + *
+ * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#getInternationalizationEntry() + * @model + * @generated + */ +public interface InternationalizationEntry extends EObject { + /** + * Returns the value of the 'Key' attribute. + * + *

+ * If the meaning of the 'Key' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Key' attribute. + * @see #setKey(Object) + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#getInternationalizationEntry_Key() + * @model required="true" + * @generated + */ + Object getKey(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getKey Key}' attribute. + * + * + * @param value the new value of the 'Key' attribute. + * @see #getKey() + * @generated + */ + void setKey(Object value); + + /** + * Returns the value of the 'Value' attribute. + * + *

+ * If the meaning of the 'Value' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value' attribute. + * @see #setValue(String) + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#getInternationalizationEntry_Value() + * @model required="true" + * @generated + */ + String getValue(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getValue Value}' attribute. + * + * + * @param value the new value of the 'Value' attribute. + * @see #getValue() + * @generated + */ + void setValue(String value); + +} // InternationalizationEntry diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationFactory.java new file mode 100644 index 00000000000..4d5c13fac54 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationFactory.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage + * @generated + */ +public interface InternationalizationFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + InternationalizationFactory eINSTANCE = org.eclipse.papyrus.infra.internationalization.impl.InternationalizationFactoryImpl + .init(); + + /** + * Returns a new object of class 'Library'. + * + * + * @return a new object of class 'Library'. + * @generated + */ + InternationalizationLibrary createInternationalizationLibrary(); + + /** + * Returns a new object of class 'Entry'. + * + * + * @return a new object of class 'Entry'. + * @generated + */ + InternationalizationEntry createInternationalizationEntry(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + InternationalizationPackage getInternationalizationPackage(); + +} //InternationalizationFactory diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationLibrary.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationLibrary.java new file mode 100644 index 00000000000..c591a85a255 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationLibrary.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Library'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary#getEntries Entries}
  • + *
+ * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#getInternationalizationLibrary() + * @model + * @generated + */ +public interface InternationalizationLibrary extends EObject { + /** + * Returns the value of the 'Entries' reference list. + * The list contents are of type {@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry}. + * + *

+ * If the meaning of the 'Entries' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Entries' reference list. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#getInternationalizationLibrary_Entries() + * @model + * @generated + */ + EList getEntries(); + +} // InternationalizationLibrary diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationPackage.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationPackage.java new file mode 100644 index 00000000000..8e3da3cc47b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/InternationalizationPackage.java @@ -0,0 +1,274 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationFactory + * @model kind="package" + * @generated + */ +public interface InternationalizationPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "internationalization"; //$NON-NLS-1$ + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.eclipse.org/papyrus/internationalization/model"; //$NON-NLS-1$ + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "internationalization"; //$NON-NLS-1$ + + /** + * The singleton instance of the package. + * + * + * @generated + */ + InternationalizationPackage eINSTANCE = org.eclipse.papyrus.infra.internationalization.impl.InternationalizationPackageImpl + .init(); + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationLibraryImpl Library}' class. + * + * + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationLibraryImpl + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationPackageImpl#getInternationalizationLibrary() + * @generated + */ + int INTERNATIONALIZATION_LIBRARY = 0; + + /** + * The feature id for the 'Entries' reference list. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_LIBRARY__ENTRIES = 0; + + /** + * The number of structural features of the 'Library' class. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_LIBRARY_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'Library' class. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_LIBRARY_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl Entry}' class. + * + * + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationPackageImpl#getInternationalizationEntry() + * @generated + */ + int INTERNATIONALIZATION_ENTRY = 1; + + /** + * The feature id for the 'Key' attribute. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_ENTRY__KEY = 0; + + /** + * The feature id for the 'Value' attribute. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_ENTRY__VALUE = 1; + + /** + * The number of structural features of the 'Entry' class. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_ENTRY_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Entry' class. + * + * + * @generated + * @ordered + */ + int INTERNATIONALIZATION_ENTRY_OPERATION_COUNT = 0; + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary Library}'. + * + * + * @return the meta object for class 'Library'. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary + * @generated + */ + EClass getInternationalizationLibrary(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary#getEntries Entries}'. + * + * + * @return the meta object for the reference list 'Entries'. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary#getEntries() + * @see #getInternationalizationLibrary() + * @generated + */ + EReference getInternationalizationLibrary_Entries(); + + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry Entry}'. + * + * + * @return the meta object for class 'Entry'. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationEntry + * @generated + */ + EClass getInternationalizationEntry(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getKey Key}'. + * + * + * @return the meta object for the attribute 'Key'. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getKey() + * @see #getInternationalizationEntry() + * @generated + */ + EAttribute getInternationalizationEntry_Key(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getValue Value}'. + * + * + * @return the meta object for the attribute 'Value'. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationEntry#getValue() + * @see #getInternationalizationEntry() + * @generated + */ + EAttribute getInternationalizationEntry_Value(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + InternationalizationFactory getInternationalizationFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationLibraryImpl Library}' class. + * + * + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationLibraryImpl + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationPackageImpl#getInternationalizationLibrary() + * @generated + */ + EClass INTERNATIONALIZATION_LIBRARY = eINSTANCE.getInternationalizationLibrary(); + + /** + * The meta object literal for the 'Entries' reference list feature. + * + * + * @generated + */ + EReference INTERNATIONALIZATION_LIBRARY__ENTRIES = eINSTANCE.getInternationalizationLibrary_Entries(); + + /** + * The meta object literal for the '{@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl Entry}' class. + * + * + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl + * @see org.eclipse.papyrus.infra.internationalization.impl.InternationalizationPackageImpl#getInternationalizationEntry() + * @generated + */ + EClass INTERNATIONALIZATION_ENTRY = eINSTANCE.getInternationalizationEntry(); + + /** + * The meta object literal for the 'Key' attribute feature. + * + * + * @generated + */ + EAttribute INTERNATIONALIZATION_ENTRY__KEY = eINSTANCE.getInternationalizationEntry_Key(); + + /** + * The meta object literal for the 'Value' attribute feature. + * + * + * @generated + */ + EAttribute INTERNATIONALIZATION_ENTRY__VALUE = eINSTANCE.getInternationalizationEntry_Value(); + + } + +} //InternationalizationPackage diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationEntryImpl.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationEntryImpl.java new file mode 100644 index 00000000000..f71b6742ccb --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationEntryImpl.java @@ -0,0 +1,236 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; + +/** + * + * An implementation of the model object 'Entry'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl#getKey Key}
  • + *
  • {@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationEntryImpl#getValue Value}
  • + *
+ * + * @generated + */ +public class InternationalizationEntryImpl extends MinimalEObjectImpl.Container implements InternationalizationEntry { + /** + * The default value of the '{@link #getKey() Key}' attribute. + * + * + * @see #getKey() + * @generated + * @ordered + */ + protected static final Object KEY_EDEFAULT = null; + + /** + * The cached value of the '{@link #getKey() Key}' attribute. + * + * + * @see #getKey() + * @generated + * @ordered + */ + protected Object key = KEY_EDEFAULT; + + /** + * The default value of the '{@link #getValue() Value}' attribute. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected static final String VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getValue() Value}' attribute. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected String value = VALUE_EDEFAULT; + + /** + * + * + * @generated + */ + protected InternationalizationEntryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return InternationalizationPackage.Literals.INTERNATIONALIZATION_ENTRY; + } + + /** + * + * + * @generated + */ + @Override + public Object getKey() { + return key; + } + + /** + * + * + * @generated + */ + @Override + public void setKey(Object newKey) { + Object oldKey = key; + key = newKey; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, + InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY, oldKey, key)); + } + } + + /** + * + * + * @generated + */ + @Override + public String getValue() { + return value; + } + + /** + * + * + * @generated + */ + @Override + public void setValue(String newValue) { + String oldValue = value; + value = newValue; +// if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, + InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE, oldValue, value)); +// } + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY: + return getKey(); + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE: + return getValue(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY: + setKey(newValue); + return; + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE: + setValue((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY: + setKey(KEY_EDEFAULT); + return; + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE: + setValue(VALUE_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__KEY: + return KEY_EDEFAULT == null ? key != null : !KEY_EDEFAULT.equals(key); + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY__VALUE: + return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) { + return super.toString(); + } + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (key: "); //$NON-NLS-1$ + result.append(key); + result.append(", value: "); //$NON-NLS-1$ + result.append(value); + result.append(')'); + return result.toString(); + } + +} //InternationalizationEntryImpl diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationFactoryImpl.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationFactoryImpl.java new file mode 100644 index 00000000000..e9b99631670 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationFactoryImpl.java @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import org.eclipse.papyrus.infra.internationalization.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class InternationalizationFactoryImpl extends EFactoryImpl implements InternationalizationFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static InternationalizationFactory init() { + try { + InternationalizationFactory theInternationalizationFactory = (InternationalizationFactory) EPackage.Registry.INSTANCE + .getEFactory(InternationalizationPackage.eNS_URI); + if (theInternationalizationFactory != null) { + return theInternationalizationFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new InternationalizationFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public InternationalizationFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY: + return createInternationalizationLibrary(); + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY: + return createInternationalizationEntry(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * + * + * @generated + */ + @Override + public InternationalizationLibrary createInternationalizationLibrary() { + InternationalizationLibraryImpl internationalizationLibrary = new InternationalizationLibraryImpl(); + return internationalizationLibrary; + } + + /** + * + * + * @generated + */ + @Override + public InternationalizationEntry createInternationalizationEntry() { + InternationalizationEntryImpl internationalizationEntry = new InternationalizationEntryImpl(); + return internationalizationEntry; + } + + /** + * + * + * @generated + */ + @Override + public InternationalizationPackage getInternationalizationPackage() { + return (InternationalizationPackage) getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static InternationalizationPackage getPackage() { + return InternationalizationPackage.eINSTANCE; + } + +} //InternationalizationFactoryImpl diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationLibraryImpl.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationLibraryImpl.java new file mode 100644 index 00000000000..d8bc0cd67a4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationLibraryImpl.java @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; + +/** + * + * An implementation of the model object 'Library'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link org.eclipse.papyrus.infra.internationalization.impl.InternationalizationLibraryImpl#getEntries Entries}
  • + *
+ * + * @generated + */ +public class InternationalizationLibraryImpl extends MinimalEObjectImpl.Container + implements InternationalizationLibrary { + /** + * The cached value of the '{@link #getEntries() Entries}' reference list. + * + * + * @see #getEntries() + * @generated + * @ordered + */ + protected EList entries; + + /** + * + * + * @generated + */ + protected InternationalizationLibraryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return InternationalizationPackage.Literals.INTERNATIONALIZATION_LIBRARY; + } + + /** + * + * + * @generated + */ + @Override + public EList getEntries() { + if (entries == null) { + entries = new EObjectResolvingEList<>(InternationalizationEntry.class, this, + InternationalizationPackage.INTERNATIONALIZATION_LIBRARY__ENTRIES); + } + return entries; + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY__ENTRIES: + return getEntries(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY__ENTRIES: + getEntries().clear(); + getEntries().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY__ENTRIES: + getEntries().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY__ENTRIES: + return entries != null && !entries.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //InternationalizationLibraryImpl diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationPackageImpl.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationPackageImpl.java new file mode 100644 index 00000000000..197e2e23368 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/impl/InternationalizationPackageImpl.java @@ -0,0 +1,252 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationFactory; +import org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class InternationalizationPackageImpl extends EPackageImpl implements InternationalizationPackage { + /** + * + * + * @generated + */ + private EClass internationalizationLibraryEClass = null; + + /** + * + * + * @generated + */ + private EClass internationalizationEntryEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage#eNS_URI + * @see #init() + * @generated + */ + private InternationalizationPackageImpl() { + super(eNS_URI, InternationalizationFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link InternationalizationPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static InternationalizationPackage init() { + if (isInited) { + return (InternationalizationPackage) EPackage.Registry.INSTANCE + .getEPackage(InternationalizationPackage.eNS_URI); + } + + // Obtain or create and register package + InternationalizationPackageImpl theInternationalizationPackage = (InternationalizationPackageImpl) (EPackage.Registry.INSTANCE + .get(eNS_URI) instanceof InternationalizationPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) + : new InternationalizationPackageImpl()); + + isInited = true; + + // Create package meta-data objects + theInternationalizationPackage.createPackageContents(); + + // Initialize created meta-data + theInternationalizationPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theInternationalizationPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(InternationalizationPackage.eNS_URI, theInternationalizationPackage); + return theInternationalizationPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getInternationalizationLibrary() { + return internationalizationLibraryEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getInternationalizationLibrary_Entries() { + return (EReference) internationalizationLibraryEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EClass getInternationalizationEntry() { + return internationalizationEntryEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getInternationalizationEntry_Key() { + return (EAttribute) internationalizationEntryEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getInternationalizationEntry_Value() { + return (EAttribute) internationalizationEntryEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public InternationalizationFactory getInternationalizationFactory() { + return (InternationalizationFactory) getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) { + return; + } + isCreated = true; + + // Create classes and their features + internationalizationLibraryEClass = createEClass(INTERNATIONALIZATION_LIBRARY); + createEReference(internationalizationLibraryEClass, INTERNATIONALIZATION_LIBRARY__ENTRIES); + + internationalizationEntryEClass = createEClass(INTERNATIONALIZATION_ENTRY); + createEAttribute(internationalizationEntryEClass, INTERNATIONALIZATION_ENTRY__KEY); + createEAttribute(internationalizationEntryEClass, INTERNATIONALIZATION_ENTRY__VALUE); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) { + return; + } + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(internationalizationLibraryEClass, InternationalizationLibrary.class, "InternationalizationLibrary", //$NON-NLS-1$ + !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getInternationalizationLibrary_Entries(), this.getInternationalizationEntry(), null, "entries", //$NON-NLS-1$ + null, 0, -1, InternationalizationLibrary.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, + !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(internationalizationEntryEClass, InternationalizationEntry.class, "InternationalizationEntry", //$NON-NLS-1$ + !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getInternationalizationEntry_Key(), ecorePackage.getEJavaObject(), "key", null, 1, 1, //$NON-NLS-1$ + InternationalizationEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getInternationalizationEntry_Value(), ecorePackage.getEString(), "value", null, 1, 1, //$NON-NLS-1$ + InternationalizationEntry.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //InternationalizationPackageImpl diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationAdapterFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationAdapterFactory.java new file mode 100644 index 00000000000..9bb7a09f475 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationAdapterFactory.java @@ -0,0 +1,147 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.papyrus.infra.internationalization.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage + * @generated + */ +public class InternationalizationAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static InternationalizationPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public InternationalizationAdapterFactory() { + if (modelPackage == null) { + modelPackage = InternationalizationPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject) object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected InternationalizationSwitch modelSwitch = new InternationalizationSwitch() { + @Override + public Adapter caseInternationalizationLibrary(InternationalizationLibrary object) { + return createInternationalizationLibraryAdapter(); + } + + @Override + public Adapter caseInternationalizationEntry(InternationalizationEntry object) { + return createInternationalizationEntryAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject) target); + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary Library}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary + * @generated + */ + public Adapter createInternationalizationLibraryAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.infra.internationalization.InternationalizationEntry Entry}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationEntry + * @generated + */ + public Adapter createInternationalizationEntryAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //InternationalizationAdapterFactory diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationSwitch.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationSwitch.java new file mode 100644 index 00000000000..8b059e257c4 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src-gen/org/eclipse/papyrus/infra/internationalization/util/InternationalizationSwitch.java @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + */ +package org.eclipse.papyrus.infra.internationalization.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import org.eclipse.papyrus.infra.internationalization.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see org.eclipse.papyrus.infra.internationalization.InternationalizationPackage + * @generated + */ +public class InternationalizationSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static InternationalizationPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public InternationalizationSwitch() { + if (modelPackage == null) { + modelPackage = InternationalizationPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case InternationalizationPackage.INTERNATIONALIZATION_LIBRARY: { + InternationalizationLibrary internationalizationLibrary = (InternationalizationLibrary) theEObject; + T result = caseInternationalizationLibrary(internationalizationLibrary); + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + case InternationalizationPackage.INTERNATIONALIZATION_ENTRY: { + InternationalizationEntry internationalizationEntry = (InternationalizationEntry) theEObject; + T result = caseInternationalizationEntry(internationalizationEntry); + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Library'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Library'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseInternationalizationLibrary(InternationalizationLibrary object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Entry'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Entry'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseInternationalizationEntry(InternationalizationEntry object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //InternationalizationSwitch diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/Activator.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/Activator.java new file mode 100644 index 00000000000..05322b0895b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/Activator.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle. + */ +public class Activator extends AbstractUIPlugin { + + /** + * The plug-in ID. + */ + public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.internationalization"; //$NON-NLS-1$ + + /** + * The shared instance. + */ + private static Activator plugin; + + /** + * The log helper. + */ + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/InternationalizationPreferenceCommandFactory.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/InternationalizationPreferenceCommandFactory.java new file mode 100644 index 00000000000..5e7dd422b96 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/InternationalizationPreferenceCommandFactory.java @@ -0,0 +1,211 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.commands; + +import java.util.Collection; + +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationAnnotationResourceUtils; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationPreferenceModel; +import org.eclipse.papyrus.infra.internationalization.utils.InternationalizationPreferenceModelUtils; + +/** + * The internationalization preference command factory that allows to manage the + * legacy of the storage. + */ +public class InternationalizationPreferenceCommandFactory { + + /** + * The model set. + */ + private final ModelSet modelSet; + + /** + * Constructor. + * + * @param modelSet + * The model set. + */ + public InternationalizationPreferenceCommandFactory(final ModelSet modelSet) { + super(); + + this.modelSet = modelSet; + } + + /** + * Creates a command that toggles whether the sash model is stored in the + * private workspace metadata area or in the shared {@code *.di} file. + * + * @return a toggle command for the private layout storage + */ + public Command createTogglePrivateStorageCommand() { + Command result = UnexecutableCommand.INSTANCE; + + final InternationalizationPreferenceModel internationalizationPrefModel = InternationalizationPreferenceModelUtils + .getInternationalizationPreferenceModel(modelSet); + if (null != internationalizationPrefModel) { + result = new AbstractToggleCommand("Toggle Private Editor Layout") { //$NON-NLS-1$ + + @Override + public void execute() { + + final EAnnotation annotationToMove = InternationalizationAnnotationResourceUtils + .getInternationalizationAnnotation(internationalizationPrefModel.getResource()); + + // We don't record changes in the internationalization + // preference model for undo/redo, + // so we cannot assume that any changes to the current page + // selections are undoable in the usual way + if (!internationalizationPrefModel.isLegacyMode()) { + final Resource internationalizationPrefResource = annotationToMove.eResource(); + final URI sharedURI = internationalizationPrefModel.getPrivateResourceURI(); + + // Move the contents into the notation model. If the + // notation resource isn't loaded, give up because + // something is seriously wrong in that case + final Resource notationResource = modelSet.getResource(sharedURI, false); + if (null != notationResource && notationResource.isLoaded()) { + moveContents(internationalizationPrefResource, notationResource, annotationToMove); + + if (internationalizationPrefResource.getContents().isEmpty()) { + // Schedule deletion on save + modelSet.getResourcesToDeleteOnSave().add(internationalizationPrefResource.getURI()); + } + } + } else { + Resource internationalizationPrefResource; + final URI privateURI = internationalizationPrefModel.getSharedResourceURI(); + + // Move the contents into the internationalization + // preference model. If the internationalization + // preference resource isn't loaded or doesn't exist, it + // will have to be handled + if (modelSet.getURIConverter().exists(privateURI, null)) { + internationalizationPrefResource = modelSet.getResource(privateURI, true); + } else { + internationalizationPrefResource = modelSet.createResource(privateURI); + } + + // In case we had marked it for deletion, earlier + modelSet.getResourcesToDeleteOnSave().remove(privateURI); + + final Resource notationResource = annotationToMove.eResource(); + moveContents(notationResource, internationalizationPrefResource, annotationToMove); + } + + // Re-load from the new resource. Snippets might find this + // odd, but it would be even more odd for there to be any + // snippets on this model + internationalizationPrefModel.loadModel(modelSet.getURIWithoutExtension()); + } + }; + } + + return result; + } + + /** + * Move the annotation from the first resource into the second one. + * + * @param fromResource + * The resource containing the annotation to move into the second + * resource. + * @param toResource + * The resource where move the annotation. + * @param annotation + * The annotation to move from first resource into the second + * one. + */ + protected void moveContents(final Resource fromResource, final Resource toResource, final EAnnotation annotation) { + EObject toReplace = null; + + final Collection existingAnnotations = EcoreUtil.getObjectsByType(toResource.getContents(), + annotation.eClass()); + if (null != existingAnnotations && existingAnnotations.isEmpty()) { + for (final EObject existingAnnotation : existingAnnotations) { + if (existingAnnotation instanceof EAnnotation && ((EAnnotation) existingAnnotation).getSource() + .equals(InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL)) { + toReplace = existingAnnotation; + } + } + } + + if (null != toReplace) { + EcoreUtil.replace(toReplace, annotation); + } else { + toResource.getContents().add(annotation); + } + } + + /** + * The command for the toggle action. We don't need recording command here + * because this is managed by properties API that will be wrapped as + * recording command. + */ + private static abstract class AbstractToggleCommand extends AbstractCommand { + + /** + * Constructor. + * + * @param label + * The label of the command. + */ + public AbstractToggleCommand(final String label) { + super(label); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + */ + @Override + protected boolean prepare() { + // Nothing to prepare + return true; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#undo() + */ + @Override + public void undo() { + // The command modified a boolean value so the undo will do the + // contrary of the previous command + execute(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#redo() + */ + @Override + public void redo() { + execute(); + } + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameCommand.java new file mode 100644 index 00000000000..246f8de4201 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameCommand.java @@ -0,0 +1,108 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.commands; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.EMFEditPlugin; +import org.eclipse.emf.edit.command.AbstractOverrideableCommand; +import org.eclipse.emf.edit.domain.EditingDomain; + +/** + * This allows to define a command to reset the feature value needed. + */ +public class ResetNameCommand extends AbstractOverrideableCommand { + + /** + * The owner to modify. + */ + private EObject owner; + + /** + * The feature tu reset. + */ + private EStructuralFeature feature; + + /** + * This caches the label. + */ + protected static final String LABEL = EMFEditPlugin.INSTANCE.getString("_UI_SetCommand_label"); + + /** + * This caches the description. + */ + protected static final String DESCRIPTION = EMFEditPlugin.INSTANCE.getString("_UI_SetCommand_description"); + + /** + * Constructor. + * + * @param domain + * The current editing domain. + * @param owner + * The owner to modify. + * @param feature + * The feature to reset. + */ + public ResetNameCommand(final EditingDomain domain, final EObject owner, final EStructuralFeature feature) { + super(domain, LABEL, DESCRIPTION); + + this.owner = owner; + this.feature = feature; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + */ + @Override + protected boolean prepare() { + return null != this.owner.eClass().getEStructuralFeature(feature.getFeatureID()) + && null != this.owner.eGet(this.feature); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.edit.command.AbstractOverrideableCommand#doExecute() + */ + @Override + public void doExecute() { + final Object oldValue = this.owner.eGet(this.feature); + this.owner.eSet(feature, null); + this.owner.eSet(feature, oldValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.edit.command.AbstractOverrideableCommand#doUndo() + */ + @Override + public void doUndo() { + final Object oldValue = this.owner.eGet(this.feature); + this.owner.eSet(feature, null); + this.owner.eSet(feature, oldValue); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.edit.command.AbstractOverrideableCommand#doRedo() + */ + @Override + public void doRedo() { + doExecute(); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameTransactionalCommand.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameTransactionalCommand.java new file mode 100644 index 00000000000..c473974144e --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/commands/ResetNameTransactionalCommand.java @@ -0,0 +1,89 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.commands; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.EMFEditPlugin; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; + +/** + * This allows to define a command to reset the feature value needed. + */ +public class ResetNameTransactionalCommand extends AbstractTransactionalCommand { + + /** + * The owner to modify. + */ + private EObject owner; + + /** + * The feature tu reset. + */ + private EStructuralFeature feature; + + /** + * This caches the label. + */ + protected static final String LABEL = EMFEditPlugin.INSTANCE.getString("_UI_SetCommand_label"); + + /** + * Constructor. + * + * @param domain + * The current editing domain. + * @param owner + * The owner to modify. + * @param feature + * The feature to reset. + */ + public ResetNameTransactionalCommand(final TransactionalEditingDomain domain, final EObject owner, + final EStructuralFeature feature) { + super(domain, LABEL, null); + + this.owner = owner; + this.feature = feature; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute() + */ + @Override + public boolean canExecute() { + return null != this.owner.eClass().getEStructuralFeature(feature.getFeatureID()) + && null != this.owner.eGet(this.feature); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, + * org.eclipse.core.runtime.IAdaptable) + */ + @Override + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) + throws ExecutionException { + final Object oldValue = this.owner.eGet(this.feature); + this.owner.eSet(feature, null); + this.owner.eSet(feature, oldValue); + return CommandResult.newOKCommandResult(this.owner); + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/AbstractInternationalizationPreferenceModelProvider.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/AbstractInternationalizationPreferenceModelProvider.java new file mode 100644 index 00000000000..f733e324b07 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/AbstractInternationalizationPreferenceModelProvider.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelresource; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.sasheditor.ISashModelProvider; + +/** + * A partial implementation of the {@link ISashModelProvider} protocol. + */ +public abstract class AbstractInternationalizationPreferenceModelProvider + implements IInternationalizationPreferenceModelProvider { + + /** + * The model set managed. + */ + private ModelSet modelSet; + + /** + * Constructor. + */ + public AbstractInternationalizationPreferenceModelProvider() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.internationalization.modelresource.IInternationalizationPreferenceModelProvider#initialize(org.eclipse.papyrus.infra.core.resource.ModelSet) + */ + @Override + public void initialize(final ModelSet modelSet) { + this.modelSet = modelSet; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.internationalization.modelresource.IInternationalizationPreferenceModelProvider#dispose() + */ + @Override + public void dispose() { + modelSet = null; + } + + /** + * Get the model set. + * + * @return The model set. + */ + protected ModelSet getModelSet() { + return modelSet; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.internationalization.modelresource.IInternationalizationPreferenceModelProvider#loadInternationalizationPreferenceModel(org.eclipse.emf.common.util.URI) + */ + @Override + public Resource loadInternationalizationPreferenceModel(final URI internationalizationPrefModelURI) { + return modelSet.getResource(internationalizationPrefModelURI, true); + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/IInternationalizationPreferenceModelProvider.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/IInternationalizationPreferenceModelProvider.java new file mode 100644 index 00000000000..7d70008b620 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/IInternationalizationPreferenceModelProvider.java @@ -0,0 +1,56 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelresource; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.infra.core.resource.ModelSet; + +/** + * This is the IInternationalizationPreferenceModelProvider type. + */ +public interface IInternationalizationPreferenceModelProvider { + + /** + * Get the internationalization preference model URI from the user model + * URI. + * + * @param userModelURI + * The initial user model URI. + * @return The internationalization preference model URI. + */ + public URI getInternationalizationPreferenceModelURI(final URI userModelURI); + + /** + * This allows to initialize the model provider. + * + * @param modelSet + * The current model set. + */ + public void initialize(final ModelSet modelSet); + + /** + * This allows to load the internationalization preference model. + * + * @param internationalizationPrefModelURI + * The internationalization preference model URI. + * @return The loaded resource. + */ + public Resource loadInternationalizationPreferenceModel(final URI internationalizationPrefModelURI); + + /** + * This allows to manage the dispose of the model provider. + */ + public void dispose(); +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java new file mode 100644 index 00000000000..1158f1e67f0 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java @@ -0,0 +1,1494 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelresource; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.command.RemoveCommand; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.internationalization.Activator; +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationFactory; +import org.eclipse.papyrus.infra.internationalization.InternationalizationLibrary; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; +import org.eclipse.papyrus.infra.internationalization.commands.ResetNameCommand; +import org.eclipse.papyrus.infra.internationalization.commands.ResetNameTransactionalCommand; +import org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.common.utils.LocaleNameResolver; +import org.eclipse.papyrus.infra.internationalization.utils.EntryPartLabelSynchronizer; +import org.eclipse.papyrus.infra.internationalization.utils.PreferencePartLabelSynchronizer; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; +import org.eclipse.papyrus.infra.internationalization.utils.QualifiedNameUtils; +import org.eclipse.papyrus.infra.internationalization.utils.ResourceBundleAndURI; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationPackage; + +/** + * This allows to manage the internationalization resource. + */ +public class InternationalizationModelResource extends AbstractModelWithSharedResource + implements IModel { + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.internationalization.resource.InternationalizationModel"; //$NON-NLS-1$ + + /** + * The '_labelDiagram_' prefix of each diagram entry. + */ + protected static final String LABEL_DIAGRAM_PREFIX_QN = "_labelDiagram_"; //$NON-NLS-1$ + + /** + * The '_labelTable_' prefix of each table entry. + */ + protected static final String LABEL_TABLE_PREFIX_QN = "_labelTable_"; //$NON-NLS-1$ + + /** + * The '_label_' prefix of each entry. + */ + public static final String LABEL_PREFIX = "_label_"; //$NON-NLS-1$ + + /** + * The notation extension file (cannot use the + * NotationModel.NOTATION_FILE_EXTENSION because of dependencies cycle). + */ + protected static final String NOTATION_FILE_EXTENSION = "notation"; //$NON-NLS-1$ + + /** + * The map of the loaded resource by the initial URI and by locale. + */ + protected Map> propertiesByLocale = null; + + /** + * Set to keep deleted objects. Those ones must be ignored at the + * {{@link #saveModel()} to avoid exceptions. + * + * The delete of objects does not remove the entries corresponding because + * at the undo, the internationalization values must be not retrieve. + */ + protected Set deletedObjects = null; + + /** + * The adapter for the object (to avoid multiple creation for the same + * object). + */ + protected Map adapters = null; + + /** + * This map allows to keep the editor part for an EObject when it is needed + * to create the InternationalizationEntry and finally the + * PartLabelSynchronizer. + */ + protected Map editorPartByEObject = null; + + /** + * Save of the created PartLabelSynchronizer to manage the dispose of those + * ones. + */ + protected Map> entriesLabelSynchronizerByEObject = null; + + /** + * Save the preference part label synchronizer corresponding to the object + * of editor part. + */ + protected Map preferencePartLabelSynchronizers = null; + + /** + * Constructor. + */ + public InternationalizationModelResource() { + super(); + propertiesByLocale = new HashMap>(); + + Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { + + @Override + public void propertyChange(final PropertyChangeEvent event) { + if (event.getProperty().equals(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE)) { + Iterator resourcesIterator = new HashSet(getResources()).iterator(); + while (resourcesIterator.hasNext()) { + final Resource resource = resourcesIterator.next(); + loadModel(getInitialURIForResource(resource).trimFileExtension()); + } + } + } + + }); + deletedObjects = new HashSet(); + adapters = new HashMap(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#loadModel(org.eclipse.emf.common.util.URI) + */ + @Override + public void loadModel(final URI uriWithoutExtension) { + loadModel(uriWithoutExtension, true); + } + + /** + * Attach the model to its resource if this is not already done. + * + * @param uriWithoutExtension + * The uri of the resource to manage. + * @param needToLoadOtherProperties + * Boolean to determinate if the other properties in the project + * have to bo loaded or not. + */ + public void loadModel(final URI uriWithoutExtension, final boolean needToLoadOtherProperties) { + // Compute model URI + final URI uri = uriWithoutExtension.appendFileExtension(getModelFileExtension()); + + if (needToBeLoaded(uri)) { + + resourceURI = uri; + + final Locale locale = InternationalizationPreferencesUtils.getLocalePreference(uriWithoutExtension); + + try { + + resource = loadResource(uri, locale); + + // We need to do even if the resource is null + if (needToLoadOtherProperties) { + resourceURI = uri; + + String existingResourceLoadedName = ""; + if (null != resource) { + existingResourceLoadedName = resource.getURI().lastSegment(); + } + + // We need to load other properties files in the same + // folders + loadOthersPropertiesFiles(uri, existingResourceLoadedName); + } + + } catch (final Exception ex) { + Activator.log.error(ex); + } + } + } + + /** + * This allows to define if the uri file was already loaded. + * + * @param uri + * The uri of the file to load. + * @return true if the file was already loaded. + * false otherwise. + */ + protected boolean needToBeLoaded(final URI uri) { + return !propertiesByLocale.containsKey(uri); + } + + /** + * This allows to add the resource in parameter in the model resources. + * + * @param uri + * The uri of the resource. + * @param resource + * The resource to add. + * @param locale + * The locale to use. + */ + public void addResourceToModel(final URI uri, final Resource resource, final Locale locale) { + resourceURI = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + configureResource(resource, locale); + } + + /** + * This allows to load others properties files in the project. + * + * @param uri + * The {@link URI}. + * @param loadedResourceFile + * The properties file already loaded. + */ + protected void loadOthersPropertiesFiles(final URI uri, final String loadedResourceFile) { + final URI uriWithoutExtension = uri.trimFileExtension(); + final String modelName = uriWithoutExtension.segment(uriWithoutExtension.segmentCount() - 1); + final URI folderURI = uriWithoutExtension.trimSegments(1); + + // Calculate the project folder + IProject projectFolder = null; + if (folderURI.isPlatformResource()) { + final String uriPlatformString = folderURI.toPlatformString(true); + projectFolder = ResourcesPlugin.getWorkspace().getRoot().getProject(uriPlatformString.substring(1)); + } + + if (null != projectFolder) { + final String extension = "." + getModelFileExtension(); //$NON-NLS-1$ + try { + // Loop on project resources to check about other properties + // file + for (final IResource resourceEntry : projectFolder.members()) { + // Check if the file starts with the name of the model and + // finish with properties + if (resourceEntry.getName().startsWith(modelName) && resourceEntry.getName().endsWith(extension)) { // $NON-NLS-1$ + + // Remove the extension of the file + final String fileNAmeWithoutExtension = resourceEntry.getName().substring(0, + resourceEntry.getName().length() - extension.length()); + // Remove the model name + String possibleLocale = fileNAmeWithoutExtension.substring(modelName.length()); + + // Check this is not the current loaded file of locale + if (!resourceEntry.getName().equals(loadedResourceFile) || possibleLocale.isEmpty()) { + + // This is modelName.properties + if (possibleLocale.isEmpty() && null == getResourceForURIAndLocale(uri, new Locale(""))) { //$NON-NLS-1$ + final URI newURI = folderURI.appendSegment(fileNAmeWithoutExtension) + .appendFileExtension(getModelFileExtension()); + loadResource(newURI, new Locale("")); //$NON-NLS-1$ + // This can be a possible properties locale file + } else if (possibleLocale.startsWith(LocaleNameResolver.UNDERSCORE)) { // $NON-NLS-1$ + possibleLocale = possibleLocale.substring(1); + Locale localeFound = null; + + // Check about possible locale in available + // locales + final Iterator availableLocales = Arrays.asList(Locale.getAvailableLocales()) + .iterator(); + while (availableLocales.hasNext() && null == localeFound) { + final Locale currentAvailableLocale = availableLocales.next(); + + if (currentAvailableLocale.toString().equals(possibleLocale)) { + localeFound = currentAvailableLocale; + } + } + + // The file contains a locale, load it + if (null != localeFound) { + loadResource(uri, localeFound); + } + } + + } + } + } + } catch (final CoreException e) { + Activator.log.error(e); + } + } + } + + /** + * This method allows to load the resource (or create it if necessary) and + * load the internationalization content. + * + * @param uri + * The {@link URI}. + * @param locale + * The current locale to use. + * @return The resource loaded. + */ + protected Resource loadResource(final URI uri, final Locale locale) { + Resource resource = null; + + final ResourceBundleAndURI resourceBundleAndURI = PropertiesFilesUtils.getResourceBundle(uri, locale); + if (null != resourceBundleAndURI) { + + // Look for the resource + resource = getResourceSet().getResource(resourceBundleAndURI.getUri(), false); + + // Check if model is loaded. + if (null != resource) { + configureResource(resource, locale); + } else { + // model is not loaded, do it. + // Create Resource of appropriate type + resource = modelSet.createResource(resourceBundleAndURI.getUri()); + + configureResource(resource, locale); + + // call registered snippets + startSnippets(); + } + + loadInternationalizationContent(uri, locale); + } + + return resource; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#createModel(org.eclipse.emf.common.util.URI) + */ + @Override + public void createModel(final URI uriWithoutExtension) { + super.createModel(uriWithoutExtension); + + final URI uri = uriWithoutExtension.appendFileExtension(getModelFileExtension()); + final Locale locale = InternationalizationPreferencesUtils.getLocalePreference(this.resource.getURI()); + final Resource resource = this.resource; + + // Fill the properties by locale map + if (null == propertiesByLocale.get(resourceURI)) { + propertiesByLocale.put(resourceURI, new HashMap()); + } + propertiesByLocale.get(resourceURI).put(locale, resource); + + // Calculate the internationalization content + loadInternationalizationContent(uri, locale); + + resource.setModified(true); + + try { + saveResource(resource); + } catch (final IOException e) { + Activator.log.error(e); + } + } + + /** + * This allows to configure the resource. + * + * @param resourceToConfigure + * The resource to configure. + * @param locale + * The locale to manage. + */ + protected void configureResource(final Resource resourceToConfigure, final Locale locale) { + super.configureResource(resourceToConfigure); + // Add the resource to the resource properties classified by their + // locale + if (null == propertiesByLocale.get(resourceURI)) { + propertiesByLocale.put(resourceURI, new HashMap()); + } + propertiesByLocale.get(resourceURI).put(locale, resourceToConfigure); + } + + /** + * This allows to load internationalization content of properties file into + * the current resource. + * + * @param uri + * The URI of the properties file with the extension. + * @param locale + * The locale to use. + */ + protected void loadInternationalizationContent(final URI uri, final Locale locale) { + final Resource resource = getResourceForURIAndLocale(uri, locale); + + if (null != resource && resource.getContents().isEmpty()) { + final ResourceBundleAndURI resourceBundleAndURI = PropertiesFilesUtils + .getResourceBundle(uri.trimFileExtension().appendFileExtension(getModelFileExtension()), locale); + if (null != resourceBundleAndURI && null != resourceBundleAndURI.getResourceBundle()) { + // Create the internationalization library to set to the + // resource contents + final InternationalizationLibrary library = InternationalizationFactory.eINSTANCE + .createInternationalizationLibrary(); + final Enumeration keys = resourceBundleAndURI.getResourceBundle().getKeys(); + + // Loop on existing keys + while (keys.hasMoreElements()) { + // Create an entry for each key + final InternationalizationEntry entry = InternationalizationFactory.eINSTANCE + .createInternationalizationEntry(); + String key = (String) keys.nextElement(); + if (key.startsWith(LABEL_DIAGRAM_PREFIX_QN)) { + final String keyWithoutPrefix = key.substring(LABEL_DIAGRAM_PREFIX_QN.length()); + final String qualifiedName = keyWithoutPrefix.substring(0, + keyWithoutPrefix.indexOf(LABEL_PREFIX)); + final String diagramName = keyWithoutPrefix + .substring(keyWithoutPrefix.indexOf(LABEL_PREFIX) + LABEL_PREFIX.length()); + + final Resource notationResource = modelSet.getResource( + uri.trimFileExtension().appendFileExtension(NOTATION_FILE_EXTENSION), true); + + if (null != notationResource && null != notationResource.getContents() + && !notationResource.getContents().isEmpty()) { + final Diagram foundDiagram = QualifiedNameUtils.getDiagram(notationResource, diagramName, + qualifiedName); + entry.setKey(foundDiagram); + addModifiedAdapter(foundDiagram, resource); + } + + } else if (key.startsWith(LABEL_TABLE_PREFIX_QN)) { + final String keyWithoutPrefix = key.substring(LABEL_TABLE_PREFIX_QN.length()); + final String qualifiedName = keyWithoutPrefix.substring(0, + keyWithoutPrefix.indexOf(LABEL_PREFIX)); + final String tableName = keyWithoutPrefix + .substring(keyWithoutPrefix.indexOf(LABEL_PREFIX) + LABEL_PREFIX.length()); + + final Resource umlResource = modelSet.getResource( + uri.trimFileExtension().appendFileExtension(NOTATION_FILE_EXTENSION), true); + + if (null != umlResource && null != umlResource.getContents() + && !umlResource.getContents().isEmpty()) { + final Table foundTable = QualifiedNameUtils.getTable(umlResource, tableName, qualifiedName); + entry.setKey(foundTable); + addModifiedAdapter(foundTable, resource); + } + } else { + entry.setKey(key); + } + entry.setValue(resourceBundleAndURI.getResourceBundle().getString(key)); + // Add the entry to the library + library.getEntries().add(entry); + } + + final GMFtoEMFCommandWrapper command = new GMFtoEMFCommandWrapper(new AddToResourceCommand( + ((ModelSet) resource.getResourceSet()).getTransactionalEditingDomain(), resource, library)); + command.execute(); + } + resource.setModified(false); + } + } + + /** + * This allows to create the properties resource corresponding to the uri in + * parameter. + * + * @param uri + * The URI of the properties resource to create. + * @param locale + * The locale to manage. + * @return The created resource. + */ + protected Resource createResource(final URI uri, final Locale locale) { + // The properties uri (cast the file extension to the needed one) + URI propertiesURI = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + resourceURI = propertiesURI; + + // The created properties resource need to have the locale in last + // segment (example: test_en_EN.properties) + String lastSegment = propertiesURI.trimFileExtension().lastSegment(); + lastSegment = lastSegment + LocaleNameResolver.UNDERSCORE + locale.toString(); + propertiesURI = propertiesURI.trimSegments(1); + propertiesURI = propertiesURI.appendSegment(lastSegment); + propertiesURI = propertiesURI.appendFileExtension(getModelFileExtension()); + + // Create the resource needed + final Resource resultResource = modelSet.createResource(propertiesURI); + configureResource(resultResource, locale); + + // Create the internationalization library in the resource content + createInternationalizationContent(resultResource); + + // call registered snippets + startSnippets(); + + resource = resultResource; + + return resultResource; + } + + /** + * This allows to create the internationalization library for the resource + * content. + * + * @param resource + * The resource where add the internationalization library. + */ + protected void createInternationalizationContent(final Resource resource) { + if (null != resource) { + // Create the library + final InternationalizationLibrary library = InternationalizationFactory.eINSTANCE + .createInternationalizationLibrary(); + + // Create the resource content command and execute it + final GMFtoEMFCommandWrapper command = new GMFtoEMFCommandWrapper(new AddToResourceCommand( + ((ModelSet) resource.getResourceSet()).getTransactionalEditingDomain(), resource, library)); + command.execute(); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#saveModel() + */ + @Override + public void saveModel() throws IOException { + // Save into the properties files + + for (final Resource resource : getResources()) { + saveResource(resource); + } + } + + /** + * This allows to save the resource. + * + * @param resource + * The resource to save. + * @throws IOException + * The input output file exception. + */ + protected void saveResource(final Resource resource) throws IOException { + final ModelSet set = getModelManager(); + if (null != resource && set.shouldSave(resource) && !resource.getContents().isEmpty()) { + // It is needed to manage the save of properties by a simple output + // stream because the resource bundle cannot be modified + final Properties properties = new Properties(); + + final InternationalizationLibrary library = (InternationalizationLibrary) resource.getContents().get(0); + + // Add all the entries into properties (need this properties to save + // easier the properties file) + for (final InternationalizationEntry entry : library.getEntries()) { + if (!deletedObjects.contains(entry.getKey()) && !entry.getValue().isEmpty()) { + properties.setProperty(getKey(entry), entry.getValue()); + } + } + + final Locale locale = getLocaleForResource(resource); + + // Get the URI of properties file used (with locale or not) + final URI resourceURI = PropertiesFilesUtils.getResourceBundleURIFromResourceURI(resource.getURI(), locale); + + // This allows to save the properties into the properties file + final URIConverter uriConverter = new ExtensibleURIConverterImpl(); + properties.store(uriConverter.createOutputStream(resourceURI), null); + resource.setModified(false); + } + } + + /** + * This allows to add an adapter to the EOBject to modified the properties + * resource when the EObject has changed. + * + * @param eObject + * The EObject. + * @param resource + * The associated resource. + */ + protected void addModifiedAdapter(final EObject eObject, final Resource resource) { + if (!adapters.containsKey(eObject)) { + Adapter modifiedAdapter = new Adapter() { + + @Override + public void setTarget(final Notifier newTarget) { + // Do nothing + } + + @Override + public void notifyChanged(final Notification notification) { + // If this is a remove, add the old value to the deleted + // objects + if (Notification.REMOVE == notification.getEventType() + || Notification.REMOVE_MANY == notification.getEventType()) { + Object oldValue = notification.getOldValue(); + + if (oldValue instanceof EObject) { + deletedObjects.add((EObject) oldValue); + } + // If this is an add, remove the new value from the + // deleted objects if existing + } else if (Notification.ADD == notification.getEventType() + || Notification.ADD_MANY == notification.getEventType()) { + Object newValue = notification.getNewValue(); + + if (newValue instanceof EObject && deletedObjects.contains(newValue)) { + deletedObjects.remove((EObject) newValue); + } + } + + // The resource is modified (not directly but need to be + // saved) + if (null != eObject.eResource() + && null != getLocalesAndResourcesForURI(eObject.eResource().getURI())) { + for (final Resource res : getLocalesAndResourcesForURI(eObject.eResource().getURI()).values()) { + res.setModified(true); + } + } else { + resource.setModified(true); + } + } + + @Override + public boolean isAdapterForType(Object type) { + return false; + } + + @Override + public Notifier getTarget() { + return null; + } + }; + eObject.eAdapters().add(modifiedAdapter); + adapters.put(eObject, modifiedAdapter); + } + } + + /** + * This allows to get the entry key (can be override to get element string + * identifier instead of string key). + * + * @param entry + * The internationalization entry. + * @return The key as String. + */ + protected String getKey(final InternationalizationEntry entry) { + final StringBuilder result = new StringBuilder(); + if (entry.getKey() instanceof Diagram) { + result.append(LABEL_DIAGRAM_PREFIX_QN); + final Diagram diagram = (Diagram) entry.getKey(); + final EObject diagramContainer = diagram.getElement(); + result.append(QualifiedNameUtils.getQualifiedName(diagramContainer)); + result.append(LABEL_PREFIX); + result.append(diagram.getName()); + } else if (entry.getKey() instanceof Table) { + result.append(LABEL_TABLE_PREFIX_QN); + final Table table = (Table) entry.getKey(); + final EObject tableContainer = table.getOwner(); + result.append(QualifiedNameUtils.getQualifiedName(tableContainer)); + result.append(LABEL_PREFIX); + result.append(table.getName()); + } else { + result.append((String) entry.getKey()); + } + return result.toString(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#isModelRoot(org.eclipse.emf.ecore.EObject) + */ + @Override + protected boolean isModelRoot(final EObject object) { + return object instanceof InternationalizationLibrary; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + */ + @Override + public String getModelFileExtension() { + return PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION; + } + + /** + * Open this method. {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModel#getModelManager() + */ + @Override + public ModelSet getModelManager() { + return super.getModelManager(); + } + + /** + * Open this method. {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#isRelatedResource(org.eclipse.emf.ecore.resource.Resource) + */ + @Override + public boolean isRelatedResource(final Resource resource) { + return super.isRelatedResource(resource); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModel#getIdentifier() + */ + @Override + public String getIdentifier() { + return MODEL_ID; + } + + /** + * Get the value for the key in parameter. + * + * @param uri + * The uri of the resource where search the key. + * @param key + * The key to search. + * @param locale + * The locale of which to get value. + * @return The value of the key. + */ + public String getValueForEntryKey(final URI uri, final Object key, final Locale locale) { + InternationalizationEntry entry = getEntryForKey(uri, key, locale); + return null != entry ? entry.getValue() : null; + } + + /** + * Get the value for the key in parameter. + * + * @param uri + * The uri of the resource where search the key. + * @param key + * The key to search. + * @return The value of the key. + */ + public String getValueForEntryKey(final URI uri, final EObject key) { + InternationalizationEntry entry = getEntryForKey(uri, key, + InternationalizationPreferencesUtils.getLocalePreference(key)); + return null != entry ? entry.getValue() : null; + } + + /** + * Get the entry for the key in parameter. + * + * @param uri + * The uri of the resource where search the key. + * @param key + * The key to search. + * @param locale + * The locale of which to get value. + * @return The entry of the key. + */ + public InternationalizationEntry getEntryForKey(final URI uri, final Object key, final Locale locale) { + InternationalizationEntry result = null; + + Resource resource = getResourceForURIAndLocale(uri, locale); + + // If the resource for the locale is not found, search for a properties + // without locale + if (null == resource) { + resource = getResourceForURIAndLocale(uri, new Locale("")); //$NON-NLS-1$ + } + + if (null != resource) { + final InternationalizationLibrary library = getModelRoot(resource); + + if (null != library) { + final Iterator entries = library.getEntries().iterator(); + + // Iterate on entries to get the value of the key in parameter + while (entries.hasNext() && null == result) { + final InternationalizationEntry entry = entries.next(); + if (entry.getKey().equals(key)) { + result = entry; + } + } + } + } + + return result; + } + + /** + * This allows to get the command to set internationalization value. + * + * @param domain + * The current editing domain. + * @param uri + * The uri of the resource where search the key. + * @param key + * The key to search. + * @param value + * The new value. + * @param locale + * The locale for which to set the value. + * @return The command to set the internationalization value. + */ + public Command getSetValueCommand(final EditingDomain domain, final URI uri, final EObject key, final String value, + final Locale locale) { + Command resultCommand = null; + + // Get the resource where add/modify the entry corresponding to the key + final Resource resource = getResourceForURIAndLocale(uri, locale); + final InternationalizationLibrary library = getModelRoot(resource); + + if (null != library) { + final Iterator entries = library.getEntries().iterator(); + + // Search on existing entries if the key already exists. + // In this case, just modify the value + while (entries.hasNext() && null == resultCommand) { + final InternationalizationEntry entry = entries.next(); + if (entry.getKey().equals(key)) { + if (null == value || value.isEmpty()) { + // If the value is null or empty, remove the entry + resultCommand = new CompoundCommand("Remove entry"); //$NON-NLS-1$ + ((CompoundCommand) resultCommand).append(new RemoveCommand(domain, library, + InternationalizationPackage.eINSTANCE.getInternationalizationLibrary_Entries(), entry)); + if (entry.getKey() instanceof EObject) { + Command setNameValueCommand = getSetNameValueCommand(domain, (EObject) entry.getKey()); + if (null != setNameValueCommand) { + ((CompoundCommand) resultCommand).append(setNameValueCommand); + } + } + resource.setModified(true); + } else { + resultCommand = new CompoundCommand("Set entry value"); //$NON-NLS-1$ + ((CompoundCommand) resultCommand).append(new SetCommand(domain, entry, + InternationalizationPackage.eINSTANCE.getInternationalizationEntry_Value(), value)); + if (entry.getKey() instanceof EObject) { + Command setNameValueCommand = getSetNameValueCommand(domain, (EObject) entry.getKey()); + if (null != setNameValueCommand) { + ((CompoundCommand) resultCommand).append(setNameValueCommand); + } + } + resource.setModified(true); + } + } + } + } + + // If the key does not exist, create an entry + if (null == resultCommand) { + final InternationalizationEntry entry = InternationalizationFactory.eINSTANCE + .createInternationalizationEntry(); + entry.setKey(key); + entry.setValue(value); + + if (null == resource) { + // If the resource does not exist, create it and add entry to + // the library + resultCommand = new CompoundCommand("Create entry"); //$NON-NLS-1$ + ((CompoundCommand) resultCommand).append(new CreatePropertiesResourceCommand(uri, entry, + InternationalizationPreferencesUtils.getLocalePreference(key))); + Command setNameValueCommand = getSetNameValueCommand(domain, (EObject) entry.getKey()); + if (null != setNameValueCommand) { + ((CompoundCommand) resultCommand).append(setNameValueCommand); + } + } else { + resultCommand = new CompoundCommand("Create entry"); //$NON-NLS-1$ + ((CompoundCommand) resultCommand).append(new AddCommand(domain, library, + InternationalizationPackage.eINSTANCE.getInternationalizationLibrary_Entries(), entry)); + Command setNameValueCommand = getSetNameValueCommand(domain, (EObject) entry.getKey()); + if (null != setNameValueCommand) { + ((CompoundCommand) resultCommand).append(setNameValueCommand); + } + resource.setModified(true); + } + + // If the created entry is an entry corresponding to an object who's + // depending to Editor part, we need to create the + // PartLabelSynchronizer + if (null != editorPartByEObject && editorPartByEObject.containsKey(key)) { + if (null != resultCommand) { + final Command tmpCommand = resultCommand; + resultCommand = new CompoundCommand("Change label value"); //$NON-NLS-1$ + ((CompoundCommand) resultCommand).append(tmpCommand); + ((CompoundCommand) resultCommand).append(new AbstractCommand() { + + @Override + public void execute() { + addPartLabelSynchronizerForEntry(key, entry); + } + + @Override + protected boolean prepare() { + return true; + } + + @Override + public void undo() { + // Do nothing + } + + @Override + public void redo() { + // Do nothing + } + }); + } + } + } + + return resultCommand; + } + + /** + * This allows to add or update value of property with key in parameter. + * + * @param uri + * The uri of the resource where search the key. + * @param key + * The key to search. + * @param value + * The new value. + * @param locale + * The locale for which set the value. + */ + public void setValue(final URI uri, final EObject key, final String value, final Locale locale) { + + // Get the resource where add/modify the entry corresponding to the key + Resource resource = getResourceForURIAndLocale(uri, locale); + if (null == resource) { + // If the resource does not exist, create it + resource = createResource(uri, InternationalizationPreferencesUtils.getLocalePreference(key)); + } + + final InternationalizationLibrary library = getModelRoot(resource); + + final Iterator entries = library.getEntries().iterator(); + boolean hasFound = false; + + // Search on existing entries if the key already exists. + // In this case, just modify the value + while (entries.hasNext() && !hasFound) { + final InternationalizationEntry entry = entries.next(); + if (entry.getKey().equals(key)) { + if (null == value || value.isEmpty()) { + // If the value is null or empty, remove the entry + entries.remove(); + } else { + entry.setValue(value); + if (entry.getKey() instanceof EObject) { + setNameValue((EObject) entry.getKey()); + } + } + hasFound = true; + } + } + + // If the key does not exist, create an entry + if (!hasFound) { + final InternationalizationEntry entry = InternationalizationFactory.eINSTANCE + .createInternationalizationEntry(); + entry.setKey(key); + entry.setValue(value); + library.getEntries().add(entry); + setNameValue(entry); + + // If the created entry is an entry corresponding to an object who's + // depending to Editor part, we need to create the + // PartLabelSynchronizer + if (editorPartByEObject.containsKey(key)) { + addPartLabelSynchronizerForEntry(key, entry); + } + } + resource.setModified(true); + } + + /** + * This allows to modify the name of the entry object when the label value + * is modified to notify all the name listeners. When the label change, all + * the name listeners need to be called. + * + * @param domain + * The current editing domain. + * @param eObject + * The eObject of the label to modify. + * @return The command modifying the name value. + */ + protected Command getSetNameValueCommand(final EditingDomain domain, final EObject eObject) { + Command result = null; + + // Change name for diagram + if (domain instanceof TransactionalEditingDomain) { + if (eObject instanceof Diagram) { + result = new GMFtoEMFCommandWrapper(new ResetNameTransactionalCommand( + (TransactionalEditingDomain) domain, eObject, NotationPackage.eINSTANCE.getDiagram_Name())); + + // Change name for table + } else if (eObject instanceof Table) { + result = new GMFtoEMFCommandWrapper( + new ResetNameTransactionalCommand((TransactionalEditingDomain) domain, eObject, + NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name())); + } + } else { + if (eObject instanceof Diagram) { + result = new ResetNameCommand(domain, eObject, NotationPackage.eINSTANCE.getDiagram_Name()); + + // Change name for table + } else if (eObject instanceof Table) { + result = new ResetNameCommand(domain, eObject, + NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name()); + } + } + + return result; + } + + /** + * This allows to modify the name of the entry object when the label value + * is modified to notify all the name listeners. When the label change, all + * the name listeners need to be called. + * + * @param eObject + * The eObject of the label to modify. + */ + protected void setNameValue(final EObject eObject) { + + // Change name for diagram + if (eObject instanceof Diagram) { + final String oldName = ((Diagram) eObject).getName(); + ((Diagram) eObject).setName(""); //$NON-NLS-1$ + ((Diagram) eObject).setName(oldName); + + // Change name for table + } else if (eObject instanceof Table) { + final String oldName = ((Table) eObject).getName(); + ((Table) eObject).setName(""); //$NON-NLS-1$ + ((Table) eObject).setName(oldName); + } + } + + /** + * Get the root of this model. Lookup in the associated {@link Resource} for + * the root. + * + * @param resource + * The resource to search. + * @return The root of the model, or null if no root exist. + */ + public InternationalizationLibrary getModelRoot(final Resource resource) { + if (null != resource) { + for (final EObject object : resource.getContents()) { + + if (isModelRoot(object)) { + return (InternationalizationLibrary) object; + } + } + } + + // Not found + return null; + } + + /** + * This allows to determinate the properties locales files loaded for the + * uri. + * + * @param uri + * The [{@link URI} to search. + * @return The set of the locales. + */ + public Set getAvailablePropertiesLocales(final URI uri) { + final URI uriWithCorrectExtension = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + return propertiesByLocale.containsKey(uriWithCorrectExtension) + ? propertiesByLocale.get(uriWithCorrectExtension).keySet() + : new HashSet(0); + } + + /** + * Get the locales and resources corresponding to the uri. + * + * @param uri + * The uri to search. + * @return The collection of the resources corresponding to the uri or + * null. + */ + public Map getLocalesAndResourcesForURI(final URI uri) { + Map result = null; + + final URI propertiesURI = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + + if (propertiesByLocale.containsKey(propertiesURI)) { + result = propertiesByLocale.get(propertiesURI); + } + + return result; + } + + /** + * Get the resource corresponding to the URI and the locale. + * + * @param uri + * The initial URI. + * @param locale + * The locale to use. + * @return The resource corresponding. + */ + public Resource getResourceForURIAndLocale(final URI uri, final Locale locale) { + Resource resultResource = null; + + final URI propertiesURI = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + + if (propertiesByLocale.containsKey(propertiesURI)) { + final Map resourceByLocale = propertiesByLocale.get(propertiesURI); + if (resourceByLocale.containsKey(locale)) { + resultResource = resourceByLocale.get(locale); + } + } + + return resultResource; + } + + /** + * Get the resource corresponding to the URI and the locale. + * + * @param uri + * The initial URI. + * @param Resource + * The resource to search. + * @return The resource corresponding. + */ + public Locale getLocaleForResource(final Resource resource) { + Locale resultLocale = null; + + for (final URI uri : propertiesByLocale.keySet()) { + final Map resourceByLocale = propertiesByLocale.get(uri); + for (Entry entry : resourceByLocale.entrySet()) { + if (entry.getValue().equals(resource)) { + resultLocale = entry.getKey(); + } + } + } + + return resultLocale; + } + + /** + * Get the initial URI for the resource in parameter. + * + * @param resource + * The resource to search. + * @return The initial URI of the resource in parameter. + */ + protected URI getInitialURIForResource(final Resource resource) { + URI initialURI = null; + + for (final Iterator uriIterator = propertiesByLocale.keySet().iterator(); uriIterator.hasNext() + && null == initialURI;) { + final URI uri = uriIterator.next(); + if (propertiesByLocale.get(uri).values().contains(resource)) { + initialURI = uri; + } + } + + return initialURI; + } + + /** + * Returns true if the URI was already loaded, + * false otherwise. + * + * @param uri + * The URI to search. + * @return true if the URI was already loaded, + * false otherwise. + */ + public boolean isLoadedResourcesForURI(final URI uri) { + return propertiesByLocale.containsKey(uri.trimFileExtension().appendFileExtension(getModelFileExtension())); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#unload() + */ + @Override + public void unload() { + for (final Resource resource : getResources()) { + final URI initialUri = getInitialURIForResource(resource); + if (null != initialUri) { + unload(initialUri); + } + resource.unload(); + } + + // Remove adapters + for (final EObject eObject : adapters.keySet()) { + Adapter adapter = adapters.get(eObject); + eObject.eAdapters().remove(adapter); + adapter = null; + } + adapters.clear(); + + // Remove the editor parts + if (null != editorPartByEObject) { + editorPartByEObject.clear(); + editorPartByEObject = null; + } + + // Dispose and remove the part label synchronizer + if (null != entriesLabelSynchronizerByEObject) { + for (final Entry> entry : entriesLabelSynchronizerByEObject + .entrySet()) { + for (final EntryPartLabelSynchronizer partLabelSynchronizer : entry.getValue().values()) { + partLabelSynchronizer.dispose(); + } + } + entriesLabelSynchronizerByEObject.clear(); + entriesLabelSynchronizerByEObject = null; + } + + // Dispose and remove the preference part label synchronizer + if (null != preferencePartLabelSynchronizers) { + for (final PreferencePartLabelSynchronizer preferenceStynchronizer : preferencePartLabelSynchronizers + .values()) { + preferenceStynchronizer.dispose(); + } + preferencePartLabelSynchronizers.clear(); + preferencePartLabelSynchronizers = null; + } + + super.unload(); + } + + /** + * This allows to unload the resource of the URI in parameter. + * + * @param uri + * The URI of the resource. + */ + public void unload(final URI uri) { + PropertiesFilesUtils.removeResourceBundle(uri); + if (propertiesByLocale.containsKey(uri)) { + propertiesByLocale.remove(uri); + } + } + + /** + * This allows to unload the resource from the properties by locale. + * + * @param resource + * The resource to unload. + */ + public void unload(final Resource resource) { + PropertiesFilesUtils.removeResourceBundle(resource.getURI()); + final URI initialUri = getInitialURIForResource(resource); + + if (propertiesByLocale.containsKey(initialUri)) { + Iterator> entriesIterator = propertiesByLocale.get(initialUri).entrySet() + .iterator(); + while (entriesIterator.hasNext()) { + final Entry entry = entriesIterator.next(); + if (entry.getValue().equals(resource)) { + entriesIterator.remove(); + } + } + } + } + + /** + * This allows to create a properties resource by command. + */ + private class CreatePropertiesResourceCommand extends AbstractCommand { + + /** + * The URI of the resource to create. + */ + protected URI uri; + + /** + * The entry to add to the resource internationalization library if not + * null. + */ + protected InternationalizationEntry entryToAdd; + + /** + * The created resource result. + */ + protected Resource createdResource; + + /** + * The locale of the file to create. + */ + protected Locale locale; + + /** + * Constructor. + * + * @param uri + * The URI of the resource to create. + * @param entry + * The entry to add to the resource internationalization + * library if not null. + */ + public CreatePropertiesResourceCommand(final URI uri, final InternationalizationEntry entry, + final Locale locale) { + super("Create properties resource"); //$NON-NLS-1$ + this.uri = uri.trimFileExtension().appendFileExtension(getModelFileExtension()); + this.entryToAdd = entry; + this.locale = locale; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#prepare() + */ + @Override + protected boolean prepare() { + return uri.fileExtension().equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#execute() + */ + @Override + public void execute() { + createdResource = createResource(uri, locale); + + if (null != entryToAdd) { + final InternationalizationLibrary library = getModelRoot(createdResource); + library.getEntries().add(entryToAdd); + } + + if (modelSet.getResourcesToDeleteOnSave().contains(createdResource.getURI())) { + modelSet.getResourcesToDeleteOnSave().remove(createdResource.getURI()); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.AbstractCommand#undo() + */ + @Override + public void undo() { + unload(uri); + createdResource.unload(); + getResources().remove(createdResource); + modelSet.getResourcesToDeleteOnSave().add(createdResource.getURI()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.emf.common.command.Command#redo() + */ + @Override + public void redo() { + execute(); + } + } + + /** + * This must be called when an Editor Part that contains the label + * internationalization will be opened. This allows to add the object and + * the editor part corresponding to the object. + * + * @param eObject + * The object corresponding to a part which manage the label + * modification. + * @param editorPart + * The editor part corresponding to the object. + */ + public void addEditorPartForEObject(final EObject eObject, final IInternationalizationEditor editorPart) { + // Create the map if not existing + if (null == editorPartByEObject) { + editorPartByEObject = new HashMap(); + } + + // Add the eObject and editor part correspondance if not already + // existing + if (!editorPartByEObject.containsKey(eObject)) { + editorPartByEObject.put(eObject, editorPart); + } + + // Call the part label synchronizer for the entries corresponding to the + // object + final URI uri = eObject.eResource().getURI(); + for (final Locale locale : getAvailablePropertiesLocales(uri)) { + final InternationalizationEntry entry = getEntryForKey(uri, eObject, locale); + addPartLabelSynchronizerForEntry(eObject, entry); + } + + // Create the part label synchronizer for the preference store + // modification for the object + addPartLabelSynchronizerForPreferenceStore(eObject); + } + + /** + * This allows to add a {@link EntryPartLabelSynchronizer} for the + * {@link EObject} in parameter. + * + * @param eObject + * The object corresponding to a part which manage the label + * modification. + * @param entry + * The entry corresponding to the {@link EObject} which be called + * for the label modification. + */ + protected void addPartLabelSynchronizerForEntry(final EObject eObject, final InternationalizationEntry entry) { + // Create the map if not existing + if (null == entriesLabelSynchronizerByEObject) { + entriesLabelSynchronizerByEObject = new HashMap>(); + } + + // Get the map of entries and part label synchronizer for the + // corresponding object + Map entriesLabelSynchronizer = null; + if (entriesLabelSynchronizerByEObject.containsKey(eObject)) { + entriesLabelSynchronizer = entriesLabelSynchronizerByEObject.get(eObject); + } else { + entriesLabelSynchronizer = new HashMap(); + entriesLabelSynchronizerByEObject.put(eObject, entriesLabelSynchronizer); + } + + // If the entry if not already managed, create the part label + // synchronizer + if (!entriesLabelSynchronizer.containsKey(entry)) { + entriesLabelSynchronizer.put(entry, + new EntryPartLabelSynchronizer(entry, editorPartByEObject.get(eObject), this)); + } + } + + /** + * This allows to manage a part label synchronizer for the object label when + * the internationalization preference change. + * + * @param eObject + * The {@link EObject} corresponding to a part which manage the + * label modification. + */ + protected void addPartLabelSynchronizerForPreferenceStore(final EObject eObject) { + // Create the map if not existing + if (null == preferencePartLabelSynchronizers) { + preferencePartLabelSynchronizers = new HashMap(); + } + + // If the object is not already managed, create the part label + // synchronizer for the preference + if (!preferencePartLabelSynchronizers.containsKey(eObject)) { + final IPreferenceStore preferenceStore = InternationalizationPreferencesUtils.getPreferenceStore(eObject); + + if (null != preferenceStore) { + preferencePartLabelSynchronizers.put(eObject, new PreferencePartLabelSynchronizer(preferenceStore, + eObject, editorPartByEObject.get(eObject), this)); + } + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModel.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModel.java new file mode 100644 index 00000000000..14bc82c98f7 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModel.java @@ -0,0 +1,606 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelresource; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.IOException; +import java.util.Collections; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.xmi.XMIResource; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.papyrus.infra.core.resource.EMFLogicalModel; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.emf.commands.AddToResourceCommand; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.internationalization.Activator; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationAnnotationResourceUtils; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; + +/** + * The model for the internationalization preference. It must be managed as + * legacy (platform:/resource/model/model.notation) or not + * (file:/~workspace/.metadata/.plugins/org.eclipse.papyrus.infra.core/model/model.internationalization). + * The internationalization preference will be managed as EAnnotation. + */ +public class InternationalizationPreferenceModel extends EMFLogicalModel implements IModel { + + /** + * Model ID. + */ + public static final String MODEL_ID = "org.eclipse.papyrus.infra.internationalization.InternationalizationPreferenceModel"; //$NON-NLS-1$ + + /** + * The private resource URI property. + */ + public static final String PROPERTY_PRIVATE_RESOURCE_URI = "privateResourceURI"; //$NON-NLS-1$ + + /** + * The shared resource URI property. + */ + public static final String PROPERTY_SHARED_RESOURCE_URI = "sharedResourceURI"; //$NON-NLS-1$ + + /** + * The legacy mode property. + */ + public static final String PROPERTY_LEGACY_MODE = "legacyMode"; //$NON-NLS-1$ + + /** + * File extension for the internationalization preference model. + */ + public static final String INTERNATIONALIZATION_PREFERENCE_FILE_EXTENSION = "internationalization"; //$NON-NLS-1$ + + /** + * The notation extension file (cannot use the + * NotationModel.NOTATION_FILE_EXTENSION because of dependencies cycle). + */ + public static final String NOTATION_FILE_EXTENSION = "notation"; //$NON-NLS-1$ + + /** + * The provider manager of the internationalization preference. + */ + private InternationalizationPreferenceModelProviderManager providerManager; + + /** + * The property change support for the legacy mode. + */ + private final PropertyChangeSupport bean = new PropertyChangeSupport(this); + + /** + * The model storage adapter for the internationalization preference + */ + private Adapter internationalizationPreferenceModelStorageAdapter; + + /** + * Boolean to determinate if the resource is managed as legacy. + */ + private volatile Boolean legacyMode; + + /** + * Constructor. + */ + public InternationalizationPreferenceModel() { + super(); + + internationalizationPreferenceModelStorageAdapter = new AdapterImpl() { + @Override + public void notifyChanged(final Notification msg) { + if (getResources().contains(msg.getNotifier())) { + switch (msg.getFeatureID(Resource.class)) { + case Resource.RESOURCE__CONTENTS: + invalidateLegacyMode(); + break; + } + } + } + }; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModel#init(org.eclipse.papyrus.infra.core.resource.ModelSet) + */ + @Override + public void init(final ModelSet modelSet) { + super.init(modelSet); + + this.providerManager = new InternationalizationPreferenceModelProviderManager(modelSet); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#unload() + */ + @Override + public void unload() { + if (null != providerManager) { + providerManager.dispose(); + providerManager = null; + } + + getResources().forEach(res -> res.eAdapters().remove(internationalizationPreferenceModelStorageAdapter)); + + super.unload(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#isRelatedResource(org.eclipse.emf.ecore.resource.Resource) + */ + @Override + public boolean isRelatedResource(final Resource resource) { + boolean result = false; + + if (null != resource) { + // We only handle the main internationalization preference resource. + // Imported *.internationalization are not relevant + if (resource == getResource()) { + result = true; + } else { + // We can only calculate these related URIs if the ModelSet is + // initialized + result = resource.getURI().equals(getSharedResourceURI()) + || resource.getURI().equals(getPrivateResourceURI()); + } + } + + return result; + } + + /** + * Just open this method to public. + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModel#getModelManager() + */ + @Override + public ModelSet getModelManager() { + return super.getModelManager(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#configureResource(org.eclipse.emf.ecore.resource.Resource) + */ + @Override + protected void configureResource(final Resource resourceToConfigure) { + super.configureResource(resourceToConfigure); + + if (null != resourceToConfigure) { + resourceToConfigure.eAdapters().add(internationalizationPreferenceModelStorageAdapter); + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#loadModel(org.eclipse.emf.common.util.URI) + */ + @Override + public void loadModel(final URI uriWithoutExtension) { + final URI sashModelURI = getInternationalizationPreferenceModelURI(uriWithoutExtension); + this.resourceURI = sashModelURI; + + try { + super.loadModel(sashModelURI.trimFileExtension()); + loadInternationalizationPreference(sashModelURI); + } catch (final Exception ex) { + // Unload it and try again by creating it + final Resource resource = getModelManager().getResource(sashModelURI, false); + if (null != resource) { + resource.unload(); + resource.getResourceSet().getResources().remove(resource); + } + + // This will create the private internationalization preference + // model if that's what we need + createModel(uriWithoutExtension); + } + + if (null == resource) { + // This will create the private internationalization preference + // model if that's what we need + createModel(uriWithoutExtension); + } + } + + /** + * This allows to load the internationalization preference as annotation in + * the root content. + * + * @param uri + * The URI of the properties file with the extension. + */ + protected void loadInternationalizationPreference(final URI uri) { + if (null != resource && null != resource.getContents() && !resource.getContents().isEmpty()) { + + boolean useInternationalizationValue = false; + String languagePreference = null; + + // Get the internationalization annotation + final EAnnotation annotation = InternationalizationAnnotationResourceUtils + .getInternationalizationAnnotation(resource); + + // Get the details values + if (null != annotation) { + // Get the 'use' details value + final String useInternationalizationStringValue = annotation.getDetails() + .get(InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL); + useInternationalizationValue = Boolean.parseBoolean(useInternationalizationStringValue); + + // Get the 'language' details value + final String languageValue = annotation.getDetails() + .get(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE); + + languagePreference = languageValue; + } + + // Set values into the preference store corresponding to the + // papyrus model + URI sharedResource = getPrivateResourceURI(); + InternationalizationPreferencesUtils.setInternationalizationPreference(sharedResource, + useInternationalizationValue); + if (null != languagePreference) { + InternationalizationPreferencesUtils.setLanguagePreference(sharedResource, + languagePreference.toString()); + } + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#createModel(org.eclipse.emf.common.util.URI) + */ + @Override + public void createModel(final URI uriWithoutExtension) { + if (isLegacy(uriWithoutExtension)) { + final URI internationalizationPrefURI = getInternationalizationPreferenceModelStoreURI(uriWithoutExtension); + try { + super.createModel(internationalizationPrefURI.trimFileExtension()); + intantiateTemplate(internationalizationPrefURI); + loadInternationalizationPreference(uriWithoutExtension); + } catch (final IOException e) { + Activator.log.error("Failed to initialize workspace private internationalization model", e); //$NON-NLS-1$ + super.createModel(internationalizationPrefURI.trimFileExtension()); + } + } else { + super.createModel(uriWithoutExtension); + } + } + + /** + * Intantiates the internationalization preference resource template on the + * given URI. + * + * @param internationalizationPrefResourceURI + * The new internationalization preference resource URI. + * @throws IOException + * on failure to copy the template to this URI for any reason + */ + protected void intantiateTemplate(final URI internationalizationPrefResourceURI) throws IOException { + + // Create the internationalization annotation with + // - Use internationalization preference to true + // - Language preference to default language + final EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation(); + annotation.setSource(InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL); + annotation.getDetails().put(InternationalizationPreferencesConstants.USE_DETAIL_ANNOTATION_LABEL, + Boolean.toString(true)); + annotation.getDetails().put(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE, + Locale.getDefault().toString()); + + // The command to add the annotation in resource content + final GMFtoEMFCommandWrapper command = new GMFtoEMFCommandWrapper(new AddToResourceCommand( + ((ModelSet) resource.getResourceSet()).getTransactionalEditingDomain(), resource, annotation)); + command.execute(); + + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#setModelURI(org.eclipse.emf.common.util.URI) + */ + @Override + public void setModelURI(final URI uriWithoutExtension) { + final URI oldPrivateURI = getSharedResourceURI(); + final URI oldSharedURI = getPrivateResourceURI(); + + URI newURI; + if ((null != resourceURI) && isLegacy(resourceURI.trimFileExtension())) { + newURI = getLegacyURI(uriWithoutExtension); + } else { + newURI = getInternationalizationPreferenceModelStoreURI(uriWithoutExtension); + } + + super.setModelURI(newURI.trimFileExtension()); + + bean.firePropertyChange(PROPERTY_PRIVATE_RESOURCE_URI, oldPrivateURI, getSharedResourceURI()); + bean.firePropertyChange(PROPERTY_SHARED_RESOURCE_URI, oldSharedURI, getPrivateResourceURI()); + } + + /** + * Determinates if this is the legacy URI. + * + * @param uriWithoutExtension + * The uri to check. + * @return true if the uri is corresponding to the legacy mode, + * false otherwise. + */ + protected boolean isLegacy(final URI uriWithoutExtension) { + boolean result = false; + if (null != uriWithoutExtension) { + result = Objects.equals(uriWithoutExtension, getModelManager().getURIWithoutExtension()); + } + return result; + } + + /** + * Returns the internationalization preference model URI (With file + * extension) + * + * It may be either the Legacy URI (platform:/resource/model/model.notation) + * or the 1.0.0 URI + * (file:/~workspace/.metadata/.plugins/org.eclipse.papyrus.infra.core/model/model.internationalization) + * + * @param uriWithoutExtension + * The initial URI. + * @return The internationalization preference model URI. + */ + protected URI getInternationalizationPreferenceModelURI(final URI uriWithoutExtension) { + final URIConverter converter = getModelManager().getURIConverter(); + final URI legacyURI = getLegacyURI(uriWithoutExtension); + + // If the notation file exists and contains the internationalization + // annotation, this is a + // legacy model + if (converter.exists(legacyURI, Collections.emptyMap())) { + try { + final Resource notationResource = getModelManager().getResource(legacyURI, true); + if (null != InternationalizationAnnotationResourceUtils + .getInternationalizationAnnotation(notationResource)) { + return legacyURI; + } + } catch (final Exception ex) { + // Temporary workaround: the notation file may exist and be + // empty + // Log the error and continue + Activator.log.error(ex); + } + } + + return getInternationalizationPreferenceModelStoreURI(uriWithoutExtension); + } + + /** + * Get the legacy URI. It must be like + * platform:/resource/model/model.notation. + * + * @param uriWithoutExtension + * The initial uri. + * @return The legacy URI. + */ + protected URI getLegacyURI(final URI uriWithoutExtension) { + return uriWithoutExtension.appendFileExtension(NOTATION_FILE_EXTENSION); + } + + /** + * Get the internationalization preference model store URI. It must be like + * file:/~workspace/.metadata/.plugins/org.eclipse.papyrus.infra.core/model/model.internationalization. + * + * @param uriWithoutExtension + * The initial URI. + * @return The non-legacy URI. + */ + protected URI getInternationalizationPreferenceModelStoreURI(final URI uriWithoutExtension) { + URI fullURI = uriWithoutExtension.appendFileExtension(INTERNATIONALIZATION_PREFERENCE_FILE_EXTENSION); + return providerManager.getInternationalizationPreferenceModelProvider(fullURI) + .getInternationalizationPreferenceModelURI(fullURI); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getSaveOptions() + */ + @Override + protected Map getSaveOptions() { + final Map saveOptions = super.getSaveOptions(); + + saveOptions.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.FALSE); + saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.FALSE); + saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); + + return saveOptions; + } + + /** + * Get the legacy mode. + * + * @return true if this is the legacy mode, false + * otherwise. + */ + public boolean isLegacyMode() { + if (null == legacyMode) { + legacyMode = false; // Assume not + + // Does the shared DI resource contain the sash layout? + final URI sharedURI = getPrivateResourceURI(); + if (null != sharedURI) { + for (final Resource next : getResources()) { + if (sharedURI.equals(next.getURI())) { + legacyMode = null != InternationalizationAnnotationResourceUtils + .getInternationalizationAnnotation(next); + break; + } + } + } + } + + return legacyMode; + } + + /** + * This allows to recalculate the legacy mode. + */ + protected void invalidateLegacyMode() { + final boolean oldValue = isLegacyMode(); + + legacyMode = null; + + final boolean newValue = isLegacyMode(); + + if (oldValue != newValue) { + bean.firePropertyChange(PROPERTY_LEGACY_MODE, oldValue, newValue); + } + } + + /** + * Gets the URI of the internationalization preference model resource in the + * shared (collocated with the user model) area, irrespective of whether + * that actually is the resource that currently stores the + * internationalization preference model. + * + * @return the shared internationalization preference model resource URI + */ + public URI getSharedResourceURI() { + URI modelURI = (null == getModelManager()) ? null : getModelManager().getURIWithoutExtension(); + return (null == modelURI) ? null : getInternationalizationPreferenceModelStoreURI(modelURI); + } + + /** + * Gets the URI of the internationalization preference model resource in the + * user private area, irrespective of whether that actually is the resource + * that currently stores the internationalization preference model. + * + * @return the private sash-model resource URI + */ + public URI getPrivateResourceURI() { + URI modelURI = (null == getModelManager()) ? null : getModelManager().getURIWithoutExtension(); + return (null == modelURI) ? null : modelURI.appendFileExtension(NOTATION_FILE_EXTENSION); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#isRootElement(org.eclipse.emf.ecore.EObject) + */ + @Override + protected boolean isRootElement(final EObject object) { + return super.isRootElement(object) && object instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) object).getSource()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.EMFLogicalModel#isSupportedRoot(org.eclipse.emf.ecore.EObject) + */ + @Override + protected boolean isSupportedRoot(final EObject object) { + return object instanceof EAnnotation + && InternationalizationPreferencesConstants.INTERNATIONALIZATION_ANNOTATION_LABEL + .equals(((EAnnotation) object).getSource()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() + */ + @Override + public String getModelFileExtension() { + if (isLegacy((null == resourceURI) ? resourceURI : resourceURI.trimFileExtension())) { + return NOTATION_FILE_EXTENSION; + } else { + return INTERNATIONALIZATION_PREFERENCE_FILE_EXTENSION; + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AbstractModel#getIdentifier() + */ + @Override + public String getIdentifier() { + return MODEL_ID; + } + + /** + * This allows to add a property change listener. + * + * @param listener + * The property change listener to add. + */ + public void addPropertyChangeListener(final PropertyChangeListener listener) { + bean.addPropertyChangeListener(listener); + } + + /** + * This allows to remove a property change listener. + * + * @param listener + * The property change listener to remove. + */ + public void removePropertyChangeListener(final PropertyChangeListener listener) { + bean.removePropertyChangeListener(listener); + } + + /** + * This allows to add a property change listener for a property name.. + * + * @param propertyName + * The property name for which one add the property change + * listener. + * @param listener + * The property change listener to add. + */ + public void addPropertyChangeListener(final String propertyName, final PropertyChangeListener listener) { + bean.addPropertyChangeListener(propertyName, listener); + } + + /** + * This allows to remove a property change listener for a property name.. + * + * @param propertyName + * The property name for which one remove the property change + * listener. + * @param listener + * The property change listener to remove. + */ + public void removePropertyChangeListener(final String propertyName, final PropertyChangeListener listener) { + bean.removePropertyChangeListener(propertyName, listener); + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModelProviderManager.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModelProviderManager.java new file mode 100644 index 00000000000..eb2713c3e81 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationPreferenceModelProviderManager.java @@ -0,0 +1,252 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelresource; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.common.util.URI; +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.internationalization.Activator; + +import com.google.common.base.Predicate; +import com.google.common.base.Strings; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + + +/** + * This is the InternationalizationPreferenceModelProviderManager type. + */ +class InternationalizationPreferenceModelProviderManager { + + /** + * The provider identifier for the extension point of the internationalization preference model provider. + */ + private static final String E_PROVIDER = "internationalizationPreferenceModelProvider"; //$NON-NLS-1$ + + /** + * The extension point identifier. + */ + private static final String EXT_PT = Activator.PLUGIN_ID + "." + E_PROVIDER; //$NON-NLS-1$ + + /** + * The current model set. + */ + private final ModelSet modelSet; + + /** + * The default internationalization preference model provider. + */ + private final IInternationalizationPreferenceModelProvider defaultInternationalizationPrefModelProvider; + + /** + * The descriptors. + */ + private final List descriptors; + + /** + * Constructor. + * + * @param modelSet The current model set. + */ + public InternationalizationPreferenceModelProviderManager(final ModelSet modelSet) { + super(); + + this.modelSet = modelSet; + this.defaultInternationalizationPrefModelProvider = createDefaultInternationalizationPrefModelProvider(); + this.descriptors = new CopyOnWriteArrayList(createDescriptors()); + } + + /** + * This allows to dispose the objects in the class. + */ + protected void dispose() { + for (final ProviderDescriptor next : descriptors) { + next.dispose(); + } + } + + /** + * Obtains the most appropriate sash model provider for the specified URI. + * + * @param userModelURI The initial user model URI. + * + * @return the sash model provider, never {@code null} (there is always a default available) + */ + protected IInternationalizationPreferenceModelProvider getInternationalizationPreferenceModelProvider(final URI userModelURI) { + IInternationalizationPreferenceModelProvider result = null; + + // We know at least the back-stop descriptor will match + ProviderDescriptor descriptor = Iterables.find(descriptors, new Predicate>() { + + @Override + public boolean apply(Predicate input) { + return input.apply(userModelURI); + } + }); + + try { + result = descriptor.getProvider(); + } catch (CoreException e) { + Activator.getDefault().getLog().log(e.getStatus()); + result = defaultInternationalizationPrefModelProvider; + + // Remove the offending descriptor + descriptors.remove(descriptor); + } + + return result; + } + + /** + * This allows to create the descriptors. + * + * @return The list of created descriptors. + */ + private List createDescriptors() { + List result = Lists.newArrayListWithExpectedSize(1); + + for (final IConfigurationElement next : Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_PT)) { + if (E_PROVIDER.equals(next.getName())) { + try { + result.add(new ProviderDescriptor(next)); + } catch (final CoreException e) { + Activator.getDefault().getLog().log(e.getStatus()); + } + } + } + + // The back-stop that will match any URI not previously matched + result.add(new ProviderDescriptor(defaultInternationalizationPrefModelProvider)); + + return result; + } + + /** + * This allows to create the default internationalization preference model provider. + * + * @return The created {@link IInternationalizationPreferenceModelProvider}. + */ + private IInternationalizationPreferenceModelProvider createDefaultInternationalizationPrefModelProvider() { + return new AbstractInternationalizationPreferenceModelProvider() { + + @Override + public URI getInternationalizationPreferenceModelURI(final URI userModelURI) { + final URI uriWithoutExtension = userModelURI.trimFileExtension(); + + IPath stateLocation = Activator.getDefault().getStateLocation(); + + if (uriWithoutExtension.isPlatform()) { + stateLocation = stateLocation.append(uriWithoutExtension.toPlatformString(true)); + } else { + stateLocation = stateLocation.append(URI.decode(uriWithoutExtension.toString())); + } + + URI workspaceFileURI = URI.createFileURI(stateLocation.toString()).appendFileExtension(InternationalizationPreferenceModel.INTERNATIONALIZATION_PREFERENCE_FILE_EXTENSION); + + return workspaceFileURI; + } + }; + } + + // + // Nested types + // + + private class ProviderDescriptor implements Predicate { + + private static final String A_SCHEME = "scheme"; //$NON-NLS-1$ + + private static final String A_PATTERN = "pattern"; //$NON-NLS-1$ + + private static final String A_CLASS = "class"; //$NON-NLS-1$ + + private final IConfigurationElement config; + + private final String scheme; + + private final Pattern pattern; + + private IInternationalizationPreferenceModelProvider provider; + + ProviderDescriptor(IInternationalizationPreferenceModelProvider provider) { + this.provider = provider; + + this.config = null; + this.scheme = null; + this.pattern = null; + } + + ProviderDescriptor(IConfigurationElement config) throws CoreException { + this.config = config; + + this.scheme = config.getAttribute(A_SCHEME); + String pattern = config.getAttribute(A_PATTERN); + + if (Strings.isNullOrEmpty(scheme) && Strings.isNullOrEmpty(pattern)) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Sash model provider missing both scheme and pattern filter.")); //$NON-NLS-1$ + } + + try { + this.pattern = (pattern == null) ? null : Pattern.compile(pattern); + } catch (PatternSyntaxException e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid sash model provider URI pattern filter.", e)); //$NON-NLS-1$ + } + } + + @Override + public boolean apply(URI input) { + return ((scheme == null) || scheme.equals(input.scheme())) // Scheme filter + && ((pattern == null) || pattern.matcher(input.toString()).find()); // Pattern filter + } + + IInternationalizationPreferenceModelProvider getProvider() throws CoreException { + if (provider == null) { + try { + provider = (IInternationalizationPreferenceModelProvider) config.createExecutableExtension(A_CLASS); + provider.initialize(modelSet); + } catch (CoreException e) { + throw e; + } catch (ClassCastException e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invalid sash model provider implementation.", e)); //$NON-NLS-1$ + } catch (Exception e) { + throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to initialize sash model provider implementation.", e)); //$NON-NLS-1$ + } + } + + return provider; + } + + void dispose() { + if (provider != null) { + try { + provider.dispose(); + } catch (Exception e) { + Activator.log.error("Failed to initialize sash model provider implementation.", e); //$NON-NLS-1$ + } + + provider = null; + } + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelsnippet/PropertiesAdjunctResourceModelSnippet.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelsnippet/PropertiesAdjunctResourceModelSnippet.java new file mode 100644 index 00000000000..a2642aeab0e --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelsnippet/PropertiesAdjunctResourceModelSnippet.java @@ -0,0 +1,119 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.modelsnippet; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.infra.core.resource.AdjunctResourceModelSnippet; +import org.eclipse.papyrus.infra.core.resource.EMFLogicalModel; +import org.eclipse.papyrus.infra.core.resource.IModel; +import org.eclipse.papyrus.infra.core.resource.ResourceAdapter; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; + +/** + * The adjunct resource model snippet for the properties files. + */ +public class PropertiesAdjunctResourceModelSnippet extends AdjunctResourceModelSnippet { + + /** + * The internationalization model. + */ + private InternationalizationModelResource model; + + /** + * The adapter. + */ + private Adapter adapter; + + /** + * Constructor. + */ + public PropertiesAdjunctResourceModelSnippet() { + super(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AdjunctResourceModelSnippet#loadResource(org.eclipse.papyrus.infra.core.resource.EMFLogicalModel, + * org.eclipse.emf.ecore.resource.ResourceSet, + * org.eclipse.emf.common.util.URI) + */ + @Override + protected void loadResource(final EMFLogicalModel model, final ResourceSet resourceSet, final URI adjunctURI) { + if (adjunctURI.fileExtension().equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)) { + model.loadModel(adjunctURI.trimFileExtension()); + } else { + super.loadResource(model, resourceSet, adjunctURI); + } + } + + /** + * Redefined to manage the load of adjunct resource. {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AdjunctResourceModelSnippet#start(org.eclipse.papyrus.infra.core.resource.IModel) + */ + @Override + public void start(final IModel startingModel) { + if (startingModel instanceof InternationalizationModelResource) { + model = (InternationalizationModelResource) startingModel; + + adapter = new ResourceAdapter() { + @Override + protected void handleResourceLoaded(Resource resource) { + loadAdjunctResource(resource); + } + }; + + model.getModelManager().eAdapters().add(adapter); + } + } + + /** + * Load the adjunct resource. + * + * @param resource + * The resource to load. + */ + protected void loadAdjunctResource(final Resource resource) { + // If the parameter resource is the model's own kind of resource, + // then there is nothing to do + if ((null != model) && !model.isRelatedResource(resource)) { + final URI adjunctURI = resource.getURI().trimFileExtension() + .appendFileExtension(model.getModelFileExtension()); + final ResourceSet resourceSet = resource.getResourceSet(); + + if (!model.isLoadedResourcesForURI(adjunctURI)) { + loadResource(model, resourceSet, adjunctURI); + } + } + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.core.resource.AdjunctResourceModelSnippet#dispose(org.eclipse.papyrus.infra.core.resource.IModel) + */ + @Override + public void dispose(final IModel stoppingModel) { + if ((stoppingModel == model) && (null != adapter)) { + model.getModelManager().eAdapters().remove(adapter); + adapter = null; + model = null; + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java new file mode 100644 index 00000000000..cc009312427 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java @@ -0,0 +1,167 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry; +import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage; +import org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; + +/** + * A class taking in charge the synchronization of the partName and the label. + * When label change, the other is automatically updated. + */ +public class EntryPartLabelSynchronizer { + + /** + * The internationalization entry. + */ + private InternationalizationEntry entry; + + /** + * The corresponding editor part (implementing + * {@link IInternationalizationEditor} for the internationalization). + */ + private IInternationalizationEditor editorPart; + + /** + * The {@link internationalizationModelResource} to get the labels needed. + */ + private InternationalizationModelResource modelResource; + + /** + * Listener on label change. + */ + private final Adapter labelListener = new AdapterImpl() { + + /** + * + * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification) + * + * @param notification + */ + @Override + public void notifyChanged(final Notification notification) { + if (notification.getFeature() == InternationalizationPackage.eINSTANCE + .getInternationalizationEntry_Value()) { + editorPart.modifyPartName(getLabel(entry.getKey())); + } + } + }; + + /** + * Constructor. + * + * @param entry + * The internationalization entry to manage. + * @param editorPart + * The editor part to change label. + * @param modelResource + * The model resource corresponding to the internationalization. + */ + public EntryPartLabelSynchronizer(final InternationalizationEntry entry, + final IInternationalizationEditor editorPart, final InternationalizationModelResource modelResource) { + this.editorPart = editorPart; + this.modelResource = modelResource; + setEntry(entry); + } + + /** + * Change the associated entry. + * + * @param entry + * The internationalization entry. + */ + public void setEntry(final InternationalizationEntry entry) { + if (null != entry && null != entry.getKey()) { + entry.eAdapters().remove(this.labelListener); + + // Set new table internationalization entry + this.entry = entry; + + // Set editor name + editorPart.modifyPartName(getLabel(entry.getKey())); + + // Listen to name change + entry.eAdapters().add(this.labelListener); + } + } + + /** + * This allows to dispose the synchronizer. + */ + public void dispose() { + this.editorPart = null; + this.modelResource = null; + if (null != entry) { + this.entry.eAdapters().remove(this.labelListener); + } + } + + /** + * This allows to get the object label from the model resource. + * + * @param object + * The object to get its label. + * @return The object label. + */ + protected String getLabel(final Object object) { + String value = ""; //$NON-NLS-1$ + if (object instanceof Table) { + value = getTableLabel((Table) entry.getKey()); + } else if (object instanceof Diagram) { + value = getDiagramLabel((Diagram) entry.getKey()); + } + return value; + } + + /** + * This allows to get the table label from the model resource. + * + * @param table + * The table to get its label (name if label returns + * null). + * @return The table label of table name if label returns null. + */ + protected String getTableLabel(final Table table) { + String result = null; + if (InternationalizationPreferencesUtils.getInternationalizationPreference(table)) { + result = modelResource.getValueForEntryKey(table.eResource().getURI(), table); + } + return null != result ? result : table.getName(); + } + + /** + * This allows to get the diagram label from the model resource. + * + * @param diagram + * The diagram to get its label (name if label returns + * null). + * @return The diagram label of diagram name if label returns + * null. + */ + protected String getDiagramLabel(final Diagram diagram) { + String result = null; + if (InternationalizationPreferencesUtils.getInternationalizationPreference(diagram)) { + result = modelResource.getValueForEntryKey(diagram.eResource().getURI(), diagram); + } + return null != result ? result : diagram.getName(); + } +} \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/InternationalizationPreferenceModelUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/InternationalizationPreferenceModelUtils.java new file mode 100644 index 00000000000..77ec76f5d07 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/InternationalizationPreferenceModelUtils.java @@ -0,0 +1,61 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ModelUtils; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationPreferenceModel; + +/** + * Set of utility methods for the InternationalizationPreferenceModel. + */ +public class InternationalizationPreferenceModelUtils { + + /** + * Gets the InternationalizationPreferenceModel from the {@link ModelSet}. + *
+ * + * @param modelsManager + * The modelManager containing the requested model. + * + * @return The {@link InternationalizationPreferenceModel} registered in + * modelManager, or null if not found. + */ + public static InternationalizationPreferenceModel getInternationalizationPreferenceModel(ModelSet modelsManager) { + return (InternationalizationPreferenceModel) modelsManager + .getModel(InternationalizationPreferenceModel.MODEL_ID); + } + + /** + * Gets the InternationalizationPreferenceModel from the {@link ModelSet}. + *
+ * + * @param ServicesRegistry + * The servie registry under which the ModelSet is registered. + * + * @return The {@link InternationalizationPreferenceModel} registered in + * modelManager, or null if not found. + */ + public static InternationalizationPreferenceModel getInternationalizationPreferenceModel( + ServicesRegistry servicesRegistry) { + try { + return (InternationalizationPreferenceModel) ModelUtils.getModelSetChecked(servicesRegistry) + .getModel(InternationalizationPreferenceModel.MODEL_ID); + } catch (ServiceException e) { + return null; + } + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java new file mode 100644 index 00000000000..cc01609c041 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java @@ -0,0 +1,171 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesConstants; +import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.internationalization.modelresource.InternationalizationModelResource; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; + +/** + * A class taking in charge the synchronization of the partName and the label. + * When label change, the other is automatically updated. + */ +public class PreferencePartLabelSynchronizer { + + /** + * The preference store. + */ + private IPreferenceStore preferenceStore; + + /** + * The EObject corresponding to the graphical editor part. + */ + private EObject graphicalEObject; + + /** + * The corresponding editor part (implementing + * {@link IInternationalizationEditor} for the internationalization). + */ + private IInternationalizationEditor editorPart; + + /** + * The {@link internationalizationModelResource} to get the labels needed. + */ + private InternationalizationModelResource modelResource; + + /** + * Listener on label change. + */ + private final IPropertyChangeListener propertyListener = new IPropertyChangeListener() { + + public void propertyChange(final PropertyChangeEvent event) { + if (event.getProperty().equals(InternationalizationPreferencesConstants.USE_INTERNATIONALIZATION_PREFERENCE) + || event.getProperty().equals(InternationalizationPreferencesConstants.LANGUAGE_PREFERENCE)) { + // Modify the part name + editorPart.modifyPartName(getLabel(graphicalEObject)); + // Refresh the editor part + editorPart.refreshEditorPart(); + } + } + }; + + /** + * Constructor. + * + * @param preferenceStore + * The preference store to manage. + * @param graphicalEObject + * The EObject corresponding to the owner of the editor part. + * @param editorPart + * The editor part to change label. + * @param modelResource + * The model resource corresponding to the internationalization. + */ + public PreferencePartLabelSynchronizer(final IPreferenceStore preferenceStore, final EObject graphicalEObject, + final IInternationalizationEditor editorPart, final InternationalizationModelResource modelResource) { + this.editorPart = editorPart; + this.modelResource = modelResource; + this.graphicalEObject = graphicalEObject; + setPreferenceStore(preferenceStore); + } + + /** + * Change the associated entry. + * + * @param preferenceStore + * The preference store + */ + public void setPreferenceStore(final IPreferenceStore preferenceStore) { + if (null != preferenceStore) { + preferenceStore.removePropertyChangeListener(this.propertyListener); + + // Set new table internationalization entry + this.preferenceStore = preferenceStore; + + // Set editor name + editorPart.modifyPartName(getLabel(graphicalEObject)); + + // Listen to name change + preferenceStore.addPropertyChangeListener(propertyListener); + } + } + + /** + * This allows to dispose the synchronizer. + */ + public void dispose() { + this.editorPart = null; + this.modelResource = null; + if (null != preferenceStore) { + this.preferenceStore.removePropertyChangeListener(this.propertyListener); + } + } + + /** + * This allows to get the object label from the model resource. + * + * @param object + * The object to get its label. + * @return The object label. + */ + protected String getLabel(final EObject object) { + String value = ""; //$NON-NLS-1$ + if (object instanceof Table) { + value = getTableLabel((Table) object); + } else if (object instanceof Diagram) { + value = getDiagramLabel((Diagram) object); + } + return value; + } + + /** + * This allows to get the table label from the model resource. + * + * @param table + * The table to get its label (name if label returns + * null). + * @return The table label or table name if label returns null. + */ + protected String getTableLabel(final Table table) { + String result = null; + if (InternationalizationPreferencesUtils.getInternationalizationPreference(table)) { + result = modelResource.getValueForEntryKey(table.eResource().getURI(), table); + } + return null != result ? result : table.getName(); + } + + /** + * This allows to get the diagram label from the model resource. + * + * @param diagram + * The diagram to get its label (name if label returns + * null). + * @return The diagram label or diagram name if label returns + * null. + */ + protected String getDiagramLabel(final Diagram diagram) { + String result = null; + if (InternationalizationPreferencesUtils.getInternationalizationPreference(diagram)) { + result = modelResource.getValueForEntryKey(diagram.eResource().getURI(), diagram); + } + return null != result ? result : diagram.getName(); + } +} \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PropertiesFilesUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PropertiesFilesUtils.java new file mode 100644 index 00000000000..797fded226e --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PropertiesFilesUtils.java @@ -0,0 +1,353 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; +import java.util.WeakHashMap; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.URIConverter; +import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl; +import org.osgi.framework.Bundle; + +/** + * This needed methods was copied from UML2Util because we can't use it (because of visibility). + */ +public class PropertiesFilesUtils { + + /** + * The default URI converter for resource bundle look-ups. + */ + protected static final URIConverter DEFAULT_URI_CONVERTER = new ExtensibleURIConverterImpl(); + + /** + * A cache of resource bundles. + */ + protected static final Map> RESOURCE_BUNDLES = Collections + .synchronizedMap(new WeakHashMap>()); + + /** + * The empty string. + */ + public static final String EMPTY_STRING = ""; //$NON-NLS-1$ + + /** + * The platform line separator. + */ + protected static final String LINE_SEPARATOR = System.getProperty(Platform.PREF_LINE_SEPARATOR); + + /** + * The scheme for platform URIs. + */ + public static final String URI_SCHEME_PLATFORM = "platform"; //$NON-NLS-1$ + + /** + * The first segment for platform plugin URIs. + */ + public static final String URI_SEGMENT_PLUGIN = "plugin"; //$NON-NLS-1$ + + /** + * The first segment for platform resource URIs. + */ + public static final String URI_SEGMENT_RESOURCE = "resource"; //$NON-NLS-1$ + + /** + * The standard extension for properties files. + */ + public static final String PROPERTIES_FILE_EXTENSION = "properties"; //$NON-NLS-1$ + + /** + * Retrieves the candidate resource bundle URIs based on the specified base + * URI and base segment in the specified locale. + * + * @param baseURI + * The base URI (i.e. without the last segment) for the candidate + * resource bundle URIs. + * @param locale + * The locale within which to base the candidate resource bundle + * URIs. + * @param baseSegment + * The base segment (i.e. the last segment without the extension) + * for the candidate resource bundle URIs. + * @return The candidate resource bundle URIs with the base URI and base + * segment in the locale. + */ + protected static List getResourceBundleURIs(final URI baseURI, final Locale locale, final String initialBaseSegment) { + String baseSegment = initialBaseSegment; + final List resourceBundleURIs = new ArrayList(); + final String language = locale.getLanguage(); + + if (language.length() > 0) { + baseSegment += ('_' + language); + resourceBundleURIs.add(0, + baseURI.appendSegment(baseSegment).appendFileExtension(PROPERTIES_FILE_EXTENSION)); + + String country = locale.getCountry(); + + if (country.length() > 0) { + baseSegment += ('_' + country); + resourceBundleURIs.add(0, + baseURI.appendSegment(baseSegment).appendFileExtension(PROPERTIES_FILE_EXTENSION)); + + String variant = locale.getVariant(); + + if (variant.length() > 0) { + baseSegment += ('_' + variant); + resourceBundleURIs.add(0, + baseURI.appendSegment(baseSegment).appendFileExtension(PROPERTIES_FILE_EXTENSION)); + } + } + } + + return resourceBundleURIs; + } + + /** + * Retrieves the candidate resource bundle URIs for the specified URI in the + * specified locale (if specified). + * + * @param uri + * The URI upon which to base the candidate resource bundle URIs. + * @param locale + * The locale within which to base the candidate resource bundle + * URIs, or null. + * @return The candidate resource bundle URIs for the URI in the locale (if + * specified). + */ + protected static List getResourceBundleURIs(final URI uri, final Locale locale) { + final List resourceBundleURIs = new ArrayList(); + final URI baseURI = uri.trimSegments(1); + final String baseSegment = uri.trimFileExtension().lastSegment(); + + if (null != baseSegment) { + resourceBundleURIs.add(baseURI.appendSegment(baseSegment).appendFileExtension(PROPERTIES_FILE_EXTENSION)); + + if (null != locale && !locale.toString().isEmpty()) { + resourceBundleURIs.addAll(0, getResourceBundleURIs(baseURI, locale, baseSegment)); + } + } + + return resourceBundleURIs; + } + + /** + * Retrieves the (cached) resource bundle for the specified object, + * localized in the default locale if indicated. + * + * @param eObject + * The object for which to retrieve the resource bundle. + * @param localize + * Whether to retrieve the resource bundle based on (the default) + * locale. + * @return The resource bundle for the object (in the default locale). + */ + public static ResourceBundleAndURI getResourceBundle(final EObject eObject, final boolean localize) { + return getResourceBundle(eObject, localize ? Locale.getDefault() : null); + } + + /** + * Retrieves the (cached) resource bundle for the specified object in the + * specified locale (if specified). + * + * @param eObject + * The object for which to retrieve the resource bundle. + * @param locale + * The locale in which to retrieve the resource bundle, or + * null. + * @return The resource bundle for the object in the locale (if specified). + */ + public static ResourceBundleAndURI getResourceBundle(final EObject eObject, final Locale locale) { + final Resource resource = eObject.eResource(); + + if (null != resource) { + return getResourceBundle(resource.getURI(), locale); + } + return null; + } + + /** + * Retrieves the (cached) resource bundle for the specified object, + * localized in the default locale if indicated. + * + * @param uri + * The URI of the object to manage. + * @param localize + * Whether to retrieve the resource bundle based on (the default) + * locale. + * @return The resource bundle for the object (in the default locale). + */ + public static ResourceBundleAndURI getResourceBundle(final URI uri, final boolean localize) { + return getResourceBundle(uri, localize ? Locale.getDefault() : null); + } + + /** + * Retrieves the (cached) resource bundle for the specified object in the + * specified locale (if specified). + * + * @param uri + * The URI of the object to manage. + * @param locale + * The locale in which to retrieve the resource bundle, or + * null. + * @return The resource bundle for the object in the locale (if specified). + */ + public static ResourceBundleAndURI getResourceBundle(final URI uri, final Locale locale) { + if (null != uri) { + Map resourceBundles = RESOURCE_BUNDLES.get(uri); + + if (null == resourceBundles) { + resourceBundles = Collections.synchronizedMap(new HashMap()); + RESOURCE_BUNDLES.put(uri, resourceBundles); + } + + if (!resourceBundles.containsKey(locale)) { + URIConverter uriConverter = DEFAULT_URI_CONVERTER; + + List resourceBundleURIs = getResourceBundleURIs(uri, locale); + + if (EMFPlugin.IS_ECLIPSE_RUNNING) { + URI normalizedURI = uriConverter.normalize(uri); + int segmentCount = normalizedURI.segmentCount(); + + if (URI_SCHEME_PLATFORM.equals(normalizedURI.scheme()) && segmentCount > 2 + && URI_SEGMENT_PLUGIN.equals(normalizedURI.segment(0))) { + + Bundle bundle = Platform.getBundle(normalizedURI.segment(1)); + + if (null != bundle) { + Bundle[] fragments = Platform.getFragments(bundle); + + if (null != fragments) { + String[] trailingSegments = normalizedURI.segmentsList().subList(2, segmentCount) + .toArray(new String[] {}); + + for (int f = 0; f < fragments.length; f++) { + resourceBundleURIs.addAll(0, + getResourceBundleURIs(normalizedURI.trimSegments(segmentCount - 1) + .appendSegment(fragments[f].getSymbolicName()) + .appendSegments(trailingSegments), locale)); + } + } + } + } + } + + ResourceBundle resourceBundle = null; + ResourceBundleAndURI resourceBundleAndURI = null; + + for (final Iterator rbu = resourceBundleURIs.iterator(); rbu.hasNext();) { + + try { + final URI nextURI = rbu.next(); + InputStream inputStream = uriConverter.createInputStream(nextURI); + try { + resourceBundle = new PropertyResourceBundle(inputStream); + resourceBundleAndURI = new ResourceBundleAndURI(resourceBundle, nextURI); + } finally { + inputStream.close(); + } + break; + } catch (IOException ioe) { + // ignore + } + } + + resourceBundles.put(locale, resourceBundleAndURI); + } + + return resourceBundles.get(locale); + } + + return null; + } + + public static URI getResourceBundleURIFromResourceURI(final URI resourceURI, final boolean localize){ + return getResourceBundleURIFromResourceURI(resourceURI, localize ? Locale.getDefault() : null); + } + + public static URI getResourceBundleURIFromResourceURI(final URI resourceURI, final Locale locale){ + URI resultURI = null; + + if (null != resourceURI) { + final Map resourceBundlesUrisUsed = RESOURCE_BUNDLES.get(resourceURI); + + if(null != resourceBundlesUrisUsed){ + if(resourceBundlesUrisUsed.containsKey(locale)){ + resultURI = resourceBundlesUrisUsed.get(locale).getUri(); + } + } + } + + return null != resultURI ? resultURI : resourceURI; + } + + /** + * Retrieves a string for the specified object, localized if indicated. + * + * @param eObject + * The object for which to retrieve a (localized) string. + * @param key + * The key in the resource bundle. + * @param defaultString + * The string to return if no string for the given key can be + * found. + * @param localize + * Whether the string should be localized. + * @return The (localized) string. + */ + public static String getString(EObject eObject, String key, String defaultString, boolean localize) { + String string = defaultString; + + if (null != eObject) { + + try { + ResourceBundleAndURI resourceBundleAndURI = getResourceBundle(eObject, localize); + + if (null != resourceBundleAndURI) { + string = resourceBundleAndURI.getResourceBundle().getString(key); + } + } catch (MissingResourceException mre) { + // ignore + } + } + + return string; + } + + /** + * This allows to remove of the map the resource bundle. + * + * @param uri The URI of the resource to remove. + */ + public static void removeResourceBundle(final URI uri){ + if(RESOURCE_BUNDLES.containsKey(uri)){ + RESOURCE_BUNDLES.remove(uri); + } + } +} \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java new file mode 100644 index 00000000000..c0d1d04accd --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java @@ -0,0 +1,162 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMIResource; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; + +/** + * The utils methods corresponding to the qualified name calculation for the + * {@linl EObject}. + */ +public class QualifiedNameUtils { + + /** + * The separator for the qualified name for the properties file. + */ + public static final String QN_SEPARATOR_FOR_PROPERTIES = "__"; //$NON-NLS-1$ + + /** + * The qualified name for the {@link EObject} in parameter. + * + * @param eObject + * The {@link EObject} to calculate qualified name. + * @return The qualified name for the EObject or the XMI:id if no feature + * name. + */ + public static String getQualifiedName(final EObject eObject) { + StringBuilder result = new StringBuilder(); + + EObject parent = eObject; + boolean hasNotFoundName = false; + + // Loop until no more parent to calculate qualified name + while (null != parent && !hasNotFoundName) { + hasNotFoundName = true; + + // Get the name feature if existing + final EStructuralFeature feature = parent.eClass().getEStructuralFeature("name"); //$NON-NLS-1$ + if (null != feature) { + Object featureValue = parent.eGet(feature); + if (featureValue instanceof String) { + result = appendQualifiedName(result, (String) featureValue); + hasNotFoundName = false; + } + } + + parent = parent.eContainer(); + } + + // The feature name was not found for an EObject in hierarchy, return + // the xmi:id of the object + if (hasNotFoundName) { + if (eObject.eResource() instanceof XMIResource) { + result = new StringBuilder(); + result.append(((XMIResource) eObject.eResource()).getID(eObject)); + } + } + + return result.toString(); + } + + /** + * This allows to append a string to the StringBuilder in parameter. + * + * @param initialStringBuilder + * The initial string builder. + * @param toAdd + * The string to add to string builder. + * @return The modified string builder. + */ + private static StringBuilder appendQualifiedName(final StringBuilder initialStringBuilder, final String toAdd) { + StringBuilder result = new StringBuilder(); + result.append(toAdd); + // If the initial string builder is not empty, add the qualified name + // separator + if (!initialStringBuilder.toString().isEmpty()) { + result.append(QN_SEPARATOR_FOR_PROPERTIES); + } + result.append(initialStringBuilder); + return result; + } + + /** + * Get a diagram by its name. + * + * @param The + * EMF logical model. + * @param diagramName + * Name of the diagram. This is the name set by the user. + * @param qualifiedName + * The qualified name representing the diagram element or + * null. + * @return The found diagram or null. + */ + public static Diagram getDiagram(final Resource resource, final String diagramName, final String qualifiedName) { + if (null != diagramName && !diagramName.isEmpty()) { + for (final EObject element : resource.getContents()) { + if (element instanceof Diagram) { + final Diagram diagram = (Diagram) element; + + if (diagramName.equals(diagram.getName())) { + if (null == qualifiedName || qualifiedName.isEmpty() + || getQualifiedName(diagram.getElement()).equals(qualifiedName)) { + // Found + return diagram; + } + } + } + } + } + + // not found + return null; + } + + /** + * Get a table by its name. + * + * @param model + * The EMF logical model. + * @param tableName + * Name of the table. This is the name set by the user. + * @param qualifiedName + * The qualified name representing the table owner or + * null. + * @return The found diagram or null. + */ + public static Table getTable(final Resource resource, final String tableName, final String qualifiedName) { + if (null != tableName && !tableName.isEmpty()) { + for (final EObject element : resource.getContents()) { + if (element instanceof Table) { + final Table table = (Table) element; + + if (tableName.equals(table.getName())) { + // Found + if (null == qualifiedName || qualifiedName.isEmpty() + || getQualifiedName(table.getOwner()).equals(qualifiedName)) { + return table; + } + } + } + } + } + // not found + return null; + } +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/ResourceBundleAndURI.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/ResourceBundleAndURI.java new file mode 100644 index 00000000000..3117ef5e238 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/ResourceBundleAndURI.java @@ -0,0 +1,87 @@ +/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.internationalization.utils; + +import java.util.ResourceBundle; + +import org.eclipse.emf.common.util.URI; + +/** + * This class allows to store the resource bundle with the real uri + * corresponding. + */ +public class ResourceBundleAndURI { + + /** + * The resource bundle. + */ + private ResourceBundle resourceBundle; + + /** + * The uri of the resource. + */ + private URI uri; + + /** + * Constructor. + * + * @param resourceBundle + * The resource bundle. + * @param uri + * The uri of the resource. + */ + public ResourceBundleAndURI(final ResourceBundle resourceBundle, final URI uri) { + this.resourceBundle = resourceBundle; + this.uri = uri; + } + + /** + * Get the resource bundle. + * + * @return The resource bundle. + */ + public ResourceBundle getResourceBundle() { + return resourceBundle; + } + + /** + * Set the resource bundle. + * + * @param resourceBundle + * The resource bundle. + */ + public void setResourceBundle(final ResourceBundle resourceBundle) { + this.resourceBundle = resourceBundle; + } + + /** + * Get the resource uri. + * + * @return The resource uri. + */ + public URI getUri() { + return uri; + } + + /** + * Set the resource uri. + * + * @param uri + * The resource uri. + */ + public void setUri(final URI uri) { + this.uri = uri; + } + +} diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/InternationalizationPreferences.png b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/InternationalizationPreferences.png new file mode 100644 index 00000000000..a3796931ef1 Binary files /dev/null and b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/InternationalizationPreferences.png differ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/LabelsInternationalizationExample.png b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/LabelsInternationalizationExample.png new file mode 100644 index 00000000000..9d4147d9d1a Binary files /dev/null and b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/LabelsInternationalizationExample.png differ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/PropertiesModelExplorer.png b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/PropertiesModelExplorer.png new file mode 100644 index 00000000000..064464dcf77 Binary files /dev/null and b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/images/PropertiesModelExplorer.png differ diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev-toc.xml b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev-toc.xml new file mode 100644 index 00000000000..555b1dbf2b2 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev-toc.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.html b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.html new file mode 100644 index 00000000000..0e65f08f962 --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.html @@ -0,0 +1,266 @@ + + + + + + +

Internationalization

+

The internationalization is the way to manage your model with a specific language by labels. Like Eclipse, the internationalization is managed by the 'properties' file which are defined depending language as following (with for example, english language in US country):

+
    +
  • + modelName + _en_US.properties +
  • +
  • + modelName + _en.properties +
  • +
  • + modelName + .properties +
  • +
+

+ Properties files in Model Explorer +

+

Plugins

+

The plugins for the internationalization are the following:

+
    +
  • org.eclipse.papyrus.infra.internationalization: it contains: +
      +
    • Internationalization Meta-model
    • +
    • Generated code from the Meta-model
    • +
    • The model resources for the internationalization entries (key and label of internationalized objects) and internationalization preferences
    • +
    • Utils classes to manage the labels and the preferences
    • +
    +
  • +
  • org.eclipse.papyrus.infra.internationalization.edit: contains generated edit code from the Meta-model
  • +
  • org.eclipse.papyrus.infra.internationalization.common: contains all the common classes to manage command modification and some utils for the internationalization preferences. It contains the IInternationalizationEditor interface too which allows to define the editor that can be internationalized.
  • +
  • org.eclipse.papyrus.infra.internationalization.controlmode: contains the needed elements to manage the control mode for the properties and the preferences files
  • +
  • org.eclipse.papyrus.infra.internationalization.ui: contains the needed ui classes especially for the internationalization preferences
  • +
  • org.eclipse.papyrus.infra.internationalization.utils: contains all the needed utils classes to manage the label which can be used to get the diagrams and tables labels
  • +
  • org.eclipse.papyrus.infra.editor.welcome.internationalization: contains the needed classes to manage the preferences in the welcome page
  • +
  • org.eclipse.papyrus.uml.internationalization: contains the UML internationalization model resource which can manage the UML elements in the properties file
  • +
  • org.eclipse.papyrus.uml.internationalization.edit: contains the InternationalizationUMLItemProviderAdapterFactory which define the ItemProvider of UML elements to use the Papyrus getLabel function instead of UML getLabel function
  • +
  • org.eclipse.papyrus.uml.internationalization.utils: contains all the needed utils classes to manage the label which can be used to get the named elements labels
  • +
+

How to use internationalization

+

Instead of name, the label of objects must be displayed in Papyrus.

+

How the labels are managed in properties file

+

Each element which have a label must be written in the properties file like following:

+
    +
  • If this is a diagram: +
      +
    • + _labelDiagram_ + DiagramOwnerQualifiedName + _label_ + DiagramName + = + DiagramLabel +
    • +
    +
  • +
  • If this is a table: +
      +
    • + _labelTable_ + TableOwnerQualifiedName + _label_ + TableName + = + TableLabel +
    • +
    +
  • +
  • If this is an UML NamedElement: +
      +
    • + _label_ + NamedElementQualifiedName + = + NamedElementLabel +
    • +
    +
  • +
+

+ Example of internationalization labels +

+

Infra (Diagrams and Tables)

+

For the Diagrams and the Tables, UML is not needed. So to use the internationalization, you just need to:

+
    +
  • add the org.eclipse.papyrus.infra.internationalization.utils dependency
  • +
  • use methods/functions of LabelInternationalization
  • +
+

The LabelInternationalization class contains the following needed methods/functions:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method/FunctionParametersDescription
getInstanceThe the instance of LabelInternationalization
getDiagramLabelWithoutNameDiagramGet the label of the diagram without getting its name if label is not available
getDiagramLabelDiagramGet the label of the diagram or the name if the diagram label is not available
setDiagramLabelDiagram, String, LocaleSet the label (in prameter) of the Diagram for the locale needed (if null, the current must be used) without using command
getSetDiagramLabelCommandEditingDomain, Diagram, String, LocaleGet the command to set the label (in prameter) of the Diagram for the locale needed (if null, the current must be used)
getTableLabelWithoutNameTableGet the label of the Table without getting its name if label is not available
getTableLabelTableGet the label of the Table or the name if the Table label is not available
setDiagramLabelTable, String, LocaleSet the label (in prameter) of the Table for the locale needed (if null, the current must be used) without using command
getSetTableLabelCommandEditingDomain, Table, String, LocaleGet the command to set the label (in prameter) of the Table for the locale needed (if null, the current must be used)
+

UML Named Elements

+

For the UML NamedElement, to use the internationalization, you just need to:

+
    +
  • add the org.eclipse.papyrus.uml.internationalization.utils dependency
  • +
  • use the UMLLabelInternationalization
  • +
+

The UMLLabelInternationalization class contains following needed methods/functions:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method/FunctionParametersDescription
getInstanceThe the instance of LabelInternationalization
getLabelWithoutNameNamedElementGet the label of the NamedElement without getting its name if label is not available
getLabelNamedElementGet the label of the NamedElement or the name if the NamedElement label is not available
setLabelNamedElement, String, LocaleSet the label (in prameter) of the NamedElement for the locale needed (if null, the current must be used) without using command
getSetLabelCommandEditingDomain, NamedElement, String, LocaleGet the command to set the label (in prameter) of the NamedElement for the locale needed (if null, the current must be used)
getKeywordWithoutNameStereotypeGet the keyword of the Stereotype without getting its name if keyword is not available
getKeywordStereotypeGet the keyword of the Stereotype or the name if the Stereotype keyword is not available
setKeywordStereotype, String, LocaleSet the keyword (in prameter) of the Stereotype for the locale needed (if null, the current must be used) without using command
getSetKeywordCommandEditingDomain, Stereotype, String, LocaleGet the command to set the keyword (in prameter) of the Stereotype for the locale needed (if null, the current must be used)
+

Internationalization preferences

+

Two preferences are managed in the papyrus model:

+
    +
  • useInternationalization: Boolean to determinate if the internationalization must be used
  • +
  • language: String to define the selected language for the internationalization
  • +
+

The preferences are stored as EAnnotation:

+
    +
  • in the notation file in this is a private storage
  • +
  • in the metadata in this is not a private storage
  • +
+

+ Internationalization preferences management +

+

Those preferences are managed in a PreferenceStore in the activator of org.eclipse.papyrus.infra.internationalization.common plugin.

+

Control mode

+

The sub-models are managed with the properties files. + Indeed, when an object is created as sub-model, the key representing this object or its descendance in the properties files must be moved in sub-properties files corresponding to the controlled object. + During this sub-model creation, the qualified names of the keys that are moved change, the new qualified names are calculated from the root of the sub-model.

+

What is it managed

+

The managed files/objects are:

+
    +
  • The properties files and their keys
  • +
  • The notation and the internationalization preferences if this is private storage
  • +
+

How is it managed

+

The org.eclipse.papyrus.infra.internationalization.controlmode manage all the control mode for the internationalization.

+

The properties files are managed by:

+
    +
  • PropertiesControlParticipant and PropertiesUncontrolParticipant for the participants
  • +
  • CreatePropertiesControlResourceCommand which define the command to create the controlled properties file
  • +
  • RemovePropertiesControlResourceCommand which define the command to delete the controlled properties file
  • +
  • ControlPropertiesCommand which define the command to manage the internationalization entries to move into the controlled properties
  • +
+

The notation and the internationalization preference storage are managed by:

+
    +
  • InternationalizationAnnotationControlParticipant for the participant (uncontrolled is not needed because the parent is priority)
  • +
  • InternationalizationAnnotationCommand which define the command to create the internationalization preference into the controlled notation file
  • +
+

Specificities

+

Loading properties resources

+

The properties resources are loaded and managed by the UMLInternationalizationModelResource class. + This UMLInternationalizationModelResource class inherit from InternationalizationModelResource from infra plugins. + The load is managed as 2 steps:

+
    +
  1. Load the file and read the content to create the InternationalizationLibrary with diagrams and tables labels reconciliation with existing diagrams and tables.
  2. +
  3. Loop on content to resolve the UML dependencies in properties files to reference the existing UML objects.
  4. +
+

So, after the load, the resolveable properties are managed as UML object, diagram or table as key of InternationalizationLibrary

+

InternationalizationUMLItemProviderAdapterFactory

+

The InternationalizationUMLItemProviderAdapterFactory extends UMLItemProviderAdapterFactory and allows to redefine the ItemProvider of UML elements to get the papyrus internationalization getLabel instead of UML getLabel.

+

If an ItemProvider of UML element need to be redefined, the ItemProviderAdapterFactory must ihnerit from this class instead of UMLItemProviderAdapterFactory.

+

Diagram and Table owner QualifiedName

+

The diagrams and the tables are managed in the infra plugins, however, the owner of the diagram or table must be serialized in the properties file by its QualifiedName. So the owner QualifiedName is managed by the class QualifiedNameUtils and calculated manually.

+

Editors

+

The diagrams and tables are managed by the internationalization. To do this, the diagram and table editor must inherit from IInternationalizationEditor which allows to modify part name and refresh the editor with the label. + If any new editor is comming with internationalization management, this one must ihnerit from IInternationalizationEditor too.

+ + \ No newline at end of file diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.mediawiki b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.mediawiki new file mode 100644 index 00000000000..608b244fa9b --- /dev/null +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/site/mediawiki/internationalizationDev.mediawiki @@ -0,0 +1,197 @@ += Internationalization = +The internationalization is the way to manage your model with a specific language by labels. Like Eclipse, the internationalization is managed by the 'properties' file which are defined depending language as following (with for example, english language in US country): +* ''modelName'''''_en_US.properties''' +* ''modelName'''''_en.properties''' +* ''modelName'''''.properties''' + +[[Image:images/PropertiesModelExplorer.png|frame|none|Properties files in Model Explorer]] + +== Plugins == +The plugins for the internationalization are the following: +* org.eclipse.papyrus.infra.internationalization: it contains: +** Internationalization Meta-model +** Generated code from the Meta-model +** The model resources for the internationalization entries (key and label of internationalized objects) and internationalization preferences +** Utils classes to manage the labels and the preferences +* org.eclipse.papyrus.infra.internationalization.edit: contains generated edit code from the Meta-model +* org.eclipse.papyrus.infra.internationalization.common: contains all the common classes to manage command modification and some utils for the internationalization preferences. It contains the IInternationalizationEditor interface too which allows to define the editor that can be internationalized. +* org.eclipse.papyrus.infra.internationalization.controlmode: contains the needed elements to manage the control mode for the properties and the preferences files +* org.eclipse.papyrus.infra.internationalization.ui: contains the needed ui classes especially for the internationalization preferences +* org.eclipse.papyrus.infra.internationalization.utils: contains all the needed utils classes to manage the label which can be used to get the diagrams and tables labels +* org.eclipse.papyrus.infra.editor.welcome.internationalization: contains the needed classes to manage the preferences in the welcome page +* org.eclipse.papyrus.uml.internationalization: contains the UML internationalization model resource which can manage the UML elements in the properties file +* org.eclipse.papyrus.uml.internationalization.edit: contains the InternationalizationUMLItemProviderAdapterFactory which define the ItemProvider of UML elements to use the Papyrus getLabel function instead of UML getLabel function +* org.eclipse.papyrus.uml.internationalization.utils: contains all the needed utils classes to manage the label which can be used to get the named elements labels + +== How to use internationalization == +Instead of name, the label of objects must be displayed in Papyrus. + +=== How the labels are managed in properties file === +Each element which have a label must be written in the properties file as following: +* If this is a diagram: +** '''_labelDiagram_'''''DiagramOwnerQualifiedName'''''_label_'''''DiagramName'' '''=''' ''DiagramLabel'' +* If this is a table: +** '''_labelTable_'''''TableOwnerQualifiedName'''''_label_'''''TableName'' '''=''' ''TableLabel'' +* If this is an UML NamedElement: +** '''_label_'''''NamedElementQualifiedName'' '''=''' ''NamedElementLabel'' + +[[Image:images/LabelsInternationalizationExample.png|frame|none|Example of internationalization labels]] + +=== Infra (Diagrams and Tables) === +For the Diagrams and the Tables, UML is not needed. So to use the internationalization, you just need to: +* add the org.eclipse.papyrus.infra.internationalization.utils dependency +* use methods/functions of LabelInternationalization + +The LabelInternationalization class contains the following needed methods/functions: +{| class="wikitable" border="1" +! style="text-align: center;" | Method/Function +! style="text-align: center;" | Parameters +! style="text-align: center;" | Description +|- +! style="font-weight: bold;" | getInstance +| +| The the instance of LabelInternationalization +|- +! style="font-weight: bold;" | getDiagramLabelWithoutName +| Diagram +| Get the label of the diagram without getting its name if label is not available +|- +! style="font-weight: bold;" | getDiagramLabel +| Diagram +| Get the label of the diagram or the name if the diagram label is not available +|- +! style="font-weight: bold;" | setDiagramLabel +| Diagram, String, Locale +| Set the label (in parameter) of the Diagram for the locale needed (if null, the current must be used) without using command +|- +! style="font-weight: bold;" | getSetDiagramLabelCommand +| EditingDomain, Diagram, String, Locale +| Get the command to set the label (in parameter) of the Diagram for the locale needed (if null, the current must be used) +|- +! style="font-weight: bold;" | getTableLabelWithoutName +| Table +| Get the label of the Table without getting its name if label is not available +|- +! style="font-weight: bold;" | getTableLabel +| Table +| Get the label of the Table or the name if the Table label is not available +|- +! style="font-weight: bold;" | setDiagramLabel +| Table, String, Locale +| Set the label (in prameter) of the Table for the locale needed (if null, the current must be used) without using command +|- +! style="font-weight: bold;" | getSetTableLabelCommand +| EditingDomain, Table, String, Locale +| Get the command to set the label (in parameter) of the Table for the locale needed (if null, the current must be used) +|} + +=== UML Named Elements === +For the UML NamedElement, to use the internationalization, you just need to: +* add the org.eclipse.papyrus.uml.internationalization.utils dependency +* use the UMLLabelInternationalization + +The UMLLabelInternationalization class contains following needed methods/functions: +{| class="wikitable" border="1" +! style="text-align: center;" | Method/Function +! style="text-align: center;" | Parameters +! style="text-align: center;" | Description +|- +! style="font-weight: bold;" | getInstance +| +| The the instance of LabelInternationalization +|- +! style="font-weight: bold;" | getLabelWithoutName +| NamedElement +| Get the label of the NamedElement without getting its name if label is not available +|- +! style="font-weight: bold;" | getLabel +| NamedElement +| Get the label of the NamedElement or the name if the NamedElement label is not available +|- +! style="font-weight: bold;" | setLabel +| NamedElement, String, Locale +| Set the label (in parameter) of the NamedElement for the locale needed (if null, the current must be used) without using command +|- +! style="font-weight: bold;" | getSetLabelCommand +| EditingDomain, NamedElement, String, Locale +| Get the command to set the label (in parameter) of the NamedElement for the locale needed (if null, the current must be used) +|- +! style="font-weight: bold;" | getKeywordWithoutName +| Stereotype +| Get the keyword of the Stereotype without getting its name if keyword is not available +|- +! style="font-weight: bold;" | getKeyword +| Stereotype +| Get the keyword of the Stereotype or the name if the Stereotype keyword is not available +|- +! style="font-weight: bold;" | setKeyword +| Stereotype, String, Locale +| Set the keyword (in parameter) of the Stereotype for the locale needed (if null, the current must be used) without using command +|- +! style="font-weight: bold;" | getSetKeywordCommand +| EditingDomain, Stereotype, String, Locale +| Get the command to set the keyword (in parameter) of the Stereotype for the locale needed (if null, the current must be used) +|} + +== Internationalization preferences == +Two preferences are managed in the Papyrus model: +* useInternationalization: Boolean to determinate if the internationalization must be used +* language: String to define the selected language for the internationalization + + +The preferences are stored as EAnnotation: +* in the notation file in this is a private storage +* in the metadata in this is not a private storage + + +[[Image:images/InternationalizationPreferences.png|frame|none|Internationalization preferences management]] + + +Those preferences are managed in a PreferenceStore in the activator of org.eclipse.papyrus.infra.internationalization.common plugin. + +The PapyrusProjectScope allows to manage the preferences for the Eclipse project with Papyrus model name. + +== Control mode == +The sub-models are managed with the properties files. +Indeed, when an object is created as sub-model, the key representing this object or its descendance in the properties files must be moved in sub-properties files corresponding to the controlled object. +During this sub-model creation, the qualified names of the keys that are moved change, the new qualified names are calculated from the root of the sub-model. + +=== What is it managed === +The managed files/objects are: +* The properties files and their keys +* The notation and the internationalization preferences if this is private storage + +=== How is it managed === +The org.eclipse.papyrus.infra.internationalization.controlmode manage all the control mode for the internationalization. + +The properties files are managed by: +* PropertiesControlParticipant and PropertiesUncontrolParticipant for the participants +* CreatePropertiesControlResourceCommand which define the command to create the controlled properties file +* RemovePropertiesControlResourceCommand which define the command to delete the controlled properties file +* ControlPropertiesCommand which define the command to manage the internationalization entries to move into the controlled properties + +The notation and the internationalization preference storage are managed by: +* InternationalizationAnnotationControlParticipant for the participant (uncontrolled is not needed because the parent is priority) +* InternationalizationAnnotationCommand which define the command to create the internationalization preference into the controlled notation file + +== Specificities == +=== Loading properties resources === +The properties resources are loaded and managed by the UMLInternationalizationModelResource class. +This UMLInternationalizationModelResource class inherit from InternationalizationModelResource from infra plugins. +The load is managed as 2 steps: +# Load the file and read the content to create the InternationalizationLibrary with diagrams and tables labels reconciliation with existing diagrams and tables. +# Loop on content to resolve the UML dependencies in properties files to reference the existing UML objects. + +So, after the load, the resolveable properties are managed as UML object, diagram or table as key of InternationalizationLibrary + +=== InternationalizationUMLItemProviderAdapterFactory === +The InternationalizationUMLItemProviderAdapterFactory extends UMLItemProviderAdapterFactory and allows to redefine the ItemProvider of UML elements to get the Papyrus internationalization getLabel instead of UML getLabel. + +If an ItemProvider of UML element needs to be redefined, the ItemProviderAdapterFactory must ihnerit from this class instead of UMLItemProviderAdapterFactory. + +=== Diagram and Table owner QualifiedName === +The diagrams and the tables are managed in the infra plugins, however, the owner of the diagram or table must be serialized in the properties file by its QualifiedName. So the owner QualifiedName is managed by the class QualifiedNameUtils and calculated manually. + +=== Editors === +The diagrams and tables are managed by the internationalization. To do this, the diagram and table editor must inherit from IInternationalizationEditor which allows to modify part name and refresh the editor with the label. +If any new editor is comming with internationalization management, this one must ihnerit from IInternationalizationEditor too. \ No newline at end of file diff --git a/plugins/infra/internationalization/pom.xml b/plugins/infra/internationalization/pom.xml new file mode 100644 index 00000000000..7c0b3134b06 --- /dev/null +++ b/plugins/infra/internationalization/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + org.eclipse.papyrus.infra + org.eclipse.papyrus + 0.0.1-SNAPSHOT + + org.eclipse.papyrus.infra-internationalization + 0.0.1-SNAPSHOT + pom + Papyrus Internationalization + Papyrus Internationalization plugins. + + + org.eclipse.papyrus.infra.internationalization + org.eclipse.papyrus.infra.internationalization.edit + org.eclipse.papyrus.infra.internationalization.utils + org.eclipse.papyrus.infra.internationalization.ui + org.eclipse.papyrus.infra.internationalization.controlmode + org.eclipse.papyrus.infra.internationalization.common + org.eclipse.papyrus.infra.editor.welcome.internationalization + + + + \ No newline at end of file diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF index b6aea445f90..17c21e03b24 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF @@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[3.0.0,4.0.0) org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)" + org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.common;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy Bundle-Version: 3.0.0.qualifier diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java index 0217ee34ffc..9ee5241d252 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java @@ -12,6 +12,7 @@ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr * Christian W. Damus (CEA) - bug 430880 * Christian W. Damus (CEA) - bug 437217 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.nattable.common.editor; @@ -32,6 +33,9 @@ import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; import org.eclipse.papyrus.infra.core.utils.ServiceUtils; import org.eclipse.papyrus.infra.emf.nattable.selection.EObjectSelectionExtractor; +import org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils; import org.eclipse.papyrus.infra.nattable.common.Activator; import org.eclipse.papyrus.infra.nattable.common.utils.TableEditorInput; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; @@ -56,7 +60,7 @@ import org.eclipse.ui.part.EditorPart; * * */ -public abstract class AbstractEMFNattableEditor extends EditorPart implements NavigationTarget { +public abstract class AbstractEMFNattableEditor extends EditorPart implements NavigationTarget, IInternationalizationEditor { /** the service registry */ protected ServicesRegistry servicesRegistry; @@ -88,6 +92,9 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na this.tableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(rawModel, new EObjectSelectionExtractor()); this.synchronizer = new PartNameSynchronizer(rawModel); this.workspacePreferenceStore = getWorkspaceViewerPreferenceStore(); + + // Need to manage the part label synchronizer for the table labels + LabelInternationalizationUtils.managePartLabelSynchronizer(rawModel, this); } /** @@ -106,7 +113,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na // IPath path = Activator.getDefault().getStateLocation(); // String id = getIdStr(this.tableManager.getTable()); // - // String fileName = path.toString() + "/" + id;//$NON-NLS-1$ + // String fileName = path.toString() + "/" + id;//$NON-NLS-1$ // java.io.File file = new File(fileName); // this.workspacePreferenceStore = new PreferenceStore(fileName); // if(file.exists()) { @@ -164,7 +171,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na final TableEditorInput tableEditorInput = new TableEditorInput(this.tableManager.getTable(), getEditingDomain()); setSite(site); setInput(tableEditorInput); - setPartName(this.tableManager.getTable().getName()); + setPartName(LabelInternationalization.getInstance().getTableLabel(this.tableManager.getTable())); } /** @@ -281,7 +288,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na saveLocalPreferenceStoreValues(); this.tableManager.dispose(); this.synchronizer.dispose(); - this.tableManager= null; + this.tableManager = null; this.servicesRegistry = null; this.synchronizer = null; super.dispose(); @@ -323,7 +330,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na @Override public void notifyChanged(final Notification notification) { if (notification.getFeature() == NattableconfigurationPackage.eINSTANCE.getTableNamedElement_Name()) { - setPartName(PartNameSynchronizer.this.papyrusTable.getName()); + setPartName(LabelInternationalization.getInstance().getTableLabel(PartNameSynchronizer.this.papyrusTable)); } } }; @@ -356,12 +363,21 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na // Set new table this.papyrusTable = papyrusTable; // Set editor name - setPartName(papyrusTable.getName()); + setPartName(LabelInternationalization.getInstance().getTableLabel(papyrusTable)); // Listen to name change papyrusTable.eAdapters().add(this.tableNameListener); } } + /** + * @see org.eclipse.ui.part.EditorPart#setPartName(java.lang.String) + * + * @param partName + */ + @Override + public void setPartName(String partName) { + super.setPartName(partName); + } /** * @@ -414,4 +430,24 @@ public abstract class AbstractEMFNattableEditor extends EditorPart implements Na public TransactionalEditingDomain getTableContextEditingDomain() { return TableEditingDomainUtils.getTableContextEditingDomain(getTable()); } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor#modifyPartName(java.lang.String) + */ + @Override + public void modifyPartName(final String name) { + setPartName(name); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.internationalization.common.editor.IInternationalizationEditor#refreshEditorPart() + */ + @Override + public void refreshEditorPart(){ + // We don't need to refresh the editor part, the table is refreshed alone + } } diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/factory/AbstractNattableEditorFactory.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/factory/AbstractNattableEditorFactory.java index 1e2688b3a99..70d7796647d 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/factory/AbstractNattableEditorFactory.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/factory/AbstractNattableEditorFactory.java @@ -1,234 +1,236 @@ -/***************************************************************************** - * Copyright (c) 2011, 2014 LIFL, CEA LIST, and others. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation - * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr - * Christian W. Damus (CEA) - bug 392301 - * - *****************************************************************************/ -package org.eclipse.papyrus.infra.nattable.common.factory; - -import java.lang.reflect.Constructor; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.infra.core.editor.BackboneException; -import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; -import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.core.services.ServicesRegistry; -import org.eclipse.papyrus.infra.nattable.Activator; -import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.ui.extension.diagrameditor.AbstractEditorFactory; -import org.eclipse.papyrus.infra.ui.multidiagram.actionbarcontributor.ActionBarContributorRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * Abstract factory for the NattableEditor - * - * - * - */ -public abstract class AbstractNattableEditorFactory extends AbstractEditorFactory { - - /** - * - * Constructor. - * - * @param editorClass - * the editor class - * @param editorType - * the type of editor - */ - public AbstractNattableEditorFactory(Class editorClass, String editorType) { - super(editorClass, editorType); - } - - /** - * Create the IPageModel that is used by the SashWindows to manage the editor. - * - * @see org.eclipse.papyrus.infra.ui.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object) - * - * @param pageIdentifier - * The model pushed in the sashmodel by the creation command - * @return A model implementing the IPageModel - */ - @Override - public IPageModel createIPageModel(Object pageIdentifier) { - return new NattableEditorModel(pageIdentifier, getServiceRegistry()); - } - - /** - * @see org.eclipse.papyrus.infra.ui.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - @Override - public boolean isPageModelFactoryFor(Object pageIdentifier) { - if (pageIdentifier instanceof Table) { - return getExpectedType().equals(((Table) pageIdentifier).getTableConfiguration().getType().trim()); - } - return false; - } - - /** - * IEditorModel used internally by the SashContainer. This model know how to handle IEditor creation. - * - * @author cedric dumoulin - * - */ - class NattableEditorModel implements IEditorModel { - - - /** - * The servicesRegistry provided at creation. - */ - private ServicesRegistry servicesRegistry; - - /** - * The created editor. - */ - private IEditorPart editor; - - /** - * The raw model stored in the SashProvider. - */ - private Table rawModel; - - private Image tabIcon; - - /** - * - * Constructor. - */ - public NattableEditorModel(Object pageIdentifier, ServicesRegistry servicesRegistry) { - this.rawModel = (Table) pageIdentifier; - this.servicesRegistry = servicesRegistry; - } - - /** - * Create the IEditor for the diagram. - * - * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart() - * @return - * @throws PartInitException - * - */ - @Override - public IEditorPart createIEditorPart() throws PartInitException { - try { - - Constructor c = getDiagramClass().getConstructor(ServicesRegistry.class, Table.class); - IEditorPart newEditor = (IEditorPart) c.newInstance(this.servicesRegistry, this.rawModel); - // IEditorPart newEditor = new DefaultNattableEditor(getServiceRegistry(), rawModel); - this.editor = newEditor; - return this.editor; - - } catch (Exception e) { - // Lets propagate. This is an implementation problem that should be solved by - // programmer. - throw new PartInitException("Can't create Nattable", e); //$NON-NLS-1$ - } - - } - - /** - * Get the action bar requested by the Editor. - * - * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor() - * @return - * - */ - @Override - public EditorActionBarContributor getActionBarContributor() { - - String actionBarId = AbstractNattableEditorFactory.this.editorDescriptor.getActionBarContributorId(); - - // Do nothing if no EditorActionBarContributor is specify. - if (actionBarId == null || actionBarId.length() == 0) { - return null; - } - - // Try to get it. - - // Get ServiceRegistry - // ServicesRegistry serviceRegistry = getServicesRegistry(); - ActionBarContributorRegistry registry; - try { - registry = this.servicesRegistry.getService(ActionBarContributorRegistry.class); - } catch (ServiceException e) { - // Service not found - Activator.log.error(e); - return null; - } - - try { - return registry.getActionBarContributor(actionBarId); - } catch (BackboneException e) { - Activator.log.error(e); - return null; - } - } - - /** - * Get the underlying RawModel. Return the Diagram. - * - * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel() - * @return - * - */ - @Override - public Object getRawModel() { - return this.rawModel; - } - - /** - * Get the icon to be shown by Tabs - * - * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon() - * @return - * - */ - @Override - public Image getTabIcon() { - if (tabIcon == null) { - ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon(); - if (imageDescriptor != null) { - tabIcon = imageDescriptor.createImage(); - } - } - - return tabIcon; - } - - /** - * Get the title of the Diagram. - * - * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle() - * @return - * - */ - @Override - public String getTabTitle() { - return this.rawModel.getName(); - } - - @Override - public void dispose() { - if (tabIcon != null) { - tabIcon.dispose(); - tabIcon = null; - } - } - } -} +/***************************************************************************** + * Copyright (c) 2011, 2014 LIFL, CEA LIST, and others. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation + * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr + * Christian W. Damus (CEA) - bug 392301 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.common.factory; + +import java.lang.reflect.Constructor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.papyrus.infra.core.editor.BackboneException; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel; +import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.nattable.Activator; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.ui.extension.diagrameditor.AbstractEditorFactory; +import org.eclipse.papyrus.infra.ui.multidiagram.actionbarcontributor.ActionBarContributorRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorActionBarContributor; + +/** + * Abstract factory for the NattableEditor + * + * + * + */ +public abstract class AbstractNattableEditorFactory extends AbstractEditorFactory { + + /** + * + * Constructor. + * + * @param editorClass + * the editor class + * @param editorType + * the type of editor + */ + public AbstractNattableEditorFactory(Class editorClass, String editorType) { + super(editorClass, editorType); + } + + /** + * Create the IPageModel that is used by the SashWindows to manage the editor. + * + * @see org.eclipse.papyrus.infra.ui.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object) + * + * @param pageIdentifier + * The model pushed in the sashmodel by the creation command + * @return A model implementing the IPageModel + */ + @Override + public IPageModel createIPageModel(Object pageIdentifier) { + return new NattableEditorModel(pageIdentifier, getServiceRegistry()); + } + + /** + * @see org.eclipse.papyrus.infra.ui.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object) + * + * @param pageIdentifier + * @return + */ + @Override + public boolean isPageModelFactoryFor(Object pageIdentifier) { + if (pageIdentifier instanceof Table) { + return getExpectedType().equals(((Table) pageIdentifier).getTableConfiguration().getType().trim()); + } + return false; + } + + /** + * IEditorModel used internally by the SashContainer. This model know how to handle IEditor creation. + * + * @author cedric dumoulin + * + */ + class NattableEditorModel implements IEditorModel { + + + /** + * The servicesRegistry provided at creation. + */ + private ServicesRegistry servicesRegistry; + + /** + * The created editor. + */ + private IEditorPart editor; + + /** + * The raw model stored in the SashProvider. + */ + private Table rawModel; + + private Image tabIcon; + + /** + * + * Constructor. + */ + public NattableEditorModel(Object pageIdentifier, ServicesRegistry servicesRegistry) { + this.rawModel = (Table) pageIdentifier; + this.servicesRegistry = servicesRegistry; + } + + /** + * Create the IEditor for the diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart() + * @return + * @throws PartInitException + * + */ + @Override + public IEditorPart createIEditorPart() throws PartInitException { + try { + + Constructor c = getDiagramClass().getConstructor(ServicesRegistry.class, Table.class); + IEditorPart newEditor = (IEditorPart) c.newInstance(this.servicesRegistry, this.rawModel); + // IEditorPart newEditor = new DefaultNattableEditor(getServiceRegistry(), rawModel); + this.editor = newEditor; + return this.editor; + + } catch (Exception e) { + // Lets propagate. This is an implementation problem that should be solved by + // programmer. + throw new PartInitException("Can't create Nattable", e); //$NON-NLS-1$ + } + + } + + /** + * Get the action bar requested by the Editor. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor() + * @return + * + */ + @Override + public EditorActionBarContributor getActionBarContributor() { + + String actionBarId = AbstractNattableEditorFactory.this.editorDescriptor.getActionBarContributorId(); + + // Do nothing if no EditorActionBarContributor is specify. + if (actionBarId == null || actionBarId.length() == 0) { + return null; + } + + // Try to get it. + + // Get ServiceRegistry + // ServicesRegistry serviceRegistry = getServicesRegistry(); + ActionBarContributorRegistry registry; + try { + registry = this.servicesRegistry.getService(ActionBarContributorRegistry.class); + } catch (ServiceException e) { + // Service not found + Activator.log.error(e); + return null; + } + + try { + return registry.getActionBarContributor(actionBarId); + } catch (BackboneException e) { + Activator.log.error(e); + return null; + } + } + + /** + * Get the underlying RawModel. Return the Diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel() + * @return + * + */ + @Override + public Object getRawModel() { + return this.rawModel; + } + + /** + * Get the icon to be shown by Tabs + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon() + * @return + * + */ + @Override + public Image getTabIcon() { + if (tabIcon == null) { + ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon(); + if (imageDescriptor != null) { + tabIcon = imageDescriptor.createImage(); + } + } + + return tabIcon; + } + + /** + * Get the title of the Diagram. + * + * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle() + * @return + * + */ + @Override + public String getTabTitle() { + return LabelInternationalization.getInstance().getTableLabel(this.rawModel); + } + + @Override + public void dispose() { + if (tabIcon != null) { + tabIcon.dispose(); + tabIcon = null; + } + } + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/RenameTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/RenameTableHandler.java index b59a54eb150..5a14f3dbefb 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/RenameTableHandler.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/RenameTableHandler.java @@ -1,171 +1,184 @@ -/***************************************************************************** - * Copyright (c) 2013 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.infra.nattable.common.handlers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.expressions.IEvaluationContext; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.nattable.common.messages.Messages; -import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; -import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; - -/** - * This handler allows to rename a Papyrus Table. The handler is activated when - * the active editor is a Papyrus NatTableEditor. - * - * @author Camille Letavernier - * - */ -public class RenameTableHandler extends AbstractHandler { - - public static final String NEW_TABLE_NAME = Messages.RenameTableHandler_NewName; - - public static final String RENAME_AN_EXISTING_TABLE = Messages.RenameTableHandler_RenameAnExistingTable; - - /** - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * @param event - * @return - * @throws ExecutionException - * - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - executeTransaction(event); - - return null; - } - - /** - * Execute as transaction - * - * @param event - */ - private void executeTransaction(ExecutionEvent event) { - - // Get requested objects - final INattableModelManager tableManager; - try { - IEvaluationContext context = getIEvaluationContext(event); - tableManager = lookupTableManager(context); - } catch (ServiceException e) { - // silently fails - return; - } - - if (tableManager == null) { - return; - } - - // Open the dialog to ask the new name - String currentName = tableManager.getTableName(); - String newName = null; - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), RENAME_AN_EXISTING_TABLE, NEW_TABLE_NAME, currentName, null); - if (dialog.open() == Window.OK) { - newName = dialog.getValue(); - if (newName == null || newName.length() <= 0) { - return; - } - } else { - // cancelled - return; - } - - tableManager.setTableName(newName); - } - - /** - * Get the name used in the {@link RecordingCommand}. This name will be - * visible in undo/redo. - * - * @return The command name to show. - */ - public String getCommandName() { - return "Rename Table"; //$NON-NLS-1$ - } - - protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) { - if (event.getApplicationContext() instanceof IEvaluationContext) { - return (IEvaluationContext) event.getApplicationContext(); - } - return null; - - } - - /** - * Get the Table model element. This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. - * - * @return The current table - * @throws ServiceException - */ - protected INattableModelManager lookupTableManager(IEvaluationContext context) throws ServiceException { - IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(IMultiDiagramEditor.class, context); - - INattableModelManager tableManager = editor.getAdapter(INattableModelManager.class); - return tableManager; - } - - /** - * Try to lookup the TransactionalEditingDomain. - * - * @return - * @throws ServiceException - * If the Editing domain can't be found. - */ - protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException { - - // Get page from the event ! - // IWorkbenchPage page = - // HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); - - return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); - } - - /** - * Called by framework. Need to set the enabled flag. - * - * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) - * - * @param evaluationContext - */ - @Override - public void setEnabled(Object evaluationContext) { - if (!(evaluationContext instanceof IEvaluationContext)) { - setBaseEnabled(false); - return; - } - - IEvaluationContext context = (IEvaluationContext) evaluationContext; - - try { - // Try to get the Table - setBaseEnabled(lookupTableManager(context) != null); - return; - } catch (ServiceException e) { - // Can't find ServiceRegistry: disable - } - - // In all other cases - setBaseEnabled(false); - } -} +/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.common.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils; +import org.eclipse.papyrus.infra.nattable.common.messages.Messages; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; +import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IEditorPart; + +/** + * This handler allows to rename a Papyrus Table. The handler is activated when + * the active editor is a Papyrus NatTableEditor. + * + * @author Camille Letavernier + * + */ +public class RenameTableHandler extends AbstractHandler { + + public static final String NEW_TABLE_NAME = Messages.RenameTableHandler_NewName; + + public static final String RENAME_AN_EXISTING_TABLE = Messages.RenameTableHandler_RenameAnExistingTable; + + /** + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) + * @param event + * @return + * @throws ExecutionException + * + */ + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + executeTransaction(event); + + return null; + } + + /** + * Execute as transaction + * + * @param event + */ + private void executeTransaction(ExecutionEvent event) { + + // Get requested objects + final INattableModelManager tableManager; + try { + IEvaluationContext context = getIEvaluationContext(event); + tableManager = lookupTableManager(context); + } catch (ServiceException e) { + // silently fails + return; + } + + if (tableManager == null) { + return; + } + + final String tableLabel = LabelInternationalization.getInstance().getTableLabelWithoutName(tableManager.getTable()); + if(null != tableLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(tableManager.getTable())){ + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename table label", "New label:", tableLabel, null); //$NON-NLS-1$ //$NON-NLS-2$ + if (Window.OK == dialog.open()) { + final String label = dialog.getValue(); + + tableManager.setTableLabel(label); + } + }else{ + // Open the dialog to ask the new name + String currentName = tableManager.getTableName(); + String newName = null; + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), RENAME_AN_EXISTING_TABLE, NEW_TABLE_NAME, currentName, null); + if (dialog.open() == Window.OK) { + newName = dialog.getValue(); + if (newName == null || newName.length() <= 0) { + return; + } + } else { + // cancelled + return; + } + + tableManager.setTableName(newName); + } + } + + /** + * Get the name used in the {@link RecordingCommand}. This name will be + * visible in undo/redo. + * + * @return The command name to show. + */ + public String getCommandName() { + return "Rename Table"; //$NON-NLS-1$ + } + + protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) { + if (event.getApplicationContext() instanceof IEvaluationContext) { + return (IEvaluationContext) event.getApplicationContext(); + } + return null; + + } + + /** + * Get the Table model element. This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. + * + * @return The current table + * @throws ServiceException + */ + protected INattableModelManager lookupTableManager(IEvaluationContext context) throws ServiceException { + IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(IMultiDiagramEditor.class, context); + + INattableModelManager tableManager = editor.getAdapter(INattableModelManager.class); + return tableManager; + } + + /** + * Try to lookup the TransactionalEditingDomain. + * + * @return + * @throws ServiceException + * If the Editing domain can't be found. + */ + protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException { + + // Get page from the event ! + // IWorkbenchPage page = + // HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); + + return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); + } + + /** + * Called by framework. Need to set the enabled flag. + * + * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) + * + * @param evaluationContext + */ + @Override + public void setEnabled(Object evaluationContext) { + if (!(evaluationContext instanceof IEvaluationContext)) { + setBaseEnabled(false); + return; + } + + IEvaluationContext context = (IEvaluationContext) evaluationContext; + + try { + // Try to get the Table + setBaseEnabled(lookupTableManager(context) != null); + return; + } catch (ServiceException e) { + // Can't find ServiceRegistry: disable + } + + // In all other cases + setBaseEnabled(false); + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF index 5d9ae837ce9..cad92805ca5 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF @@ -1,7 +1,8 @@ Manifest-Version: 1.0 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)", org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)";visibility:=reexport, - org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport + org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Export-Package: org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.provider, org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.provider, org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.provider, diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/provider/TableItemProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/provider/TableItemProvider.java index 9b9d211c77a..05f4113984c 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/provider/TableItemProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/provider/TableItemProvider.java @@ -1,396 +1,397 @@ -/** - * Copyright (c) 2013 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - */ -package org.eclipse.papyrus.infra.nattable.model.nattable.provider; - - -import java.util.Collection; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.ResourceLocator; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; -import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; -import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; -import org.eclipse.emf.edit.provider.ViewerNotification; -import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; -import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderFactory; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecell.NattablecellFactory; -import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.provider.TableNamedElementItemProvider; - -/** - * This is the item provider adapter for a {@link org.eclipse.papyrus.infra.nattable.model.nattable.Table} object. - * - * - * @generated - */ -public class TableItemProvider extends TableNamedElementItemProvider { - /** - * This constructs an instance from a factory and a notifier. - * - * - * @generated - */ - public TableItemProvider(AdapterFactory adapterFactory) { - super(adapterFactory); - } - - /** - * This returns the property descriptors for the adapted class. - * - * - * @generated - */ - @Override - public List getPropertyDescriptors(Object object) { - if (itemPropertyDescriptors == null) { - super.getPropertyDescriptors(object); - - addContextPropertyDescriptor(object); - addOwnerPropertyDescriptor(object); - addPrototypePropertyDescriptor(object); - addTableConfigurationPropertyDescriptor(object); - addInvertAxisPropertyDescriptor(object); - addCurrentRowAxisProviderPropertyDescriptor(object); - addCurrentColumnAxisProviderPropertyDescriptor(object); - } - return itemPropertyDescriptors; - } - - /** - * This adds a property descriptor for the Context feature. - * - * - * @generated - */ - protected void addContextPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_context_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_context_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__CONTEXT, - true, - false, - true, - null, - null, - null)); - } - - /** - * This adds a property descriptor for the Owner feature. - * - * - * @generated - */ - protected void addOwnerPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_owner_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_owner_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__OWNER, - true, - false, - true, - null, - null, - null)); - } - - /** - * This adds a property descriptor for the Prototype feature. - * - * - * @generated - */ - protected void addPrototypePropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_prototype_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_prototype_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__PROTOTYPE, - true, - false, - true, - null, - null, - null)); - } - - /** - * This adds a property descriptor for the Table Configuration feature. - * - * - * @generated - */ - protected void addTableConfigurationPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_tableConfiguration_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_tableConfiguration_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__TABLE_CONFIGURATION, - true, - false, - true, - null, - null, - null)); - } - - /** - * This adds a property descriptor for the Invert Axis feature. - * - * - * @generated - */ - protected void addInvertAxisPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_invertAxis_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_invertAxis_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__INVERT_AXIS, - true, - false, - false, - ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, - null, - null)); - } - - /** - * This adds a property descriptor for the Current Row Axis Provider feature. - * - * - * @generated - */ - protected void addCurrentRowAxisProviderPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_currentRowAxisProvider_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_currentRowAxisProvider_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__CURRENT_ROW_AXIS_PROVIDER, - true, - false, - true, - null, - null, - null)); - } - - /** - * This adds a property descriptor for the Current Column Axis Provider feature. - * - * - * @generated - */ - protected void addCurrentColumnAxisProviderPropertyDescriptor(Object object) { - itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_Table_currentColumnAxisProvider_feature"), //$NON-NLS-1$ - getString("_UI_PropertyDescriptor_description", "_UI_Table_currentColumnAxisProvider_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - NattablePackage.Literals.TABLE__CURRENT_COLUMN_AXIS_PROVIDER, - true, - false, - true, - null, - null, - null)); - } - - /** - * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an - * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or - * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. - * - * - * @generated - */ - @Override - public Collection getChildrenFeatures(Object object) { - if (childrenFeatures == null) { - super.getChildrenFeatures(object); - childrenFeatures.add(NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY); - childrenFeatures.add(NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY); - childrenFeatures.add(NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION); - childrenFeatures.add(NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION); - childrenFeatures.add(NattablePackage.Literals.TABLE__CELLS); - } - return childrenFeatures; - } - - /** - * - * - * @generated - */ - @Override - protected EStructuralFeature getChildFeature(Object object, Object child) { - // Check the type of the specified child object and return the proper feature to use for - // adding (see {@link AddCommand}) it as a child. - - return super.getChildFeature(object, child); - } - - /** - * This returns Table.gif. - * - * - * @generated - */ - @Override - public Object getImage(Object object) { - return overlayImage(object, getResourceLocator().getImage("full/obj16/Table")); //$NON-NLS-1$ - } - - /** - * This returns the label text for the adapted class. - * - * - * @generated - */ - @Override - public String getText(Object object) { - String label = ((Table)object).getName(); - return label == null || label.length() == 0 ? - getString("_UI_Table_type") : //$NON-NLS-1$ - getString("_UI_Table_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ - } - - - /** - * This handles model notifications by calling {@link #updateChildren} to update any cached - * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. - * - * - * @generated - */ - @Override - public void notifyChanged(Notification notification) { - updateChildren(notification); - - switch (notification.getFeatureID(Table.class)) { - case NattablePackage.TABLE__INVERT_AXIS: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); - return; - case NattablePackage.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY: - case NattablePackage.TABLE__ROW_AXIS_PROVIDERS_HISTORY: - case NattablePackage.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION: - case NattablePackage.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION: - case NattablePackage.TABLE__CELLS: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); - return; - } - super.notifyChanged(notification); - } - - /** - * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children - * that can be created under this object. - * - * - * @generated - */ - @Override - protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { - super.collectNewChildDescriptors(newChildDescriptors, object); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY, - NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY, - NattableaxisproviderFactory.eINSTANCE.createMasterObjectAxisProvider())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY, - NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY, - NattableaxisproviderFactory.eINSTANCE.createMasterObjectAxisProvider())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION, - NattableaxisconfigurationFactory.eINSTANCE.createLocalTableHeaderAxisConfiguration())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION, - NattableaxisconfigurationFactory.eINSTANCE.createLocalTableHeaderAxisConfiguration())); - - newChildDescriptors.add - (createChildParameter - (NattablePackage.Literals.TABLE__CELLS, - NattablecellFactory.eINSTANCE.createCell())); - } - - /** - * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. - * - * - * @generated - */ - @Override - public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) { - Object childFeature = feature; - Object childObject = child; - - boolean qualify = - childFeature == NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY || - childFeature == NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY || - childFeature == NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION || - childFeature == NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION; - - if (qualify) { - return getString - ("_UI_CreateChild_text2", //$NON-NLS-1$ - new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); - } - return super.getCreateChildText(owner, feature, child, selection); - } - - /** - * Return the resource locator for this item provider's resources. - * - * - * @generated - */ - @Override - public ResourceLocator getResourceLocator() { - return NattableEditPlugin.INSTANCE; - } - -} +/** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + */ +package org.eclipse.papyrus.infra.nattable.model.nattable.provider; + + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.ResourceLocator; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ViewerNotification; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderFactory; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecell.NattablecellFactory; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.provider.TableNamedElementItemProvider; + +/** + * This is the item provider adapter for a {@link org.eclipse.papyrus.infra.nattable.model.nattable.Table} object. + * + * + * @generated + */ +public class TableItemProvider extends TableNamedElementItemProvider { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public TableItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addContextPropertyDescriptor(object); + addOwnerPropertyDescriptor(object); + addPrototypePropertyDescriptor(object); + addTableConfigurationPropertyDescriptor(object); + addInvertAxisPropertyDescriptor(object); + addCurrentRowAxisProviderPropertyDescriptor(object); + addCurrentColumnAxisProviderPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Context feature. + * + * + * @generated + */ + protected void addContextPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_context_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_context_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__CONTEXT, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Owner feature. + * + * + * @generated + */ + protected void addOwnerPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_owner_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_owner_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__OWNER, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Prototype feature. + * + * + * @generated + */ + protected void addPrototypePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_prototype_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_prototype_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__PROTOTYPE, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Table Configuration feature. + * + * + * @generated + */ + protected void addTableConfigurationPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_tableConfiguration_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_tableConfiguration_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__TABLE_CONFIGURATION, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Invert Axis feature. + * + * + * @generated + */ + protected void addInvertAxisPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_invertAxis_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_invertAxis_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__INVERT_AXIS, + true, + false, + false, + ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Current Row Axis Provider feature. + * + * + * @generated + */ + protected void addCurrentRowAxisProviderPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_currentRowAxisProvider_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_currentRowAxisProvider_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__CURRENT_ROW_AXIS_PROVIDER, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Current Column Axis Provider feature. + * + * + * @generated + */ + protected void addCurrentColumnAxisProviderPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Table_currentColumnAxisProvider_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Table_currentColumnAxisProvider_feature", "_UI_Table_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + NattablePackage.Literals.TABLE__CURRENT_COLUMN_AXIS_PROVIDER, + true, + false, + true, + null, + null, + null)); + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (childrenFeatures == null) { + super.getChildrenFeatures(object); + childrenFeatures.add(NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY); + childrenFeatures.add(NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY); + childrenFeatures.add(NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION); + childrenFeatures.add(NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION); + childrenFeatures.add(NattablePackage.Literals.TABLE__CELLS); + } + return childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns Table.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/Table")); //$NON-NLS-1$ + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated NOT + */ + @Override + public String getText(Object object) { + String label = LabelInternationalization.getInstance().getTableLabel((Table)object); + return label == null || label.length() == 0 ? + getString("_UI_Table_type") : //$NON-NLS-1$ + getString("_UI_Table_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } + + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(Table.class)) { + case NattablePackage.TABLE__INVERT_AXIS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + case NattablePackage.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY: + case NattablePackage.TABLE__ROW_AXIS_PROVIDERS_HISTORY: + case NattablePackage.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION: + case NattablePackage.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION: + case NattablePackage.TABLE__CELLS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY, + NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY, + NattableaxisproviderFactory.eINSTANCE.createMasterObjectAxisProvider())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY, + NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY, + NattableaxisproviderFactory.eINSTANCE.createMasterObjectAxisProvider())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION, + NattableaxisconfigurationFactory.eINSTANCE.createLocalTableHeaderAxisConfiguration())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION, + NattableaxisconfigurationFactory.eINSTANCE.createLocalTableHeaderAxisConfiguration())); + + newChildDescriptors.add + (createChildParameter + (NattablePackage.Literals.TABLE__CELLS, + NattablecellFactory.eINSTANCE.createCell())); + } + + /** + * This returns the label text for {@link org.eclipse.emf.edit.command.CreateChildCommand}. + * + * + * @generated + */ + @Override + public String getCreateChildText(Object owner, Object feature, Object child, Collection selection) { + Object childFeature = feature; + Object childObject = child; + + boolean qualify = + childFeature == NattablePackage.Literals.TABLE__COLUMN_AXIS_PROVIDERS_HISTORY || + childFeature == NattablePackage.Literals.TABLE__ROW_AXIS_PROVIDERS_HISTORY || + childFeature == NattablePackage.Literals.TABLE__LOCAL_ROW_HEADER_AXIS_CONFIGURATION || + childFeature == NattablePackage.Literals.TABLE__LOCAL_COLUMN_HEADER_AXIS_CONFIGURATION; + + if (qualify) { + return getString + ("_UI_CreateChild_text2", //$NON-NLS-1$ + new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) }); + } + return super.getCreateChildText(owner, feature, child, selection); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return NattableEditPlugin.INSTANCE; + } + +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF index 829b9e13a9a..8b10a6fef59 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0, org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.extensionpoints.editors;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)" + org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-Version: 3.0.0.qualifier Bundle-Activator: org.eclipse.papyrus.infra.nattable.modelexplorer.Activator diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java index a1623c64850..097ef1f69fa 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/src/org/eclipse/papyrus/infra/nattable/modelexplorer/handlers/RenameTableHandler.java @@ -9,12 +9,14 @@ * Contributors: * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation * Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.nattable.modelexplorer.handlers; import java.util.List; +import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.expressions.IEvaluationContext; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; @@ -28,6 +30,8 @@ import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.window.Window; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; import org.eclipse.papyrus.infra.nattable.modelexplorer.messages.Messages; import org.eclipse.papyrus.views.modelexplorer.DirectEditorEditingSupport; @@ -48,18 +52,18 @@ public class RenameTableHandler extends AbstractTableCommandHandler { if (editingDomain != null && tables.size() == 1) { final Table table = tables.get(0); - final String currentName = table.getName(); - if (currentName != null) { - - AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameTableCommand", null) { //$NON-NLS-1$ - + + final String tableLabel = LabelInternationalization.getInstance().getTableLabelWithoutName(table); + if(null != tableLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(table)){ + AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "ChangeTableLabelCommand", null) { //$NON-NLS-1$ + @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) { - InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameTableHandler_RenameAnExistingTable, Messages.RenameTableHandler_NewName, currentName, null); - if (dialog.open() == Window.OK) { - final String name = dialog.getValue(); - if (name != null && name.length() > 0) { - table.setName(name); + protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException { + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename table label...", "New label:", tableLabel, null); //$NON-NLS-1$ //$NON-NLS-2$ + if (Window.OK == dialog.open()) { + final String label = dialog.getValue(); + if (label != null && label.length() > 0) { + LabelInternationalization.getInstance().setTableLabel(table, label, null); } return CommandResult.newOKCommandResult(); } else { @@ -68,6 +72,28 @@ public class RenameTableHandler extends AbstractTableCommandHandler { } }; return new GMFtoEMFCommandWrapper(cmd); + }else{ + final String currentName = table.getName(); + if (currentName != null) { + + AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameTableCommand", null) { //$NON-NLS-1$ + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) { + InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameTableHandler_RenameAnExistingTable, Messages.RenameTableHandler_NewName, currentName, null); + if (dialog.open() == Window.OK) { + final String name = dialog.getValue(); + if (name != null && name.length() > 0) { + table.setName(name); + } + return CommandResult.newOKCommandResult(); + } else { + return CommandResult.newCancelledCommandResult(); + } + } + }; + return new GMFtoEMFCommandWrapper(cmd); + } } } return UnexecutableCommand.INSTANCE; diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF index 66893c61ae5..9c025454ff0 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF @@ -6,7 +6,9 @@ Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3 org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)", org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)" + org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy Bundle-Version: 2.2.0.qualifier diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInFlatTable.xwt b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInFlatTable.xwt index 4bf9e016758..0fc1e2013dd 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInFlatTable.xwt +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInFlatTable.xwt @@ -8,10 +8,17 @@ - + + + + + + + diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInTreeTable.xwt b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInTreeTable.xwt index f39d3fb7204..1e2d8ba91ed 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInTreeTable.xwt +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/EObjectInTreeTable.xwt @@ -8,10 +8,17 @@ - + + property="EObjectInTable:TableNamedElement:name"> + + + + + + diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/SingleTable.xwt b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/SingleTable.xwt index 0452f5604a9..034fdb13d6f 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/SingleTable.xwt +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/model/ui/SingleTable.xwt @@ -8,10 +8,17 @@ - + + + + + + + objectsToAdd, final int index); + /** + * This allows to set the label of a table. + * + * @param label The new label. + */ + public void setTableLabel(final String label); + public void setTableName(String name); public String getTableName(); diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java index 5eba65507c7..fc7ad24bc4c 100755 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java @@ -9,7 +9,7 @@ * * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618, 496905 * Nicolas Boulay (Esterel Technologies SAS) - Bug 497467 * Sebastien Bordes (Esterel Technologies SAS) - Bug 497738 * @@ -70,6 +70,7 @@ import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; import org.eclipse.nebula.widgets.nattable.style.DisplayMode; import org.eclipse.nebula.widgets.nattable.ui.NatEventData; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; import org.eclipse.papyrus.infra.nattable.Activator; import org.eclipse.papyrus.infra.nattable.command.CommandIds; import org.eclipse.papyrus.infra.nattable.dialog.DisplayedAxisSelectorDialog; @@ -1765,6 +1766,15 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen return this.rowManager; } + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#setTableLabel(java.lang.String) + */ + @Override + public void setTableLabel(final String label) { + getTableEditingDomain().getCommandStack().execute(LabelInternationalization.getInstance().getSetTableLabelCommand(getTableEditingDomain(), getTable(), label, null)); + } @Override public void setTableName(final String name) { diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java index f5383eecc89..00e72f39c5f 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java @@ -1,61 +1,82 @@ -/***************************************************************************** - * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation - * Christian W. Damus - bug 474467 - * - *****************************************************************************/ -package org.eclipse.papyrus.infra.nattable.provider; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider; -import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototypeLabelProvider; -import org.eclipse.swt.graphics.Image; - -/** - * - * This labelprovider provides icon and text for tables to display them in treeviewer AND in the property view - * - */ -public class TableLabelProvider extends ViewPrototypeLabelProvider implements IFilteredLabelProvider { - - @Override - public boolean accept(Object object) { - if (object instanceof IStructuredSelection) { - return accept((IStructuredSelection) object); - } - - boolean result = EMFHelper.getEObject(object) instanceof Table; - return result; - } - - /** - * - * @param selection - * a selection - * @return - * true if all elements in the selection are accepted - */ - protected boolean accept(final IStructuredSelection selection) { - for (final Object current : selection.toList()) { - if (!accept(current)) { - return false; - } - } - return true; - } - - @Override - protected Image getNonCommonIcon(final Object commonObject) { - return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(org.eclipse.papyrus.infra.nattable.Activator.PLUGIN_ID, "/icons/table.gif"); - } - -} +/***************************************************************************** + * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation + * Christian W. Damus - bug 474467 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.provider; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider; +import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototypeLabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * + * This labelprovider provides icon and text for tables to display them in treeviewer AND in the property view + * + */ +public class TableLabelProvider extends ViewPrototypeLabelProvider implements IFilteredLabelProvider { + + @Override + public boolean accept(Object object) { + if (object instanceof IStructuredSelection) { + return accept((IStructuredSelection) object); + } + + boolean result = EMFHelper.getEObject(object) instanceof Table; + return result; + } + + /** + * + * @param selection + * a selection + * @return + * true if all elements in the selection are accepted + */ + protected boolean accept(final IStructuredSelection selection) { + for (final Object current : selection.toList()) { + if (!accept(current)) { + return false; + } + } + return true; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider#getText(java.lang.Object) + */ + @Override + public String getText(Object element) { + String result = null; + + // return the internationalization of the table if this is the case + EObject eObject = EMFHelper.getEObject(element); + if (eObject instanceof Table) { + result = LabelInternationalization.getInstance().getTableLabel((Table) eObject); + } + + return null != result ? result : super.getText(element); + } + + @Override + protected Image getNonCommonIcon(final Object commonObject) { + return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(org.eclipse.papyrus.infra.nattable.Activator.PLUGIN_ID, "/icons/table.gif"); + } + +} diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF index 41670ccc965..a9e86595a7e 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Export-Package: org.eclipse.papyrus.infra.onefile.model, org.eclipse.papyrus.infra.onefile.utils Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="[2.0.0,3.0.0)", org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport, - org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)";visibility:=reexport + org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)";visibility:=reexport, + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 2.0.0.qualifier diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java index e7888b7cfa7..f5fc561112a 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/PapyrusFile.java @@ -8,10 +8,15 @@ * * Contributors: * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * *****************************************************************************/ package org.eclipse.papyrus.infra.onefile.model.impl; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Locale; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -19,6 +24,8 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.core.Activator; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils; @@ -44,12 +51,39 @@ public class PapyrusFile implements IPapyrusFile { public IResource[] getAssociatedResources() { ArrayList files = new ArrayList(); try { - for (IResource res : file.getParent().members()) { - if (res instanceof IFile && OneFileUtils.withoutFileExtension(file).equals(OneFileUtils.withoutFileExtension(res))) { - files.add(res); + for (final IResource res : file.getParent().members()) { + if (res instanceof IFile){ + final String resourceWithoutExtension = OneFileUtils.withoutFileExtension(res); + final String fileWithoutExtension = OneFileUtils.withoutFileExtension(file); + if(fileWithoutExtension.equals(resourceWithoutExtension)) { + files.add(res); + }else if(res.getFileExtension().equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION) && resourceWithoutExtension.startsWith(fileWithoutExtension)){ + String possibleLocale = resourceWithoutExtension.substring(fileWithoutExtension.length()); + if(possibleLocale.startsWith("_")){ //$NON-NLS-1$ + possibleLocale = possibleLocale.substring(1); + Locale localeFound = null; + + // Check about possible locale in available locales + final Iterator availableLocales = Arrays.asList(Locale.getAvailableLocales()) + .iterator(); + while (availableLocales.hasNext() && null == localeFound) { + final Locale currentAvailableLocale = availableLocales.next(); + + if (currentAvailableLocale.toString().equals(possibleLocale)) { + localeFound = currentAvailableLocale; + } + } + + // The file contains a locale, load it + if (null != localeFound) { + files.add(res); + } + } + } } } - } catch (CoreException e) { + } catch (final CoreException e) { + Activator.log.error("The file members cannot be found", e); //$NON-NLS-1$ } return files.toArray(new IResource[] {}); } diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java index 3ddcf35ad8d..a6722120821 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/model/impl/SubResourceFile.java @@ -8,12 +8,15 @@ * * Contributors: * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * *****************************************************************************/ package org.eclipse.papyrus.infra.onefile.model.impl; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; import org.eclipse.papyrus.infra.onefile.model.ISubResourceFile; @@ -41,8 +44,18 @@ public class SubResourceFile implements ISubResourceFile { @Override public String toString() { + String result = subResource.getName(); String fileExtension = subResource.getFileExtension(); - return fileExtension != null ? fileExtension : subResource.getName(); + if(null != fileExtension){ + result = fileExtension; + if(fileExtension.equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)){ + final String resourceWithoutExtension = subResource.getName().substring(0, subResource.getName().lastIndexOf('.')); //$NON-NLS-1$ + if(!resourceWithoutExtension.equals(parent.getText())){ + result = subResource.getName().substring(parent.getText().length()); + } + } + } + return result; } public IFile getFile() { diff --git a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java index 9a3ab4ef4bb..0c23c91750f 100644 --- a/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java +++ b/plugins/infra/onefile/org.eclipse.papyrus.infra.onefile/src/org/eclipse/papyrus/infra/onefile/utils/OneFileUtils.java @@ -9,11 +9,16 @@ * Contributors: * Tristan Faure (Atos Origin Integration) tristan.faure@atosorigin.com - Initial API and implementation * Christian W. Damus - bug 485220 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.onefile.utils; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -21,6 +26,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile; import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper; @@ -54,10 +60,7 @@ public class OneFileUtils { if (parent == null || parent.getType() == IResource.ROOT) { return null; } - String substring = fileName; - if (fileName.indexOf('.') > 0) { - substring = fileName.substring(0, fileName.lastIndexOf('.')); - } + final String substring = getFileNameForDi(fileName); IFile file = parent.getFile(new Path(substring + "." + DiModel.DI_FILE_EXTENSION)); if (file.exists()) { return file; @@ -65,6 +68,55 @@ public class OneFileUtils { return null; } + /** + * The file name for di search in parent container. + * + * @param fileName + * The initial file name. + * @return The base of the di to search in the parent container. + */ + protected static String getFileNameForDi(final String fileName) { + String result = fileName; + if (fileName.indexOf('.') > 0) { + // Manage the properties files which contains languages + final String extension = fileName.substring(fileName.lastIndexOf('.') + 1); + String fileNameWithoutExtension = fileName.substring(0, fileName.lastIndexOf('.')); + + // For the properties file with underscore in name, we need to check if a locale is available in the name + // If this is true, the file name is the name without the locale name + // Example: projectName_en_US.properties must return projectName + if (extension.equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION) && fileNameWithoutExtension.contains("_")) { + boolean localeFound = false; + // Get the available locales + final List availableLocales = Arrays.asList(Locale.getAvailableLocales()); + String substring = fileNameWithoutExtension; + + // Loop until no underscore in the name or if a locale is found + while (substring.contains("_") && !localeFound) { //$NON-NLS-1$ + // Remove the first part of the name to check the possible locale + substring = substring.substring(substring.indexOf("_") + 1); //$NON-NLS-1$ + + final Iterator localesIterator = availableLocales.iterator(); + + // Loop on available locales + while (localesIterator.hasNext() && !localeFound) { + final Locale currentAvailableLocale = localesIterator.next(); + + // The available locale is corresponding to the substring of the file name + if (currentAvailableLocale.toString().equals(substring)) { + localeFound = true; + // Get the initial name without the locale as string + fileNameWithoutExtension = fileNameWithoutExtension.substring(0, fileNameWithoutExtension.length() - substring.length() - 1); + } + } + } + } + + result = fileNameWithoutExtension; + } + return result; + } + /** * check if the element has children or not * diff --git a/plugins/infra/pom.xml b/plugins/infra/pom.xml index 91442858b0d..542478c84a3 100644 --- a/plugins/infra/pom.xml +++ b/plugins/infra/pom.xml @@ -33,5 +33,6 @@ ui misc discovery + internationalization diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF index f228409e741..a4b34478f18 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF @@ -2,6 +2,7 @@ Manifest-Version: 1.0 Export-Package: org.eclipse.papyrus.infra.services.controlmode, org.eclipse.papyrus.infra.services.controlmode.commands, org.eclipse.papyrus.infra.services.controlmode.handler, + org.eclipse.papyrus.infra.services.controlmode.messages, org.eclipse.papyrus.infra.services.controlmode.internal.handler;x-internal:=true, org.eclipse.papyrus.infra.services.controlmode.internal.ui;x-internal:=true, org.eclipse.papyrus.infra.services.controlmode.participants, @@ -21,7 +22,7 @@ Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)";visibili org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 1.4.0.qualifier +Bundle-Version: 1.5.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml index b0cf7c2c462..a430a472b84 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml @@ -7,6 +7,6 @@ 0.0.1-SNAPSHOT org.eclipse.papyrus.infra.services.controlmode - 1.4.0-SNAPSHOT + 1.5.0-SNAPSHOT eclipse-plugin diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java index 213b3f8c88d..16174e6f391 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java @@ -11,6 +11,7 @@ * Christian W. Damus - bug 399859 * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952 * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.services.controlmode.commands; @@ -19,6 +20,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; @@ -149,7 +151,7 @@ public class CreateControlResource extends AbstractControlResourceCommand { resource.setModified(true); // Handle old resource - if (!isControlledResourceLocked(getRequest().getNewURI())) { + if (!isControlledResourceLocked(getNewURI())) { getResourceSet().getResources().remove(oldResource); modelSet.getResourcesToDeleteOnSave().add(oldResource.getURI()); } @@ -157,6 +159,16 @@ public class CreateControlResource extends AbstractControlResourceCommand { return superStatus; } + + /** + * Get the new URI. + * + * @return The new URI. + * @since 1.5 + */ + protected URI getNewURI(){ + return getRequest().getNewURI(); + } /** * Gets the target resrource. @@ -165,7 +177,7 @@ public class CreateControlResource extends AbstractControlResourceCommand { * the object to uncontrol * @return the target resrource */ - private Resource getTargetResrource(EObject objectToUncontrol) { + protected Resource getTargetResrource(EObject objectToUncontrol) { return getRequest().getModelSet().getAssociatedResource(objectToUncontrol, getFileExtension(), true); } diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java index 1a35810c63a..94a2690ea1b 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java @@ -10,6 +10,8 @@ * Contributors: * Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 + * *****************************************************************************/ package org.eclipse.papyrus.infra.services.controlmode.commands; @@ -39,22 +41,22 @@ import org.eclipse.papyrus.infra.services.controlmode.messages.Messages; public class RemoveControlResourceCommand extends AbstractControlResourceCommand { /** The Constant PREVIOUS_RESOURCE_ERROR. */ - private static final String PREVIOUS_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.previous.resource.error"); //$NON-NLS-1$ + protected static final String PREVIOUS_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.previous.resource.error"); //$NON-NLS-1$ /** The Constant TARGET_RESOURCE_ERROR. */ - private static final String TARGET_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.target.resource.error"); //$NON-NLS-1$ + protected static final String TARGET_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.target.resource.error"); //$NON-NLS-1$ /** The Constant RESOURCE_ERROR. */ - private static final String RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.resource.error"); //$NON-NLS-1$ + protected static final String RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.resource.error"); //$NON-NLS-1$ /** The Constant RESOURCESET_ERROR. */ - private static final String RESOURCESET_ERROR = Messages.getString("RemoveControlResourceCommand.resourceset.error"); //$NON-NLS-1$ + protected static final String RESOURCESET_ERROR = Messages.getString("RemoveControlResourceCommand.resourceset.error"); //$NON-NLS-1$ /** The Constant CONTROL_OBJECT_ERROR. */ - private static final String CONTROL_OBJECT_ERROR = Messages.getString("RemoveControlResourceCommand.object.error"); //$NON-NLS-1$ + protected static final String CONTROL_OBJECT_ERROR = Messages.getString("RemoveControlResourceCommand.object.error"); //$NON-NLS-1$ /** The Constant UNCONTROL_COMMAND_TITLE. */ - private static final String UNCONTROL_COMMAND_TITLE = Messages.getString("RemoveControlResourceCommand.command.title"); //$NON-NLS-1$ + protected static final String UNCONTROL_COMMAND_TITLE = Messages.getString("RemoveControlResourceCommand.command.title"); //$NON-NLS-1$ /** * @param request @@ -128,7 +130,7 @@ public class RemoveControlResourceCommand extends AbstractControlResourceCommand if (modelSet == null) { return CommandResult.newErrorCommandResult(RESOURCESET_ERROR).getStatus(); } - Resource resource = getRequest().getSourceResource(getFileExtension()); + Resource resource = getSourceResource(); if (resource == null) { return CommandResult.newErrorCommandResult(RESOURCE_ERROR).getStatus(); } @@ -141,11 +143,21 @@ public class RemoveControlResourceCommand extends AbstractControlResourceCommand return superStatus; } + + /** + * Get the source resource. + * + * @return The source resource. + * @since 1.5 + */ + protected Resource getSourceResource(){ + return getRequest().getSourceResource(getFileExtension()); + } @Override protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { IStatus superStatus = super.doRedo(monitor, info); - Resource resource = getRequest().getSourceResource(getFileExtension()); + Resource resource = getSourceResource(); if (resource == null) { return CommandResult.newErrorCommandResult(PREVIOUS_RESOURCE_ERROR).getStatus(); } diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF index 97e65ebedbb..223f3ffe63a 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)", org.eclipse.core.filesystem;bundle-version="[1.6.0,2.0.0)", org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)", - org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)" + org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 1.2.0.qualifier diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java index 05e987f060b..72813b1919f 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.onefile.ui/src/org/eclipse/papyrus/infra/onefile/internal/ui/action/PapyrusCopyFilesAndFoldersOperation.java @@ -9,6 +9,7 @@ * * Contributors: * Benoit Maggi benoit.maggi@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ @@ -41,6 +42,7 @@ import org.eclipse.papyrus.infra.emf.resource.DependencyManagementHelper; import org.eclipse.papyrus.infra.emf.resource.MoveFileURIReplacementStrategy; import org.eclipse.papyrus.infra.emf.resource.RestoreDependencyHelper; import org.eclipse.papyrus.infra.emf.utils.ResourceUtils; +import org.eclipse.papyrus.infra.internationalization.utils.PropertiesFilesUtils; import org.eclipse.papyrus.infra.onefile.internal.ui.Activator; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -83,9 +85,8 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper destinationPaths[i] = destination.append(source.getName()); IPath relativSourcePath = source.getFullPath(); String sourceFileName = relativSourcePath.removeFileExtension().lastSegment(); - if (sourceFileName.equals(oldName)) { - String fileExtension = relativSourcePath.getFileExtension(); - destinationPaths[i] = relativSourcePath.removeLastSegments(1).append(newName).addFileExtension(fileExtension); + if (!oldName.isEmpty() && sourceFileName.startsWith(oldName)) { + destinationPaths[i] = getDestinationPath(relativSourcePath, newName, oldName); } else { oldName = sourceFileName; if (workspace.getRoot().exists(destinationPaths[i]) && destinationPaths[i].getFileExtension().equals(DiModel.MODEL_FILE_EXTENSION)) { @@ -111,7 +112,28 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper return true; } + /** + * Get the new destination path for the current relative source path. + * + * @param relativeSourcePath + * The relative source path. + * @param newName + * The new name to set. + * @param oldName + * The old name. + * @return The destination path. + */ + public IPath getDestinationPath(final IPath relativeSourcePath, final String newName, final String oldName) { + final String fileExtension = relativeSourcePath.getFileExtension(); + // Get the source file name + final String sourceFileName = relativeSourcePath.removeFileExtension().lastSegment(); + // Replace the oldName by the newName + final String destinationFileName = sourceFileName.replace(oldName, newName); + // Retrieve the last segment and append the new one with the file extension + return relativeSourcePath.removeLastSegments(1).append(destinationFileName).addFileExtension(fileExtension); + } + /* * (non-Javadoc) * @@ -222,7 +244,10 @@ public class PapyrusCopyFilesAndFoldersOperation extends CopyFilesAndFoldersOper for (Entry oneInternalCopyMapping : constructInternalMapping.entrySet()) { DependencyManagementHelper.updateDependencies(oneInternalCopyMapping.getKey(), oneInternalCopyMapping.getValue(), resource); } - resource.save(ResourceUtils.getSaveOptions()); + // Don't save the resource properties, the model resource manage it at create model call + if(!resource.getURI().fileExtension().equals(PropertiesFilesUtils.PROPERTIES_FILE_EXTENSION)){ + resource.save(ResourceUtils.getSaveOptions()); + } IPath fullPath = copyResources.getFullPath(); Resource sashResource = null; diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF index eec08634d1f..892eaad5336 100755 --- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF +++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)";visibility:=reex org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.constraints;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)" + org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java index 5e71ff35851..912db7f9087 100644 --- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java +++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java @@ -9,13 +9,16 @@ * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 474467 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905 * *****************************************************************************/ package org.eclipse.papyrus.infra.viewpoints.policy; import org.eclipse.emf.ecore.EObject; import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; +import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; import org.eclipse.papyrus.infra.ui.emf.providers.DependentEMFLabelProvider; import org.eclipse.swt.graphics.Image; @@ -90,6 +93,10 @@ public class ViewPrototypeLabelProvider extends DependentEMFLabelProvider { * @see EMFCoreUtil#getName(EObject) */ protected String getName(EObject object) { - return EMFCoreUtil.getName(object); + String value = null; + if(object instanceof Diagram){ + value = LabelInternationalization.getInstance().getDiagramLabel((Diagram)object); + } + return null != value ? value : EMFCoreUtil.getName(object); } } -- cgit v1.2.3