Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java58
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java470
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java82
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java88
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java290
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java50
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java198
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationDetailCommand.java100
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java124
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties30
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java64
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java1270
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java112
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java70
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java78
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java208
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java70
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java102
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java124
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java148
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java122
21 files changed, 1929 insertions, 1929 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
index 2f6fbe39135..1577299ab5e 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
@@ -1,29 +1,29 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (Patrick.Tessier@cea.fr) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf;
-
-import java.util.Comparator;
-
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-
-/**
- * this class is used to compare customization by taking in account the rank of the customization
- *
- */
-public class CustomizationComparator implements Comparator<Customization> {
-
- public int compare(Customization o1, Customization o2) {
- return (o1.getRank() < o2.getRank() ? -1 : (o1.getRank() == o2.getRank() ? 0 : 1));
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (Patrick.Tessier@cea.fr) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf;
+
+import java.util.Comparator;
+
+import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
+
+/**
+ * this class is used to compare customization by taking in account the rank of the customization
+ *
+ */
+public class CustomizationComparator implements Comparator<Customization> {
+
+ public int compare(Customization o1, Customization o2) {
+ return (o1.getRank() < o2.getRank() ? -1 : (o1.getRank() == o2.getRank() ? 0 : 1));
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
index 946c0549ec5..74ffdbb5abd 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
@@ -1,235 +1,235 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST, Christian W. Damus, 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 451338
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.adapters;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EContentAdapter;
-import org.eclipse.emf.transaction.NotificationFilter;
-import org.eclipse.emf.transaction.ResourceSetChangeEvent;
-import org.eclipse.emf.transaction.ResourceSetListener;
-import org.eclipse.emf.transaction.RollbackException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- * An EMF Adapter which listens on Resource Set root elements. For resource sets managed by {@link TransactionalEditingDomain}s,
- * consider using the {@link Transactional} subclass.
- *
- * @author Camille Letavernier
- *
- */
-public abstract class ResourceSetRootsAdapter extends EContentAdapter {
-
- @Override
- public void notifyChanged(Notification msg) {
- switch (msg.getEventType()) {
- case Notification.ADD:
- case Notification.ADD_MANY:
- case Notification.REMOVE:
- case Notification.REMOVE_MANY:
- case Notification.UNSET:
- doNotify(msg);
- break;
- }
-
- super.notifyChanged(msg);
- }
-
- @Override
- protected void setTarget(ResourceSet target) {
- if (target instanceof ResourceSet) {
- ResourceSet resourceSet = target;
- if (!resourceSet.eAdapters().contains(this)) {
- addAdapter(resourceSet);
- }
- }
- super.setTarget(target);
- }
-
- @Override
- protected void setTarget(Resource target) {
- // Ignore
- }
-
- @Override
- protected void setTarget(EObject target) {
- // Ignore
- }
-
- @Override
- protected void unsetTarget(EObject target) {
- // Ignore
- }
-
- @Override
- protected void unsetTarget(Resource target) {
- // Ignore
- }
-
- @Override
- protected void addAdapter(Notifier notifier) {
- super.addAdapter(notifier);
- }
-
- @Override
- protected void removeAdapter(Notifier notifier) {
- super.removeAdapter(notifier);
- }
-
- @Override
- protected void unsetTarget(ResourceSet target) {
- if (target != null) {
- removeAdapter(target);
- }
- super.unsetTarget(target);
- }
-
- @Override
- protected void handleContainment(Notification notification) {
- if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY) {
- // Do not propagate listeners to EObjects. We're only interested on events on the ResourceSet (Add/remove resources) and Resources (Add/remove EObjects)
- if (notification.getNotifier() == getTarget()) {
- super.handleContainment(notification);
- }
- } else {
- super.handleContainment(notification);
- }
- }
-
- protected abstract void doNotify(Notification msg);
-
- //
- // Nested types
- //
-
- /**
- * A variant of the {@link ResourceSetRootsAdapter} that is attached to a {@link TransactionalEditingDomain} to process batched notifications.
- */
- public static abstract class Transactional extends ResourceSetRootsAdapter implements ResourceSetListener {
- private final boolean isPrecommit;
-
- private final NotificationFilter filter = NotificationFilter.NOT_TOUCH.and(createFilter());
-
- /**
- * Initializes me as a post-commit resource-set roots notification handler.
- */
- public Transactional() {
- this(false);
- }
-
- /**
- * Initializes me as a pre- or post-commit resource-set roots notification handler.
- *
- * @param isPrecommit
- * {@code true} to react to pre-commit notifications; {@code false} to react to post-commit notifications
- */
- public Transactional(boolean isPrecommit) {
- this.isPrecommit = isPrecommit;
- }
-
- @Override
- public boolean isAggregatePrecommitListener() {
- return false;
- }
-
- @Override
- public boolean isPrecommitOnly() {
- return isPrecommit;
- }
-
- @Override
- public boolean isPostcommitOnly() {
- return !isPrecommit;
- }
-
- /**
- * Subclasses may override/extend this method to create custom filters, perhaps based on the default filter create by the superclass.
- * <b>Note</b> that this method is invoked by the superclass constructor, so subclasses must not attempt to access their own state.
- *
- * @return my notification filter
- */
- protected NotificationFilter createFilter() {
- return NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES).or(
- NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__CONTENTS));
- }
-
- @Override
- public NotificationFilter getFilter() {
- return filter;
- }
-
- @Override
- public void resourceSetChanged(ResourceSetChangeEvent event) {
- handleResourceSetChangeEvent(event);
- }
-
- @Override
- public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
- handleResourceSetChangeEvent(event);
- return null;
- }
-
- /**
- * Subclasses may override this to handle notifications as a group.
- *
- * @param event
- * the resource-set changed event carrying notifications to process
- *
- * @see #doNotify(Notification)
- */
- protected void handleResourceSetChangeEvent(ResourceSetChangeEvent event) {
- for (Notification next : event.getNotifications()) {
- doNotify(next);
- }
- }
-
- /**
- * Subclasses may override this to handle notifications individually.
- *
- * @param msg
- * a notification from the group sent by the commit of a transaction
- *
- * @see #handleResourceSetChangeEvent(ResourceSetChangeEvent)
- */
- @Override
- protected void doNotify(Notification msg) {
- // Pass
- }
-
- @Override
- public final void setTarget(Notifier newTarget) {
- // Don't attach me to anything. I am fed directly by the editing domain
- }
-
- @Override
- public final void unsetTarget(Notifier oldTarget) {
- // Pass
- }
-
- @Override
- protected final void addAdapter(Notifier notifier) {
- // Don't attach me to anything. I am fed directly by the editing domain
- }
-
- @Override
- protected final void removeAdapter(Notifier notifier) {
- // Pass
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST, Christian W. Damus, 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 451338
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.adapters;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.transaction.NotificationFilter;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+/**
+ * An EMF Adapter which listens on Resource Set root elements. For resource sets managed by {@link TransactionalEditingDomain}s,
+ * consider using the {@link Transactional} subclass.
+ *
+ * @author Camille Letavernier
+ *
+ */
+public abstract class ResourceSetRootsAdapter extends EContentAdapter {
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ switch (msg.getEventType()) {
+ case Notification.ADD:
+ case Notification.ADD_MANY:
+ case Notification.REMOVE:
+ case Notification.REMOVE_MANY:
+ case Notification.UNSET:
+ doNotify(msg);
+ break;
+ }
+
+ super.notifyChanged(msg);
+ }
+
+ @Override
+ protected void setTarget(ResourceSet target) {
+ if (target instanceof ResourceSet) {
+ ResourceSet resourceSet = target;
+ if (!resourceSet.eAdapters().contains(this)) {
+ addAdapter(resourceSet);
+ }
+ }
+ super.setTarget(target);
+ }
+
+ @Override
+ protected void setTarget(Resource target) {
+ // Ignore
+ }
+
+ @Override
+ protected void setTarget(EObject target) {
+ // Ignore
+ }
+
+ @Override
+ protected void unsetTarget(EObject target) {
+ // Ignore
+ }
+
+ @Override
+ protected void unsetTarget(Resource target) {
+ // Ignore
+ }
+
+ @Override
+ protected void addAdapter(Notifier notifier) {
+ super.addAdapter(notifier);
+ }
+
+ @Override
+ protected void removeAdapter(Notifier notifier) {
+ super.removeAdapter(notifier);
+ }
+
+ @Override
+ protected void unsetTarget(ResourceSet target) {
+ if (target != null) {
+ removeAdapter(target);
+ }
+ super.unsetTarget(target);
+ }
+
+ @Override
+ protected void handleContainment(Notification notification) {
+ if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY) {
+ // Do not propagate listeners to EObjects. We're only interested on events on the ResourceSet (Add/remove resources) and Resources (Add/remove EObjects)
+ if (notification.getNotifier() == getTarget()) {
+ super.handleContainment(notification);
+ }
+ } else {
+ super.handleContainment(notification);
+ }
+ }
+
+ protected abstract void doNotify(Notification msg);
+
+ //
+ // Nested types
+ //
+
+ /**
+ * A variant of the {@link ResourceSetRootsAdapter} that is attached to a {@link TransactionalEditingDomain} to process batched notifications.
+ */
+ public static abstract class Transactional extends ResourceSetRootsAdapter implements ResourceSetListener {
+ private final boolean isPrecommit;
+
+ private final NotificationFilter filter = NotificationFilter.NOT_TOUCH.and(createFilter());
+
+ /**
+ * Initializes me as a post-commit resource-set roots notification handler.
+ */
+ public Transactional() {
+ this(false);
+ }
+
+ /**
+ * Initializes me as a pre- or post-commit resource-set roots notification handler.
+ *
+ * @param isPrecommit
+ * {@code true} to react to pre-commit notifications; {@code false} to react to post-commit notifications
+ */
+ public Transactional(boolean isPrecommit) {
+ this.isPrecommit = isPrecommit;
+ }
+
+ @Override
+ public boolean isAggregatePrecommitListener() {
+ return false;
+ }
+
+ @Override
+ public boolean isPrecommitOnly() {
+ return isPrecommit;
+ }
+
+ @Override
+ public boolean isPostcommitOnly() {
+ return !isPrecommit;
+ }
+
+ /**
+ * Subclasses may override/extend this method to create custom filters, perhaps based on the default filter create by the superclass.
+ * <b>Note</b> that this method is invoked by the superclass constructor, so subclasses must not attempt to access their own state.
+ *
+ * @return my notification filter
+ */
+ protected NotificationFilter createFilter() {
+ return NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES).or(
+ NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__CONTENTS));
+ }
+
+ @Override
+ public NotificationFilter getFilter() {
+ return filter;
+ }
+
+ @Override
+ public void resourceSetChanged(ResourceSetChangeEvent event) {
+ handleResourceSetChangeEvent(event);
+ }
+
+ @Override
+ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
+ handleResourceSetChangeEvent(event);
+ return null;
+ }
+
+ /**
+ * Subclasses may override this to handle notifications as a group.
+ *
+ * @param event
+ * the resource-set changed event carrying notifications to process
+ *
+ * @see #doNotify(Notification)
+ */
+ protected void handleResourceSetChangeEvent(ResourceSetChangeEvent event) {
+ for (Notification next : event.getNotifications()) {
+ doNotify(next);
+ }
+ }
+
+ /**
+ * Subclasses may override this to handle notifications individually.
+ *
+ * @param msg
+ * a notification from the group sent by the commit of a transaction
+ *
+ * @see #handleResourceSetChangeEvent(ResourceSetChangeEvent)
+ */
+ @Override
+ protected void doNotify(Notification msg) {
+ // Pass
+ }
+
+ @Override
+ public final void setTarget(Notifier newTarget) {
+ // Don't attach me to anything. I am fed directly by the editing domain
+ }
+
+ @Override
+ public final void unsetTarget(Notifier oldTarget) {
+ // Pass
+ }
+
+ @Override
+ protected final void addAdapter(Notifier notifier) {
+ // Don't attach me to anything. I am fed directly by the editing domain
+ }
+
+ @Override
+ protected final void removeAdapter(Notifier notifier) {
+ // Pass
+ }
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
index 8d5e552b410..ea0676da800 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
@@ -1,41 +1,41 @@
-/*****************************************************************************
- * Copyright (c) 2013, 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 433371
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.advice;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
-
-/**
- * An EditHelperAdvice which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
- * When a page identifier object is deleted, the associated page is removed
- *
- * This advice is used when an Object containing a page is deleted
- *
- * @author Camille Letavernier
- *
- */
-public class DeletePageAdvice extends AbstractEditHelperAdvice {
-
- @Override
- protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
- final EObject objectToDestroy = request.getElementToDestroy();
- if (objectToDestroy == null) {
- return null;
- }
- return RemovePageHelper.getRemovePageCommand(request.getEditingDomain(), objectToDestroy);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013, 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.advice;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+
+/**
+ * An EditHelperAdvice which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
+ * When a page identifier object is deleted, the associated page is removed
+ *
+ * This advice is used when an Object containing a page is deleted
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class DeletePageAdvice extends AbstractEditHelperAdvice {
+
+ @Override
+ protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
+ final EObject objectToDestroy = request.getElementToDestroy();
+ if (objectToDestroy == null) {
+ return null;
+ }
+ return RemovePageHelper.getRemovePageCommand(request.getEditingDomain(), objectToDestroy);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
index 8741660c19a..514a51ba949 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
@@ -1,44 +1,44 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.advice;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-
-/**
- * An EditHelper which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
- * When a page identifier object is deleted, the associated page is removed
- *
- * This EditHelper will be called when a Page is deleted
- *
- * @author Camille Letavernier
- *
- */
-public class DeletePageEditHelper extends AbstractEditHelper {
-
- @Override
- protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
- ICommand baseCommand = super.getDestroyElementCommand(req);
-
- final EObject elementToDestroy = req.getElementToDestroy();
-
- ICommand removePage = RemovePageHelper.getRemovePageCommand(req.getEditingDomain(), elementToDestroy);
-
- baseCommand = CompositeCommand.compose(removePage, baseCommand);
-
- return baseCommand;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.advice;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+
+/**
+ * An EditHelper which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
+ * When a page identifier object is deleted, the associated page is removed
+ *
+ * This EditHelper will be called when a Page is deleted
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class DeletePageEditHelper extends AbstractEditHelper {
+
+ @Override
+ protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
+ ICommand baseCommand = super.getDestroyElementCommand(req);
+
+ final EObject elementToDestroy = req.getElementToDestroy();
+
+ ICommand removePage = RemovePageHelper.getRemovePageCommand(req.getEditingDomain(), elementToDestroy);
+
+ baseCommand = CompositeCommand.compose(removePage, baseCommand);
+
+ return baseCommand;
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
index 76b633d5fa7..9faf7097961 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
@@ -1,145 +1,145 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
-
- public EModelElement getObject() {
- return object;
- }
-
- // @unused
- public void setObject(EModelElement object) {
- this.object = object;
- }
-
- // @unused
- public String getEAnnotationName() {
- return eAnnotationName;
- }
-
- // @unused
- public void setEAnnotationName(String annotationName) {
- eAnnotationName = annotationName;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- /**
- * Instantiates a new creates the e annotation command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param eannotationName
- * the eannotation name
- */
- public CreateEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- attachEannotation(createEAnnotation(), object);
-
- }
-
- /**
- * Creates the e annotation.
- *
- * @return the e annotation
- */
- protected EAnnotation createEAnnotation() {
- EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eannotation.setSource(eAnnotationName);
- return eannotation;
- }
-
- /**
- * Attach eannotation to an EmodelElement.
- *
- * @param annotation
- * the annotation
- * @param object
- * the object
- */
- protected void attachEannotation(EAnnotation annotation, EModelElement object) {
- object.getEAnnotations().add(annotation);
- }
-
- /**
- * Replace existing eannotation with a new eannotation. This repplaced eannotation has the same
- * source.
- *
- * @param annotation
- * the annotation
- * @param object
- * the object
- */
- protected void replaceEannotation(EAnnotation annotation, EModelElement object) {
- while (object.getEAnnotation(annotation.getSource()) != null) {
- object.getEAnnotations().remove(object.getEAnnotation(annotation.getSource()));
- }
-
- object.getEAnnotations().add(annotation);
- }
-
- /**
- * Adds the entry.
- *
- * @param annotation
- * the annotation
- * @param key
- * the key
- * @param value
- * the value
- */
- // @unused
- protected void addEntry(EAnnotation annotation, String key, String value) {
- annotation.getDetails().put(key, value);
- }
-
- /**
- * Replace entry.
- *
- * @param annotation
- * the annotation not null
- * @param key
- * the key
- * @param value
- * the value
- */
- protected void replaceEntry(EAnnotation annotation, String key, String value) {
- while (annotation.getDetails().get(key) != null) {
- annotation.getDetails().removeKey(key);
-
- }
- annotation.getDetails().put(key, value);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.commands;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
+
+ public EModelElement getObject() {
+ return object;
+ }
+
+ // @unused
+ public void setObject(EModelElement object) {
+ this.object = object;
+ }
+
+ // @unused
+ public String getEAnnotationName() {
+ return eAnnotationName;
+ }
+
+ // @unused
+ public void setEAnnotationName(String annotationName) {
+ eAnnotationName = annotationName;
+ }
+
+ /** The object. */
+ private EModelElement object;
+
+ /** The e annotation name. */
+ private String eAnnotationName;
+
+ /**
+ * Instantiates a new creates the e annotation command.
+ *
+ * @param domain
+ * the domain
+ * @param object
+ * the object
+ * @param eannotationName
+ * the eannotation name
+ */
+ public CreateEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
+ super(domain);
+ this.object = object;
+ this.eAnnotationName = eannotationName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void doExecute() {
+ attachEannotation(createEAnnotation(), object);
+
+ }
+
+ /**
+ * Creates the e annotation.
+ *
+ * @return the e annotation
+ */
+ protected EAnnotation createEAnnotation() {
+ EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eannotation.setSource(eAnnotationName);
+ return eannotation;
+ }
+
+ /**
+ * Attach eannotation to an EmodelElement.
+ *
+ * @param annotation
+ * the annotation
+ * @param object
+ * the object
+ */
+ protected void attachEannotation(EAnnotation annotation, EModelElement object) {
+ object.getEAnnotations().add(annotation);
+ }
+
+ /**
+ * Replace existing eannotation with a new eannotation. This repplaced eannotation has the same
+ * source.
+ *
+ * @param annotation
+ * the annotation
+ * @param object
+ * the object
+ */
+ protected void replaceEannotation(EAnnotation annotation, EModelElement object) {
+ while (object.getEAnnotation(annotation.getSource()) != null) {
+ object.getEAnnotations().remove(object.getEAnnotation(annotation.getSource()));
+ }
+
+ object.getEAnnotations().add(annotation);
+ }
+
+ /**
+ * Adds the entry.
+ *
+ * @param annotation
+ * the annotation
+ * @param key
+ * the key
+ * @param value
+ * the value
+ */
+ // @unused
+ protected void addEntry(EAnnotation annotation, String key, String value) {
+ annotation.getDetails().put(key, value);
+ }
+
+ /**
+ * Replace entry.
+ *
+ * @param annotation
+ * the annotation not null
+ * @param key
+ * the key
+ * @param value
+ * the value
+ */
+ protected void replaceEntry(EAnnotation annotation, String key, String value) {
+ while (annotation.getDetails().get(key) != null) {
+ annotation.getDetails().removeKey(key);
+
+ }
+ annotation.getDetails().put(key, value);
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
index 53234310bde..d4f9c3f36fb 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
@@ -1,25 +1,25 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-
-/**
- * Constants for the duplication commands.
- */
-public interface IPapyrusDuplicateCommandConstants {
-
- /** Constant used as a key for the parameters map of the duplication request */
- public final String ADDITIONAL_DUPLICATED_ELEMENTS = "Additional_Duplicated_Elements"; //$NON-NLS-1$
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.commands;
+
+
+/**
+ * Constants for the duplication commands.
+ */
+public interface IPapyrusDuplicateCommandConstants {
+
+ /** Constant used as a key for the parameters map of the duplication request */
+ public final String ADDITIONAL_DUPLICATED_ELEMENTS = "Additional_Duplicated_Elements"; //$NON-NLS-1$
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
index e27f191824e..981d14e4d93 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
@@ -1,99 +1,99 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Remi Schnekenburger (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- * This {@link RecordingCommand} removes an eannotation to a given element.
- */
-public class RemoveEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
-
- // @unused
- public EModelElement getObject() {
- return object;
- }
-
- // @unused
- public void setObject(EModelElement object) {
- this.object = object;
- }
-
- // @unused
- public String getEAnnotationName() {
- return eAnnotationName;
- }
-
- // @unused
- public void setEAnnotationName(String annotationName) {
- eAnnotationName = annotationName;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- private EModelElement eAnnotation;
-
- /**
- * Instantiates a new creates the e annotation command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param eannotationName
- * the eannotation name
- */
- public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- /**
- * Instantiates a new creates the e annotation command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param eAnnotation
- * The Eannotation
- *
- */
- public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, EModelElement eAnnotation) {
- super(domain);
- this.eAnnotation = eAnnotation;
- this.object = object;
-
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- if (eAnnotation == null && eAnnotationName != null) {
- eAnnotation = object.getEAnnotation(eAnnotationName);
- }
- object.getEAnnotations().remove(eAnnotation);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.commands;
+
+import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+/**
+ * This {@link RecordingCommand} removes an eannotation to a given element.
+ */
+public class RemoveEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
+
+ // @unused
+ public EModelElement getObject() {
+ return object;
+ }
+
+ // @unused
+ public void setObject(EModelElement object) {
+ this.object = object;
+ }
+
+ // @unused
+ public String getEAnnotationName() {
+ return eAnnotationName;
+ }
+
+ // @unused
+ public void setEAnnotationName(String annotationName) {
+ eAnnotationName = annotationName;
+ }
+
+ /** The object. */
+ private EModelElement object;
+
+ /** The e annotation name. */
+ private String eAnnotationName;
+
+ private EModelElement eAnnotation;
+
+ /**
+ * Instantiates a new creates the e annotation command.
+ *
+ * @param domain
+ * the domain
+ * @param object
+ * the object
+ * @param eannotationName
+ * the eannotation name
+ */
+ public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
+ super(domain);
+ this.object = object;
+ this.eAnnotationName = eannotationName;
+ }
+
+ /**
+ * Instantiates a new creates the e annotation command.
+ *
+ * @param domain
+ * the domain
+ * @param object
+ * the object
+ * @param eAnnotation
+ * The Eannotation
+ *
+ */
+ public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, EModelElement eAnnotation) {
+ super(domain);
+ this.eAnnotation = eAnnotation;
+ this.object = object;
+
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void doExecute() {
+ if (eAnnotation == null && eAnnotationName != null) {
+ eAnnotation = object.getEAnnotation(eAnnotationName);
+ }
+ object.getEAnnotations().remove(eAnnotation);
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationDetailCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationDetailCommand.java
index bddab04c74b..2e4621081f7 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationDetailCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationDetailCommand.java
@@ -1,50 +1,50 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- * @author Céline JANSSENS
- *
- */
-public class RemoveEAnnotationDetailCommand extends RecordingCommand {
-
- private EAnnotation eAnnotation;
- private String detailKey;
-
- /**
- * Constructor.
- *
- */
- public RemoveEAnnotationDetailCommand(TransactionalEditingDomain domain, EAnnotation annotation, String detailKey) {
- super(domain);
- this.eAnnotation = annotation;
- this.detailKey = detailKey;
-
- }
-
- /**
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- eAnnotation.getDetails().removeKey(detailKey);
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.emf.commands;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+
+/**
+ * @author Céline JANSSENS
+ *
+ */
+public class RemoveEAnnotationDetailCommand extends RecordingCommand {
+
+ private EAnnotation eAnnotation;
+ private String detailKey;
+
+ /**
+ * Constructor.
+ *
+ */
+ public RemoveEAnnotationDetailCommand(TransactionalEditingDomain domain, EAnnotation annotation, String detailKey) {
+ super(domain);
+ this.eAnnotation = annotation;
+ this.detailKey = detailKey;
+
+ }
+
+ /**
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ *
+ */
+ @Override
+ protected void doExecute() {
+ eAnnotation.getDetails().removeKey(detailKey);
+
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
index 90723871d7a..716b302471c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
@@ -1,62 +1,62 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.messages.Messages;
-
-
-public class UnsetCommand extends RecordingCommand {
-
- /**
- * the source eobject
- */
- private final EObject source;
-
- /**
- * the feature
- */
- private final EStructuralFeature feature;
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * the editing domain
- * @param source
- * the eobject to modify
- * @param feature
- * the feature to unset
- */
- public UnsetCommand(final TransactionalEditingDomain domain, final EObject source, final EStructuralFeature feature) {
- super(domain, Messages.UnsetCommand_UnsetCommand);
- this.source = source;
- this.feature = feature;
- }
-
- /**
- *
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- source.eUnset(feature);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.commands;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.messages.Messages;
+
+
+public class UnsetCommand extends RecordingCommand {
+
+ /**
+ * the source eobject
+ */
+ private final EObject source;
+
+ /**
+ * the feature
+ */
+ private final EStructuralFeature feature;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param domain
+ * the editing domain
+ * @param source
+ * the eobject to modify
+ * @param feature
+ * the feature to unset
+ */
+ public UnsetCommand(final TransactionalEditingDomain domain, final EObject source, final EStructuralFeature feature) {
+ super(domain, Messages.UnsetCommand_UnsetCommand);
+ this.source = source;
+ this.feature = feature;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ *
+ */
+ @Override
+ protected void doExecute() {
+ source.eUnset(feature);
+ }
+
+}
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 379d3dfb6a6..b0d37d44d39 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,15 +1,15 @@
-#
-# Copyright (c) 2012, 2016 CEA, Christian W. Damus, 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
-# Christian W. Damus - bug 485220
-#
-
-UnsetCommand_UnsetCommand=Unset Command
+#
+# Copyright (c) 2012, 2016 CEA, Christian W. Damus, 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
+# Christian W. Damus - bug 485220
+#
+
+UnsetCommand_UnsetCommand=Unset Command
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
index daa0dbe8cf3..dc1997368e5 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
@@ -1,32 +1,32 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * Represents a value replacement.
- *
- * @author Camille Letavernier
- *
- */
-public interface Replacement extends EStructuralFeature.Setting {
-
- /**
- * Returns the old value
- *
- * @return
- * The value which has been replaced
- */
- public EObject getOldValue();
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.resource;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * Represents a value replacement.
+ *
+ * @author Camille Letavernier
+ *
+ */
+public interface Replacement extends EStructuralFeature.Setting {
+
+ /**
+ * Returns the old value
+ *
+ * @return
+ * The value which has been replaced
+ */
+ public EObject getOldValue();
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java
index 35a17275d8c..2ed8f58db73 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/index/WorkspaceModelIndex.java
@@ -1,635 +1,635 @@
-/*****************************************************************************
- * Copyright (c) 2014, 2017 Christian W. Damus 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 - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.emf.resource.index;
-
-import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.TRACE_INDEXER_FILES;
-import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.detailf;
-import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.isTracing;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.stream.Collectors;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.emf.internal.resource.index.IIndexSaveParticipant;
-import org.eclipse.papyrus.infra.emf.internal.resource.index.IndexManager;
-import org.eclipse.papyrus.infra.emf.internal.resource.index.IndexPersistenceManager;
-import org.eclipse.papyrus.infra.emf.internal.resource.index.InternalModelIndex;
-
-import com.google.common.base.Function;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.SetMultimap;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * A general-purpose index of model resources in the Eclipse workspace.
- */
-public class WorkspaceModelIndex<T> extends InternalModelIndex {
- private static final long INDEX_RECORD_SERIAL_VERSION = 1L;
-
- private final IndexHandler<? extends T> indexer;
- private final PersistentIndexHandler<T> pIndexer;
-
- private final String indexName;
- private final IContentType contentType;
-
- private final IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- private final SetMultimap<IProject, IFile> index = HashMultimap.create();
-
- private final Set<String> fileExtensions;
- private boolean started;
-
- public WorkspaceModelIndex(String name, String contentType, IndexHandler<? extends T> indexer) {
- this(name, contentType, indexer, 0);
- }
-
- public WorkspaceModelIndex(String name, String contentType, IndexHandler<? extends T> indexer, int maxConcurrentJobs) {
- this(name, contentType,
- Platform.getContentTypeManager().getContentType(contentType).getFileSpecs(IContentType.FILE_EXTENSION_SPEC),
- indexer, maxConcurrentJobs);
- }
-
- /**
- * @since 2.1
- */
- public WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, IndexHandler<? extends T> indexer, int maxConcurrentJobs) {
- this(name, contentType, fileExtensions, indexer, null, maxConcurrentJobs);
- }
-
- /**
- * @since 2.1
- */
- public WorkspaceModelIndex(String name, String contentType, PersistentIndexHandler<T> indexer) {
- this(name, contentType, indexer, 0);
- }
-
- /**
- * @since 2.1
- */
- public WorkspaceModelIndex(String name, String contentType, PersistentIndexHandler<T> indexer, int maxConcurrentJobs) {
- this(name, contentType,
- Platform.getContentTypeManager().getContentType(contentType).getFileSpecs(IContentType.FILE_EXTENSION_SPEC),
- indexer, maxConcurrentJobs);
- }
-
- /**
- * @since 2.1
- */
- public WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, PersistentIndexHandler<T> indexer, int maxConcurrentJobs) {
- this(name, contentType, fileExtensions, indexer, indexer, maxConcurrentJobs);
- }
-
- private WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, IndexHandler<? extends T> indexer, PersistentIndexHandler<T> pIndexer, int maxConcurrentJobs) {
- super(new QualifiedName(Activator.PLUGIN_ID, "index:" + name), maxConcurrentJobs); //$NON-NLS-1$
-
- this.indexName = name;
- this.contentType = Platform.getContentTypeManager().getContentType(contentType);
- this.indexer = indexer;
- this.pIndexer = pIndexer;
-
- if ((fileExtensions != null) && (fileExtensions.length > 0)) {
- this.fileExtensions = ImmutableSet.copyOf(fileExtensions);
- } else {
- this.fileExtensions = null;
- }
- }
-
- @Override
- public void dispose() {
- if (pIndexer != null) {
- IndexPersistenceManager.INSTANCE.removeIndex(this);
- }
-
- synchronized (index) {
- for (IFile next : index.values()) {
- try {
- next.setSessionProperty(getIndexKey(), null);
- } catch (CoreException e) {
- // Just continue, best-effort. There's nothing else to do
- }
- }
-
- index.clear();
- }
- }
-
- /**
- * @since 2.1
- */
- @Override
- protected final void start() {
- if (started) {
- throw new IllegalStateException("index already started: " + getName()); //$NON-NLS-1$
- }
- started = true;
-
- // If we support persistence, initialize from the store
- if (pIndexer != null) {
- InputStream storeInput = IndexPersistenceManager.INSTANCE.addIndex(this, createSaveParticipant());
- if (storeInput != null) {
- try {
- loadIndex(storeInput);
- } catch (IOException e) {
- // The input was already closed, if it could be
- Activator.log.error("Failed to load index data for " + getName(), e); //$NON-NLS-1$
- }
- }
- }
- }
-
- private void loadIndex(InputStream storeInput) throws IOException {
- List<IndexRecord> store = loadStore(storeInput);
-
- synchronized (index) {
- for (IndexRecord record : store) {
- if (record.file.isAccessible()) {
- try {
- record.file.setSessionProperty(getIndexKey(), record);
- index.put(record.file.getProject(), record.file);
- } catch (CoreException e) {
- // Doesn't matter; it will be indexed from scratch, then
- Activator.log.log(e.getStatus());
- }
- }
- }
- }
- }
-
- private List<IndexRecord> loadStore(InputStream storeInput) throws IOException {
- List<IndexRecord> result = Collections.emptyList();
-
- try (InputStream outer = storeInput; ObjectInputStream input = createObjectInput(outer)) {
- // Load the version. So far, we're at the first version
- long version = input.readLong();
- if (version != INDEX_RECORD_SERIAL_VERSION) {
- throw new IOException("Unexpected index record serial version " + version); //$NON-NLS-1$
- }
-
- // Read the number of records
- int count = input.readInt();
- result = new ArrayList<>(count);
-
- // Read the records
- for (int i = 0; i < count; i++) {
- try {
- result.add(readIndexRecord(input));
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
- }
- }
- }
-
- return result;
- }
-
- private IndexRecord readIndexRecord(ObjectInput in) throws IOException, ClassNotFoundException {
- // Load the file
- IPath path = new Path((String) in.readObject());
- IFile file = wsRoot.getFile(path);
-
- // Load the index data
- @SuppressWarnings("unchecked")
- T index = (T) in.readObject();
-
- return new IndexRecord(file, index);
- }
-
- private IIndexSaveParticipant createSaveParticipant() {
- return new IIndexSaveParticipant() {
- @Override
- public void save(WorkspaceModelIndex<?> index, OutputStream storeOutput) throws IOException, CoreException {
- if (index == WorkspaceModelIndex.this) {
- List<IndexRecord> store;
-
- synchronized (index) {
- store = index.index.values().stream()
- .filter(IResource::isAccessible)
- .map(f -> {
- IndexRecord result = null;
-
- try {
- @SuppressWarnings("unchecked")
- IndexRecord __ = (IndexRecord) f.getSessionProperty(getIndexKey());
- result = __;
- } catch (CoreException e) {
- // Doesn't matter; we'll just index it next time
- Activator.log.log(e.getStatus());
- }
-
- return result;
- })
- .collect(Collectors.toList());
- }
-
- saveStore(store, storeOutput);
- }
- }
- };
- }
-
- private void saveStore(List<IndexRecord> store, OutputStream storeOutput) throws IOException {
- try (ObjectOutputStream output = new ObjectOutputStream(storeOutput)) {
- // Write the version
- output.writeLong(INDEX_RECORD_SERIAL_VERSION);
-
- // Write the number of records
- output.writeInt(store.size());
-
- // Write the records
- for (IndexRecord next : store) {
- writeIndexRecord(next, output);
- }
- }
- }
-
- private void writeIndexRecord(IndexRecord record, ObjectOutput out) throws IOException {
- out.writeObject(record.file.getFullPath().toPortableString());
- out.writeObject(record.index);
- }
-
- /**
- * Obtains the name of this index.
- *
- * @return my name
- * @since 2.1
- */
- public final String getName() {
- return indexName;
- }
-
- @Override
- public String toString() {
- return String.format("WorkspaceModelIndex(%s)", getName()); //$NON-NLS-1$
- }
-
- /**
- * Obtains an asynchronous future result that is scheduled to run after any pending indexing work has completed.
- * The {@code function} is <em>not</em> invoked under synchronization on the index; it is passed a copy of the
- * last consistent state of the index after any pending calculations have completed.
- *
- * @param function
- * the function to schedule. Its input is the complete index map
- *
- * @return the future result of the function applied to the index
- */
- public <V> ListenableFuture<V> afterIndex(final Function<? super Map<IFile, T>, V> function) {
- return Futures.transform(getIndex(), function);
- }
-
- /**
- * Obtains an asynchronous future result that is scheduled to run after any
- * pending indexing work has completed. The {@code callable} is invoked under
- * synchronization on the index, so it must be careful about how it
- * synchronizes on other objects to avoid deadlocks.
- *
- * @param callable
- * the operation to schedule
- *
- * @return the future result of the operation
- */
- @Override
- public <V> ListenableFuture<V> afterIndex(Callable<V> callable) {
- return super.afterIndex(() -> {
- synchronized (index) {
- return callable.call();
- }
- });
- }
-
- @Override
- public final <V> V ifAvailable(Callable<V> callable) throws CoreException {
- return super.ifAvailable(callable);
- }
-
- /**
- * Schedules an operation to run after any pending indexing work has completed.
- * The {@code runnable} is invoked under synchronization on the index, so it must be careful about how it
- * synchronizes on other objects to avoid deadlocks.
- *
- * @param runnable
- * the operation to schedule
- */
- public void afterIndex(final Runnable runnable) {
- afterIndex(new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- runnable.run();
- return null;
- }
- });
- }
-
- /**
- * Obtains the index when it is ready.
- *
- * @return the future value of the index, when it is ready
- */
- public ListenableFuture<Map<IFile, T>> getIndex() {
- return afterIndex(new Callable<Map<IFile, T>>() {
- @Override
- public Map<IFile, T> call() {
- return map();
- }
- });
- }
-
- /**
- * @precondition The {@link #index} monitor is held.
- */
- private Map<IFile, T> map() {
- ImmutableMap.Builder<IFile, T> result = ImmutableMap.builder();
-
- for (IFile next : index.values()) {
- try {
- @SuppressWarnings("unchecked")
- IndexRecord record = (IndexRecord) next.getSessionProperty(getIndexKey());
- if (record != null) {
- result.put(next, record.index);
- }
- } catch (CoreException e) {
- Activator.log.error("Failed to access index data for file " + next.getFullPath(), e); //$NON-NLS-1$
- }
- }
-
- return result.build();
- }
-
- /**
- * @since 2.1
- */
- @Override
- protected final void process(IFile file) throws CoreException {
- IProject project = file.getProject();
- if (match(file)) {
- @SuppressWarnings("unchecked")
- IndexRecord record = (IndexRecord) file.getSessionProperty(getIndexKey());
- if ((record == null) || record.isObsolete()) {
- add(project, file);
- } else if (pIndexer == null) {
- // No persistence support? Fine, then recompute
- add(project, file);
- } else {
- // If it's not obsolete, then we're loading it from persistent storage
- init(project, file, record);
- }
- } else {
- remove(project, file);
- }
- }
-
- /**
- * @since 2.1
- */
- @Override
- protected final boolean match(IFile file) {
- boolean result = false;
-
- // Don't even attempt to match the content type if the file extension doesn't match.
- // And if it's not synchronized, don't attempt to do anything with it. We'll get it
- // later when it is synchronized
- if (file.isAccessible()
- && ((fileExtensions == null) || fileExtensions.contains(file.getFileExtension()))
- && file.isSynchronized(IResource.DEPTH_ZERO)) {
-
- IContentType[] contentTypes = getContentTypes(file);
- if (contentTypes != null) {
- for (int i = 0; (i < contentTypes.length) && !result; i++) {
- result = contentTypes[i].isKindOf(contentType);
- }
- }
- }
-
- // Let the indexer apply its own criteria if the standard filters don't match
- result = result && indexer.shouldIndex(file);
-
- return result;
- }
-
- void init(IProject project, IFile file, IndexRecord record) throws CoreException {
- if (isTracing()) {
- detailf(TRACE_INDEXER_FILES,
- "Loading initial index %s for %s", getIndexKey().getLocalName(), file.getFullPath()); //$NON-NLS-1$
- }
-
- if (pIndexer.load(file, record.index)) {
- synchronized (index) {
- index.put(project, file);
- file.setSessionProperty(getIndexKey(), record);
- }
- }
- }
-
- void add(IProject project, IFile file) throws CoreException {
- if (isTracing()) {
- detailf(TRACE_INDEXER_FILES,
- "Computing index %s for %s", getIndexKey().getLocalName(), file.getFullPath()); //$NON-NLS-1$
- }
-
- T data = indexer.index(file);
- synchronized (index) {
- index.put(project, file);
- file.setSessionProperty(getIndexKey(), new IndexRecord(file, data));
- }
- }
-
- /**
- * @since 2.1
- */
- @Override
- protected final void remove(IProject project, IFile file) throws CoreException {
- boolean unindex;
-
- synchronized (index) {
- // Don't need to do any work on the index data if
- // this wasn't in the index in the first place
- unindex = index.remove(project, file);
- }
-
- if (unindex) {
- try {
- indexer.unindex(file);
- } finally {
- if (file.exists()) {
- file.setSessionProperty(getIndexKey(), null);
- }
- }
- }
- }
-
- /**
- * @since 2.1
- */
- @Override
- protected final void remove(IProject project) throws CoreException {
- Set<IFile> files;
-
- synchronized (index) {
- files = index.containsKey(project)
- ? index.removeAll(project)
- : null;
- }
-
- if (files != null) {
- files.forEach(indexer::unindex);
- }
- }
-
- @Override
- protected boolean hasIndex(IProject project) {
- synchronized (index) {
- return index.containsKey(project);
- }
- }
-
- public void addListener(IWorkspaceModelIndexListener listener) {
- Futures.addCallback(getManager(), new FutureCallback<IndexManager>() {
- @Override
- public void onSuccess(IndexManager result) {
- result.addListener(WorkspaceModelIndex.this, listener);
- }
-
- @Override
- public void onFailure(Throwable t) {
- // Don't need a listener
- }
- });
- }
-
- public void removeListener(IWorkspaceModelIndexListener listener) {
- Futures.addCallback(getManager(), new FutureCallback<IndexManager>() {
- @Override
- public void onSuccess(IndexManager result) {
- result.removeListener(WorkspaceModelIndex.this, listener);
- }
-
- @Override
- public void onFailure(Throwable t) {
- // Couldn't have added the listener anyways
- }
- });
- }
-
- //
- // Nested types
- //
-
- /**
- * Callback interface for the index client to update the index.
- */
- public static interface IndexHandler<T> {
- /**
- * Updates the index for a file that matches our selection criteria.
- *
- * @param file
- * a file that exists and matches the index selection criteria
- *
- * @return the object to store in the index for this {@code file}
- */
- T index(IFile file);
-
- /**
- * Updates the index for a file that no longer exists or no longer matches our selection criteria.
- *
- * @param file
- * a file that no longer exists or otherwise no longer matches our selection criteria. It is removed from the index
- */
- void unindex(IFile file);
-
- /**
- * Queries whether a give {@code file} should be indexed.
- * The default implementation just returns {@code true}, always.
- *
- * @param file
- * a file proposed for indexing
- * @return whether the file should be indexed
- *
- * @since 3.0
- */
- default boolean shouldIndex(IFile file) {
- return true;
- }
- }
-
- /**
- * Extension interface for index handlers that provide persistable index
- * data associated with each file. This enables storage of the index in
- * the workspace metadata for quick initialization on start-up, requiring
- * re-calculation of the index only for files that were changed since the
- * workspace was last closed.
- *
- * @param <T>
- * the index data store type, which must be {@link Serializable}
- * @since 2.1
- */
- public static interface PersistentIndexHandler<T> extends IndexHandler<T> {
- /**
- * Initializes the {@code index} data for a file from the persistent store.
- *
- * @param file
- * a file in the workspace
- * @param index
- * its previously stored index
- *
- * @return whether the {@code index} data were successfully integrated.
- * A {@code false} result indicates that the file must be indexed
- * from scratch
- */
- boolean load(IFile file, T index);
- }
-
- private final class IndexRecord {
- private IFile file;
- private long generation;
- private T index;
-
- IndexRecord(IFile file, T index) {
- super();
-
- this.file = file;
- this.generation = file.getModificationStamp();
- this.index = index;
- }
-
- boolean isObsolete() {
- return file.getModificationStamp() != generation;
- }
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2014, 2017 Christian W. Damus 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 - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.emf.resource.index;
+
+import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.TRACE_INDEXER_FILES;
+import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.detailf;
+import static org.eclipse.papyrus.infra.emf.internal.resource.InternalIndexUtil.isTracing;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.stream.Collectors;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.emf.internal.resource.index.IIndexSaveParticipant;
+import org.eclipse.papyrus.infra.emf.internal.resource.index.IndexManager;
+import org.eclipse.papyrus.infra.emf.internal.resource.index.IndexPersistenceManager;
+import org.eclipse.papyrus.infra.emf.internal.resource.index.InternalModelIndex;
+
+import com.google.common.base.Function;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.SetMultimap;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * A general-purpose index of model resources in the Eclipse workspace.
+ */
+public class WorkspaceModelIndex<T> extends InternalModelIndex {
+ private static final long INDEX_RECORD_SERIAL_VERSION = 1L;
+
+ private final IndexHandler<? extends T> indexer;
+ private final PersistentIndexHandler<T> pIndexer;
+
+ private final String indexName;
+ private final IContentType contentType;
+
+ private final IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ private final SetMultimap<IProject, IFile> index = HashMultimap.create();
+
+ private final Set<String> fileExtensions;
+ private boolean started;
+
+ public WorkspaceModelIndex(String name, String contentType, IndexHandler<? extends T> indexer) {
+ this(name, contentType, indexer, 0);
+ }
+
+ public WorkspaceModelIndex(String name, String contentType, IndexHandler<? extends T> indexer, int maxConcurrentJobs) {
+ this(name, contentType,
+ Platform.getContentTypeManager().getContentType(contentType).getFileSpecs(IContentType.FILE_EXTENSION_SPEC),
+ indexer, maxConcurrentJobs);
+ }
+
+ /**
+ * @since 2.1
+ */
+ public WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, IndexHandler<? extends T> indexer, int maxConcurrentJobs) {
+ this(name, contentType, fileExtensions, indexer, null, maxConcurrentJobs);
+ }
+
+ /**
+ * @since 2.1
+ */
+ public WorkspaceModelIndex(String name, String contentType, PersistentIndexHandler<T> indexer) {
+ this(name, contentType, indexer, 0);
+ }
+
+ /**
+ * @since 2.1
+ */
+ public WorkspaceModelIndex(String name, String contentType, PersistentIndexHandler<T> indexer, int maxConcurrentJobs) {
+ this(name, contentType,
+ Platform.getContentTypeManager().getContentType(contentType).getFileSpecs(IContentType.FILE_EXTENSION_SPEC),
+ indexer, maxConcurrentJobs);
+ }
+
+ /**
+ * @since 2.1
+ */
+ public WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, PersistentIndexHandler<T> indexer, int maxConcurrentJobs) {
+ this(name, contentType, fileExtensions, indexer, indexer, maxConcurrentJobs);
+ }
+
+ private WorkspaceModelIndex(String name, String contentType, String[] fileExtensions, IndexHandler<? extends T> indexer, PersistentIndexHandler<T> pIndexer, int maxConcurrentJobs) {
+ super(new QualifiedName(Activator.PLUGIN_ID, "index:" + name), maxConcurrentJobs); //$NON-NLS-1$
+
+ this.indexName = name;
+ this.contentType = Platform.getContentTypeManager().getContentType(contentType);
+ this.indexer = indexer;
+ this.pIndexer = pIndexer;
+
+ if ((fileExtensions != null) && (fileExtensions.length > 0)) {
+ this.fileExtensions = ImmutableSet.copyOf(fileExtensions);
+ } else {
+ this.fileExtensions = null;
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (pIndexer != null) {
+ IndexPersistenceManager.INSTANCE.removeIndex(this);
+ }
+
+ synchronized (index) {
+ for (IFile next : index.values()) {
+ try {
+ next.setSessionProperty(getIndexKey(), null);
+ } catch (CoreException e) {
+ // Just continue, best-effort. There's nothing else to do
+ }
+ }
+
+ index.clear();
+ }
+ }
+
+ /**
+ * @since 2.1
+ */
+ @Override
+ protected final void start() {
+ if (started) {
+ throw new IllegalStateException("index already started: " + getName()); //$NON-NLS-1$
+ }
+ started = true;
+
+ // If we support persistence, initialize from the store
+ if (pIndexer != null) {
+ InputStream storeInput = IndexPersistenceManager.INSTANCE.addIndex(this, createSaveParticipant());
+ if (storeInput != null) {
+ try {
+ loadIndex(storeInput);
+ } catch (IOException e) {
+ // The input was already closed, if it could be
+ Activator.log.error("Failed to load index data for " + getName(), e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ private void loadIndex(InputStream storeInput) throws IOException {
+ List<IndexRecord> store = loadStore(storeInput);
+
+ synchronized (index) {
+ for (IndexRecord record : store) {
+ if (record.file.isAccessible()) {
+ try {
+ record.file.setSessionProperty(getIndexKey(), record);
+ index.put(record.file.getProject(), record.file);
+ } catch (CoreException e) {
+ // Doesn't matter; it will be indexed from scratch, then
+ Activator.log.log(e.getStatus());
+ }
+ }
+ }
+ }
+ }
+
+ private List<IndexRecord> loadStore(InputStream storeInput) throws IOException {
+ List<IndexRecord> result = Collections.emptyList();
+
+ try (InputStream outer = storeInput; ObjectInputStream input = createObjectInput(outer)) {
+ // Load the version. So far, we're at the first version
+ long version = input.readLong();
+ if (version != INDEX_RECORD_SERIAL_VERSION) {
+ throw new IOException("Unexpected index record serial version " + version); //$NON-NLS-1$
+ }
+
+ // Read the number of records
+ int count = input.readInt();
+ result = new ArrayList<>(count);
+
+ // Read the records
+ for (int i = 0; i < count; i++) {
+ try {
+ result.add(readIndexRecord(input));
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private IndexRecord readIndexRecord(ObjectInput in) throws IOException, ClassNotFoundException {
+ // Load the file
+ IPath path = new Path((String) in.readObject());
+ IFile file = wsRoot.getFile(path);
+
+ // Load the index data
+ @SuppressWarnings("unchecked")
+ T index = (T) in.readObject();
+
+ return new IndexRecord(file, index);
+ }
+
+ private IIndexSaveParticipant createSaveParticipant() {
+ return new IIndexSaveParticipant() {
+ @Override
+ public void save(WorkspaceModelIndex<?> index, OutputStream storeOutput) throws IOException, CoreException {
+ if (index == WorkspaceModelIndex.this) {
+ List<IndexRecord> store;
+
+ synchronized (index) {
+ store = index.index.values().stream()
+ .filter(IResource::isAccessible)
+ .map(f -> {
+ IndexRecord result = null;
+
+ try {
+ @SuppressWarnings("unchecked")
+ IndexRecord __ = (IndexRecord) f.getSessionProperty(getIndexKey());
+ result = __;
+ } catch (CoreException e) {
+ // Doesn't matter; we'll just index it next time
+ Activator.log.log(e.getStatus());
+ }
+
+ return result;
+ })
+ .collect(Collectors.toList());
+ }
+
+ saveStore(store, storeOutput);
+ }
+ }
+ };
+ }
+
+ private void saveStore(List<IndexRecord> store, OutputStream storeOutput) throws IOException {
+ try (ObjectOutputStream output = new ObjectOutputStream(storeOutput)) {
+ // Write the version
+ output.writeLong(INDEX_RECORD_SERIAL_VERSION);
+
+ // Write the number of records
+ output.writeInt(store.size());
+
+ // Write the records
+ for (IndexRecord next : store) {
+ writeIndexRecord(next, output);
+ }
+ }
+ }
+
+ private void writeIndexRecord(IndexRecord record, ObjectOutput out) throws IOException {
+ out.writeObject(record.file.getFullPath().toPortableString());
+ out.writeObject(record.index);
+ }
+
+ /**
+ * Obtains the name of this index.
+ *
+ * @return my name
+ * @since 2.1
+ */
+ public final String getName() {
+ return indexName;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("WorkspaceModelIndex(%s)", getName()); //$NON-NLS-1$
+ }
+
+ /**
+ * Obtains an asynchronous future result that is scheduled to run after any pending indexing work has completed.
+ * The {@code function} is <em>not</em> invoked under synchronization on the index; it is passed a copy of the
+ * last consistent state of the index after any pending calculations have completed.
+ *
+ * @param function
+ * the function to schedule. Its input is the complete index map
+ *
+ * @return the future result of the function applied to the index
+ */
+ public <V> ListenableFuture<V> afterIndex(final Function<? super Map<IFile, T>, V> function) {
+ return Futures.transform(getIndex(), function);
+ }
+
+ /**
+ * Obtains an asynchronous future result that is scheduled to run after any
+ * pending indexing work has completed. The {@code callable} is invoked under
+ * synchronization on the index, so it must be careful about how it
+ * synchronizes on other objects to avoid deadlocks.
+ *
+ * @param callable
+ * the operation to schedule
+ *
+ * @return the future result of the operation
+ */
+ @Override
+ public <V> ListenableFuture<V> afterIndex(Callable<V> callable) {
+ return super.afterIndex(() -> {
+ synchronized (index) {
+ return callable.call();
+ }
+ });
+ }
+
+ @Override
+ public final <V> V ifAvailable(Callable<V> callable) throws CoreException {
+ return super.ifAvailable(callable);
+ }
+
+ /**
+ * Schedules an operation to run after any pending indexing work has completed.
+ * The {@code runnable} is invoked under synchronization on the index, so it must be careful about how it
+ * synchronizes on other objects to avoid deadlocks.
+ *
+ * @param runnable
+ * the operation to schedule
+ */
+ public void afterIndex(final Runnable runnable) {
+ afterIndex(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ runnable.run();
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Obtains the index when it is ready.
+ *
+ * @return the future value of the index, when it is ready
+ */
+ public ListenableFuture<Map<IFile, T>> getIndex() {
+ return afterIndex(new Callable<Map<IFile, T>>() {
+ @Override
+ public Map<IFile, T> call() {
+ return map();
+ }
+ });
+ }
+
+ /**
+ * @precondition The {@link #index} monitor is held.
+ */
+ private Map<IFile, T> map() {
+ ImmutableMap.Builder<IFile, T> result = ImmutableMap.builder();
+
+ for (IFile next : index.values()) {
+ try {
+ @SuppressWarnings("unchecked")
+ IndexRecord record = (IndexRecord) next.getSessionProperty(getIndexKey());
+ if (record != null) {
+ result.put(next, record.index);
+ }
+ } catch (CoreException e) {
+ Activator.log.error("Failed to access index data for file " + next.getFullPath(), e); //$NON-NLS-1$
+ }
+ }
+
+ return result.build();
+ }
+
+ /**
+ * @since 2.1
+ */
+ @Override
+ protected final void process(IFile file) throws CoreException {
+ IProject project = file.getProject();
+ if (match(file)) {
+ @SuppressWarnings("unchecked")
+ IndexRecord record = (IndexRecord) file.getSessionProperty(getIndexKey());
+ if ((record == null) || record.isObsolete()) {
+ add(project, file);
+ } else if (pIndexer == null) {
+ // No persistence support? Fine, then recompute
+ add(project, file);
+ } else {
+ // If it's not obsolete, then we're loading it from persistent storage
+ init(project, file, record);
+ }
+ } else {
+ remove(project, file);
+ }
+ }
+
+ /**
+ * @since 2.1
+ */
+ @Override
+ protected final boolean match(IFile file) {
+ boolean result = false;
+
+ // Don't even attempt to match the content type if the file extension doesn't match.
+ // And if it's not synchronized, don't attempt to do anything with it. We'll get it
+ // later when it is synchronized
+ if (file.isAccessible()
+ && ((fileExtensions == null) || fileExtensions.contains(file.getFileExtension()))
+ && file.isSynchronized(IResource.DEPTH_ZERO)) {
+
+ IContentType[] contentTypes = getContentTypes(file);
+ if (contentTypes != null) {
+ for (int i = 0; (i < contentTypes.length) && !result; i++) {
+ result = contentTypes[i].isKindOf(contentType);
+ }
+ }
+ }
+
+ // Let the indexer apply its own criteria if the standard filters don't match
+ result = result && indexer.shouldIndex(file);
+
+ return result;
+ }
+
+ void init(IProject project, IFile file, IndexRecord record) throws CoreException {
+ if (isTracing()) {
+ detailf(TRACE_INDEXER_FILES,
+ "Loading initial index %s for %s", getIndexKey().getLocalName(), file.getFullPath()); //$NON-NLS-1$
+ }
+
+ if (pIndexer.load(file, record.index)) {
+ synchronized (index) {
+ index.put(project, file);
+ file.setSessionProperty(getIndexKey(), record);
+ }
+ }
+ }
+
+ void add(IProject project, IFile file) throws CoreException {
+ if (isTracing()) {
+ detailf(TRACE_INDEXER_FILES,
+ "Computing index %s for %s", getIndexKey().getLocalName(), file.getFullPath()); //$NON-NLS-1$
+ }
+
+ T data = indexer.index(file);
+ synchronized (index) {
+ index.put(project, file);
+ file.setSessionProperty(getIndexKey(), new IndexRecord(file, data));
+ }
+ }
+
+ /**
+ * @since 2.1
+ */
+ @Override
+ protected final void remove(IProject project, IFile file) throws CoreException {
+ boolean unindex;
+
+ synchronized (index) {
+ // Don't need to do any work on the index data if
+ // this wasn't in the index in the first place
+ unindex = index.remove(project, file);
+ }
+
+ if (unindex) {
+ try {
+ indexer.unindex(file);
+ } finally {
+ if (file.exists()) {
+ file.setSessionProperty(getIndexKey(), null);
+ }
+ }
+ }
+ }
+
+ /**
+ * @since 2.1
+ */
+ @Override
+ protected final void remove(IProject project) throws CoreException {
+ Set<IFile> files;
+
+ synchronized (index) {
+ files = index.containsKey(project)
+ ? index.removeAll(project)
+ : null;
+ }
+
+ if (files != null) {
+ files.forEach(indexer::unindex);
+ }
+ }
+
+ @Override
+ protected boolean hasIndex(IProject project) {
+ synchronized (index) {
+ return index.containsKey(project);
+ }
+ }
+
+ public void addListener(IWorkspaceModelIndexListener listener) {
+ Futures.addCallback(getManager(), new FutureCallback<IndexManager>() {
+ @Override
+ public void onSuccess(IndexManager result) {
+ result.addListener(WorkspaceModelIndex.this, listener);
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ // Don't need a listener
+ }
+ });
+ }
+
+ public void removeListener(IWorkspaceModelIndexListener listener) {
+ Futures.addCallback(getManager(), new FutureCallback<IndexManager>() {
+ @Override
+ public void onSuccess(IndexManager result) {
+ result.removeListener(WorkspaceModelIndex.this, listener);
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ // Couldn't have added the listener anyways
+ }
+ });
+ }
+
+ //
+ // Nested types
+ //
+
+ /**
+ * Callback interface for the index client to update the index.
+ */
+ public static interface IndexHandler<T> {
+ /**
+ * Updates the index for a file that matches our selection criteria.
+ *
+ * @param file
+ * a file that exists and matches the index selection criteria
+ *
+ * @return the object to store in the index for this {@code file}
+ */
+ T index(IFile file);
+
+ /**
+ * Updates the index for a file that no longer exists or no longer matches our selection criteria.
+ *
+ * @param file
+ * a file that no longer exists or otherwise no longer matches our selection criteria. It is removed from the index
+ */
+ void unindex(IFile file);
+
+ /**
+ * Queries whether a give {@code file} should be indexed.
+ * The default implementation just returns {@code true}, always.
+ *
+ * @param file
+ * a file proposed for indexing
+ * @return whether the file should be indexed
+ *
+ * @since 3.0
+ */
+ default boolean shouldIndex(IFile file) {
+ return true;
+ }
+ }
+
+ /**
+ * Extension interface for index handlers that provide persistable index
+ * data associated with each file. This enables storage of the index in
+ * the workspace metadata for quick initialization on start-up, requiring
+ * re-calculation of the index only for files that were changed since the
+ * workspace was last closed.
+ *
+ * @param <T>
+ * the index data store type, which must be {@link Serializable}
+ * @since 2.1
+ */
+ public static interface PersistentIndexHandler<T> extends IndexHandler<T> {
+ /**
+ * Initializes the {@code index} data for a file from the persistent store.
+ *
+ * @param file
+ * a file in the workspace
+ * @param index
+ * its previously stored index
+ *
+ * @return whether the {@code index} data were successfully integrated.
+ * A {@code false} result indicates that the file must be indexed
+ * from scratch
+ */
+ boolean load(IFile file, T index);
+ }
+
+ private final class IndexRecord {
+ private IFile file;
+ private long generation;
+ private T index;
+
+ IndexRecord(IFile file, T index) {
+ super();
+
+ this.file = file;
+ this.generation = file.getModificationStamp();
+ this.index = index;
+ }
+
+ boolean isObsolete() {
+ return file.getModificationStamp() != generation;
+ }
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
index 3040faed3b5..e36fa4bb3e1 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
@@ -1,56 +1,56 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.emf.utils;
-
-
-/**
- * This class allows to retrieve the business object from an object representing
- * a graphical artifact in a diagram. Each diagram can register its resolver
- * which will be added to the list of resolvers. Some common resolvers are
- * already registered : gef.EditPart TODO Use extensions to register additional
- * resolvers.
- */
-// Refactoring 0.10: This class has been moved from infra.core to infra.emf.
-// It should be re-implemented as a Service.
-public class BusinessModelResolver {
-
- /**
- * The unique instance
- */
- public static final BusinessModelResolver instance = new BusinessModelResolver();
-
- public BusinessModelResolver() {
-
- }
-
- /**
- * Get the business object associated to this object, if any. This method
- * navigate throw the object if the object is an graphical artefact or a
- * diagram artifact.
- *
- * @param object
- * @return Object
- */
- public Object getBusinessModel(Object object) {
- return EMFHelper.getEObject(object);
- }
-
- /**
- * @return BusinessModelResolver
- */
- public static BusinessModelResolver getInstance() {
- return instance;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2008 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.emf.utils;
+
+
+/**
+ * This class allows to retrieve the business object from an object representing
+ * a graphical artifact in a diagram. Each diagram can register its resolver
+ * which will be added to the list of resolvers. Some common resolvers are
+ * already registered : gef.EditPart TODO Use extensions to register additional
+ * resolvers.
+ */
+// Refactoring 0.10: This class has been moved from infra.core to infra.emf.
+// It should be re-implemented as a Service.
+public class BusinessModelResolver {
+
+ /**
+ * The unique instance
+ */
+ public static final BusinessModelResolver instance = new BusinessModelResolver();
+
+ public BusinessModelResolver() {
+
+ }
+
+ /**
+ * Get the business object associated to this object, if any. This method
+ * navigate throw the object if the object is an graphical artefact or a
+ * diagram artifact.
+ *
+ * @param object
+ * @return Object
+ */
+ public Object getBusinessModel(Object object) {
+ return EMFHelper.getEObject(object);
+ }
+
+ /**
+ * @return BusinessModelResolver
+ */
+ public static BusinessModelResolver getInstance() {
+ return instance;
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
index d8d4217066d..f15a88029a9 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
@@ -1,35 +1,35 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * A class for comparing EClasses by name
- *
- * @author Camille Letavernier
- *
- */
-public class EClassNameComparator implements Comparator<EClass> {
-
- public int compare(EClass class1, EClass class2) {
- if (class1 == null) {
- return class2 == null ? 0 : -1;
- }
-
- return Collator.getInstance().compare(class1.getName(), class2.getName());
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import java.text.Collator;
+import java.util.Comparator;
+
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * A class for comparing EClasses by name
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class EClassNameComparator implements Comparator<EClass> {
+
+ public int compare(EClass class1, EClass class2) {
+ if (class1 == null) {
+ return class2 == null ? 0 : -1;
+ }
+
+ return Collator.getInstance().compare(class1.getName(), class2.getName());
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
index e1335d945bb..91fd63190bf 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
@@ -1,39 +1,39 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-/**
- * Thyis class defines some useful constants for EMF
- *
- * @author Vincent Lorenzo
- *
- */
-public class EMFContants {
-
-
- private EMFContants() {
- // to prevent instanciation
- }
-
- public static final String ESTRING = "EString";
-
- public static final String EBOOLEAN = "EBoolean";
-
- public static final String EINT = "EInt";
-
- public static final String EDOUBLE = "EDouble";
-
- public static final String EENUM_LITERAL = "EENumLiteral";
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+/**
+ * Thyis class defines some useful constants for EMF
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class EMFContants {
+
+
+ private EMFContants() {
+ // to prevent instanciation
+ }
+
+ public static final String ESTRING = "EString";
+
+ public static final String EBOOLEAN = "EBoolean";
+
+ public static final String EINT = "EInt";
+
+ public static final String EDOUBLE = "EDouble";
+
+ public static final String EENUM_LITERAL = "EENumLiteral";
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
index 5acd8eeb22d..2e67c072e8c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
@@ -1,104 +1,104 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tessier (CEA LIST) - Initial API and implementation
- /*****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.papyrus.infra.emf.Activator;
-
-//TODO
-public class EMFFileUtil {
-
- /*
- * Returns the path to the IFile (Encoded)
- *
- * @param file
- *
- * @return
- */
- public static String getPath(IFile file) {
- URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
-
- // ToString, toPlatformString
- return uri.toString();
- }
-
- /*
- * Returns the IFile (Workspace file) from the given location.
- * The location may be either absolute (From the FileSystem) or
- * relative to the workspace root.
- *
- * @param location
- *
- * @return
- */
- public static IFile getIFile(String location) {
- URI uri = URI.createURI(location);
- IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
-
- // Search the file in the workspace
- if (uri.isPlatform()) {
- Path workspacePath = new Path(uri.toPlatformString(true));
- return workspace.getFile(workspacePath);
- } else { // Then search it on the disk
- Path absolutePath = new Path(URI.decode(location));
- return workspace.getFileForLocation(absolutePath);
- }
- }
-
- /*
- * Returns the Java File from the given location.
- * The location may be either absolute (From the FileSystem) or
- * relative to the workspace root.
- *
- * @param location
- *
- * @return
- */
- public static File getFile(String location) {
- IFile iFile = getIFile(location);
- if (iFile == null || !iFile.exists()) {
- return new File(location);
- }
-
- return new File(iFile.getLocationURI());
- }
-
- /*
- * Returns the Java File from the given location.
- * The location is relative to the workspace root.
- *
- * @param location
- *
- * @return
- */
- public static File getWorkspaceFile(String location) {
- IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
- IPath path = new Path(location);
- IFile currentFile = null;
- try {
- currentFile = workspace.getFile(path);
- } catch (IllegalArgumentException ex) {
- Activator.log.error(ex);
- return null;
- }
-
- return currentFile.getLocation().toFile();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ /*****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.infra.emf.Activator;
+
+//TODO
+public class EMFFileUtil {
+
+ /*
+ * Returns the path to the IFile (Encoded)
+ *
+ * @param file
+ *
+ * @return
+ */
+ public static String getPath(IFile file) {
+ URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
+
+ // ToString, toPlatformString
+ return uri.toString();
+ }
+
+ /*
+ * Returns the IFile (Workspace file) from the given location.
+ * The location may be either absolute (From the FileSystem) or
+ * relative to the workspace root.
+ *
+ * @param location
+ *
+ * @return
+ */
+ public static IFile getIFile(String location) {
+ URI uri = URI.createURI(location);
+ IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
+
+ // Search the file in the workspace
+ if (uri.isPlatform()) {
+ Path workspacePath = new Path(uri.toPlatformString(true));
+ return workspace.getFile(workspacePath);
+ } else { // Then search it on the disk
+ Path absolutePath = new Path(URI.decode(location));
+ return workspace.getFileForLocation(absolutePath);
+ }
+ }
+
+ /*
+ * Returns the Java File from the given location.
+ * The location may be either absolute (From the FileSystem) or
+ * relative to the workspace root.
+ *
+ * @param location
+ *
+ * @return
+ */
+ public static File getFile(String location) {
+ IFile iFile = getIFile(location);
+ if (iFile == null || !iFile.exists()) {
+ return new File(location);
+ }
+
+ return new File(iFile.getLocationURI());
+ }
+
+ /*
+ * Returns the Java File from the given location.
+ * The location is relative to the workspace root.
+ *
+ * @param location
+ *
+ * @return
+ */
+ public static File getWorkspaceFile(String location) {
+ IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
+ IPath path = new Path(location);
+ IFile currentFile = null;
+ try {
+ currentFile = workspace.getFile(path);
+ } catch (IllegalArgumentException ex) {
+ Activator.log.error(ex);
+ return null;
+ }
+
+ return currentFile.getLocation().toFile();
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
index 36bb8a4ea08..c41f2f65b82 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
@@ -1,35 +1,35 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.ENamedElement;
-
-/**
- *
- * A comparator for ENamedElement
- *
- */
-public class ENamedElementComparator implements Comparator<ENamedElement> {
-
- public int compare(final ENamedElement namedElement1, final ENamedElement namedElement2) {
- if (namedElement1 == null) {
- return namedElement2 == null ? 0 : -1;
- }
-
- return Collator.getInstance().compare(namedElement1.getName(), namedElement2.getName());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import java.text.Collator;
+import java.util.Comparator;
+
+import org.eclipse.emf.ecore.ENamedElement;
+
+/**
+ *
+ * A comparator for ENamedElement
+ *
+ */
+public class ENamedElementComparator implements Comparator<ENamedElement> {
+
+ public int compare(final ENamedElement namedElement1, final ENamedElement namedElement2) {
+ if (namedElement1 == null) {
+ return namedElement2 == null ? 0 : -1;
+ }
+
+ return Collator.getInstance().compare(namedElement1.getName(), namedElement2.getName());
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
index 824035a5849..81d11797493 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
@@ -1,51 +1,51 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-
-public class HistoryUtil {
-
- /**
- * Returns a String identifying the History of selected values for the given object/feature
- *
- * The HistoryID is scoped to a Resource (If editedObject has one)
- *
- * @param editedObject
- * @param feature
- * @return
- */
- public static String getHistoryID(EObject editedObject, EStructuralFeature feature) {
- return getHistoryID(editedObject, feature, "");
- }
-
- /**
- * Returns a String identifying the History of selected values for the given object/feature,
- * and prepends the given prefix
- *
- * The HistoryID is scoped to a Resource (If editedObject has one)
- *
- * @param editedObject
- * @param feature
- * @return
- */
- public static String getHistoryID(EObject editedObject, EStructuralFeature feature, String prefix) {
- // return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
- if (editedObject == null || editedObject.eResource() == null) {
- return String.format("history_%s_%s:%s", prefix, EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return String.format("history_%s_%s:%s:%s", prefix, editedObject.eResource().getURI(), EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+
+public class HistoryUtil {
+
+ /**
+ * Returns a String identifying the History of selected values for the given object/feature
+ *
+ * The HistoryID is scoped to a Resource (If editedObject has one)
+ *
+ * @param editedObject
+ * @param feature
+ * @return
+ */
+ public static String getHistoryID(EObject editedObject, EStructuralFeature feature) {
+ return getHistoryID(editedObject, feature, "");
+ }
+
+ /**
+ * Returns a String identifying the History of selected values for the given object/feature,
+ * and prepends the given prefix
+ *
+ * The HistoryID is scoped to a Resource (If editedObject has one)
+ *
+ * @param editedObject
+ * @param feature
+ * @return
+ */
+ public static String getHistoryID(EObject editedObject, EStructuralFeature feature, String prefix) {
+ // return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
+ if (editedObject == null || editedObject.eResource() == null) {
+ return String.format("history_%s_%s:%s", prefix, EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return String.format("history_%s_%s:%s:%s", prefix, editedObject.eResource().getURI(), EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
index e9d8e12815d..f9f6403c78e 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
@@ -1,62 +1,62 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 Cedric Dumoulin, 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * This AdapterFactory is used to attach a reference on the ServiceRegiqtry to an EMF ResourceSet.
- *
- * This adapterFactory is not a real factory: no adapter is created.
- *
- * @author cedric dumoulin
- *
- * @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry.
- */
-@Deprecated
-public class ServiceRegistryAdapterFactory extends AdapterFactoryImpl {
-
- /**
- * ID used to register the factory in the ResourceSet.
- */
- static final public String TYPE_ID = ServiceRegistryAdapterFactory.class.getName() + "TypeId";
-
- /**
- * The reference to the ServiceRegistry.
- */
- protected ServicesRegistry servicesRegistry;
-
- /**
- * @param servicesRegistry
- */
- public ServiceRegistryAdapterFactory(ServicesRegistry servicesRegistry) {
- this.servicesRegistry = servicesRegistry;
- }
-
- /**
- *
- * @return the associated {@link ServicesRegistry}
- */
- public ServicesRegistry getServicesRegistry() {
- return servicesRegistry;
- }
-
- @Override
- public boolean isFactoryForType(Object type) {
- return type.equals(TYPE_ID);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 Cedric Dumoulin, 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * This AdapterFactory is used to attach a reference on the ServiceRegiqtry to an EMF ResourceSet.
+ *
+ * This adapterFactory is not a real factory: no adapter is created.
+ *
+ * @author cedric dumoulin
+ *
+ * @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry.
+ */
+@Deprecated
+public class ServiceRegistryAdapterFactory extends AdapterFactoryImpl {
+
+ /**
+ * ID used to register the factory in the ResourceSet.
+ */
+ static final public String TYPE_ID = ServiceRegistryAdapterFactory.class.getName() + "TypeId";
+
+ /**
+ * The reference to the ServiceRegistry.
+ */
+ protected ServicesRegistry servicesRegistry;
+
+ /**
+ * @param servicesRegistry
+ */
+ public ServiceRegistryAdapterFactory(ServicesRegistry servicesRegistry) {
+ this.servicesRegistry = servicesRegistry;
+ }
+
+ /**
+ *
+ * @return the associated {@link ServicesRegistry}
+ */
+ public ServicesRegistry getServicesRegistry() {
+ return servicesRegistry;
+ }
+
+ @Override
+ public boolean isFactoryForType(Object type) {
+ return type.equals(TYPE_ID);
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
index a3a98b5a0fe..8a928da8cdf 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
@@ -1,74 +1,74 @@
-/*****************************************************************************
- * Copyright (c) 2012, 2014 Cedric Dumoulin, 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.IService;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-
-/**
- * This service register inside the ResourceSet an AdapterFactory referencing the ServiceRegistry.
- * This will allows to get the ServicesRegistry from any EMF object (see {@link ServiceUtilsForResource}.
- * The AdapterFactory can't provide Adapters. It is only used to hold a reference on the ServiceRegistry.
- *
- * This service depends on the ModelSet service.
- *
- *
- * @see ServiceRegistryAdapterFactory
- * @see ServiceUtilsForResource
- *
- * @author cedric dumoulin
- *
- * @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry
- * and an injected {@link ModelSet} has an external service lifecycle adapter provided for it.
- */
-@Deprecated
-public class ServiceUtilsForResourceInitializerService implements IService {
-
- ServicesRegistry servicesRegistry;
-
- /**
- * Associate the service registry with the resource set if the resource set wasn't created by the registry.
- */
- public void init(ServicesRegistry servicesRegistry) throws ServiceException {
-
- this.servicesRegistry = servicesRegistry;
- ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
-
- ModelSetServiceFactory.setServiceRegistry(modelSet, servicesRegistry);
- }
-
- public void startService() throws ServiceException {
- // Do nothing
- }
-
- /**
- * Ensure that the service registry is dissociated from the resource set.
- */
- public void disposeService() throws ServiceException {
- try {
- ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
-
- ModelSetServiceFactory.setServiceRegistry(modelSet, null);
- } catch (BadStateException e) {
- // ModelSet is already disposed. Do nothing
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2012, 2014 Cedric Dumoulin, 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.IService;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+
+/**
+ * This service register inside the ResourceSet an AdapterFactory referencing the ServiceRegistry.
+ * This will allows to get the ServicesRegistry from any EMF object (see {@link ServiceUtilsForResource}.
+ * The AdapterFactory can't provide Adapters. It is only used to hold a reference on the ServiceRegistry.
+ *
+ * This service depends on the ModelSet service.
+ *
+ *
+ * @see ServiceRegistryAdapterFactory
+ * @see ServiceUtilsForResource
+ *
+ * @author cedric dumoulin
+ *
+ * @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry
+ * and an injected {@link ModelSet} has an external service lifecycle adapter provided for it.
+ */
+@Deprecated
+public class ServiceUtilsForResourceInitializerService implements IService {
+
+ ServicesRegistry servicesRegistry;
+
+ /**
+ * Associate the service registry with the resource set if the resource set wasn't created by the registry.
+ */
+ public void init(ServicesRegistry servicesRegistry) throws ServiceException {
+
+ this.servicesRegistry = servicesRegistry;
+ ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
+
+ ModelSetServiceFactory.setServiceRegistry(modelSet, servicesRegistry);
+ }
+
+ public void startService() throws ServiceException {
+ // Do nothing
+ }
+
+ /**
+ * Ensure that the service registry is dissociated from the resource set.
+ */
+ public void disposeService() throws ServiceException {
+ try {
+ ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
+
+ ModelSetServiceFactory.setServiceRegistry(modelSet, null);
+ } catch (BadStateException e) {
+ // ModelSet is already disposed. Do nothing
+ }
+ }
+
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
index 6fcca922d2c..9a5c76e5f65 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
@@ -1,61 +1,61 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.commands.UnsetCommand;
-
-/**
- *
- * This class allows to do unset on a feature using a command
- *
- */
-public class TransactionalUnsetter {
-
-
- /**
- * the source eobject
- */
- private final Command cmd;
-
- /**
- * the editing domain used for the command
- */
-
- private final TransactionalEditingDomain domain;
-
- /**
- *
- * Constructor.
- *
- * @param source
- * the eobject to modify
- * @param feature
- * the feature on which we want to do an unset
- */
- public TransactionalUnsetter(final EObject source, final EStructuralFeature feature) {
- domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(source);
- cmd = new UnsetCommand(domain, source, feature);
- }
-
- /**
- * this method do the unset
- */
- public void doUnset() {
- domain.getCommandStack().execute(cmd);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.utils;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.emf.commands.UnsetCommand;
+
+/**
+ *
+ * This class allows to do unset on a feature using a command
+ *
+ */
+public class TransactionalUnsetter {
+
+
+ /**
+ * the source eobject
+ */
+ private final Command cmd;
+
+ /**
+ * the editing domain used for the command
+ */
+
+ private final TransactionalEditingDomain domain;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ * the eobject to modify
+ * @param feature
+ * the feature on which we want to do an unset
+ */
+ public TransactionalUnsetter(final EObject source, final EStructuralFeature feature) {
+ domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(source);
+ cmd = new UnsetCommand(domain, source, feature);
+ }
+
+ /**
+ * this method do the unset
+ */
+ public void doUnset() {
+ domain.getCommandStack().execute(cmd);
+ }
+}

Back to the top