diff options
author | Nicolas FAUVERGUE | 2016-02-10 09:56:17 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-02-18 10:29:30 +0000 |
commit | aa2547d92c26a840aae1594e07b70b04b2baf586 (patch) | |
tree | 2b65d6ce250046ff0e98cd7f2612a29ddaa82669 | |
parent | 311dc7873510ce1c46bc2c25bc7930e238021c4b (diff) | |
download | org.eclipse.papyrus-aa2547d92c26a840aae1594e07b70b04b2baf586.tar.gz org.eclipse.papyrus-aa2547d92c26a840aae1594e07b70b04b2baf586.tar.xz org.eclipse.papyrus-aa2547d92c26a840aae1594e07b70b04b2baf586.zip |
Bug 460812: [Table - CellManager] The CellManager extension point
doesn't accept multiple contributions with the same order
https://bugs.eclipse.org/bugs/show_bug.cgi?id=460812
Manage some cell manager with the same order.
When we get the cell manager corresponding to row and column, we get the
first corresponding cell manager in the collection.
Change-Id: I6a57770070325583b2e06a900e153b1aff31275f
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r-- | plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java index 9c4d3734f44..b0c27de0504 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/cell/CellManagerFactory.java @@ -16,6 +16,8 @@ package org.eclipse.papyrus.infra.nattable.manager.cell; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.TreeMap; @@ -53,7 +55,7 @@ public final class CellManagerFactory { /** * the map of the cell manager sorted by priority */ - private final Map<Integer, ICellManager> managersMap; + private final Map<Integer, Collection<ICellManager>> managersMap; /** * The cell manager factory @@ -66,7 +68,7 @@ public final class CellManagerFactory { * Initialize the field of the class */ private CellManagerFactory() { - this.managersMap = new TreeMap<Integer, ICellManager>(); + this.managersMap = new TreeMap<Integer, Collection<ICellManager>>(); final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID); for (final IConfigurationElement iConfigurationElement : configElements) { @@ -76,7 +78,10 @@ public final class CellManagerFactory { final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER)); try { final ICellManager solver = (ICellManager) iConfigurationElement.createExecutableExtension(CLASS_MANAGER); - this.managersMap.put(order, new StringResolutionProblemWrapperCellManager(solver)); + if(!this.managersMap.containsKey(order)){ + this.managersMap.put(order, new HashSet<ICellManager>()); + } + this.managersMap.get(order).add(new StringResolutionProblemWrapperCellManager(solver)); } catch (final CoreException e) { Activator.log.error(e); } @@ -127,20 +132,25 @@ public final class CellManagerFactory { * the column element as described in the model (you must ignore the invert axis) * * @param rowElement - * - * the row element as described in the model (you must ignore the invert axis) * * @return * the cell manager */ private ICellManager getCellManager(final Object columnElement, final Object rowElement) { - for (final Integer integer : this.managersMap.keySet()) { - ICellManager current = this.managersMap.get(integer); - if (current.handles(columnElement, rowElement)) { - return current; + ICellManager result = null; + final Iterator<Integer> orders = this.managersMap.keySet().iterator(); + while(orders.hasNext() && null == result){ + final Integer integer = orders.next(); + final Iterator<ICellManager> cellManagers = this.managersMap.get(integer).iterator(); + while(cellManagers.hasNext() && null == result){ + final ICellManager current = cellManagers.next(); + if (current.handles(columnElement, rowElement)) { + result = current; + } } } - return null; + return result; } /** |