From b97cafff961eaf540abf031e047b42674b7b68b0 Mon Sep 17 00:00:00 2001 From: Christian W. Damus Date: Thu, 6 Mar 2014 22:51:57 -0500 Subject: 429826: [Read-Only] Orthogonal Classification of Read-Only Concerns https://bugs.eclipse.org/bugs/show_bug.cgi?id=429826 Add classification of orthogonal axes of concern to the API for read-only queries. --- .../profile/ControlledElementReadOnlyHandler.java | 14 +++++++++----- .../profile/readonly/AppliedProfileReadOnlyHandler.java | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'plugins/uml') diff --git a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/ControlledElementReadOnlyHandler.java b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/ControlledElementReadOnlyHandler.java index 78020d006ce..bc0739e861f 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/ControlledElementReadOnlyHandler.java +++ b/plugins/uml/org.eclipse.papyrus.uml.controlmode.profile/src/org/eclipse/papyrus/uml/controlmode/profile/ControlledElementReadOnlyHandler.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2013 Atos. + * Copyright (c) 2013, 2014 Atos, CEA, and others. * * * All rights reserved. This program and the accompanying materials @@ -9,15 +9,19 @@ * * Contributors: * Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation + * Christian W. Damus (CEA) - bug 429826 * *****************************************************************************/ package org.eclipse.papyrus.uml.controlmode.profile; +import java.util.Set; + import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis; import org.eclipse.papyrus.infra.emf.readonly.AbstractReadOnlyHandler; import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder; import org.eclipse.papyrus.uml.tools.model.UmlModel; @@ -30,7 +34,7 @@ import com.google.common.base.Optional; /** * Read only handler that will prevent model fragment to be modified it the root element is not a package * This restriction is because of the UML2 implementation which delete stereotype applications if the current model can not find the corresponding profile - * application + * application. This handler is discretion-based. * * @author adaussy * @@ -41,8 +45,8 @@ public class ControlledElementReadOnlyHandler extends AbstractReadOnlyHandler { super(editingDomain); } - public Optional anyReadOnly(URI[] uris) { - if(getEditingDomain() == null) { + public Optional anyReadOnly(Set axes, URI[] uris) { + if((getEditingDomain() == null) || !axes.contains(ReadOnlyAxis.DISCRETION)) { return Optional.absent(); } ResourceSet resourceSet = getEditingDomain().getResourceSet(); @@ -65,7 +69,7 @@ public class ControlledElementReadOnlyHandler extends AbstractReadOnlyHandler { return Optional.absent(); } - public Optional makeWritable(URI[] uris) { + public Optional makeWritable(Set axes, URI[] uris) { //Never authorize write NotificationBuilder.createErrorPopup("This model fragment can not be modified independently from the rest of the model").run(); return Optional.absent(); diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/readonly/AppliedProfileReadOnlyHandler.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/readonly/AppliedProfileReadOnlyHandler.java index 6c13310f271..f8a78d1e2b2 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/readonly/AppliedProfileReadOnlyHandler.java +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/readonly/AppliedProfileReadOnlyHandler.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2012 CEA LIST. + * Copyright (c) 2012, 2014 CEA LIST and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,28 +8,35 @@ * * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - bug 429826 + * *****************************************************************************/ package org.eclipse.papyrus.uml.profile.readonly; +import java.util.Set; + import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.papyrus.infra.core.resource.ModelSet; +import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis; import org.eclipse.papyrus.infra.emf.readonly.AbstractReadOnlyHandler; import org.eclipse.papyrus.uml.tools.model.UmlModel; import org.eclipse.uml2.uml.Profile; import com.google.common.base.Optional; - +/** + * Discretion-based read-only handler for applied profiles. + */ public class AppliedProfileReadOnlyHandler extends AbstractReadOnlyHandler { public AppliedProfileReadOnlyHandler(EditingDomain editingDomain) { super(editingDomain); } - public Optional anyReadOnly(URI[] uris) { - if(getEditingDomain() != null) { + public Optional anyReadOnly(Set axes, URI[] uris) { + if((getEditingDomain() != null) && axes.contains(ReadOnlyAxis.DISCRETION)) { Resource mainUmlResource = null; if(getEditingDomain().getResourceSet() instanceof ModelSet) { UmlModel umlModel = (UmlModel)((ModelSet)getEditingDomain().getResourceSet()).getModel(UmlModel.MODEL_ID); @@ -62,7 +69,7 @@ public class AppliedProfileReadOnlyHandler extends AbstractReadOnlyHandler { return false; } - public Optional makeWritable(URI[] uris) { + public Optional makeWritable(Set axes, URI[] uris) { return Optional.absent(); //Applied profiles should remain read-only } -- cgit v1.2.3