Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IReadOnlyHandler2.java45
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IRollbackStatus.java41
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/RollbackStatus.java166
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/AbstractReadOnlyHandler.java21
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/FSReadOnlyHandler.java23
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java59
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java38
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyOneFileApprover.java76
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml26
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java288
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java26
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties19
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java135
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java25
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.properties6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.xml2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/schema/historyListeners.exsd91
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/CheckedOperationHistory.java23
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml356
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/listener/RollbackNotificationHistoryListener.java143
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/messages.properties20
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/plugin.xml17
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/internal/ElementEditServiceProvider.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/plugin.xml14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/plugin.xml14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/plugin.xml16
36 files changed, 1660 insertions, 207 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IReadOnlyHandler2.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IReadOnlyHandler2.java
new file mode 100644
index 00000000000..8c266376d1c
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IReadOnlyHandler2.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.core.resource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.common.base.Optional;
+
+
+/**
+ * An optional extension interface for {@linkplain IReadOnlyHandler read-only handlers} that support making files writable.
+ */
+public interface IReadOnlyHandler2 extends IReadOnlyHandler {
+
+ /**
+ * Queries whether I can make the resources indicated by the given URIs writable.
+ *
+ * @param uris
+ * indicate a set of resources (presumed read-only)
+ * @return a {@linkplain Optional#isPresent() present} boolean indicating either that I can make the resources writable or that I handle these
+ * kinds of resources and they cannot be made writable; an {@linkplain Optional#absent() absent} value, otherwise
+ */
+ Optional<Boolean> canMakeWritable(URI[] uris);
+
+ /**
+ * Queries whether I can make the given {@code object} writable.
+ *
+ * @param object
+ * a model element (presumed read-only)
+ * @return a {@linkplain Optional#isPresent() present} boolean indicating either that I can make the {@code object writable or that I handle its
+ * kind of resources and it cannot be made writable; an {@linkplain Optional#absent() absent} value, otherwise
+ */
+ Optional<Boolean> canMakeWritable(EObject object);
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IRollbackStatus.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IRollbackStatus.java
new file mode 100644
index 00000000000..8451f1ce2c6
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/IRollbackStatus.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.core.resource;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IStatus;
+
+
+/**
+ * A specialized status that indicates that execution of a command was rolled back. Additional context that it provides includes model elements that
+ * triggered rollback.
+ */
+public interface IRollbackStatus extends IStatus {
+
+ /** A {@linkplain IStatus#getCode() status code} indicating that the reason for the rollback could not be determined or is otherwise unclassified. */
+ int UNKNOWN_REASON = 0;
+
+ /** A {@linkplain IStatus#getCode() status code} indicating that rollback occurred because of an uncaught exception in command execution. */
+ int UNCAUGHT_EXCEPTION = 1;
+
+ /** A {@linkplain IStatus#getCode() status code} indicating that rollback occurred to revert modifications to an object that is read-only. */
+ int READ_ONLY_OBJECT = 2;
+
+ /**
+ * Queries the set of objects (if known) that caused the rollback, such as because they are are {@linkplain #READ_ONLY_OBJECT read-only}.
+ *
+ * @return the set (possibly empty, but not {@code null}) of objects that caused the rollback
+ */
+ Collection<?> getCausalObjects();
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/RollbackStatus.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/RollbackStatus.java
new file mode 100644
index 00000000000..256de09aa96
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/RollbackStatus.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.core.resource;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.transaction.RollbackException;
+
+import com.google.common.collect.ImmutableSet;
+
+
+/**
+ * An useful default implementation of the {@link IRollbackStatus} interface.
+ * Rollback is always an {@linkplain IStatus#ERROR error} condition, so the constructors do not require the severity.
+ */
+public class RollbackStatus extends Status implements IRollbackStatus {
+
+ private final Set<?> causalObjects;
+
+ /**
+ * Initializes me with the source bundle ID, reason code, and message.
+ *
+ * @param pluginId
+ * the source bundle ID
+ * @param reason
+ * the {@linkplain IRollbackStatus#UNKNOWN_REASON reason code} indicating why rollback occurred
+ * @param message
+ * the human-readable message
+ */
+ public RollbackStatus(String pluginId, int reason, String message) {
+ this(pluginId, reason, message, null, null);
+ }
+
+ /**
+ * Initializes me with the source bundle ID, reason code, and message.
+ *
+ * @param pluginId
+ * the source bundle ID
+ * @param reason
+ * the {@linkplain IRollbackStatus#UNKNOWN_REASON reason code} indicating why rollback occurred
+ * @param message
+ * the human-readable message
+ * @param exception
+ * an exception that somehow caused the rollback to occur
+ */
+ public RollbackStatus(String pluginId, int reason, String message, Throwable exception) {
+ this(pluginId, reason, message, null, exception);
+ }
+
+ /**
+ * Initializes me with the source bundle ID, reason code, and message.
+ *
+ * @param pluginId
+ * the source bundle ID
+ * @param reason
+ * the {@linkplain IRollbackStatus#UNKNOWN_REASON reason code} indicating why rollback occurred
+ * @param message
+ * the human-readable message
+ * @param causalObjects
+ * the objects that caused the rollback (may be {@code null} if not needed)
+ */
+ public RollbackStatus(String pluginId, int reason, String message, Iterable<?> causalObjects) {
+ this(pluginId, reason, message, causalObjects, null);
+ }
+
+ /**
+ * Initializes me with the source bundle ID, reason code, and message.
+ *
+ * @param pluginId
+ * the source bundle ID
+ * @param reason
+ * the {@linkplain IRollbackStatus#UNKNOWN_REASON reason code} indicating why rollback occurred
+ * @param message
+ * the human-readable message
+ * @param causalObjects
+ * the objects that caused the rollback (may be {@code null} if not needed)
+ * @param exception
+ * an exception that somehow caused the rollback to occur
+ */
+ public RollbackStatus(String pluginId, int reason, String message, Iterable<?> causalObjects, Throwable exception) {
+ super(IStatus.ERROR, pluginId, reason, message, exception);
+
+ this.causalObjects = (causalObjects == null) ? Collections.emptySet() : ImmutableSet.copyOf(causalObjects);
+ }
+
+ @Override
+ public Collection<?> getCausalObjects() {
+ return causalObjects;
+ }
+
+ /**
+ * Dig through a possibly {@linkplain #isMultiStatus() multi} status to get a rollback status out of it.
+ *
+ * @param status
+ * a status
+ *
+ * @return the embedded rollback status, if any (which could be the {@code status}, itself, in the simplest case)
+ */
+ public static IRollbackStatus findRollbackStatus(IStatus status) {
+ IRollbackStatus result = null;
+
+ if(status != null) {
+ if(status instanceof IRollbackStatus) {
+ result = (IRollbackStatus)status;
+ } else if(status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for(int i = 0; (result == null) && (i < children.length); i++) {
+ result = findRollbackStatus(children[i]);
+ }
+ }
+
+ if((result == null) && (status.getException() instanceof RollbackException)) {
+ // The RollbackStatus may be rolled up in a generic Status created from the RollbackException that originally carried it
+ result = findRollbackStatus(((RollbackException)status.getException()).getStatus());
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Nested types
+ //
+
+ public static class Multi extends MultiStatus implements IRollbackStatus {
+
+ private IRollbackStatus rollback;
+
+ public Multi(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) {
+ super(pluginId, code, newChildren, message, exception);
+ }
+
+ public Multi(String pluginId, int code, String message, Throwable exception) {
+ super(pluginId, code, message, exception);
+ }
+
+ IRollbackStatus getRollback() {
+ if(rollback == null) {
+ rollback = findRollbackStatus(this);
+ }
+
+ return rollback;
+ }
+
+ @Override
+ public Collection<?> getCausalObjects() {
+ IRollbackStatus rollback = getRollback();
+ return (rollback == null) ? Collections.emptySet() : rollback.getCausalObjects();
+ }
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/AbstractReadOnlyHandler.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/AbstractReadOnlyHandler.java
index 91c9168e20a..e378e43c022 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/AbstractReadOnlyHandler.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/AbstractReadOnlyHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 Atos
+ * Copyright (c) 2013, 2014 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
@@ -17,11 +18,11 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import com.google.common.base.Optional;
-public abstract class AbstractReadOnlyHandler implements IReadOnlyHandler {
+public abstract class AbstractReadOnlyHandler implements IReadOnlyHandler2 {
private EditingDomain editingDomain;
@@ -49,4 +50,18 @@ public abstract class AbstractReadOnlyHandler implements IReadOnlyHandler {
return Optional.absent();
}
+ /**
+ * By default, we do not handle writability of these resources.
+ */
+ public Optional<Boolean> canMakeWritable(URI[] uris) {
+ return Optional.absent();
+ }
+
+ public Optional<Boolean> canMakeWritable(EObject object) {
+ Resource res = object.eResource();
+ if((res != null) && (res.getURI() != null)) {
+ return canMakeWritable(new URI[]{ res.getURI() });
+ }
+ return Optional.absent();
+ }
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/FSReadOnlyHandler.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/FSReadOnlyHandler.java
index 3f8957536bf..49accd2726a 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/FSReadOnlyHandler.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/FSReadOnlyHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 Atos Origin.
+ * Copyright (c) 2011, 2014 Atos Origin, CEA, and otherw.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
@@ -27,7 +28,7 @@ import org.eclipse.swt.widgets.Display;
import com.google.common.base.Optional;
-public class FSReadOnlyHandler extends AbstractReadOnlyHandler {
+public class FSReadOnlyHandler extends AbstractReadOnlyHandler {
public FSReadOnlyHandler(EditingDomain editingDomain) {
super(editingDomain);
@@ -88,4 +89,22 @@ public class FSReadOnlyHandler extends AbstractReadOnlyHandler {
}
}
+ /**
+ * I can make workspace resources writable.
+ */
+ @Override
+ public Optional<Boolean> canMakeWritable(URI[] uris) {
+ Optional<Boolean> result = Optional.absent();
+
+ for(int i = 0; (!result.isPresent() || result.get()) && (i < uris.length); i++) {
+ if(uris[i].isPlatformResource()) {
+ result = Optional.of(true);
+ } else if(uris[i].isFile()) {
+ // We don't make non-workspace (external but local) files writable
+ result = Optional.of(false);
+ }
+ }
+
+ return result;
+ }
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
index 3beab6d2fac..8def957283e 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/PapyrusROTransactionalEditingDomain.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2013 Atos Origin, CEA, and others.
+ * Copyright (c) 2011, 2014 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,17 +10,28 @@
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
* Christian W. Damus (CEA) - Support object-level read/write controls (CDO)
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
+import java.util.Collection;
+import java.util.Collections;
+
import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
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.transaction.NotificationFilter;
+import org.eclipse.emf.transaction.Transaction;
import org.eclipse.emf.transaction.TransactionalCommandStack;
+import org.eclipse.emf.transaction.impl.InternalTransaction;
+import org.eclipse.emf.transaction.impl.TransactionChangeRecorder;
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
+import org.eclipse.papyrus.infra.core.resource.IRollbackStatus;
+import org.eclipse.papyrus.infra.core.resource.RollbackStatus;
public class PapyrusROTransactionalEditingDomain extends TransactionalEditingDomainImpl {
@@ -40,6 +51,52 @@ public class PapyrusROTransactionalEditingDomain extends TransactionalEditingDom
public boolean isReadOnly(EObject eObject) {
return ReadOnlyManager.getReadOnlyHandler(this).isReadOnly(eObject).get();
}
+
+ @Override
+ protected TransactionChangeRecorder createChangeRecorder(ResourceSet rset) {
+ return new TransactionChangeRecorder(this, rset) {
+ @Override
+ protected void appendNotification(Notification notification) {
+ // Append to the transaction first
+ super.appendNotification(notification);
+
+ if (!NotificationFilter.READ.matches(notification)) {
+ // Check whether we are modifying a read-only object
+ assertNotReadOnly(notification.getNotifier());
+ }
+ }
+ };
+ }
+
+ protected void assertNotReadOnly(Object object) {
+ InternalTransaction tx = getActiveTransaction();
+
+ // If there's no transaction, then there will be nothing to roll back. And if it's unprotected, let the client do whatever
+ if((tx != null) && !Boolean.TRUE.equals(tx.getOptions().get(Transaction.OPTION_UNPROTECTED))) {
+ boolean readOnly;
+
+ // Check for Resource first because CDO resources *are* EObjects
+ if(object instanceof Resource) {
+ Resource.Internal resource = (Resource.Internal)object;
+ if(resource.isLoading()) {
+ // We must be able to modify read-only resources in order to load them
+ return;
+ }
+ readOnly = isReadOnly(resource);
+ } else if(object instanceof EObject) {
+ readOnly = isReadOnly((EObject)object);
+ } else {
+ // If it's not an EMF-managed object, we don't care
+ readOnly = false;
+ }
+
+ if(readOnly) {
+ String message = "Attempt to modify object(s) in a read-only model."; //$NON-NLS-1$
+ Collection<?> offenders = Collections.singleton(object);
+ tx.abort(new RollbackStatus(Activator.PLUGIN_ID, IRollbackStatus.READ_ONLY_OBJECT, message, offenders));
+ }
+ }
+ }
@Override
public void dispose() {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
index 779bf21b8f6..47ce49f351b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2013 Atos Origin, CEA, and others.
+ * Copyright (c) 2011, 2014 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
* Christian W. Damus (CEA) - support non-IFile resources and object-level permissions (CDO)
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
@@ -28,12 +29,13 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import com.google.common.base.Optional;
@SuppressWarnings("deprecation")
-public class ReadOnlyManager implements IReadOnlyHandler {
+public class ReadOnlyManager implements IReadOnlyHandler2 {
//Using a WeakHashMap leads to a Memory Leak, because only the Key is weak.
//The IReadOnlyHandler typically has a reference to its editingDomain,
@@ -212,6 +214,38 @@ public class ReadOnlyManager implements IReadOnlyHandler {
return Optional.of(finalResult);
}
+
+ public Optional<Boolean> canMakeWritable(URI[] uris) {
+ Boolean result = false;
+
+ for(int i = 0; (i < orderedHandlersArray.length); i++) {
+ if(orderedHandlersArray[i] instanceof IReadOnlyHandler2) {
+ Optional<Boolean> canMakeWritable = ((IReadOnlyHandler2)orderedHandlersArray[i]).canMakeWritable(uris);
+ if(canMakeWritable.isPresent()) {
+ result = canMakeWritable.get();
+ break;
+ }
+ }
+ }
+
+ return Optional.of(result);
+ }
+
+ public Optional<Boolean> canMakeWritable(EObject object) {
+ Boolean result = false;
+
+ for(int i = 0; (i < orderedHandlersArray.length); i++) {
+ if(orderedHandlersArray[i] instanceof IReadOnlyHandler2) {
+ Optional<Boolean> canMakeWritable = ((IReadOnlyHandler2)orderedHandlersArray[i]).canMakeWritable(object);
+ if(canMakeWritable.isPresent()) {
+ result = canMakeWritable.get();
+ break;
+ }
+ }
+ }
+
+ return Optional.of(result);
+ }
private static final class HandlerAdapter extends AbstractReadOnlyHandler {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyOneFileApprover.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyOneFileApprover.java
index b65196de99d..03a5388e717 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyOneFileApprover.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyOneFileApprover.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 Atos Origin.
+ * Copyright (c) 2011, 2014 Atos Origin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,14 +9,17 @@
*
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
+import java.util.Set;
import org.eclipse.core.commands.operations.IOperationApprover2;
import org.eclipse.core.commands.operations.IOperationHistory;
@@ -26,13 +29,17 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.workspace.AbstractEMFOperation;
+import org.eclipse.emf.workspace.EMFCommandOperation;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
import org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile;
import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper;
import org.eclipse.papyrus.infra.onefile.utils.OneFileUtils;
@@ -52,10 +59,9 @@ public class ReadOnlyOneFileApprover implements IOperationApprover2 {
public IStatus proceedExecuting(IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
HashSet<URI> filesToCheckForLock = new HashSet<URI>();
- if(operation instanceof ICommand) {
- ICommand command = (ICommand)operation;
- List<IFile> affectedFiles = command.getAffectedFiles();
-
+ Set<IFile> affectedFiles = getAffectedFiles(operation);
+
+ if(!affectedFiles.isEmpty()) {
for(IFile affectedFile : affectedFiles) {
if(affectedFile == null)
continue;
@@ -71,14 +77,18 @@ public class ReadOnlyOneFileApprover implements IOperationApprover2 {
IPath path = affectedFile.getRawLocation();
if(path == null) {
// cancel if we can't find the file
- setCommandResult(command, Status.CANCEL_STATUS);
+ if(operation instanceof ICommand) {
+ setCommandResult((ICommand)operation, Status.CANCEL_STATUS);
+ }
return Status.CANCEL_STATUS;
}
File file = path.toFile();
if(file != null && file.exists() && !file.canWrite()) {
// cancel if we find a read-only file outside the
// workspace
- setCommandResult(command, Status.CANCEL_STATUS);
+ if(operation instanceof ICommand) {
+ setCommandResult((ICommand)operation, Status.CANCEL_STATUS);
+ }
return Status.CANCEL_STATUS;
}
}
@@ -130,4 +140,54 @@ public class ReadOnlyOneFileApprover implements IOperationApprover2 {
}
}
+ protected Set<IFile> getAffectedFiles(IUndoableOperation operation) {
+ Set<IFile> result = getAffectedFiles(operation, null);
+ return (result == null) ? Collections.<IFile> emptySet() : result;
+ }
+
+ protected Set<IFile> getAffectedFiles(IUndoableOperation operation, Set<IFile> result) {
+ if(operation instanceof ICommand) {
+ result = appendFiles(result, ((ICommand)operation).getAffectedFiles());
+ } else if(operation instanceof GMFtoEMFCommandWrapper) {
+ result = getAffectedFiles(((GMFtoEMFCommandWrapper)operation).getGMFCommand(), result);
+ } else if(operation instanceof EMFCommandOperation) {
+ result = getAffectedFiles(((EMFCommandOperation)operation).getCommand(), result);
+ }
+
+ return result;
+ }
+
+ private Set<IFile> appendFiles(Set<IFile> result, Collection<IFile> files) {
+ if((files != null) && !files.isEmpty()) {
+ if(result == null) {
+ result = new HashSet<IFile>(files);
+ } else {
+ result.addAll(files);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Dig into an EMF command to find wrapped GMF commands and get their affected files. As commands are generally provided by GMF edit-helpers, this
+ * should turn up useful results.
+ *
+ * @param command
+ * a command to mine for affected files
+ * @param result
+ * an accumulator of affected files
+ * @return the {@code result} if it already exists, a non-empty set containing affected files, or {@code null}
+ */
+ protected Set<IFile> getAffectedFiles(Command command, Set<IFile> result) {
+ if(command instanceof CompoundCommand) {
+ for(Command next : ((CompoundCommand)command).getCommandList()) {
+ // accumulate affected files
+ result = getAffectedFiles(next, result);
+ }
+ } else if(command instanceof GMFtoEMFCommandWrapper) {
+ result = getAffectedFiles(((GMFtoEMFCommandWrapper)command).getGMFCommand(), result);
+ }
+
+ return result;
+ }
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
index d9b6cb0f5d1..201411fb724 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2012, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension
point="org.eclipse.papyrus.infra.core.service">
@@ -17,6 +30,10 @@
<extension
point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
<labelProvider
+ priority="110"
+ provider="org.eclipse.papyrus.infra.emf.providers.ResourceFilteredLabelProvider">
+ </labelProvider>
+ <labelProvider
priority="100"
provider="org.eclipse.papyrus.infra.emf.providers.EMFFilteredLabelProvider">
</labelProvider>
@@ -41,6 +58,15 @@
id="org.eclipse.papyrus.infra.emf.page">
</metamodelType>
</metamodel>
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ <adviceBinding
+ id="org.eclipse.papyrus.infra.emf.readOnlyAdvice"
+ class="org.eclipse.papyrus.infra.emf.advice.ReadOnlyObjectEditAdvice"
+ typeId="*"
+ inheritance="none">
+ </adviceBinding>
+ </metamodel>
</extension>
<extension
point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java
new file mode 100644
index 00000000000..4756c1ee264
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.emf.advice;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+
+
+/**
+ * Advice that vetoes edits that would modify objects that are read-only and could not reasonably be made writable.
+ */
+public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
+
+ public ReadOnlyObjectEditAdvice() {
+ super();
+ }
+
+ protected boolean isUneditable(IEditCommandRequest request, EObject object) {
+ boolean result = false;
+
+ EditingDomain domain = request.getEditingDomain();
+ if(EMFHelper.isReadOnly(object, domain)) {
+ // Check whether we have some means of making it writable
+ result = !EMFHelper.canMakeWritable(object, domain);
+ }
+
+ return result;
+ }
+
+ protected ICommand getRefusal() {
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ @Override
+ protected ICommand getBeforeCreateCommand(CreateElementRequest request) {
+ EObject container = request.getContainer();
+
+ if((container != null) && isUneditable(request, container)) {
+ return getRefusal();
+ }
+
+ return super.getBeforeCreateCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
+ EObject container = request.getContainer();
+
+ if((container != null) && isUneditable(request, container)) {
+ return getRefusal();
+ }
+
+ if(isUneditable(request, request.getSource())) {
+ return getRefusal();
+ }
+ // Assume that the target (as in most cases) will not have an inverse reference to the new relationship
+
+ return super.getBeforeCreateRelationshipCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeDestroyElementCommand(DestroyElementRequest request) {
+ EObject container = request.getContainer();
+
+ if((container != null) && isUneditable(request, container)) {
+ return getRefusal();
+ }
+ // Cross-resource containment to a read-only resource? Unlikely. Don't need to look at the object-to-be-destroyed
+
+ return super.getBeforeDestroyElementCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeDestroyReferenceCommand(DestroyReferenceRequest request) {
+ EObject container = request.getContainer();
+
+ // Simple case is when the owner object is read-only
+ if((container != null) && isUneditable(request, container)) {
+ return getRefusal();
+ }
+
+ // Handle the case where the reference has an opposite
+ EReference ref = request.getContainingFeature();
+ if(ref.getEOpposite() != null) {
+ // The object being removed will have its inverse reference removed, also
+ EObject referenced = request.getReferencedObject();
+ if((referenced != null) && isUneditable(request, referenced)) {
+ return getRefusal();
+ }
+ }
+
+ return super.getBeforeDestroyReferenceCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeDuplicateCommand(DuplicateElementsRequest request) {
+ List<?> elements = request.getElementsToBeDuplicated();
+
+ // Elements are duplicated in their containers, so the container must not be read-only
+ for(EObject next : Iterables.filter(elements, EObject.class)) {
+ EObject container = next.eContainer();
+ if((container != null) && isUneditable(request, container)) {
+ return getRefusal();
+ }
+ }
+
+ return super.getBeforeDuplicateCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeMoveCommand(MoveRequest request) {
+ // Is any of the former containers read-only?
+ for(EObject next : Iterables.filter(request.getElementsToMove().keySet(), EObject.class)) {
+ EObject container = next.eContainer();
+
+ if((container != null) && isUneditable(request, container)) {
+ System.out.printf("Container not writable: %s%n", container);
+ return getRefusal();
+ }
+ }
+
+ if(isUneditable(request, request.getTargetContainer())) {
+ return getRefusal();
+ }
+
+ return super.getBeforeMoveCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeReorientRelationshipCommand(ReorientRelationshipRequest request) {
+ EObject relationship = request.getRelationship();
+
+ // Simple case is when the owner object is read-only
+ if((relationship != null) && isUneditable(request, relationship)) {
+ return getRefusal();
+ }
+
+ // Assume that changing the target would not affect the target object because it would not have an inverse reference
+ if(request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
+ if(isUneditable(request, request.getOldRelationshipEnd())) {
+ return getRefusal();
+ }
+ if(isUneditable(request, request.getNewRelationshipEnd())) {
+ return getRefusal();
+ }
+ }
+
+ return super.getBeforeReorientRelationshipCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest request) {
+ EObject owner = request.getReferenceOwner();
+
+ // Simple case is when the owner object is read-only
+ if((owner != null) && isUneditable(request, owner)) {
+ return getRefusal();
+ }
+
+ // Assume that changing the target would not affect the target object because it would not have an inverse reference
+ if(request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
+ if(isUneditable(request, request.getOldRelationshipEnd())) {
+ return getRefusal();
+ }
+ if(isUneditable(request, request.getNewRelationshipEnd())) {
+ return getRefusal();
+ }
+ }
+
+ return super.getBeforeReorientReferenceRelationshipCommand(request);
+ }
+
+ @Override
+ protected ICommand getBeforeSetCommand(SetRequest request) {
+ // Simple case of read-only element
+ if(isUneditable(request, request.getElementToEdit())) {
+ return getRefusal();
+ }
+
+ if(request.getFeature() instanceof EReference) {
+ EReference ref = (EReference)request.getFeature();
+ if(ref.getEOpposite() != null) {
+ // Objects on the opposite end must not be read-only
+ Collection<EObject> affectedOpposites = getAffectedOpposites(request.getElementToEdit(), ref, request.getValue());
+ if(!affectedOpposites.isEmpty()) {
+ for(EObject next : affectedOpposites) {
+ if(isUneditable(request, next)) {
+ return getRefusal();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Obtains the objects that will be changed by means of the opposite "handshaking" of the given reference of a {@code source} object getting a new
+ * value.
+ */
+ protected Collection<EObject> getAffectedOpposites(EObject source, EReference refWithOpposite, Object newValue) {
+ Collection<EObject> result;
+
+ if(refWithOpposite.isMany()) {
+ if((newValue == null) || ((newValue instanceof Collection<?>) && ((Collection<?>)newValue).isEmpty())) {
+ // Removing all current references (and, hence, their inverses)
+ result = getReferencedObjects(source, refWithOpposite);
+ } else {
+ // The symmetric difference of currently- and to-be-referenced objects will change
+ Set<EObject> current = Sets.newHashSet(getReferencedObjects(source, refWithOpposite));
+ Set<EObject> future = (newValue instanceof Collection<?>) ? ImmutableSet.copyOf(Iterables.filter((Collection<?>)newValue, EObject.class)) : Collections.singleton((EObject)newValue);
+ result = ImmutableList.copyOf(Sets.symmetricDifference(current, future));
+ }
+ } else {
+ Object current = source.eGet(refWithOpposite);
+ if(current != newValue) {
+ // The current value will lose its inverse reference and the new value will gain one
+ if(current == null) {
+ result = Collections.singletonList((EObject)newValue);
+ } else if(newValue == null) {
+ result = Collections.singleton((EObject)current);
+ } else {
+ result = ImmutableList.of((EObject)current, (EObject)newValue);
+ }
+ } else {
+ // No objects will change
+ result = Collections.emptyList();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Obtains the objects referenced by a {@code source} object via a particular {@code reference}.
+ */
+ private Collection<EObject> getReferencedObjects(EObject source, EReference reference) {
+ Collection<EObject> result;
+
+ Object current = source.eGet(reference);
+ if(current instanceof Collection<?>) {
+ result = ImmutableList.copyOf(Iterables.filter((Collection<?>)current, EObject.class));
+ } else if(current != null) {
+ result = Collections.singletonList((EObject)current);
+ } else {
+ result = Collections.emptyList();
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
index 04d8fa9b5a0..77ff3cbd56b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
@@ -1,3 +1,16 @@
+/*
+ * Copyright (c) 2012, 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
+ */
package org.eclipse.papyrus.infra.emf.messages;
import org.eclipse.osgi.util.NLS;
@@ -6,7 +19,20 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.emf.messages.messages"; //$NON-NLS-1$
+ public static String ResourceFilteredLabelProvider_local;
+
+ public static String ResourceFilteredLabelProvider_localExt;
+
+ public static String ResourceFilteredLabelProvider_system;
+
+ public static String ResourceFilteredLabelProvider_systemExt;
+
+ public static String ResourceFilteredLabelProvider_workspace;
+
+ public static String ResourceFilteredLabelProvider_workspaceExt;
+
public static String UnsetCommand_UnsetCommand;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties
index b5119e19f07..7a50929b818 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties
@@ -1 +1,20 @@
+#
+# Copyright (c) 2012, 2014 CEA and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Vincent Lorenzo (CEA LIST) - Initial API and implementation
+# Christian W. Damus (CEA) - bug 323802
+#
+
+ResourceFilteredLabelProvider_local=Local model file "{0}"
+ResourceFilteredLabelProvider_localExt=Local model file "{0}" ({1} component)
+ResourceFilteredLabelProvider_system=System resource "{0}"
+ResourceFilteredLabelProvider_systemExt=Resource "{0}"
+ResourceFilteredLabelProvider_workspace=Workspace model file "{0}"
+ResourceFilteredLabelProvider_workspaceExt=Workspace model file "{0}" ({1} component)
UnsetCommand_UnsetCommand=Unset Command
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java
new file mode 100644
index 00000000000..b776f51de5a
--- /dev/null
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.emf.providers;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ContentHandler;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.emf.messages.Messages;
+import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * A label provider for EMF {@link Resource}s.
+ */
+public class ResourceFilteredLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
+
+ private ResourceManager images;
+
+ public boolean accept(Object element) {
+ return element instanceof Resource;
+ }
+
+ @Override
+ public void dispose() {
+ if(images != null) {
+ images.dispose();
+ images = null;
+ }
+
+ super.dispose();
+ }
+
+ @Override
+ public String getText(Object element) {
+ return (element instanceof Resource) ? getText((Resource)element) : super.getText(element);
+ }
+
+ protected String getText(Resource resource) {
+ String result;
+
+ URI uri = resource.getURI();
+
+ if(uri.isPlatformResource()) {
+ String ext = uri.fileExtension();
+ if(ext == null) {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_workspace, uri.toPlatformString(true));
+ } else {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_workspaceExt, uri.toPlatformString(true), uri.fileExtension());
+ }
+ } else if(uri.isFile()) {
+ String ext = uri.fileExtension();
+ if(ext == null) {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_local, uri.toFileString());
+ } else {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_localExt, uri.toFileString(), uri.fileExtension());
+ }
+ } else if(uri.isHierarchical()) {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_system, uri.lastSegment());
+ } else {
+ result = NLS.bind(Messages.ResourceFilteredLabelProvider_systemExt, uri.toString());
+ }
+
+ return result;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return (element instanceof Resource) ? getImage((Resource)element) : super.getImage(element);
+ }
+
+ protected Image getImage(Resource resource) {
+ URI uri = resource.getURI();
+ URIConverter converter = (resource.getResourceSet() == null) ? URIConverter.INSTANCE : resource.getResourceSet().getURIConverter();
+
+ IContentType contentType = null;
+ try {
+ Map<String, ?> description = converter.contentDescription(uri, null);
+ contentType = (description.get(ContentHandler.CONTENT_TYPE_PROPERTY) == null) ? null : Platform.getContentTypeManager().getContentType((String)description.get(ContentHandler.CONTENT_TYPE_PROPERTY));
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+
+ IEditorDescriptor[] editors;
+ if(contentType != null) {
+ editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(uri.lastSegment(), contentType);
+ } else {
+ editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(uri.lastSegment());
+ }
+
+ ImageDescriptor result = null;
+ for(int i = 0; (result == null) && (i < editors.length); i++) {
+ result = editors[0].getImageDescriptor();
+ }
+
+ return convert(result);
+ }
+
+ protected Image convert(ImageDescriptor descriptor) {
+ Image result = null;
+
+ if(descriptor != null) {
+ if(images == null) {
+ images = new LocalResourceManager(JFaceResources.getResources());
+ }
+
+ result = (Image)images.get(descriptor);
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index bdcc1864b2e..594b111e94d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2013 CEA LIST.
+ * Copyright (c) 2010, 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
@@ -10,6 +10,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - filter out EObjects that are Resources (CDO)
* Christian W. Damus (CEA) - Support read-only state at object level (CDO)
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -46,6 +47,7 @@ import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.facet.custom.ui.CustomizedContentProviderUtils;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
+import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
import org.eclipse.papyrus.infra.emf.Activator;
@@ -500,6 +502,27 @@ public class EMFHelper {
}
/**
+ * Tests if an object that is read only could possibly be made writable by some means (file system attributes, team provider hook, database
+ * permissions, etc.)
+ *
+ * @param eObject
+ * an object that is assumed to be read-only
+ * @param domain
+ * the editing domain context of the {@link eObject}
+ * @return
+ * whether the {@code eObject} could be made writable
+ */
+ public static boolean canMakeWritable(final EObject eObject, final EditingDomain domain) {
+ if(domain != null) {
+ Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
+ if(handler instanceof IReadOnlyHandler2) {
+ return ((IReadOnlyHandler2)handler).canMakeWritable(eObject).or(false);
+ }
+ }
+ return false;
+ }
+
+ /**
* Tests if the given EStructuralFeature is required (ie. should always
* have a value)
*
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.properties
index 7b616a5ac05..7324564d6df 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.properties
@@ -1,5 +1,5 @@
#################################################################################
-# Copyright (c) 2011 Atos.
+# Copyright (c) 2011, 2014 Atos, CEA, and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -7,6 +7,10 @@
#
# Contributors:
# Vincent Hemery - Initial API and implementation
+# Christian W. Damus (CEA) - bug 323802
+#
##################################################################################
pluginName=Papyrus Commands Tools (Incubation)
providerName=Eclipse Modeling Project
+
+historyListeners-extpt=Operation History Listeners
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.xml
index f8f60be4ccb..98f0fc190ef 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/plugin.xml
@@ -2,6 +2,8 @@
<?eclipse version="3.4"?>
<plugin>
<extension-point id="operationApprover" name="operationApprover" schema="schema/operationApprover.exsd"/>
+ <extension-point id="historyListeners" name="%historyListeners-extpt" schema="schema/historyListeners.exsd"/>
+
<extension
point="org.eclipse.ui.handlers">
<handler
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/schema/historyListeners.exsd b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/schema/historyListeners.exsd
new file mode 100644
index 00000000000..16f042831a6
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/schema/historyListeners.exsd
@@ -0,0 +1,91 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.gmfdiag.commands" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.gmfdiag.commands" id="historyListeners" name="historyListeners"/>
+ </appinfo>
+ <documentation>
+ Registration of history listeners to be attached to the operation history used by the Papyrus GMF diagrams (and transactional editing domains in general).
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="historyListener" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="historyListener">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The Java class implementing of the history listener.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.core.commands.operations.IOperationHistoryListener"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ 1.0
+ </documentation>
+ </annotation>
+
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2014 CEA and others.
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/CheckedOperationHistory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/CheckedOperationHistory.java
index 5973347c169..179be3fdc44 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/CheckedOperationHistory.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/CheckedOperationHistory.java
@@ -9,7 +9,7 @@
*
* Contributors:
* Mathieu Velten (Atos) - Initial API and implementation
- * Christian W. Damus (CEA) - bug 357250
+ * Christian W. Damus (CEA) - bug 357250, bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.commands;
@@ -80,8 +80,8 @@ public class CheckedOperationHistory implements IOperationHistory {
if("operationApprover".equals(elem.getName())) { //$NON-NLS-1$
try {
ApproverPriorityPair approverPriorityPair = new ApproverPriorityPair();
- approverPriorityPair.approver = (IOperationApprover2)elem.createExecutableExtension("class");
- approverPriorityPair.priority = Integer.parseInt(elem.getAttribute("priority"));
+ approverPriorityPair.approver = (IOperationApprover2)elem.createExecutableExtension("class"); //$NON-NLS-1$
+ approverPriorityPair.priority = Integer.parseInt(elem.getAttribute("priority")); //$NON-NLS-1$
approverPriorityPairs.add(approverPriorityPair);
} catch (Exception e) {
@@ -101,6 +101,8 @@ public class CheckedOperationHistory implements IOperationHistory {
private CheckedOperationHistory() {
history = OperationHistoryFactory.getOperationHistory();
+
+ addRegisteredListeners(history);
}
/*
@@ -218,6 +220,21 @@ public class CheckedOperationHistory implements IOperationHistory {
return history.redo(context, monitor, info);
}
+ private static void addRegisteredListeners(IOperationHistory history) {
+ IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, "historyListeners"); //$NON-NLS-1$
+
+ for(IConfigurationElement elem : configElements) {
+ if("historyListener".equals(elem.getName())) { //$NON-NLS-1$
+ try {
+ IOperationHistoryListener listener = (IOperationHistoryListener)elem.createExecutableExtension("class"); //$NON-NLS-1$
+ history.addOperationHistoryListener(listener);
+ } catch (Exception e) {
+ Activator.log.error("Uncaught exception in instantiation of operation history listener.", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
// all the following methods are pure delegation
public IStatus undoOperation(IUndoableOperation operation, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index 7021ed3753b..ac6c78cbdbf 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -1,179 +1,179 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+
+<plugin>
+ <extension-point id="nestedEditor" name="NestedEditor" schema="schema/nestedEditor.exsd"/>
+ <extension-point id="initializeView" name="initializeView" schema="schema/initializeView.exsd"/>
+ <extension-point id="shapeProvider" name="ShapeProvider" schema="schema/shapeProvider.exsd"/>
+ <extension-point id="notationTypesMapping" name="notationTypesMapping" schema="schema/notationTypesMapping.exsd"/>
+ <extension-point id="svgPostProcessors" name="svgPostProcessors" schema="schema/svgPostProcessors.exsd"/>
+ <extension-point id="pasteCommandProvider" name="pasteCommandProvider" schema="schema/pasteCommandProvider.exsd"/>
-<plugin>
- <extension-point id="nestedEditor" name="NestedEditor" schema="schema/nestedEditor.exsd"/>
- <extension-point id="initializeView" name="initializeView" schema="schema/initializeView.exsd"/>
- <extension-point id="shapeProvider" name="ShapeProvider" schema="schema/shapeProvider.exsd"/>
- <extension-point id="notationTypesMapping" name="notationTypesMapping" schema="schema/notationTypesMapping.exsd"/>
- <extension-point id="svgPostProcessors" name="svgPostProcessors" schema="schema/svgPostProcessors.exsd"/>
- <extension-point id="pasteCommandProvider" name="pasteCommandProvider" schema="schema/pasteCommandProvider.exsd"/>
-
-<extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.papyrus.infra.gmfdiag.common.handler.RefreshHandler"
- commandId="org.eclipse.ui.file.refresh">
- <activeWhen>
- <with
- variable="activePartId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </activeWhen>
- </handler>
-</extension>
-<extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="toolbar:org.eclipes.papyrus.menu.toolbar">
- <command
- commandId="org.eclipse.ui.file.refresh"
- icon="icons/refresh.gif"
- label="Refresh"
- style="push"
- tooltip="Refresh the current diagram">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
-</extension>
-<extension
- point="org.eclipse.ui.preferencePages">
- <page
- category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
- class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferencePage"
- id="org.eclipse.papyrus.infra.gmfdiag.common.connectionTools"
- name="Connection Tools">
- </page>
-</extension>
-<extension
- point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferenceInitializer">
- </initializer>
-</extension>
- <extension
- point="org.eclipse.papyrus.infra.core.model">
- <model
- classname="org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel"
- description="Model for notation">
- </model>
- </extension>
-
-
- <extension
- point="org.eclipse.emf.ecore.extension_parser">
- <parser
- class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory"
- type="notation">
- </parser>
- </extension>
-<extension
- point="org.eclipse.papyrus.infra.core.service">
- <serviceFactory
- classname="org.eclipse.papyrus.infra.gmfdiag.common.undocontext.UndoContextServiceFactory"
- description="The shared IUndoContext used to tag command in the CommandStack"
- id="org.eclipse.core.commands.operations.IUndoContext"
- priority="1"
- startKind="lazy">
- <dependsOn
- serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
- </dependsOn>
- </serviceFactory>
- <service
- classname="org.eclipse.papyrus.infra.gmfdiag.common.DefaultGraphicalEditorSupport"
- description="The default diagram editor support implementation."
- id="org.eclipse.papyrus.infra.gmfdiag.common.IGraphicalEditorSupport"
- priority="1"
- startKind="lazy">
- </service>
- </extension>
-<extension
- point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
- <labelProvider
- priority="40"
- provider="org.eclipse.papyrus.infra.gmfdiag.common.providers.NotationFilteredLabelProvider">
- </labelProvider>
-</extension>
-<extension
- point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
- <decoratorProvider
- class="org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecoratorProvider">
- <Priority
- name="Lowest">
- </Priority>
- </decoratorProvider>
-</extension>
-<extension
- point="org.eclipse.core.runtime.adapters">
- <factory
- adaptableType="org.eclipse.gmf.runtime.notation.Diagram"
- class="org.eclipse.papyrus.infra.gmfdiag.common.adapter.DiagramAdapterFactory">
- <adapter
- type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
- </adapter>
- </factory>
-</extension>
-
-<!-- ElementType bindings for diagram duplication with paste command -->
- <extension
- point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
- <metamodel
- nsURI="http://www.eclipse.org/emf/2002/Ecore">
- <adviceBinding
- class="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
- id="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
- inheritance="none"
- typeId="*">
- </adviceBinding>
- </metamodel>
- </extension>
-
-<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
-
- <!-- Bindings declaration -->
- <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
- <advice ref="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice" />
- </binding>
-</extension>
-<extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
- id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
- namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
- properties="isDiagramEditor"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- <propertyTester
- class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
- id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
- namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
- properties="isGmfDiagramContextActive"
- type="java.util.Collection">
+<extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.papyrus.infra.gmfdiag.common.handler.RefreshHandler"
+ commandId="org.eclipse.ui.file.refresh">
+ <activeWhen>
+ <with
+ variable="activePartId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </activeWhen>
+ </handler>
+</extension>
+<extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="toolbar:org.eclipes.papyrus.menu.toolbar">
+ <command
+ commandId="org.eclipse.ui.file.refresh"
+ icon="icons/refresh.gif"
+ label="Refresh"
+ style="push"
+ tooltip="Refresh the current diagram">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+</extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferencePage"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.connectionTools"
+ name="Connection Tools">
+ </page>
+</extension>
+<extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferenceInitializer">
+ </initializer>
+</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.core.model">
+ <model
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel"
+ description="Model for notation">
+ </model>
+ </extension>
+
+
+ <extension
+ point="org.eclipse.emf.ecore.extension_parser">
+ <parser
+ class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory"
+ type="notation">
+ </parser>
+ </extension>
+<extension
+ point="org.eclipse.papyrus.infra.core.service">
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.undocontext.UndoContextServiceFactory"
+ description="The shared IUndoContext used to tag command in the CommandStack"
+ id="org.eclipse.core.commands.operations.IUndoContext"
+ priority="1"
+ startKind="lazy">
+ <dependsOn
+ serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
+ </dependsOn>
+ </serviceFactory>
+ <service
+ classname="org.eclipse.papyrus.infra.gmfdiag.common.DefaultGraphicalEditorSupport"
+ description="The default diagram editor support implementation."
+ id="org.eclipse.papyrus.infra.gmfdiag.common.IGraphicalEditorSupport"
+ priority="1"
+ startKind="lazy">
+ </service>
+ </extension>
+<extension
+ point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
+ <labelProvider
+ priority="40"
+ provider="org.eclipse.papyrus.infra.gmfdiag.common.providers.NotationFilteredLabelProvider">
+ </labelProvider>
+</extension>
+<extension
+ point="org.eclipse.gmf.runtime.diagram.ui.decoratorProviders">
+ <decoratorProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecoratorProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ </decoratorProvider>
+</extension>
+<extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.gmf.runtime.notation.Diagram"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.adapter.DiagramAdapterFactory">
+ <adapter
+ type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
+ </adapter>
+ </factory>
+</extension>
+
+<!-- ElementType bindings for diagram duplication with paste command -->
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ <adviceBinding
+ class="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice"
+ inheritance="none"
+ typeId="*">
+ </adviceBinding>
+ </metamodel>
+ </extension>
+
+<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+
+ <!-- Bindings declaration -->
+ <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+ <advice ref="org.eclipse.papyrus.infra.gmfdiag.common.advice.GMFDiagramDuplicateEditHelperAdvice" />
+ </binding>
+</extension>
+<extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
+ namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.tester"
+ properties="isDiagramEditor"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramPropertyTester"
+ id="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
+ namespace="org.eclipse.papyrus.infra.gmfdiag.common.diagram.context.tester"
+ properties="isGmfDiagramContextActive"
+ type="java.util.Collection">
</propertyTester>
-</extension>
-<extension
- point="org.eclipse.papyrus.infra.gmfdiag.common.shapeProvider">
- <shapeProvider
- class="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
- description="Provides shapes based on the applied styles."
- id="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
- name="StyleBasedShapeProvider">
- <Priority
- name="Low"></Priority>
- </shapeProvider>
-</extension>
+</extension>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.shapeProvider">
+ <shapeProvider
+ class="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
+ description="Provides shapes based on the applied styles."
+ id="org.eclipse.papyrus.infra.gmfdiag.common.providers.StyleBasedShapeProvider"
+ name="StyleBasedShapeProvider">
+ <Priority
+ name="Low"></Priority>
+ </shapeProvider>
+</extension>
<extension
point="org.eclipse.papyrus.infra.gmfdiag.common.notationTypesMapping">
<mapping
@@ -181,4 +181,10 @@
type="compartment_shape_display">
</mapping>
</extension>
-</plugin>
+<extension
+ point="org.eclipse.papyrus.infra.gmfdiag.commands.historyListeners">
+ <historyListener
+ class="org.eclipse.papyrus.infra.gmfdiag.common.listener.RollbackNotificationHistoryListener">
+ </historyListener>
+</extension>
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/listener/RollbackNotificationHistoryListener.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/listener/RollbackNotificationHistoryListener.java
new file mode 100644
index 00000000000..b14056758e8
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/listener/RollbackNotificationHistoryListener.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.gmfdiag.common.listener;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.commands.operations.IOperationHistoryListener;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.OperationHistoryEvent;
+import org.eclipse.core.commands.operations.TriggeredOperations;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.core.resource.IRollbackStatus;
+import org.eclipse.papyrus.infra.core.resource.RollbackStatus;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
+import org.eclipse.papyrus.infra.gmfdiag.common.messages.Messages;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.ui.statushandlers.IStatusAdapterConstants;
+import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+
+/**
+ * An operation history listener that detects execution failures due to transaction rollback and presents dialogs to explain.
+ */
+public class RollbackNotificationHistoryListener implements IOperationHistoryListener {
+
+ public RollbackNotificationHistoryListener() {
+ super();
+ }
+
+ public void historyNotification(OperationHistoryEvent event) {
+ switch(event.getEventType()) {
+ case OperationHistoryEvent.OPERATION_NOT_OK:
+ final long now = System.currentTimeMillis();
+
+ IRollbackStatus rollback = RollbackStatus.findRollbackStatus(event.getStatus());
+ if(rollback == null) {
+ // Failure of a TriggeredOperations results in an event without a status
+ rollback = findRollbackStatus(event.getOperation());
+ }
+
+ if(rollback != null) {
+ Collection<?> causalObjects = rollback.getCausalObjects();
+ Collection<String> labels = getObjectLabels(causalObjects);
+
+ String message;
+ switch(rollback.getCode()) {
+ case IRollbackStatus.UNCAUGHT_EXCEPTION:
+ message = labels.isEmpty() ? Messages.RollbackNotificationHistoryListener_exception : NLS.bind(Messages.RollbackNotificationHistoryListener_exceptionWithCause, labels);
+ break;
+ case IRollbackStatus.READ_ONLY_OBJECT:
+ message = labels.isEmpty() ? Messages.RollbackNotificationHistoryListener_readOnly : NLS.bind(Messages.RollbackNotificationHistoryListener_readOnlyWithCause, labels);
+ break;
+ default:
+ message = labels.isEmpty() ? Messages.RollbackNotificationHistoryListener_unknown : NLS.bind(Messages.RollbackNotificationHistoryListener_unknownWithCause, labels);
+ break;
+ }
+
+ // Eclipse doesn't seem to use the status adapter explanation property, so we must create a new status with our message
+ StatusAdapter adapter = new StatusAdapter(new Status(rollback.getSeverity(), rollback.getPlugin(), rollback.getCode(), message, rollback.getException()));
+ adapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, Messages.RollbackNotificationHistoryListener_title);
+ adapter.setProperty(IStatusAdapterConstants.TIMESTAMP_PROPERTY, now);
+
+ StatusManager.getManager().handle(adapter, StatusManager.SHOW);
+ }
+ break;
+ }
+ }
+
+ protected List<String> getObjectLabels(Iterable<?> objects) {
+ List<String> result = new ArrayList<String>();
+ ILabelProvider labels = null;
+
+ try {
+ for(Object next : objects) {
+ if(labels == null) {
+ try {
+ LabelProviderService labelService = null;
+ if(next instanceof EObject) {
+ labelService = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, (EObject)next);
+ } else if(next instanceof Resource) {
+ labelService = ServiceUtilsForResource.getInstance().getService(LabelProviderService.class, (Resource)next);
+ }
+
+ if(labelService != null) {
+ labels = labelService.getLabelProvider();
+ }
+ } catch (ServiceException e) {
+ // not in an editor context. Fine
+ labels = new EMFLabelProvider();
+ }
+ }
+
+ if(labels != null) {
+ result.add(labels.getText(next));
+ }
+ }
+ } finally {
+ if(labels != null) {
+ labels.dispose();
+ }
+ }
+
+ return result;
+ }
+
+ protected IRollbackStatus findRollbackStatus(IUndoableOperation operation) {
+ IRollbackStatus result = null;
+
+ if(operation instanceof ICommand) {
+ CommandResult commandResult = ((ICommand)operation).getCommandResult();
+ if(commandResult != null) {
+ result = RollbackStatus.findRollbackStatus(commandResult.getStatus());
+ }
+ } else if(operation instanceof TriggeredOperations) {
+ // We can't get the children out of a generic ICompositeOperation, and from this one only the initial triggering operation
+ return findRollbackStatus(((TriggeredOperations)operation).getTriggeringOperation());
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java
index 0843a4eafb7..80509fc4975 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/Messages.java
@@ -1,3 +1,16 @@
+/*
+ * Copyright (c) 2013, 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
+ */
package org.eclipse.papyrus.infra.gmfdiag.common.messages;
import org.eclipse.osgi.util.NLS;
@@ -6,11 +19,26 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.common.messages.messages"; //$NON-NLS-1$
+ public static String RollbackNotificationHistoryListener_exception;
+
+ public static String RollbackNotificationHistoryListener_exceptionWithCause;
+
+ public static String RollbackNotificationHistoryListener_readOnly;
+
+ public static String RollbackNotificationHistoryListener_readOnlyWithCause;
+
+ public static String RollbackNotificationHistoryListener_title;
+
+ public static String RollbackNotificationHistoryListener_unknown;
+
+ public static String RollbackNotificationHistoryListener_unknownWithCause;
+
public static String UnitsUtils_Centimeters;
public static String UnitsUtils_Inches;
public static String UnitsUtils_Pixels;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/messages.properties
index 1d8adde52ab..700f3e214d5 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/messages/messages.properties
@@ -1,3 +1,23 @@
+#
+# Copyright (c) 2013, 2014 CEA and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Vincent Lorenzo (CEA LIST) - Initial API and implementation
+# Christian W. Damus (CEA) - bug 323802
+#
+
+RollbackNotificationHistoryListener_exception=The operation was rolled back due to an uncaught exception.
+RollbackNotificationHistoryListener_exceptionWithCause=The operation was rolled back due to an uncaught exception relating to the following objects: {0}
+RollbackNotificationHistoryListener_readOnly=The operation was rolled back because it modified read-only objects.
+RollbackNotificationHistoryListener_readOnlyWithCause=The operation was rolled back because it modified read-only objects: {0}
+RollbackNotificationHistoryListener_title=Operation Rolled Back
+RollbackNotificationHistoryListener_unknown=The operation was rolled back for an unknown reason.
+RollbackNotificationHistoryListener_unknownWithCause=The operation was rolled back for an unknown reason relating to the following objects: {0}
UnitsUtils_Centimeters=Centimeters
UnitsUtils_Inches=Inches
UnitsUtils_Pixels=Pixels
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/plugin.xml
index 8b67866e84a..3c5b99602e9 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2010, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
@@ -40,7 +53,9 @@
<!-- ElementType that deals with View deletion when their related model element is deleted -->
<elementType ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
<elementType ref="org.eclipse.gmf.runtime.diagram.core.advice.removeBookmarks"/>
-
+
+ <!-- Check for attempts to edit read-only objects that cannot reasonably be made writeable. -->
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice" />
</binding>
</extension>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/internal/ElementEditServiceProvider.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/internal/ElementEditServiceProvider.java
index c6098144371..be57c143bd2 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/internal/ElementEditServiceProvider.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.edit/src/org/eclipse/papyrus/infra/services/edit/internal/ElementEditServiceProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2013 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - support read-only objects (CDO)
+ * Christian W. Damus (CEA) - bug 323802
*
*****************************************************************************/
package org.eclipse.papyrus.infra.services.edit.internal;
@@ -21,6 +22,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
@@ -120,7 +122,8 @@ public class ElementEditServiceProvider implements IElementEditServiceProvider {
}
private boolean isReadOnly(EObject object) {
- return EMFHelper.isReadOnly(object);
+ EditingDomain domain = EMFHelper.resolveEditingDomain(object);
+ return EMFHelper.isReadOnly(object, domain) && !EMFHelper.canMakeWritable(object, domain);
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml
index 184e676f03f..c27c77e40f6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -1404,7 +1417,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.activity.ExceptionHandler_4005"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.activity.CommentAnnotatedElement_4006"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.activity.ConstraintConstrainedElement_4007"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
index fdc18ad9e1d..403448d8d5f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -1279,6 +1292,7 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.clazz.InformationFlow_4026"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.clazz.ConstraintContext_8500"/>
<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/plugin.xml
index 663ec2ad8c6..626e58bc97d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.communication/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2010, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
@@ -555,7 +568,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.communication.ConstraintConstrainedElement_8011"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.communication.DurationObservationEvent_8012"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.communication.TimeObservationEvent_8013"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/plugin.xml
index 35b9385e01c..e5554d74cfb 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2011, 2014 LIFL, CEA, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ LIFL - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension
point="org.eclipse.ui.commands">
@@ -776,7 +789,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.component.Dependency_4017"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.component.Link_4018"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.component.Connector_4019"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/plugin.xml
index 69b8c144132..22626c268ed 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -1528,6 +1541,7 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.composite.Representation_4020"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.composite.InformationFlow_4021"/>
<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/plugin.xml
index 8b1bdb752c6..3ccd454eb85 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.deployment/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2011, 2014 LIFL, CEA, and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ LIFL - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension
point="org.eclipse.ui.commands">
@@ -1110,7 +1123,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.deployment.Generalization_4003"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.deployment.Dependency_4004"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.deployment.Dependency_4010"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/plugin.xml
index 5ffcfbc10c8..5a4203eb4bd 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.interactionoverview/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
+<!--
+ Copyright (c) 2013, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<!-- Diagram declaration -->
@@ -817,6 +830,9 @@
ref="org.eclipse.papyrus.uml.diagram.interactionoverview.edit.advices.CallBehaviorActionAsInteractionUseEditHelperAdvice">
</advice>
</binding>
+ <binding context="org.eclipse.papyrus.uml.diagram.activity.TypeContext">
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
+ </binding>
</extension>
<extension
point="org.eclipse.ui.commands">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
index 6c32fc5b2e7..46b07a27e2e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2010, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -958,7 +971,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.profile.CommentAnnotatedElement_1022"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.profile.ConstraintConstrainedElement_4014"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.profile.ConstraintContext_8500"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.ui.commands" id="update-cmd">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
index ff9ecb984f7..df94629a8d8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.papyrus.views.properties.context">
<context contextModel="model/prop/seq.ctx">
@@ -618,7 +631,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.sequence.ConstraintConstrainedElement_4011"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.sequence.GeneralOrdering_4012"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.sequence.ConstraintContext_8500"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
index 5883f4aa37c..4573b6a3d10 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 MOSKitt, CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ MOSKitt - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
@@ -516,7 +529,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.statemachine.Generalization_19000"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.statemachine.CommentAnnotatedElement_667"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.statemachine.ConstraintConstrainedElement_670"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/plugin.xml
index 6c683390781..934dc8bf499 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.timing/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2013, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -1078,6 +1091,7 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.timing.MessageLost_50"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.timing.MessageFound_53"/>
<advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>
<extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/plugin.xml
index 2bf6e4a69c8..2a8fb8ff11c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.usecase/plugin.xml
@@ -1,5 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
+<!--
+ Copyright (c) 2009, 2014 CEA and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ CEA - Initial API and implementation
+ Christian W. Damus (CEA) - bug 323802
+
+-->
<plugin>
<extension point="org.eclipse.ui.contexts" id="ui-context">
@@ -654,7 +667,8 @@
<elementType ref="org.eclipse.papyrus.uml.diagram.usecase.Realization_4017"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.usecase.PackageMerge_4018"/>
<elementType ref="org.eclipse.papyrus.uml.diagram.usecase.PackageImport_4019"/>
- <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ <advice ref="org.eclipse.papyrus.infra.emf.readOnlyAdvice"/>
</binding>
</extension>

Back to the top