Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreperico2011-03-04 08:29:02 +0000
committereperico2011-03-04 08:29:02 +0000
commit70376f360ec347439159a47a3bff7bcd9d4a0e6e (patch)
treee23ffdbce012c0a5dad0b5356b7952e7b6e2722b
parent6057b0e42f2dd0527a920361832ca35cd4a47632 (diff)
downloadorg.eclipse.papyrus-70376f360ec347439159a47a3bff7bcd9d4a0e6e.tar.gz
org.eclipse.papyrus-70376f360ec347439159a47a3bff7bcd9d4a0e6e.tar.xz
org.eclipse.papyrus-70376f360ec347439159a47a3bff7bcd9d4a0e6e.zip
NEW - bug 338808: [General] Merge collaborative work features to the trunk
https://bugs.eclipse.org/bugs/show_bug.cgi?id=338808
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/history/utils/HistoryUtils.java4
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/ControledResource.java30
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyFactory.java5
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyPackage.java53
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/ControledResourceImpl.java152
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyFactoryImpl.java48
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyPackageImpl.java52
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historyAdapterFactory.java44
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historySwitch.java49
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF3
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/CollaborativeActionsFactory.java2
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusControlAction.java73
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java38
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java314
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IControlCondition.java7
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IUncontrolCommand.java3
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/UncontrolCommand.java85
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/ui/ControlResourceDialog.java17
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/CorePlugin.java8
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/StrategyChooser.java3
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/Activator.java6
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ControledResourceAdapter.java8
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategy.java8
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategyExtension.java10
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSet.java4
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSetServiceFactory.java15
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/impl/ProxyManager.java4
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/AskUserStrategy.java7
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadAllResources.java2
-rw-r--r--plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadCurrentResource.java5
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java28
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java120
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java86
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/ModelSet.java37
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java112
-rw-r--r--plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/META-INF/MANIFEST.MF7
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/build.properties3
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/plugin.xml35
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Activator.java6
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Messages.java46
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCommand.java36
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCondition.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileUncontrolCommand.java45
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/ProfileApplicationHelper.java175
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/SafeDialogOpenerDuringValidation.java72
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/messages.properties4
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/providers/UMLValidationProvider.java189
-rw-r--r--plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/validation/ProfileApplicationDuplicationChecker.java332
49 files changed, 1964 insertions, 436 deletions
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/history/utils/HistoryUtils.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/history/utils/HistoryUtils.java
index a057a956657..80c2fce0d4b 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/history/utils/HistoryUtils.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/history/utils/HistoryUtils.java
@@ -147,7 +147,7 @@ public class HistoryUtils {
}
/**
- * Get all the controled resource in the Model Set with the corresponding url
+ * Get all the controlled resource in the Model Set with the corresponding url
*
* @param set
* @param url
@@ -155,7 +155,7 @@ public class HistoryUtils {
*/
public static List<ControledResource> getControledResourcesForURL(ModelSet set, String url) {
if(url == null || set == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
List<ControledResource> result = new LinkedList<ControledResource>();
for(Resource r : set.getResources()) {
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/ControledResource.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/ControledResource.java
index 31b5c8c60f4..8aebce39fb3 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/ControledResource.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/ControledResource.java
@@ -14,37 +14,38 @@ import org.eclipse.emf.ecore.EObject;
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Controled Resource</b></em>'.
* <!-- end-user-doc -->
- *
+ *
* <!-- begin-model-doc -->
* Represent a Controled Resource.
* It is a node made of children. The node know its resource URL, and is able to get its children.
* A child is a Resource controled by this node.
* <!-- end-model-doc -->
- *
+ *
* <p>
* The following features are supported:
* <ul>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren <em>Children</em>}</li>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent <em>Parent</em>}</li>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL <em>Resource URL</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren <em>Children</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent <em>Parent</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL <em>Resource URL</em>}</li>
* </ul>
* </p>
- *
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage#getControledResource()
* @model
* @generated
*/
public interface ControledResource extends EObject {
+
/**
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
* The list contents are of type {@link org.eclipse.papyrus.controlmode.mm.history.ControledResource}.
* It is bidirectional and its opposite is '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent <em>Parent</em>}'.
* <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Children</em>' containment reference list isn't clear,
- * there really should be more of a description here...
+ * If the meaning of the '<em>Children</em>' containment reference list isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
+ *
* @return the value of the '<em>Children</em>' containment reference list.
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage#getControledResource_Children()
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent
@@ -58,10 +59,10 @@ public interface ControledResource extends EObject {
* It is bidirectional and its opposite is '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren <em>Children</em>}'.
* <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Parent</em>' container reference isn't clear,
- * there really should be more of a description here...
+ * If the meaning of the '<em>Parent</em>' container reference isn't clear, there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
+ *
* @return the value of the '<em>Parent</em>' container reference.
* @see #setParent(ControledResource)
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage#getControledResource_Parent()
@@ -75,7 +76,9 @@ public interface ControledResource extends EObject {
* Sets the value of the '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent <em>Parent</em>}' container reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param value the new value of the '<em>Parent</em>' container reference.
+ *
+ * @param value
+ * the new value of the '<em>Parent</em>' container reference.
* @see #getParent()
* @generated
*/
@@ -88,6 +91,7 @@ public interface ControledResource extends EObject {
* <!-- begin-model-doc -->
* URL of this ControledResource.
* <!-- end-model-doc -->
+ *
* @return the value of the '<em>Resource URL</em>' attribute.
* @see #setResourceURL(String)
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage#getControledResource_ResourceURL()
@@ -100,7 +104,9 @@ public interface ControledResource extends EObject {
* Sets the value of the '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL <em>Resource URL</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param value the new value of the '<em>Resource URL</em>' attribute.
+ *
+ * @param value
+ * the new value of the '<em>Resource URL</em>' attribute.
* @see #getResourceURL()
* @generated
*/
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyFactory.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyFactory.java
index df06568df73..3455654c7a9 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyFactory.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyFactory.java
@@ -13,14 +13,17 @@ import org.eclipse.emf.ecore.EFactory;
* The <b>Factory</b> for the model.
* It provides a create method for each non-abstract class of the model.
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage
* @generated
*/
public interface historyFactory extends EFactory {
+
/**
* The singleton instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
historyFactory eINSTANCE = org.eclipse.papyrus.controlmode.mm.history.impl.historyFactoryImpl.init();
@@ -29,6 +32,7 @@ public interface historyFactory extends EFactory {
* Returns a new object of class '<em>Controled Resource</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return a new object of class '<em>Controled Resource</em>'.
* @generated
*/
@@ -38,6 +42,7 @@ public interface historyFactory extends EFactory {
* Returns the package supported by this factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the package supported by this factory.
* @generated
*/
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyPackage.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyPackage.java
index 2f85798878f..5182781df77 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyPackage.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/historyPackage.java
@@ -17,21 +17,24 @@ import org.eclipse.emf.ecore.EReference;
* The <b>Package</b> for the model.
* It contains accessors for the meta objects to represent
* <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.historyFactory
* @model kind="package"
* @generated
*/
public interface historyPackage extends EPackage {
+
/**
* The package name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
String eNAME = "history";
@@ -40,6 +43,7 @@ public interface historyPackage extends EPackage {
* The package namespace URI.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
String eNS_URI = "http://www.eclipse.org/papyrus/0.7.0/controlmode";
@@ -48,6 +52,7 @@ public interface historyPackage extends EPackage {
* The package namespace name.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
String eNS_PREFIX = "history";
@@ -56,6 +61,7 @@ public interface historyPackage extends EPackage {
* The singleton instance of the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
historyPackage eINSTANCE = org.eclipse.papyrus.controlmode.mm.history.impl.historyPackageImpl.init();
@@ -64,6 +70,7 @@ public interface historyPackage extends EPackage {
* The meta object id for the '{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl <em>Controled Resource</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl
* @see org.eclipse.papyrus.controlmode.mm.history.impl.historyPackageImpl#getControledResource()
* @generated
@@ -74,6 +81,7 @@ public interface historyPackage extends EPackage {
* The feature id for the '<em><b>Children</b></em>' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
* @ordered
*/
@@ -83,6 +91,7 @@ public interface historyPackage extends EPackage {
* The feature id for the '<em><b>Parent</b></em>' container reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
* @ordered
*/
@@ -92,6 +101,7 @@ public interface historyPackage extends EPackage {
* The feature id for the '<em><b>Resource URL</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
* @ordered
*/
@@ -101,6 +111,7 @@ public interface historyPackage extends EPackage {
* The number of structural features of the '<em>Controled Resource</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
* @ordered
*/
@@ -110,6 +121,7 @@ public interface historyPackage extends EPackage {
* The meta object id for the '<em>String</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see java.lang.String
* @see org.eclipse.papyrus.controlmode.mm.history.impl.historyPackageImpl#getString()
* @generated
@@ -121,6 +133,7 @@ public interface historyPackage extends EPackage {
* Returns the meta object for class '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource <em>Controled Resource</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the meta object for class '<em>Controled Resource</em>'.
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource
* @generated
@@ -128,9 +141,11 @@ public interface historyPackage extends EPackage {
EClass getControledResource();
/**
- * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren <em>Children</em>}'.
+ * Returns the meta object for the containment reference list '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren
+ * <em>Children</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the meta object for the containment reference list '<em>Children</em>'.
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource#getChildren()
* @see #getControledResource()
@@ -139,9 +154,11 @@ public interface historyPackage extends EPackage {
EReference getControledResource_Children();
/**
- * Returns the meta object for the container reference '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent <em>Parent</em>}'.
+ * Returns the meta object for the container reference '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent
+ * <em>Parent</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the meta object for the container reference '<em>Parent</em>'.
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource#getParent()
* @see #getControledResource()
@@ -150,9 +167,11 @@ public interface historyPackage extends EPackage {
EReference getControledResource_Parent();
/**
- * Returns the meta object for the attribute '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL <em>Resource URL</em>}'.
+ * Returns the meta object for the attribute '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL
+ * <em>Resource URL</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the meta object for the attribute '<em>Resource URL</em>'.
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource#getResourceURL()
* @see #getControledResource()
@@ -164,6 +183,7 @@ public interface historyPackage extends EPackage {
* Returns the meta object for data type '{@link java.lang.String <em>String</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the meta object for data type '<em>String</em>'.
* @see java.lang.String
* @model instanceClass="java.lang.String"
@@ -175,6 +195,7 @@ public interface historyPackage extends EPackage {
* Returns the factory that creates the instances of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the factory that creates the instances of the model.
* @generated
*/
@@ -184,19 +205,23 @@ public interface historyPackage extends EPackage {
* <!-- begin-user-doc -->
* Defines literals for the meta objects that represent
* <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
* </ul>
* <!-- end-user-doc -->
+ *
* @generated
*/
interface Literals {
+
/**
- * The meta object literal for the '{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl <em>Controled Resource</em>}' class.
+ * The meta object literal for the '{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl <em>Controled Resource</em>}'
+ * class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl
* @see org.eclipse.papyrus.controlmode.mm.history.impl.historyPackageImpl#getControledResource()
* @generated
@@ -207,6 +232,7 @@ public interface historyPackage extends EPackage {
* The meta object literal for the '<em><b>Children</b></em>' containment reference list feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
EReference CONTROLED_RESOURCE__CHILDREN = eINSTANCE.getControledResource_Children();
@@ -215,6 +241,7 @@ public interface historyPackage extends EPackage {
* The meta object literal for the '<em><b>Parent</b></em>' container reference feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
EReference CONTROLED_RESOURCE__PARENT = eINSTANCE.getControledResource_Parent();
@@ -223,6 +250,7 @@ public interface historyPackage extends EPackage {
* The meta object literal for the '<em><b>Resource URL</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
EAttribute CONTROLED_RESOURCE__RESOURCE_URL = eINSTANCE.getControledResource_ResourceURL();
@@ -231,6 +259,7 @@ public interface historyPackage extends EPackage {
* The meta object literal for the '<em>String</em>' data type.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see java.lang.String
* @see org.eclipse.papyrus.controlmode.mm.history.impl.historyPackageImpl#getString()
* @generated
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/ControledResourceImpl.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/ControledResourceImpl.java
index 2a861fdb725..56ba5670a5a 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/ControledResourceImpl.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/ControledResourceImpl.java
@@ -33,19 +33,21 @@ import org.eclipse.papyrus.controlmode.mm.history.historyPackage;
* <p>
* The following features are implemented:
* <ul>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getChildren <em>Children</em>}</li>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getParent <em>Parent</em>}</li>
- * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getResourceURL <em>Resource URL</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getChildren <em>Children</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getParent <em>Parent</em>}</li>
+ * <li>{@link org.eclipse.papyrus.controlmode.mm.history.impl.ControledResourceImpl#getResourceURL <em>Resource URL</em>}</li>
* </ul>
* </p>
- *
+ *
* @generated
*/
public class ControledResourceImpl extends EObjectImpl implements ControledResource {
+
/**
* The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getChildren()
* @generated
* @ordered
@@ -56,6 +58,7 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
* The default value of the '{@link #getResourceURL() <em>Resource URL</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getResourceURL()
* @generated
* @ordered
@@ -66,6 +69,7 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
* The cached value of the '{@link #getResourceURL() <em>Resource URL</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getResourceURL()
* @generated
* @ordered
@@ -75,6 +79,7 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
protected ControledResourceImpl() {
@@ -84,6 +89,7 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
@@ -94,10 +100,11 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EList<ControledResource> getChildren() {
- if (children == null) {
+ if(children == null) {
children = new EObjectContainmentWithInverseEList<ControledResource>(ControledResource.class, this, historyPackage.CONTROLED_RESOURCE__CHILDREN, historyPackage.CONTROLED_RESOURCE__PARENT);
}
return children;
@@ -106,16 +113,19 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public ControledResource getParent() {
- if (eContainerFeatureID() != historyPackage.CONTROLED_RESOURCE__PARENT) return null;
+ if(eContainerFeatureID() != historyPackage.CONTROLED_RESOURCE__PARENT)
+ return null;
return (ControledResource)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public NotificationChain basicSetParent(ControledResource newParent, NotificationChain msgs) {
@@ -126,27 +136,29 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public void setParent(ControledResource newParent) {
- if (newParent != eInternalContainer() || (eContainerFeatureID() != historyPackage.CONTROLED_RESOURCE__PARENT && newParent != null)) {
- if (EcoreUtil.isAncestor(this, newParent))
+ if(newParent != eInternalContainer() || (eContainerFeatureID() != historyPackage.CONTROLED_RESOURCE__PARENT && newParent != null)) {
+ if(EcoreUtil.isAncestor(this, newParent))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
- if (eInternalContainer() != null)
+ if(eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
- if (newParent != null)
+ if(newParent != null)
msgs = ((InternalEObject)newParent).eInverseAdd(this, historyPackage.CONTROLED_RESOURCE__CHILDREN, ControledResource.class, msgs);
msgs = basicSetParent(newParent, msgs);
- if (msgs != null) msgs.dispatch();
- }
- else if (eNotificationRequired())
+ if(msgs != null)
+ msgs.dispatch();
+ } else if(eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, historyPackage.CONTROLED_RESOURCE__PARENT, newParent, newParent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public String getResourceURL() {
@@ -156,30 +168,32 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public void setResourceURL(String newResourceURL) {
String oldResourceURL = resourceURL;
resourceURL = newResourceURL;
- if (eNotificationRequired())
+ if(eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, historyPackage.CONTROLED_RESOURCE__RESOURCE_URL, oldResourceURL, resourceURL));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs);
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- if (eInternalContainer() != null)
- msgs = eBasicRemoveFromContainer(msgs);
- return basicSetParent((ControledResource)otherEnd, msgs);
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs);
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ if(eInternalContainer() != null)
+ msgs = eBasicRemoveFromContainer(msgs);
+ return basicSetParent((ControledResource)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
@@ -187,15 +201,16 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- return basicSetParent(null, msgs);
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ return ((InternalEList<?>)getChildren()).basicRemove(otherEnd, msgs);
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ return basicSetParent(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -203,13 +218,14 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
- switch (eContainerFeatureID()) {
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- return eInternalContainer().eInverseRemove(this, historyPackage.CONTROLED_RESOURCE__CHILDREN, ControledResource.class, msgs);
+ switch(eContainerFeatureID()) {
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ return eInternalContainer().eInverseRemove(this, historyPackage.CONTROLED_RESOURCE__CHILDREN, ControledResource.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
@@ -217,17 +233,18 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- return getChildren();
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- return getParent();
- case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
- return getResourceURL();
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ return getChildren();
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ return getParent();
+ case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
+ return getResourceURL();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -235,22 +252,23 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- getChildren().clear();
- getChildren().addAll((Collection<? extends ControledResource>)newValue);
- return;
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- setParent((ControledResource)newValue);
- return;
- case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
- setResourceURL((String)newValue);
- return;
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ getChildren().clear();
+ getChildren().addAll((Collection<? extends ControledResource>)newValue);
+ return;
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ setParent((ControledResource)newValue);
+ return;
+ case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
+ setResourceURL((String)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -258,20 +276,21 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public void eUnset(int featureID) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- getChildren().clear();
- return;
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- setParent((ControledResource)null);
- return;
- case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
- setResourceURL(RESOURCE_URL_EDEFAULT);
- return;
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ getChildren().clear();
+ return;
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ setParent((ControledResource)null);
+ return;
+ case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
+ setResourceURL(RESOURCE_URL_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -279,17 +298,18 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
- switch (featureID) {
- case historyPackage.CONTROLED_RESOURCE__CHILDREN:
- return children != null && !children.isEmpty();
- case historyPackage.CONTROLED_RESOURCE__PARENT:
- return getParent() != null;
- case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
- return RESOURCE_URL_EDEFAULT == null ? resourceURL != null : !RESOURCE_URL_EDEFAULT.equals(resourceURL);
+ switch(featureID) {
+ case historyPackage.CONTROLED_RESOURCE__CHILDREN:
+ return children != null && !children.isEmpty();
+ case historyPackage.CONTROLED_RESOURCE__PARENT:
+ return getParent() != null;
+ case historyPackage.CONTROLED_RESOURCE__RESOURCE_URL:
+ return RESOURCE_URL_EDEFAULT == null ? resourceURL != null : !RESOURCE_URL_EDEFAULT.equals(resourceURL);
}
return super.eIsSet(featureID);
}
@@ -297,11 +317,13 @@ public class ControledResourceImpl extends EObjectImpl implements ControledResou
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public String toString() {
- if (eIsProxy()) return super.toString();
+ if(eIsProxy())
+ return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (resourceURL: ");
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyFactoryImpl.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyFactoryImpl.java
index 55af278a095..b448cfc55f8 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyFactoryImpl.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyFactoryImpl.java
@@ -21,23 +21,25 @@ import org.eclipse.papyrus.controlmode.mm.history.*;
* <!-- begin-user-doc -->
* An implementation of the model <b>Factory</b>.
* <!-- end-user-doc -->
+ *
* @generated
*/
public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
+
/**
* Creates the default factory implementation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public static historyFactory init() {
try {
- historyFactory thehistoryFactory = (historyFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/0.7.0/controlmode");
- if (thehistoryFactory != null) {
+ historyFactory thehistoryFactory = (historyFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/papyrus/0.7.0/controlmode");
+ if(thehistoryFactory != null) {
return thehistoryFactory;
}
- }
- catch (Exception exception) {
+ } catch (Exception exception) {
EcorePlugin.INSTANCE.log(exception);
}
return new historyFactoryImpl();
@@ -47,6 +49,7 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
* Creates an instance of the factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public historyFactoryImpl() {
@@ -56,50 +59,55 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public EObject create(EClass eClass) {
- switch (eClass.getClassifierID()) {
- case historyPackage.CONTROLED_RESOURCE: return createControledResource();
- default:
- throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ switch(eClass.getClassifierID()) {
+ case historyPackage.CONTROLED_RESOURCE:
+ return createControledResource();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public Object createFromString(EDataType eDataType, String initialValue) {
- switch (eDataType.getClassifierID()) {
- case historyPackage.STRING:
- return createStringFromString(eDataType, initialValue);
- default:
- throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ switch(eDataType.getClassifierID()) {
+ case historyPackage.STRING:
+ return createStringFromString(eDataType, initialValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public String convertToString(EDataType eDataType, Object instanceValue) {
- switch (eDataType.getClassifierID()) {
- case historyPackage.STRING:
- return convertStringToString(eDataType, instanceValue);
- default:
- throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
+ switch(eDataType.getClassifierID()) {
+ case historyPackage.STRING:
+ return convertStringToString(eDataType, instanceValue);
+ default:
+ throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public ControledResource createControledResource() {
@@ -110,6 +118,7 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public String createStringFromString(EDataType eDataType, String initialValue) {
@@ -119,6 +128,7 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public String convertStringToString(EDataType eDataType, Object instanceValue) {
@@ -128,6 +138,7 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public historyPackage gethistoryPackage() {
@@ -137,6 +148,7 @@ public class historyFactoryImpl extends EFactoryImpl implements historyFactory {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @deprecated
* @generated
*/
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyPackageImpl.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyPackageImpl.java
index 03da434cd99..56ee2d7666f 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyPackageImpl.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/impl/historyPackageImpl.java
@@ -22,12 +22,15 @@ import org.eclipse.papyrus.controlmode.mm.history.historyPackage;
* <!-- begin-user-doc -->
* An implementation of the model <b>Package</b>.
* <!-- end-user-doc -->
+ *
* @generated
*/
public class historyPackageImpl extends EPackageImpl implements historyPackage {
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
private EClass controledResourceEClass = null;
@@ -35,20 +38,19 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
private EDataType stringEDataType = null;
/**
- * Creates an instance of the model <b>Package</b>, registered with
- * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * Creates an instance of the model <b>Package</b>, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the
+ * package
* package URI value.
- * <p>Note: the correct way to create the package is via the static
- * factory method {@link #init init()}, which also performs
- * initialization of the package, or returns the registered package,
- * if one already exists.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <p>
+ * Note: the correct way to create the package is via the static factory method {@link #init init()}, which also performs initialization of the
+ * package, or returns the registered package, if one already exists. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @see org.eclipse.emf.ecore.EPackage.Registry
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage#eNS_URI
* @see #init()
@@ -61,6 +63,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
private static boolean isInited = false;
@@ -68,17 +71,18 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
*
- * <p>This method is used to initialize {@link historyPackage#eINSTANCE} when that field is accessed.
- * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
+ * <p>
+ * This method is used to initialize {@link historyPackage#eINSTANCE} when that field is accessed. Clients should not invoke it directly. Instead,
+ * they should simply access that field to obtain the package. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
* @see #eNS_URI
* @see #createPackageContents()
* @see #initializePackageContents()
* @generated
*/
public static historyPackage init() {
- if (isInited) return (historyPackage)EPackage.Registry.INSTANCE.getEPackage(historyPackage.eNS_URI);
+ if(isInited)
+ return (historyPackage)EPackage.Registry.INSTANCE.getEPackage(historyPackage.eNS_URI);
// Obtain or create and register package
historyPackageImpl thehistoryPackage = (historyPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof historyPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new historyPackageImpl());
@@ -94,7 +98,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
// Mark meta-data to indicate it can't be changed
thehistoryPackage.freeze();
-
+
// Update the registry and return the package
EPackage.Registry.INSTANCE.put(historyPackage.eNS_URI, thehistoryPackage);
return thehistoryPackage;
@@ -103,6 +107,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EClass getControledResource() {
@@ -112,6 +117,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EReference getControledResource_Children() {
@@ -121,6 +127,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EReference getControledResource_Parent() {
@@ -130,6 +137,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EAttribute getControledResource_ResourceURL() {
@@ -139,6 +147,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public EDataType getString() {
@@ -148,6 +157,7 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public historyFactory gethistoryFactory() {
@@ -157,19 +167,22 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
private boolean isCreated = false;
/**
- * Creates the meta-model objects for the package. This method is
+ * Creates the meta-model objects for the package. This method is
* guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public void createPackageContents() {
- if (isCreated) return;
+ if(isCreated)
+ return;
isCreated = true;
// Create classes and their features
@@ -185,19 +198,22 @@ public class historyPackageImpl extends EPackageImpl implements historyPackage {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
private boolean isInitialized = false;
/**
- * Complete the initialization of the package and its meta-model. This
+ * Complete the initialization of the package and its meta-model. This
* method is guarded to have no affect on any invocation but its first.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public void initializePackageContents() {
- if (isInitialized) return;
+ if(isInitialized)
+ return;
isInitialized = true;
// Initialize package
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historyAdapterFactory.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historyAdapterFactory.java
index ee6cd27baa3..dd0ba5eef1b 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historyAdapterFactory.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historyAdapterFactory.java
@@ -20,14 +20,17 @@ import org.eclipse.papyrus.controlmode.mm.history.*;
* The <b>Adapter Factory</b> for the model.
* It provides an adapter <code>createXXX</code> method for each class of the model.
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage
* @generated
*/
public class historyAdapterFactory extends AdapterFactoryImpl {
+
/**
* The cached model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
protected static historyPackage modelPackage;
@@ -36,10 +39,11 @@ public class historyAdapterFactory extends AdapterFactoryImpl {
* Creates an instance of the adapter factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public historyAdapterFactory() {
- if (modelPackage == null) {
+ if(modelPackage == null) {
modelPackage = historyPackage.eINSTANCE;
}
}
@@ -49,15 +53,16 @@ public class historyAdapterFactory extends AdapterFactoryImpl {
* <!-- begin-user-doc -->
* This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
* <!-- end-user-doc -->
+ *
* @return whether this factory is applicable for the type of the object.
* @generated
*/
@Override
public boolean isFactoryForType(Object object) {
- if (object == modelPackage) {
+ if(object == modelPackage) {
return true;
}
- if (object instanceof EObject) {
+ if(object instanceof EObject) {
return ((EObject)object).eClass().getEPackage() == modelPackage;
}
return false;
@@ -67,25 +72,29 @@ public class historyAdapterFactory extends AdapterFactoryImpl {
* The switch that delegates to the <code>createXXX</code> methods.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
- protected historySwitch<Adapter> modelSwitch =
- new historySwitch<Adapter>() {
- @Override
- public Adapter caseControledResource(ControledResource object) {
- return createControledResourceAdapter();
- }
- @Override
- public Adapter defaultCase(EObject object) {
- return createEObjectAdapter();
- }
- };
+ protected historySwitch<Adapter> modelSwitch = new historySwitch<Adapter>() {
+
+ @Override
+ public Adapter caseControledResource(ControledResource object) {
+ return createControledResourceAdapter();
+ }
+
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
/**
* Creates an adapter for the <code>target</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param target the object to adapt.
+ *
+ * @param target
+ * the object to adapt.
* @return the adapter for the <code>target</code>.
* @generated
*/
@@ -96,11 +105,13 @@ public class historyAdapterFactory extends AdapterFactoryImpl {
/**
- * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource <em>Controled Resource</em>}'.
+ * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.controlmode.mm.history.ControledResource <em>Controled Resource</em>}
+ * '.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
+ *
* @return the new adapter.
* @see org.eclipse.papyrus.controlmode.mm.history.ControledResource
* @generated
@@ -114,6 +125,7 @@ public class historyAdapterFactory extends AdapterFactoryImpl {
* <!-- begin-user-doc -->
* This default implementation returns null.
* <!-- end-user-doc -->
+ *
* @return the new adapter.
* @generated
*/
diff --git a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historySwitch.java b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historySwitch.java
index aa03e9a0c86..74c4bebd344 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historySwitch.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode.history/src/org/eclipse/papyrus/controlmode/mm/history/util/historySwitch.java
@@ -16,21 +16,23 @@ import org.eclipse.papyrus.controlmode.mm.history.*;
/**
* <!-- begin-user-doc -->
* The <b>Switch</b> for the model's inheritance hierarchy.
- * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
- * to invoke the <code>caseXXX</code> method for each class of the model,
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)} to invoke the <code>caseXXX</code> method for each class of the model,
* starting with the actual class of the object
* and proceeding up the inheritance hierarchy
* until a non-null result is returned,
* which is the result of the switch.
* <!-- end-user-doc -->
+ *
* @see org.eclipse.papyrus.controlmode.mm.history.historyPackage
* @generated
*/
public class historySwitch<T> {
+
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
protected static historyPackage modelPackage;
@@ -39,10 +41,11 @@ public class historySwitch<T> {
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public historySwitch() {
- if (modelPackage == null) {
+ if(modelPackage == null) {
modelPackage = historyPackage.eINSTANCE;
}
}
@@ -51,6 +54,7 @@ public class historySwitch<T> {
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
@@ -62,19 +66,16 @@ public class historySwitch<T> {
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
protected T doSwitch(EClass theEClass, EObject theEObject) {
- if (theEClass.eContainer() == modelPackage) {
+ if(theEClass.eContainer() == modelPackage) {
return doSwitch(theEClass.getClassifierID(), theEObject);
- }
- else {
+ } else {
List<EClass> eSuperTypes = theEClass.getESuperTypes();
- return
- eSuperTypes.isEmpty() ?
- defaultCase(theEObject) :
- doSwitch(eSuperTypes.get(0), theEObject);
+ return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch(eSuperTypes.get(0), theEObject);
}
}
@@ -82,18 +83,22 @@ public class historySwitch<T> {
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @return the first non-null result returned by a <code>caseXXX</code> call.
* @generated
*/
protected T doSwitch(int classifierID, EObject theEObject) {
- switch (classifierID) {
- case historyPackage.CONTROLED_RESOURCE: {
- ControledResource controledResource = (ControledResource)theEObject;
- T result = caseControledResource(controledResource);
- if (result == null) result = defaultCase(theEObject);
- return result;
- }
- default: return defaultCase(theEObject);
+ switch(classifierID) {
+ case historyPackage.CONTROLED_RESOURCE:
+ {
+ ControledResource controledResource = (ControledResource)theEObject;
+ T result = caseControledResource(controledResource);
+ if(result == null)
+ result = defaultCase(theEObject);
+ return result;
+ }
+ default:
+ return defaultCase(theEObject);
}
}
@@ -103,7 +108,9 @@ public class historySwitch<T> {
* This implementation returns null;
* returning a non-null result will terminate the switch.
* <!-- end-user-doc -->
- * @param object the target of the switch.
+ *
+ * @param object
+ * the target of the switch.
* @return the result of interpreting the object as an instance of '<em>Controled Resource</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
@@ -118,7 +125,9 @@ public class historySwitch<T> {
* This implementation returns null;
* returning a non-null result will terminate the switch, but this is the last case anyway.
* <!-- end-user-doc -->
- * @param object the target of the switch.
+ *
+ * @param object
+ * the target of the switch.
* @return the result of interpreting the object as an instance of '<em>EObject</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject)
* @generated
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF b/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
index d0c6a20c17a..f8e5d23f25c 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
+++ b/plugins/core/org.eclipse.papyrus.controlmode/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.core,
org.eclipse.papyrus.controlmode.history,
org.eclipse.papyrus.ui.toolbox,
- org.eclipse.papyrus.core.resourceloading
+ org.eclipse.papyrus.core.resourceloading,
+ org.eclipse.papyrus.core.resourceloading.preferences
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.controlmode,
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/CollaborativeActionsFactory.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/CollaborativeActionsFactory.java
index 639a8813c78..98aaf419e0e 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/CollaborativeActionsFactory.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/CollaborativeActionsFactory.java
@@ -97,7 +97,7 @@ public class CollaborativeActionsFactory implements IActionHandlerFactory {
public void fillActionBars(IActionBars actionBars) {
// actionBars.setGlobalActionHandler(actionId, handler);
}
-
+
/**
* {@inheritDoc}
*/
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusControlAction.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusControlAction.java
index 171bf756171..66b70acdc52 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusControlAction.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusControlAction.java
@@ -28,17 +28,27 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.edit.ui.action.ControlAction;
+import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.controlmode.commands.ControlCommand;
import org.eclipse.papyrus.controlmode.commands.IControlCondition;
import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.resource.AbstractBaseModel;
+import org.eclipse.papyrus.resource.IModel;
+import org.eclipse.papyrus.resource.ModelSet;
+import org.eclipse.papyrus.resource.ModelUtils;
+import org.eclipse.papyrus.resource.notation.NotationModel;
+import org.eclipse.papyrus.resource.uml.UmlModel;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -82,7 +92,32 @@ public class PapyrusControlAction extends ControlAction {
// check if action is disabled by an extension
enableControl &= cond.enableControl(eObject);
}
- return enableControl && getEditingDomain().isControllable(eObject) && !AdapterFactoryEditingDomain.isControlled(eObject) && !eObject.eContents().isEmpty();
+ return enableControl && getEditingDomain().isControllable(eObject) && !AdapterFactoryEditingDomain.isControlled(eObject) && getDiagram(eObject);
+ }
+
+ /**
+ * Checks if a specified element gets a diagram
+ *
+ * @param eObject
+ * @return true if a diagram exists
+ */
+ private boolean getDiagram(EObject eObject) {
+ Resource modelResource = eObject.eResource();
+ if(modelResource != null) {
+ // only check for diagrams in the relative notation resource (same name as the opened resource)
+ Resource notationResource = modelResource.getResourceSet().getResource(modelResource.getURI().trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION), true);
+ if(notationResource != null) {
+ for(EObject o : notationResource.getContents()) {
+ if(o instanceof Diagram) {
+ EObject element = ((Diagram)o).getElement();
+ if(element != null && (element.equals(eObject) || EcoreUtil.isAncestor(this.eObject, element))) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
}
/**
@@ -102,8 +137,6 @@ public class PapyrusControlAction extends ControlAction {
result = domain.isControllable(object);
if(result) {
eObject = (EObject)object;
- // active control if selection has children
- result = !eObject.eContents().isEmpty();
} else {
eObject = null;
}
@@ -116,16 +149,30 @@ public class PapyrusControlAction extends ControlAction {
*/
@Override
public void run() {
- Resource controlledModel = getControlledResource();
- if(controlledModel == null) {
- return;
- }
- try {
- ControlCommand transactionalCommand = new ControlCommand(EditorUtils.getTransactionalEditingDomain(), controlledModel, eObject, "Control", null);
- OperationHistoryFactory.getOperationHistory().execute(transactionalCommand, new NullProgressMonitor(), null);
- } catch (ExecutionException e) {
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
- EMFEditUIPlugin.INSTANCE.log(e);
+ // check if object selection is in the current model set. If not, warn the user and disable action
+ ModelSet modelSet = ModelUtils.getModelSet();
+ if(modelSet != null) {
+ IModel umlModel = modelSet.getModel(UmlModel.MODEL_ID);
+ boolean enableControl = false;
+ if(eObject != null && umlModel instanceof AbstractBaseModel) {
+ enableControl = ((AbstractBaseModel)umlModel).getResource().equals(eObject.eResource());
+ }
+ if(!enableControl) {
+ NotificationBuilder.createAsyncPopup("You must perform control action from the resource:\n" + eObject.eResource().getURI().trimFileExtension().toString() + " for this element").setType(Type.INFO).run();
+ return;
+ }
+
+ Resource controlledModel = getControlledResource();
+ if(controlledModel == null) {
+ return;
+ }
+ try {
+ ControlCommand transactionalCommand = new ControlCommand(EditorUtils.getTransactionalEditingDomain(), controlledModel, eObject, "Control", null);
+ OperationHistoryFactory.getOperationHistory().execute(transactionalCommand, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
+ EMFEditUIPlugin.INSTANCE.log(e);
+ }
}
}
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
index b44d9ba4c6d..81d9b944239 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
@@ -18,6 +18,7 @@ import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
@@ -26,6 +27,12 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.controlmode.commands.UncontrolCommand;
import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.resource.AbstractBaseModel;
+import org.eclipse.papyrus.resource.IModel;
+import org.eclipse.papyrus.resource.ModelUtils;
+import org.eclipse.papyrus.resource.uml.UmlModel;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
import org.eclipse.ui.PlatformUI;
/**
@@ -95,6 +102,18 @@ public class PapyrusUncontrolAction extends CommandActionHandler {
*/
@Override
public void run() {
+ // check if the uncontrol is made from the parent resource. If not, warn the user and disable action
+ IModel umlModel = ModelUtils.getModelSet().getModel(UmlModel.MODEL_ID);
+ Resource parentOfControlledResource = getParentOfControlledResource(eObject);
+ boolean enableAction = false;
+ if(eObject != null && umlModel instanceof AbstractBaseModel) {
+ enableAction = ((AbstractBaseModel)umlModel).getResource().equals(parentOfControlledResource);
+ }
+ if(!enableAction) {
+ NotificationBuilder.createAsyncPopup("You must perform uncontrol action from the resource:\n" + parentOfControlledResource.getURI().trimFileExtension().toString() + " for this element").setType(Type.INFO).run();
+ return;
+ }
+
try {
UncontrolCommand transactionalCommand = new UncontrolCommand(EditorUtils.getTransactionalEditingDomain(), eObject, "Uncontrol", null);
OperationHistoryFactory.getOperationHistory().execute(transactionalCommand, new NullProgressMonitor(), null);
@@ -103,4 +122,23 @@ public class PapyrusUncontrolAction extends CommandActionHandler {
EMFEditUIPlugin.INSTANCE.log(e);
}
}
+
+ /**
+ * Returns the first parent resource of the controlled resource in which the eObject is.
+ *
+ * @param eObject
+ * the specified eObject
+ * @return null otherwise
+ */
+ private Resource getParentOfControlledResource(EObject eObject) {
+ Resource currentResource = eObject.eResource();
+ if(eObject.eContainer() != null) {
+ if(!currentResource.equals(eObject.eContainer().eResource())) {
+ return eObject.eContainer().eResource();
+ } else {
+ getParentOfControlledResource(eObject.eContainer());
+ }
+ }
+ return null;
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
index 8df84238fa0..02029ac40da 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
@@ -13,7 +13,6 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.commands;
-import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -38,6 +37,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -45,7 +45,6 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContext;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.papyrus.controlmode.commands.IControlCommand.STATE_CONTROL;
import org.eclipse.papyrus.controlmode.history.HistoryModel;
import org.eclipse.papyrus.controlmode.history.utils.HistoryUtils;
@@ -54,7 +53,6 @@ import org.eclipse.papyrus.controlmode.mm.history.historyFactory;
import org.eclipse.papyrus.controlmode.mm.history.historyPackage;
import org.eclipse.papyrus.core.modelsetquery.ModelSetQuery;
import org.eclipse.papyrus.core.utils.EditorUtils;
-import org.eclipse.papyrus.resource.ModelIdentifiers;
import org.eclipse.papyrus.resource.ModelSet;
import org.eclipse.papyrus.resource.notation.NotationModel;
import org.eclipse.papyrus.resource.notation.NotationUtils;
@@ -65,7 +63,11 @@ import org.eclipse.papyrus.sashwindows.di.PageRef;
import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.sashwindows.di.exception.SashEditorException;
import org.eclipse.papyrus.sashwindows.di.util.DiUtils;
+import org.eclipse.papyrus.ui.toolbox.notification.NotificationRunnable;
+import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.IContext;
import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -148,7 +150,7 @@ public class ControlCommand extends AbstractTransactionalCommand {
final URI newDiURI = URI.createURI(controlledModel.getURI().trimFileExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION).toString());
this.controlledDI = getResource(newDiURI);
- final List<Diagram> diagrams = NotationUtils.getDiagrams(NotationUtils.getNotationModel(diResourceSet).getResource(), eObject);
+ final List<Diagram> diagrams = getDiagrams(eObject);
// compound command that executes whole control action
CompoundCommand compoundCommand = new CompoundCommand();
@@ -162,13 +164,12 @@ public class ControlCommand extends AbstractTransactionalCommand {
return Status.CANCEL_STATUS;
}
- // Ensure that all proxies are resolved so that references into the controlled object will
- // be saved to reference the new resource
+ // Ensure that all proxies are resolved so that references into the controlled object will be saved to reference the new resource
EcoreUtil.resolveAll(getEditingDomain().getResourceSet());
if(compoundCommand.canExecute()) {
compoundCommand.execute();
- saveResources();
+ notifySave();
return Status.OK_STATUS;
} else {
NotificationBuilder.createErrorPopup("Unable to execute control command").setTitle("Unable to control").run();
@@ -177,6 +178,38 @@ public class ControlCommand extends AbstractTransactionalCommand {
}
/**
+ * Search for diagrams in corresponding notation resource of the eObject model resource
+ *
+ * @param eObject
+ * @return
+ */
+ private List<Diagram> getDiagrams(EObject eObject) {
+ List<Diagram> diagrams = new LinkedList<Diagram>();
+ // search for diagrams only in the notation resource corresponding to the model resource where eObject is.
+ // Some "sub diagrams" in the model can be in controlled resource, we must not move them.
+ Resource resource = eObject.eResource();
+ Resource notationResource = diResourceSet.getResource(resource.getURI().trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION), false);
+ diagrams.addAll(NotationUtils.getDiagrams(notationResource, eObject));
+ return diagrams;
+ }
+
+ // /**
+ // * Search for diagrams in all the resources
+ // *
+ // * @param eObject
+ // * @return
+ // */
+ // private List<Diagram> getDiagrams(EObject eObject) {
+ // List<Diagram> diagrams = new LinkedList<Diagram>();
+ // for(Resource r : diResourceSet.getResources()) {
+ // if(NotationModel.NOTATION_FILE_EXTENSION.equals(r.getURI().fileExtension())) {
+ // diagrams.addAll(NotationUtils.getDiagrams(r, eObject));
+ // }
+ // }
+ // return diagrams;
+ // }
+
+ /**
* Control the model resource
*
* @param compoundCommand
@@ -189,20 +222,97 @@ public class ControlCommand extends AbstractTransactionalCommand {
compoundCommand.append(new AddCommand(getEditingDomain(), controlledModel.getContents(), eObject));
// update history
- HistoryModel historyModel = getHistoryModel();
- assignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, historyModel, eObject.eResource().getURI().toString(), controlledModel.getURI().toString());
+ assignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, getHistoryResource(eObject), eObject.eResource().getURI().toString(), controlledModel.getURI().toString());
// POST control operation
control(getEditingDomain(), eObject, UmlUtils.getUmlModel(diResourceSet).getResource(), controlledModel, compoundCommand, STATE_CONTROL.POST_MODEL);
}
- protected HistoryModel getHistoryModel() {
- HistoryModel historyModel = HistoryUtils.getHistoryModel(diResourceSet);
- if(historyModel == null) {
- diResourceSet.createsModels(new ModelIdentifiers(HistoryModel.MODEL_ID));
- historyModel = HistoryUtils.getHistoryModel(diResourceSet);
+ /**
+ * Control the notation resource
+ *
+ * @param compoundCommand
+ * @param diagrams
+ * list
+ */
+ private void controlNotation(CompoundCommand compoundCommand, List<Diagram> diagrams) {
+ // PRE control operation
+ for(Diagram diag : diagrams) {
+ control(getEditingDomain(), diag, getNotationResourceForCurrent(eObject), controlledNotation, compoundCommand, STATE_CONTROL.PRE_NOTATION);
+ }
+ if(!diagrams.isEmpty()) {
+ // Control the Notation model
+ compoundCommand.append(new AddCommand(getEditingDomain(), controlledNotation.getContents(), diagrams));
+ }
+
+ // update history
+ Set<Resource> resources = new HashSet<Resource>(diagrams.size());
+ for(Diagram d : diagrams) {
+ resources.add(d.eResource());
+ }
+ for(Resource r : resources) {
+ assignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, getHistoryResource(eObject), r.getURI().toString(), controlledNotation.getURI().toString());
+ }
+
+ // POST control operation
+ for(Diagram diag : diagrams) {
+ control(getEditingDomain(), diag, getNotationResourceForCurrent(eObject), controlledNotation, compoundCommand, STATE_CONTROL.POST_NOTATION);
}
- return historyModel;
+ }
+
+ /**
+ * Control the di resource
+ *
+ * @param compoundCommand
+ * @param diagrams
+ * @throws SashEditorException
+ */
+ private void controlDi(CompoundCommand compoundCommand, final List<Diagram> diagrams) throws SashEditorException {
+ // Create a new SashWindowManager
+ SashWindowsMngr windowsMngr = DiUtils.createDefaultSashWindowsMngr();
+ Resource diResource = SashModelUtils.getSashModel(diResourceSet).getResource();
+ // add pages to the page list
+ for(Diagram diagram : diagrams) {
+ PageRef pageRef = DiUtils.getPageRef(diResource, diagram);
+ if(pageRef != null) {
+ windowsMngr.getPageList().addPage(pageRef.getPageIdentifier());
+ DiUtils.addPageToTabFolder(windowsMngr, pageRef);
+ }
+ }
+
+ // PRE control operation
+ control(getEditingDomain(), eObject, diResource, controlledDI, compoundCommand, STATE_CONTROL.PRE_DI);
+
+ // Control the DI model
+ compoundCommand.append(new AddCommand(getEditingDomain(), controlledDI.getContents(), windowsMngr, 0));
+
+ // POST control operation
+ control(getEditingDomain(), eObject, diResource, controlledDI, compoundCommand, STATE_CONTROL.POST_DI);
+ }
+
+ /**
+ * Display asynchronous popup to inform user about the control action
+ */
+ protected void notifySave() {
+ new NotificationBuilder().setMessage("Your element has been controlled.\nYou need to save your model to see modifications in your workspace.\nDo you want to save ?").addAction(new NotificationRunnable() {
+
+ public void run(IContext context) {
+ try {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getLabel() {
+ return "Save";
+ }
+ }).setTemporary(true).setAsynchronous(true).setType(Type.INFO).setDelay(2000).run();
}
/**
@@ -214,7 +324,7 @@ public class ControlCommand extends AbstractTransactionalCommand {
* @param currentURL
* @param newURL
*/
- private void assignControlledResourceOfCurrentElement(EditingDomain domain, CompoundCommand compoundCommand, HistoryModel model, String currentURL, String newURL) {
+ private void assignControlledResourceOfCurrentElement(EditingDomain domain, CompoundCommand compoundCommand, Resource model, String currentURL, String newURL) {
if(model == null) {
return;
}
@@ -226,7 +336,7 @@ public class ControlCommand extends AbstractTransactionalCommand {
ControledResource child = historyFactory.eINSTANCE.createControledResource();
child.setResourceURL(newURLResolved);
- ControledResource resource = model.getModelRoot();
+ ControledResource resource = getControledResource(model);
Resource parentResource = null;
// create the controlled resource according to the control action
@@ -235,14 +345,15 @@ public class ControlCommand extends AbstractTransactionalCommand {
parent = historyFactory.eINSTANCE.createControledResource();
parent.setResourceURL(currentURLResolved);
parent.getChildren().add(child);
- parentResource = model.getResource();
+ parentResource = model;
compoundCommand.append(new AddCommand(domain, parentResource.getContents(), Collections.singleton(parent)));
} else {
if(isCurrentURL(currentURLResolved, resource)) {
parent = resource;
}
if(parent == null) {
- Collection<EObject> controled = ModelSetQuery.getObjectsOfType(model.getModelRoot(), historyPackage.Literals.CONTROLED_RESOURCE);
+ EObject modelRoot = getControledResource(model);
+ Collection<EObject> controled = ModelSetQuery.getObjectsOfType(modelRoot, historyPackage.Literals.CONTROLED_RESOURCE);
for(EObject next : controled) {
if(next instanceof ControledResource) {
ControledResource tmp = (ControledResource)next;
@@ -257,7 +368,10 @@ public class ControlCommand extends AbstractTransactionalCommand {
parent = historyFactory.eINSTANCE.createControledResource();
parent.setResourceURL(currentURLResolved);
parentResource = resource.eResource();
- compoundCommand.append(new AddCommand(domain, parentResource.getContents(), Collections.singleton(parent)));
+ // add controlled resource command for notation is done in assignToChildExistingControledResources
+ if(!currentURLResolved.endsWith(NotationModel.NOTATION_FILE_EXTENSION)) {
+ compoundCommand.append(new AddCommand(domain, parentResource.getContents(), Collections.singleton(parent)));
+ }
}
if(parent != null) {
compoundCommand.append(AddCommand.create(domain, parent, historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, Collections.singleton(child)));
@@ -265,7 +379,7 @@ public class ControlCommand extends AbstractTransactionalCommand {
}
List<ControledResource> controledFromParent = new LinkedList<ControledResource>();
if(parentResource == null) {
- parentResource = model.getResource();
+ parentResource = model;
}
if(parentResource != null) {
for(EObject e : parentResource.getContents()) {
@@ -281,12 +395,24 @@ public class ControlCommand extends AbstractTransactionalCommand {
}
}
}
- // manage move of existing controlled resource
+ // manage move of existing controlled resources
if(!newURL.endsWith(NotationModel.NOTATION_FILE_EXTENSION)) {
assignToChildExistingControledResources(domain, compoundCommand, child, newURL, controledFromParent, currentURL, URI.createURI(newURL), uriPath);
}
}
+ /**
+ * Manage move of existing controlled resources
+ *
+ * @param domain
+ * @param compoundCommand
+ * @param child
+ * @param controledResourceURL
+ * @param controledFromParent
+ * @param parentURL
+ * @param controledURIFullPath
+ * @param parentURIFullPath
+ */
private void assignToChildExistingControledResources(EditingDomain domain, CompoundCommand compoundCommand, ControledResource child, String controledResourceURL, List<ControledResource> controledFromParent, String parentURL, URI controledURIFullPath, URI parentURIFullPath) {
for(ControledResource r : controledFromParent) {
if(r.getResourceURL() != null) {
@@ -296,25 +422,61 @@ public class ControlCommand extends AbstractTransactionalCommand {
EObject top = resourceLoaded.getContents().get(0);
if(isInRootHierarchy(top, eObject)) {
// manage model
- URI newResolvedURIFromChild = fullPathParent.deresolve(controledURIFullPath);
+ URI newResolvedURIFromChild = fullPathParent.deresolve(controledURIFullPath, false, true, true);
ControledResource aNewOne = historyFactory.eINSTANCE.createControledResource();
aNewOne.setResourceURL(newResolvedURIFromChild.toString());
+ // add new control resource to the new history
compoundCommand.append(new AddCommand(domain, getControledResource(controlledDI, URI.createURI(controledResourceURL).lastSegment(), compoundCommand, getEditingDomain()), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, aNewOne));
+ // remove old controlled resource from the parent resource
+ compoundCommand.append(RemoveCommand.create(domain, r.eContainer(), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, r));
+
// manage notation
URI newNotation = newResolvedURIFromChild.trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION);
ControledResource aNewOneNotation = historyFactory.eINSTANCE.createControledResource();
aNewOneNotation.setResourceURL(newNotation.toString());
+ // add new control resource to the new history
compoundCommand.append(new AddCommand(domain, getControledResource(controlledDI, URI.createURI(URI.createURI(controledResourceURL).trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION).toString()).lastSegment(), compoundCommand, getEditingDomain()), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, aNewOneNotation));
-
+ // remove old controlled resource from the parent resource
+ URI notationParentURL = URI.createURI(r.getParent().getResourceURL()).trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION);
+ ControledResource notationParent = getControledResource(r.eResource(), notationParentURL.toString(), compoundCommand, domain);
+ for(ControledResource notationChild : notationParent.getChildren()) {
+ //URI notationURI = newResolvedURIFromChild.trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION);
+ URI notationURI = URI.createURI(r.getResourceURL()).trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION);
+ if(notationChild.getResourceURL().equals(notationURI.toString())) {
+ compoundCommand.append(RemoveCommand.create(domain, notationParent, historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, notationChild));
+ }
+ }
}
}
}
}
}
- private ControledResource getControledResource(Resource eResource, String controledResourceURL, CompoundCommand command, EditingDomain domain) {
+ /**
+ * Get the controlled resource in a specified resource
+ */
+ private ControledResource getControledResource(Resource resource) {
+ for(EObject e : resource.getContents()) {
+ if(e instanceof ControledResource) {
+ return (ControledResource)e;
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the controlled resource for the specified URL, create it if it doesn't exist
+ *
+ * @param resource
+ * @param controledResourceURL
+ * @param command
+ * @param domain
+ * @return
+ */
+ private ControledResource getControledResource(Resource resource, String controledResourceURL, CompoundCommand command, EditingDomain domain) {
ControledResource result = null;
- for(EObject e : eResource.getContents()) {
+ for(EObject e : resource.getContents()) {
if(e instanceof ControledResource) {
ControledResource controled = (ControledResource)e;
if(controledResourceURL != null && controledResourceURL.equals(controled.getResourceURL())) {
@@ -325,11 +487,18 @@ public class ControlCommand extends AbstractTransactionalCommand {
if(result == null) {
result = historyFactory.eINSTANCE.createControledResource();
result.setResourceURL(controledResourceURL);
- command.append(new AddCommand(domain, eResource.getContents(), result, 0));
+ command.append(new AddCommand(domain, resource.getContents(), result, 0));
}
return result;
}
+ /**
+ * Check if an EObject start is in root hierarchy of another eObject search
+ *
+ * @param start
+ * @param search
+ * @return
+ */
protected boolean isInRootHierarchy(EObject start, EObject search) {
while(start != null && start != search) {
start = start.eContainer();
@@ -337,68 +506,38 @@ public class ControlCommand extends AbstractTransactionalCommand {
return start != null;
}
+ /**
+ * Check if an URL is the current one of the specified resource
+ *
+ * @param currentURL
+ * @param resource
+ * @return
+ */
protected boolean isCurrentURL(String currentURL, ControledResource resource) {
return resource.getResourceURL() != null && resource.getResourceURL().equals(currentURL);
}
/**
- * Control the notation resource
+ * Get the notation resource for the specified eObject
*
- * @param compoundCommand
- * @param diagrams
- * list
+ * @param eObject
+ * @return
*/
- private void controlNotation(CompoundCommand compoundCommand, List<Diagram> diagrams) {
- // PRE control operation
- for(Diagram diag : diagrams) {
- control(getEditingDomain(), diag, NotationUtils.getNotationModel(diResourceSet).getResource(), controlledNotation, compoundCommand, STATE_CONTROL.PRE_NOTATION);
- }
-
- // Control the Notation model
- compoundCommand.append(new AddCommand(getEditingDomain(), controlledNotation.getContents(), diagrams));
-
- // update history
- HistoryModel historyModel = getHistoryModel();
- Set<Resource> resources = new HashSet<Resource>(diagrams.size());
- for(Diagram d : diagrams) {
- resources.add(d.eResource());
- }
- for(Resource r : resources) {
- assignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, historyModel, r.getURI().toString(), controlledNotation.getURI().toString());
- }
-
- // POST control operation
- for(Diagram diag : diagrams) {
- control(getEditingDomain(), diag, NotationUtils.getNotationModel(diResourceSet).getResource(), controlledNotation, compoundCommand, STATE_CONTROL.POST_NOTATION);
- }
+ private Resource getNotationResourceForCurrent(EObject eObject) {
+ return diResourceSet.getResource(eObject.eResource().getURI().trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION), true);
}
/**
- * Control the di resource
+ * Get the history resource of the specified eObject
*
- * @param compoundCommand
- * @param diagrams
- * @throws SashEditorException
+ * @param eObject
+ * @return
*/
- private void controlDi(CompoundCommand compoundCommand, final List<Diagram> diagrams) throws SashEditorException {
- // Create a new SashWindowManager
- SashWindowsMngr windowsMngr = DiUtils.createDefaultSashWindowsMngr();
- Resource diResource = SashModelUtils.getSashModel(diResourceSet).getResource();
- // add pages to the page list
- for(Diagram diagram : diagrams) {
- PageRef pageRef = DiUtils.getPageRef(diResource, diagram);
- windowsMngr.getPageList().addPage(pageRef.getPageIdentifier());
- DiUtils.addPageToTabFolder(windowsMngr, pageRef);
+ private Resource getHistoryResource(EObject eObject) {
+ if(eObject.eResource() != null) {
+ return diResourceSet.getResource(eObject.eResource().getURI().trimFileExtension().appendFileExtension(HistoryModel.MODEL_FILE_EXTENSION), true);
}
-
- // PRE control operation
- control(getEditingDomain(), eObject, diResource, controlledDI, compoundCommand, STATE_CONTROL.PRE_DI);
-
- // Control the DI model
- compoundCommand.append(new AddCommand(getEditingDomain(), controlledDI.getContents(), windowsMngr, 0));
-
- // POST control operation
- control(getEditingDomain(), eObject, diResource, controlledDI, compoundCommand, STATE_CONTROL.POST_DI);
+ return null;
}
/**
@@ -420,7 +559,8 @@ public class ControlCommand extends AbstractTransactionalCommand {
}
/**
- * Gets the custom command extensions that will be executed with the default control action.
+ * Gets the custom command extensions that will be executed with the default
+ * control action.
*
* @return the command extensions
*/
@@ -455,24 +595,4 @@ public class ControlCommand extends AbstractTransactionalCommand {
return res;
}
- /**
- * Save resources.
- */
- private void saveResources() {
- try {
- controlledModel.save(null);
- controlledNotation.save(null);
- controlledDI.save(null);
-
- // TODO save parent resources, check if it is useful
- // diResourceSet.save(new NullProgressMonitor());
- } catch (IOException exception) {
- if(getEditingDomain().getCommandStack().canUndo()) {
- getEditingDomain().getCommandStack().undo();
- }
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
- EMFEditUIPlugin.INSTANCE.log(exception);
- }
- }
-
}
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IControlCondition.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IControlCondition.java
index 4459f6268da..b84a5a6e114 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IControlCondition.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IControlCondition.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.controlmode.commands;
import org.eclipse.emf.ecore.EObject;
@@ -19,11 +19,12 @@ import org.eclipse.emf.ecore.EObject;
* The Interface IControlCondition to enable/disable contol action if needed
*/
public interface IControlCondition {
-
+
/**
* This method returns true if the control action is allowed
*
- * @param selection the element where the control action is performed
+ * @param selection
+ * the element where the control action is performed
* @return true to enable the control action, false otherwise
*/
boolean enableControl(EObject selection);
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IUncontrolCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IUncontrolCommand.java
index 8298b32ec7b..c3eb54aa7a9 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IUncontrolCommand.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/IUncontrolCommand.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.controlmode.commands;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -63,4 +63,3 @@ public interface IUncontrolCommand {
}
}
-
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/UncontrolCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/UncontrolCommand.java
index 499a109f870..40e0a2353a7 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/UncontrolCommand.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/UncontrolCommand.java
@@ -43,6 +43,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -52,7 +53,6 @@ import org.eclipse.gmf.runtime.emf.commands.core.command.EditingDomainUndoContex
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.papyrus.controlmode.commands.IUncontrolCommand.STATE_CONTROL;
-import org.eclipse.papyrus.controlmode.history.HistoryModel;
import org.eclipse.papyrus.controlmode.history.utils.HistoryUtils;
import org.eclipse.papyrus.controlmode.mm.history.ControledResource;
import org.eclipse.papyrus.controlmode.mm.history.historyPackage;
@@ -61,6 +61,7 @@ import org.eclipse.papyrus.resource.ModelSet;
import org.eclipse.papyrus.resource.notation.NotationModel;
import org.eclipse.papyrus.resource.notation.NotationUtils;
import org.eclipse.papyrus.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.resource.sasheditor.SashModelUtils;
import org.eclipse.papyrus.resource.uml.UmlUtils;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -92,6 +93,10 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
private List<IUncontrolCommand> commands;
+ private List<ControledResource> controlledResourceToRemove;
+
+ private List<ControledResource> addedControlledResource;
+
/**
* Instantiates a new uncontrol command.
*
@@ -105,6 +110,8 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
this.eObject = selectedObject;
// Add an undo context to allow the editor to react to that change
addContext(new EditingDomainUndoContext(domain));
+ controlledResourceToRemove = new LinkedList<ControledResource>();
+ addedControlledResource = new LinkedList<ControledResource>();
}
/**
@@ -141,7 +148,7 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
if(eObject != null) {
controlledModel = eObject.eResource();
final URI newNotationURI = URI.createURI(controlledModel.getURI().trimFileExtension().appendFileExtension(NotationModel.NOTATION_FILE_EXTENSION).toString());
- this.controlledNotation = getEditingDomain().getResourceSet().getResource(newNotationURI, false);
+ this.controlledNotation = getEditingDomain().getResourceSet().getResource(newNotationURI, true);
final URI newDiURI = URI.createURI(controlledModel.getURI().trimFileExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION).toString());
this.controlledDI = getEditingDomain().getResourceSet().getResource(newDiURI, true);
@@ -186,7 +193,7 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
// Create the Command to Uncontrol the model object
compoundCommand.append(new RemoveCommand(getEditingDomain(), eObject.eResource().getContents(), eObject));
- unassignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, HistoryUtils.getHistoryModel(diResourceSet), eObject.eResource().getURI().toString(), resource.getURI().toString());
+ unassignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, getDIResource(eObject), eObject.eResource().getURI().toString(), resource.getURI().toString());
// POST uncontrol operation
uncontrol(getEditingDomain(), eObject, controlledModel, resource, compoundCommand, STATE_CONTROL.POST_MODEL);
@@ -204,6 +211,7 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
if(!controlledDiagrams.isEmpty()) {
// PRE uncontrol operation
Resource notationResource = NotationUtils.getNotationModel(diResourceSet).getResource();
+
for(Diagram diag : controlledDiagrams) {
uncontrol(getEditingDomain(), diag, controlledNotation, notationResource, compoundCommand, STATE_CONTROL.PRE_NOTATION);
}
@@ -215,7 +223,7 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
resources.add(d.eResource());
}
for(Resource r : resources) {
- unassignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, HistoryUtils.getHistoryModel(diResourceSet), r.getURI().toString(), notationResource.getURI().toString());
+ unassignControlledResourceOfCurrentElement(getEditingDomain(), compoundCommand, getDIResource(eObject), r.getURI().toString(), notationResource.getURI().toString());
}
// POST uncontrol operation
@@ -234,29 +242,66 @@ public class UncontrolCommand extends AbstractTransactionalCommand {
* @param currentURL
* @param newURL
*/
- private void unassignControlledResourceOfCurrentElement(EditingDomain domain, CompoundCommand compoundCommand, HistoryModel model, String oldURL, String newURL) {
- if(model == null) {
- return;
- }
- // TODO move the history model from the controlled resource to the parent DI resource
- URI uriPath = HistoryUtils.getURIFullPath(newURL);
- newURL = HistoryUtils.resolve(uriPath, newURL);
- oldURL = HistoryUtils.resolve(uriPath, oldURL);
- List<ControledResource> controled = HistoryUtils.getControledResourcesForURL(diResourceSet, oldURL);
- for(ControledResource resource : controled) {
- if(resource.getChildren().isEmpty()) {
- compoundCommand.append(RemoveCommand.create(domain, resource.eContainer(), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, resource));
- } else {
- if(resource.eContainer() instanceof ControledResource) {
- compoundCommand.append(AddCommand.create(domain, resource.eContainer(), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, Collections.singleton(resource)));
+ private void unassignControlledResourceOfCurrentElement(EditingDomain domain, CompoundCommand compoundCommand, Resource model, String oldURL, String newURL) {
+ controlledResourceToRemove.clear();
+ addedControlledResource.clear();
+ if(model != null) {
+ URI uriPath = HistoryUtils.getURIFullPath(newURL);
+ newURL = HistoryUtils.resolve(uriPath, newURL);
+ oldURL = HistoryUtils.resolve(uriPath, oldURL);
+ Set<ControledResource> controledOldURL = new HashSet<ControledResource>(HistoryUtils.getControledResourcesForURL(diResourceSet, oldURL));
+ controledOldURL.addAll(HistoryUtils.getControledResourcesForURL(diResourceSet, oldURL.substring(oldURL.lastIndexOf("/") + 1, oldURL.length())));
+ List<ControledResource> controledNewURL = HistoryUtils.getControledResourcesForURL(diResourceSet, newURL);
+ for(ControledResource resourceOldURL : controledOldURL) {
+ if(resourceOldURL.getChildren().isEmpty()) {
+ // store the controlled resource to remove
+ controlledResourceToRemove.add(resourceOldURL);
+ } else {
+ if(resourceOldURL.eContainer() instanceof ControledResource) {
+ compoundCommand.append(AddCommand.create(domain, resourceOldURL.eContainer(), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, Collections.singleton(resourceOldURL)));
+ } else {
+ for(ControledResource resourceNewURL : controledNewURL) {
+ // add children of the old controlled resource to the controlled resource with the new URL
+ compoundCommand.append(AddCommand.create(domain, resourceNewURL, historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, resourceOldURL.getChildren()));
+ addedControlledResource.addAll(resourceOldURL.getChildren());
+
+ // resolve url to be relative to the new resource
+ for(ControledResource c : resourceOldURL.getChildren()) {
+ String childRelativeUrl = c.getResourceURL();
+ URI absoluteChildPath = URI.createURI(c.eResource().getURI().trimSegments(1).toString() + "/");
+ URI absoluteChildURI = URI.createURI(childRelativeUrl).resolve(absoluteChildPath);
+ String urlResolved = absoluteChildURI.deresolve(uriPath).toString();
+ compoundCommand.append(SetCommand.create(domain, c, historyPackage.Literals.CONTROLED_RESOURCE__RESOURCE_URL, urlResolved));
+ }
+ }
+ }
+ }
+ }
+ // remove children and parent if needed
+ for(ControledResource parent : controledNewURL) {
+ if(controlledResourceToRemove.containsAll(parent.getChildren()) && addedControlledResource.isEmpty()) {
+ compoundCommand.append(new RemoveCommand(domain, parent.eResource().getContents(), parent));
} else {
- compoundCommand.append(new AddCommand(getEditingDomain(), resource.eResource().getContents(), resource));
+ for(ControledResource r : controlledResourceToRemove) {
+ compoundCommand.append(RemoveCommand.create(domain, r.eContainer(), historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, r));
+ }
}
}
}
}
/**
+ * Get the history resource of the specified eObject
+ *
+ * @param eObject
+ * @return
+ */
+ private Resource getDIResource(EObject eObject) {
+ // uncontrol command is only available from its parent. With this condition, the current sashModel is the parent
+ return SashModelUtils.getSashModel(diResourceSet).getResource();
+ }
+
+ /**
* Control action applied on the specified selection
*
* @param domain
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/ui/ControlResourceDialog.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/ui/ControlResourceDialog.java
index 87323c4b512..a596e3155a5 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/ui/ControlResourceDialog.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/ui/ControlResourceDialog.java
@@ -83,13 +83,11 @@ public class ControlResourceDialog extends ResourceDialog {
boolean resourceInSet = resource != null;
if(resource == currentResource) {
- MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"),
- EMFEditUIPlugin.INSTANCE.getString("_WARN_AlreadyInResource"));
+ MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AlreadyInResource"));
return false;
}
if(domain.isReadOnly(resource)) {
- MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"),
- EMFEditUIPlugin.INSTANCE.getString("_WARN_ReadOnlyResource"));
+ MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReadOnlyResource"));
return false;
}
@@ -108,8 +106,7 @@ public class ControlResourceDialog extends ResourceDialog {
if(!resourceInSet) {
resource = resourceSet.createResource(uri);
if(resource == null) {
- MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"),
- EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
+ MessageDialog.openError(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
return false;
}
@@ -125,13 +122,9 @@ public class ControlResourceDialog extends ResourceDialog {
boolean result = true;
if(resourceBad) {
- result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE
- .getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE
- .getString("_WARN_ReplaceResource"));
+ result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_ReplaceResource"));
} else if(resourceExists) {
- result = MessageDialog
- .openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"),
- EMFEditUIPlugin.INSTANCE.getString("_WARN_AddToResource"));
+ result = MessageDialog.openQuestion(getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_ExistingResource_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_AddToResource"));
}
if(!result && !resourceInSet) {
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/CorePlugin.java b/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/CorePlugin.java
index 741e08a8401..a8211b449fa 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/CorePlugin.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/CorePlugin.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.core.resourceloading.preferences;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -26,7 +26,7 @@ public class CorePlugin extends AbstractUIPlugin {
// The shared instance
private static CorePlugin plugin;
-
+
/**
* The constructor
*/
@@ -35,6 +35,7 @@ public class CorePlugin extends AbstractUIPlugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@@ -44,6 +45,7 @@ public class CorePlugin extends AbstractUIPlugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -53,7 +55,7 @@ public class CorePlugin extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static CorePlugin getDefault() {
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/StrategyChooser.java b/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/StrategyChooser.java
index 6cabd5f959d..80cd57e1b06 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/StrategyChooser.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading.preferences/src/org/eclipse/papyrus/core/resourceloading/preferences/StrategyChooser.java
@@ -50,6 +50,9 @@ public class StrategyChooser implements IStrategyChooser {
*/
public static void setCurrentStrategy(int strategy) {
currentStrategy = strategy;
+ if(Activator.getDefault().getPreferenceStore().getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY) != strategy) {
+ Activator.getDefault().getPreferenceStore().setValue(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY, String.valueOf(strategy));
+ }
}
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/Activator.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/Activator.java
index 98a6e3e8160..b3a156188f6 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/Activator.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/Activator.java
@@ -13,7 +13,7 @@ public class Activator extends Plugin {
// The shared instance
private static Activator plugin;
-
+
/**
* The constructor
*/
@@ -22,6 +22,7 @@ public class Activator extends Plugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@@ -31,6 +32,7 @@ public class Activator extends Plugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -40,7 +42,7 @@ public class Activator extends Plugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ControledResourceAdapter.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ControledResourceAdapter.java
index 5e7df2606a7..b0071e2c06f 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ControledResourceAdapter.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ControledResourceAdapter.java
@@ -153,9 +153,11 @@ public class ControledResourceAdapter implements Adapter.Internal {
if(o instanceof ControledResource) {
ControledResource res = (ControledResource)o;
List<ControledResource> list = resources.get(res.getResourceURL());
- list.remove(res);
- if(list.isEmpty()) {
- resources.remove(res.getResourceURL());
+ if(list != null) {
+ list.remove(res);
+ if(list.isEmpty()) {
+ resources.remove(res.getResourceURL());
+ }
}
}
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategy.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategy.java
index ced827f0405..9ca66491fd7 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategy.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategy.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.core.resourceloading;
import org.eclipse.emf.common.util.URI;
@@ -23,18 +23,18 @@ public interface ILoadingStrategy {
/**
* Check if the resource from the uri need to be loaded according to the strategy.
- *
+ *
* @param modelSet
* @param uri
* @return true if resource must be loaded, return false otherwise
*/
boolean loadResource(ModelSet modelSet, URI uri);
-
+
// AR : additional resources (types, profiles ...)
// parents : set of elements containing the current selection
// currents : the resource opened
// children : the resources bellow the current selection
-
+
// strategy 1: all : AR U parents U currents U children -> done
// strategy 2: only one : AR U currents -> done
// strategy 3: bellow : AR U children U currents
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategyExtension.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategyExtension.java
index dc954632555..234d048e09c 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategyExtension.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/ILoadingStrategyExtension.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.core.resourceloading;
import org.eclipse.emf.common.util.URI;
@@ -23,9 +23,11 @@ public interface ILoadingStrategyExtension {
/**
* Check if the resource from the uri need to be loaded, no matter which strategy is set.
- *
- * @param modelSet the model set
- * @param uri the uri of the eObject
+ *
+ * @param modelSet
+ * the model set
+ * @param uri
+ * the uri of the eObject
* @return true if resource must be loaded irrespective of strategy, return false otherwise
*/
boolean loadResource(ModelSet modelSet, URI uri);
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSet.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSet.java
index e4aebfb3765..f4a5c1a8782 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSet.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSet.java
@@ -21,9 +21,9 @@ import org.eclipse.papyrus.resource.uml.UmlUtils;
* A {@link ModelSet} allowing to load models on demand.
* Also, this implementation allows to have loading strategies.
*
- * TODO extends {@link ModelSet} rather than {@link DiResourceSet}. This can be done once
+ * TODO extends {@link ModelSet} rather than {@link DiResourceSet}. This can be done once
* DiResourceSet is not referenced anywhere.
-
+ *
* @author cedric dumoulin
* @author emilien perico
*
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSetServiceFactory.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSetServiceFactory.java
index af9ed8aafd6..fa81e6c9d50 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSetServiceFactory.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/OnDemandLoadingModelSetServiceFactory.java
@@ -16,18 +16,19 @@ import org.eclipse.papyrus.resource.ModelSet;
/**
* A service starting the ModelSet
+ *
* @author cedric dumoulin
- *
+ *
*/
-public class OnDemandLoadingModelSetServiceFactory implements IServiceFactory{
+public class OnDemandLoadingModelSetServiceFactory implements IServiceFactory {
/** The ModelSet */
private ModelSet service;
-
+
/**
*
* @see org.eclipse.papyrus.core.services.IService#init(org.eclipse.papyrus.core.services.ServicesRegistry)
- *
+ *
* @param servicesRegistry
* @throws ServiceException
*/
@@ -37,7 +38,7 @@ public class OnDemandLoadingModelSetServiceFactory implements IServiceFactory{
/**
*
* @see org.eclipse.papyrus.core.services.IService#startService()
- *
+ *
* @throws ServiceException
*/
public void startService() throws ServiceException {
@@ -47,11 +48,11 @@ public class OnDemandLoadingModelSetServiceFactory implements IServiceFactory{
/**
*
* @see org.eclipse.papyrus.core.services.IService#disposeService()
- *
+ *
* @throws ServiceException
*/
public void disposeService() throws ServiceException {
- if( service != null)
+ if(service != null)
service.unload();
}
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/impl/ProxyManager.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/impl/ProxyManager.java
index 9dba7bf1414..a0d8584d0fe 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/impl/ProxyManager.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/impl/ProxyManager.java
@@ -185,7 +185,7 @@ public class ProxyManager implements IProxyManager {
*
* @return the current strategy, strategy 0 (load all resources) is loaded by default if null
*/
- private int getCurrentStrategy() {
+ private static int getCurrentStrategy() {
if(strategyChooser == null) {
return 0;
}
@@ -257,7 +257,7 @@ public class ProxyManager implements IProxyManager {
*
* @return
*/
- private static IStrategyChooser getStrategyChooser() {
+ public static IStrategyChooser getStrategyChooser() {
IStrategyChooser result = null;
IConfigurationElement[] element = Platform.getExtensionRegistry().getConfigurationElementsFor(STRATEGY_CHOOSER_EXTENSION_POINT_ID);
if(element.length > 0) {
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/AskUserStrategy.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/AskUserStrategy.java
index 59cda2ce0a0..3cb8193c4bc 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/AskUserStrategy.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/AskUserStrategy.java
@@ -50,7 +50,7 @@ public class AskUserStrategy implements ILoadingStrategy {
public boolean loadResource(ModelSet modelSet, URI uri) {
// pathmap resource are always loaded
boolean result = !uri.isPlatform() && !uri.isFile();
- if (!result) {
+ if(!result) {
URI lastInitialURI = SashModelUtils.getInitialURI(modelSet).trimFileExtension();
if(!lastInitialURI.equals(initialURI)) {
clear();
@@ -75,7 +75,7 @@ public class AskUserStrategy implements ILoadingStrategy {
// notification
}
}
- }
+ }
}
return result;
}
@@ -136,8 +136,7 @@ public class AskUserStrategy implements ILoadingStrategy {
for(String s : extensions) {
try {
URI uriToLoad = URI.createURI(uri.toString());
- if (s != null)
- {
+ if(s != null) {
uriToLoad = uriToLoad.appendFileExtension(s);
}
if(!alreadyLoaded.contains(uriToLoad)) {
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadAllResources.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadAllResources.java
index 2b6ba6aeb6c..23546e3eccf 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadAllResources.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadAllResources.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.core.resourceloading.strategies;
import org.eclipse.emf.common.util.URI;
diff --git a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadCurrentResource.java b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadCurrentResource.java
index 61db1a0c6dd..160572c1cd6 100644
--- a/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadCurrentResource.java
+++ b/plugins/core/org.eclipse.papyrus.core.resourceloading/src/org/eclipse/papyrus/core/resourceloading/strategies/LoadCurrentResource.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.core.resourceloading.strategies;
import org.eclipse.emf.common.util.URI;
@@ -21,8 +21,7 @@ import org.eclipse.papyrus.resource.ModelSet;
public class LoadCurrentResource implements ILoadingStrategy {
/**
- * {@inheritDoc}
- * Only loads additional resources (types, profiles, etc) and the current opened resource
+ * {@inheritDoc} Only loads additional resources (types, profiles, etc) and the current opened resource
* Controlled resources from the current one are not loaded
*/
public boolean loadResource(ModelSet modelSet, URI uri) {
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
index ef9771cb16b..6caeb12f6f7 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/multidiagram/actionbarcontributor/CoreComposedActionBarContributor.java
@@ -1,12 +1,20 @@
-/**
- *
- */
+/*****************************************************************************
+ * Copyright (c) 2008 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.core.multidiagram.actionbarcontributor;
import java.util.List;
-import org.eclipse.gef.ui.actions.RedoRetargetAction;
-import org.eclipse.gef.ui.actions.UndoRetargetAction;
import org.eclipse.papyrus.core.Activator;
import org.eclipse.papyrus.core.editor.BackboneException;
import org.eclipse.papyrus.sasheditor.editor.actionbarcontributor.ComposedActionBarContributor;
@@ -101,10 +109,12 @@ public class CoreComposedActionBarContributor extends ComposedActionBarContribut
//getActionBars().getToolBarManager().add(new RedoRetargetAction());
}
-
- public void setActiveEditor(IEditorPart targetEditor) {
- super.setActiveEditor(targetEditor);
+ @Override
+ public void setActiveEditor(IEditorPart part) {
+ super.setActiveEditor(part);
+ for (EditorActionBarContributor contributor : contributors) {
+ contributor.setActiveEditor(part);
+ }
}
-
}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java
new file mode 100644
index 00000000000..d2c86a9cf24
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/GMFtoEMFCommandWrapper.java
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * Copyright (c) 2007 Conselleria de Infraestructuras y Transporte,
+ * Generalitat de la Comunitat Valenciana . 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: Mario Cervera Ubeda (Prodevelop)
+ *
+ ******************************************************************************/
+package org.eclipse.papyrus.core.utils;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+
+/**
+ * A EMF Command that wraps a GMF command. Each method is redirected to the GMF one.
+ */
+public class GMFtoEMFCommandWrapper extends AbstractCommand {
+
+ /**
+ * The wrapped GMF Command. Package-level visibility so that the command stack wrapper can
+ * access the field.
+ */
+ private final ICommand gmfCommand;
+
+ /**
+ * Constructor.
+ *
+ * @param gmfCommand
+ * the gmf command
+ */
+ public GMFtoEMFCommandWrapper(ICommand gmfCommand) {
+ super(gmfCommand.getLabel());
+ this.gmfCommand = gmfCommand;
+ }
+
+ /**
+ * Returns the wrapped GMF command.
+ *
+ * @return the GMF command
+ */
+ // @unused
+ public ICommand getGMFCommand() {
+ return gmfCommand;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
+ */
+ @Override
+ public boolean canExecute() {
+ return gmfCommand.canExecute();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#dispose()
+ */
+ @Override
+ public void dispose() {
+ gmfCommand.dispose();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
+ */
+ @Override
+ public boolean canUndo() {
+ return gmfCommand.canUndo();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.Command#execute()
+ */
+ public void execute() {
+ try {
+ gmfCommand.execute(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.Command#redo()
+ */
+ public void redo() {
+ try {
+ gmfCommand.redo(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.common.command.AbstractCommand#undo()
+ */
+ @Override
+ public void undo() {
+ try {
+ gmfCommand.undo(new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ }
+
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java
new file mode 100644
index 00000000000..5f3f2fc3a21
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/core/utils/OpenDiagramCommand.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.core.utils;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.core.utils.DiResourceSet;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+
+
+/**
+ * The Class OpenDiagramCommand.
+ */
+public class OpenDiagramCommand extends AbstractTransactionalCommand {
+
+ /** The diagram to open. */
+ private EObject diagramToOpen = null;
+
+ private ICommand previousCreateDiagramCommand = null;
+
+ /**
+ * Instantiates a new open diagram command.
+ *
+ * @param domain
+ * the domain
+ * @param diagram
+ * the diagram
+ */
+ public OpenDiagramCommand(TransactionalEditingDomain editingDomain, EObject diagram) {
+ super(editingDomain, "Open diagram", null);
+ diagramToOpen = diagram;
+ }
+
+ public OpenDiagramCommand(TransactionalEditingDomain editingDomain, ICommand previousCreateDiagramCommand) {
+ super(editingDomain, "Open diagram", null);
+ this.previousCreateDiagramCommand = previousCreateDiagramCommand;
+ }
+
+ /**
+ * {@inheritedDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ try {
+ if(diagramToOpen == null && previousCreateDiagramCommand != null) {
+ Object possibleDiagramToOpen = previousCreateDiagramCommand.getCommandResult().getReturnValue();
+ if (possibleDiagramToOpen instanceof EObject) {
+ diagramToOpen = (EObject)possibleDiagramToOpen;
+ }
+ }
+
+ if(diagramToOpen != null && getEditingDomain().getResourceSet() instanceof DiResourceSet) {
+ DiResourceSet diResourceSet = (DiResourceSet)getEditingDomain().getResourceSet();
+
+ IPageMngr pageMngr = EditorUtils.getIPageMngr(diResourceSet.getDiResource());
+
+ if(pageMngr.isOpen(diagramToOpen)) {
+ pageMngr.closePage(diagramToOpen);
+ }
+ pageMngr.openPage(diagramToOpen);
+ }
+
+ return CommandResult.newOKCommandResult();
+ } catch (Exception e) {
+ throw new ExecutionException("Can't open diagram", e);
+ }
+ }
+}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/ModelSet.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/ModelSet.java
index 40a40994afd..6a06e09e369 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/ModelSet.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/ModelSet.java
@@ -25,10 +25,12 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
+import org.eclipse.papyrus.resource.additional.AdditionalResourcesModel;
@@ -60,6 +62,8 @@ public class ModelSet extends ResourceSetImpl {
/** The snippets. */
private ModelSetSnippetList snippets = new ModelSetSnippetList();
+
+ private AdditionalResourcesModel additional = new AdditionalResourcesModel();
/**
* The associated EditingDomain.
@@ -77,7 +81,9 @@ public class ModelSet extends ResourceSetImpl {
*
*/
public ModelSet() {
+ registerModel(additional);
}
+
/**
* Register the specified model under its associated key.
@@ -366,9 +372,13 @@ public class ModelSet extends ResourceSetImpl {
try {
// Walk all registered models
for(IModel model : modelList) {
- model.saveModel();
- monitor.worked(1);
+ if (!(model instanceof AdditionalResourcesModel))
+ {
+ model.saveModel();
+ monitor.worked(1);
+ }
}
+ additional.saveModel();
} finally {
monitor.done();
}
@@ -407,8 +417,12 @@ public class ModelSet extends ResourceSetImpl {
// Walk all registered models
for(IModel model : models.values()) {
- model.unload();
+ if (!(model instanceof AdditionalResourcesModel))
+ {
+ model.unload();
+ }
}
+ additional.unload();
// Unload remaining resources
for(Iterator<Resource> iter = getResources().iterator(); iter.hasNext();) {
@@ -427,7 +441,7 @@ public class ModelSet extends ResourceSetImpl {
public void addModelSetSnippet(IModelSetSnippet snippet) {
snippets.add(snippet);
}
-
+
/**
* A list of {@link IModelSetSnippet}.
*
@@ -466,4 +480,19 @@ public class ModelSet extends ResourceSetImpl {
}
}
+
+ /**
+ * Check is a resource is additional in the resource set
+ * @param uri the specified URI of the resource
+ * @return true if it is an additional resource
+ */
+ public boolean isAdditionalResource(URI uri) {
+ if (uri != null) {
+ String platformString = uri.trimFileExtension().toPlatformString(false);
+ return ((platformString == null) || !getFilenameWithoutExtension().toString().equals(platformString.toString()));
+ }
+ return false;
+ }
+
+
}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java
new file mode 100644
index 00000000000..ae6b43c52b5
--- /dev/null
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/additional/AdditionalResourcesModel.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Emilien Perico emilien.perico@atosorigin.com - manage loading strategies
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.resource.additional;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.resource.IModel;
+import org.eclipse.papyrus.resource.IModelSnippet;
+import org.eclipse.papyrus.resource.ModelSet;
+import org.eclipse.papyrus.resource.ModelSnippetList;
+
+public class AdditionalResourcesModel implements IModel {
+
+ /**
+ * The associated ModelManager.
+ */
+ private ModelSet modelSet;
+
+ /**
+ * List of attached snippets.
+ */
+ private ModelSnippetList snippets = new ModelSnippetList();
+
+ /**
+ * Model ID.
+ */
+ public static String MODEL_ID = "org.eclipse.papyrus.resource.additional";
+
+ public void init(ModelSet modelManager) {
+ this.modelSet = modelManager;
+ }
+
+ public String getIdentifier() {
+ return MODEL_ID;
+ }
+
+ /**
+ * useless for additional resources
+ */
+ public void createModel(IPath fullPath) {
+ //do nothing
+ }
+
+ public void loadModel(IPath path) {
+ // call registered snippets
+ snippets.performStart(this);
+ }
+
+ public void importModel(IPath fullPathWithoutExtension) {
+ loadModel(fullPathWithoutExtension);
+ }
+
+ public void saveModel() throws IOException {
+ for(Resource r : modelSet.getResources()) {
+ if(modelSet.isAdditionalResource(r.getURI())) {
+ EditingDomain editingDomain = modelSet.getTransactionalEditingDomain();
+ if(!r.getContents().isEmpty() && editingDomain != null && !editingDomain.isReadOnly(r) && (r.getURI().isPlatform() || r.getURI().isFile())) {
+ r.save(Collections.EMPTY_MAP);
+ }
+ }
+ }
+ }
+
+ /**
+ * useless for additional resources
+ */
+ public void changeModelPath(IPath fullPath) {
+ // do nothing
+ }
+
+ public void unload() {
+ // call registered snippets
+ snippets.performDispose(this);
+
+ // Unload remaining resources
+ for(Iterator<Resource> iter = modelSet.getResources().iterator(); iter.hasNext();) {
+ Resource next = iter.next();
+ if(modelSet.isAdditionalResource(next.getURI())) {
+ next.unload();
+ }
+ iter.remove();
+ }
+ }
+
+ public void addModelSnippet(IModelSnippet snippet) {
+ snippets.add(snippet);
+ }
+
+ /**
+ * @return the modelManager
+ */
+ protected ModelSet getModelManager() {
+ return modelSet;
+ }
+
+}
diff --git a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java
index af75dc8cc70..89979d4c0da 100644
--- a/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java
+++ b/plugins/core/org.eclipse.papyrus.core/src/org/eclipse/papyrus/resource/notation/NotationUtils.java
@@ -13,7 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.resource.notation;
-import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
@@ -21,8 +21,8 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.core.services.ServiceException;
-import org.eclipse.papyrus.resource.ModelUtils;
import org.eclipse.papyrus.resource.ModelSet;
+import org.eclipse.papyrus.resource.ModelUtils;
/**
* Utilities method to manage notation models. Should be moved in a more suitable plugin
@@ -133,7 +133,7 @@ public class NotationUtils {
*
*/
public static List<Diagram> getDiagrams(Resource notationResource, EObject eObject) {
- List<Diagram> diagrams = new ArrayList<Diagram>();
+ List<Diagram> diagrams = new LinkedList<Diagram>();
if(notationResource != null) {
for(EObject obj : notationResource.getContents()) {
if(obj instanceof Diagram) {
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/META-INF/MANIFEST.MF
index 7df585d7ff6..f9f6073adc2 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/META-INF/MANIFEST.MF
@@ -2,13 +2,16 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.controlmode.umlprofiles;singleton:=true
-Bundle-Version: 0.8.0.qualifier
+Bundle-Version: 0.7.3.qualifier
Bundle-Activator: org.eclipse.papyrus.controlmode.umlprofiles.Activator
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.controlmode,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.uml2.uml,
- org.eclipse.uml2.uml.edit
+ org.eclipse.uml2.uml.edit,
+ org.eclipse.papyrus.ui.toolbox,
+ org.eclipse.papyrus.core,
+ org.eclipse.papyrus.core.resourceloading.preferences
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/build.properties b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/build.properties
index bfa98369607..2fc980772f5 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/build.properties
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/build.properties
@@ -4,4 +4,5 @@ bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
- plugin.properties
+ plugin.properties,\
+ src/org/eclipse/papyrus/controlmode/umlprofiles/messages.properties
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/plugin.xml b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/plugin.xml
index 739a391a00f..ac023ae85c7 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/plugin.xml
@@ -13,5 +13,40 @@
controlCondition="org.eclipse.papyrus.controlmode.umlprofiles.commands.UMLProfileControlCondition">
</enableControlCommand>
</extension>
+
+ <extension point="org.eclipse.emf.validation.constraintProviders">
+ <category id="org.eclipse.papyrus.controlmode.umlprofiles/duplicateProfileApplication" mandatory="false" name="duplicateProfileApplication">
+ <![CDATA[Validate that Profile Application is correctly duplicated on controlled Packages]]>
+ </category>
+ <constraintProvider cache="true">
+ <package namespaceUri="http://www.eclipse.org/uml2/3.0.0/UML"/>
+ <constraints categories="org.eclipse.papyrus.controlmode.umlprofiles/duplicateProfileApplication">
+ <constraint id="org.eclipse.papyrus.controlmode.umlprofiles.validation.ProfileApplicationDuplicationChecker"
+ lang="Java"
+ name="ProfileApplicationDuplicationChecker"
+ class="org.eclipse.papyrus.controlmode.umlprofiles.validation.ProfileApplicationDuplicationChecker"
+ mode="Live"
+ severity="ERROR" statusCode="200">
+ <description><![CDATA[Profile Applications must be duplicated on controlled Packages]]></description>
+ <message><![CDATA[Profile Applications modification did not successfully completed]]></message>
+ <target class="uml.ProfileApplication"/>
+ <target class="uml.Package"/>
+ </constraint>
+ </constraints>
+ </constraintProvider>
+ </extension>
+
+ <extension point="org.eclipse.emf.validation.constraintBindings">
+ <clientContext default="false" id="org.eclipse.papyrus.controlmodeDefaultCtx">
+ <selector class="org.eclipse.papyrus.controlmode.umlprofiles.providers.UMLValidationProvider$DefaultCtx"/>
+ </clientContext>
+ <binding context="org.eclipse.papyrus.controlmodeDefaultCtx">
+ <constraint ref="org.eclipse.papyrus.controlmode.umlprofiles.validation.ProfileApplicationDuplicationChecker"/>
+ </binding>
+ </extension>
+
+ <extension point="org.eclipse.emf.validation.ui.UIRegisteredClientContext">
+ <clientContext id="org.eclipse.papyrus.controlmodeDefaultCtx"/>
+ </extension>
</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Activator.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Activator.java
index ad05cb0db8f..d27f2164a9b 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Activator.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Activator.java
@@ -13,7 +13,7 @@ public class Activator extends Plugin {
// The shared instance
private static Activator plugin;
-
+
/**
* The constructor
*/
@@ -22,6 +22,7 @@ public class Activator extends Plugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
@@ -31,6 +32,7 @@ public class Activator extends Plugin {
/*
* (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
@@ -40,7 +42,7 @@ public class Activator extends Plugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Messages.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Messages.java
new file mode 100644
index 00000000000..77aff64add1
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/Messages.java
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.controlmode.umlprofiles;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * This class handles messages internationalization.
+ *
+ * @author vhemery
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.controlmode.umlprofiles.messages"; //$NON-NLS-1$
+
+ /** Message for switching the loading strategy when controlled package is not loaded */
+ public static String switch_loading_strategy;
+
+ /** Error message when controlled package is read-only */
+ public static String error_readonly;
+
+ /** Error message when an error occurs during validation */
+ public static String error_during_validation;
+
+ /** Error message when trying to delete a duplicated profile application */
+ public static String warning_cannot_delete_duplicated;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCommand.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCommand.java
index 972f4a2a0a7..030fe89551c 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCommand.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCommand.java
@@ -13,17 +13,13 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.umlprofiles.commands;
-import java.util.Iterator;
-
import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.controlmode.commands.IControlCommand;
+import org.eclipse.papyrus.controlmode.umlprofiles.helpers.ProfileApplicationHelper;
import org.eclipse.uml2.common.edit.command.ChangeCommand;
-import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
@@ -56,7 +52,7 @@ public class UMLProfileControlCommand implements IControlCommand {
commandToModify.append(new ChangeCommand(domain, new Runnable() {
public void run() {
- relocateStereotypeApplications(selection, target);
+ ProfileApplicationHelper.relocateStereotypeApplications((Package)selection, target);
}
}));
break;
@@ -72,33 +68,7 @@ public class UMLProfileControlCommand implements IControlCommand {
private void duplicateAppliedProfiles(final EObject selection) {
Package _package = (Package)selection;
for(Profile profile : _package.getAllAppliedProfiles()) {
- if(!_package.isProfileApplied(profile)) {
- _package.applyProfile(profile);
- }
- }
- }
-
- /**
- * Relocate stereotype applications for the nested elements of the selection in the controlled resource
- *
- * @param selection
- * @param target
- * the target controlled resource
- */
- private void relocateStereotypeApplications(final EObject selection, final Resource target) {
- Package pack = (Package)selection;
- for(Iterator<EObject> i = EcoreUtil.getAllProperContents(pack, false); i.hasNext();) {
- EObject current = i.next();
- if(current instanceof Element) {
- Element element = (Element)current;
- EList<EObject> stereotypeApplications = element.getStereotypeApplications();
- if(!stereotypeApplications.isEmpty()) {
- for(EObject e : stereotypeApplications) {
- int size = target.getContents().size();
- target.getContents().add(size, e);
- }
- }
- }
+ ProfileApplicationHelper.duplicateProfileApplication(_package, profile);
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCondition.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCondition.java
index dfaa5efb091..7b987b9414e 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCondition.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileControlCondition.java
@@ -10,7 +10,7 @@
* Contributors:
* Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
*
- *****************************************************************************/
+ *****************************************************************************/
package org.eclipse.papyrus.controlmode.umlprofiles.commands;
import org.eclipse.emf.ecore.EObject;
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileUncontrolCommand.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileUncontrolCommand.java
index 8a4abc7a6bc..8536cabf9ce 100644
--- a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileUncontrolCommand.java
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/commands/UMLProfileUncontrolCommand.java
@@ -13,17 +13,16 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.umlprofiles.commands;
-import java.util.Iterator;
+import java.util.ArrayList;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.controlmode.commands.IUncontrolCommand;
+import org.eclipse.papyrus.controlmode.umlprofiles.helpers.ProfileApplicationHelper;
import org.eclipse.uml2.common.edit.command.ChangeCommand;
-import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
@@ -57,7 +56,7 @@ public class UMLProfileUncontrolCommand implements IUncontrolCommand {
commandToModify.append(new ChangeCommand(domain, new Runnable() {
public void run() {
- relocateStereotypeApplications(selection, target);
+ ProfileApplicationHelper.relocateStereotypeApplications((Package)selection, target);
}
}));
break;
@@ -67,44 +66,22 @@ public class UMLProfileUncontrolCommand implements IUncontrolCommand {
/**
* Unapply profiles duplicated for control action
+ *
* @param selection
- * @param the resource target
+ * @param target
+ * the resource target
*/
private void unapplyDuplicateProfiles(final EObject selection, Resource target) {
Package _package = (Package)selection;
EList<Profile> allAppliedProfiles = _package.getAllAppliedProfiles();
- if (!allAppliedProfiles.isEmpty()) {
- for(Profile profile : _package.getAppliedProfiles()) {
- if (allAppliedProfiles.contains(profile)) {
- // profile is duplicate, unapply it
- _package.unapplyProfile(profile);
+ if(!allAppliedProfiles.isEmpty()) {
+ for(Profile profile : new ArrayList<Profile>(_package.getAppliedProfiles())) {
+ if(allAppliedProfiles.contains(profile)) {
+ // profile is duplicated, unapply it
+ ProfileApplicationHelper.removeProfileApplicationDuplication(_package, profile, true);
}
}
-
- }
- }
- /**
- * Relocate stereotype applications for the nested elements of the selection in the parent resource
- *
- * @param selection
- * @param target
- * the parent resource
- */
- private void relocateStereotypeApplications(final EObject selection, final Resource target) {
- Package pack = (Package)selection;
- for(Iterator<EObject> i = EcoreUtil.getAllProperContents(pack, false); i.hasNext();) {
- EObject current = i.next();
- if(current instanceof Element) {
- Element element = (Element)current;
- EList<EObject> stereotypeApplications = element.getStereotypeApplications();
- if(!stereotypeApplications.isEmpty()) {
- for(EObject e : stereotypeApplications) {
- int size = target.getContents().size();
- target.getContents().add(size, e);
- }
- }
- }
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/ProfileApplicationHelper.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/ProfileApplicationHelper.java
new file mode 100644
index 00000000000..435175d0574
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/ProfileApplicationHelper.java
@@ -0,0 +1,175 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.controlmode.umlprofiles.helpers;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+
+/**
+ * This helper provides methods to manipulate profile applications on packages.
+ *
+ * @author vhemery
+ */
+public class ProfileApplicationHelper {
+
+ /** EAnnotation for duplicated profiles on controlled packages */
+ public static final String DUPLICATED_PROFILE = "duplicatedProfile";
+
+ /**
+ * Duplicate a profile application on a child package.
+ *
+ * @param _package
+ * package to duplicate profile application on
+ * @param profile
+ * profile to apply
+ */
+ public static void duplicateProfileApplication(Package _package, Profile profile) {
+ if(!isSameProfileApplied(_package, profile)) {
+ _package.applyProfile(profile);
+ ProfileApplication profileAppl = _package.getProfileApplication(profile);
+ if(profileAppl != null) {
+ markAsDuplicate(profileAppl);
+ }
+ }
+ }
+
+ /**
+ * Remove a profile application duplicate on a child package
+ *
+ * @param _package
+ * package to remove duplicated profile application from
+ * @param profile
+ * profile to unapply
+ * @param force
+ * true when package is no longer controlled for forcing profile application removal
+ */
+ public static void removeProfileApplicationDuplication(Package _package, Profile profile, boolean force) {
+ if(isSameProfileApplied(_package, profile)) {
+ ProfileApplication profileAppl = _package.getProfileApplication(profile);
+ // remove only duplicated profile applications with eannotation
+ if(isDuplicatedProfileApplication(profileAppl)) {
+ if(force || getParentPackageWithProfile(_package, profile, false) == null) {
+ // first remove eannotation to ensure it will not added again by checker
+ profileAppl.getEAnnotations().remove(profileAppl.getEAnnotation(DUPLICATED_PROFILE));
+ _package.unapplyProfile(profile);
+ }
+ // else, there is another parent profile which justifies the duplication
+ }
+ }
+ }
+
+ /**
+ * Check if the profile is applied on a package, or one similar
+ *
+ * @param _package
+ * package to test on
+ * @param profile
+ * profile to check
+ * @return true if a similar profile is applied
+ */
+ private static boolean isSameProfileApplied(Package _package, Profile profile) {
+ for(Profile prof : _package.getAppliedProfiles()) {
+ if(prof.equals(profile)) {
+ return true;
+ }
+ if(profile.getQualifiedName().equals(prof.getQualifiedName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Relocate stereotype applications for the nested elements of the selection in the controlled resource
+ *
+ * @param pack
+ * the package for which stereotype application must be relocated
+ * @param target
+ * the target controlled resource
+ */
+ public static void relocateStereotypeApplications(Package pack, Resource target) {
+ for(Iterator<EObject> i = EcoreUtil.getAllProperContents(pack, false); i.hasNext();) {
+ EObject current = i.next();
+ if(current instanceof Element) {
+ Element element = (Element)current;
+ EList<EObject> stereotypeApplications = element.getStereotypeApplications();
+ if(!stereotypeApplications.isEmpty()) {
+ for(EObject e : stereotypeApplications) {
+ int size = target.getContents().size();
+ target.getContents().add(size, e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if the profile application is a duplicated one
+ *
+ * @param profileAppl
+ * profile application to check
+ * @return true if it is a duplicated copy
+ */
+ public static boolean isDuplicatedProfileApplication(ProfileApplication profileAppl) {
+ return profileAppl.getEAnnotation(DUPLICATED_PROFILE) != null;
+ }
+
+ /**
+ * Get the nearest parent package which has the profile applied.
+ *
+ * @param packageElement
+ * child package
+ * @param profile
+ * applied profile
+ * @param notControlledOnly
+ * true to return only a not controlled package
+ * @return the parent package with profile application
+ */
+ public static Package getParentPackageWithProfile(Package packageElement, Profile profile, boolean notControlledOnly) {
+ Element parent = packageElement.getOwner();
+ while(parent != null) {
+ if(parent instanceof Package) {
+ Package parentPackage = (Package)parent;
+ if(isSameProfileApplied(parentPackage, profile)) {
+ if(!notControlledOnly || !AdapterFactoryEditingDomain.isControlled(parentPackage)) {
+ return parentPackage;
+ }
+ }
+ }
+ parent = parent.getOwner();
+ }
+ return null;
+ }
+
+ /**
+ * Mark this profile application as the duplication of a parent profile
+ *
+ * @param profileAppl
+ * profile application to mark
+ */
+ public static void markAsDuplicate(ProfileApplication profileAppl) {
+ // add eannotation for duplicated profile applications
+ profileAppl.createEAnnotation(DUPLICATED_PROFILE);
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/SafeDialogOpenerDuringValidation.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/SafeDialogOpenerDuringValidation.java
new file mode 100644
index 00000000000..f239cb4e0e6
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/helpers/SafeDialogOpenerDuringValidation.java
@@ -0,0 +1,72 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.controlmode.umlprofiles.helpers;
+
+import org.eclipse.core.commands.operations.IOperationApprover2;
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * This class must be used to open a dialog during a validation. Its usage avoids side effects with the Properties view, which would throw an
+ * {@link IllegalStateException}. The parameterizing class can be used to return a result from the dialog (use {@link Void} if no result is expected).
+ */
+public abstract class SafeDialogOpenerDuringValidation<ReturnType> {
+
+
+ /**
+ * This approver is used to disable any operation during opening of a popup to avoid side
+ * effects
+ */
+ private static IOperationApprover2 operationDisapprover = new IOperationApprover2() {
+
+ public IStatus proceedUndoing(IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
+ return Status.CANCEL_STATUS;
+ }
+
+ public IStatus proceedRedoing(IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
+ return Status.CANCEL_STATUS;
+ }
+
+ public IStatus proceedExecuting(IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
+ return Status.CANCEL_STATUS;
+ }
+ };
+
+ /**
+ * Subclasses must implement this method with the dialog opening. If no result is expected, return null.
+ */
+ protected abstract ReturnType openDialog();
+
+ /**
+ * Run the dialog opening with necessary precautions.
+ */
+ public final ReturnType execute() {
+ /*
+ * We are currently validating an ongoing operation. Opening a popup here may have
+ * side-effects such as re-launching the same operation. (the editor may have not been
+ * deactivated yet, and its loss of focus will open a new operation) For this reason, we
+ * temporarily disable all operations on the history, just enough time for opening the
+ * popup.
+ */
+ IOperationHistory history = OperationHistoryFactory.getOperationHistory();
+ history.addOperationApprover(operationDisapprover);
+ ReturnType result = openDialog();
+ history.removeOperationApprover(operationDisapprover);
+ return result;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/messages.properties b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/messages.properties
new file mode 100644
index 00000000000..9e9c8df736a
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/messages.properties
@@ -0,0 +1,4 @@
+switch_loading_strategy=<form>The following controlled packages are not loaded :{0}In order to change profile application, will you switch to the default loading strategy ? Otherwise, the operation will be canceled.</form>
+error_readonly=<form>The following packages are in a read-only resource :{0}You can not change profile application without updating them. Please ensure the containing resource is writeable before trying again.</form>
+error_during_validation=An unexpected exception occurred during profile application duplication check.
+warning_cannot_delete_duplicated=The profile application on {0} has not be deleted since it has been copied from {1} during controlling. Delete this one's instead.
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/providers/UMLValidationProvider.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/providers/UMLValidationProvider.java
new file mode 100644
index 00000000000..410fc8c9368
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/providers/UMLValidationProvider.java
@@ -0,0 +1,189 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.controlmode.umlprofiles.providers;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.validation.model.IClientSelector;
+import org.eclipse.emf.validation.model.IConstraintStatus;
+import org.eclipse.emf.validation.service.IValidationListener;
+import org.eclipse.emf.validation.service.ModelValidationService;
+import org.eclipse.emf.validation.service.ValidationEvent;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.papyrus.controlmode.umlprofiles.Activator;
+import org.eclipse.papyrus.controlmode.umlprofiles.helpers.SafeDialogOpenerDuringValidation;
+import org.eclipse.papyrus.resource.ModelSet;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
+
+/**
+ * Provides validation for UML models
+ */
+public class UMLValidationProvider {
+
+ /**
+ * Whether constraints are active
+ */
+ private static boolean constraintsActive = false;
+
+ /**
+ * Ids of constraints which report is already managed by themselves.
+ */
+ protected static final Collection<String> SELF_MANAGING_CONSTRAINTS = Arrays.asList("org.eclipse.papyrus.controlmode.umlprofiles.validation.ProfileApplicationDuplicationChecker");
+
+ /**
+ * Validation listener which reports problems to the user
+ */
+ private static class ValidationReportListener implements IValidationListener {
+
+ /**
+ * Report the validation result to the user in case operation did not fully succeed
+ *
+ * @see org.eclipse.emf.validation.service.IValidationListener#validationOccurred(org.eclipse.emf.validation.service.ValidationEvent)
+ *
+ * @param event
+ * provides the validation operation results
+ */
+ public void validationOccurred(ValidationEvent event) {
+ boolean needReport = false;
+ if(event.getSeverity() >= IStatus.WARNING) {
+ needReport = true;
+ }
+ if(needReport && event.getEvaluationMode().isLive()) {
+ StringBuffer messageBuff = new StringBuffer();
+ List<String> handledConstraints = new LinkedList<String>(SELF_MANAGING_CONSTRAINTS);
+ for(IConstraintStatus status : event.getValidationResults()) {
+ // report only major problems
+ if(status.getSeverity() >= event.getSeverity()) {
+ String constraintId = status.getConstraint().getDescriptor().getId();
+ String constraintPlugin = status.getConstraint().getDescriptor().getPluginId();
+ if(Activator.PLUGIN_ID.equals(constraintPlugin) && !handledConstraints.contains(constraintId)) {
+ handledConstraints.add(constraintId);
+ messageBuff.append(status.getMessage());
+ }
+ }
+ }
+ if(messageBuff.length() == 0) {
+ // no error to report
+ return;
+ }
+ final String message = messageBuff.toString();
+ if(event.getSeverity() >= IStatus.ERROR) {
+ SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+
+ protected Void openDialog() {
+ NotificationBuilder.createWarningPopup(message).run();
+ return null;
+ }
+ };
+ opener.execute();
+ } else {
+ SafeDialogOpenerDuringValidation<Void> opener = new SafeDialogOpenerDuringValidation<Void>() {
+
+ protected Void openDialog() {
+ NotificationBuilder.createInfoPopup(message).run();
+ return null;
+ }
+ };
+ opener.execute();
+ }
+ }
+ }
+ }
+
+ /**
+ * Add a validation listener to report problems
+ */
+ static {
+ ModelValidationService.getInstance().addValidationListener(new ValidationReportListener());
+ }
+
+ /**
+ * Run an operation with checking of the constraints
+ *
+ * @param editingDomain
+ * editing domain
+ * @param operation
+ * operation to run
+ */
+ public static void runWithConstraints(TransactionalEditingDomain editingDomain, Runnable operation) {
+ final Runnable op = operation;
+ Runnable task = new Runnable() {
+
+ public void run() {
+ try {
+ constraintsActive = true;
+ op.run();
+ } finally {
+ constraintsActive = false;
+ }
+ }
+ };
+ if(editingDomain != null) {
+ try {
+ editingDomain.runExclusive(task);
+ } catch (Exception e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Validation failed", e));
+ }
+ } else {
+ task.run();
+ }
+ }
+
+ /**
+ * Context for validation
+ */
+ public static class DefaultCtx implements IClientSelector {
+
+ /**
+ * Indicate whether validation is activated
+ *
+ * @see org.eclipse.emf.validation.model.IClientSelector#selects(java.lang.Object)
+ *
+ * @param object
+ * object to eventually validate
+ * @return true if validation is required
+ */
+ public boolean selects(Object object) {
+ if(constraintsActive) {
+ return true;
+ }
+ if(object instanceof EObject) {
+ EObject eObj = (EObject)object;
+ ResourceSet set = eObj.eResource().getResourceSet();
+ return set instanceof ModelSet;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Format a model element
+ *
+ * @param object
+ * element to format
+ * @return text
+ */
+ static String formatElement(EObject object) {
+ return EMFCoreUtil.getQualifiedName(object, true);
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/validation/ProfileApplicationDuplicationChecker.java b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/validation/ProfileApplicationDuplicationChecker.java
new file mode 100644
index 00000000000..5fd40058a5c
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.controlmode.umlprofiles/src/org/eclipse/papyrus/controlmode/umlprofiles/validation/ProfileApplicationDuplicationChecker.java
@@ -0,0 +1,332 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos Origin.
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.controlmode.umlprofiles.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.validation.AbstractModelConstraint;
+import org.eclipse.emf.validation.EMFEventType;
+import org.eclipse.emf.validation.IValidationContext;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.controlmode.umlprofiles.Activator;
+import org.eclipse.papyrus.controlmode.umlprofiles.Messages;
+import org.eclipse.papyrus.controlmode.umlprofiles.helpers.ProfileApplicationHelper;
+import org.eclipse.papyrus.core.resourceloading.preferences.StrategyChooser;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.ProfileApplication;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Check if profile application is correctly duplicated on all controlled sub-packages and duplicate it if needed.
+ * In case of deletion, it also removes unnecessary profile applications.
+ *
+ * @author vhemery
+ */
+public class ProfileApplicationDuplicationChecker extends AbstractModelConstraint {
+
+ /**
+ * This is a result which is intended to be set with a boolean value with notification runables.
+ *
+ * @author vhemery
+ */
+ public class BooleanResult {
+
+ boolean value = false;
+
+ /**
+ * Get result
+ *
+ * @return boolean result value
+ */
+ public boolean getValue() {
+ return value;
+ }
+
+ /**
+ * Set result
+ *
+ * @param pValue
+ * boolean result value
+ */
+ public void setValue(boolean pValue) {
+ value = pValue;
+ }
+
+ }
+
+ /** Format String for a list entry */
+ private static final String ENTRY_FORMAT = "<li>%s</li>";
+
+ /** Constant for load all loading strategy */
+ protected static final int LOAD_ALL_STRATEGY = 0;
+
+ private IValidationContext lastValidatedContext = null;
+
+ /**
+ * Check if profile applications are correctly duplicated on controlled package and that there is no useless copy left.
+ *
+ * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
+ *
+ * @param ctx
+ * validation context
+ * @return validation status
+ */
+ public IStatus validate(IValidationContext ctx) {
+ try {
+ if(ctx.equals(lastValidatedContext)) {
+ return ctx.createSuccessStatus();
+ } else {
+ lastValidatedContext = ctx;
+ }
+ EObject eObject = ctx.getTarget();
+ // detect profile application creation
+ if((EMFEventType.ADD.equals(ctx.getEventType()) || EMFEventType.ADD_MANY.equals(ctx.getEventType())) && ctx.getFeatureNewValue() instanceof ProfileApplication) {
+ ProfileApplication profileAppl = (ProfileApplication)ctx.getFeatureNewValue();
+ Package pack = (Package)eObject;
+ boolean res = stereotypeApplicationAdded(pack, profileAppl);
+ if(!res) {
+ return ctx.createFailureStatus();
+ }
+ }
+ // detect profile application deletion
+ else if(((EMFEventType.REMOVE.equals(ctx.getEventType()) && ctx.getFeatureNewValue() instanceof ProfileApplication) || EMFEventType.REMOVE_MANY.equals(ctx.getEventType()))) {
+ Map<ProfileApplication, Profile> oldAssignement = new HashMap<ProfileApplication, Profile>(ctx.getAllEvents().size());
+ for(Notification n : ctx.getAllEvents()) {
+ // case when profile is removed from profile application : keep the reference
+ if(ENotificationImpl.SET == n.getEventType() && UMLPackage.eINSTANCE.getProfileApplication_AppliedProfile().equals(n.getFeature()) && n.getNotifier() instanceof ProfileApplication) {
+ Profile profile = (Profile)n.getOldValue();
+ ProfileApplication profileAppl = (ProfileApplication)n.getNotifier();
+ oldAssignement.put(profileAppl, profile);
+ }
+ // cases when profile application is removed
+ if(ENotificationImpl.REMOVE == n.getEventType() && n.getOldValue() instanceof ProfileApplication && n.getNotifier() instanceof Package) {
+ ProfileApplication profileAppl = (ProfileApplication)n.getOldValue();
+ Package pack = (Package)n.getNotifier();
+ Profile profile = profileAppl.getAppliedProfile();
+ if(profile == null) {
+ profile = oldAssignement.get(profileAppl);
+ }
+ if(profile != null) {
+ boolean res = stereotypeApplicationRemoved(pack, profileAppl, profile);
+ if(!res) {
+ return ctx.createFailureStatus();
+ }
+ }
+ }
+ }
+
+ }
+ return ctx.createSuccessStatus();
+ } catch (RuntimeException rte) {
+ // avoid throwing uncaught exception which would disable the constraint
+ Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.error_during_validation, rte));
+ // ensure that the constraint's failure does not prevent modification
+ return ctx.createSuccessStatus();
+ }
+ }
+
+ /**
+ * Handle the case when a stereotype application is added :
+ * - Inspect controlled sub-packages
+ * - Duplicate profile applicationss on these
+ * - Create eAnnotation for duplicated profiles
+ *
+ * @param packageElement
+ * the package on which stereotype application has been added
+ * @param profileAppl
+ * the added profile application
+ * @return whether addition is allowed
+ */
+ private boolean stereotypeApplicationAdded(Package packageElement, ProfileApplication profileAppl) {
+ //Inspect controlled sub-packages
+ Set<Package> controlledPack = getControlledSubPackages(packageElement);
+ boolean update = checkControlledPackagesUpdateable(controlledPack);
+ if(update) {
+ for(Package pack : controlledPack) {
+ ProfileApplicationHelper.duplicateProfileApplication(pack, profileAppl.getAppliedProfile());
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Handle the case when a stereotype application is removed :
+ * - Forbid direct removal of a duplicated profile application (with eAnnotation)
+ * - Inspect controlled sub-packages
+ * - Remove duplicated profile applications on these (with eAnnotation)
+ *
+ * @param packageElement
+ * the package from which stereotype application has been removed
+ * @param profileAppl
+ * the removed profile application
+ * @param profile
+ * the unapplied profile
+ * @return whether removal is allowed
+ */
+ private boolean stereotypeApplicationRemoved(Package packageElement, ProfileApplication profileAppl, Profile profile) {
+ //Forbid direct removal of a duplicated profile application (with eAnnotation)
+ if(ProfileApplicationHelper.isDuplicatedProfileApplication(profileAppl)) {
+ Package parentPack = ProfileApplicationHelper.getParentPackageWithProfile(packageElement, profile, true);
+ if(parentPack != null) {
+ // restore stereotype application when it is called from parent intermediate package
+ ProfileApplicationHelper.duplicateProfileApplication(packageElement, profile);
+ String msg = NLS.bind(Messages.warning_cannot_delete_duplicated, EMFCoreUtil.getQualifiedName(packageElement, true), EMFCoreUtil.getQualifiedName(parentPack, true));
+ NotificationBuilder notifBuild = NotificationBuilder.createAsyncPopup(msg);
+ notifBuild.run();
+ return true;
+ }
+ }
+ //Inspect controlled sub-packages
+ Set<Package> controlledPack = getControlledSubPackages(packageElement);
+ boolean update = checkControlledPackagesUpdateable(controlledPack);
+ if(update) {
+ for(Package pack : controlledPack) {
+ ProfileApplicationHelper.removeProfileApplicationDuplication(pack, profile, false);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check if controlled sub-packages can be correctly updated :
+ * - Check if controlled package is loaded
+ * - Change the control strategy if necessary
+ * - Report error if the controlled package is read-only
+ *
+ * @param controlledPackages
+ * the controlled sub-packages (may be updated if contains proxies)
+ * @return true if can be updated
+ */
+ private boolean checkControlledPackagesUpdateable(Set<Package> controlledPackages) {
+ boolean notLoadedPackages = false;
+ StringBuffer notLoadedPackagesList = new StringBuffer();
+ boolean readOnlyPackages = false;
+ StringBuffer readOnlyPackagesList = new StringBuffer();
+ //Check if controlled package is loaded
+ for(Iterator<Package> iterator = controlledPackages.iterator(); iterator.hasNext();) {
+ Package pack = iterator.next();
+ EditingDomain domain = EditorUtils.getTransactionalEditingDomain();
+ if(pack.eIsProxy()) {
+ EObject loadedObject = domain.getResourceSet().getEObject(((InternalEObject)pack).eProxyURI(), true);
+ if(loadedObject != null) {
+ // pack has been reload, replace proxy;
+ controlledPackages.remove(pack);
+ pack = (Package)loadedObject;
+ controlledPackages.add(pack);
+ }
+ }
+ if(pack.eIsProxy()) {
+ notLoadedPackages = true;
+ URI uri = ((InternalEObject)pack).eProxyURI();
+ String uriLastSeg = uri.lastSegment();
+ String name = uriLastSeg.substring(0, uriLastSeg.length() - uri.fileExtension().length() - 1);
+ String qualifName = EMFCoreUtil.getQualifiedName(pack.getOwner(), true).concat("::").concat(name);//$NON-NLS-1$
+ notLoadedPackagesList.append(String.format(ENTRY_FORMAT, qualifName));
+ } else {
+ if(domain instanceof AdapterFactoryEditingDomain) {
+ // reset read-only cache map
+ ((AdapterFactoryEditingDomain)domain).getResourceToReadOnlyMap().clear();
+ }
+ if(domain.isReadOnly(pack.eResource())) {
+ readOnlyPackages = true;
+ String name = EMFCoreUtil.getQualifiedName(pack, true);
+ readOnlyPackagesList.append(String.format(ENTRY_FORMAT, name));
+ }
+ }
+ }
+ //Report error if the controlled package is read-only
+ if(readOnlyPackages) {
+ String msg = NLS.bind(Messages.error_readonly, readOnlyPackagesList.toString());
+ NotificationBuilder notifBuild = NotificationBuilder.createErrorPopup(msg);
+ notifBuild.setHTML(true);
+ notifBuild.run();
+ return false;
+ }
+ //Change the control strategy if necessary
+ if(notLoadedPackages) {
+ String msg = NLS.bind(Messages.switch_loading_strategy, notLoadedPackagesList.toString());
+ final BooleanResult stategyChanged = new BooleanResult();
+ Runnable runStrategySwitch = new Runnable() {
+
+ public void run() {
+ StrategyChooser.setCurrentStrategy(LOAD_ALL_STRATEGY);
+ stategyChanged.setValue(true);
+ }
+ };
+ Runnable cancel = new Runnable() {
+
+ public void run() {
+ stategyChanged.setValue(false);
+ }
+ };
+ NotificationBuilder notifBuild = NotificationBuilder.createYesNo(msg, runStrategySwitch, cancel);
+ notifBuild.setHTML(true);
+ notifBuild.setAsynchronous(false);
+ notifBuild.run();
+ if(stategyChanged.getValue()) {
+ // refresh set controlledPackages
+ return checkControlledPackagesUpdateable(controlledPackages);
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Get the controlled children packages
+ *
+ * @param packageElement
+ * package to inspect children
+ * @return set of children packages which are controlled
+ */
+ private Set<Package> getControlledSubPackages(Package packageElement) {
+ Set<Package> controlledPackages = new HashSet<Package>();
+ TreeIterator<EObject> iterator = packageElement.eAllContents();
+ while(iterator.hasNext()) {
+ EObject child = iterator.next();
+ if(child instanceof Package) {
+ // despite what AdapterFactoryEditingDomain#isControlled says, a not loaded child is controlled
+ if(AdapterFactoryEditingDomain.isControlled(child) || child.eIsProxy()) {
+ controlledPackages.add((Package)child);
+ }
+ } else {
+ iterator.prune();
+ }
+ }
+ return controlledPackages;
+ }
+}

Back to the top