[499618] [Activity Explorer] Migration to Sirius 4.1
Bug: 499618
Change-Id: Ibea0cfd044637f6a0bd8ed14617abfc199f8a813
Signed-off-by: Faycal Abka <faycal.abka@altran.com>
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneAction.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneAction.java
index b7d1590..dea4c7e 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneAction.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneAction.java
@@ -22,6 +22,7 @@
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -31,7 +32,7 @@
/**
* Latest selection of representations.
*/
- private Collection<DRepresentation> _representations;
+ private Collection<DRepresentationDescriptor> _representationDescriptors;
/**
* Common viewer reminder.
@@ -52,21 +53,21 @@
* @param selectedElements_p
* A list of selected elements.
* @return A not <code>null</code> (possibly empty) collection of
- * representations.
+ * representations descriptor.
*/
- protected Collection<DRepresentation> getSelectedRepresentations(List<?> selectedElements_p) {
+ protected Collection<DRepresentationDescriptor> getSelectedRepresentations(List<?> selectedElements_p) {
// Resulting collection.
- Collection<DRepresentation> result = null;
+ Collection<DRepresentationDescriptor> result = null;
// Cycle through selected elements.
for (Object element : selectedElements_p) {
// Got a representation, store it.
- if (element instanceof DRepresentation) {
+ if (element instanceof DRepresentationDescriptor) {
// Lazy initialization.
if (null == result) {
- result = new ArrayList<DRepresentation>(1);
+ result = new ArrayList<DRepresentationDescriptor>(1);
}
// Add representation.
- result.add((DRepresentation) element);
+ result.add((DRepresentationDescriptor) element);
}
}
// Do not return a null collection.
@@ -81,7 +82,7 @@
*/
@Override
public void run() {
- CloneDiagramCommand command = new CloneDiagramCommand(_representations);
+ CloneDiagramCommand command = new CloneDiagramCommand(_representationDescriptors);
// Add a listener that refreshes the model explorer during
// execution/undo/redo operations.
command.addCloneListener(new ICloneListener() {
@@ -134,7 +135,7 @@
// recording command implementation.
// Thus is more adequate to execute it against the command stack
// directly, rather than use the default behavior.
- TransactionUtil.getEditingDomain(_representations.iterator().next()).getCommandStack().execute(command);
+ TransactionUtil.getEditingDomain(_representationDescriptors.iterator().next()).getCommandStack().execute(command);
}
/**
@@ -143,9 +144,9 @@
@Override
protected boolean updateSelection(IStructuredSelection selection_p) {
List<?> selectedElements = selection_p.toList();
- _representations = getSelectedRepresentations(selectedElements);
+ _representationDescriptors = getSelectedRepresentations(selectedElements);
// Enable action only if all selected elements are representations.
int size = selectedElements.size();
- return (size > 0) && (size == _representations.size());
+ return (size > 0) && (size == _representationDescriptors.size());
}
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneDiagramCommand.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneDiagramCommand.java
index 5dc1111..3c18b65 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneDiagramCommand.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/CloneDiagramCommand.java
@@ -28,7 +28,9 @@
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
+import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
/**
* A command thats clone specified representations.<br>
@@ -37,243 +39,249 @@
*
*/
public class CloneDiagramCommand extends AbstractCommand {
- /**
- * The representations to clone.
- */
- private Collection<DRepresentation> _representations;
- /**
- * Cloned representations.
- */
- private Collection<DRepresentation> _clones;
- /**
- * Clone life cycle listeners.
- */
- private Collection<ICloneListener> _listeners;
+ /**
+ * The representations to clone.
+ */
+ private Collection<DRepresentationDescriptor> _representationDescriptors;
- /**
- * Constructor.
- *
- * @param representations_p
- */
- public CloneDiagramCommand(Collection<DRepresentation> representations_p) {
- super(Messages.CloneDiagramCommand_0);
- _representations = representations_p;
- }
+ /**
+ * Cloned representations.
+ */
+ private Collection<DRepresentation> _clones;
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#dispose()
- */
- @Override
- public void dispose() {
- super.dispose();
- if (null != _clones) {
- _clones.clear();
- _clones = null;
- }
- if (null != _listeners) {
- _listeners.clear();
- _listeners = null;
- }
- if (null != _representations) {
- _representations = null;
- }
- }
+ /**
+ * Clone life cycle listeners.
+ */
+ private Collection<ICloneListener> _listeners;
- /**
- * Add a clone life cycle listener.
- *
- * @param listener_p
- */
- public void addCloneListener(ICloneListener listener_p) {
- if (null == listener_p) {
- return;
- }
- // Lazy allocation.
- if (null == _listeners) {
- _listeners = new HashSet<ICloneListener>(1);
- }
- // Add listener.
- _listeners.add(listener_p);
- }
+ /**
+ * Constructor.
+ *
+ * @param representations_p
+ */
+ public CloneDiagramCommand(Collection<DRepresentationDescriptor> representations_p) {
+ super(Messages.CloneDiagramCommand_0);
+ _representationDescriptors = representations_p;
+ }
- /**
- * Remove a registered clone life cycle listener.
- *
- * @param listener_p
- */
- public void removeCloneListener(ICloneListener listener_p) {
- if ((null == _listeners) || (null == listener_p)) {
- return;
- }
- // Remove listener.
- _listeners.remove(listener_p);
- }
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#dispose()
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (null != _clones) {
+ _clones.clear();
+ _clones = null;
+ }
+ if (null != _listeners) {
+ _listeners.clear();
+ _listeners = null;
+ }
+ if (null != _representationDescriptors) {
+ _representationDescriptors = null;
+ }
+ }
- /**
- * Send clone life cycle event.
- *
- * @param type_p
- * @param clone_p
- * @param session_p
- */
- protected void notifyListeners(EventType type_p, DRepresentation clone_p, Session session_p) {
- if ((null == _listeners) || _listeners.isEmpty()) {
- return;
- }
- // Clone listeners collection.
- ArrayList<ICloneListener> listeners = new ArrayList<ICloneListener>(_listeners);
- // Call listeners.
- for (ICloneListener listener : listeners) {
- try {
- if (EventType.ADD.equals(type_p)) {
- listener.cloneCreated(clone_p, session_p);
- } else if (EventType.REMOVE.equals(type_p)) {
- listener.cloneAboutToBeRemoved(clone_p, session_p);
- }
- } catch (Exception exception_p) {
- ActivityExplorerLoggerService.getInstance().log(IStatus.ERROR, "Unable to notify listeners !", exception_p);
- }
- }
- }
+ /**
+ * Add a clone life cycle listener.
+ *
+ * @param listener_p
+ */
+ public void addCloneListener(ICloneListener listener_p) {
+ if (null == listener_p) {
+ return;
+ }
+ // Lazy allocation.
+ if (null == _listeners) {
+ _listeners = new HashSet<ICloneListener>(1);
+ }
+ // Add listener.
+ _listeners.add(listener_p);
+ }
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
- */
- @Override
- public boolean canUndo() {
- return (null != _clones) && (_clones.size() > 0);
- }
+ /**
+ * Remove a registered clone life cycle listener.
+ *
+ * @param listener_p
+ */
+ public void removeCloneListener(ICloneListener listener_p) {
+ if ((null == _listeners) || (null == listener_p)) {
+ return;
+ }
+ // Remove listener.
+ _listeners.remove(listener_p);
+ }
- /**
- * @see org.eclipse.emf.common.command.Command#execute()
- */
- public void execute() {
- // Initialize clones list.
- if (null == _clones) {
- _clones = new ArrayList<DRepresentation>(0);
- } else {
- // Ensure emptiness.
- if (_clones.size() > 0) {
- _clones.clear();
- }
- }
- // Copy all representations.
- for (DRepresentation representation : _representations) {
- if (representation instanceof DSemanticDecorator) {
- // Get target semantic element.
- EObject target = ((DSemanticDecorator) representation).getTarget();
- // Get session.
- Session session = SessionManager.INSTANCE.getSession(target);
- // Copy representation.
- DRepresentation copyRepresentation = DialectManager.INSTANCE.copyRepresentation(representation,
- getCloneName(representation, session), session, null);
- // Retain copied reference.
- _clones.add(copyRepresentation);
- // Notify listeners.
- // S0024665 Not sure that is really needed as viewer has been
- // already notified through the session
- // notifyListeners(EventType.ADD, copyRepresentation, session);
- } else {
+ /**
+ * Send clone life cycle event.
+ *
+ * @param type_p
+ * @param clone_p
+ * @param session_p
+ */
+ protected void notifyListeners(EventType type_p, DRepresentation clone_p, Session session_p) {
+ if ((null == _listeners) || _listeners.isEmpty()) {
+ return;
+ }
+ // Clone listeners collection.
+ ArrayList<ICloneListener> listeners = new ArrayList<ICloneListener>(_listeners);
+ // Call listeners.
+ for (ICloneListener listener : listeners) {
+ try {
+ if (EventType.ADD.equals(type_p)) {
+ listener.cloneCreated(clone_p, session_p);
+ } else if (EventType.REMOVE.equals(type_p)) {
+ listener.cloneAboutToBeRemoved(clone_p, session_p);
+ }
+ } catch (Exception exception_p) {
+ ActivityExplorerLoggerService.getInstance().log(IStatus.ERROR, "Unable to notify listeners !", exception_p);
+ }
+ }
+ }
- ActivityExplorerActivator
- .getDefault()
- .getLog()
- .log(new Status(IStatus.WARNING, ActivityExplorerActivator.ID,
- "Clone is not supported for " + representation.getName())); //$NON-NLS-1$
- }
- }
- }
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#canUndo()
+ */
+ @Override
+ public boolean canUndo() {
+ return (null != _clones) && (_clones.size() > 0);
+ }
- /**
- * Get clone name for specified representation.
- *
- * @param representation_p
- * @return
- */
- protected String getCloneName(DRepresentation representation_p, Session session_p) {
- String message = "Clone {0}of {1} "; //$NON-NLS-1$
- String cloneName = StringHelper.formatMessage(message, new Object[] { "", representation_p.getName() }); //$NON-NLS-1$
- boolean cloneNameFound = false;
- Collection<DRepresentation> allRepresentations = DialectManager.INSTANCE.getAllRepresentations(session_p);
- int i = 1;
- while (!cloneNameFound) {
- boolean collision = false;
- for (DRepresentation representation : allRepresentations) {
- if (cloneName.equals(representation.getName())) {
- collision = true;
- break;
- }
- }
- if (collision) {
- cloneName = StringHelper.formatMessage(message, new Object[] { "" + ++i + ' ', //$NON-NLS-1$
- representation_p.getName() });
- }
- cloneNameFound = !collision;
- }
- return cloneName;
- }
+ /**
+ * @see org.eclipse.emf.common.command.Command#execute()
+ */
+ @Override
+ public void execute() {
+ // Initialize clones list.
+ if (null == _clones) {
+ _clones = new ArrayList<DRepresentation>(0);
+ } else {
+ // Ensure emptiness.
+ if (_clones.size() > 0) {
+ _clones.clear();
+ }
+ }
+ // Copy all representation.
+ for (DRepresentationDescriptor representationDescriptor : _representationDescriptors) {
+ DRepresentation representation = representationDescriptor.getRepresentation();
+ if (representation instanceof DSemanticDecorator) {
+ // Get target semantic element.
+ EObject target = ((DSemanticDecorator) representation).getTarget();
+ // Get session.
+ Session session = SessionManager.INSTANCE.getSession(target);
+ // Copy representation.
+ DRepresentation copyRepresentation = DialectManager.INSTANCE.copyRepresentation(representation, getCloneName(representation, session), session, null);
+ // Retain copied reference.
+ _clones.add(copyRepresentation);
+ // Notify listeners.
+ // S0024665 Not sure that is really needed as viewer has been
+ // already notified through the session
+ // notifyListeners(EventType.ADD, copyRepresentation, session);
+ } else {
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
- */
- @Override
- protected boolean prepare() {
- return true;
- }
+ ActivityExplorerActivator.getDefault().getLog().log(new Status(IStatus.WARNING, ActivityExplorerActivator.ID, "Clone is not supported for " + representationDescriptor.getName())); //$NON-NLS-1$
+ }
+ }
+ }
- /**
- * @see org.eclipse.emf.common.command.Command#redo()
- */
- public void redo() {
- execute();
- }
+ /**
+ * Get clone name for specified representation.
+ *
+ * @param representation_p
+ * @return
+ */
+ protected String getCloneName(DRepresentation representation_p, Session session_p) {
+ String message = "Clone {0}of {1}"; //$NON-NLS-1$
+ String cloneName = StringHelper.formatMessage(message, new Object[] { "", representation_p.getName() }); //$NON-NLS-1$
+ boolean cloneNameFound = false;
+ Collection<DRepresentation> allRepresentations = DialectManager.INSTANCE.getAllRepresentations(session_p);
+ int i = 1;
+ while (!cloneNameFound) {
+ boolean collision = false;
+ for (DRepresentation representation : allRepresentations) {
+ if (cloneName.equals(representation.getName())) {
+ collision = true;
+ break;
+ }
+ }
+ if (collision) {
+ cloneName = StringHelper.formatMessage(message, new Object[] { "" + ++i + ' ', //$NON-NLS-1$
+ representation_p.getName() });
+ }
+ cloneNameFound = !collision;
+ }
+ return cloneName;
+ }
- /**
- * @see org.eclipse.emf.common.command.AbstractCommand#undo()
- */
- @Override
- public void undo() {
- // Delete all cloned representations.
- for (DRepresentation representation : _clones) {
- Session session = SessionManager.INSTANCE.getSession(((DSemanticDecorator) representation).getTarget());
- // Notify listeners.
- // S0024665 Not sure that is really needed as viewer has been
- // already notified through the session
- // notifyListeners(EventType.REMOVE, representation, session);
- // Then execute delete.
- DialectManager.INSTANCE.deleteRepresentation(representation, session);
- }
- // Clean clones collection.
- _clones.clear();
- }
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
+ */
+ @Override
+ protected boolean prepare() {
+ return true;
+ }
- /**
- * Clone event type.
- *
- */
- protected enum EventType {
- ADD, REMOVE
- }
+ /**
+ * @see org.eclipse.emf.common.command.Command#redo()
+ */
+ @Override
+ public void redo() {
+ execute();
+ }
- /**
- * Clone listener.
- *
- */
- public interface ICloneListener {
- /**
- * Specified clone has just been added to specified session.
- *
- * @param clone_p
- * @param session_p
- */
- void cloneCreated(DRepresentation clone_p, Session session_p);
+ /**
+ * @see org.eclipse.emf.common.command.AbstractCommand#undo()
+ */
+ @Override
+ public void undo() {
+ // Delete all cloned representations.
+ for (DRepresentation representation : _clones) {
+ Session session = SessionManager.INSTANCE.getSession(((DSemanticDecorator) representation).getTarget());
+ // Notify listeners.
+ // S0024665 Not sure that is really needed as viewer has been
+ // already notified through the session
+ // notifyListeners(EventType.REMOVE, representation, session);
+ // Then execute delete.
+ RepresentationDescription dRepresentationDescription = DialectManager.INSTANCE.getDescription(representation);
+ Collection<DRepresentationDescriptor> representationDescriptors = DialectManager.INSTANCE.getRepresentationDescriptors(dRepresentationDescription, session);
+ for (DRepresentationDescriptor dRepresentationDescriptor : representationDescriptors) {
+ if (dRepresentationDescription.getName().equals(representation.getName())) {
+ DialectManager.INSTANCE.deleteRepresentation(dRepresentationDescriptor, session);
+ }
+ }
+ }
+ // Clean clones collection.
+ _clones.clear();
+ }
- /**
- * Specified clone is about to be removed from specified session.
- *
- * @param clone_p
- * @param session_p
- */
- void cloneAboutToBeRemoved(DRepresentation clone_p, Session session_p);
- }
-}
\ No newline at end of file
+ /**
+ * Clone event type.
+ *
+ */
+ protected enum EventType {
+ ADD, REMOVE
+ }
+
+ /**
+ * Clone listener.
+ *
+ */
+ public interface ICloneListener {
+ /**
+ * Specified clone has just been added to specified session.
+ *
+ * @param clone_p
+ * @param session_p
+ */
+ void cloneCreated(DRepresentation clone_p, Session session_p);
+
+ /**
+ * Specified clone is about to be removed from specified session.
+ *
+ * @param clone_p
+ * @param session_p
+ */
+ void cloneAboutToBeRemoved(DRepresentation clone_p, Session session_p);
+ }
+}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/DeleteRepresentationAction.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/DeleteRepresentationAction.java
index dab92d7..dd733ae 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/DeleteRepresentationAction.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/DeleteRepresentationAction.java
@@ -17,7 +17,12 @@
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.amalgam.explorer.activity.ui.ActivityExplorerActivator;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.helper.StringHelper;
+import org.eclipse.amalgam.explorer.activity.ui.internal.util.ActivityExplorerLoggerService;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -26,6 +31,7 @@
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -53,7 +59,7 @@
@Override
public void run() {
// Gets selected representations from the current selection.
- Set<DRepresentation> selectedRepresentations = getRepresentationsFromSelection();
+ Set<DRepresentationDescriptor> selectedRepresentations = getRepresentationsFromSelection();
if (!selectedRepresentations.isEmpty()) {
int deletedDiagramCount = selectedRepresentations.size();
String contextualMessage = null;
@@ -70,21 +76,39 @@
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(getRepresentationsFromSelection()
.iterator().next());
if (domain != null) {
- SessionManager.INSTANCE.getSessions();
- Session session = SessionManager.INSTANCE
- .getSession(((DSemanticDecorator) getRepresentationsFromSelection().iterator().next())
- .getTarget());
- DeleteRepresentationCommand command = new DeleteRepresentationCommand(session,
- selectedRepresentations);
- domain.getCommandStack().execute(command);
+ DRepresentationDescriptor dRepresentationDescriptor = getRepresentationsFromSelection().iterator().next();
+ Session session = getSessionOf(dRepresentationDescriptor);
+ if (session != null) {
+ DeleteRepresentationCommand command = new DeleteRepresentationCommand(session,
+ selectedRepresentations);
+ domain.getCommandStack().execute(command);
+ } else {
+ IStatus status = new Status(IStatus.ERROR, ActivityExplorerActivator.ID,
+ "Cannot find the session of " + dRepresentationDescriptor.getName()); //$NON-NLS-1$
+ ActivityExplorerLoggerService.getInstance().log(status);
+ }
}
}
}
}
+
+ /**
+ * @param dRepresentationDescriptor
+ * @return return the session behind the dReprestationDescription or null
+ */
+ private Session getSessionOf(DRepresentationDescriptor dRepresentationDescriptor){
+ Session session = null;
+ DRepresentation representation = dRepresentationDescriptor.getRepresentation();
+ if (representation instanceof DSemanticDecorator){
+ EObject Elt = ((DSemanticDecorator)representation).getTarget();
+ session = SessionManager.INSTANCE.getSession(Elt);
+ }
+ return session;
+ }
// Gets the selected representations from the current selection.
- private Set<DRepresentation> getRepresentationsFromSelection() {
- Set<DRepresentation> representations = new HashSet<DRepresentation>();
+ private Set<DRepresentationDescriptor> getRepresentationsFromSelection() {
+ Set<DRepresentationDescriptor> representations = new HashSet<DRepresentationDescriptor>();
IStructuredSelection structuredSelection = getStructuredSelection();
for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) {
@@ -94,8 +118,8 @@
// semantic decorators.
// Semantic decorators allow to retrieve the parent session of each
// representation.
- if ((selectedObject instanceof DRepresentation) && (selectedObject instanceof DSemanticDecorator)) {
- DRepresentation selectedRepresentation = (DRepresentation) selectedObject;
+ if ((selectedObject instanceof DRepresentationDescriptor)) {
+ DRepresentationDescriptor selectedRepresentation = (DRepresentationDescriptor) selectedObject;
representations.add(selectedRepresentation);
}
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/OpenRepresentationsAction.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/OpenRepresentationsAction.java
index 7595a36..e24fbc1 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/OpenRepresentationsAction.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/OpenRepresentationsAction.java
@@ -20,6 +20,7 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -64,15 +65,20 @@
}
}
- // Filters representations.
+ /**
+ * Filter representation from viewer
+ * @param selection_p
+ * @return
+ */
protected List<DRepresentation> getRepresentations(IStructuredSelection selection_p) {
List<DRepresentation> representations = new ArrayList<DRepresentation>();
Iterator<?> iterator = selection_p.iterator();
while (iterator.hasNext()) {
Object selectedObject = iterator.next();
- if (selectedObject instanceof DRepresentation) {
- representations.add((DRepresentation) selectedObject);
+ if (selectedObject instanceof DRepresentationDescriptor) {
+ DRepresentation representation = ((DRepresentationDescriptor) selectedObject).getRepresentation();
+ representations.add(representation);
}
}
return representations;
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/RenameRepresentationAction.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/RenameRepresentationAction.java
index 824d87f..4a99154 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/RenameRepresentationAction.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/actions/RenameRepresentationAction.java
@@ -21,6 +21,7 @@
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.common.ui.tools.api.dialog.RenameDialog;
import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -36,6 +37,7 @@
public RenameRepresentationAction() {
super("Rename"); //$NON-NLS-1$
setActionDefinitionId("org.eclipse.ui.edit.rename"); //$NON-NLS-1$
+ setAccelerator(findKeyCode("F2"));
}
/**
@@ -48,8 +50,9 @@
IStructuredSelection structuredSelection = getStructuredSelection();
for (Iterator<?> iterator = structuredSelection.iterator(); iterator.hasNext();) {
Object selectedObject = iterator.next();
- if (selectedObject instanceof DRepresentation) {
- representations.add((DRepresentation) selectedObject);
+ if (selectedObject instanceof DRepresentationDescriptor) {
+ DRepresentation representation = ((DRepresentationDescriptor)selectedObject).getRepresentation();
+ representations.add((DRepresentation) representation);
}
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/providers/DiagramViewerContentProvider.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/providers/DiagramViewerContentProvider.java
index b5749cc..fac92fb 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/providers/DiagramViewerContentProvider.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/internal/viewer/diagram/providers/DiagramViewerContentProvider.java
@@ -31,7 +31,7 @@
import org.eclipse.sirius.ui.tools.api.views.common.item.ViewpointsFolderItem;
import org.eclipse.sirius.ui.tools.internal.views.common.item.RepresentationItemImpl;
import org.eclipse.sirius.ui.tools.internal.views.common.item.ViewpointsFolderItemImpl;
-import org.eclipse.sirius.viewpoint.DRepresentation;
+import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.sirius.viewpoint.description.audit.provider.AuditItemProviderAdapterFactory;
import org.eclipse.sirius.viewpoint.description.provider.DescriptionItemProviderAdapterFactory;
@@ -105,28 +105,32 @@
result = getSessionChildren((Session) parentElement_p);
}
// Handle ViewpointItem.
- else if (parentElement_p instanceof ViewpointItem) {
- ViewpointItem viewpointItem = (ViewpointItem) parentElement_p;
- result = handleViewPointItem(parentElement_p, viewpointItem.getChildren());
- }
- // Handle all wrapped objects
- else if (parentElement_p instanceof RepresentationDescriptionItem) {
- RepresentationDescriptionItem representationDescriptionItem = (RepresentationDescriptionItem) parentElement_p;
- // Get children for current representation description item.
- Collection<?> representationItems = representationDescriptionItem.getChildren();
- // Check thate the children are not empty
- if (!representationItems.isEmpty()) {
+ else {
+ if (parentElement_p instanceof ViewpointItem) {
+ ViewpointItem viewpointItem = (ViewpointItem) parentElement_p;
+ result = handleViewPointItem(parentElement_p, viewpointItem.getChildren());
+ }
+ // Handle all wrapped objects
+ else {
+ if (parentElement_p instanceof RepresentationDescriptionItem) {
+ RepresentationDescriptionItem representationDescriptionItem = (RepresentationDescriptionItem) parentElement_p;
+ // Get children for current representation description item.
+ Collection<?> representationItems = representationDescriptionItem.getChildren();
+ // Check thate the children are not empty
+ if (!representationItems.isEmpty()) {
- RepresentationDescription representationDescription = (RepresentationDescription) representationDescriptionItem
- .getWrappedObject();
- if (_handledViewpoint.contains(representationDescription.getName())) {
- Iterator<?> it = representationItems.iterator();
- Collection<DRepresentation> desc = new ArrayList<DRepresentation>();
- while (it.hasNext()) {
- RepresentationItemImpl item = (RepresentationItemImpl) it.next();
- desc.add(item.getRepresentation());
+ RepresentationDescription representationDescription = (RepresentationDescription) representationDescriptionItem
+ .getWrappedObject();
+ if (_handledViewpoint.contains(representationDescription.getName())) {
+ Iterator<?> it = representationItems.iterator();
+ Collection<DRepresentationDescriptor> desc = new ArrayList<DRepresentationDescriptor>();
+ while (it.hasNext()) {
+ RepresentationItemImpl item = (RepresentationItemImpl) it.next();
+ desc.add(item.getDRepresentationDescriptor());
+ }
+ result = desc.toArray();
+ }
}
- result = desc.toArray();
}
}
diff --git a/releng/org.eclipse.amalgam.releng/target_platforms/mars.target b/releng/org.eclipse.amalgam.releng/target_platforms/mars.target
index a19eb91..9d17d7f 100644
--- a/releng/org.eclipse.amalgam.releng/target_platforms/mars.target
+++ b/releng/org.eclipse.amalgam.releng/target_platforms/mars.target
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
-<target name="mars" sequenceNumber="1471008064">
+<target name="mars" sequenceNumber="1471525859">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gmf.feature.group" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
- <unit id="org.eclipse.sirius.runtime.feature.group" version="0.0.0"/>
- <unit id="org.eclipse.sirius.runtime.ide.ui.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/releases/mars"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
+ <unit id="org.eclipse.sirius.runtime.feature.group" version="0.0.0"/>
+ <unit id="org.eclipse.sirius.runtime.ide.ui.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/sirius/updates/stable/4.1.0-S20160809-110054/mars/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
diff --git a/releng/org.eclipse.amalgam.releng/target_platforms/mars.targetplatform b/releng/org.eclipse.amalgam.releng/target_platforms/mars.targetplatform
index ef5d7c8..8dc8f8a 100644
--- a/releng/org.eclipse.amalgam.releng/target_platforms/mars.targetplatform
+++ b/releng/org.eclipse.amalgam.releng/target_platforms/mars.targetplatform
@@ -5,12 +5,11 @@
org.eclipse.emf.sdk.feature.group lazy
org.eclipse.gmf.feature.group lazy
org.junit lazy
-
- org.eclipse.sirius.runtime.feature.group lazy
- org.eclipse.sirius.runtime.ide.ui.feature.group lazy
}
location "http://download.eclipse.org/sirius/updates/stable/4.1.0-S20160809-110054/mars/" {
+ org.eclipse.sirius.runtime.feature.group lazy
+ org.eclipse.sirius.runtime.ide.ui.feature.group lazy
}
location "http://download.eclipse.org/cbi/updates/license" {
diff --git a/releng/org.eclipse.amalgam.releng/target_platforms/neon.target b/releng/org.eclipse.amalgam.releng/target_platforms/neon.target
index 0bac0c4..00b23f9 100644
--- a/releng/org.eclipse.amalgam.releng/target_platforms/neon.target
+++ b/releng/org.eclipse.amalgam.releng/target_platforms/neon.target
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
-<target name="neon" sequenceNumber="1471008079">
+<target name="neon" sequenceNumber="1471525863">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
<unit id="org.eclipse.emf.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.gmf.feature.group" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
- <unit id="org.eclipse.sirius.runtime.feature.group" version="0.0.0"/>
- <unit id="org.eclipse.sirius.runtime.ide.ui.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/releases/neon"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
+ <unit id="org.eclipse.sirius.runtime.feature.group" version="0.0.0"/>
+ <unit id="org.eclipse.sirius.runtime.ide.ui.feature.group" version="0.0.0"/>
<repository location="http://download.eclipse.org/sirius/updates/stable/4.1.0-S20160809-110054/neon/"/>
</location>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="InstallableUnit">
diff --git a/releng/org.eclipse.amalgam.releng/target_platforms/neon.targetplatform b/releng/org.eclipse.amalgam.releng/target_platforms/neon.targetplatform
index 513d615..6db65cb 100644
--- a/releng/org.eclipse.amalgam.releng/target_platforms/neon.targetplatform
+++ b/releng/org.eclipse.amalgam.releng/target_platforms/neon.targetplatform
@@ -5,12 +5,11 @@
org.eclipse.emf.sdk.feature.group lazy
org.eclipse.gmf.feature.group lazy
org.junit lazy
-
- org.eclipse.sirius.runtime.feature.group lazy
- org.eclipse.sirius.runtime.ide.ui.feature.group lazy
}
location "http://download.eclipse.org/sirius/updates/stable/4.1.0-S20160809-110054/neon/" {
+ org.eclipse.sirius.runtime.feature.group lazy
+ org.eclipse.sirius.runtime.ide.ui.feature.group lazy
}
location "http://download.eclipse.org/cbi/updates/license" {