Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2016-02-01 13:52:33 +0000
committerFlorian Noyrit2016-02-05 10:07:34 +0000
commitfc691bb69c710107b43fbfb12abcc0914b857837 (patch)
treeb1c4801bf2519a09df56e2ed9f0e1a3bc786ec12 /plugins/developer
parent70b72ba9943c839aec0a04caae4312cea8e240f0 (diff)
downloadorg.eclipse.papyrus-fc691bb69c710107b43fbfb12abcc0914b857837.tar.gz
org.eclipse.papyrus-fc691bb69c710107b43fbfb12abcc0914b857837.tar.xz
org.eclipse.papyrus-fc691bb69c710107b43fbfb12abcc0914b857837.zip
Improve/Fix the support of extensions of the
ElementTypesConfiguration framework - Bug 477206 Change-Id: I50ed9bb1bf6a807881a143875f87c5a6f56a6afc
Diffstat (limited to 'plugins/developer')
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/META-INF/MANIFEST.MF3
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/plugin.xml41
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/pom.xml48
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurations.java195
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurationsFromGmfGen.java390
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/MigrateElementTypesConfigurations.java252
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventContentProvider.java4
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventLabelProvider.java6
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/ElementTypesConfigurationsEventPrinter.java28
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/NotifierNullEditHelper.java2
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/ElementTypesConfigurationsListenerView.java8
11 files changed, 332 insertions, 645 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/META-INF/MANIFEST.MF
index 75de21c1413..0698a30e61b 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/META-INF/MANIFEST.MF
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.xtend.lib,
org.eclipse.xtend.lib.macro,
org.eclipse.ui.workbench,
- org.eclipse.ui.ide;bundle-version="3.10.100"
+ org.eclipse.ui.ide;bundle-version="3.10.100",
+ org.eclipse.core.filesystem;bundle-version="1.6.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/plugin.xml b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/plugin.xml
index ff3062d9ba1..96f841b7711 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/plugin.xml
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/plugin.xml
@@ -11,9 +11,9 @@
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any">
<command
- commandId="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.generateElementTypesConfigurations"
- id="org.eclipse.papyrus.infra.elementtypesconfigurations.menus.generateElementTypesConfigurations"
- label="Generate ElementTypes Configurations"
+ commandId="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.migrateElementTypesConfigurations"
+ id="org.eclipse.papyrus.infra.elementtypesconfigurations.menus.migrateElementTypesConfigurations"
+ label="Migrate ElementTypes Configurations"
mnemonic="S"
style="push">
<visibleWhen
@@ -35,30 +35,6 @@
allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any">
<command
- commandId="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.generateElementTypesConfigurationsFromGmfGen"
- id="org.eclipse.papyrus.infra.elementtypesconfigurations.menus.generateEElementTypesConfigurationsFromGmfGen"
- label="Generate ElementTypesConfigurations From GmfGen"
- mnemonic="G"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="selection">
- <iterate
- ifEmpty="false"
- operator="and">
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.ui.popup.any">
- <command
commandId="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.generateElementTypesRegistry"
id="org.eclipse.papyrus.infra.elementtypesconfigurations.menus.generateElementTypesRegistry"
label="Generate ElementTypes Registry"
@@ -84,14 +60,9 @@
<extension
point="org.eclipse.ui.commands">
<command
- defaultHandler="org.eclipse.papyrus.elementtypesconfigurations.developer.handlers.GenerateElementTypesConfigurations"
- id="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.generateElementTypesConfigurations"
- name="Generate ElementTypesConfigurations">
- </command>
- <command
- defaultHandler="org.eclipse.papyrus.elementtypesconfigurations.developer.handlers.GenerateElementTypesConfigurationsFromGmfGen"
- id="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.generateElementTypesConfigurationsFromGmfGen"
- name="Generate ElementTypesConfigurations From GmfGen">
+ defaultHandler="org.eclipse.papyrus.elementtypesconfigurations.developer.handlers.MigrateElementTypesConfigurations"
+ id="org.eclipse.papyrus.infra.elementtypesconfigurations.commands.migrateElementTypesConfigurations"
+ name="Migrate ElementTypesConfigurations">
</command>
<command
defaultHandler="org.eclipse.papyrus.elementtypesconfigurations.developer.handlers.GenerateElementTypesRegistry"
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/pom.xml b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/pom.xml
new file mode 100644
index 00000000000..e8b3fd5bc83
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.dev.releng</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../../../releng/dev</relativePath>
+ </parent>
+ <artifactId>org.eclipse.papyrus.elementtypesconfigurations.developer</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <build>
+ <plugins>
+ <!-- Empty out the xtend-gen folder in the clean phase. -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>xtend-gen</directory>
+ <excludes>
+ <exclude>**/.gitignore</exclude>
+ </excludes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <!-- Generate Xtend sources in the compilation phase. -->
+ <plugin>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>xtend-gen</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurations.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurations.java
deleted file mode 100644
index b299bff62d6..00000000000
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurations.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.elementtypesconfigurations.developer.handlers;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.emf.common.util.ECollections;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.ElementTypeConfigurationComparator;
-import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.GenerateElementTypesConfigurationsUtils;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ContainerConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementtypesconfigurationsFactory;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.IconEntry;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.MetamodelTypeConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.SpecializationTypeConfiguration;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public class GenerateElementTypesConfigurations extends AbstractHandler {
-
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ResourceSet resourceSet = new ResourceSetImpl();
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
- return null;
- }
-
- final IStructuredSelection selection = (IStructuredSelection) currentSelection;
- Object selectedElement = selection.getFirstElement();
-
- if (selectedElement instanceof IFolder) {
- IFolder selectedFolder = (IFolder) selectedElement;
- String selectedFolderPath = selectedFolder.getFullPath().toString();
-
- ElementTypeSetConfiguration elementTypeSetConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createElementTypeSetConfiguration();
- elementTypeSetConfiguration.setMetamodelNsURI(UMLPackage.eNS_URI);
- createElementTypesConfigurationsModel(UMLPackage.eINSTANCE, elementTypeSetConfiguration);
-
- Resource outputResource = resourceSet.createResource(URI.createURI(selectedFolderPath + "/" + "output.elementtypesconfigurations"));
- outputResource.getContents().add(elementTypeSetConfiguration);
- try {
- outputResource.save(Collections.EMPTY_MAP);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } else if (selectedElement instanceof IFile) {
- if ("elementtypesconfigurations".equals(((IFile) selectedElement).getFileExtension())) {
- String selectedFilePath = ((IFile) selectedElement).getFullPath().toString();
-
- Resource outputResource = resourceSet.getResource(URI.createURI(selectedFilePath), true);
- createElementTypesConfigurationsModel(UMLPackage.eINSTANCE, (ElementTypeSetConfiguration) outputResource.getContents().get(0));
-
- ECollections.sort(((ElementTypeSetConfiguration) outputResource.getContents().get(0)).getElementTypeConfigurations(), new ElementTypeConfigurationComparator());
-
- try {
- outputResource.save(Collections.EMPTY_MAP);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
- return null;
- }
-
-
-
- protected void createElementTypesConfigurationsModel(EPackage ePackage, ElementTypeSetConfiguration elementTypeSetConfiguration) {
-
- Collection<EClass> eClasses = GenerateElementTypesConfigurationsUtils.getAllEClass(ePackage);
-
-
- // Create metamodelTypes
- for (EClass eClass : eClasses) {
- if (!containsElementType(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass), elementTypeSetConfiguration)) {
- MetamodelTypeConfiguration metamodelTypeConfiguration = createMetamodelTypeConfiguration(eClass);
- elementTypeSetConfiguration.getElementTypeConfigurations().add(metamodelTypeConfiguration);
- }
-
-
- // Create Specializations
- if (!eClass.isAbstract()) {
-
- // get all features for containments
- Collection<EReference> possibleContainmentsEReference = GenerateElementTypesConfigurationsUtils.findPossibleContainmentsEReference(eClass, eClasses);
- for (EReference containmentEReference : possibleContainmentsEReference) {
- Collection<EReference> ambiguousContainments = GenerateElementTypesConfigurationsUtils.findAmbiguousContainments(containmentEReference, possibleContainmentsEReference);
- if (!ambiguousContainments.isEmpty()) {
-
- if (!containsElementType(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass) + GenerateElementTypesConfigurationsUtils.getAsName(containmentEReference, containmentEReference.getEContainingClass()),
- elementTypeSetConfiguration)) {
- SpecializationTypeConfiguration specializationTypeConfiguration = createSpecializationTypeConfiguration(eClass, containmentEReference,
- GenerateElementTypesConfigurationsUtils.getAsName(containmentEReference, containmentEReference.getEContainingClass()));
-
- elementTypeSetConfiguration.getElementTypeConfigurations().add(specializationTypeConfiguration);
- }
-
- // Add ambiguous containments
- for (EReference ambiguousEReference : ambiguousContainments) {
- if (!containsElementType(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass) + GenerateElementTypesConfigurationsUtils.getAsName(ambiguousEReference, containmentEReference.getEContainingClass()),
- elementTypeSetConfiguration)) {
- SpecializationTypeConfiguration ambiguousSpecializationTypeConfiguration = createSpecializationTypeConfiguration(eClass, ambiguousEReference,
- GenerateElementTypesConfigurationsUtils.getAsName(ambiguousEReference, containmentEReference.getEContainingClass()));
- elementTypeSetConfiguration.getElementTypeConfigurations().add(ambiguousSpecializationTypeConfiguration);
- }
- }
- }
- }
- }
- }
-
- }
-
- protected MetamodelTypeConfiguration createMetamodelTypeConfiguration(EClass eClass) {
- MetamodelTypeConfiguration metamodelTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createMetamodelTypeConfiguration();
- metamodelTypeConfiguration.setEClass(eClass);
- metamodelTypeConfiguration.setIdentifier(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass));
- metamodelTypeConfiguration.setHint(metamodelTypeConfiguration.getIdentifier());
- metamodelTypeConfiguration.setName(((ENamedElement) eClass.eContainer()).getName().toUpperCase() + "::" + eClass.getName());
- metamodelTypeConfiguration.setKind("org.eclipse.gmf.runtime.emf.type.core.IHintedType");
- metamodelTypeConfiguration.setEditHelperClassName("org.eclipse.papyrus.infra.gmfdiag.common.helper.DefaultEditHelper");
-
- IconEntry iconEntry = ElementtypesconfigurationsFactory.eINSTANCE.createIconEntry();
- iconEntry.setBundleId("org.eclipse.uml2.uml.edit");
- iconEntry.setIconPath("/icons/full/obj16/" + eClass.getName() + ".gif");
-
- metamodelTypeConfiguration.setIconEntry(iconEntry);
-
- return metamodelTypeConfiguration;
- }
-
- protected SpecializationTypeConfiguration createSpecializationTypeConfiguration(EClass eClass, EReference containmentEReference, String asName) {
- SpecializationTypeConfiguration specializationTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createSpecializationTypeConfiguration();
-
- specializationTypeConfiguration.setIdentifier(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass) + asName);
- specializationTypeConfiguration.setHint(specializationTypeConfiguration.getIdentifier());
- specializationTypeConfiguration.setName(((ENamedElement) eClass.eContainer()).getName().toUpperCase() + "::" + eClass.getName() + asName);
- specializationTypeConfiguration.setKind("org.eclipse.gmf.runtime.emf.type.core.IHintedType");
- specializationTypeConfiguration.getSpecializedTypesID().add(GenerateElementTypesConfigurationsUtils.getIdentifier(eClass));
-
- ContainerConfiguration containerConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createContainerConfiguration();
- containerConfiguration.getEContainmentFeatures().add(containmentEReference);
- specializationTypeConfiguration.setContainerConfiguration(containerConfiguration);
-
- IconEntry iconEntryForSpecialization = ElementtypesconfigurationsFactory.eINSTANCE.createIconEntry();
- iconEntryForSpecialization.setBundleId("org.eclipse.uml2.uml.edit");
- iconEntryForSpecialization.setIconPath("/icons/full/obj16/" + eClass.getName() + ".gif");
-
- specializationTypeConfiguration.setIconEntry(iconEntryForSpecialization);
-
- return specializationTypeConfiguration;
- }
-
- protected boolean containsElementType(String identifier, ElementTypeSetConfiguration elementTypeSetConfiguration) {
- for (ElementTypeConfiguration elementTypeConfiguration : elementTypeSetConfiguration.getElementTypeConfigurations()) {
- if (elementTypeConfiguration.getIdentifier().equals(identifier)) {
- return true;
- }
- }
- return false;
- }
-
-
-}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurationsFromGmfGen.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurationsFromGmfGen.java
deleted file mode 100644
index 50ef874aade..00000000000
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/GenerateElementTypesConfigurationsFromGmfGen.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014, 2015 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:
- * CEA LIST - Initial API and implementation
- * Christian W. Damus - bug 451230
- *
- *****************************************************************************/
-package org.eclipse.papyrus.elementtypesconfigurations.developer.handlers;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.ECollections;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet;
-import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
-import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
-import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
-import org.eclipse.gmf.codegen.gmfgen.NotationType;
-import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.elementtypesconfigurations.developer.Activator;
-import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.ElementTypeConfigurationComparator;
-import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.GenerateElementTypesConfigurationsUtils;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ContainerConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeSetConfiguration;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementtypesconfigurationsFactory;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementtypesconfigurationsPackage;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.IconEntry;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.SpecializationTypeConfiguration;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-
-
-public class GenerateElementTypesConfigurationsFromGmfGen extends AbstractHandler {
-
-
-
-
- public GenerateElementTypesConfigurationsFromGmfGen() {
- }
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ResourceSet resourceSet = new ResourceSetImpl();
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
- return null;
- }
-
- final IStructuredSelection selection = (IStructuredSelection) currentSelection;
- Object selectedElement = selection.getFirstElement();
-
- if (selectedElement instanceof IFile) {
-
- String selectedFilePath = ((IFile) selectedElement).getFullPath().toString();
-
- /*
- * Generate the semantic types.
- */
- Resource inputResource = resourceSet.getResource(URI.createPlatformResourceURI(selectedFilePath, true), true);
- String outputFilePath = ((IFile) selectedElement).getFullPath().removeFileExtension().toString();
- URI outputURI = URI.createURI(outputFilePath + ".elementtypesconfigurations");
- Resource outputResource;
- if (resourceSet.getURIConverter().exists(outputURI, null)) {
- // We'll merge with the existing model
- outputResource = resourceSet.getResource(outputURI, true);
- } else {
- // Generate a new model
- outputResource = resourceSet.createResource(outputURI);
- }
- ElementTypeSetConfiguration elementTypeSetConfiguration = generateElementTypeSetConfiguration(inputResource, outputResource);
-
- /*
- * Generate the notation types.
- */
- URI outputNotationURI = URI.createURI(outputFilePath + "-notation.elementtypesconfigurations");
- Resource outputNotationResource;
- if (resourceSet.getURIConverter().exists(outputNotationURI, null)) {
- // We'll merge with the existing model
- outputNotationResource = resourceSet.getResource(outputNotationURI, true);
- } else {
- // Generate a new model
- outputNotationResource = resourceSet.createResource(outputNotationURI);
- }
- ElementTypeSetConfiguration elementTypeSetConfigurationNotation = generateElementTypeSetConfigurationNotation(inputResource, outputNotationResource);
-
- // Sort only when generating new
- if (!resourceSet.getURIConverter().exists(outputURI, null)) {
- ECollections.sort(elementTypeSetConfiguration.getElementTypeConfigurations(), new ElementTypeConfigurationComparator());
- }
- if (!resourceSet.getURIConverter().exists(outputNotationURI, null)) {
- ECollections.sort(elementTypeSetConfigurationNotation.getElementTypeConfigurations(), new ElementTypeConfigurationComparator());
- }
-
- try {
- outputResource.save(Collections.EMPTY_MAP);
- outputNotationResource.save(Collections.EMPTY_MAP);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return null;
- }
-
- protected ElementTypeSetConfiguration generateElementTypeSetConfigurationNotation(Resource inputResource, Resource outputResource) {
- ElementTypeSetConfiguration elementTypeSetConfiguration = (ElementTypeSetConfiguration) EcoreUtil.getObjectByType(outputResource.getContents(), ElementtypesconfigurationsPackage.Literals.ELEMENT_TYPE_SET_CONFIGURATION);
- final Map<String, ElementTypeConfiguration> extantConfigurations = Maps.newHashMap();
- if (elementTypeSetConfiguration == null) {
- // Creating a new model
- elementTypeSetConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createElementTypeSetConfiguration();
- outputResource.getContents().add(elementTypeSetConfiguration);
- } else {
- // Gather the configurations already in the model to merge them
- for (ElementTypeConfiguration next : elementTypeSetConfiguration.getElementTypeConfigurations()) {
- extantConfigurations.put(next.getIdentifier(), next);
- }
- }
-
- elementTypeSetConfiguration.setMetamodelNsURI("http://www.eclipse.org/gmf/runtime/1.0.2/notation");
-
-
- TreeIterator<EObject> it = inputResource.getAllContents();
- while (it.hasNext()) {
- EObject eObject = it.next();
- if (eObject instanceof NotationType) {
- NotationType notationType = (NotationType) eObject;
-
- // Merge with existing?
- String identifier = notationType.getUniqueIdentifier();
- SpecializationTypeConfiguration specializationTypeConfiguration;
- ElementTypeConfiguration existing = extantConfigurations.get(identifier);
- if (existing instanceof SpecializationTypeConfiguration) {
- // Merged
- specializationTypeConfiguration = (SpecializationTypeConfiguration) extantConfigurations.remove(identifier);
- } else {
- // New
- specializationTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createSpecializationTypeConfiguration();
- specializationTypeConfiguration.setIdentifier(identifier);
- }
-
- specializationTypeConfiguration.setIdentifier(notationType.getUniqueIdentifier());
- specializationTypeConfiguration.setHint("" + ((GenCommonBase) notationType.eContainer()).getVisualID());
- specializationTypeConfiguration.setName(notationType.getDisplayName());
-
- specializationTypeConfiguration.setKind("org.eclipse.gmf.runtime.diagram.ui.util.INotationType");
-
- if (specializationTypeConfiguration.getSpecializedTypesID().isEmpty()) {
- specializationTypeConfiguration.getSpecializedTypesID().add("org.eclipse.gmf.runtime.emf.type.core.null");
- }
-
- elementTypeSetConfiguration.getElementTypeConfigurations().add(specializationTypeConfiguration);
-
-
- }
- }
-
- deleteLeftovers(extantConfigurations);
-
- return elementTypeSetConfiguration;
- }
-
- protected ElementTypeSetConfiguration generateElementTypeSetConfiguration(Resource inputResource, Resource outputResource) {
- ElementTypeSetConfiguration elementTypeSetConfiguration = (ElementTypeSetConfiguration) EcoreUtil.getObjectByType(outputResource.getContents(), ElementtypesconfigurationsPackage.Literals.ELEMENT_TYPE_SET_CONFIGURATION);
- final Map<String, ElementTypeConfiguration> extantConfigurations = Maps.newHashMap();
- if (elementTypeSetConfiguration == null) {
- // Creating a new model
- elementTypeSetConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createElementTypeSetConfiguration();
- outputResource.getContents().add(elementTypeSetConfiguration);
- } else {
- // Gather the configurations already in the model to merge them
- for (ElementTypeConfiguration next : elementTypeSetConfiguration.getElementTypeConfigurations()) {
- extantConfigurations.put(next.getIdentifier(), next);
- }
- }
-
- elementTypeSetConfiguration.setMetamodelNsURI("http://www.eclipse.org/uml2/5.0.0/UML");
-
- TreeIterator<EObject> it = inputResource.getAllContents();
- while (it.hasNext()) {
- EObject eObject = it.next();
- if (eObject instanceof GenEditorGenerator) {
- GenEditorGenerator editorGen = (GenEditorGenerator) eObject;
- elementTypeSetConfiguration.setName(editorGen.getModelID());
- } else if (eObject instanceof GenDiagram) {
- // Diagram model does not have a TypeModelFacet, so use this instead
- GenDiagram diagram = (GenDiagram) eObject;
-
- // Merge with existing?
- String identifier = diagram.getElementType().getUniqueIdentifier();
- SpecializationTypeConfiguration specializationTypeConfiguration;
- ElementTypeConfiguration existing = extantConfigurations.get(identifier);
- if (existing instanceof SpecializationTypeConfiguration) {
- // Merged
- specializationTypeConfiguration = (SpecializationTypeConfiguration) extantConfigurations.remove(identifier);
- } else {
- // New
- specializationTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createSpecializationTypeConfiguration();
- specializationTypeConfiguration.setIdentifier(identifier);
- }
-
- // This is what the Diagram uses as its type, not the visual ID
- specializationTypeConfiguration.setHint(diagram.getEditorGen().getModelID());
-
- // The element type name is often just "Undefined"
- specializationTypeConfiguration.setName(cleanUpName(diagram.getDomainDiagramElement().getFormattedName()));
-
- specializationTypeConfiguration.setKind("org.eclipse.gmf.runtime.emf.type.core.IHintedType");
-
- // Container configuration is irrelevant for the diagram because it has no parent view
- specializationTypeConfiguration.getSpecializedTypesID().clear();
- specializationTypeConfiguration.getSpecializedTypesID().add(GenerateElementTypesConfigurationsUtils.getIdentifier(diagram.getDomainDiagramElement().getEcoreClass()));
-
- generateIconEntry(specializationTypeConfiguration, diagram.getDomainDiagramElement().getEcoreClass());
-
- elementTypeSetConfiguration.getElementTypeConfigurations().add(specializationTypeConfiguration);
-
- } else if (eObject instanceof TypeModelFacet) {
- TypeModelFacet typeModelFacet = (TypeModelFacet) eObject;
-
-
-
- EClass eClass = typeModelFacet.getMetaClass().getEcoreClass();
- if (eClass == null)
- {
- Activator.log.info("EClass not defined for: " + typeModelFacet.eContainer());
- } else {
- GenCommonBase base = (GenCommonBase) typeModelFacet.eContainer();
-
- // Merge with existing?
- String identifier = base.getElementType().getUniqueIdentifier();
- SpecializationTypeConfiguration specializationTypeConfiguration;
- ElementTypeConfiguration existing = extantConfigurations.get(identifier);
- if (existing instanceof SpecializationTypeConfiguration) {
- // Merged
- specializationTypeConfiguration = (SpecializationTypeConfiguration) extantConfigurations.remove(identifier);
- } else {
- // New
- specializationTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createSpecializationTypeConfiguration();
- specializationTypeConfiguration.setIdentifier(identifier);
- }
-
- specializationTypeConfiguration.setHint(Integer.toString(base.getVisualID()));
- specializationTypeConfiguration.setName(cleanUpName(base.getElementType().getDisplayName()));
-
- specializationTypeConfiguration.setKind("org.eclipse.gmf.runtime.emf.type.core.IHintedType");
-
- EReference containmentEReference = null;
- if (typeModelFacet.getContainmentMetaFeature() != null) {
- EStructuralFeature feature = typeModelFacet.getContainmentMetaFeature().getEcoreFeature();
- if (feature instanceof EReference) {
- containmentEReference = (EReference) feature;
- }
- }
- if (containmentEReference != null) {
- specializationTypeConfiguration.getSpecializedTypesID().clear();
- specializationTypeConfiguration.getSpecializedTypesID().add(GenerateElementTypesConfigurationsUtils.findSpecializedTypesIDs(eClass, containmentEReference));
-
- if (GenerateElementTypesConfigurationsUtils.isSpecializedASpecialization(eClass, containmentEReference)) {
- ContainerConfiguration containerConfiguration = specializationTypeConfiguration.getContainerConfiguration();
- if (containerConfiguration == null) {
- containerConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createContainerConfiguration();
- specializationTypeConfiguration.setContainerConfiguration(containerConfiguration);
- }
-
- containerConfiguration.getEContainmentFeatures().clear();
- containerConfiguration.getEContainmentFeatures().add(containmentEReference);
- } else if (specializationTypeConfiguration.getContainerConfiguration() != null) {
- // Delete it
- EcoreUtil.delete(specializationTypeConfiguration.getContainerConfiguration(), true);
- }
- }
-
- generateIconEntry(specializationTypeConfiguration, eClass);
-
- elementTypeSetConfiguration.getElementTypeConfigurations().add(specializationTypeConfiguration);
- }
-
- } else if (eObject instanceof FeatureLinkModelFacet) {
- FeatureLinkModelFacet featureLinkModelFacet = (FeatureLinkModelFacet) eObject;
- GenCommonBase base = (GenCommonBase) featureLinkModelFacet.eContainer();
-
- // Merge with existing?
- String identifier = base.getElementType().getUniqueIdentifier();
- SpecializationTypeConfiguration specializationTypeConfiguration;
- ElementTypeConfiguration existing = extantConfigurations.get(identifier);
- if (existing instanceof SpecializationTypeConfiguration) {
- // Merged
- specializationTypeConfiguration = (SpecializationTypeConfiguration) extantConfigurations.remove(identifier);
- } else {
- // New
- specializationTypeConfiguration = ElementtypesconfigurationsFactory.eINSTANCE.createSpecializationTypeConfiguration();
- specializationTypeConfiguration.setIdentifier(identifier);
- }
-
- specializationTypeConfiguration.setHint(Integer.toString(base.getVisualID()));
- specializationTypeConfiguration.setName(cleanUpName(base.getElementType().getUniqueIdentifier()));
-
- specializationTypeConfiguration.setKind("org.eclipse.gmf.runtime.emf.type.core.IHintedType");
-
- if (specializationTypeConfiguration.getSpecializedTypesID().isEmpty()) {
- specializationTypeConfiguration.getSpecializedTypesID().add("org.eclipse.gmf.runtime.emf.type.core.null");
- }
-
- elementTypeSetConfiguration.getElementTypeConfigurations().add(specializationTypeConfiguration);
-
- }
- }
-
- deleteLeftovers(extantConfigurations);
-
- return elementTypeSetConfiguration;
- }
-
- protected IconEntry generateIconEntry(ElementTypeConfiguration type, EClass eClass) {
- // If an icon entry already exists, it may have been customized, so don't mess with it
- IconEntry result = type.getIconEntry();
- if (result == null) {
- result = ElementtypesconfigurationsFactory.eINSTANCE.createIconEntry();
- result.setBundleId("org.eclipse.uml2.uml.edit");
- result.setIconPath("/icons/full/obj16/" + eClass.getName() + ".gif");
- type.setIconEntry(result);
- }
-
- return result;
- }
-
- /**
- * Deletes from the merged element types model those element types that are no longer defined in the GMFGen.
- *
- * @param elementTypesToDelete
- * element types to delete
- */
- protected void deleteLeftovers(Map<String, ElementTypeConfiguration> elementTypesToDelete) {
- if (!elementTypesToDelete.isEmpty()) {
- String names = Joiner.on(", ").join(Iterables.transform(elementTypesToDelete.values(), new Function<ElementTypeConfiguration, String>() {
- @Override
- public String apply(ElementTypeConfiguration input) {
- return Strings.isNullOrEmpty(input.getName()) ? input.getIdentifier() : input.getName();
- }
- }));
-
- if (MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Delete Left-over Element Types", "Delete element types no longer defined in the GMFGen model?\n\n" + names)) {
- for (ElementTypeConfiguration next : elementTypesToDelete.values()) {
- EcoreUtil.delete(next, true);
- }
- }
- }
- }
-
- static String cleanUpName(String name) {
- name = name.substring(name.lastIndexOf('.') + 1); // Strip off namespace qualifier, if any
- if (name.matches("^.*_\\d+$")) {
- name = name.substring(0, name.lastIndexOf('_')); // Strip off visual ID suffix, if any
- }
- name = name.replaceAll("([a-z])([A-Z])", "$1 $2"); // put space between camel-case words
-
- return name;
- }
-}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/MigrateElementTypesConfigurations.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/MigrateElementTypesConfigurations.java
new file mode 100644
index 00000000000..2bb3b935828
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/handlers/MigrateElementTypesConfigurations.java
@@ -0,0 +1,252 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.elementtypesconfigurations.developer.handlers;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class MigrateElementTypesConfigurations extends AbstractHandler {
+
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ final String FILE_EXTENSION = "elementtypesconfigurations";
+
+ final String ELEMENTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:elementtypesconfigurations";
+ final String ELEMENTTYPECONFIGURATION_NAMESPACE_OLD = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.0";
+ final String ELEMENTTYPECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.1";
+
+ final String APPLYSTEREOTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:applystereotypeadviceconfiguration";
+ final String APPLYSTEREOTYPEADVICECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/uml/applystereotypeadvice/1.1";
+
+ final String INVARIANTSTEREOTYPERULECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:invariantstereotyperuleconfiguration";
+ final String INVARIANTSTEREOTYPERULECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/invariantstereotyperule/1.1";
+
+ final String SETTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:settypeadviceconfiguration";
+ final String SETTYPEADVICECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/uml/settypeadvice/1.1";
+
+ final String STEREOTYPEAPPLICATIONMATCHERCONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:stereotypeapplicationmatcherconfiguration";
+ final String STEREOTYPEAPPLICATIONMATCHERCONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/payrus/elementtypesconfigurations/uml/stereotypematcherconfiguration/1.1";
+
+ final String INVARIANTCONTAINERRULECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:invariantcontainerruleconfiguration";
+ final String INVARIANTCONTAINERRULECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/invarianttypeconfiguration/containerruleconfiguration/1.1";
+
+ final String RUNTIMEVALUESEDITIONADVICECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:runtimevalueseditionadviceconfiguration";
+ final String RUNTIMEVALUESEDITIONADVICECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/emf/runtimevalueseditionadviceconfiguration/1.1";
+
+ final String SETVALUESADVICECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:setvaluesadviceconfiguration";
+ final String SETVALUESADVICECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/emf/setvaluesadviceconfiguration/1.1";
+
+ final String INVARIANTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE = "xmlns:invarianttypeconfiguration";
+ final String INVARIANTTYPECONFIGURATION_NAMESPACE_NEW = "http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/invarianttype/1.1";
+
+
+
+ final String TYPE_ATTRIBUTE = "xsi:type";
+ final String EDITHELPERADVICECONFIGURATION_TAG = "editHelperAdviceConfiguration";
+ final String MATCHERCONFIGURATION_TAG = "matcherConfiguration";
+ final String NAME_ATTRIBUTE = "name";
+ final String IDENTIFIER_ATTRIBUTE = "identifier";
+ final String EDITHELPERADVICECLASSNAME_ATTRIBUTE = "editHelperAdviceClassName";
+ final String ADVICEBINDINGSCONFIGURATIONS_TAG = "adviceBindingsConfigurations";
+ final String MATCHER_TYPE = "elementtypesconfigurations:MatcherConfiguration";
+ final String ADVICEBINDINGCONFIGURATION_TYPE = "elementtypesconfigurations:AdviceBindingConfiguration";
+ final String EDITHELPERADVICECONFIGURATION_TYPE = "elementtypesconfigurations:EditHelperAdviceConfiguration";
+ final String MATCHERCLASSNAME_ATTRIBUTE = "matcherClassName";
+
+
+ ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
+ return null;
+ }
+
+ final IStructuredSelection selection = (IStructuredSelection) currentSelection;
+
+ Iterator<?> it = selection.iterator();
+
+ while (it.hasNext()) {
+ Object selectedElement = (Object) it.next();
+
+ if (selectedElement instanceof IFile) {
+ if (FILE_EXTENSION.equals(((IFile) selectedElement).getFileExtension())) {
+ IFile selectedFile = ((IFile) selectedElement);
+ URI uri = selectedFile.getLocationURI();
+
+ if (selectedFile.isLinked()) {
+ uri = selectedFile.getRawLocationURI();
+ }
+
+ try {
+ File file = EFS.getStore(uri).toLocalFile(0, new NullProgressMonitor());
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(file);
+ Element root = doc.getDocumentElement();
+
+ if (root.getAttribute(ELEMENTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE).equals(ELEMENTTYPECONFIGURATION_NAMESPACE_OLD)) {
+
+ // Update namespaces
+ root.setAttribute(ELEMENTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE, ELEMENTTYPECONFIGURATION_NAMESPACE_NEW);
+
+ if (!root.getAttribute(APPLYSTEREOTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(APPLYSTEREOTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE, APPLYSTEREOTYPEADVICECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(INVARIANTSTEREOTYPERULECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(INVARIANTSTEREOTYPERULECONFIGURATION_NAMESPACE_ATTRIBUTE, INVARIANTSTEREOTYPERULECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(SETTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(SETTYPEADVICECONFIGURATION_NAMESPACE_ATTRIBUTE, SETTYPEADVICECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(STEREOTYPEAPPLICATIONMATCHERCONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(STEREOTYPEAPPLICATIONMATCHERCONFIGURATION_NAMESPACE_ATTRIBUTE, STEREOTYPEAPPLICATIONMATCHERCONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(INVARIANTCONTAINERRULECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(INVARIANTCONTAINERRULECONFIGURATION_NAMESPACE_ATTRIBUTE, INVARIANTCONTAINERRULECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(RUNTIMEVALUESEDITIONADVICECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(RUNTIMEVALUESEDITIONADVICECONFIGURATION_NAMESPACE_ATTRIBUTE, RUNTIMEVALUESEDITIONADVICECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(SETVALUESADVICECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(SETVALUESADVICECONFIGURATION_NAMESPACE_ATTRIBUTE, SETVALUESADVICECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ if (!root.getAttribute(INVARIANTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE).isEmpty()) {
+ root.setAttribute(INVARIANTTYPECONFIGURATION_NAMESPACE_ATTRIBUTE, INVARIANTTYPECONFIGURATION_NAMESPACE_NEW);
+ }
+
+ NodeList editHelperAdviceConfigurations = root.getElementsByTagName(EDITHELPERADVICECONFIGURATION_TAG);
+
+ for (int i = 0; i < editHelperAdviceConfigurations.getLength(); i++) {
+ Element editHelperAdvice = (Element) editHelperAdviceConfigurations.item(i);
+
+ Node type = editHelperAdvice.getAttributes().getNamedItem(TYPE_ATTRIBUTE);
+
+ if (type == null) {
+ editHelperAdvice.setAttribute(TYPE_ATTRIBUTE, EDITHELPERADVICECONFIGURATION_TYPE);
+ } else if (!type.getNodeValue().equals(EDITHELPERADVICECONFIGURATION_TYPE)) {
+ editHelperAdvice.removeAttribute(EDITHELPERADVICECLASSNAME_ATTRIBUTE);
+ }
+
+ editHelperAdvice.removeAttribute(NAME_ATTRIBUTE);
+ editHelperAdvice.removeAttribute(IDENTIFIER_ATTRIBUTE);
+ }
+
+ NodeList adviceBindingsConfigurations = root.getElementsByTagName(ADVICEBINDINGSCONFIGURATIONS_TAG);
+
+ for (int i = 0; i < adviceBindingsConfigurations.getLength(); i++) {
+ Element adviceBinding = (Element) adviceBindingsConfigurations.item(i);
+
+ Node type = adviceBinding.getAttributes().getNamedItem(TYPE_ATTRIBUTE);
+
+ if (type == null) {
+ adviceBinding.setAttribute(TYPE_ATTRIBUTE, ADVICEBINDINGCONFIGURATION_TYPE);
+ } else if (!type.getNodeValue().equals(ADVICEBINDINGCONFIGURATION_TYPE)) {
+ adviceBinding.removeAttribute(EDITHELPERADVICECLASSNAME_ATTRIBUTE);
+ }
+
+ adviceBinding.removeAttribute(NAME_ATTRIBUTE);
+ }
+
+ NodeList matcherConfigurations = root.getElementsByTagName(MATCHERCONFIGURATION_TAG);
+
+ for (int i = 0; i < matcherConfigurations.getLength(); i++) {
+ Element matcher = (Element) matcherConfigurations.item(i);
+
+ Node type = matcher.getAttributes().getNamedItem(TYPE_ATTRIBUTE);
+
+ if (type == null) {
+ matcher.setAttribute(TYPE_ATTRIBUTE, MATCHER_TYPE);
+ } else {
+ matcher.removeAttribute(MATCHERCLASSNAME_ATTRIBUTE);
+ }
+ }
+
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ Result output = new StreamResult(file);
+ Source input = new DOMSource(doc);
+
+ transformer.transform(input, output);
+ }
+
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TransformerConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TransformerFactoryConfigurationError e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TransformerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ }
+ return null;
+ }
+
+
+
+
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventContentProvider.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventContentProvider.java
index ed359c6846f..dab888ab1c1 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventContentProvider.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventContentProvider.java
@@ -23,8 +23,8 @@ import java.util.Map;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.ElementTypesConfigurationsEventsChain;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.AbstractElementTypesConfigurationsEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.ElementTypesConfigurationsEventsChain;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.AbstractElementTypesConfigurationsEvent;
public class ElementTypesConfigurationsEventContentProvider implements ITreeContentProvider {
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventLabelProvider.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventLabelProvider.java
index eaec0f088c4..7be683e4e2a 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventLabelProvider.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/providers/ElementTypesConfigurationsEventLabelProvider.java
@@ -19,9 +19,9 @@ import java.util.Collection;
import java.util.Map;
import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.ElementTypesConfigurationsEventsChain;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.ElementTypesConfigurationsEventType;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IElementTypesConfigurationsEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.ElementTypesConfigurationsEventsChain;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.ElementTypesConfigurationsEventType;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IElementTypesConfigurationsEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/ElementTypesConfigurationsEventPrinter.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/ElementTypesConfigurationsEventPrinter.java
index d285a0a6af7..07edd34b9ad 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/ElementTypesConfigurationsEventPrinter.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/ElementTypesConfigurationsEventPrinter.java
@@ -20,20 +20,20 @@ import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.AdviceApprovedEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.AdviceDisapprovedEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.AdviceRequestConfigurationEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.EditHelperApprovedEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.EditHelperDisapprovedEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.EditHelperRequestConfigurationEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.ExecutableAdviceEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.ExecutableEditHelperEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IAdviceEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IElementTypesConfigurationsEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IdentityAdviceEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IdentityEditHelperEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.UnexecutableAdviceEvent;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.UnexecutableEditHelperEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.AdviceApprovedEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.AdviceDisapprovedEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.AdviceRequestConfigurationEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.EditHelperApprovedEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.EditHelperDisapprovedEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.EditHelperRequestConfigurationEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.ExecutableAdviceEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.ExecutableEditHelperEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IAdviceEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IElementTypesConfigurationsEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IdentityAdviceEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IdentityEditHelperEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.UnexecutableAdviceEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.UnexecutableEditHelperEvent;
public class ElementTypesConfigurationsEventPrinter {
public static Map<String, String> getEventDetails(IElementTypesConfigurationsEvent event) {
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/NotifierNullEditHelper.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/NotifierNullEditHelper.java
index 1ff2b2cdd8a..9173ffb9af2 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/NotifierNullEditHelper.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/utils/NotifierNullEditHelper.java
@@ -15,7 +15,7 @@ package org.eclipse.papyrus.elementtypesconfigurations.developer.utils;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.AbstractNotifierEditHelper;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.AbstractNotifierEditHelper;
/**
* Edit helper for the NullElementType that considers before and after
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/ElementTypesConfigurationsListenerView.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/ElementTypesConfigurationsListenerView.java
index e17ad196472..47ea0f8693b 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/ElementTypesConfigurationsListenerView.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/src/org/eclipse/papyrus/elementtypesconfigurations/developer/view/ElementTypesConfigurationsListenerView.java
@@ -32,10 +32,10 @@ import org.eclipse.papyrus.elementtypesconfigurations.developer.providers.Elemen
import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.ElementTypeRegistryUtils;
import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.ElementTypesConfigurationsEventPrinter;
import org.eclipse.papyrus.elementtypesconfigurations.developer.utils.NotifierNullEditHelper;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.ElementTypesConfigurationsEventsChain;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.ElementTypesConfigurationsListenersRegistry;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.IElementTypesConfigurationsEventsChainListener;
-import org.eclipse.papyrus.infra.elementtypesconfiguration.notification.events.IElementTypesConfigurationsEvent;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.ElementTypesConfigurationsEventsChain;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.ElementTypesConfigurationsListenersRegistry;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.IElementTypesConfigurationsEventsChainListener;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.notification.events.IElementTypesConfigurationsEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.SashForm;

Back to the top