Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanh Liem PHAN2016-12-06 15:56:09 +0000
committerGerrit Code Review @ Eclipse.org2016-12-09 20:03:00 +0000
commit6237c597f4b1c6ceb984687c7e0fefcef8912278 (patch)
treed51be984e8ca78d05990d3223a56d740551f12fa /plugins/infra
parent541e9352407e8de79a46b491c726c0b7c658779f (diff)
downloadorg.eclipse.papyrus-6237c597f4b1c6ceb984687c7e0fefcef8912278.tar.gz
org.eclipse.papyrus-6237c597f4b1c6ceb984687c7e0fefcef8912278.tar.xz
org.eclipse.papyrus-6237c597f4b1c6ceb984687c7e0fefcef8912278.zip
Bug 506068: NullPointerException in NattableModelManager.updateCellMap
https://bugs.eclipse.org/bugs/show_bug.cgi?id=506068 - Check potential null objects (located in the method updateCellMap) before calling its methods Change-Id: Ia99ede42d45eb7fd4a72439b978aa9059399c3a7 Signed-off-by: Thanh Liem PHAN <thanhliem.phan@all4tec.net>
Diffstat (limited to 'plugins/infra')
-rw-r--r--[-rwxr-xr-x]plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java120
1 files changed, 63 insertions, 57 deletions
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 2e456fff871..5aa01c44c8c 100755..100644
--- 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
@@ -111,7 +111,6 @@ import org.eclipse.papyrus.infra.nattable.sort.PapyrusCompositeGlazedListSortMod
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.CellMapKey;
import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
-import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.StringComparator;
import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
@@ -212,8 +211,8 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
private final AdapterImpl changeAxisProviderHistory;
-
- private IFocusService focusService;
+
+ private IFocusService focusService;
/**
* the listener on the table cells
@@ -510,21 +509,21 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
this.focusListener = this;
nattable.addFocusListener(this.focusListener);
-
- //registering to focusService allows to declare properties tester on "activeFocusControl" and "activeFocusControlId" variables
+
+ // registering to focusService allows to declare properties tester on "activeFocusControl" and "activeFocusControlId" variables
focusService = (IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class);
- if (focusService!=null){
- String id=null;
- if (getTable().getTableConfiguration()!= null){
- id = getTable().getTableConfiguration().getType();
+ if (focusService != null) {
+ String id = null;
+ if (getTable().getTableConfiguration() != null) {
+ id = getTable().getTableConfiguration().getType();
}
- if (id == null){
+ if (id == null) {
id = getTableName();
}
- focusService.addFocusTracker(nattable,id);
+ focusService.addFocusTracker(nattable, id);
}
-
-
+
+
this.layerListener = new ILayerListener() {
@Override
@@ -896,11 +895,11 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
}
- if (focusService != null && this.natTable!=null){
+ if (focusService != null && this.natTable != null) {
focusService.removeFocusTracker(this.natTable);
focusService = null;
}
-
+
removeListeners();
super.dispose();
}
@@ -1808,51 +1807,58 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
@Override
protected IStatus run(final IProgressMonitor monitor) {
- if (notification == null) {
- cellsMap.clear();
- for (final Cell current : getTable().getCells()) {
- final CellMapKey key = createCellMapKeyWaitingCellAxis(current);
- cellsMap.put(key, current);
- }
- } else {
- final int eventType = notification.getEventType();
- if (eventType == Notification.ADD) {
- final Object object = notification.getNewValue();
- if (object instanceof Cell) {
- final Cell cell = (Cell) object;
- final CellMapKey key = createCellMapKeyWaitingCellAxis(cell);
- cellsMap.put(key, cell);
+ // Check the existence of the cellsMap
+ if (null != cellsMap) {
+ if (notification == null) {
+ cellsMap.clear();
+
+ // Check the existence of the table and its cells
+ if (null != getTable() && null != getTable().getCells()) {
+ for (final Cell current : getTable().getCells()) {
+ final CellMapKey key = createCellMapKeyWaitingCellAxis(current);
+ cellsMap.put(key, current);
+ }
}
- } else if (eventType == Notification.ADD_MANY) {
- final Object coll = notification.getNewValue();
-
- if (coll instanceof Collection<?>) {
- final Iterator<?> iter = ((Collection<?>) coll).iterator();
- while (iter.hasNext()) {
- final Object object = iter.next();
- if (object instanceof Cell) {
- final Cell cell = (Cell) object;
- final CellMapKey key = createCellMapKeyWaitingCellAxis(cell);
- cellsMap.put(key, cell);
+ } else {
+ final int eventType = notification.getEventType();
+ if (eventType == Notification.ADD) {
+ final Object object = notification.getNewValue();
+ if (object instanceof Cell) {
+ final Cell cell = (Cell) object;
+ final CellMapKey key = createCellMapKeyWaitingCellAxis(cell);
+ cellsMap.put(key, cell);
+ }
+ } else if (eventType == Notification.ADD_MANY) {
+ final Object coll = notification.getNewValue();
+
+ if (coll instanceof Collection<?>) {
+ final Iterator<?> iter = ((Collection<?>) coll).iterator();
+ while (iter.hasNext()) {
+ final Object object = iter.next();
+ if (object instanceof Cell) {
+ final Cell cell = (Cell) object;
+ final CellMapKey key = createCellMapKeyWaitingCellAxis(cell);
+ cellsMap.put(key, cell);
+ }
}
}
- }
- } else if (eventType == Notification.REMOVE) {
- final Object oldCell = notification.getOldValue();
- if (oldCell instanceof Cell) {
- final CellMapKey key = cellsMap.inverse().get(oldCell);
- cellsMap.remove(key);
- }
- } else if (eventType == Notification.REMOVE_MANY) {
- final Object coll = notification.getOldValue();
-
- if (coll instanceof Collection<?>) {
- final Iterator<?> iter = ((Collection<?>) coll).iterator();
- while (iter.hasNext()) {
- final Object object = iter.next();
- if (object instanceof Cell) {
- final CellMapKey key = cellsMap.inverse().get(object);
- cellsMap.remove(key);
+ } else if (eventType == Notification.REMOVE) {
+ final Object oldCell = notification.getOldValue();
+ if (oldCell instanceof Cell) {
+ final CellMapKey key = cellsMap.inverse().get(oldCell);
+ cellsMap.remove(key);
+ }
+ } else if (eventType == Notification.REMOVE_MANY) {
+ final Object coll = notification.getOldValue();
+
+ if (coll instanceof Collection<?>) {
+ final Iterator<?> iter = ((Collection<?>) coll).iterator();
+ while (iter.hasNext()) {
+ final Object object = iter.next();
+ if (object instanceof Cell) {
+ final CellMapKey key = cellsMap.inverse().get(object);
+ cellsMap.remove(key);
+ }
}
}
}

Back to the top