Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils')
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/EClassComparator.java48
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeConfigurationComparator.java48
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeRegistryUtils.java90
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/GenerateElementTypesConfigurationsUtils.java224
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/IElementTypeComparator.java48
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/NotifierNullEditHelper.java58
-rw-r--r--plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/TypesEventPrinter.java276
7 files changed, 396 insertions, 396 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/EClassComparator.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/EClassComparator.java
index 43edf19b7f2..25a9421e6f6 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/EClassComparator.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/EClassComparator.java
@@ -1,25 +1,25 @@
-/*****************************************************************************
- * 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.dev.types.utils;
-
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.EClass;
-
-public class EClassComparator implements Comparator<EClass> {
-
- @Override
- public int compare(EClass o1, EClass o2) {
- return o1.getName().compareTo(o2.getName());
- }
+/*****************************************************************************
+ * 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.dev.types.utils;
+
+import java.util.Comparator;
+
+import org.eclipse.emf.ecore.EClass;
+
+public class EClassComparator implements Comparator<EClass> {
+
+ @Override
+ public int compare(EClass o1, EClass o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeConfigurationComparator.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeConfigurationComparator.java
index 6632433a54f..b8de00edf4c 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeConfigurationComparator.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeConfigurationComparator.java
@@ -1,25 +1,25 @@
-/*****************************************************************************
- * 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.dev.types.utils;
-
-import java.util.Comparator;
-
-import org.eclipse.papyrus.infra.types.ElementTypeConfiguration;
-
-public class ElementTypeConfigurationComparator implements Comparator<ElementTypeConfiguration> {
-
- @Override
- public int compare(ElementTypeConfiguration o1, ElementTypeConfiguration o2) {
- return o1.getName().compareTo(o2.getName());
- }
+/*****************************************************************************
+ * 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.dev.types.utils;
+
+import java.util.Comparator;
+
+import org.eclipse.papyrus.infra.types.ElementTypeConfiguration;
+
+public class ElementTypeConfigurationComparator implements Comparator<ElementTypeConfiguration> {
+
+ @Override
+ public int compare(ElementTypeConfiguration o1, ElementTypeConfiguration o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeRegistryUtils.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeRegistryUtils.java
index bd6cd54695b..0b44546e382 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeRegistryUtils.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/ElementTypeRegistryUtils.java
@@ -1,45 +1,45 @@
-/*****************************************************************************
- * 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.dev.types.utils;
-
-import java.lang.reflect.Field;
-
-import org.eclipse.gmf.runtime.emf.type.core.MetamodelType;
-import org.eclipse.papyrus.dev.types.Activator;
-
-
-public class ElementTypeRegistryUtils {
-
-
- static public synchronized Field getNullElementTypeEditHelper() {
-
- Field declaredField = null;
- try {
- declaredField = MetamodelType.class.getDeclaredField("editHelper");
- } catch (SecurityException e1) {
- Activator.log.error(e1);
- return null;
- } catch (NoSuchFieldException e1) {
- Activator.log.error(e1);
- return null;
- }
- if (declaredField == null) {
- Activator.log.error("impossible to find editHelper", null);
- return null;
- }
- declaredField.setAccessible(true);
-
- return declaredField;
- }
-
-}
+/*****************************************************************************
+ * 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.dev.types.utils;
+
+import java.lang.reflect.Field;
+
+import org.eclipse.gmf.runtime.emf.type.core.MetamodelType;
+import org.eclipse.papyrus.dev.types.Activator;
+
+
+public class ElementTypeRegistryUtils {
+
+
+ static public synchronized Field getNullElementTypeEditHelper() {
+
+ Field declaredField = null;
+ try {
+ declaredField = MetamodelType.class.getDeclaredField("editHelper");
+ } catch (SecurityException e1) {
+ Activator.log.error(e1);
+ return null;
+ } catch (NoSuchFieldException e1) {
+ Activator.log.error(e1);
+ return null;
+ }
+ if (declaredField == null) {
+ Activator.log.error("impossible to find editHelper", null);
+ return null;
+ }
+ declaredField.setAccessible(true);
+
+ return declaredField;
+ }
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/GenerateElementTypesConfigurationsUtils.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/GenerateElementTypesConfigurationsUtils.java
index fbc452094b2..05a3ad24c00 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/GenerateElementTypesConfigurationsUtils.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/GenerateElementTypesConfigurationsUtils.java
@@ -1,112 +1,112 @@
-/*****************************************************************************
- * 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.dev.types.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.uml2.uml.UMLPackage;
-
-public class GenerateElementTypesConfigurationsUtils {
-
-
-
- static public Collection<EReference> findAmbiguousContainments(EReference eReference, Collection<EReference> possibleContainmentsEReference) {
- HashSet<EReference> result = new HashSet<EReference>();
-
- for (EReference ownerContainment : eReference.getEContainingClass().getEAllContainments()) {
- for (EReference possibleContainement : possibleContainmentsEReference) {
- if (eReference != possibleContainement) {
- if (ownerContainment.equals(possibleContainement)) {
- result.add(possibleContainement);
- }
- }
- }
- }
-
- return result;
- }
-
- static public Collection<EReference> findPossibleContainmentsEReference(EClass ownedEClass, Collection<EClass> ownerTypes) {
- HashSet<EReference> result = new HashSet<EReference>();
- for (EClass candidateOwner : ownerTypes) {
- for (EReference eReference : candidateOwner.getEAllContainments()) {
- if (isKindOf(ownedEClass, eReference.getEReferenceType())) {
- result.add(eReference);
- }
- }
- }
- return result;
- }
-
- static public boolean isKindOf(EClass a, EClassifier b) {
- if (a.getEAllSuperTypes().contains(b)) {
- return true;
- } else {
- return a.equals(b);
- }
- }
-
- static public Collection<EClass> getAllEClass(EPackage ePackage) {
- List<EClass> eClasses = new ArrayList<EClass>();
- for (EClassifier eClassifier : ePackage.getEClassifiers()) {
- if (eClassifier instanceof EClass) {
- eClasses.add((EClass) eClassifier);
- }
- }
-
- Collections.sort(eClasses, new EClassComparator());
-
- return eClasses;
- }
-
- static public String getIdentifier(EClass eClass) {
- return "org.eclipse.papyrus.uml." + eClass.getName();
- }
-
- static public String getAsName(EReference containmentEReference, EClass container) {
- return "_As_" + ((ENamedElement) container.eContainer()).getName().toUpperCase() + "::" + container.getName() + "::" + containmentEReference.getName();
- }
-
- static public boolean isSpecializedASpecialization(EClass eClass, EReference containmentEReference) {
- Collection<EReference> possibleContainmentsEReference = findPossibleContainmentsEReference(eClass, getAllEClass(UMLPackage.eINSTANCE));
- if (!findAmbiguousContainments(containmentEReference, possibleContainmentsEReference).isEmpty()) {
- // The SpecialiazedType is SpecializationType
- return true;
- } else {
- // The SpecialiazedType is MetamodelType
- return false;
-
- }
- }
-
- static public String findSpecializedTypesIDs(EClass eClass, EReference containmentEReference) {
- if (isSpecializedASpecialization(eClass, containmentEReference)) {
- // The SpecialiazedType is SpecializationType
- return GenerateElementTypesConfigurationsUtils.getIdentifier(eClass) + GenerateElementTypesConfigurationsUtils.getAsName(containmentEReference, eClass);
- } else {
- // The SpecialiazedType is MetamodelType
- return getIdentifier(eClass);
- }
-
-
- }
-}
+/*****************************************************************************
+ * 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.dev.types.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.uml2.uml.UMLPackage;
+
+public class GenerateElementTypesConfigurationsUtils {
+
+
+
+ static public Collection<EReference> findAmbiguousContainments(EReference eReference, Collection<EReference> possibleContainmentsEReference) {
+ HashSet<EReference> result = new HashSet<EReference>();
+
+ for (EReference ownerContainment : eReference.getEContainingClass().getEAllContainments()) {
+ for (EReference possibleContainement : possibleContainmentsEReference) {
+ if (eReference != possibleContainement) {
+ if (ownerContainment.equals(possibleContainement)) {
+ result.add(possibleContainement);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ static public Collection<EReference> findPossibleContainmentsEReference(EClass ownedEClass, Collection<EClass> ownerTypes) {
+ HashSet<EReference> result = new HashSet<EReference>();
+ for (EClass candidateOwner : ownerTypes) {
+ for (EReference eReference : candidateOwner.getEAllContainments()) {
+ if (isKindOf(ownedEClass, eReference.getEReferenceType())) {
+ result.add(eReference);
+ }
+ }
+ }
+ return result;
+ }
+
+ static public boolean isKindOf(EClass a, EClassifier b) {
+ if (a.getEAllSuperTypes().contains(b)) {
+ return true;
+ } else {
+ return a.equals(b);
+ }
+ }
+
+ static public Collection<EClass> getAllEClass(EPackage ePackage) {
+ List<EClass> eClasses = new ArrayList<EClass>();
+ for (EClassifier eClassifier : ePackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ eClasses.add((EClass) eClassifier);
+ }
+ }
+
+ Collections.sort(eClasses, new EClassComparator());
+
+ return eClasses;
+ }
+
+ static public String getIdentifier(EClass eClass) {
+ return "org.eclipse.papyrus.uml." + eClass.getName();
+ }
+
+ static public String getAsName(EReference containmentEReference, EClass container) {
+ return "_As_" + ((ENamedElement) container.eContainer()).getName().toUpperCase() + "::" + container.getName() + "::" + containmentEReference.getName();
+ }
+
+ static public boolean isSpecializedASpecialization(EClass eClass, EReference containmentEReference) {
+ Collection<EReference> possibleContainmentsEReference = findPossibleContainmentsEReference(eClass, getAllEClass(UMLPackage.eINSTANCE));
+ if (!findAmbiguousContainments(containmentEReference, possibleContainmentsEReference).isEmpty()) {
+ // The SpecialiazedType is SpecializationType
+ return true;
+ } else {
+ // The SpecialiazedType is MetamodelType
+ return false;
+
+ }
+ }
+
+ static public String findSpecializedTypesIDs(EClass eClass, EReference containmentEReference) {
+ if (isSpecializedASpecialization(eClass, containmentEReference)) {
+ // The SpecialiazedType is SpecializationType
+ return GenerateElementTypesConfigurationsUtils.getIdentifier(eClass) + GenerateElementTypesConfigurationsUtils.getAsName(containmentEReference, eClass);
+ } else {
+ // The SpecialiazedType is MetamodelType
+ return getIdentifier(eClass);
+ }
+
+
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/IElementTypeComparator.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/IElementTypeComparator.java
index b557679d875..622d729ecd7 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/IElementTypeComparator.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/IElementTypeComparator.java
@@ -1,25 +1,25 @@
-/*****************************************************************************
- * 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.dev.types.utils;
-
-import java.util.Comparator;
-
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-
-public class IElementTypeComparator implements Comparator<IElementType> {
-
- @Override
- public int compare(IElementType o1, IElementType o2) {
- return o1.getId().compareTo(o2.getId());
- }
+/*****************************************************************************
+ * 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.dev.types.utils;
+
+import java.util.Comparator;
+
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+
+public class IElementTypeComparator implements Comparator<IElementType> {
+
+ @Override
+ public int compare(IElementType o1, IElementType o2) {
+ return o1.getId().compareTo(o2.getId());
+ }
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/NotifierNullEditHelper.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/NotifierNullEditHelper.java
index c7297f9d370..df2e84c7db1 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/NotifierNullEditHelper.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/NotifierNullEditHelper.java
@@ -1,30 +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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.dev.types.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.types.core.notification.AbstractNotifierEditHelper;
-
-/**
- * Edit helper for the NullElementType that considers before and after
- * advice, only.
- */
-public class NotifierNullEditHelper
- extends AbstractNotifierEditHelper {
-
- protected ICommand getInsteadCommand(IEditCommandRequest req) {
- return null;
- }
+/*****************************************************************************
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.dev.types.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.types.core.notification.AbstractNotifierEditHelper;
+
+/**
+ * Edit helper for the NullElementType that considers before and after
+ * advice, only.
+ */
+public class NotifierNullEditHelper
+ extends AbstractNotifierEditHelper {
+
+ protected ICommand getInsteadCommand(IEditCommandRequest req) {
+ return null;
+ }
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/TypesEventPrinter.java b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/TypesEventPrinter.java
index 88ef53da10f..f8213214503 100644
--- a/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/TypesEventPrinter.java
+++ b/plugins/developer/org.eclipse.papyrus.dev.types/src/org/eclipse/papyrus/dev/types/utils/TypesEventPrinter.java
@@ -1,138 +1,138 @@
-/*****************************************************************************
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.dev.types.utils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-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.types.core.notification.events.AdviceApprovedEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.AdviceDisapprovedEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.AdviceRequestEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperApprovedEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperDisapprovedEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperRequestEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.ExecutableAdviceEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.ExecutableEditHelperEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.IAdviceEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.ITypesEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.IdentityAdviceEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.IdentityEditHelperEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.UnexecutableAdviceEvent;
-import org.eclipse.papyrus.infra.types.core.notification.events.UnexecutableEditHelperEvent;
-
-public class TypesEventPrinter {
- public static Map<String, String> getEventDetails(ITypesEvent event) {
- Map<String, String> result = new HashMap<>();
-
- if (event instanceof AdviceApprovedEvent) {
- result.put("Approved Advice", ((AdviceApprovedEvent) event).getAdvice().getClass().getName());
- } else if (event instanceof AdviceDisapprovedEvent) {
- result.put("Disapprover Advice", ((AdviceDisapprovedEvent) event).getAdvice().getClass().getName());
- } else if (event instanceof EditHelperApprovedEvent) {
- result.put("Approver edithelper", ((EditHelperApprovedEvent) event).getEditHelper().getClass().getName());
- } else if (event instanceof EditHelperDisapprovedEvent) {
- result.put("Disapprover edithelper", ((EditHelperDisapprovedEvent) event).getEditHelper().getClass().getName());
- } else if (event instanceof ExecutableAdviceEvent) {
- result.put("Advice", ((ExecutableAdviceEvent) event).getAdvice().getClass().getName());
- result.put("Phase ", ((ExecutableAdviceEvent) event).getAdvicePhase().name());
- result.put("Executable command", ((ExecutableAdviceEvent) event).getCommand().getClass().getName());
- } else if (event instanceof ExecutableEditHelperEvent) {
- result.put("Executable command from edithelper", ((ExecutableEditHelperEvent) event).getEditHelper().getClass().getName());
- result.put("Executable command", ((ExecutableEditHelperEvent) event).getCommand().getClass().getName());
- } else if (event instanceof IdentityAdviceEvent) {
- result.put("Identity Advice", ((IdentityAdviceEvent) event).getAdvice().getClass().getName());
- result.put("Phase ", ((IdentityAdviceEvent) event).getAdvicePhase().name());
- } else if (event instanceof IdentityEditHelperEvent) {
- result.put("Identity EditHelper", ((IdentityEditHelperEvent) event).getEditHelper().getClass().getName());
- } else if (event instanceof UnexecutableAdviceEvent) {
- result.put("Unexecutable Advice", ((UnexecutableAdviceEvent) event).getAdvice().getClass().getName());
- result.put("Phase ", ((UnexecutableAdviceEvent) event).getAdvicePhase().name());
- result.put("Unexecutable command", ((UnexecutableAdviceEvent) event).getCommand().getClass().getName());
- } else if (event instanceof UnexecutableEditHelperEvent) {
- result.put("Unexecutable command from edithelper", ((UnexecutableEditHelperEvent) event).getEditHelper().getClass().getName());
- result.put("Unexecutable command", ((UnexecutableEditHelperEvent) event).getCommand().getClass().getName());
- } else if (event instanceof AdviceRequestEvent) {
- result.put("RequestConfiguration Advice", ((AdviceRequestEvent) event).getAdvice().getClass().getName());
- } else if (event instanceof EditHelperRequestEvent) {
- result.put("RequestConfiguration EditHelper", ((EditHelperRequestEvent) event).getEditHelper().getClass().getName());
- }
-
- if (event instanceof IAdviceEvent) {
- String adviceNames = "";
- for (IEditHelperAdvice editHelperAdvice : ((IAdviceEvent) event).getAdvices()) {
- adviceNames += " -" + editHelperAdvice.getClass().getName() + "\n";
- }
- result.put("Among the following advices ", adviceNames);
- }
-
- return result;
- }
-
- public static String printHtmlEvent(Map<String, String> details) {
-
-
- String html = "<table border=\"1\">";
- for (String key : details.keySet()) {
- html += "<tr>";
- html += "<td><b>" + key + "<b></td>";
- html += "<td>" + details.get(key) + "</td>";
- html += "</tr>";
- }
- html += "</table>";
-
- html = html.replaceAll("\\n", "<br>");
-
- return html;
- }
-
- /**
- * @param req
- * @return
- */
- public static String printHtmRequest(IEditCommandRequest req) {
- String result = "<ul>";
- result += "<li><b>Request</b>: " + req + "</li>";
- result += "<li><b>Label</b>: " + req.getLabel() + "</li>";
- result += "<li><b>Kind</b>: " + req.getClass().getName() + "</li>";
- result += "<li><b>ElementsToEdit</b>: " + req.getElementsToEdit() + "</li>";
- result += "<li><b>Parameters</b>:</li>";
-
- if (!req.getParameters().keySet().isEmpty()) {
- result += "<ul>";
-
- for (Object key : req.getParameters().keySet()) {
- result += "<li><b>" + key + "</b> <-> " + req.getParameters().get(key) + "</li>";
- }
- result += "</ul>";
- }
- result += "<li><b>EditHelperContext</b>: " + req.getEditHelperContext() + "</li>";
-
- if (req instanceof CreateElementRequest) {
- result += "<li><b>ElementType</b>: " + ((CreateElementRequest) req).getElementType() + "</li>";
- result += "<li><b>Container</b>: " + ((CreateElementRequest) req).getContainer() + "</li>";
- result += "<li><b>ContainmentFeature</b>: " + ((CreateElementRequest) req).getContainmentFeature() + "</li>";
- if (req instanceof CreateRelationshipRequest) {
- result += "<li><b>Source</b>: " + ((CreateRelationshipRequest) req).getSource() + "</li>";
- result += "<li><b>Target</b>: " + ((CreateRelationshipRequest) req).getTarget() + "</li>";
- }
- }
- result += "</ul>";
-
- return result;
- }
-}
+/*****************************************************************************
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.dev.types.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.types.core.notification.events.AdviceApprovedEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.AdviceDisapprovedEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.AdviceRequestEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperApprovedEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperDisapprovedEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.EditHelperRequestEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.ExecutableAdviceEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.ExecutableEditHelperEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.IAdviceEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.ITypesEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.IdentityAdviceEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.IdentityEditHelperEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.UnexecutableAdviceEvent;
+import org.eclipse.papyrus.infra.types.core.notification.events.UnexecutableEditHelperEvent;
+
+public class TypesEventPrinter {
+ public static Map<String, String> getEventDetails(ITypesEvent event) {
+ Map<String, String> result = new HashMap<>();
+
+ if (event instanceof AdviceApprovedEvent) {
+ result.put("Approved Advice", ((AdviceApprovedEvent) event).getAdvice().getClass().getName());
+ } else if (event instanceof AdviceDisapprovedEvent) {
+ result.put("Disapprover Advice", ((AdviceDisapprovedEvent) event).getAdvice().getClass().getName());
+ } else if (event instanceof EditHelperApprovedEvent) {
+ result.put("Approver edithelper", ((EditHelperApprovedEvent) event).getEditHelper().getClass().getName());
+ } else if (event instanceof EditHelperDisapprovedEvent) {
+ result.put("Disapprover edithelper", ((EditHelperDisapprovedEvent) event).getEditHelper().getClass().getName());
+ } else if (event instanceof ExecutableAdviceEvent) {
+ result.put("Advice", ((ExecutableAdviceEvent) event).getAdvice().getClass().getName());
+ result.put("Phase ", ((ExecutableAdviceEvent) event).getAdvicePhase().name());
+ result.put("Executable command", ((ExecutableAdviceEvent) event).getCommand().getClass().getName());
+ } else if (event instanceof ExecutableEditHelperEvent) {
+ result.put("Executable command from edithelper", ((ExecutableEditHelperEvent) event).getEditHelper().getClass().getName());
+ result.put("Executable command", ((ExecutableEditHelperEvent) event).getCommand().getClass().getName());
+ } else if (event instanceof IdentityAdviceEvent) {
+ result.put("Identity Advice", ((IdentityAdviceEvent) event).getAdvice().getClass().getName());
+ result.put("Phase ", ((IdentityAdviceEvent) event).getAdvicePhase().name());
+ } else if (event instanceof IdentityEditHelperEvent) {
+ result.put("Identity EditHelper", ((IdentityEditHelperEvent) event).getEditHelper().getClass().getName());
+ } else if (event instanceof UnexecutableAdviceEvent) {
+ result.put("Unexecutable Advice", ((UnexecutableAdviceEvent) event).getAdvice().getClass().getName());
+ result.put("Phase ", ((UnexecutableAdviceEvent) event).getAdvicePhase().name());
+ result.put("Unexecutable command", ((UnexecutableAdviceEvent) event).getCommand().getClass().getName());
+ } else if (event instanceof UnexecutableEditHelperEvent) {
+ result.put("Unexecutable command from edithelper", ((UnexecutableEditHelperEvent) event).getEditHelper().getClass().getName());
+ result.put("Unexecutable command", ((UnexecutableEditHelperEvent) event).getCommand().getClass().getName());
+ } else if (event instanceof AdviceRequestEvent) {
+ result.put("RequestConfiguration Advice", ((AdviceRequestEvent) event).getAdvice().getClass().getName());
+ } else if (event instanceof EditHelperRequestEvent) {
+ result.put("RequestConfiguration EditHelper", ((EditHelperRequestEvent) event).getEditHelper().getClass().getName());
+ }
+
+ if (event instanceof IAdviceEvent) {
+ String adviceNames = "";
+ for (IEditHelperAdvice editHelperAdvice : ((IAdviceEvent) event).getAdvices()) {
+ adviceNames += " -" + editHelperAdvice.getClass().getName() + "\n";
+ }
+ result.put("Among the following advices ", adviceNames);
+ }
+
+ return result;
+ }
+
+ public static String printHtmlEvent(Map<String, String> details) {
+
+
+ String html = "<table border=\"1\">";
+ for (String key : details.keySet()) {
+ html += "<tr>";
+ html += "<td><b>" + key + "<b></td>";
+ html += "<td>" + details.get(key) + "</td>";
+ html += "</tr>";
+ }
+ html += "</table>";
+
+ html = html.replaceAll("\\n", "<br>");
+
+ return html;
+ }
+
+ /**
+ * @param req
+ * @return
+ */
+ public static String printHtmRequest(IEditCommandRequest req) {
+ String result = "<ul>";
+ result += "<li><b>Request</b>: " + req + "</li>";
+ result += "<li><b>Label</b>: " + req.getLabel() + "</li>";
+ result += "<li><b>Kind</b>: " + req.getClass().getName() + "</li>";
+ result += "<li><b>ElementsToEdit</b>: " + req.getElementsToEdit() + "</li>";
+ result += "<li><b>Parameters</b>:</li>";
+
+ if (!req.getParameters().keySet().isEmpty()) {
+ result += "<ul>";
+
+ for (Object key : req.getParameters().keySet()) {
+ result += "<li><b>" + key + "</b> <-> " + req.getParameters().get(key) + "</li>";
+ }
+ result += "</ul>";
+ }
+ result += "<li><b>EditHelperContext</b>: " + req.getEditHelperContext() + "</li>";
+
+ if (req instanceof CreateElementRequest) {
+ result += "<li><b>ElementType</b>: " + ((CreateElementRequest) req).getElementType() + "</li>";
+ result += "<li><b>Container</b>: " + ((CreateElementRequest) req).getContainer() + "</li>";
+ result += "<li><b>ContainmentFeature</b>: " + ((CreateElementRequest) req).getContainmentFeature() + "</li>";
+ if (req instanceof CreateRelationshipRequest) {
+ result += "<li><b>Source</b>: " + ((CreateRelationshipRequest) req).getSource() + "</li>";
+ result += "<li><b>Target</b>: " + ((CreateRelationshipRequest) req).getTarget() + "</li>";
+ }
+ }
+ result += "</ul>";
+
+ return result;
+ }
+}

Back to the top