Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2016-08-09 10:25:50 +0000
committerGerrit Code Review @ Eclipse.org2016-08-28 15:46:41 +0000
commit7310db0b3b2e8ee805fedf4bfd16baf438c89332 (patch)
tree3dadff6a067e8d8bcbf837d8277dfac7749aef27 /plugins/infra/nattable
parent7851474fe5f33de156c797942945a3e9c97cb0a8 (diff)
downloadorg.eclipse.papyrus-7310db0b3b2e8ee805fedf4bfd16baf438c89332.tar.gz
org.eclipse.papyrus-7310db0b3b2e8ee805fedf4bfd16baf438c89332.tar.xz
org.eclipse.papyrus-7310db0b3b2e8ee805fedf4bfd16baf438c89332.zip
Bug 443799 - Fix potential bugs identified by FindBugs in oep.infra.*
Bug 499554 - Oxygen release version number moved to 3.0.0. Change-Id: I8e112db7175a5b89eb9b37973639627a6c29e007
Diffstat (limited to 'plugins/infra/nattable')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/META-INF/MANIFEST.MF4
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java81
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/api/TableEditorCreationHelper.java12
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/pom.xml22
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.gmfdiag/META-INF/MANIFEST.MF6
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateColumnElementContraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateRowElementContraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateColumnElementContraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateRowElementContraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnFeatureLabelConfigurationConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnObjectLabelConfigurationConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowFeatureLabelConfigurationConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowObjectLabelConfigurationConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasTreeFillingConfigurationConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableIsFlatTableConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableJavaConstraint.java23
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInFlatTableConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTableConstraint.java21
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTreeTableConstraint.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.editor/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/comparator/DoubleFilterComparator.java148
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/FilterRowDataProvider.java1159
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/AbstractSinglePapyrusMatcher.java240
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/glazedlists/copy/MouseOnlySortingStrategy.java134
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ITreeItemAxisComparator.java10
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java16
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java11
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/PapyrusBeveledBorderDecorator.java14
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractPasteInSelectionNattableCommandProvider.java91
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java12
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteInSelectionTreeNattableCommandProvider.java12
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/InsertedElementInNattable.java37
44 files changed, 1132 insertions, 1107 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/META-INF/MANIFEST.MF
index 438227a32a1..6adf29412ba 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/META-INF/MANIFEST.MF
@@ -10,13 +10,13 @@ Export-Package: org.eclipse.papyrus.infra.emf.nattable,
org.eclipse.papyrus.infra.emf.nattable.registry,
org.eclipse.papyrus.infra.emf.nattable.selection,
org.eclipse.papyrus.infra.emf.nattable.validator
-Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[2.1.0,3.0.0)";visibility:=reexport,
+Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Name: EMF Nattable
Bundle-Activator: org.eclipse.papyrus.infra.emf.nattable.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/pom.xml
index 98dec14739a..c1811eba5dd 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.emf.nattable</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.emf.nattable</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
index 10d6833a2c3..0e40103f34e 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/cell/EMFFeatureValueCellManager.java
@@ -106,7 +106,7 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
* @param sharedMap
* a map with interesting informations
* @return
- * <code>null</code> or a list of 2 objects.
+ * <code>null</code> or a list of 2 objects.
* <ul>
* <li>the first element is the edited EObject</li>
* <li>the second one is the edited feature</li>
@@ -179,7 +179,7 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
* @param newValue
* the new value
* @return
- * the command to set the value
+ * the command to set the value
*/
protected Command getSetValueCommand(final TransactionalEditingDomain domain, final EObject elementToEdit, final EStructuralFeature featureToEdit, final Object newValue, final Object columnElement, final Object rowElement,
final INattableModelManager tableManager) {
@@ -194,48 +194,51 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
final AbstractEditCommandRequest request = new SetRequest(domain, elementToEdit, featureToEdit, newValue);
final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToEdit);
final ICommand cmd = provider.getEditCommand(request);
- ICommand returnedCommand = (cmd != null) ? cmd : org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;;
- if (cmd.canExecute() && featureToEdit instanceof EReference) {
- boolean shouldOpenDialog = false;
- final EReference editedReference = (EReference) featureToEdit;
-
- // we are editing a containment feature
- if (editedReference.isContainment()) {
- if (newValue instanceof Collection<?>) {
- if (!editedReference.isMany()) {
- return UnexecutableCommand.INSTANCE;
- } else {
- final Collection<?> currentValues = new ArrayList<Object>((Collection<?>) elementToEdit.eGet(editedReference));
- final Collection<?> addedValues = new ArrayList<Object>((Collection<?>) newValue);
- addedValues.removeAll(currentValues);
- // we need to test the added values
- final Iterator<?> iter = ((Collection<?>) addedValues).iterator();
- while (iter.hasNext() && !shouldOpenDialog) {
- final Object current = iter.next();
- if (current instanceof EObject) {
- if (elementToEdit == current) {
- // an element can be owned by itself
- return UnexecutableCommand.INSTANCE;
- } else {
- shouldOpenDialog = ((EObject) current).eContainer() != elementToEdit;
+ if (cmd != null) {
+ ICommand returnedCommand = cmd;
+ if (cmd.canExecute() && featureToEdit instanceof EReference) {
+ boolean shouldOpenDialog = false;
+ final EReference editedReference = (EReference) featureToEdit;
+
+ // we are editing a containment feature
+ if (editedReference.isContainment()) {
+ if (newValue instanceof Collection<?>) {
+ if (!editedReference.isMany()) {
+ return UnexecutableCommand.INSTANCE;
+ } else {
+ final Collection<?> currentValues = new ArrayList<Object>((Collection<?>) elementToEdit.eGet(editedReference));
+ final Collection<?> addedValues = new ArrayList<Object>((Collection<?>) newValue);
+ addedValues.removeAll(currentValues);
+ // we need to test the added values
+ final Iterator<?> iter = ((Collection<?>) addedValues).iterator();
+ while (iter.hasNext() && !shouldOpenDialog) {
+ final Object current = iter.next();
+ if (current instanceof EObject) {
+ if (elementToEdit == current) {
+ // an element can be owned by itself
+ return UnexecutableCommand.INSTANCE;
+ } else {
+ shouldOpenDialog = ((EObject) current).eContainer() != elementToEdit;
+ }
}
}
}
+ } else if (elementToEdit == newValue) {
+ // an element cannot be owned by itself
+ return UnexecutableCommand.INSTANCE;
+ } else if (newValue instanceof EObject) {
+ shouldOpenDialog = ((EObject) newValue).eContainer() != elementToEdit;
}
- } else if (elementToEdit == newValue) {
- // an element cannot be owned by itself
- return UnexecutableCommand.INSTANCE;
- } else if (newValue instanceof EObject) {
- shouldOpenDialog = ((EObject) newValue).eContainer() != elementToEdit;
- }
- if (shouldOpenDialog) {
- returnedCommand = getOpenConfirmChangeContainmentDialogCommand(domain, returnedCommand, editedReference.isMany());
+ if (shouldOpenDialog) {
+ returnedCommand = getOpenConfirmChangeContainmentDialogCommand(domain, returnedCommand, editedReference.isMany());
+ }
}
-
}
+ result.add(returnedCommand);
+ } else {
+ result.add(org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE);
}
- result.add(returnedCommand);
}
return result.isEmpty() ? null : new GMFtoEMFCommandWrapper(result);
}
@@ -283,7 +286,7 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
ConvertedValueContainer<?> solvedValue = valueSolver.deduceValueFromString(editedFeature, newValue);
Object convertedValue = solvedValue.getConvertedValue();
Command setValueCommand = getSetValueCommand(domain, editedObject, editedFeature, convertedValue, columnElement, rowElement, tableManager);
- if(null != setValueCommand && !solvedValue.getStatus().isOK()){
+ if (null != setValueCommand && !solvedValue.getStatus().isOK()) {
setValueCommand = new GMFtoEMFCommandWrapper(new ErrorTransactionalCommand(domain, null, null, solvedValue.getStatus()));
}
return setValueCommand;
@@ -305,7 +308,7 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
* @param valueContainer
* the converted value
* @return
- * the command to create a String resolution Problem
+ * the command to create a String resolution Problem
*/
@Deprecated
// use CellHelper.getCreateStringResolutionProblemCommand(
@@ -366,7 +369,7 @@ public class EMFFeatureValueCellManager extends AbstractCellManager {
* @param valueContainer
* @param sharedMap
*/
- @Deprecated //problem must no be managed here, since Eclipse Mars
+ @Deprecated // problem must no be managed here, since Eclipse Mars
// use CellHelper.createStringResolutionProblem
protected void createStringResolutionProblem(final INattableModelManager tableManager, final Object columnElement, final Object rowElement, final String pastedText, final ConvertedValueContainer<?> valueContainer, final Map<?, ?> sharedMap) {
CellHelper.createStringResolutionProblem(tableManager, columnElement, rowElement, pastedText, valueContainer, sharedMap);
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
index aae0115c45f..b6aea445f90 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
@@ -8,18 +8,18 @@ Export-Package: org.eclipse.papyrus.infra.nattable.common,
org.eclipse.papyrus.infra.nattable.common.utils,
org.eclipse.papyrus.infra.nattable.common.wizards,
org.eclipse.papyrus.infra.nattable.internal.common.commands;x-friends:="org.eclipse.papyrus.infra.nattable.gmfdiag"
-Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[2.1.0,3.0.0)";visibility:=reexport,
+Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.emf.nattable;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.common.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/pom.xml
index 052fe79cc98..d925d431854 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable.common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable.common</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/api/TableEditorCreationHelper.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/api/TableEditorCreationHelper.java
index da467d1d38f..4e8f340936a 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/api/TableEditorCreationHelper.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/api/TableEditorCreationHelper.java
@@ -351,11 +351,13 @@ public class TableEditorCreationHelper {
if (this.creationCommand != null && this.creationCommand.canExecute()) {
this.editingDomain.getCommandStack().execute(creationCommand);
}
- Collection<?> result = creationCommand.getResult();
- if (result.size() > 0) {
- Object res = result.iterator().next();
- if (res instanceof Table) {
- return (Table) res;
+ if (this.creationCommand != null) {
+ Collection<?> result = creationCommand.getResult();
+ if (result.size() > 0) {
+ Object res = result.iterator().next();
+ if (res instanceof Table) {
+ return (Table) res;
+ }
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/META-INF/MANIFEST.MF
index 46c55fe3a05..8c228271846 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/META-INF/MANIFEST.MF
@@ -5,10 +5,10 @@ Export-Package: org.eclipse.papyrus.infra.nattable.controlmode,
Require-Bundle: org.eclipse.papyrus.infra.services.controlmode;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.nattable.common;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.controlmode.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/pom.xml
index d46645fb89e..a613b3ee1d5 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.controlmode/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable.controlmode</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
-</project>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable.controlmode</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.gmfdiag/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.gmfdiag/META-INF/MANIFEST.MF
index 89c05558574..9eb8ec1162d 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.gmfdiag/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.gmfdiag/META-INF/MANIFEST.MF
@@ -1,8 +1,8 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.emf.nattable;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.nattable.common;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
index 44cb4466d48..157431fc326 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
@@ -14,12 +14,12 @@ Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,
org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.extensionpoints.editors;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.views.modelexplorer;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Activator: org.eclipse.papyrus.infra.nattable.modelexplorer.Activator
Bundle-ManifestVersion: 2
Bundle-Description: %pluginDescription
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/pom.xml
index 01b1bf954af..8dde4cb38ea 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable.modelexplorer</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable.modelexplorer</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF
index 8d62f875cf7..66893c61ae5 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/META-INF/MANIFEST.MF
@@ -1,15 +1,15 @@
Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.infra.nattable.properties.constraints
-Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[1.3.0,2.0.0)",
+Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.constraints;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.emf.nattable;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.nattable.common;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 2.2.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.properties.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/pom.xml
index bab927344d0..8141d36f713 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable.properties</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable.properties</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateColumnElementContraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateColumnElementContraint.java
index 93e6b5be626..3b6235f7eb1 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateColumnElementContraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateColumnElementContraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.CreatableEObjectAxisUtils;
/**
* The java constraint to define the constraint to create the paste properties from the active nattable editor.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableCanCreateColumnElementContraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateRowElementContraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateRowElementContraint.java
index 440d3645b3d..cf890afe953 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateRowElementContraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCanCreateRowElementContraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.CreatableEObjectAxisUtils;
/**
* The java constraint to define the constraint to create the paste properties from the active nattable editor.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableCanCreateRowElementContraint extends EObjectInTableHasTreeFillingConfigurationConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateColumnElementContraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateColumnElementContraint.java
index be7ea221715..d80bc172f40 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateColumnElementContraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateColumnElementContraint.java
@@ -18,7 +18,7 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
/**
* The java constraint to define the constraint to not create the paste properties from the active nattable editor.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableCantCreateColumnElementContraint extends EObjectInTableCanCreateColumnElementContraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateRowElementContraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateRowElementContraint.java
index 292f5e35565..1a2df1a7998 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateRowElementContraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableCantCreateRowElementContraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.CreatableEObjectAxisUtils;
/**
* The java constraint to define the constraint to not create the paste properties from the active nattable editor.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableCantCreateRowElementContraint extends EObjectInTableHasTreeFillingConfigurationConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnFeatureLabelConfigurationConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnFeatureLabelConfigurationConstraint.java
index b4ef211e0e6..eeaa2de58b1 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnFeatureLabelConfigurationConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnFeatureLabelConfigurationConstraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtil
/**
* The java constraint to check if the table from the active nattable editor has a feature column label configuration.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableHasColumnFeatureLabelConfigurationConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnObjectLabelConfigurationConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnObjectLabelConfigurationConstraint.java
index 0a73162733d..d97e10948a4 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnObjectLabelConfigurationConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasColumnObjectLabelConfigurationConstraint.java
@@ -21,7 +21,7 @@ import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtil
/**
* The java constraint to check if the table from the active nattable editor has an object column label configuration.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableHasColumnObjectLabelConfigurationConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowFeatureLabelConfigurationConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowFeatureLabelConfigurationConstraint.java
index 8727dc71a75..c0cc9cca09a 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowFeatureLabelConfigurationConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowFeatureLabelConfigurationConstraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtil
/**
* The java constraint to check if the table from the active nattable editor has a feature row label configuration.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableHasRowFeatureLabelConfigurationConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowObjectLabelConfigurationConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowObjectLabelConfigurationConstraint.java
index 86a0d2d6552..0c2c1f468ee 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowObjectLabelConfigurationConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasRowObjectLabelConfigurationConstraint.java
@@ -21,7 +21,7 @@ import org.eclipse.papyrus.infra.nattable.utils.LabelConfigurationManagementUtil
/**
* The java constraint to check if the table from the active nattable editor has an object row label configuration.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableHasRowObjectLabelConfigurationConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasTreeFillingConfigurationConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasTreeFillingConfigurationConstraint.java
index 0d35ac10367..858386f7b07 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasTreeFillingConfigurationConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableHasTreeFillingConfigurationConstraint.java
@@ -20,7 +20,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
/**
* The java constraint to check if the table from the active nattable editor has tree filling configuration for the first depth.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableHasTreeFillingConfigurationConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableIsFlatTableConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableIsFlatTableConstraint.java
index 20ffd857336..9c60f052da3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableIsFlatTableConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableIsFlatTableConstraint.java
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
/**
* The java constraint to check if the table from the active nattable editor is a flat table.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableIsFlatTableConstraint extends EObjectInTableJavaConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableJavaConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableJavaConstraint.java
index 62e6589921b..c29b1295c27 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableJavaConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/EObjectInTableJavaConstraint.java
@@ -23,7 +23,7 @@ import org.eclipse.ui.IEditorPart;
/**
* The java constraint to check if the table from the active nattable editor.
*
- * @since 2.1
+ * @since 2.2
*/
public class EObjectInTableJavaConstraint implements JavaQuery {
@@ -35,31 +35,32 @@ public class EObjectInTableJavaConstraint implements JavaQuery {
@Override
public boolean match(Object selection) {
boolean result = false;
-
+
if (null != EditorHelper.getActivePart()) {
final IEditorPart currentEditor = EditorHelper.getCurrentEditor();
- if (currentEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart)currentEditor).getActiveEditor()) {
- final IMultiPageEditorPart multiDiagramEditor = (IMultiPageEditorPart)currentEditor;
+ if (currentEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart) currentEditor).getActiveEditor()) {
+ final IMultiPageEditorPart multiDiagramEditor = (IMultiPageEditorPart) currentEditor;
final Table table = multiDiagramEditor.getActiveEditor().getAdapter(Table.class);
- if(null != table){
+ if (null != table) {
result = checkMoreConstraints(table);
}
- }else if(currentEditor instanceof IAdaptable){
- final Table table = ((IAdaptable)currentEditor).getAdapter(Table.class);
+ } else if (currentEditor instanceof IAdaptable) {
+ final Table table = ((IAdaptable) currentEditor).getAdapter(Table.class);
result = checkMoreConstraints(table);
}
}
-
+
return result;
}
-
+
/**
* This allows to check more constraint for the match.
*
- * @param table the current table.
+ * @param table
+ * the current table.
* @return <code>true</code> if the constraints are correctly managed, <code>false</code> otherwise.
*/
- protected boolean checkMoreConstraints(final Table table){
+ protected boolean checkMoreConstraints(final Table table) {
return true;
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInFlatTableConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInFlatTableConstraint.java
index 58a2ce8db68..7ea1265d292 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInFlatTableConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInFlatTableConstraint.java
@@ -20,7 +20,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
/**
* The constraint which allow to determinate if this is a nattable editor as current editor part and a flat table.
*
- * @since 2.1
+ * @since 2.2
*/
public class IsEObjectInFlatTableConstraint extends IsEObjectInTableConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTableConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTableConstraint.java
index 1d466b11f13..ab66a5437c5 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTableConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTableConstraint.java
@@ -27,7 +27,7 @@ import org.eclipse.ui.IEditorPart;
/**
* The constraint which allow to determinate if this is a nattable editor as current editor part.
*
- * @since 2.1
+ * @since 2.2
*/
public class IsEObjectInTableConstraint extends AbstractConstraint {
@@ -63,14 +63,14 @@ public class IsEObjectInTableConstraint extends AbstractConstraint {
if (null != EditorHelper.getActivePart()) {
final IEditorPart currentEditor = EditorHelper.getCurrentEditor();
- if (currentEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart)currentEditor).getActiveEditor()) {
- final IMultiPageEditorPart multiDiagramEditor = (IMultiPageEditorPart)currentEditor;
+ if (currentEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart) currentEditor).getActiveEditor()) {
+ final IMultiPageEditorPart multiDiagramEditor = (IMultiPageEditorPart) currentEditor;
result = EditorHelper.getActivePart().equals(currentEditor)
&& null != multiDiagramEditor.getActiveEditor().getAdapter(NatTableEditor.class)
- && checkMoreTableConstraint(((NatTableEditor)multiDiagramEditor.getActiveEditor()).getTable());
- }else if(currentEditor instanceof IAdaptable){
- final Table table = ((IAdaptable)currentEditor).getAdapter(Table.class);
- result = null != table
+ && checkMoreTableConstraint(((NatTableEditor) multiDiagramEditor.getActiveEditor()).getTable());
+ } else if (currentEditor instanceof IAdaptable) {
+ final Table table = ((IAdaptable) currentEditor).getAdapter(Table.class);
+ result = null != table
&& EditorHelper.getActivePart().equals(currentEditor)
&& checkMoreTableConstraint(table);
}
@@ -78,14 +78,15 @@ public class IsEObjectInTableConstraint extends AbstractConstraint {
return expectedValue == result;
}
-
+
/**
* This allows to check more constraint for the match.
*
- * @param table the current table.
+ * @param table
+ * the current table.
* @return <code>true</code> if the constraints are correctly managed, <code>false</code> otherwise.
*/
- protected boolean checkMoreTableConstraint(final Table table){
+ protected boolean checkMoreTableConstraint(final Table table) {
return true;
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTreeTableConstraint.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTreeTableConstraint.java
index aab196058ef..98a484dae8b 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTreeTableConstraint.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.properties/src/org/eclipse/papyrus/infra/nattable/properties/constraints/IsEObjectInTreeTableConstraint.java
@@ -20,7 +20,7 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
/**
* The constraint which allow to determinate if this is a nattable editor as current editor part and a tree table.
*
- * @since 2.1
+ * @since 2.2
*/
public class IsEObjectInTreeTableConstraint extends IsEObjectInTableConstraint {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/META-INF/MANIFEST.MF
index be2075d042d..9385e32bdd5 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/META-INF/MANIFEST.MF
@@ -7,12 +7,12 @@ Export-Package: org.eclipse.papyrus.infra.nattable.views.config,
org.eclipse.papyrus.infra.nattable.views.config.provider,
org.eclipse.papyrus.infra.nattable.views.config.utils
Require-Bundle: org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.emf.nattable;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.emf.nattable;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.views.config.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/pom.xml
index 346230debc0..d4e18be48fb 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.config/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable.views.config</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable.views.config</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.editor/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.editor/META-INF/MANIFEST.MF
index 51101591acb..4cd05bc6159 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.editor/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.views.editor/META-INF/MANIFEST.MF
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[2.0.0,3.0.0)"
+Require-Bundle: org.eclipse.papyrus.infra.nattable.common;bundle-version="[3.0.0,4.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index 6e5e64b4939..936fe2d883f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -59,15 +59,15 @@ Require-Bundle: org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0
org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.4.0,2.0.0)",
ca.odell.glazedlists;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.services.decoration;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.ui.emf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.ui.emf;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.editor;bundle-version="[1.4.0,2.0.0)"
+ org.eclipse.papyrus.editor;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.1.0.qualifier
+Bundle-Version: 3.0.0.qualifier
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
index 1c2698e8f8e..799251ff3ce 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.nattable</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-nattable</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.nattable</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/comparator/DoubleFilterComparator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/comparator/DoubleFilterComparator.java
index f78303122a1..adbc33db977 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/comparator/DoubleFilterComparator.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/comparator/DoubleFilterComparator.java
@@ -1,74 +1,74 @@
-/*****************************************************************************
- * 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.nattable.comparator;
-
-import java.math.BigDecimal;
-import java.util.Comparator;
-
-import org.eclipse.papyrus.infra.nattable.filter.FilterPreferences;
-import org.eclipse.papyrus.infra.tools.util.TypeUtils;
-
-/**
- * @author VL222926
- *
- */
-public class DoubleFilterComparator implements Comparator<Object> {
-
- private static DoubleFilterComparator singleton;
-
- /**
- *
- * @return
- */
- public static final DoubleFilterComparator getInstance() {
- if (singleton == null) {
- singleton = new DoubleFilterComparator();
- }
- return singleton;
- }
-
- /**
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- *
- * @param o1
- * @param o2
- * @return
- */
- @Override
- public int compare(Object o1, Object o2) {
- if (o1 instanceof Double && o2 instanceof Double) {
- Double d1 = (Double) o1;
- Double d2 = (Double) o2;
- return d1.compareTo(d2);
- }
- if (!(o1 instanceof Double)) {
- return FilterPreferences.INCONSISTENT_VALUE;
- }
- // o1 is the cell value and o2 the value to match
- if (o1 instanceof Double) {
- Double d1 = (Double) o1;
- Double d2 = null;
- if (o2 instanceof Double) {
- if (TypeUtils.isDoubleValue((String) o2)) {
- // big decimal to avoid to get comma as separator instead of dot
- d2 = new BigDecimal((String) o2).doubleValue();
- return d1.compareTo(d2);
- }
- return FilterPreferences.INCONSISTENT_VALUE;
- }
- }
- return FilterPreferences.INCONSISTENT_VALUE;
- }
-
-}
+/*****************************************************************************
+ * 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.nattable.comparator;
+
+import java.math.BigDecimal;
+import java.util.Comparator;
+
+import org.eclipse.papyrus.infra.nattable.filter.FilterPreferences;
+import org.eclipse.papyrus.infra.tools.util.TypeUtils;
+
+/**
+ * @author VL222926
+ *
+ */
+public class DoubleFilterComparator implements Comparator<Object> {
+
+ private static DoubleFilterComparator singleton;
+
+ /**
+ *
+ * @return
+ */
+ public static final DoubleFilterComparator getInstance() {
+ if (singleton == null) {
+ singleton = new DoubleFilterComparator();
+ }
+ return singleton;
+ }
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ @Override
+ public int compare(Object o1, Object o2) {
+ if (o1 instanceof Double && o2 instanceof Double) {
+ Double d1 = (Double) o1;
+ Double d2 = (Double) o2;
+ return d1.compareTo(d2);
+ }
+ if (!(o1 instanceof Double)) {
+ return FilterPreferences.INCONSISTENT_VALUE;
+ }
+ // o1 is the cell value and o2 the value to match
+ if (o1 instanceof Double) {
+ Double d1 = (Double) o1;
+ Double d2 = null;
+ if (o2 instanceof Double) {
+ if (TypeUtils.isDoubleValue(o2.toString())) {
+ // big decimal to avoid to get comma as separator instead of dot
+ d2 = new BigDecimal(o2.toString()).doubleValue();
+ return d1.compareTo(d2);
+ }
+ return FilterPreferences.INCONSISTENT_VALUE;
+ }
+ }
+ return FilterPreferences.INCONSISTENT_VALUE;
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/FilterRowDataProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/FilterRowDataProvider.java
index 54640513a3b..75ba4fda298 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/FilterRowDataProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/FilterRowDataProvider.java
@@ -1,579 +1,580 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Original authors 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:
- * Original authors and others - initial API and implementation
- ******************************************************************************/
-package org.eclipse.papyrus.infra.nattable.dataprovider;
-
-
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.nebula.widgets.nattable.NatTable;
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
-import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
-import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer;
-import org.eclipse.nebula.widgets.nattable.filterrow.IFilterStrategy;
-import org.eclipse.nebula.widgets.nattable.filterrow.event.FilterAppliedEvent;
-import org.eclipse.nebula.widgets.nattable.layer.ILayer;
-import org.eclipse.nebula.widgets.nattable.persistence.IPersistable;
-import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
-import org.eclipse.nebula.widgets.nattable.util.ObjectUtils;
-import org.eclipse.papyrus.infra.nattable.filter.IFilterValueToMatchManager;
-import org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
-import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
-import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * Data provider for the filter row
- * <ul>
- * <li>Stores filter strings</li>
- * <li>Applies them to the ca.odell.glazedlists.matchers.MatcherEditor on the ca.odell.glazedlists.FilterList</li>
- * </ul>
- *
- * Duplicated and adapted code from nattable
- */
-public class FilterRowDataProvider<T> implements IDataProvider /* , IPersistable */{
-
- /**
- * Replacement for the pipe character | that is used for persistence.
- * If regular expressions are used for filtering, the pipe character can be used
- * in the regular expression to specify alternations. As the persistence
- * mechanism in NatTable uses the pipe character for separation of values,
- * the persistence breaks for such cases.
- * By replacing the pipe in the regular expression with some silly uncommon
- * value specified here, we ensure to be able to also persist pipes in the
- * regular expressions, aswell as being backwards compatible with already
- * saved filter row states.
- */
- public static final String PIPE_REPLACEMENT = "°~°"; //$NON-NLS-1$
-
- /**
- * The prefix String that will be used to mark that the following filter
- * value in the persisted state is a collection.
- */
- public static final String FILTER_COLLECTION_PREFIX = "°coll("; //$NON-NLS-1$
-
- /**
- * The {@link IFilterStrategy} to which the set filter value should be applied.
- */
- private final IFilterStrategy<T> filterStrategy;
- /**
- * The column header layer where this {@link IDataProvider} is used for filtering.
- * Needed for retrieval of column indexes and firing according filter events.
- */
- private final ILayer columnHeaderLayer;
- /**
- * The {@link IDataProvider} of the column header.
- * This is necessary to retrieve the real column count of the column header and not a
- * transformed one. (e.g. hiding a column would change the column count in the column header
- * but not in the column header {@link IDataProvider}).
- */
- private final IDataProvider columnHeaderDataProvider;
-
- // /**
- // * The {@link IConfigRegistry} needed to retrieve the {@link IDisplayConverter} for converting
- // * the values on state save/load operations.
- // */
- // private final IConfigRegistry configRegistry;
-
- private final INattableModelManager manager;
- /**
- * Contains the filter objects mapped to the column index.
- * Basically the data storage for the set filters in the filter row so they are
- * visible to the user who entered them.
- */
- private Map<Integer, Object> filterIndexToObjectMap = new HashMap<Integer, Object>();
-
- private Runnable refreshFilterRunnable;
-
- /* Flag to avoid reentrant call to refresh */
- private AtomicBoolean isFilterRefreshing = new AtomicBoolean(false);
-
-// private ResourceSetListener listener;
-
-
- /**
- *
- * @param filterStrategy
- * The {@link IFilterStrategy} to which the set filter value should be applied.
- * @param columnHeaderLayer
- * The column header layer where this {@link IDataProvider} is used for filtering
- * needed for retrieval of column indexes and firing according filter events..
- * @param columnHeaderDataProvider
- * The {@link IDataProvider} of the column header needed to retrieve the real
- * column count of the column header and not a transformed one.
- * @param tableManager
- * The {@link IConfigRegistry} needed to retrieve the {@link IDisplayConverter} for
- * converting the values on state save/load operations.
- */
- public FilterRowDataProvider(IFilterStrategy<T> filterStrategy, ILayer columnHeaderLayer, IDataProvider columnHeaderDataProvider, INattableModelManager tableManager) {
- this.filterStrategy = filterStrategy;
- this.columnHeaderLayer = columnHeaderLayer;
- this.columnHeaderDataProvider = columnHeaderDataProvider;
- this.manager = tableManager;
-// TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(this.manager.getTable());
-// listener = new ResourceSetListener() {
-//
-// @Override
-// public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// @Override
-// public void resourceSetChanged(ResourceSetChangeEvent event) {
-// // TODO Auto-generated method stub
-// for (Notification current : event.getNotifications()) {
-// if (current.getNotifier() instanceof IAxis) {
-// IAxis axis = (IAxis) current.getNotifier();
-// EObject parent = axis.eContainer();
-// if (current.getOldValue() instanceof NamedStyle) {
-// NamedStyle style = (NamedStyle) current.getOldValue();
-// if (style.getName().equals(IFilterConfiguration.FILTER_VALUE_TO_MATCH)) {
-// int index = manager.getColumnElementsList().indexOf(axis);
-// getDataValue(index, 0);
-// applyFilter();
-// }
-// }
-// if (current.getNewValue() instanceof NamedStyle) {
-// NamedStyle style = (NamedStyle) current.getOldValue();
-// if (style.getName().equals(IFilterConfiguration.FILTER_VALUE_TO_MATCH)) {
-// int index = manager.getColumnElementsList().indexOf(axis);
-// getDataValue(index, 0);
-// applyFilter();
-// }
-// }
-// }
-//
-// }
-//
-// }
-//
-// @Override
-// public boolean isPrecommitOnly() {
-// // TODO Auto-generated method stub
-// return false;
-// }
-//
-// @Override
-// public boolean isPostcommitOnly() {
-// // TODO Auto-generated method stub
-// return false;
-// }
-//
-// @Override
-// public boolean isAggregatePrecommitListener() {
-// // TODO Auto-generated method stub
-// return false;
-// }
-//
-// @Override
-// public NotificationFilter getFilter() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-// };
-// domain.addResourceSetListener(listener);
- }
-
- /**
- * Returns the map that contains the filter objects mapped to the column index.
- * It is the data storage for the inserted filters into the filter row by the user.
- * <p>
- * Note: Usually it is not intended to modify this Map directly. You should rather call <code>setDataValue(int, int, Object)</code> or <code>clearAllFilters()</code> to modify this Map to ensure consistency in other framework code. It is made visible
- * because there might be code that needs to modify the Map without index transformations or firing events.
- *
- * @return Map that contains the filter objects mapped to the column index.
- */
- public Map<Integer, Object> getFilterIndexToObjectMap() {
- return this.filterIndexToObjectMap;
- }
-
- /**
- * Set the map that contains the filter objects mapped to the column index to be the
- * data storage for the inserted filters into the filter row by the user.
- * <p>
- * Note: Usually it is not intended to set this Map from the outside as it is created in the constructor. But there might be use cases where you e.g. need to connect filter rows to each other. In this case it might be useful to override the local Map with
- * the one form another FilterRowDataProvider. This is not a typical use case, therefore you should use this method carefully!
- *
- * @param filterIndexToObjectMap
- * Map that contains the filter objects mapped to the column index.
- */
- public void setFilterIndexToObjectMap(Map<Integer, Object> filterIndexToObjectMap) {
- this.filterIndexToObjectMap = filterIndexToObjectMap;
- }
-
- @Override
- public int getColumnCount() {
- return columnHeaderDataProvider.getColumnCount();
- }
-
- public void updateMapValue(int columnIndex) {
- NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
- IConfigRegistry configRegistry = natTable.getConfigRegistry();
-
- if (manager != null) {
- IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
- if (loader != null) {
- Object columnObject = manager.getColumnElement(columnIndex);
- Object savedValue = loader.getValueToMatch(configRegistry, columnObject);
- // to manage undo/redo
- Object mapValue = filterIndexToObjectMap.get(columnIndex);
- if (savedValue != mapValue) {
- if ((mapValue != null && !mapValue.equals(savedValue)) || (savedValue != null && !savedValue.equals(mapValue))) {
- if (savedValue == null) {
- filterIndexToObjectMap.remove(columnIndex);
- } else {
- filterIndexToObjectMap.put(columnIndex, savedValue);
- }
- applyFilter();
- }
- }
- }
- }
- }
-
- @Override
- public Object getDataValue(int columnIndex, int rowIndex) {
-// NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
-// IConfigRegistry configRegistry = natTable.getConfigRegistry();
-//
-// if (manager != null) {
-// IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
-// if (loader != null) {
-// Object columnObject = manager.getColumnElement(columnIndex);
-// Object savedValue = loader.getValueToMatch(configRegistry, columnObject);
-// // to manage undo/redo
-// Object mapValue = filterIndexToObjectMap.get(columnIndex);
-// if (savedValue != mapValue) {
-// if ((mapValue != null && !mapValue.equals(savedValue)) || (savedValue != null && !savedValue.equals(mapValue))) {
-// if (savedValue == null) {
-// filterIndexToObjectMap.remove(columnIndex);
-// } else {
-// filterIndexToObjectMap.put(columnIndex, savedValue);
-// }
-// applyFilter();
-//
-// }
-// }
-// }
-// }
-
- return filterIndexToObjectMap.get(columnIndex);
- }
-
- /**
- * refresh the view.
- */
- protected void refreshFilterInUIThread() {
- NatTable natTable = getNatTable();
- // Need to refresh, even if (temporarily) invisible
- // (Better alternative?: store refresh event and execute once visible again)
- if (natTable != null && natTable.isDisposed()) {
- return;
- }
-
- // avoid reentrant call
- // Refresh only of we are not already refreshing.
- if (isFilterRefreshing.compareAndSet(false, true)) {
- filterStrategy.applyFilter(filterIndexToObjectMap);
- columnHeaderLayer.fireLayerEvent(new FilterAppliedEvent(columnHeaderLayer));
- isFilterRefreshing.set(false);
- }
- }
-
-
-
- /**
- *
- * @return
- * a new runnable for the refreash action
- */
- private Runnable createRefreshFilterRunnable() {
- return new Runnable() {
-
- @Override
- public void run() {
- // Only run if I'm still pending
- synchronized (this) {
- if (refreshFilterRunnable != this) {
- return;
- }
-
- refreshFilterRunnable = null;
- }
- refreshFilterInUIThread();
- ((NattableModelManager) manager).refreshNatTable();
- }
- };
- }
-
- private NatTable getNatTable() {
- return (NatTable) manager.getAdapter(NatTable.class);
- }
-
- public void applyFilter() {
- // This refresh code has been duplicated from the refresh of the ModelExplorer (class ModelExplorerView)
- final Runnable schedule;
- NatTable natTable = getNatTable();
- if (natTable != null && !natTable.isDisposed()) {
- synchronized (this) {
- if (refreshFilterRunnable == null) {
- // No refresh is yet pending. Schedule one
- schedule = createRefreshFilterRunnable();
- refreshFilterRunnable = schedule;
- } else {
- schedule = null;
- }
- }
-
- if (schedule != null) {
- Control control = natTable;
- Display display = ((control == null) || control.isDisposed()) ? null : control.getDisplay();
-
- if (display != null) {
- // Don't need to schedule a refresh if we have no control or it's disposed
- display.asyncExec(schedule);
- }
- }
- }
- }
-
-
-
- @Override
- public int getRowCount() {
- return 1;
- }
-
- @Override
- public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
- columnIndex = columnHeaderLayer.getColumnIndexByPosition(columnIndex);
- // INattableModelManager manager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
-
- NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
- IConfigRegistry configRegistry = natTable.getConfigRegistry();
- if (manager != null) {
- IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
- if (loader != null) {
- Object columnObject = manager.getColumnElement(columnIndex);
- loader.saveValueToMatch(configRegistry, columnObject, newValue);
- }
- }
- if (ObjectUtils.isNotNull(newValue)) {
- filterIndexToObjectMap.put(columnIndex, newValue);
- } else {
- filterIndexToObjectMap.remove(columnIndex);
- }
-
- filterStrategy.applyFilter(filterIndexToObjectMap);
-
- columnHeaderLayer.fireLayerEvent(new FilterAppliedEvent(columnHeaderLayer));
- }
-
- /**
- *
- * @param columnIndex
- * the index of the column
- * @return
- * the filter value to match manager to use
- */
- private IFilterValueToMatchManager getFilterValueToMatchManager(int columnIndex) {
- StringBuilder builder = new StringBuilder();
- builder.append(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX);
- builder.append(Integer.valueOf(columnIndex));
- return getConfigRegistry().getConfigAttribute(NattableConfigAttributes.FILTER_VALUE_TO_MATCH_MANAGER, DisplayMode.NORMAL, builder.toString());
- }
-
- /**
- *
- * @return
- * the config registry to used by the nattable widget
- */
- private IConfigRegistry getConfigRegistry() {
- NatTable natTable = (NatTable) this.manager.getAdapter(NatTable.class);
- return natTable.getConfigRegistry();
- }
-
- // Load/save state
- //
- // @Override
- // public void saveState(String prefix, Properties properties) {
- // Map<Integer, String> filterTextByIndex = new HashMap<Integer, String>();
- // for(Integer columnIndex : filterIndexToObjectMap.keySet()) {
- // final IDisplayConverter converter = configRegistry.getConfigAttribute(
- // CellConfigAttributes.DISPLAY_CONVERTER,
- // DisplayMode.NORMAL,
- // FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + columnIndex);
- //
- // String filterText = getFilterStringRepresentation(filterIndexToObjectMap.get(columnIndex), converter);
- // filterText = filterText.replace("|", PIPE_REPLACEMENT); //$NON-NLS-1$
- // filterTextByIndex.put(columnIndex, filterText);
- // }
- //
- // String string = PersistenceUtils.mapAsString(filterTextByIndex);
- //
- // if (!isEmpty(string)) {
- // properties.put(prefix + FilterRowDataLayer.PERSISTENCE_KEY_FILTER_ROW_TOKENS, string);
- // }
- // }
-
- // @Override
- // public void loadState(String prefix, Properties properties) {
- // filterIndexToObjectMap.clear();
- //
- // try {
- // Object property = properties.get(prefix + FilterRowDataLayer.PERSISTENCE_KEY_FILTER_ROW_TOKENS);
- // Map<Integer, String> filterTextByIndex = PersistenceUtils.parseString(property);
- // for (Integer columnIndex : filterTextByIndex.keySet()) {
- // final IDisplayConverter converter = configRegistry.getConfigAttribute(
- // CellConfigAttributes.DISPLAY_CONVERTER,
- // DisplayMode.NORMAL,
- // FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + columnIndex);
- //
- // String filterText = filterTextByIndex.get(columnIndex);
- // filterText = filterText.replace(PIPE_REPLACEMENT, "|"); //$NON-NLS-1$
- // filterIndexToObjectMap.put(columnIndex, getFilterFromString(filterText, converter));
- // }
- // } catch (Exception e) {
- // log.error("Error while restoring filter row text!", e); //$NON-NLS-1$
- // }
-
- // filterStrategy.applyFilter(filterIndexToObjectMap);
- // }
-
- /**
- * This method is used to support saving of a filter collection, e.g. in the context of the
- * Excel like filter row. In such cases the filter value is not a simple String but a
- * Collection of filter values that need to be converted to a String representation.
- * As the state persistence is encapsulated to be handled here, we need to take care
- * of such states here also.
- *
- * @param filterValue
- * The filter value object that is used for filtering.
- * @param converter
- * The converter that is used to convert the filter value, which is necessary
- * to support filtering of custom types.
- * @return The String representation of the filter value.
- */
- private String getFilterStringRepresentation(Object filterValue, IDisplayConverter converter) {
- // in case the filter value is a collection of values, we need to create a special
- // string representation
- if (filterValue instanceof Collection) {
- String collectionSpec = FILTER_COLLECTION_PREFIX + filterValue.getClass().getName() + ")"; //$NON-NLS-1$
- StringBuilder builder = new StringBuilder(collectionSpec);
- builder.append("["); //$NON-NLS-1$
- Collection<?> filterCollection = (Collection<?>) filterValue;
- for (Iterator<?> iterator = filterCollection.iterator(); iterator.hasNext();) {
- Object filterObject = iterator.next();
- builder.append(converter.canonicalToDisplayValue(filterObject));
- if (iterator.hasNext())
- builder.append(IPersistable.VALUE_SEPARATOR);
- }
-
- builder.append("]"); //$NON-NLS-1$
- return builder.toString();
- }
- return (String) converter.canonicalToDisplayValue(filterValue);
- }
-
- /**
- * This method is used to support loading of a filter collection, e.g. in the context of the
- * Excel like filter row. In such cases the saved filter value is not a simple String but
- * represents a Collection of filter values that need to be converted to the corresponding values.
- * As the state persistence is encapsulated to be handled here, we need to take care
- * of such states here also.
- *
- * @param filterText
- * The String representation of the applied saved filter.
- * @param converter
- * The converter that is used to convert the filter value, which is necessary
- * to support filtering of custom types.
- * @return The filter value that will be used to apply a filter to the IFilterStrategy
- *
- * @throws InstantiationException
- * @throws IllegalAccessException
- * @throws ClassNotFoundException
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private Object getFilterFromString(String filterText, IDisplayConverter converter) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
- if (filterText.startsWith(FILTER_COLLECTION_PREFIX)) {
- // the filter text represents a collection
- int indexEndCollSpec = filterText.indexOf(")"); //$NON-NLS-1$
- String collectionSpec = filterText.substring(filterText.indexOf("(") + 1, indexEndCollSpec); //$NON-NLS-1$
- Collection filterCollection = (Collection) Class.forName(collectionSpec).newInstance();
-
- // also get rid of the collection marks
- filterText = filterText.substring(indexEndCollSpec + 2, filterText.length() - 1);
- String[] filterSplit = filterText.split(IPersistable.VALUE_SEPARATOR);
- for (String filterString : filterSplit) {
- filterCollection.add(converter.displayToCanonicalValue(filterString));
- }
-
- return filterCollection;
- }
- return converter.displayToCanonicalValue(filterText);
- }
-
- /**
- * Clear all filters that are currently applied.
- */
- public void clearAllFilters() {
- filterIndexToObjectMap.clear();
- filterStrategy.applyFilter(filterIndexToObjectMap);
-
- // we clear the filter
- if (manager != null) {
- CompoundCommand cc = new CompoundCommand("Clear All Filter"); //$NON-NLS-1$
- TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(manager.getTable());
- List<?> columnElement = manager.getColumnElementsList();
- for (Object current : columnElement) {
- if (current instanceof IAxis) {
- Style idToDestroy = ((IAxis) current).getNamedStyle(NattablestylePackage.eINSTANCE.getStringValueStyle(), IFilterConfiguration.FILTER_SYSTEM_ID);
- Style keyToDestroy = ((IAxis) current).getNamedStyle(NattablestylePackage.eINSTANCE.getStyle(), IFilterConfiguration.FILTER_FORCED_BY_USER_ID);
-
- if (idToDestroy != null) {
- Command cmd = DeleteCommand.create(domain, idToDestroy);
- if (cmd != null && cmd.canExecute()) {
- cc.append(cmd);
- }
- }
- if (idToDestroy != null) {
- Command cmd = DeleteCommand.create(domain, keyToDestroy);
- if (cmd != null && cmd.canExecute()) {
- cc.append(cmd);
- }
- }
- }
- }
- if (!cc.isEmpty() && cc.canExecute()) {
- domain.getCommandStack().execute(cc);
- }
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Original authors 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:
+ * Original authors and others - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.papyrus.infra.nattable.dataprovider;
+
+
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer;
+import org.eclipse.nebula.widgets.nattable.filterrow.IFilterStrategy;
+import org.eclipse.nebula.widgets.nattable.filterrow.event.FilterAppliedEvent;
+import org.eclipse.nebula.widgets.nattable.layer.ILayer;
+import org.eclipse.nebula.widgets.nattable.persistence.IPersistable;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.util.ObjectUtils;
+import org.eclipse.papyrus.infra.nattable.filter.IFilterValueToMatchManager;
+import org.eclipse.papyrus.infra.nattable.filter.configuration.IFilterConfiguration;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * Data provider for the filter row
+ * <ul>
+ * <li>Stores filter strings</li>
+ * <li>Applies them to the ca.odell.glazedlists.matchers.MatcherEditor on the ca.odell.glazedlists.FilterList</li>
+ * </ul>
+ *
+ * Duplicated and adapted code from nattable
+ */
+public class FilterRowDataProvider<T> implements IDataProvider /* , IPersistable */ {
+
+ /**
+ * Replacement for the pipe character | that is used for persistence.
+ * If regular expressions are used for filtering, the pipe character can be used
+ * in the regular expression to specify alternations. As the persistence
+ * mechanism in NatTable uses the pipe character for separation of values,
+ * the persistence breaks for such cases.
+ * By replacing the pipe in the regular expression with some silly uncommon
+ * value specified here, we ensure to be able to also persist pipes in the
+ * regular expressions, aswell as being backwards compatible with already
+ * saved filter row states.
+ */
+ public static final String PIPE_REPLACEMENT = "°~°"; //$NON-NLS-1$
+
+ /**
+ * The prefix String that will be used to mark that the following filter
+ * value in the persisted state is a collection.
+ */
+ public static final String FILTER_COLLECTION_PREFIX = "°coll("; //$NON-NLS-1$
+
+ /**
+ * The {@link IFilterStrategy} to which the set filter value should be applied.
+ */
+ private final IFilterStrategy<T> filterStrategy;
+ /**
+ * The column header layer where this {@link IDataProvider} is used for filtering.
+ * Needed for retrieval of column indexes and firing according filter events.
+ */
+ private final ILayer columnHeaderLayer;
+ /**
+ * The {@link IDataProvider} of the column header.
+ * This is necessary to retrieve the real column count of the column header and not a
+ * transformed one. (e.g. hiding a column would change the column count in the column header
+ * but not in the column header {@link IDataProvider}).
+ */
+ private final IDataProvider columnHeaderDataProvider;
+
+ // /**
+ // * The {@link IConfigRegistry} needed to retrieve the {@link IDisplayConverter} for converting
+ // * the values on state save/load operations.
+ // */
+ // private final IConfigRegistry configRegistry;
+
+ private final INattableModelManager manager;
+ /**
+ * Contains the filter objects mapped to the column index.
+ * Basically the data storage for the set filters in the filter row so they are
+ * visible to the user who entered them.
+ */
+ private Map<Integer, Object> filterIndexToObjectMap = new HashMap<Integer, Object>();
+
+ private Runnable refreshFilterRunnable;
+
+ /* Flag to avoid reentrant call to refresh */
+ private AtomicBoolean isFilterRefreshing = new AtomicBoolean(false);
+
+ // private ResourceSetListener listener;
+
+
+ /**
+ *
+ * @param filterStrategy
+ * The {@link IFilterStrategy} to which the set filter value should be applied.
+ * @param columnHeaderLayer
+ * The column header layer where this {@link IDataProvider} is used for filtering
+ * needed for retrieval of column indexes and firing according filter events..
+ * @param columnHeaderDataProvider
+ * The {@link IDataProvider} of the column header needed to retrieve the real
+ * column count of the column header and not a transformed one.
+ * @param tableManager
+ * The {@link IConfigRegistry} needed to retrieve the {@link IDisplayConverter} for
+ * converting the values on state save/load operations.
+ */
+ public FilterRowDataProvider(IFilterStrategy<T> filterStrategy, ILayer columnHeaderLayer, IDataProvider columnHeaderDataProvider, INattableModelManager tableManager) {
+ this.filterStrategy = filterStrategy;
+ this.columnHeaderLayer = columnHeaderLayer;
+ this.columnHeaderDataProvider = columnHeaderDataProvider;
+ this.manager = tableManager;
+ // TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(this.manager.getTable());
+ // listener = new ResourceSetListener() {
+ //
+ // @Override
+ // public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
+ // // TODO Auto-generated method stub
+ // return null;
+ // }
+ //
+ // @Override
+ // public void resourceSetChanged(ResourceSetChangeEvent event) {
+ // // TODO Auto-generated method stub
+ // for (Notification current : event.getNotifications()) {
+ // if (current.getNotifier() instanceof IAxis) {
+ // IAxis axis = (IAxis) current.getNotifier();
+ // EObject parent = axis.eContainer();
+ // if (current.getOldValue() instanceof NamedStyle) {
+ // NamedStyle style = (NamedStyle) current.getOldValue();
+ // if (style.getName().equals(IFilterConfiguration.FILTER_VALUE_TO_MATCH)) {
+ // int index = manager.getColumnElementsList().indexOf(axis);
+ // getDataValue(index, 0);
+ // applyFilter();
+ // }
+ // }
+ // if (current.getNewValue() instanceof NamedStyle) {
+ // NamedStyle style = (NamedStyle) current.getOldValue();
+ // if (style.getName().equals(IFilterConfiguration.FILTER_VALUE_TO_MATCH)) {
+ // int index = manager.getColumnElementsList().indexOf(axis);
+ // getDataValue(index, 0);
+ // applyFilter();
+ // }
+ // }
+ // }
+ //
+ // }
+ //
+ // }
+ //
+ // @Override
+ // public boolean isPrecommitOnly() {
+ // // TODO Auto-generated method stub
+ // return false;
+ // }
+ //
+ // @Override
+ // public boolean isPostcommitOnly() {
+ // // TODO Auto-generated method stub
+ // return false;
+ // }
+ //
+ // @Override
+ // public boolean isAggregatePrecommitListener() {
+ // // TODO Auto-generated method stub
+ // return false;
+ // }
+ //
+ // @Override
+ // public NotificationFilter getFilter() {
+ // // TODO Auto-generated method stub
+ // return null;
+ // }
+ // };
+ // domain.addResourceSetListener(listener);
+ }
+
+ /**
+ * Returns the map that contains the filter objects mapped to the column index.
+ * It is the data storage for the inserted filters into the filter row by the user.
+ * <p>
+ * Note: Usually it is not intended to modify this Map directly. You should rather call <code>setDataValue(int, int, Object)</code> or <code>clearAllFilters()</code> to modify this Map to ensure consistency in other framework code. It is made visible
+ * because there might be code that needs to modify the Map without index transformations or firing events.
+ *
+ * @return Map that contains the filter objects mapped to the column index.
+ */
+ public Map<Integer, Object> getFilterIndexToObjectMap() {
+ return this.filterIndexToObjectMap;
+ }
+
+ /**
+ * Set the map that contains the filter objects mapped to the column index to be the
+ * data storage for the inserted filters into the filter row by the user.
+ * <p>
+ * Note: Usually it is not intended to set this Map from the outside as it is created in the constructor. But there might be use cases where you e.g. need to connect filter rows to each other. In this case it might be useful to override the local Map with
+ * the one form another FilterRowDataProvider. This is not a typical use case, therefore you should use this method carefully!
+ *
+ * @param filterIndexToObjectMap
+ * Map that contains the filter objects mapped to the column index.
+ */
+ public void setFilterIndexToObjectMap(Map<Integer, Object> filterIndexToObjectMap) {
+ this.filterIndexToObjectMap = filterIndexToObjectMap;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnHeaderDataProvider.getColumnCount();
+ }
+
+ public void updateMapValue(int columnIndex) {
+ if (manager != null) {
+ NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
+ IConfigRegistry configRegistry = natTable.getConfigRegistry();
+
+
+ IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
+ if (loader != null) {
+ Object columnObject = manager.getColumnElement(columnIndex);
+ Object savedValue = loader.getValueToMatch(configRegistry, columnObject);
+ // to manage undo/redo
+ Object mapValue = filterIndexToObjectMap.get(columnIndex);
+ if (savedValue != mapValue) {
+ if ((mapValue != null && !mapValue.equals(savedValue)) || (savedValue != null && !savedValue.equals(mapValue))) {
+ if (savedValue == null) {
+ filterIndexToObjectMap.remove(columnIndex);
+ } else {
+ filterIndexToObjectMap.put(columnIndex, savedValue);
+ }
+ applyFilter();
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public Object getDataValue(int columnIndex, int rowIndex) {
+ // NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
+ // IConfigRegistry configRegistry = natTable.getConfigRegistry();
+ //
+ // if (manager != null) {
+ // IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
+ // if (loader != null) {
+ // Object columnObject = manager.getColumnElement(columnIndex);
+ // Object savedValue = loader.getValueToMatch(configRegistry, columnObject);
+ // // to manage undo/redo
+ // Object mapValue = filterIndexToObjectMap.get(columnIndex);
+ // if (savedValue != mapValue) {
+ // if ((mapValue != null && !mapValue.equals(savedValue)) || (savedValue != null && !savedValue.equals(mapValue))) {
+ // if (savedValue == null) {
+ // filterIndexToObjectMap.remove(columnIndex);
+ // } else {
+ // filterIndexToObjectMap.put(columnIndex, savedValue);
+ // }
+ // applyFilter();
+ //
+ // }
+ // }
+ // }
+ // }
+
+ return filterIndexToObjectMap.get(columnIndex);
+ }
+
+ /**
+ * refresh the view.
+ */
+ protected void refreshFilterInUIThread() {
+ NatTable natTable = getNatTable();
+ // Need to refresh, even if (temporarily) invisible
+ // (Better alternative?: store refresh event and execute once visible again)
+ if (natTable != null && natTable.isDisposed()) {
+ return;
+ }
+
+ // avoid reentrant call
+ // Refresh only of we are not already refreshing.
+ if (isFilterRefreshing.compareAndSet(false, true)) {
+ filterStrategy.applyFilter(filterIndexToObjectMap);
+ columnHeaderLayer.fireLayerEvent(new FilterAppliedEvent(columnHeaderLayer));
+ isFilterRefreshing.set(false);
+ }
+ }
+
+
+
+ /**
+ *
+ * @return
+ * a new runnable for the refreash action
+ */
+ private Runnable createRefreshFilterRunnable() {
+ return new Runnable() {
+
+ @Override
+ public void run() {
+ // Only run if I'm still pending
+ synchronized (this) {
+ if (refreshFilterRunnable != this) {
+ return;
+ }
+
+ refreshFilterRunnable = null;
+ }
+ refreshFilterInUIThread();
+ ((NattableModelManager) manager).refreshNatTable();
+ }
+ };
+ }
+
+ private NatTable getNatTable() {
+ return (NatTable) manager.getAdapter(NatTable.class);
+ }
+
+ public void applyFilter() {
+ // This refresh code has been duplicated from the refresh of the ModelExplorer (class ModelExplorerView)
+ final Runnable schedule;
+ NatTable natTable = getNatTable();
+ if (natTable != null && !natTable.isDisposed()) {
+ synchronized (this) {
+ if (refreshFilterRunnable == null) {
+ // No refresh is yet pending. Schedule one
+ schedule = createRefreshFilterRunnable();
+ refreshFilterRunnable = schedule;
+ } else {
+ schedule = null;
+ }
+ }
+
+ if (schedule != null) {
+ Control control = natTable;
+ Display display = ((control == null) || control.isDisposed()) ? null : control.getDisplay();
+
+ if (display != null) {
+ // Don't need to schedule a refresh if we have no control or it's disposed
+ display.asyncExec(schedule);
+ }
+ }
+ }
+ }
+
+
+
+ @Override
+ public int getRowCount() {
+ return 1;
+ }
+
+ @Override
+ public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
+ columnIndex = columnHeaderLayer.getColumnIndexByPosition(columnIndex);
+ // INattableModelManager manager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ if (manager != null) {
+ NatTable natTable = (NatTable) manager.getAdapter(NatTable.class);
+ IConfigRegistry configRegistry = natTable.getConfigRegistry();
+
+ IFilterValueToMatchManager loader = getFilterValueToMatchManager(columnIndex);
+ if (loader != null) {
+ Object columnObject = manager.getColumnElement(columnIndex);
+ loader.saveValueToMatch(configRegistry, columnObject, newValue);
+ }
+ }
+ if (ObjectUtils.isNotNull(newValue)) {
+ filterIndexToObjectMap.put(columnIndex, newValue);
+ } else {
+ filterIndexToObjectMap.remove(columnIndex);
+ }
+
+ filterStrategy.applyFilter(filterIndexToObjectMap);
+
+ columnHeaderLayer.fireLayerEvent(new FilterAppliedEvent(columnHeaderLayer));
+ }
+
+ /**
+ *
+ * @param columnIndex
+ * the index of the column
+ * @return
+ * the filter value to match manager to use
+ */
+ private IFilterValueToMatchManager getFilterValueToMatchManager(int columnIndex) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX);
+ builder.append(Integer.valueOf(columnIndex));
+ return getConfigRegistry().getConfigAttribute(NattableConfigAttributes.FILTER_VALUE_TO_MATCH_MANAGER, DisplayMode.NORMAL, builder.toString());
+ }
+
+ /**
+ *
+ * @return
+ * the config registry to used by the nattable widget
+ */
+ private IConfigRegistry getConfigRegistry() {
+ NatTable natTable = (NatTable) this.manager.getAdapter(NatTable.class);
+ return natTable.getConfigRegistry();
+ }
+
+ // Load/save state
+ //
+ // @Override
+ // public void saveState(String prefix, Properties properties) {
+ // Map<Integer, String> filterTextByIndex = new HashMap<Integer, String>();
+ // for(Integer columnIndex : filterIndexToObjectMap.keySet()) {
+ // final IDisplayConverter converter = configRegistry.getConfigAttribute(
+ // CellConfigAttributes.DISPLAY_CONVERTER,
+ // DisplayMode.NORMAL,
+ // FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + columnIndex);
+ //
+ // String filterText = getFilterStringRepresentation(filterIndexToObjectMap.get(columnIndex), converter);
+ // filterText = filterText.replace("|", PIPE_REPLACEMENT); //$NON-NLS-1$
+ // filterTextByIndex.put(columnIndex, filterText);
+ // }
+ //
+ // String string = PersistenceUtils.mapAsString(filterTextByIndex);
+ //
+ // if (!isEmpty(string)) {
+ // properties.put(prefix + FilterRowDataLayer.PERSISTENCE_KEY_FILTER_ROW_TOKENS, string);
+ // }
+ // }
+
+ // @Override
+ // public void loadState(String prefix, Properties properties) {
+ // filterIndexToObjectMap.clear();
+ //
+ // try {
+ // Object property = properties.get(prefix + FilterRowDataLayer.PERSISTENCE_KEY_FILTER_ROW_TOKENS);
+ // Map<Integer, String> filterTextByIndex = PersistenceUtils.parseString(property);
+ // for (Integer columnIndex : filterTextByIndex.keySet()) {
+ // final IDisplayConverter converter = configRegistry.getConfigAttribute(
+ // CellConfigAttributes.DISPLAY_CONVERTER,
+ // DisplayMode.NORMAL,
+ // FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + columnIndex);
+ //
+ // String filterText = filterTextByIndex.get(columnIndex);
+ // filterText = filterText.replace(PIPE_REPLACEMENT, "|"); //$NON-NLS-1$
+ // filterIndexToObjectMap.put(columnIndex, getFilterFromString(filterText, converter));
+ // }
+ // } catch (Exception e) {
+ // log.error("Error while restoring filter row text!", e); //$NON-NLS-1$
+ // }
+
+ // filterStrategy.applyFilter(filterIndexToObjectMap);
+ // }
+
+ /**
+ * This method is used to support saving of a filter collection, e.g. in the context of the
+ * Excel like filter row. In such cases the filter value is not a simple String but a
+ * Collection of filter values that need to be converted to a String representation.
+ * As the state persistence is encapsulated to be handled here, we need to take care
+ * of such states here also.
+ *
+ * @param filterValue
+ * The filter value object that is used for filtering.
+ * @param converter
+ * The converter that is used to convert the filter value, which is necessary
+ * to support filtering of custom types.
+ * @return The String representation of the filter value.
+ */
+ private String getFilterStringRepresentation(Object filterValue, IDisplayConverter converter) {
+ // in case the filter value is a collection of values, we need to create a special
+ // string representation
+ if (filterValue instanceof Collection) {
+ String collectionSpec = FILTER_COLLECTION_PREFIX + filterValue.getClass().getName() + ")"; //$NON-NLS-1$
+ StringBuilder builder = new StringBuilder(collectionSpec);
+ builder.append("["); //$NON-NLS-1$
+ Collection<?> filterCollection = (Collection<?>) filterValue;
+ for (Iterator<?> iterator = filterCollection.iterator(); iterator.hasNext();) {
+ Object filterObject = iterator.next();
+ builder.append(converter.canonicalToDisplayValue(filterObject));
+ if (iterator.hasNext())
+ builder.append(IPersistable.VALUE_SEPARATOR);
+ }
+
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
+ return (String) converter.canonicalToDisplayValue(filterValue);
+ }
+
+ /**
+ * This method is used to support loading of a filter collection, e.g. in the context of the
+ * Excel like filter row. In such cases the saved filter value is not a simple String but
+ * represents a Collection of filter values that need to be converted to the corresponding values.
+ * As the state persistence is encapsulated to be handled here, we need to take care
+ * of such states here also.
+ *
+ * @param filterText
+ * The String representation of the applied saved filter.
+ * @param converter
+ * The converter that is used to convert the filter value, which is necessary
+ * to support filtering of custom types.
+ * @return The filter value that will be used to apply a filter to the IFilterStrategy
+ *
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private Object getFilterFromString(String filterText, IDisplayConverter converter) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+ if (filterText.startsWith(FILTER_COLLECTION_PREFIX)) {
+ // the filter text represents a collection
+ int indexEndCollSpec = filterText.indexOf(")"); //$NON-NLS-1$
+ String collectionSpec = filterText.substring(filterText.indexOf("(") + 1, indexEndCollSpec); //$NON-NLS-1$
+ Collection filterCollection = (Collection) Class.forName(collectionSpec).newInstance();
+
+ // also get rid of the collection marks
+ filterText = filterText.substring(indexEndCollSpec + 2, filterText.length() - 1);
+ String[] filterSplit = filterText.split(IPersistable.VALUE_SEPARATOR);
+ for (String filterString : filterSplit) {
+ filterCollection.add(converter.displayToCanonicalValue(filterString));
+ }
+
+ return filterCollection;
+ }
+ return converter.displayToCanonicalValue(filterText);
+ }
+
+ /**
+ * Clear all filters that are currently applied.
+ */
+ public void clearAllFilters() {
+ filterIndexToObjectMap.clear();
+ filterStrategy.applyFilter(filterIndexToObjectMap);
+
+ // we clear the filter
+ if (manager != null) {
+ CompoundCommand cc = new CompoundCommand("Clear All Filter"); //$NON-NLS-1$
+ TransactionalEditingDomain domain = TableEditingDomainUtils.getTableEditingDomain(manager.getTable());
+ List<?> columnElement = manager.getColumnElementsList();
+ for (Object current : columnElement) {
+ if (current instanceof IAxis) {
+ Style idToDestroy = ((IAxis) current).getNamedStyle(NattablestylePackage.eINSTANCE.getStringValueStyle(), IFilterConfiguration.FILTER_SYSTEM_ID);
+ Style keyToDestroy = ((IAxis) current).getNamedStyle(NattablestylePackage.eINSTANCE.getStyle(), IFilterConfiguration.FILTER_FORCED_BY_USER_ID);
+
+ if (idToDestroy != null) {
+ Command cmd = DeleteCommand.create(domain, idToDestroy);
+ if (cmd != null && cmd.canExecute()) {
+ cc.append(cmd);
+ }
+ }
+ if (idToDestroy != null) {
+ Command cmd = DeleteCommand.create(domain, keyToDestroy);
+ if (cmd != null && cmd.canExecute()) {
+ cc.append(cmd);
+ }
+ }
+ }
+ }
+ if (!cc.isEmpty() && cc.canExecute()) {
+ domain.getCommandStack().execute(cc);
+ }
+ }
+
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/AbstractSinglePapyrusMatcher.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/AbstractSinglePapyrusMatcher.java
index 98996dddf62..0eb7ed2a6e0 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/AbstractSinglePapyrusMatcher.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/filter/AbstractSinglePapyrusMatcher.java
@@ -1,125 +1,115 @@
-/*****************************************************************************
- * 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.nattable.filter;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.nebula.widgets.nattable.data.IColumnAccessor;
-
-import ca.odell.glazedlists.matchers.Matcher;
-
-/**
- * Abstract matcher class used by filter
- *
- */
-public abstract class AbstractSinglePapyrusMatcher<E> implements Matcher<E> {
-
- /**
- * the wanted object
- */
- private Object matchOn;
-
- /**
- * the column accesor to use
- */
- private IColumnAccessor<Object> columnAccessor;
-
- /**
- * the index of the column on which we are working
- */
- private int columnIndex;
-
- /**
- * the config registry of the table
- */
- private IConfigRegistry registry;
-
- /**
- *
- * Constructor.
- *
- * @param columnAccessor
- * the accessor to use to get cell value
- * @param columnIndex
- * the index of the column on which we are working
- * @param matchOn
- * the object looked for by the filter, it must not be a collection
- */
- public AbstractSinglePapyrusMatcher(IColumnAccessor<Object> columnAccessor, int columnIndex, Object matchOn) {
- this(columnAccessor, columnIndex, matchOn, null);
- }
-
- /**
- *
- * Constructor.
- *
- * @param columnAccessor
- * the accessor to use to get cell value
- * @param columnIndex
- * the index of the column on which we are working
- * @param matchOn
- * the object looked for by the filter, it must not be a collection
- * @param configRegistry
- * the config registry used by the nattable widget
- */
- public AbstractSinglePapyrusMatcher(IColumnAccessor<Object> columnAccessor, int columnIndex, Object matchOn, IConfigRegistry configRegistry) {
- this.matchOn = matchOn;
- Assert.isTrue(!(matchOn instanceof Collection<?>));
- this.columnAccessor = columnAccessor;
- this.columnIndex = columnIndex;
- }
-
- /**
- * @return the wantedObject
- */
- protected final Object getObjectToMatch() {
- return matchOn;
- }
-
- /**
- * @return the accessor
- */
- protected final IColumnAccessor<Object> getColumnAccessor() {
- return columnAccessor;
- }
-
- /**
- * @return the columnIndex
- */
- protected final int getColumnIndex() {
- return columnIndex;
- }
-
- /**
- * @return the registry
- */
- protected final IConfigRegistry getRegistry() {
- return registry;
- }
-
- /**
- *
- * @param item
- * an object (a row)
- * @return
- * the cell value for this row and the filtered column
- */
- protected Object getCellValueFor(Object item) {
- return getColumnAccessor().getDataValue(item, getColumnIndex());
- }
-
-
-}
+/*****************************************************************************
+ * 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.nattable.filter;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.IColumnAccessor;
+
+import ca.odell.glazedlists.matchers.Matcher;
+
+/**
+ * Abstract matcher class used by filter
+ *
+ */
+public abstract class AbstractSinglePapyrusMatcher<E> implements Matcher<E> {
+
+ /**
+ * the wanted object
+ */
+ private Object matchOn;
+
+ /**
+ * the column accesor to use
+ */
+ private IColumnAccessor<Object> columnAccessor;
+
+ /**
+ * the index of the column on which we are working
+ */
+ private int columnIndex;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param columnAccessor
+ * the accessor to use to get cell value
+ * @param columnIndex
+ * the index of the column on which we are working
+ * @param matchOn
+ * the object looked for by the filter, it must not be a collection
+ */
+ public AbstractSinglePapyrusMatcher(IColumnAccessor<Object> columnAccessor, int columnIndex, Object matchOn) {
+ this(columnAccessor, columnIndex, matchOn, null);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param columnAccessor
+ * the accessor to use to get cell value
+ * @param columnIndex
+ * the index of the column on which we are working
+ * @param matchOn
+ * the object looked for by the filter, it must not be a collection
+ * @param configRegistry
+ * the config registry used by the nattable widget
+ */
+ public AbstractSinglePapyrusMatcher(IColumnAccessor<Object> columnAccessor, int columnIndex, Object matchOn, IConfigRegistry configRegistry) {
+ this.matchOn = matchOn;
+ Assert.isTrue(!(matchOn instanceof Collection<?>));
+ this.columnAccessor = columnAccessor;
+ this.columnIndex = columnIndex;
+ }
+
+ /**
+ * @return the wantedObject
+ */
+ protected final Object getObjectToMatch() {
+ return matchOn;
+ }
+
+ /**
+ * @return the accessor
+ */
+ protected final IColumnAccessor<Object> getColumnAccessor() {
+ return columnAccessor;
+ }
+
+ /**
+ * @return the columnIndex
+ */
+ protected final int getColumnIndex() {
+ return columnIndex;
+ }
+
+
+ /**
+ *
+ * @param item
+ * an object (a row)
+ * @return
+ * the cell value for this row and the filtered column
+ */
+ protected Object getCellValueFor(Object item) {
+ return getColumnAccessor().getDataValue(item, getColumnIndex());
+ }
+
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/glazedlists/copy/MouseOnlySortingStrategy.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/glazedlists/copy/MouseOnlySortingStrategy.java
index 92f4a33abcd..b89ceda5751 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/glazedlists/copy/MouseOnlySortingStrategy.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/glazedlists/copy/MouseOnlySortingStrategy.java
@@ -1,68 +1,68 @@
-/* Glazed Lists (c) 2003-2006 */
-/* http://publicobject.com/glazedlists/ publicobject.com,*/
-/* O'Dell Engineering Ltd.*/
-package org.eclipse.papyrus.infra.nattable.glazedlists.copy;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#SINGLE_COLUMN
- * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE
- *
- * @author <a href="mailto:jesse@swank.ca">Jesse Wilson</a>
- */
-public final class MouseOnlySortingStrategy implements SortingStrategy {
-
- /** if false, other sorting columns will be cleared before a click takes effect */
- private final boolean multipleColumnSort;
-
- /**
- * Create a new {@link8 ca.odell.glazedlists.impl.gui.MouseOnlySortingStrategy}, sorting multiple
- * columns or not as specified.
- */
- public MouseOnlySortingStrategy(boolean multipleColumnSort) {
- this.multipleColumnSort = multipleColumnSort;
- }
-
- /**
- * Adjust the sorting state based on receiving the specified clicks.
- */
- public void columnClicked(SortingState sortingState, int column, int clicks, boolean shift, boolean control) {
- SortingState.SortingColumn clickedColumn = sortingState.getColumns().get(column);
- if (clickedColumn.getComparators().isEmpty())
- return;
-
- List<SortingState.SortingColumn> recentlyClickedColumns = sortingState.getRecentlyClickedColumns();
-
- // on a double click, clear all click counts
- if (clicks == 2) {
- for (Iterator<SortingState.SortingColumn> i = recentlyClickedColumns.iterator(); i.hasNext();) {
- SortingState.SortingColumn sortingColumn = i.next();
- sortingColumn.clear();
- }
- recentlyClickedColumns.clear();
-
- // if we're only sorting one column at a time, clear other columns
- } else if (!multipleColumnSort) {
- for (Iterator<SortingState.SortingColumn> i = recentlyClickedColumns.iterator(); i.hasNext();) {
- SortingState.SortingColumn sortingColumn = i.next();
- if (sortingColumn != clickedColumn) {
- sortingColumn.clear();
- }
- }
- recentlyClickedColumns.clear();
- }
-
- // add a click to the newly clicked column if it has any comparators
- int netClicks = 1 + clickedColumn.getComparatorIndex() * 2 + (clickedColumn.isReverse() ? 1 : 0);
- clickedColumn.setComparatorIndex((netClicks / 2) % clickedColumn.getComparators().size());
- clickedColumn.setReverse(netClicks % 2 == 1);
- if (!recentlyClickedColumns.contains(clickedColumn)) {
- recentlyClickedColumns.add(clickedColumn);
- }
-
- // rebuild the sorting state
- sortingState.fireSortingChanged();
- }
+/* Glazed Lists (c) 2003-2006 */
+/* http://publicobject.com/glazedlists/ publicobject.com,*/
+/* O'Dell Engineering Ltd.*/
+package org.eclipse.papyrus.infra.nattable.glazedlists.copy;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#SINGLE_COLUMN
+ * @see ca.odell.glazedlists.gui.AbstractTableComparatorChooser#MULTIPLE_COLUMN_MOUSE
+ *
+ * @author <a href="mailto:jesse@swank.ca">Jesse Wilson</a>
+ */
+public final class MouseOnlySortingStrategy implements SortingStrategy {
+
+ /** if false, other sorting columns will be cleared before a click takes effect */
+ private final boolean multipleColumnSort;
+
+ /**
+ * Create a new {@link8 ca.odell.glazedlists.impl.gui.MouseOnlySortingStrategy}, sorting multiple
+ * columns or not as specified.
+ */
+ public MouseOnlySortingStrategy(boolean multipleColumnSort) {
+ this.multipleColumnSort = multipleColumnSort;
+ }
+
+ /**
+ * Adjust the sorting state based on receiving the specified clicks.
+ */
+ public void columnClicked(SortingState sortingState, int column, int clicks, boolean shift, boolean control) {
+ SortingState.SortingColumn clickedColumn = sortingState.getColumns().get(column);
+ if (clickedColumn.getComparators().isEmpty())
+ return;
+
+ List<SortingState.SortingColumn> recentlyClickedColumns = sortingState.getRecentlyClickedColumns();
+
+ // on a double click, clear all click counts
+ if (clicks == 2) {
+ for (Iterator<SortingState.SortingColumn> i = recentlyClickedColumns.iterator(); i.hasNext();) {
+ SortingState.SortingColumn sortingColumn = i.next();
+ sortingColumn.clear();
+ }
+ recentlyClickedColumns.clear();
+
+ // if we're only sorting one column at a time, clear other columns
+ } else if (!multipleColumnSort) {
+ for (Iterator<SortingState.SortingColumn> i = recentlyClickedColumns.iterator(); i.hasNext();) {
+ SortingState.SortingColumn sortingColumn = i.next();
+ if (sortingColumn != clickedColumn) {
+ sortingColumn.clear();
+ }
+ }
+ recentlyClickedColumns.clear();
+ }
+
+ // add a click to the newly clicked column if it has any comparators
+ int netClicks = 1 + clickedColumn.getComparatorIndex() * 2 + (clickedColumn.isReverse() ? 1 : 0);
+ clickedColumn.setComparatorIndex((netClicks / 2) % clickedColumn.getComparators().size());
+ clickedColumn.setReverse(netClicks % 2 != 0);
+ if (!recentlyClickedColumns.contains(clickedColumn)) {
+ recentlyClickedColumns.add(clickedColumn);
+ }
+
+ // rebuild the sorting state
+ sortingState.fireSortingChanged();
+ }
} \ No newline at end of file
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ITreeItemAxisComparator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ITreeItemAxisComparator.java
index b0fb9ec3f93..4a0a26d276c 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ITreeItemAxisComparator.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/ITreeItemAxisComparator.java
@@ -114,7 +114,7 @@ public class ITreeItemAxisComparator implements Comparator<ITreeItemAxis> {
* @param axis1
* @param axis2
* @return
- * the axis manager representation
+ * the axis manager representation
*/
protected AxisManagerRepresentation getAxisManagerRepresentation(ITreeItemAxis axis1, ITreeItemAxis axis2) {
if (this.axisManager != null) {
@@ -128,7 +128,11 @@ public class ITreeItemAxisComparator implements Comparator<ITreeItemAxis> {
if ((subAxisManager1 != null || subAxisManager2 != null) && (subAxisManager1 != subAxisManager2)) {
throw new UnsupportedOperationException("this case is not yet supported"); //$NON-NLS-1$
}
- return subAxisManager1.getAxisManagerRepresentation();
+ if (subAxisManager1 != null) {
+ return subAxisManager1.getAxisManagerRepresentation();
+ } else {
+ throw new UnsupportedOperationException("this case is not yet supported"); //$NON-NLS-1$
+ }
}
/**
@@ -202,7 +206,7 @@ public class ITreeItemAxisComparator implements Comparator<ITreeItemAxis> {
* @param axis2
* the second axis
* @return
- * the axis manager used
+ * the axis manager used
*/
private IAxisManager getAxisManager(ITreeItemAxis axis1, ITreeItemAxis axis2) {
if (this.axisManager != null) {
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 54f74b7ce37..98eef5214fe 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
@@ -293,7 +293,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* The table popup menu configuration.
*/
private TablePopupMenuConfiguration tablePopupMenuConfiguration;
-
+
/**
* The CTabFolder.
*
@@ -469,10 +469,10 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @return The parent CTabFolder or <code>null</code>.
*
- * @since 2.1
+ * @since 3.0
*/
protected CTabFolder getParentCTabFolder() {
- if(null == cTabFolder){
+ if (null == cTabFolder) {
Control currentControl = natTable.getParent();
while (null != currentControl && !(currentControl instanceof CTabFolder)) {
currentControl = currentControl.getParent();
@@ -489,7 +489,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @return The CTabFolder selection listener.
*
- * @since 2.1
+ * @since 3.0
*/
protected SelectionListener getCTabFolderSelectionListener() {
if (null == cTabFolderSelectionListener) {
@@ -508,7 +508,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
if (!hasSelection && null != natTable && null != selectionProvider && null != getTable().getContext()) {
- if(selectionInTable.getFirstElement().equals(getTable().getContext())){
+ if (selectionInTable.getFirstElement().equals(getTable().getContext())) {
// Set the table as selection to force the properties view to refresh it
selectionProvider.setSelection(new TableStructuredSelection(getTable(), new TableSelectionWrapper(Collections.<PositionCoordinate> emptyList())));
}
@@ -527,7 +527,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @return The display of the top composite.
*
- * @since 2.1
+ * @since 3.0
*/
protected Control getNattableTopParentComposite() {
Control currentControl = natTable.getParent();
@@ -535,7 +535,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
while (null != currentControl && !hasToStop) {
if (null == currentControl.getParent() || currentControl.getParent() instanceof CTabFolder) {
hasToStop = true;
- }else{
+ } else {
currentControl = currentControl.getParent();
}
}
@@ -1399,7 +1399,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
public void exportToXLS() {
this.natTable.doCommand(new ExportCommand(this.natTable.getConfigRegistry(), this.natTable.getShell()));
}
-
+
/**
* {@inheritDoc}
*
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index 1f3c6f55dc8..923314b11e6 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -721,11 +721,6 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
this.horizontalFilterList = newHorizontalFilterList;
this.verticalFilterList = newVerticalFilterLilst;
- this.rowSortedList = newHorizontalSortedList;
- this.columnSortedList = newVerticalSortedList;
-
-
- NattableModelManager.this.rowManager = newRowManager;
NattableModelManager.this.columnManager = newColumnManager;
this.rowManager.setAxisComparator(null);
this.columnManager.setAxisComparator(null);
@@ -841,17 +836,17 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
this.contextEditingDomain.removeResourceSetListener(resourceSetListener);
}
}
-
+
if (this.columnManager != null) {
this.columnManager.dispose();
this.columnManager = null;
}
-
+
if (this.rowManager != null) {
this.rowManager.dispose();
this.rowManager = null;
}
-
+
final Table table = getTable();
if (table != null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/PapyrusBeveledBorderDecorator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/PapyrusBeveledBorderDecorator.java
index 074f68b4768..22457ffc522 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/PapyrusBeveledBorderDecorator.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/painter/PapyrusBeveledBorderDecorator.java
@@ -64,12 +64,14 @@ public class PapyrusBeveledBorderDecorator extends BeveledBorderDecorator {
if (cell instanceof TranslatedLayerCell) {
labels = cell.getConfigLabels();
}
- if (!labels.hasLabel(TreeLayer.TREE_COLUMN_CELL)) {
- super.paintCell(cell, gc, adjustedCellBounds, configRegistry);
- return;
- } else {
- if (getWrappedPainter() != null) {
- getWrappedPainter().paintCell(cell, gc, adjustedCellBounds, configRegistry);
+ if (labels != null) {
+ if (!labels.hasLabel(TreeLayer.TREE_COLUMN_CELL)) {
+ super.paintCell(cell, gc, adjustedCellBounds, configRegistry);
+ return;
+ } else {
+ if (getWrappedPainter() != null) {
+ getWrappedPainter().paintCell(cell, gc, adjustedCellBounds, configRegistry);
+ }
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractPasteInSelectionNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractPasteInSelectionNattableCommandProvider.java
index d99684f48ac..c742cc91ac7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractPasteInSelectionNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/AbstractPasteInSelectionNattableCommandProvider.java
@@ -367,9 +367,11 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
referencedPasteConf.add(tmp.getPasteConfiguration());
}
}
- for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
- if (axisConf instanceof IPasteConfiguration && !referencedPasteConf.contains(axisConf)) {
- return (IPasteConfiguration) axisConf;
+ if (conf != null) {
+ for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
+ if (axisConf instanceof IPasteConfiguration && !referencedPasteConf.contains(axisConf)) {
+ return (IPasteConfiguration) axisConf;
+ }
}
}
}
@@ -666,11 +668,11 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
// If only one row is pasted in the columns,
// transpose the pastedValues to try to repeat for each row in the table
final Map<Object, List<String>> returnedPastedValues = new LinkedHashMap<Object, List<String>>();
- if(!pastedValues.isEmpty()){
- for(Object o : pastedValues.keySet()){
+ if (!pastedValues.isEmpty()) {
+ for (Object o : pastedValues.keySet()) {
int i = 0;
- for(String s : pastedValues.get(o)){
- if(null == returnedPastedValues.get(i)){
+ for (String s : pastedValues.get(o)) {
+ if (null == returnedPastedValues.get(i)) {
returnedPastedValues.put(i, new ArrayList<String>());
}
returnedPastedValues.get(i).add(s);
@@ -678,17 +680,17 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
}
}
pastedValues = returnedPastedValues;
-
+
// The number of columns must be the same to repeat it
- if(pastedValues.size() == 1 && fullySelectedColumns.size() == pastedValues.get(pastedValues.keySet().iterator().next()).size()){
+ if (pastedValues.size() == 1 && fullySelectedColumns.size() == pastedValues.get(pastedValues.keySet().iterator().next()).size()) {
this.isSingleAxisPasted = true;
this.numberSelectedAxis = tableManager.getBodyLayerStack().getRowHideShowLayer().getRowCount();
resultCommand = getPasteCellsRowFromStringCommand(contextEditingDomain, tableEditingDomain, tableSelectionWrapper.getSelectedCells(), openDialog, progressMonitor, sharedMap, attachedMode);
}
}
-
+
// If we can't repeat (not only one line or not the same number of columns), return the error message
- if(null == resultCommand){
+ if (null == resultCommand) {
resultCommand = new ErrorTransactionalCommand(contextEditingDomain, PASTE_COMMAND_NAME, null, canPasteStatus);
}
}
@@ -932,10 +934,12 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
// - The rows numbers are not equals -> Error
// - The column read is alone -> Continue and repeat the column pasted
// - The columns numbers are not equals -> Error
- /*if (1 == nbRowRead && nbColumnsSelected == nbColumnRead){
- this.isSingleAxisPasted = true;
- this.numberSelectedAxis = nbRowsSelected;
- }else*/ if (nbRowRead != nbRowsSelected) {
+ /*
+ * if (1 == nbRowRead && nbColumnsSelected == nbColumnRead){
+ * this.isSingleAxisPasted = true;
+ * this.numberSelectedAxis = nbRowsSelected;
+ * }else
+ */ if (nbRowRead != nbRowsSelected) {
result = new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.AbstractPasteInSelectionNattableCommandProvider_readrowsexceedsexistingrows);
} else if (1 == nbColumnRead && 1 < nbColumnsSelected) {
this.isSingleAxisPasted = true;
@@ -1043,24 +1047,24 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
int realRowIndex = rowHideShowLayer.getRowIndexByPosition(lastRowPosition);
// Get the row element from its index
final Object rowElement = AxisUtils.getRepresentedElement(tableManager.getRowElement(realRowIndex));
-
+
// check that the row element is not a tree filling configuration and continue the process for others
- if(!(rowElement instanceof TreeFillingConfiguration)){
-
+ if (!(rowElement instanceof TreeFillingConfiguration)) {
+
// Manage the columns of the row
while (cellIter.hasNext() && canContinue(resultStatus)) {
final String valueAsString = cellIter.next();
-
+
// Get the column index from its position
int realColumnIndex = columnHideShowLayer.getColumnIndexByPosition(nbColmnRead);
// Get the column attribute from its index
final Object columnElement = AxisUtils.getRepresentedElement(tableManager.getColumnElement(realColumnIndex));
-
+
// Edit the value if this is editable
final boolean isEditable = CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement, sharedMap);
if (isEditable) {
final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnElement, rowElement, tableManager, existingConverters, pasteHelper.getMultiValueSeparator());
-
+
// Get the converted value (to compare with the new one
final Command command = CellManagerFactory.INSTANCE.getSetStringValueCommand(tableEditingDomain, columnElement, rowElement, valueAsString, converter, tableManager);
final IStatus commandStatus = getStatusCommand(command);
@@ -1077,7 +1081,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
}
nbColmnRead++;
}
-
+
if (lastColumnPosition < nbColmnRead) {
lastColumnPosition = nbColmnRead;
}
@@ -1093,7 +1097,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
if (canContinue(resultStatus) && null != compoundCommand && !compoundCommand.isEmpty() && compoundCommand.canExecute()) {
// Execute the compound command
tableEditingDomain.getCommandStack().execute(compoundCommand);
-
+
return new CommandResult(resultStatus);
}
if (!resultStatus.isOK()) {
@@ -1320,7 +1324,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
Iterator<InsertedElementInNattable> objectsToAddIterator = objectsToAdd.iterator();
while (objectsToAddIterator.hasNext() && null == foundInsertedElement) {
final InsertedElementInNattable insertedElement = objectsToAddIterator.next();
- if (insertedElement.equals(currentContext) && insertedElement.getContainementFeature().equals(containementFeature)) {
+ if (insertedElement.getContext().equals(currentContext) && insertedElement.getContainementFeature().equals(containementFeature)) {
foundInsertedElement = insertedElement;
}
}
@@ -1378,9 +1382,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
final Object columnElement = getColumnElement(realColumnIndex);
// Edit the value if this is editable
- final boolean isEditable = null == sharedMap ?
- CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement) :
- CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement, sharedMap);
+ final boolean isEditable = null == sharedMap ? CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement) : CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement, sharedMap);
if (isEditable) {
final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnElement, rowElement, tableManager, existingConverters, pasteHelper.getMultiValueSeparator());
@@ -1431,23 +1433,23 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
createTableRowInAttachedModeCommand(compoundCommand, objectsToAdd);
}
}
-
+
// Execute some actions available in the share map when this is the detached mode
- if(!attachedMode){
+ if (!attachedMode) {
// Manage the reference to set
@SuppressWarnings("unchecked")
final List<IValueSetter> valueToSet = (List<IValueSetter>) sharedMap.get(Constants.REFERENCES_TO_SET_KEY);
-
+
if (valueToSet.size() > 0) {
for (final IValueSetter current : valueToSet) {
current.doSetValue(contextEditingDomain);
}
}
-
+
// Manage the cells problems to add
@SuppressWarnings("unchecked")
final List<Cell> cells = (List<Cell>) sharedMap.get(Constants.CELLS_TO_ADD_KEY);
-
+
// add the created cells to the table
if (null != cells && !cells.isEmpty()) {
compoundCommand.append(AddCommand.create(tableEditingDomain, table, NattablePackage.eINSTANCE.getTable_Cells(), cells));
@@ -1455,13 +1457,18 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
}
}
- if (progressMonitor != null && progressMonitor.isCanceled()) {
+
+ if (progressMonitor != null) {
+ if (progressMonitor.isCanceled()) {
+ progressMonitor.done();
+ localDispose();
+ return CommandResult.newCancelledCommandResult();
+ }
+
progressMonitor.done();
- localDispose();
- return CommandResult.newCancelledCommandResult();
}
-
- progressMonitor.done();
+
+
localDispose();
if (resultStatus.isOK()) {
@@ -1613,13 +1620,13 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
int realRowIndex = rowHideShowLayer.getRowIndexByPosition(nbRowRead);
// Get the row object from its index
final Object rowElement = AxisUtils.getRepresentedElement(tableManager.getRowElement(realRowIndex));
-
- if(!(rowElement instanceof TreeFillingConfiguration)){
+
+ if (!(rowElement instanceof TreeFillingConfiguration)) {
// Edit the value if this is editable
final boolean isEditable = CellManagerFactory.INSTANCE.isCellEditable(columnElement, rowElement, sharedMap);
if (isEditable) {
final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnElement, rowElement, tableManager, existingConverters, pasteHelper.getMultiValueSeparator());
-
+
// Get the converted value (to compare with the new one
final Command command = CellManagerFactory.INSTANCE.getSetStringValueCommand(tableEditingDomain, columnElement, rowElement, valueAsString, converter, tableManager);
final IStatus commandStatus = getStatusCommand(command);
@@ -1781,7 +1788,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
if (isInsert) {
currentUserAction = UserActionConstants.ADD_USER_ACTION;
multiStatus.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, String.format(Messages.AbstractPasteInSelectionNattableCommandProvider_identifierNotFoundInSelectionSoTheObjectWasCreated, identifierValue)));
- }else{
+ } else {
multiStatus.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, String.format(Messages.AbstractPasteInSelectionNattableCommandProvider_identifierNotFoundInSelection, identifierValue)));
}
}
@@ -1961,7 +1968,7 @@ public abstract class AbstractPasteInSelectionNattableCommandProvider implements
* @return The depth from the object in parameter.
*/
protected abstract int getDepthFromObject(final Object object);
-
+
/**
* Get the category from the object in parameter.
*
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
index 1711c771270..3879b40e45d 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectTreeAxisInNattableCommandProvider.java
@@ -194,9 +194,11 @@ public class PasteEObjectTreeAxisInNattableCommandProvider extends AbstractPaste
referencedPasteConf.add(tmp.getPasteConfiguration());
}
}
- for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
- if (axisConf instanceof IPasteConfiguration && !referencedPasteConf.contains(axisConf)) {
- return (IPasteConfiguration) axisConf;
+ if (conf != null) {
+ for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
+ if (axisConf instanceof IPasteConfiguration && !referencedPasteConf.contains(axisConf)) {
+ return (IPasteConfiguration) axisConf;
+ }
}
}
}
@@ -547,7 +549,7 @@ public class PasteEObjectTreeAxisInNattableCommandProvider extends AbstractPaste
*/
private Object createElement(final boolean isDetachedMode, final ExtendedCompoundCommand compoundCommand, final Map<Integer, EObject> contextMap, final int depth, final String valueAsString, final PasteEObjectConfiguration pasteConfToUse,
final IProgressMonitor monitor, final IAdaptable info)
- throws ExecutionException {
+ throws ExecutionException {
return isDetachedMode ? createElementInDetachedMode(compoundCommand, contextMap, depth, valueAsString, pasteConfToUse, monitor, info) : createElementInAttachedMode(compoundCommand, contextMap, depth, valueAsString, pasteConfToUse, monitor, info);
}
@@ -631,7 +633,7 @@ public class PasteEObjectTreeAxisInNattableCommandProvider extends AbstractPaste
*/
protected Object createElementInAttachedMode(final ExtendedCompoundCommand compoundCommand, final Map<Integer, EObject> contextMap, final int depth, final String valueAsString, final PasteEObjectConfiguration pasteConfToUse, final IProgressMonitor monitor,
final IAdaptable info)
- throws ExecutionException {
+ throws ExecutionException {
Object createdElement = null;
// get the element type to use to create the element
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteInSelectionTreeNattableCommandProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteInSelectionTreeNattableCommandProvider.java
index 1a5bd3f28ef..5d2f14c206e 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteInSelectionTreeNattableCommandProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteInSelectionTreeNattableCommandProvider.java
@@ -122,9 +122,11 @@ public class PasteInSelectionTreeNattableCommandProvider extends PasteInSelectio
referencedPasteConf.add(tmp.getPasteConfiguration());
}
}
- for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
- if (axisConf instanceof PasteEObjectConfiguration && !referencedPasteConf.contains(axisConf)) {
- return (PasteEObjectConfiguration) axisConf;
+ if (conf != null) {
+ for (final IAxisConfiguration axisConf : conf.getOwnedAxisConfigurations()) {
+ if (axisConf instanceof PasteEObjectConfiguration && !referencedPasteConf.contains(axisConf)) {
+ return (PasteEObjectConfiguration) axisConf;
+ }
}
}
}
@@ -282,8 +284,8 @@ public class PasteInSelectionTreeNattableCommandProvider extends PasteInSelectio
final InsertedElementInNattable currentInsertedElement = createdElements.get(insertedElementIndex);
if (-1 != currentInsertedElement.getIndexInParent()) {
int addedIndex = 0;
- for(Object createdElement : currentInsertedElement.getCreatedElements()){
- addCommand.append(MoveCommand.create(contextEditingDomain, currentInsertedElement.getContext(), currentInsertedElement.getContainementFeature(), createdElement, currentInsertedElement.getIndexInParent()+addedIndex));
+ for (Object createdElement : currentInsertedElement.getCreatedElements()) {
+ addCommand.append(MoveCommand.create(contextEditingDomain, currentInsertedElement.getContext(), currentInsertedElement.getContainementFeature(), createdElement, currentInsertedElement.getIndexInParent() + addedIndex));
addedIndex++;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/InsertedElementInNattable.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/InsertedElementInNattable.java
index 27ee85a903b..ced6c0a03fc 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/InsertedElementInNattable.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/InsertedElementInNattable.java
@@ -54,10 +54,14 @@ public class InsertedElementInNattable {
/**
* Constructor.
*
- * @param context The context of the created elements
- * @param containementFeature The containment feature.
- * @param indexInParent The index where add the created elements in the context.
- * @param indexInTable The index where add the created elements in the table.
+ * @param context
+ * The context of the created elements
+ * @param containementFeature
+ * The containment feature.
+ * @param indexInParent
+ * The index where add the created elements in the context.
+ * @param indexInTable
+ * The index where add the created elements in the table.
*/
public InsertedElementInNattable(EObject context, EStructuralFeature containementFeature, int indexInParent, int indexInTable) {
super();
@@ -67,16 +71,21 @@ public class InsertedElementInNattable {
this.indexInParent = indexInParent;
this.indexInTable = indexInTable;
}
-
+
/**
*
* Constructor.
*
- * @param context The context of the created elements.
- * @param createdElements The created elements to add.
- * @param containementFeature The containment feature.
- * @param indexInParent The index where add the created elements in the context.
- * @param indexInTable The index where add the created elements in the table.
+ * @param context
+ * The context of the created elements.
+ * @param createdElements
+ * The created elements to add.
+ * @param containementFeature
+ * The containment feature.
+ * @param indexInParent
+ * The index where add the created elements in the context.
+ * @param indexInTable
+ * The index where add the created elements in the table.
*/
public InsertedElementInNattable(EObject context, List<Object> createdElements, EStructuralFeature containementFeature, int indexInParent, int indexInTable) {
super();
@@ -100,7 +109,8 @@ public class InsertedElementInNattable {
/**
* This allows to add a created elements.
*
- * @param object the created element to add.
+ * @param object
+ * the created element to add.
*/
public void addCreatedElement(final Object createdElement) {
this.createdElements.add(createdElement);
@@ -162,4 +172,9 @@ public class InsertedElementInNattable {
return result;
}
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
}

Back to the top