Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauricio Alferez2015-03-04 17:34:19 +0000
committerMauricio Alferez2015-03-20 12:05:47 +0000
commite346cfd7fd22162c4fcdfe5250b2504969c5001a (patch)
treef0faf8b70032ba1786ed63574182fae986232fbc /plugins
parentbd85bc6f0ab11c0158ecb22412a0e0779dfa8c25 (diff)
downloadorg.eclipse.papyrus-e346cfd7fd22162c4fcdfe5250b2504969c5001a.tar.gz
org.eclipse.papyrus-e346cfd7fd22162c4fcdfe5250b2504969c5001a.tar.xz
org.eclipse.papyrus-e346cfd7fd22162c4fcdfe5250b2504969c5001a.zip
Refactoring of cell editors for nattable
[Bug 459647] [Table 2] The cell editor configuration files must be splitted Change-Id: Ib37410875faf14c7ba16317d919dcd573ed3618f Signed-off-by: Mauricio Alferez <mauricio.alferez@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/plugin.xml16
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/EStructuralFeatureEditorConfig.java4
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleBooleanCellEditorConfiguration.java97
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleEEnumTypeCellEditorConfiguration.java116
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleIntegerCellEditorConfiguration.java97
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java97
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/schema/org.eclipse.papyrus.infra.nattable.celleditor.configuration.exsd30
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellAxisConfigurationRegistry.java132
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java29
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/ICellAxisConfiguration.java40
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java203
11 files changed, 800 insertions, 61 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/plugin.xml
index ba84e3b43a4..0683a75d140 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/plugin.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/plugin.xml
@@ -7,6 +7,22 @@
class="org.eclipse.papyrus.infra.emf.nattable.celleditor.config.EStructuralFeatureEditorConfig"
order="1000">
</configuration>
+ <cellAxisConfiguration
+ class="org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleBooleanCellEditorConfiguration"
+ order="1000">
+ </cellAxisConfiguration>
+ <cellAxisConfiguration
+ class="org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleEEnumTypeCellEditorConfiguration"
+ order="1001">
+ </cellAxisConfiguration>
+ <cellAxisConfiguration
+ class="org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleIntegerCellEditorConfiguration"
+ order="1002">
+ </cellAxisConfiguration>
+ <cellAxisConfiguration
+ class="org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration"
+ order="1003">
+ </cellAxisConfiguration>
</extension>
<extension
point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/EStructuralFeatureEditorConfig.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/EStructuralFeatureEditorConfig.java
index ce76abd070d..b376a3843ca 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/EStructuralFeatureEditorConfig.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/EStructuralFeatureEditorConfig.java
@@ -45,8 +45,10 @@ import org.eclipse.papyrus.infra.nattable.painter.CustomCheckBoxPainter;
* The configuration to edit EMF properties
*
* @author Vincent Lorenzo
- *
+ * @deprecated Used just until Papyrus Luna. Replaced by classes that are specific to each type of cell editor in the package org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration
+ *
*/
+@Deprecated
public class EStructuralFeatureEditorConfig extends AbstractCellEditorConfiguration {
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleBooleanCellEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleBooleanCellEditorConfiguration.java
new file mode 100644
index 00000000000..19b5a9c142b
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleBooleanCellEditorConfiguration.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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.emf.nattable.celleditor.config;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.editor.CheckBoxCellEditor;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.painter.CustomCheckBoxPainter;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.infra.tools.util.TypesConstants;
+
+/**
+ * @author MA244259
+ *
+ */
+public class SingleBooleanCellEditorConfiguration implements ICellAxisConfiguration {
+
+ /**
+ * the id of this editor
+ */
+ private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleBooleanCellEditorConfiguration.CheckBox";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationId()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationId() {
+ return ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationDescription() {
+ return "This configuration provides a CheckBox editor for a single Boolean"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#handles(org.eclipse.papyrus.infra.nattable.model.nattable.Table, java.lang.Object)
+ *
+ * @param table
+ * @param axisElement
+ * @return
+ */
+ @Override
+ public boolean handles(Table table, Object axisElement) {
+ Object object = AxisUtils.getRepresentedElement(axisElement);
+ if (object instanceof EStructuralFeature) {
+ EStructuralFeature feature = (EStructuralFeature) object;
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+
+ return TypesConstants.BOOLEAN.equals(datatype.getName());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#configureCellEditor(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object, java.lang.String)
+ *
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+ @Override
+ public void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new CustomCheckBoxPainter(), DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new CheckBoxCellEditor(), DisplayMode.NORMAL, configLabel);
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultBooleanDisplayConverter(), DisplayMode.NORMAL, configLabel);
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleEEnumTypeCellEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleEEnumTypeCellEditorConfiguration.java
new file mode 100644
index 00000000000..f682b19bc7b
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleEEnumTypeCellEditorConfiguration.java
@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * 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.emf.nattable.celleditor.config;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
+import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ComboBoxPainter;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.emf.nattable.dataprovider.EEnumComboBoxDataProvider;
+import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+
+/**
+ * @author MA244259
+ *
+ */
+public class SingleEEnumTypeCellEditorConfiguration implements ICellAxisConfiguration {
+
+ /**
+ * the id of this editor
+ */
+ private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleEEnumTypeCellEditorConfiguration.ComboBox";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationId()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationId() {
+ return ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationDescription() {
+ return "This configuration provides a ComboBox editor for a single EEnum type"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.ICellAxisEditorConfiguration#handles(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object)
+ *
+ * @param table
+ * @param axisElement
+ * @return
+ * <code>true</code> if axisElement is a {@link EEnum} {@link EStructuralFeature}
+ */
+ @Override
+ public boolean handles(Table table, Object axisElement) {
+ Object representedElement = AxisUtils.getRepresentedElement(axisElement);
+ if (representedElement instanceof EStructuralFeature) {
+ EClassifier eType = ((EStructuralFeature) representedElement).getEType();
+ return eType instanceof EEnum;
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.ICellAxisEditorConfiguration#configureCellEditor(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object, java.lang.String)
+ *
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+ @Override
+ public void configureCellEditor(final IConfigRegistry configRegistry, Object axis, String configLabel) {
+ Object representedElement = AxisUtils.getRepresentedElement(axis);
+ EEnum eenum =(EEnum)((EStructuralFeature) representedElement).getEType();
+
+ IDisplayConverter displayConverter = new DisplayConverter() {
+
+ @Override
+ public Object displayToCanonicalValue(Object displayValue) {
+ return null;
+ }
+
+ @Override
+ public Object canonicalToDisplayValue(Object canonicalValue) {
+ // for others case
+ // LabelProviderService service = configRegistry.getConfigAttribute(NattableConfigAttributes.LABEL_PROVIDER_SERVICE_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.LABEL_PROVIDER_SERVICE_ID);
+ // return service.getLabelProvider(canonicalValue).getText(canonicalValue);
+ //
+
+ return new EMFLabelProvider().getText(canonicalValue);
+ }
+ };
+
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new ComboBoxPainter(), DisplayMode.EDIT, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new ComboBoxCellEditor(new EEnumComboBoxDataProvider(eenum)), DisplayMode.EDIT, configLabel);
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, displayConverter, DisplayMode.EDIT, configLabel);
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleIntegerCellEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleIntegerCellEditorConfiguration.java
new file mode 100644
index 00000000000..ea0a025c8b2
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleIntegerCellEditorConfiguration.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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.emf.nattable.celleditor.config;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.DefaultIntegerDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor;
+import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.infra.tools.util.TypesConstants;
+
+/**
+ * @author MA244259
+ *
+ */
+public class SingleIntegerCellEditorConfiguration implements ICellAxisConfiguration{
+
+ /**
+ * the id of this editor
+ */
+ private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleIntegerCellEditorConfiguration.Text";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationId()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationId() {
+ return ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationDescription() {
+ return "This configuration provides a Text editor for a single Integer"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#handles(org.eclipse.papyrus.infra.nattable.model.nattable.Table, java.lang.Object)
+ *
+ * @param table
+ * @param axisElement
+ * @return
+ */
+ @Override
+ public boolean handles(Table table, Object axisElement) {
+ Object object = AxisUtils.getRepresentedElement(axisElement);
+ if (object instanceof EStructuralFeature) {
+ EStructuralFeature feature = (EStructuralFeature) object;
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+ return TypesConstants.INTEGER.equals(datatype.getName());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#configureCellEditor(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object, java.lang.String)
+ *
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+ @Override
+ public void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TextPainter(), DisplayMode.EDIT, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor(), DisplayMode.EDIT, configLabel);
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultIntegerDisplayConverter(), DisplayMode.EDIT, configLabel);
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java
new file mode 100644
index 00000000000..b8fb2a6b080
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/celleditor/config/SingleStringCellEditorConfiguration.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * 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.emf.nattable.celleditor.config;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.data.convert.DefaultIntegerDisplayConverter;
+import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor;
+import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
+import org.eclipse.papyrus.infra.tools.util.TypesConstants;
+
+/**
+ * @author MA244259
+ *
+ */
+public class SingleStringCellEditorConfiguration implements ICellAxisConfiguration{
+
+ /**
+ * the id of this editor
+ */
+ private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleStringCellEditorConfiguration.MultiLineText";//$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationId()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationId() {
+ return ID;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration#getConfigurationDescription()
+ *
+ * @return
+ */
+ @Override
+ public String getConfigurationDescription() {
+ return "This configuration provides a multi-line text editor for a single String"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#handles(org.eclipse.papyrus.infra.nattable.model.nattable.Table, java.lang.Object)
+ *
+ * @param table
+ * @param axisElement
+ * @return
+ */
+ @Override
+ public boolean handles(Table table, Object axisElement) {
+ Object object = AxisUtils.getRepresentedElement(axisElement);
+ if (object instanceof EStructuralFeature) {
+ EStructuralFeature feature = (EStructuralFeature) object;
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+ return TypesConstants.STRING.equals(datatype.getName());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration#configureCellEditor(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry, java.lang.Object, java.lang.String)
+ *
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+ @Override
+ public void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TextPainter(), DisplayMode.EDIT, configLabel);
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TextCellEditor(), DisplayMode.EDIT, configLabel);
+ //I believe that we don't need converters because we are working with the standard type --String.
+ //configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, null, DisplayMode.EDIT, configLabel);
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/schema/org.eclipse.papyrus.infra.nattable.celleditor.configuration.exsd b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/schema/org.eclipse.papyrus.infra.nattable.celleditor.configuration.exsd
index 0683d205574..df497e55889 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/schema/org.eclipse.papyrus.infra.nattable.celleditor.configuration.exsd
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/schema/org.eclipse.papyrus.infra.nattable.celleditor.configuration.exsd
@@ -19,6 +19,7 @@
<complexType>
<sequence>
<element ref="configuration" minOccurs="1" maxOccurs="unbounded"/>
+ <element ref="cellAxisConfiguration" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
@@ -49,8 +50,12 @@
<element name="configuration">
<annotation>
+ <appinfo>
+ <meta.element deprecated="true"/>
+ </appinfo>
<documentation>
This extension point allows to register configuration used for celleditor in the table
+@Deprecated since Papyrus 1.1.0. use cellAxisConfiguration instead
</documentation>
</annotation>
<complexType>
@@ -60,7 +65,30 @@
The class providing cell editor configuration for one or several type.
</documentation>
<appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.nattable.celleditor.configs.IAxisCellEditorConfiguration"/>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="order" type="string" use="required">
+ <annotation>
+ <documentation>
+ Several configuration can be used for the same type, so we use this attribute to sort them.
+more the order is small, more the configuration is prioritary
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="cellAxisConfiguration">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class providing cell editor configuration for one or several type.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.ICellAxisConfiguration"/>
</appinfo>
</annotation>
</attribute>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellAxisConfigurationRegistry.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellAxisConfigurationRegistry.java
new file mode 100644
index 00000000000..addc9fd7b4a
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellAxisConfigurationRegistry.java
@@ -0,0 +1,132 @@
+/*****************************************************************************
+ * 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.celleditor.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.emf.Activator;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+
+/**
+ * @author MA244259
+ *
+ */
+public class CellAxisConfigurationRegistry {
+
+ private Map<Integer, ICellAxisConfiguration> registry;
+
+ public static final String EXTENSION_ID = "org.eclipse.papyrus.infra.nattable.celleditor.configuration"; //$NON-NLS-1$
+
+ public static final String CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
+ public static final String ORDER_ATTRIBUTE = "order"; //$NON-NLS-1$
+
+ public static final CellAxisConfigurationRegistry INSTANCE = new CellAxisConfigurationRegistry();
+
+// public static final String EXTENSION_POINT_NAMESPACE = "org.eclipse.papyrus.infra.nattable.celleditor";
+
+ public static final String CONFIGURATION_EXT_NEW = "cellAxisConfiguration";
+
+ /**
+ *
+ * Constructor.
+ * Initial the registry of the configuration factories
+ */
+ private CellAxisConfigurationRegistry() {
+ // to prevent instantiation
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ // final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_NAMESPACE, EXTENSION_POINT_NAME, EXTENSION_ID);
+ this.registry = new TreeMap<Integer, ICellAxisConfiguration>();
+ for (final IConfigurationElement iConfigurationElement : configElements) {
+ if (CONFIGURATION_EXT_NEW.equals(iConfigurationElement.getName())) {
+ // final String id = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
+ final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER_ATTRIBUTE));
+ try {
+ final ICellAxisConfiguration factory = (ICellAxisConfiguration) iConfigurationElement.createExecutableExtension(CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE);
+ // factory.initFactory(id);
+
+ if (factory != null) {
+ this.registry.put(order, factory);
+ }
+ } catch (final CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param configurationId
+ * the id of the factory
+ * @return
+ * the cellEditorFactory declared on this id or <code>null</code> if not found
+ *
+ *
+ */
+ public ICellAxisConfiguration getCellEditorConfiguration(final String configurationId) {
+ Assert.isNotNull(configurationId);
+ for (final Integer order : this.registry.keySet()) {
+ final ICellAxisConfiguration current = this.registry.get(order);
+ if (configurationId.equals(current.getConfigurationId())) {
+ return current;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * the table for which we are looking for a cell editor factory
+ * @param obj
+ * the object for which we are looking for a cell editor factory
+ * @return
+ * the first cell editor configuration factory which is able to manage this object
+ */
+ public ICellAxisConfiguration getFirstCellEditorConfiguration(final Table table, final Object obj) {
+ final List<ICellAxisConfiguration> configurations = getCellEditorConfigurationFactories(table, obj);
+ if (!configurations.isEmpty()) {
+ return configurations.get(0);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param table
+ * the table for which we are looking for a cell editor factory
+ * @param obj
+ * the object for which we are looking for a cell editor factory
+ * @return
+ * the list of the cell editor configuration which are able to manage this object
+ */
+ public List<ICellAxisConfiguration> getCellEditorConfigurationFactories(final Table table, final Object obj) {
+ final List<ICellAxisConfiguration> factories = new ArrayList<ICellAxisConfiguration>();
+ for (final ICellAxisConfiguration current : this.registry.values()) {
+ if (current.handles(table, obj)) {
+ factories.add(current);
+ }
+ }
+ return factories;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java
index f5ecd423ab4..4cfe0238275 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/CellEditorConfigurationFactory.java
@@ -42,6 +42,10 @@ public class CellEditorConfigurationFactory {
public static final CellEditorConfigurationFactory INSTANCE = new CellEditorConfigurationFactory();
+ public static final String EXTENSION_POINT_NAMESPACE = "org.eclipse.papyrus.infra.nattable.celleditor";
+
+ public static final String EXTENSION_POINT_NAME = "configuration";
+
/**
*
* Constructor.
@@ -49,20 +53,23 @@ public class CellEditorConfigurationFactory {
*/
private CellEditorConfigurationFactory() {
// to prevent instanciation
- final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ // final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_ID);
+ final IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_NAMESPACE, EXTENSION_POINT_NAME);
this.registry = new TreeMap<Integer, IAxisCellEditorConfiguration>();
for (final IConfigurationElement iConfigurationElement : configElements) {
- // final String id = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
- final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER_ATTRIBUTE));
- try {
- final IAxisCellEditorConfiguration factory = (IAxisCellEditorConfiguration) iConfigurationElement.createExecutableExtension(CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE);
- // factory.initFactory(id);
-
- if (factory != null) {
- this.registry.put(order, factory);
+ if (EXTENSION_POINT_NAME.equals(iConfigurationElement.getName())) {
+ // final String id = iConfigurationElement.getAttribute(FACTORY_ID_ATTRIBUTE);
+ final Integer order = new Integer(iConfigurationElement.getAttribute(ORDER_ATTRIBUTE));
+ try {
+ final IAxisCellEditorConfiguration factory = (IAxisCellEditorConfiguration) iConfigurationElement.createExecutableExtension(CELL_EDITOR_CONFIGURATION_CLASS_ATTRIBUTE);
+ // factory.initFactory(id);
+
+ if (factory != null) {
+ this.registry.put(order, factory);
+ }
+ } catch (final CoreException e) {
+ Activator.log.error(e);
}
- } catch (final CoreException e) {
- Activator.log.error(e);
}
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/ICellAxisConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/ICellAxisConfiguration.java
new file mode 100644
index 00000000000..362c2b086c3
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/celleditor/config/ICellAxisConfiguration.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * 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.celleditor.config;
+
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.papyrus.infra.nattable.configuration.IPapyrusNatTableConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+
+/**
+ * @author MA244259
+ *
+ */
+public interface ICellAxisConfiguration extends IPapyrusNatTableConfiguration{
+
+ /**
+ * @param table
+ * @param axisElement
+ * @return
+ */
+ boolean handles(Table table, Object axisElement);
+
+ /**
+ * @param configRegistry
+ * @param axis
+ * @param configLabel
+ */
+ void configureCellEditor(IConfigRegistry configRegistry, Object axis, String configLabel);
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java
index 86447d3cc7f..8694306ffe7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/EditConfiguration.java
@@ -17,6 +17,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
@@ -31,8 +34,10 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.accumulator.CustomRowOverrideLabelAccumulator;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.CellAxisConfigurationRegistry;
import org.eclipse.papyrus.infra.nattable.celleditor.config.CellEditorConfigurationFactory;
import org.eclipse.papyrus.infra.nattable.celleditor.config.IAxisCellEditorConfiguration;
+import org.eclipse.papyrus.infra.nattable.celleditor.config.ICellAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.layerstack.BodyLayerStack;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
@@ -91,17 +96,13 @@ public class EditConfiguration extends DefaultEditConfiguration {
// not yet supported
throw new UnsupportedOperationException(Messages.EditConfiguration_DeclarationNotYetSupported);
}
-
-
}
private void declaredCellEditors(final List<Object> elements, final IConfigRegistry configRegistry, final ColumnOverrideLabelAccumulator columnAccumulator, final CustomRowOverrideLabelAccumulator rowAccumulator) {
INattableModelManager modelManager = configRegistry.getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
boolean declareOnColumn = columnAccumulator != null;
boolean declareOnRow = rowAccumulator != null;
- assert declareOnColumn != declareOnRow;
- final CellEditorConfigurationFactory factory = CellEditorConfigurationFactory.INSTANCE;
- List<String> existingEditorIds = new ArrayList<String>();
+ Assert.isTrue(declareOnColumn != declareOnRow);
for (int i = 0; i < elements.size(); i++) {
// TODO : for containement feature : see oep.views.properties.
// example : create Usecase in a class from the property view : EcorePropertyEditorFactory create a popup to display available type
@@ -111,51 +112,91 @@ public class EditConfiguration extends DefaultEditConfiguration {
current = ((IAxis) current).getElement();
}
final Table table = modelManager.getTable();
- final IAxisCellEditorConfiguration config = factory.getFirstCellEditorConfiguration(table, current);
- if (config != null) {
- final ICellEditor editor = config.getICellEditor(table, current, modelManager.getTableAxisElementProvider());
- if (editor != null) {
- final String editorId = config.getEditorConfigId() + Integer.toString(i);
- if (existingEditorIds.contains(editorId)) {
- org.eclipse.papyrus.infra.nattable.Activator.log.warn("Several editor have the same id"); //$NON-NLS-1$
- } else {
- existingEditorIds.add(editorId);
- }
-
- final String cellId = editorId + "_cellId"; //$NON-NLS-1$
-
- final ICellPainter painter = config.getCellPainter(table, current);
- final String displayMode = config.getDisplayMode(table, current);
- final IDisplayConverter converter = config.getDisplayConvert(table, current, new EMFLabelProvider());// TODO : label provider
-
- final IDataValidator validator = config.getDataValidator(table, current);
- assert !cellId.equals(editorId);
- if (declareOnColumn) {
- columnAccumulator.registerColumnOverrides(i, editorId, cellId);
- } else {
- rowAccumulator.registerRowOverrides(i, editorId, cellId);
- }
- if (painter != null) {
- configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, displayMode, cellId);
- }
- configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, displayMode, editorId);
-
- if (converter != null) {
- configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, converter, displayMode, cellId);
- }
-
- if (validator != null) {
- configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, validator, displayMode, cellId);
- }
- } else {
- final String errorMessage = NLS.bind(Messages.EditConfiguration_FactoryHandlesElementButDoesntProvideEditor, config.getEditorConfigId(), current);
- if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
- Activator.log.warn(errorMessage);
- this.messagesAlreadyDisplayed.add(errorMessage);
- }
+ boolean configWithNewRegistry = configureWithNewFactory(table, configRegistry, current, i, declareOnColumn, columnAccumulator, rowAccumulator);
+ boolean configWithOldFactory = false;
+ if (!configWithNewRegistry) {
+ final String errorMessage = NLS.bind("You should use the new interface {0} to declare cell editor for {1}", ICellAxisConfiguration.class.getName(), current);
+ if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ Activator.log.warn(errorMessage);
+ this.messagesAlreadyDisplayed.add(errorMessage);
}
- } else {
+ configWithOldFactory = configureWithOldFactory(table, configRegistry, modelManager, current, i, declareOnColumn, columnAccumulator, rowAccumulator);
+ }
+ // // 1. Try to find configuration in the new factory --ceFactory-- of type CellEdConfigurationFactory. If found, then configure and continue()!
+ // final ICellAxisConfiguration ceConfig = ceFactory.getFirstCellEditorConfiguration(table, current);
+ // if (ceConfig != null) {
+ // if (existingEditorIds.contains(ceConfig.getConfigurationId())) {
+ // org.eclipse.papyrus.infra.nattable.Activator.log.warn("Several editor have the same id"); //$NON-NLS-1$
+ // } else {
+ // existingEditorIds.add(ceConfig.getConfigurationId());
+ // }
+ // // final ICellEditor editor = ceConfig.getICellEditor(table, current, modelManager.getTableAxisElementProvider());
+ // ceConfig.configureCellEditor(configRegistry, current, ceConfig.getConfigurationId());
+ // continue;// go to the next element
+ // } else {
+ // final String errorMessage = NLS.bind(Messages.EditConfiguration_FactoryHandlesElementButDoesntProvideEditor, ceFactory, current);
+ // if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ // Activator.log.warn(errorMessage);
+ // this.messagesAlreadyDisplayed.add(errorMessage);
+ // }
+ // }
+ //
+ // // 2. if the program does not find the configuration, it will continue using the old, (i.e., deprecated) factory --factory-- of type CellEditorConfigurationFactory
+ //
+ // final IAxisCellEditorConfiguration config = factory.getFirstCellEditorConfiguration(table, current);
+ // if (config != null) {
+ // final ICellEditor editor = config.getICellEditor(table, current, modelManager.getTableAxisElementProvider());
+ // if (editor != null) {
+ // final String editorId = config.getEditorConfigId() + Integer.toString(i);
+ // if (existingEditorIds.contains(editorId)) {
+ // org.eclipse.papyrus.infra.nattable.Activator.log.warn("Several editor have the same id"); //$NON-NLS-1$
+ // } else {
+ // existingEditorIds.add(editorId);
+ // }
+ //
+ // final String cellId = editorId + "_cellId"; //$NON-NLS-1$
+ //
+ // final ICellPainter painter = config.getCellPainter(table, current);
+ // final String displayMode = config.getDisplayMode(table, current);
+ // final IDisplayConverter converter = config.getDisplayConvert(table, current, new EMFLabelProvider());// TODO : label provider
+ //
+ // final IDataValidator validator = config.getDataValidator(table, current);
+ // assert !cellId.equals(editorId);
+ // if (declareOnColumn) {
+ // columnAccumulator.registerColumnOverrides(i, editorId, cellId);
+ // } else {
+ // rowAccumulator.registerRowOverrides(i, editorId, cellId);
+ // }
+ // if (painter != null) {
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, displayMode, cellId);
+ // }
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, displayMode, editorId);
+ //
+ // if (converter != null) {
+ // configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, converter, displayMode, cellId);
+ // }
+ //
+ // if (validator != null) {
+ // configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, validator, displayMode, cellId);
+ // }
+ // } else {
+ // final String errorMessage = NLS.bind(Messages.EditConfiguration_FactoryHandlesElementButDoesntProvideEditor, config.getEditorConfigId(), current);
+ // if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ // Activator.log.warn(errorMessage);
+ // this.messagesAlreadyDisplayed.add(errorMessage);
+ // }
+ //
+ // }
+ // } else {
+ // final String errorMessage = NLS.bind(Messages.EditConfiguration_ConfigurationNotFound, current);
+ // if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
+ // Activator.log.warn(errorMessage);
+ // this.messagesAlreadyDisplayed.add(errorMessage);
+ // }
+ // }
+
+ if (!configWithNewRegistry && !configWithOldFactory) {
final String errorMessage = NLS.bind(Messages.EditConfiguration_ConfigurationNotFound, current);
if (!this.messagesAlreadyDisplayed.contains(errorMessage)) {
Activator.log.warn(errorMessage);
@@ -165,4 +206,70 @@ public class EditConfiguration extends DefaultEditConfiguration {
}
}
+
+ /**
+ * @param table
+ * @param configRegistry
+ * @param current
+ * @return
+ */
+ private boolean configureWithOldFactory(Table table, IConfigRegistry configRegistry, INattableModelManager modelManager, Object current, int indexOfTheAxis, boolean declareOnColumn, final ColumnOverrideLabelAccumulator columnAccumulator,
+ final CustomRowOverrideLabelAccumulator rowAccumulator) {
+ final CellEditorConfigurationFactory factory = CellEditorConfigurationFactory.INSTANCE; // this factory was used until Papyrus Luna. Better use CellEdConfigurationFactory
+
+ final IAxisCellEditorConfiguration config = factory.getFirstCellEditorConfiguration(table, current);
+
+ final ICellEditor editor = config.getICellEditor(table, current, modelManager.getTableAxisElementProvider());
+ if (editor != null) {
+ final String editorId = config.getEditorConfigId() + Integer.toString(indexOfTheAxis);
+ final String cellId = editorId + "_cellId"; //$NON-NLS-1$
+
+ final ICellPainter painter = config.getCellPainter(table, current);
+ final String displayMode = config.getDisplayMode(table, current);
+ final IDisplayConverter converter = config.getDisplayConvert(table, current, new EMFLabelProvider());// TODO : label provider
+
+ final IDataValidator validator = config.getDataValidator(table, current);
+ if (declareOnColumn) {
+ columnAccumulator.registerColumnOverrides(indexOfTheAxis, editorId, cellId);
+ } else {
+ rowAccumulator.registerRowOverrides(indexOfTheAxis, editorId, cellId);
+ }
+ if (painter != null) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, displayMode, cellId);
+ }
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, editor, displayMode, editorId);
+
+ if (converter != null) {
+ configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, converter, displayMode, cellId);
+ }
+
+ if (validator != null) {
+ configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, validator, displayMode, cellId);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ protected final boolean configureWithNewFactory(Table table, IConfigRegistry configRegistry, Object current, int indexOfTheAxis, boolean declareOnColumn, final ColumnOverrideLabelAccumulator columnAccumulator,
+ final CustomRowOverrideLabelAccumulator rowAccumulator) {
+ final CellAxisConfigurationRegistry ceFactory = CellAxisConfigurationRegistry.INSTANCE;
+ final ICellAxisConfiguration ceConfig = ceFactory.getFirstCellEditorConfiguration(table, current);
+
+
+ if (ceConfig != null) {
+ final String editorId = ceConfig.getConfigurationId() + Integer.toString(indexOfTheAxis);
+ final String cellId = editorId + "_cellId"; //$NON-NLS-1$
+ ceConfig.configureCellEditor(configRegistry, current, cellId);
+ if (declareOnColumn) {
+ columnAccumulator.registerColumnOverrides(indexOfTheAxis, editorId, cellId);
+ } else {
+ rowAccumulator.registerRowOverrides(indexOfTheAxis, editorId, cellId);
+ }
+ return true;
+ }
+ return false;
+ }
+
+
}

Back to the top