Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2013-09-05 13:57:51 +0000
committerVincent Lorenzo2013-09-05 13:57:51 +0000
commit27d3e12c02d4f5b439720241806b3d0fe75a7ced (patch)
tree31d9c94a9d8db7186f0f291404572ad3fea4fffa /extraplugins
parentb211058b94839a2b09e1d2fc04041b42145449cd (diff)
downloadorg.eclipse.papyrus-27d3e12c02d4f5b439720241806b3d0fe75a7ced.tar.gz
org.eclipse.papyrus-27d3e12c02d4f5b439720241806b3d0fe75a7ced.tar.xz
org.eclipse.papyrus-27d3e12c02d4f5b439720241806b3d0fe75a7ced.zip
415754: [Table 2] The label and the icon for existing property of
streotype column is not correct https://bugs.eclipse.org/bugs/show_bug.cgi?id=415754 416626: [Table 2] The order of the columns can't be changed in the dialog Create/Destroy Columns https://bugs.eclipse.org/bugs/show_bug.cgi?id=416626 416627: [Table 2] The dialog to Create/Destroy columns doesn't manage properly existing stereotypes properties columns https://bugs.eclipse.org/bugs/show_bug.cgi?id=416627
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/AbstractSynchronizedOnEStructuralFeatureAxisManager.java2
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java6
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java118
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java2
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java10
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IIdAxisManager.java31
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java18
-rw-r--r--extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java42
8 files changed, 187 insertions, 42 deletions
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/AbstractSynchronizedOnEStructuralFeatureAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/AbstractSynchronizedOnEStructuralFeatureAxisManager.java
index e3191f4cd7b..57effc52937 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/AbstractSynchronizedOnEStructuralFeatureAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/AbstractSynchronizedOnEStructuralFeatureAxisManager.java
@@ -405,7 +405,7 @@ public abstract class AbstractSynchronizedOnEStructuralFeatureAxisManager extend
* @return
*/
@Override
- public Collection<Object> getAllManagedAxis() {
+ public List<Object> getAllManagedAxis() {
return new ArrayList<Object>(this.managedObject);
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
index 8346cececc8..765d0e31762 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java
@@ -15,9 +15,7 @@ package org.eclipse.papyrus.infra.nattable.manager.axis;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -402,8 +400,8 @@ public abstract class AbstractAxisManager implements IAxisManager {
*
* @return
*/
- public Collection<Object> getAllManagedAxis() {
- final Set<Object> eObjects = new HashSet<Object>();
+ public List<Object> getAllManagedAxis() {
+ final List<Object> eObjects = new ArrayList<Object>();
for(final IAxis current : getRepresentedContentProvider().getAxis()) {
if(current.getManager() == this.representedAxisManager) {
eObjects.add(current.getElement());
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
index 8017647b9e9..3e08b875465 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java
@@ -17,16 +17,17 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
+import java.util.TreeMap;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -37,9 +38,12 @@ import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IdAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
import org.eclipse.papyrus.infra.nattable.utils.AxisComparator;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.providers.CompoundFilteredRestrictedContentProvider;
@@ -396,8 +400,8 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
* @return
*/
@Override
- public Collection<Object> getAllManagedAxis() {
- final Set<Object> allExistingAxis = new HashSet<Object>();
+ public List<Object> getAllManagedAxis() {
+ final List<Object> allExistingAxis = new ArrayList<Object>();
for(IAxisManager manager : this.subManagers) {
Collection<Object> managerPossibleElements = manager.getAllManagedAxis();
if(managerPossibleElements != null) {
@@ -409,6 +413,33 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
/**
*
+ * @param resolve
+ * if <code>true</code> the path will be resolved
+ * @return
+ * a list with the managed objects
+ */
+ public List<Object> getAllManagedAxis(final boolean resolve) {
+ final List<Object> allExistingAxis = new ArrayList<Object>();
+ for(final IAxis current : getRepresentedContentProvider().getAxis()) {
+ Object representedElement = AxisUtils.getRepresentedElement(current);
+ if(resolve && current instanceof IdAxis) {
+ representedElement = getResolvedPath((IdAxis)current);
+ }
+ allExistingAxis.add(representedElement);
+ }
+ for(IAxisManager manager : this.subManagers) {
+ if(manager.isDynamic()) {
+ final List<Object> managerPossibleElements = manager.getAllManagedAxis();
+ if(managerPossibleElements != null) {
+ allExistingAxis.addAll(managerPossibleElements);
+ }
+ }
+ }
+ return allExistingAxis;
+ }
+
+ /**
+ *
* @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#isSlave()
*
* @return
@@ -669,4 +700,83 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos
}
return false;
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager#getSetNewAxisOrderCommand(java.util.List)
+ *
+ * @param newOrder
+ * @return
+ */
+ @Override
+ public Command getSetNewAxisOrderCommand(final List<Object> newOrder) {
+ if(canMoveAxis() && !isDynamic()) {
+ return new RecordingCommand(getTableEditingDomain()) {
+
+ @Override
+ protected void doExecute() {
+ final TreeMap<Integer, IAxis> order = new TreeMap<Integer, IAxis>();
+ final AbstractAxisProvider provider = getRepresentedContentProvider();
+ for(int i = 0; i < provider.getAxis().size(); i++) {
+ final IAxis currentAxis = provider.getAxis().get(i);
+ int index = newOrder.indexOf(currentAxis);
+ if(index != -1) {
+ order.put(Integer.valueOf(index), currentAxis);
+ } else {
+ Object resolvedObject = AxisUtils.getRepresentedElement(currentAxis);
+ if(currentAxis instanceof IdAxis) {
+ resolvedObject = getResolvedPath((IdAxis)currentAxis);
+ }
+ index = newOrder.indexOf(resolvedObject);
+ if(index == -1) {
+ throw new IndexOutOfBoundsException("A reordered element can't be resolved"); //$NON-NLS-1$
+ }
+ order.put(Integer.valueOf(index), currentAxis);
+ }
+ }
+
+ final List<IAxis> newValues = new ArrayList<IAxis>();
+ newValues.addAll(order.values());
+ SetCommand.create(getTableEditingDomain(), provider, NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), newValues).execute();
+ }
+ };
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param axisManagerId
+ * an axis
+ * @return
+ * the axis manager managing it
+ */
+ protected IAxisManager findAxisManager(final IAxis axis) {
+ final String axisManagerId = axis.getManager().getAxisManagerId();
+ for(final IAxisManager currentManager : this.subManagers) {
+ if(currentManager.getAxisManagerRepresentation().getAxisManagerId().equals(axisManagerId)) {
+ return currentManager;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param idAxis
+ * an idAxis
+ * @return
+ * the resolved path or the {@link String} represented by the idAxis if the path can't be resolved
+ */
+ protected Object getResolvedPath(final IdAxis idAxis) {
+ final String path = idAxis.getElement();
+ final IAxisManager manager = findAxisManager(idAxis);
+ if(manager instanceof IIdAxisManager) {
+ final Object resolvedElement = ((IIdAxisManager)manager).resolvedPath(path);
+ if(resolvedElement != null) {
+ return resolvedElement;
+ }
+ }
+ return path;
+ }
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
index de5f08f771b..7e24049e919 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java
@@ -149,7 +149,7 @@ public interface IAxisManager extends IDisposable, IAdaptable {
* @return
* the list of the existing axis managed by the axis manager
*/
- public Collection<Object> getAllManagedAxis();
+ public List<Object> getAllManagedAxis();
/**
*
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
index 2951d788c58..c96addb0892 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ICompositeAxisManager.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.nattable.manager.axis;
import java.util.Comparator;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
@@ -64,5 +65,14 @@ public interface ICompositeAxisManager extends IAxisManager {
*/
public void setAxisComparator(final Comparator<Object> comp);
+ /**
+ *
+ * @param newOrder
+ * the new order for the objects : the objects can be IAxis or objects, or objects represented by IAxis in the model
+ * @return
+ * the command to use to set this new order
+ */
+ public Command getSetNewAxisOrderCommand(final List<Object> newOrder);
+
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IIdAxisManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IIdAxisManager.java
new file mode 100644
index 00000000000..d9010376fe6
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IIdAxisManager.java
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * 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.nattable.manager.axis;
+
+/**
+ *
+ * @author vl222926
+ *
+ */
+public interface IIdAxisManager {
+
+ /**
+ *
+ * @param path
+ * a path
+ * @return
+ * the resolved object or <code>null</code> if it is not possible
+ */
+ public Object resolvedPath(final String path);
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index 037ca62da5d..9cbbf78d252 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -986,8 +986,8 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
IStaticContentProvider provider = editedAxisManager.createPossibleAxisContentProvider(true);
if(provider != null) {
selector.setContentProvider(new FlattenableRestrictedFilteredContentProvider((IRestrictedContentProvider)provider, selector));
-
- final DisplayedAxisSelectorDialog dialog = new DisplayedAxisSelectorDialog(Display.getDefault().getActiveShell(), selector, dialogTitle, true, false, -1);
+ boolean canBeReorder = (!editedAxisManager.isDynamic()) && editedAxisManager.canMoveAxis();
+ final DisplayedAxisSelectorDialog dialog = new DisplayedAxisSelectorDialog(Display.getDefault().getActiveShell(), selector, dialogTitle, true, canBeReorder, -1);
boolean displayCheckBox = editedAxisProvider instanceof ISlaveAxisProvider;
dialog.setDisplayCheckBox(displayCheckBox);
boolean checkboxValue = secondAxisProvider instanceof IMasterAxisProvider && ((IMasterAxisProvider)secondAxisProvider).isDisconnectSlave();
@@ -997,13 +997,15 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
dialog.setInformationDialogValues(Messages.NattableModelManager_DisconnectAxisManagerInformationDialogTitle, dialogQuestion);
dialog.setLabelProvider(labelProvider);
- dialog.setInitialElementSelections(new ArrayList<Object>(editedAxisManager.getAllManagedAxis()));
+ final List<Object> initialSelection = ((CompositeAxisManager)editedAxisManager).getAllManagedAxis(true);//TODO : must be a list!
+ dialog.setInitialElementSelections(new ArrayList<Object>(initialSelection));
int open = dialog.open();
if(open == Window.OK) {
- Collection<Object> existingColumns = editedAxisManager.getAllManagedAxis();
+ Collection<Object> existingColumns = initialSelection;
ArrayList<Object> checkedColumns = new ArrayList<Object>();
- checkedColumns.addAll(Arrays.asList(dialog.getResult()));
+ final List<Object> result = Arrays.asList(dialog.getResult());
+ checkedColumns.addAll(result);
ArrayList<Object> columnsToAdd = new ArrayList<Object>(checkedColumns);
columnsToAdd.removeAll(existingColumns);
@@ -1038,6 +1040,12 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
compoundCommand.append(new GMFtoEMFCommandWrapper(commandProvider.getEditCommand(request)));
}
+ if(canBeReorder) {
+ final Command setOrderCommand = ((ICompositeAxisManager)editedAxisManager).getSetNewAxisOrderCommand(result);
+ if(setOrderCommand != null) {
+ compoundCommand.append(setOrderCommand);
+ }
+ }
if(!compoundCommand.isEmpty()) {
getContextEditingDomain().getCommandStack().execute(compoundCommand);
updateToggleActionState();
diff --git a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
index 439592e70aa..8e80c181780 100644
--- a/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
+++ b/extraplugins/table/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java
@@ -28,6 +28,7 @@ import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IIdAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IdAxis;
@@ -39,6 +40,7 @@ import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.infra.widgets.providers.IRestrictedContentProvider;
import org.eclipse.papyrus.uml.nattable.provider.UMLStereotypeRestrictedPropertyContentProvider;
import org.eclipse.papyrus.uml.nattable.utils.Constants;
+import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.NamedElement;
@@ -52,7 +54,7 @@ import org.eclipse.uml2.uml.Stereotype;
* @author Vincent Lorenzo
*
*/
-public class UMLStereotypePropertyAxisManager extends UMLFeatureAxisManager {
+public class UMLStereotypePropertyAxisManager extends UMLFeatureAxisManager implements IIdAxisManager {
/**
*
@@ -203,30 +205,16 @@ public class UMLStereotypePropertyAxisManager extends UMLFeatureAxisManager {
return null;
}
- // /**
- // *
- // * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAllManagedAxis()
- // *
- // * @return
- // */
- // @Override
- // public Collection<Object> getAllManagedAxis() {//TODO : this calculus must not be done here
- // Set<Object> eObjects = new HashSet<Object>();
- // final List<Object> elementList = getElements();
- // for(final Object element : elementList) {
- // if(element instanceof IAxis && ((IAxis)element).getManager() == this.representedAxisManager) {
- // EObject context = ((INattableModelManager)getTableManager()).getTable().getContext();
- // String id = null;
- // IdAxis idAxis = (IdAxis)element;
- // id = idAxis.getElement();
- // Property property = UMLTableUtils.getRealStereotypeProperty(context, id);
- // if(property != null) {
- // eObjects.add(property);
- // } else {
- // eObjects.add(idAxis);
- // }
- // }
- // }
- // return eObjects;
- // }
+ /**
+ *
+ * @param path
+ * @return
+ */
+ public Object resolvedPath(final String path) {
+ if(path.startsWith(Constants.PROPERTY_OF_STEREOTYPE_PREFIX)) {
+ return UMLTableUtils.getRealStereotypeProperty(getTableContext(), path);
+ }
+ return null;
+ }
+
}

Back to the top