Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-09-16 09:43:20 +0000
committervlorenzo2011-09-16 09:43:20 +0000
commit3ca795bddfe3705d06a696fcdc9b6cc25b70169c (patch)
treeaed1ee526176bc29ba9158654a5c2de418aaed93
parentd5420ed8e881acf0e2d7a3ed96ec30fd7129ba70 (diff)
downloadorg.eclipse.papyrus-0.8.1_SR1@5489.tar.gz
org.eclipse.papyrus-0.8.1_SR1@5489.tar.xz
org.eclipse.papyrus-0.8.1_SR1@5489.zip
350910: [Profile Diagram][ModelExplorer] Metaclasses are not in read only access mode0.8.1_SR1@5489
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350910
-rw-r--r--0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/META-INF/MANIFEST.MF3
-rw-r--r--0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/src/org/eclipse/papyrus/modelexplorer/handler/DeleteCommandHandler.java67
2 files changed, 65 insertions, 5 deletions
diff --git a/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/META-INF/MANIFEST.MF b/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/META-INF/MANIFEST.MF
index bf7e8fadcb7..3e31b2dca39 100644
--- a/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/META-INF/MANIFEST.MF
+++ b/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/META-INF/MANIFEST.MF
@@ -28,8 +28,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.emf.facet.infra.facet;bundle-version="0.1.0",
org.eclipse.emf.facet.infra.facet.core;bundle-version="0.1.0",
org.eclipse.emf.facet.infra.query.ui;bundle-version="0.1.0",
- org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0",
- org.eclipse.papyrus.properties
+ org.eclipse.papyrus.ui.toolbox;bundle-version="0.8.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
diff --git a/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/src/org/eclipse/papyrus/modelexplorer/handler/DeleteCommandHandler.java b/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/src/org/eclipse/papyrus/modelexplorer/handler/DeleteCommandHandler.java
index 8a33a74ce5c..ca434c14f73 100644
--- a/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/src/org/eclipse/papyrus/modelexplorer/handler/DeleteCommandHandler.java
+++ b/0.8.X/plugins/core/org.eclipse.papyrus.modelexplorer/src/org/eclipse/papyrus/modelexplorer/handler/DeleteCommandHandler.java
@@ -22,10 +22,14 @@ import org.eclipse.core.commands.IHandler;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-import org.eclipse.papyrus.properties.util.EMFHelper;
import org.eclipse.papyrus.service.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.service.edit.service.IElementEditService;
@@ -114,8 +118,9 @@ public class DeleteCommandHandler extends AbstractCommandHandler implements IHan
List<EObject> selectedElements = getSelectedElements();
for(EObject current : selectedElements) {
- //FIXME EMFHelper should be moved in an utils plugin
- if(EMFHelper.isReadOnly(current)) {
+ //FIXME use the method isReadOnly provided by the class EMFHelper
+ //TODO after the refactoring (currently, there is circular dependencies)
+ if(isReadOnly(current)) {
return false;
}
}
@@ -124,4 +129,60 @@ public class DeleteCommandHandler extends AbstractCommandHandler implements IHan
// it can be WAY too slow...
return true;
}
+
+ /**
+ * Tests if an EObject is read only
+ * Delegates to the EObject's editing domain if it can be found
+ *
+ * @param eObject
+ * @return
+ * True if the EObject is read only
+ */
+ public static boolean isReadOnly(EObject eObject) {
+ EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(eObject);
+ return isReadOnly(eObject, domain);
+ }
+
+ /**
+ * Tests if an EObject is read only
+ * Delegates to the given editing domain if it isn't null
+ *
+ * @param eObject
+ * @param domain
+ * @return
+ * True if the EObject is read only
+ */
+ public static boolean isReadOnly(EObject eObject, EditingDomain domain) {
+ return isReadOnly(eObject.eResource(), domain);
+ }
+
+ /**
+ * Tests if the Resource is read only
+ * Delegates to the given editing domain if it isn't null
+ *
+ * @param resource
+ * @param domain
+ * @return
+ * True if the Resource is read only
+ */
+ public static boolean isReadOnly(Resource resource, EditingDomain domain) {
+ if(domain instanceof AdapterFactoryEditingDomain) {
+ return ((AdapterFactoryEditingDomain)domain).isReadOnly(resource);
+ }
+
+ if(resource == null) {
+ return false;
+ }
+
+ ResourceSet resourceSet = resource.getResourceSet();
+
+ if(resourceSet == null) {
+ return false;
+ }
+
+ Map<String, ?> attributes = resourceSet.getURIConverter().getAttributes(resource.getURI(), null);
+ Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
+
+ return readOnly == null ? false : readOnly;
+ }
}

Back to the top