Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2017-05-05 09:21:53 +0000
committervincent lorenzo2017-05-08 13:37:09 +0000
commit66d0a630c88cc9177a142b09060a7ffa59249936 (patch)
treeba3a23ae88e67f332c6b909b53c1f4f366d7905c /plugins/infra/nattable
parente52cda92eba72b1bb114151ffe4cbfab2315e38a (diff)
downloadorg.eclipse.papyrus-66d0a630c88cc9177a142b09060a7ffa59249936.tar.gz
org.eclipse.papyrus-66d0a630c88cc9177a142b09060a7ffa59249936.tar.xz
org.eclipse.papyrus-66d0a630c88cc9177a142b09060a7ffa59249936.zip
Bug 497571: [Table] Move column using boolean filter breaks the table
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497571 - Add data validators for Boolean and Enumerated (needed to recalculate the current canonical values of BomcoBoxCellEditor after a move) - Reconfigure the config registry of FILTER_ROW_X after a move. - Manage correctly the Filter loader for the Boolean Filter celle editor configuration Change-Id: Id7ee254bb0005c560c5ad57316ff2887a78e3b40 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra/nattable')
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/filter/configuration/EEnumFilterCellEditorFilterConfiguration.java50
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanComboBoxCellEditorFilterConfiguration.java26
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanFilterRowComboBoxCellEditorFilterConfiguration.java8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/BooleanFilterDataValidator.java67
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/EnumFilterDataValidator.java82
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java31
6 files changed, 244 insertions, 20 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/filter/configuration/EEnumFilterCellEditorFilterConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/filter/configuration/EEnumFilterCellEditorFilterConfiguration.java
index 7813c67a8b1..6567838df2b 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/filter/configuration/EEnumFilterCellEditorFilterConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/filter/configuration/EEnumFilterCellEditorFilterConfiguration.java
@@ -7,7 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * CEA LIST - Initial API and implementation
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 497571
*
*****************************************************************************/
@@ -31,6 +32,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IColumnAccessor;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
import org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxCellEditor;
@@ -41,6 +43,7 @@ import org.eclipse.papyrus.infra.nattable.filter.IFilterValueToMatchManager;
import org.eclipse.papyrus.infra.nattable.filter.IPapyrusMatcherEditorFactory;
import org.eclipse.papyrus.infra.nattable.filter.configuration.AbstractFilterValueToMatchManager;
import org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration;
+import org.eclipse.papyrus.infra.nattable.filter.validator.EnumFilterDataValidator;
import org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NamedStyle;
@@ -88,7 +91,7 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
* @param axis
* an axis
* @return
- * a list containing the possible Enumerator for the axis
+ * a list containing the possible Enumerator for the axis
*/
protected List<Enumerator> getLiteral(IConfigRegistry configRegistry, Object axis) {
Object representedElement = AxisUtils.getRepresentedElement(axis);
@@ -126,10 +129,16 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(NattableConfigAttributes.FILTER_VALUE_TO_MATCH_MANAGER, createFilterValueToMatchManager(getConfigurationId(), literals), DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new GenericDisplayConverter(), DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, getDataValidator(configRegistry, literals), DisplayMode.NORMAL, configLabel);
}
- protected IPapyrusMatcherEditorFactory<Object> createPapyrusMatcherFactory(){
- return new IPapyrusMatcherEditorFactory<Object>() {
+ /**
+ * This allows to create the papyrus matcher factory.
+ *
+ * @return The create papyrus matcher factory.
+ */
+ protected IPapyrusMatcherEditorFactory<Object> createPapyrusMatcherFactory() {
+ return new IPapyrusMatcherEditorFactory<Object>() {
@Override
public EventList<MatcherEditor<Object>> instantiateMatcherEditors(IColumnAccessor<Object> columnAccessor, Integer columnIndex, Object wantedValue, IConfigRegistry configRegistry) {
@@ -139,6 +148,7 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
}
};
}
+
/**
*
* @param filterConfiguration
@@ -146,13 +156,29 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
* @param literals
* the available literals
* @return
- * the filter value manager for the managed axis
+ * the filter value manager for the managed axis
*/
protected IFilterValueToMatchManager createFilterValueToMatchManager(String filterConfiguration, List<Enumerator> literals) {
return new EnumeratorFilterValueToMatchManager(filterConfiguration, literals);
}
/**
+ * This allows to get the data validator to use.
+ *
+ * @param configRegistry
+ * The config registry.
+ * @param literals
+ * The list of authorized literals.
+ *
+ * @return The data validator to use.
+ *
+ * @since 3.0
+ */
+ protected IDataValidator getDataValidator(final IConfigRegistry configRegistry, final List<Enumerator> literals) {
+ return new EnumFilterDataValidator(literals);
+ }
+
+ /**
*
*
* @see org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration#getConfigurationId()
@@ -180,12 +206,12 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
*
*/
public static class EnumeratorFilterValueToMatchManager extends AbstractFilterValueToMatchManager {
-
+
/**
* a list with the available literal
*/
protected final List<Enumerator> literals;
-
+
/**
* Constructor.
*
@@ -198,8 +224,8 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
super(filterConfigurationId);
this.literals = literals;
}
-
-
+
+
/**
* @see org.eclipse.papyrus.infra.nattable.filter.IFilterValueToMatchManager#getValueToMatch(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
*
@@ -246,7 +272,7 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
}
return null;
}
-
+
/**
* @see org.eclipse.papyrus.infra.nattable.filter.configuration.AbstractFilterValueToMatchManager#getSaveValueToMatchCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry,
* java.lang.Object, java.lang.Object)
@@ -280,7 +306,7 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
keyStyle.setName(FILTER_VALUE_TO_MATCH);
cc.append(AddCommand.create(domain, iaxis, NattablestylePackage.eINSTANCE.getNamedStyle(), keyStyle));
}
-
+
List<String> values = new ArrayList<String>();
for (Object tmp : coll) {
Assert.isTrue(tmp instanceof Enumerator || ICellManager.NOT_AVALAIBLE.equals(tmp));
@@ -318,6 +344,6 @@ public class EEnumFilterCellEditorFilterConfiguration implements IFilterConfigur
}
return cc;
}
-
+
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanComboBoxCellEditorFilterConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanComboBoxCellEditorFilterConfiguration.java
index 88d7570986e..1f952c67ee8 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanComboBoxCellEditorFilterConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanComboBoxCellEditorFilterConfiguration.java
@@ -7,7 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * CEA LIST - Initial API and implementation
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 497571
*
*****************************************************************************/
@@ -19,12 +20,14 @@ import java.util.List;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.papyrus.infra.nattable.filter.BooleanMatcherEditorFactory;
import org.eclipse.papyrus.infra.nattable.filter.IPapyrusMatcherEditorFactory;
+import org.eclipse.papyrus.infra.nattable.filter.validator.BooleanFilterDataValidator;
import org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
@@ -52,12 +55,13 @@ public abstract class AbstractBooleanComboBoxCellEditorFilterConfiguration imple
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(NattableConfigAttributes.MATCHER_EDITOR_FACTORY, createMatcherFactory(), DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, getDataValidator(configRegistry), DisplayMode.NORMAL, configLabel);
}
/**
*
* @return
- * a new matcher factory
+ * a new matcher factory
*/
protected IPapyrusMatcherEditorFactory<Object> createMatcherFactory() {
return new BooleanMatcherEditorFactory();
@@ -69,19 +73,33 @@ public abstract class AbstractBooleanComboBoxCellEditorFilterConfiguration imple
* @param columnElement
* @param configLabel
* @return
- * a new ICellEditor
+ * a new ICellEditor
*/
protected ICellEditor createICellEditor(IConfigRegistry configRegistry, Object columnElement, String configLabel) {
return new ComboBoxCellEditor(availableValue);
}
/**
+ * This allows to get the data validator to use.
+ *
+ * @param configRegistry
+ * The config registry.
+ *
+ * @return The data validator to use.
+ *
+ * @since 3.0
+ */
+ protected IDataValidator getDataValidator(IConfigRegistry configRegistry) {
+ return new BooleanFilterDataValidator();
+ }
+
+ /**
* @see org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration#getConfigurationDescription()
*
* @return
*/
@Override
public String getConfigurationDescription() {
- return "This configuration provides an Combo to filter boolean values. Known values are true, false and N/A"; //$//$NON-NLS-1$
+ return "This configuration provides an Combo to filter boolean values. Known values are true, false and N/A"; //$NON-NLS-1$
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanFilterRowComboBoxCellEditorFilterConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanFilterRowComboBoxCellEditorFilterConfiguration.java
index 0747173ebee..cb742c9fd1d 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanFilterRowComboBoxCellEditorFilterConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/configuration/AbstractBooleanFilterRowComboBoxCellEditorFilterConfiguration.java
@@ -7,7 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * CEA LIST - Initial API and implementation
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 497571
*
*****************************************************************************/
@@ -61,7 +62,8 @@ public abstract class AbstractBooleanFilterRowComboBoxCellEditorFilterConfigurat
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, configLabel);
configRegistry.registerConfigAttribute(NattableConfigAttributes.MATCHER_EDITOR_FACTORY, createMatcherFactory(), DisplayMode.NORMAL, configLabel);
- configRegistry.registerConfigAttribute(IFilterConfiguration.FILTER_VALUE_TO_MATCH_MANAGER, createBooleanFilterLoader());
+ configRegistry.registerConfigAttribute(IFilterConfiguration.FILTER_VALUE_TO_MATCH_MANAGER, createBooleanFilterLoader(), DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, getDataValidator(configRegistry), DisplayMode.NORMAL, configLabel);
}
/**
@@ -97,7 +99,7 @@ public abstract class AbstractBooleanFilterRowComboBoxCellEditorFilterConfigurat
* @return
*/
public String getConfigurationDescription() {
- return "This configuration provides an Combo with checkbox to filter boolean values. Known values are true, false and N/A"; //$//$NON-NLS-1$
+ return "This configuration provides an Combo with checkbox to filter boolean values. Known values are true, false and N/A"; // $//$NON-NLS-1$
}
public static class BooleanFilterValueToMatchManager extends AbstractFilterValueToMatchManager {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/BooleanFilterDataValidator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/BooleanFilterDataValidator.java
new file mode 100644
index 00000000000..aa3132f2b0e
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/BooleanFilterDataValidator.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.filter.validator;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager;
+
+/**
+ * The validator used for boolean editor in the filter row header.
+ *
+ * @since 3.0
+ */
+public class BooleanFilterDataValidator implements IDataValidator {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator#validate(int, int, java.lang.Object)
+ */
+ @Override
+ public boolean validate(int columnIndex, int rowIndex, Object newValue) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator#validate(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
+ */
+ @Override
+ public boolean validate(ILayerCell cell, IConfigRegistry configRegistry, Object newValue) {
+ if (null == newValue) {
+ return true;
+ }
+ if (newValue instanceof Boolean) {
+ return true;
+ } else if (newValue instanceof String && newValue.equals(ICellManager.NOT_AVALAIBLE)) {
+ return true;
+ } else if (newValue instanceof Collection<?>) {
+ boolean result = true;
+ final Iterator<?> values = ((Collection<?>) newValue).iterator();
+ while (values.hasNext() && result) {
+ final Object value = values.next();
+ result = validate(cell, configRegistry, value);
+ }
+ return result;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/EnumFilterDataValidator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/EnumFilterDataValidator.java
new file mode 100644
index 00000000000..961f4092b99
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/validator/EnumFilterDataValidator.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.filter.validator;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator;
+import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
+import org.eclipse.papyrus.infra.nattable.manager.cell.ICellManager;
+
+/**
+ * The validator used for enum editor in the filter row header.
+ *
+ * @since 3.0
+ */
+public class EnumFilterDataValidator implements IDataValidator {
+
+ /**
+ * The list of authorized literals.
+ */
+ final List<Enumerator> authorizedLiterals;
+
+ /**
+ * Constructor.
+ *
+ */
+ public EnumFilterDataValidator(final List<Enumerator> authorizedLiterals) {
+ this.authorizedLiterals = authorizedLiterals;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator#validate(int, int, java.lang.Object)
+ */
+ @Override
+ public boolean validate(int columnIndex, int rowIndex, Object newValue) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.nebula.widgets.nattable.data.validate.IDataValidator#validate(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell, org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
+ */
+ @Override
+ public boolean validate(ILayerCell cell, IConfigRegistry configRegistry, Object newValue) {
+ if (null == newValue) {
+ return true;
+ }
+ if(newValue instanceof Enumerator && authorizedLiterals.contains(newValue)) {
+ return true;
+ } else if (newValue instanceof String && newValue.equals(ICellManager.NOT_AVALAIBLE)) {
+ return true;
+ } else if (newValue instanceof Collection<?>) {
+ boolean result = true;
+ final Iterator<?> values = ((Collection<?>) newValue).iterator();
+ while (values.hasNext() && result) {
+ final Object value = values.next();
+ result = validate(cell, configRegistry, value);
+ }
+ return result;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index 59a084ec458..dbe6e678b4d 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -11,7 +11,7 @@
* Christian W. Damus (CEA) - bug 402525
* Christian W. Damus (CEA) - bug 430880
* Dirk Fauth <dirk.fauth@googlemail.com> - Bug 488234
- * Nicolas FAUVERGUE(ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077
+ * Nicolas FAUVERGUE(ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077, 497571
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 502560: add drag to diagram support
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220
*****************************************************************************/
@@ -54,6 +54,7 @@ import org.eclipse.nebula.widgets.nattable.coordinate.Range;
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand;
+import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer;
//import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowHeaderComposite;
import org.eclipse.nebula.widgets.nattable.filterrow.IFilterStrategy;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
@@ -104,6 +105,7 @@ import org.eclipse.papyrus.infra.nattable.dataprovider.CompositeRowHeaderDataPro
import org.eclipse.papyrus.infra.nattable.display.converter.ObjectNameAndPathDisplayConverter;
import org.eclipse.papyrus.infra.nattable.export.file.command.PapyrusFileExportCommand;
import org.eclipse.papyrus.infra.nattable.fillhandle.config.PapyrusFillHandleConfiguration;
+import org.eclipse.papyrus.infra.nattable.filter.configuration.FilterConfigurationRegistry;
import org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration;
import org.eclipse.papyrus.infra.nattable.layer.FilterRowHeaderComposite;
import org.eclipse.papyrus.infra.nattable.layer.PapyrusGridLayer;
@@ -883,6 +885,33 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
end--;
}
+ // When a column is moved, we need to reconfigure the columns impacted by the move because the cell editors, filters, validators, ...
+ // are managed with config attribute specifying the column index (managed by NatTable)
+ // We need to make it before the move for the filter for example.
+
+ // First step: Configure the moved column
+ // The end index with the start column element
+ final StringBuilder movedConfigAttribute = new StringBuilder(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX);
+ movedConfigAttribute.append(Integer.valueOf(end).toString());
+ FilterConfigurationRegistry.INSTANCE.configureFilter(natTable.getConfigRegistry(), getColumnElement(start), movedConfigAttribute.toString());
+
+ // Second step: Configure the existing column that need to be recalculated because of the move.
+ if (start < end) {
+ // If the start is less than the end, the column element is moved to the left (targetIndex = sourceIndex - 1)
+ for (int i = start; i < end; i++) {
+ StringBuilder configAttribute = new StringBuilder(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX);
+ configAttribute.append(Integer.valueOf(i).toString());
+ FilterConfigurationRegistry.INSTANCE.configureFilter(natTable.getConfigRegistry(), getColumnElement(i + 1), configAttribute.toString());
+ }
+ } else {
+ // If the start is greater than the end, the column element is moved to the right (targetIndex = sourceIndex + 1)
+ for (int i = end + 1; i >= start; i--) {
+ StringBuilder configAttribute = new StringBuilder(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX);
+ configAttribute.append(Integer.valueOf(i).toString());
+ FilterConfigurationRegistry.INSTANCE.configureFilter(natTable.getConfigRegistry(), getColumnElement(i - 1), configAttribute.toString());
+ }
+ }
+
final IAxis axisToMove = allAxis.get(start);
if (axisToMove != null) {
moveColumnElement(axisToMove, end);

Back to the top