diff options
author | Sebastien Gabel | 2016-07-07 12:21:03 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-07-07 15:26:32 +0000 |
commit | e3d745ff1daeff18af0c10c14e9f7f241fc5ef1a (patch) | |
tree | 01507e5775ed47a6ab8d87b367a389831e2c9379 /plugins/infra/nattable | |
parent | a893b892eabc4f7f85ae2af78373dc4fc1072ef7 (diff) | |
download | org.eclipse.papyrus-e3d745ff1daeff18af0c10c14e9f7f241fc5ef1a.tar.gz org.eclipse.papyrus-e3d745ff1daeff18af0c10c14e9f7f241fc5ef1a.tar.xz org.eclipse.papyrus-e3d745ff1daeff18af0c10c14e9f7f241fc5ef1a.zip |
Bug 497470 - [Table] Missing listener unregistrations + call to dispose
Change-Id: I645f0ba271f8b05d1d1828388b8994c880d68903
Signed-off-by: Sebastien Gabel <sebastien.gabel@esterel-technologies.com>
Diffstat (limited to 'plugins/infra/nattable')
3 files changed, 442 insertions, 421 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractIndexHeaderDataProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractIndexHeaderDataProvider.java index 36e758ee8fb..356d55709f9 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractIndexHeaderDataProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractIndexHeaderDataProvider.java @@ -1,185 +1,194 @@ -/*****************************************************************************
- * Copyright (c) 2014 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.dataprovider;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisIndexStyle;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
-import org.eclipse.papyrus.infra.tools.util.IntegerAndSpreadsheetNumberConverter;
-
-/**
- *
- * Abstract class used to display index header
- *
- */
-public abstract class AbstractIndexHeaderDataProvider extends AbstractDataProvider {
-
- /** fields used to know what display in the headers */
- protected boolean displayIndex;
-
- /** the style used to display the index of the axis */
- protected AxisIndexStyle style;
-
-
- /** listener on {@link Table#isInvertAxis()} feature */
- private Adapter invertedListener;
-
- /**
- * listener on the axis configuration
- */
- private Adapter axisListener;
-
- /**
- * listener on the table
- */
- private Adapter localHeaderConfigListener;
-
- /**
- * the listen axis configuration
- */
- private AbstractHeaderAxisConfiguration listenAxisConfiguration;
-
- /**
- *
- * Constructor.
- *
- * @param tableModelManager
- * the table manager
- */
- public AbstractIndexHeaderDataProvider(final INattableModelManager tableModelManager) {
- super(tableModelManager);
- this.listenAxisConfiguration = getAxisConfiguration();
- initListeners();
- this.manager.getTable().eAdapters().add(this.invertedListener);
- this.manager.getTable().eAdapters().add(this.localHeaderConfigListener);
- initFields();
- }
-
-
- /**
- * Create the listeners, but doesn't assign them to an object
- */
- protected void initListeners() {
- this.axisListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- final Object feature = msg.getFeature();
- if (feature != null) {
- if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex())) {
- displayIndex = msg.getNewBooleanValue();
- } else if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_IndexStyle())) {
- style = AxisIndexStyle.get(msg.getNewStringValue());
- }
- }
- }
- };
- this.invertedListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) {
- final Object oldValue = msg.getOldValue();
- final Object newValue = msg.getNewValue();
- if (oldValue != null && newValue != null) {
- initFields();
- }
- }
- }
- };
-
- this.localHeaderConfigListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration() || msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration()) {
- initFields();
- }
- }
- };
- }
-
- /**
- * init the field value, and update the listen axis if required
- */
- private void initFields() {
- if (this.listenAxisConfiguration != getAxisConfiguration() && this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
- }
- this.listenAxisConfiguration = getAxisConfiguration();
- if (this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().add(this.axisListener);
- if (this.listenAxisConfiguration instanceof AbstractHeaderAxisConfiguration) {
- AbstractHeaderAxisConfiguration config = this.listenAxisConfiguration;
- this.style = config.getIndexStyle();
- this.displayIndex = config.isDisplayIndex();
- }
- }
- }
-
- /**
- *
- * @param axisIndex
- * the index of the axis
- * @return
- * the index to display according to the index style
- */
- protected Object getAxisIndex(int axisIndex) {
- if (axisIndex > -1) {
- switch (this.style) {
- case ALPHABETIC:
- return IntegerAndSpreadsheetNumberConverter.toString(axisIndex + 1);
- case NUMERIC:
- return axisIndex;
- }
- }
- return null;
- }
-
-
- /**
- * remove the listener
- */
- protected void removeListeners() {
- if (this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
- }
- this.manager.getTable().eAdapters().remove(this.invertedListener);
- this.manager.getTable().eAdapters().remove(this.localHeaderConfigListener);
- }
-
- /**
- *
- * @return
- * the axis configuration to listen
- */
- protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration();
-
- /**
- * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#dispose()
- *
- */
- @Override
- public void dispose() {
- removeListeners();
- this.listenAxisConfiguration = null;
- super.dispose();
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2014, 2016 CEA LIST, Esterel Technologies SAS 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Calin Glitia (Esterel Technologies SAS) - Bug 497470 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.dataprovider; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisIndexStyle; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage; +import org.eclipse.papyrus.infra.tools.util.IntegerAndSpreadsheetNumberConverter; + +/** + * + * Abstract class used to display index header + * + */ +public abstract class AbstractIndexHeaderDataProvider extends AbstractDataProvider { + + /** fields used to know what display in the headers */ + protected boolean displayIndex; + + /** the style used to display the index of the axis */ + protected AxisIndexStyle style; + + + /** listener on {@link Table#isInvertAxis()} feature */ + private Adapter invertedListener; + + /** + * listener on the axis configuration + */ + private Adapter axisListener; + + /** + * listener on the table + */ + private Adapter localHeaderConfigListener; + + /** + * the listen axis configuration + */ + private AbstractHeaderAxisConfiguration listenAxisConfiguration; + + /** + * + * Constructor. + * + * @param tableModelManager + * the table manager + */ + public AbstractIndexHeaderDataProvider(final INattableModelManager tableModelManager) { + super(tableModelManager); + this.listenAxisConfiguration = getAxisConfiguration(); + initListeners(); + this.manager.getTable().eAdapters().add(this.invertedListener); + this.manager.getTable().eAdapters().add(this.localHeaderConfigListener); + initFields(); + } + + + /** + * Create the listeners, but doesn't assign them to an object + */ + protected void initListeners() { + this.axisListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + final Object feature = msg.getFeature(); + if (feature != null) { + if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayIndex())) { + displayIndex = msg.getNewBooleanValue(); + } else if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_IndexStyle())) { + style = AxisIndexStyle.get(msg.getNewStringValue()); + } + } + } + }; + this.invertedListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) { + final Object oldValue = msg.getOldValue(); + final Object newValue = msg.getNewValue(); + if (oldValue != null && newValue != null) { + initFields(); + } + } + } + }; + + this.localHeaderConfigListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration() || msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration()) { + initFields(); + } + } + }; + } + + /** + * init the field value, and update the listen axis if required + */ + private void initFields() { + if (this.listenAxisConfiguration != getAxisConfiguration() && this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().remove(this.axisListener); + } + this.listenAxisConfiguration = getAxisConfiguration(); + if (this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().add(this.axisListener); + if (this.listenAxisConfiguration instanceof AbstractHeaderAxisConfiguration) { + AbstractHeaderAxisConfiguration config = this.listenAxisConfiguration; + this.style = config.getIndexStyle(); + this.displayIndex = config.isDisplayIndex(); + } + } + } + + /** + * + * @param axisIndex + * the index of the axis + * @return + * the index to display according to the index style + */ + protected Object getAxisIndex(int axisIndex) { + if (axisIndex > -1) { + switch (this.style) { + case ALPHABETIC: + return IntegerAndSpreadsheetNumberConverter.toString(axisIndex + 1); + case NUMERIC: + return axisIndex; + } + } + return null; + } + + + /** + * remove the listener + */ + protected void removeListeners() { + if (this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().remove(this.axisListener); + } + Table table = this.manager.getTable(); + if (table != null) { + if (this.invertedListener != null) { + table.eAdapters().remove(this.invertedListener); + } + if (this.localHeaderConfigListener != null) { + table.eAdapters().remove(this.localHeaderConfigListener); + } + } + } + + /** + * + * @return + * the axis configuration to listen + */ + protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration(); + + /** + * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#dispose() + * + */ + @Override + public void dispose() { + removeListeners(); + this.listenAxisConfiguration = null; + super.dispose(); + } + +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractLabelHeaderDataProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractLabelHeaderDataProvider.java index b9f449d7c8c..be95a4a6ed3 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractLabelHeaderDataProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dataprovider/AbstractLabelHeaderDataProvider.java @@ -1,158 +1,167 @@ -/*****************************************************************************
- * Copyright (c) 2014 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.dataprovider;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
-
-/**
- *
- * @author VL222926
- *
- * Abstract class used to display label header
- *
- */
-public abstract class AbstractLabelHeaderDataProvider extends AbstractDataProvider {
-
- /** fields used to know what display in the headers */
- protected boolean displayLabel;
-
-
- /** listener on {@link Table#isInvertAxis()} feature */
- private Adapter invertedListener;
-
- /**
- * listener on the axis configuration
- */
- private Adapter axisListener;
-
- /**
- * listener on the table
- */
- private Adapter localHeaderConfigListener;
-
- /**
- * the listen axis configuration
- */
- private AbstractHeaderAxisConfiguration listenAxisConfiguration;
-
- /**
- *
- * Constructor.
- *
- * @param tableModelManager
- */
- public AbstractLabelHeaderDataProvider(final INattableModelManager tableModelManager) {
- super(tableModelManager);
- this.listenAxisConfiguration = getAxisConfiguration();
- initListeners();
- this.manager.getTable().eAdapters().add(this.invertedListener);
- this.manager.getTable().eAdapters().add(this.localHeaderConfigListener);
- initFields();
- }
-
- /**
- * Create the listeners, but doesn't assign them to an object
- */
- protected void initListeners() {
- this.axisListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- final Object feature = msg.getFeature();
- if (feature != null) {
- if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel())) {
- displayLabel = msg.getNewBooleanValue();
- }
- }
- }
- };
- this.invertedListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) {
- final Object oldValue = msg.getOldValue();
- final Object newValue = msg.getNewValue();
- if (oldValue != null && newValue != null) {
- initFields();
- }
- }
- }
- };
-
- this.localHeaderConfigListener = new AdapterImpl() {
-
- @Override
- public void notifyChanged(Notification msg) {
- if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration() || msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration()) {
- initFields();
- }
- }
- };
- }
-
- /**
- * init the field value, and update the listen axis if required
- */
- private void initFields() {
- if (this.listenAxisConfiguration != getAxisConfiguration() && this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
- }
- this.listenAxisConfiguration = getAxisConfiguration();
- if (this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().add(this.axisListener);
- if (this.listenAxisConfiguration instanceof AbstractHeaderAxisConfiguration) {
- AbstractHeaderAxisConfiguration config = this.listenAxisConfiguration;
- this.displayLabel = config.isDisplayLabel();
- }
- }
- }
-
-
- /**
- * remove the listener
- */
- protected void removeListeners() {
- if (this.listenAxisConfiguration != null) {
- this.listenAxisConfiguration.eAdapters().remove(this.axisListener);
- this.listenAxisConfiguration = null;
- }
- this.manager.getTable().eAdapters().remove(this.invertedListener);
- this.manager.getTable().eAdapters().remove(this.localHeaderConfigListener);
- }
-
- /**
- *
- * @return
- * the axis configuration to listen
- */
- protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration();
-
- /**
- * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#dispose()
- *
- */
- @Override
- public void dispose() {
- removeListeners();
- this.listenAxisConfiguration = null;
- super.dispose();
- }
-}
+/***************************************************************************** + * Copyright (c) 2014, 2016 CEA LIST, Esterel Technologies SAS 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Calin Glitia (Esterel Technologies SAS) - Bug 497470 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.dataprovider; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AbstractHeaderAxisConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage; + +/** + * + * @author VL222926 + * + * Abstract class used to display label header + * + */ +public abstract class AbstractLabelHeaderDataProvider extends AbstractDataProvider { + + /** fields used to know what display in the headers */ + protected boolean displayLabel; + + + /** listener on {@link Table#isInvertAxis()} feature */ + private Adapter invertedListener; + + /** + * listener on the axis configuration + */ + private Adapter axisListener; + + /** + * listener on the table + */ + private Adapter localHeaderConfigListener; + + /** + * the listen axis configuration + */ + private AbstractHeaderAxisConfiguration listenAxisConfiguration; + + /** + * + * Constructor. + * + * @param tableModelManager + */ + public AbstractLabelHeaderDataProvider(final INattableModelManager tableModelManager) { + super(tableModelManager); + this.listenAxisConfiguration = getAxisConfiguration(); + initListeners(); + this.manager.getTable().eAdapters().add(this.invertedListener); + this.manager.getTable().eAdapters().add(this.localHeaderConfigListener); + initFields(); + } + + /** + * Create the listeners, but doesn't assign them to an object + */ + protected void initListeners() { + this.axisListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + final Object feature = msg.getFeature(); + if (feature != null) { + if (feature.equals(NattableaxisconfigurationPackage.eINSTANCE.getAbstractHeaderAxisConfiguration_DisplayLabel())) { + displayLabel = msg.getNewBooleanValue(); + } + } + } + }; + this.invertedListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_InvertAxis()) { + final Object oldValue = msg.getOldValue(); + final Object newValue = msg.getNewValue(); + if (oldValue != null && newValue != null) { + initFields(); + } + } + } + }; + + this.localHeaderConfigListener = new AdapterImpl() { + + @Override + public void notifyChanged(Notification msg) { + if (msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalColumnHeaderAxisConfiguration() || msg.getFeature() == NattablePackage.eINSTANCE.getTable_LocalRowHeaderAxisConfiguration()) { + initFields(); + } + } + }; + } + + /** + * init the field value, and update the listen axis if required + */ + private void initFields() { + if (this.listenAxisConfiguration != getAxisConfiguration() && this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().remove(this.axisListener); + } + this.listenAxisConfiguration = getAxisConfiguration(); + if (this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().add(this.axisListener); + if (this.listenAxisConfiguration instanceof AbstractHeaderAxisConfiguration) { + AbstractHeaderAxisConfiguration config = this.listenAxisConfiguration; + this.displayLabel = config.isDisplayLabel(); + } + } + } + + + /** + * remove the listener + */ + protected void removeListeners() { + if (this.listenAxisConfiguration != null) { + this.listenAxisConfiguration.eAdapters().remove(this.axisListener); + this.listenAxisConfiguration = null; + } + Table table = this.manager.getTable(); + if (table != null) { + if (this.invertedListener != null) { + table.eAdapters().remove(this.invertedListener); + } + if (this.localHeaderConfigListener != null) { + table.eAdapters().remove(this.localHeaderConfigListener); + } + } + } + + /** + * + * @return + * the axis configuration to listen + */ + protected abstract AbstractHeaderAxisConfiguration getAxisConfiguration(); + + /** + * @see org.eclipse.papyrus.infra.nattable.dataprovider.AbstractDataProvider#dispose() + * + */ + @Override + public void dispose() { + removeListeners(); + this.listenAxisConfiguration = null; + super.dispose(); + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CreatableEObjectAxisUtils.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CreatableEObjectAxisUtils.java index 3045583815c..7841ade36eb 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CreatableEObjectAxisUtils.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CreatableEObjectAxisUtils.java @@ -1,78 +1,81 @@ -/*****************************************************************************
- * 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.utils;
-
-import java.util.Collection;
-import java.util.TreeSet;
-
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.papyrus.infra.nattable.selection.ObjectsSelectionExtractor;
-import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeUtils;
-
-/**
- *
- * This class provides useful methods to know which kind of elements can be created for a given table
- *
- */
-public class CreatableEObjectAxisUtils {
-
- private CreatableEObjectAxisUtils() {
- // to prevent instanciation
- }
-
- /**
- *
- * @param table
- * the table
- * @param onColumn
- * <code>true</code> if we are working on column, false if not
- * @return
- * the list of the creatable element on the axis
- */
- public static final Collection<String> getCreatableElementIds(final Table table, final boolean onColumn) {
- final INattableModelManager nattableModelManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(table, new ObjectsSelectionExtractor());
- return getCreatableElementIds(nattableModelManager, onColumn);
- }
-
- /**
- *
- * @param tableManager
- * the tableManager
- * @param onColumn
- * <code>true</code> if we are working on column, false if not
- * @return
- * the list of the creatable element on the axis
- */
- public static final Collection<String> getCreatableElementIds(final INattableModelManager nattableModelManager, final boolean onColumn) {
- final IAxisManager axisManager;
- if (onColumn) {
- axisManager = nattableModelManager.getColumnAxisManager();
- } else {
- axisManager = nattableModelManager.getRowAxisManager();
- }
- final Collection<IElementType> possibleValues = ElementTypeUtils.getAllExistingElementTypes();
- final Collection<String> allowedElements = new TreeSet<String>();
- for (final IElementType current : possibleValues) {
- final String id = current.getId();
- if (axisManager.canCreateAxisElement(id)) {
- allowedElements.add(id);
- }
- }
- return allowedElements;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2013, 2016 CEA LIST, Esterel Technologies SAS 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Calin Glitia (Esterel Technologies SAS) - Bug 497470 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.utils; + +import java.util.Collection; +import java.util.TreeSet; + +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.selection.ObjectsSelectionExtractor; +import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeUtils; + +/** + * + * This class provides useful methods to know which kind of elements can be created for a given table + * + */ +public class CreatableEObjectAxisUtils { + + private CreatableEObjectAxisUtils() { + // to prevent instanciation + } + + /** + * + * @param table + * the table + * @param onColumn + * <code>true</code> if we are working on column, false if not + * @return + * the list of the creatable element on the axis + */ + public static final Collection<String> getCreatableElementIds(final Table table, final boolean onColumn) { + final INattableModelManager nattableModelManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(table, new ObjectsSelectionExtractor()); + Collection<String> creatableElementIds = getCreatableElementIds(nattableModelManager, onColumn); + nattableModelManager.dispose(); + return creatableElementIds; + } + + /** + * + * @param tableManager + * the tableManager + * @param onColumn + * <code>true</code> if we are working on column, false if not + * @return + * the list of the creatable element on the axis + */ + public static final Collection<String> getCreatableElementIds(final INattableModelManager nattableModelManager, final boolean onColumn) { + final IAxisManager axisManager; + if (onColumn) { + axisManager = nattableModelManager.getColumnAxisManager(); + } else { + axisManager = nattableModelManager.getRowAxisManager(); + } + final Collection<IElementType> possibleValues = ElementTypeUtils.getAllExistingElementTypes(); + final Collection<String> allowedElements = new TreeSet<String>(); + for (final IElementType current : possibleValues) { + final String id = current.getId(); + if (axisManager.canCreateAxisElement(id)) { + allowedElements.add(id); + } + } + return allowedElements; + } + +} |