aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2017-09-25 16:33:13 -0400
committervincent lorenzo2017-10-05 05:15:45 -0400
commite23cb123bb7655876db76d538f2f12be196d380d (patch)
tree57017eb6fbe69ddb647bff6ff1bade6f1f5ad417
parent05b047f0cad0bdff062b87feff39e43ffa0fe8fe (diff)
downloadorg.eclipse.papyrus-e23cb123bb7655876db76d538f2f12be196d380d.zip
org.eclipse.papyrus-e23cb123bb7655876db76d538f2f12be196d380d.tar.gz
org.eclipse.papyrus-e23cb123bb7655876db76d538f2f12be196d380d.tar.xz
bug 525221 : [Table][Matrix][PropertyView] NPE editing Row Sources
Change-Id: I8f53b00e34e953da1d7aaff373fbcbff8760895b Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java7
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java6
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java336
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableSelectionWrapper.java161
4 files changed, 351 insertions, 159 deletions
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 98f6de0..3b1290d 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
@@ -14,6 +14,7 @@
* Nicolas FAUVERGUE(ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 504077, 497571
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 502560: add drag to diagram support
* Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 459220, 417095
+ * Vincent Lorenzo (CEA LIST) - bug 525221
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.manager.table;
@@ -433,7 +434,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable));
this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer());
// This allows to define the table context as selection on the table opening
- this.selectionProvider.setSelection(new TableStructuredSelection(getTable().getContext(), new TableSelectionWrapper(Collections.<PositionCoordinate> emptyList())));
+ this.selectionProvider.setSelection(new TableStructuredSelection(getTable().getContext(), new TableSelectionWrapper(this, Collections.<PositionCoordinate> emptyList())));
// Add a selection listener on the CTabFolder to select the table context
final CTabFolder tabFolder = getParentCTabFolder();
@@ -520,10 +521,10 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
if (!hasSelection && null != natTable && null != selectionProvider && null != 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())));
+ selectionProvider.setSelection(new TableStructuredSelection(getTable(), new TableSelectionWrapper(AbstractNattableWidgetManager.this, Collections.<PositionCoordinate> emptyList())));
}
// This allows to define the table context as selection on the table opening
- selectionProvider.setSelection(new TableStructuredSelection(getTable().getContext(), new TableSelectionWrapper(Collections.<PositionCoordinate> emptyList())));
+ selectionProvider.setSelection(new TableStructuredSelection(getTable().getContext(), new TableSelectionWrapper(AbstractNattableWidgetManager.this, Collections.<PositionCoordinate> emptyList())));
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
index f83b2ae..581b8bc 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableSelectionProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,7 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618
- *
+ * Vincent Lorenzo (CEA LIST) - bug 525221
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.provider;
@@ -156,7 +156,7 @@ public class TableSelectionProvider implements ISelectionProvider, IDisposable,
Collection<Object> selection = new HashSet<Object>();
final ISelection newSelection;
if (event instanceof ISelectionEvent) {
- TableSelectionWrapper wrapper = new TableSelectionWrapper(ListHelper.asList(this.selectionLayer.getSelectedCellPositions()), new HashMap<Integer, Object>(0), new HashMap<Integer, Object>(0));
+ TableSelectionWrapper wrapper = new TableSelectionWrapper(this.manager, ListHelper.asList(this.selectionLayer.getSelectedCellPositions()), new HashMap<Integer, Object>(0), new HashMap<Integer, Object>(0));
// Get the type selection event if it is a specific selection event
TypeSelectionEnum typeSelectionEvent = TypeSelectionEnum.NONE;
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java
index 95f6629..f023264 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableStructuredSelection.java
@@ -1,112 +1,224 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.provider;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
-
-/**
- * The StructuredSelection filled by the tables. It able to embed more precision about the selected elements in the table.
- *
- * @author vl222926
- *
- */
-public class TableStructuredSelection extends StructuredSelection implements IAdaptable {
-
- /**
- * the wrapper for the table selection
- */
- private final TableSelectionWrapper wrapper;
-
- /**
- *
- * Constructor.
- *
- * @param wrapper
- */
- public TableStructuredSelection(TableSelectionWrapper wrapper) {
- super();
- this.wrapper = wrapper;
- }
-
- /**
- *
- * Constructor.
- *
- * @param elements
- * @param comparer
- * @param wrapper
- */
- public TableStructuredSelection(List<?> elements, IElementComparer comparer, TableSelectionWrapper wrapper) {
- super(elements, comparer);
- this.wrapper = wrapper;
- }
-
- /**
- *
- * Constructor.
- *
- * @param elements
- * @param wrapper
- */
- public TableStructuredSelection(List<?> elements, TableSelectionWrapper wrapper) {
- super(elements);
- this.wrapper = wrapper;
- }
-
- /**
- *
- * Constructor.
- *
- * @param element
- * @param wrapper
- */
- public TableStructuredSelection(Object element, TableSelectionWrapper wrapper) {
- super(element);
- this.wrapper = wrapper;
- }
-
- /**
- *
- * Constructor.
- *
- * @param elements
- * @param wrapper
- */
- public TableStructuredSelection(Object[] elements, TableSelectionWrapper wrapper) {
- super(elements);
- this.wrapper = wrapper;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- *
- * @param adapter
- * @return
- */
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- if (adapter == TableSelectionWrapper.class) {
- return this.wrapper;
- }
- return null;
- }
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2013, 2017 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) - bug 525221
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.provider;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
+
+/**
+ * The StructuredSelection filled by the tables. It able to embed more precision about the selected elements in the table.
+ *
+ */
+public class TableStructuredSelection implements IStructuredSelection, IAdaptable {
+
+ /**
+ * the wrapper for the table selection
+ */
+ private final TableSelectionWrapper wrapper;
+
+ /**
+ * the wrapped selection
+ */
+ private final IStructuredSelection wrappedSelection;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param wrapper
+ */
+ public TableStructuredSelection(final TableSelectionWrapper wrapper) {
+ this.wrapper = wrapper;
+ this.wrappedSelection = StructuredSelection.EMPTY;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param comparer
+ * @param wrapper
+ */
+ public TableStructuredSelection(final List<?> elements, final IElementComparer comparer, final TableSelectionWrapper wrapper) {
+ this.wrappedSelection = new StructuredSelection(elements, comparer);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param wrapper
+ */
+ public TableStructuredSelection(final List<?> elements, final TableSelectionWrapper wrapper) {
+ this.wrappedSelection = new StructuredSelection(elements);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param element
+ * @param wrapper
+ */
+ public TableStructuredSelection(final Object element, final TableSelectionWrapper wrapper) {
+ this.wrappedSelection = new StructuredSelection(element);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param elements
+ * @param wrapper
+ */
+ public TableStructuredSelection(final Object[] elements, final TableSelectionWrapper wrapper) {
+ this.wrappedSelection = new StructuredSelection(elements);
+ this.wrapper = wrapper;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ *
+ * @param adapter
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
+ if (adapter == TableSelectionWrapper.class) {
+ return this.wrapper;
+ }
+ if (adapter == INattableModelManager.class && null != this.wrapper) {// to ease manipulation
+ return this.wrapper.getNatTableModelManager();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ISelection#isEmpty()
+ *
+ * @return
+ */
+ @Override
+ public boolean isEmpty() {
+ return this.wrappedSelection.isEmpty();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredSelection#getFirstElement()
+ *
+ * @return
+ */
+ @Override
+ public Object getFirstElement() {
+ return this.wrappedSelection.getFirstElement();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredSelection#iterator()
+ *
+ * @return
+ */
+ @Override
+ public Iterator<?> iterator() {
+ return this.wrappedSelection.iterator();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredSelection#size()
+ *
+ * @return
+ */
+ @Override
+ public int size() {
+ return this.wrappedSelection.size();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toArray()
+ *
+ * @return
+ */
+ @Override
+ public Object[] toArray() {
+ return this.wrappedSelection.toArray();
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredSelection#toList()
+ *
+ * @return
+ */
+ @Override
+ public List<?> toList() {
+ return this.wrappedSelection.toList();
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ *
+ * @param arg0
+ * @return
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof TableStructuredSelection)) {
+ return false;
+ }
+
+ final TableStructuredSelection tss2 = (TableStructuredSelection) o;
+ if (tss2.getTableSelectionWrapper().equals(getTableSelectionWrapper())
+ && tss2.getWrappedSelection().equals(getWrappedSelection())) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Internal usage onlyS
+ *
+ * @return
+ * the table selection wrapper
+ */
+ private TableSelectionWrapper getTableSelectionWrapper() {
+ return this.wrapper;
+ }
+
+ /**
+ * Internal usage only
+ *
+ * @return
+ * the wrapped selection
+ */
+ private IStructuredSelection getWrappedSelection() {
+ return this.wrappedSelection;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableSelectionWrapper.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableSelectionWrapper.java
index e28256d..fb1b968 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableSelectionWrapper.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableSelectionWrapper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,7 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 476618
- *
+ * Vincent Lorenzo (CEA LIST) - bug 525221
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.utils;
@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
/**
* Wrapper for the selection in the table
@@ -41,12 +42,17 @@ public class TableSelectionWrapper {
* a map linking index of selected column and the object in the selected column
*/
final private Map<Integer, Object> fullySelectionColumnsObject;
+ /**
+ * the table manager from where the selection comes
+ */
+ final private INattableModelManager manager;
/**
* Constructor.
*
* @param selectionCells
* The selected cells.
+ * @deprecated since 5.0
*/
public TableSelectionWrapper(final Collection<PositionCoordinate> selectionCells) {
this(selectionCells, Collections.<Integer, Object> emptyMap(), Collections.<Integer, Object> emptyMap());
@@ -61,11 +67,46 @@ public class TableSelectionWrapper {
* The selected rows (index or object affected).
* @param fullySelectedColumnObject
* The selected columns (index or object affected).
+ * @deprecated since 5.0
*/
public TableSelectionWrapper(final Collection<PositionCoordinate> selectionCells, final Map<Integer, Object> fullySelectedRowObject, final Map<Integer, Object> fullySelectedColumnObject) {
this.selectedCells = selectionCells;
this.fullySelectedRowsObject = fullySelectedRowObject;
this.fullySelectionColumnsObject = fullySelectedColumnObject;
+ this.manager = null;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param manager
+ * the table manager from where the selection comes
+ * @param selectionCells
+ * The selected cells.
+ * @since 5.0
+ */
+ public TableSelectionWrapper(final INattableModelManager manager, final Collection<PositionCoordinate> selectionCells) {
+ this(manager, selectionCells, Collections.<Integer, Object> emptyMap(), Collections.<Integer, Object> emptyMap());
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param manager
+ * the table manager from where the selection comes
+ * @param selectionCells
+ * The selected cells.
+ * @param fullySelectedRowObject
+ * The selected rows (index or object affected).
+ * @param fullySelectedColumnObject
+ * The selected columns (index or object affected).
+ * @since 5.0
+ */
+ public TableSelectionWrapper(final INattableModelManager manager, final Collection<PositionCoordinate> selectionCells, final Map<Integer, Object> fullySelectedRowObject, final Map<Integer, Object> fullySelectedColumnObject) {
+ this.selectedCells = selectionCells;
+ this.fullySelectedRowsObject = fullySelectedRowObject;
+ this.fullySelectionColumnsObject = fullySelectedColumnObject;
+ this.manager = manager;
}
/**
@@ -99,7 +140,7 @@ public class TableSelectionWrapper {
}
/**
- * Rturns a boolean determining if at least one selected cell is outside of the selected rows and columns.
+ * Returns a boolean determining if at least one selected cell is outside of the selected rows and columns.
*
* @return <code>true</code> if at least one selected cell is outside of the selected rows and columns, <code>false</code> otherwise.
*/
@@ -135,86 +176,86 @@ public class TableSelectionWrapper {
*
* @return <code>true</code> if the selected rows are continuous, <code>false</code> otherwise.
*/
- public boolean isContinuousRows(){
+ public boolean isContinuousRows() {
int firstRowIndex = -1;
int lastRowIndex = -1;
-
+
// To check if the selected rows are continuous, calculate :
- // - The first row index
- // - The last row index
- // To finalize :
- // - The number of selected rows must be equals to last index subtracted to the first index
- for(final int rowIndex : getFullySelectedRows().keySet()){
- if(-1 == firstRowIndex || rowIndex < firstRowIndex){
+ // - The first row index
+ // - The last row index
+ // To finalize :
+ // - The number of selected rows must be equals to last index subtracted to the first index
+ for (final int rowIndex : getFullySelectedRows().keySet()) {
+ if (-1 == firstRowIndex || rowIndex < firstRowIndex) {
firstRowIndex = rowIndex;
}
- if(-1 == lastRowIndex || rowIndex > lastRowIndex){
+ if (-1 == lastRowIndex || rowIndex > lastRowIndex) {
lastRowIndex = rowIndex;
}
}
-
- return (lastRowIndex-firstRowIndex+1) == getFullySelectedRows().size();
+
+ return (lastRowIndex - firstRowIndex + 1) == getFullySelectedRows().size();
}
-
+
/**
* Check if the selected columns are continuous.
*
* @return <code>true</code> if the selected columns are continuous, <code>false</code> otherwise.
*/
- public boolean isContinuousColumns(){
+ public boolean isContinuousColumns() {
int firstColumnIndex = -1;
int lastColumnIndex = -1;
-
+
// To check if the selected columns are continuous, calculate :
- // - The first column index
- // - The last column index
- // To finalize :
- // - The number of selected column must be equals to last index subtracted to the first index
- for(final int rowIndex : getFullySelectedColumns().keySet()){
- if(-1 == firstColumnIndex || rowIndex < firstColumnIndex){
+ // - The first column index
+ // - The last column index
+ // To finalize :
+ // - The number of selected column must be equals to last index subtracted to the first index
+ for (final int rowIndex : getFullySelectedColumns().keySet()) {
+ if (-1 == firstColumnIndex || rowIndex < firstColumnIndex) {
firstColumnIndex = rowIndex;
}
- if(-1 == lastColumnIndex || rowIndex > lastColumnIndex){
+ if (-1 == lastColumnIndex || rowIndex > lastColumnIndex) {
lastColumnIndex = rowIndex;
}
}
-
- return (lastColumnIndex-firstColumnIndex+1) == getFullySelectedColumns().size();
+
+ return (lastColumnIndex - firstColumnIndex + 1) == getFullySelectedColumns().size();
}
-
+
/**
* Check if the selected cells are continuous.
*
* @return <code>true</code> if the selected cells are continuous, <code>false</code> otherwise.
*/
- public boolean isContinuousCells(){
+ public boolean isContinuousCells() {
int firstRowIndex = -1;
int lastRowIndex = -1;
int firstColumnIndex = -1;
int lastColumnIndex = -1;
-
+
// To check if the selected cells are continuous, calculate :
- // - The first row index
- // - The last row index
- // - The first column index
- // - The last column index
- // To finalize :
- // - The number of selected cells must be equals to number of row index multiplied to number of column index
- for(final PositionCoordinate currentPosition : getSelectedCells()){
- if(-1 == firstRowIndex || currentPosition.getRowPosition() < firstRowIndex){
+ // - The first row index
+ // - The last row index
+ // - The first column index
+ // - The last column index
+ // To finalize :
+ // - The number of selected cells must be equals to number of row index multiplied to number of column index
+ for (final PositionCoordinate currentPosition : getSelectedCells()) {
+ if (-1 == firstRowIndex || currentPosition.getRowPosition() < firstRowIndex) {
firstRowIndex = currentPosition.getRowPosition();
}
- if(-1 == firstColumnIndex || currentPosition.getColumnPosition() < firstColumnIndex){
+ if (-1 == firstColumnIndex || currentPosition.getColumnPosition() < firstColumnIndex) {
firstColumnIndex = currentPosition.getColumnPosition();
}
- if(-1 == lastRowIndex || currentPosition.getRowPosition() > lastRowIndex){
+ if (-1 == lastRowIndex || currentPosition.getRowPosition() > lastRowIndex) {
lastRowIndex = currentPosition.getRowPosition();
}
- if(-1 == lastColumnIndex || currentPosition.getColumnPosition() > lastColumnIndex){
+ if (-1 == lastColumnIndex || currentPosition.getColumnPosition() > lastColumnIndex) {
lastColumnIndex = currentPosition.getColumnPosition();
}
}
-
+
return ((lastColumnIndex - firstColumnIndex + 1) * (lastRowIndex - firstRowIndex + 1)) == getSelectedCells().size();
}
@@ -227,4 +268,42 @@ public class TableSelectionWrapper {
this.selectedCells.clear();
}
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ *
+ * @param obj
+ * @return
+ */
+ @Override
+ public boolean equals(final Object o) {
+ if (!(o instanceof TableSelectionWrapper)) {
+ return false;
+ }
+
+ if (o == this) {
+ return true;
+ }
+
+ final TableSelectionWrapper w2 = (TableSelectionWrapper) o;
+ if (w2.getNatTableModelManager() != this.manager) {
+ return false;
+ }
+
+ if (w2.getNatTableModelManager() == this.manager && w2.getFullySelectedColumns().equals(this.fullySelectionColumnsObject)
+ && w2.getFullySelectedRows().equals(this.fullySelectedRowsObject)
+ && w2.getSelectedCells().equals(this.selectedCells)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @return
+ * the table manager from where the selection comes or <code>null</code> if a deprecated constructor has been used
+ * @since 5.0
+ */
+ public INattableModelManager getNatTableModelManager() {
+ return this.manager;
+ }
}