diff options
author | Vincent Lorenzo | 2015-10-30 13:44:59 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2015-10-31 18:26:48 +0000 |
commit | 0df497a6917d06c8eab5333d08c756899a60cf4b (patch) | |
tree | 98261616ddfc7c76093f98d25d10da08dc5cd4db /plugins | |
parent | e0cf99f584a68ef90f744b224f116adaaeab661e (diff) | |
download | org.eclipse.papyrus-0df497a6917d06c8eab5333d08c756899a60cf4b.tar.gz org.eclipse.papyrus-0df497a6917d06c8eab5333d08c756899a60cf4b.tar.xz org.eclipse.papyrus-0df497a6917d06c8eab5333d08c756899a60cf4b.zip |
bug 459647: [Table 2] The cell editor configuration files must be splitted
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins')
8 files changed, 250 insertions, 26 deletions
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 index cf7e1640afb..8959aa558e7 100644 --- 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 @@ -37,7 +37,7 @@ public class SingleBooleanCellEditorConfiguration implements ICellAxisConfigurat /**
* the id of this editor
*/
- private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleBooleanCellEditorConfiguration.CheckBox";//$NON-NLS-1$
+ 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()
@@ -71,10 +71,12 @@ public class SingleBooleanCellEditorConfiguration implements ICellAxisConfigurat 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());
+ if (!feature.isMany()) {
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+ return TypesConstants.BOOLEAN.equals(datatype.getName());
+ }
}
}
return false;
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 index f682b19bc7b..a904b149d82 100644 --- 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 @@ -39,7 +39,7 @@ public class SingleEEnumTypeCellEditorConfiguration implements ICellAxisConfigur /**
* the id of this editor
*/
- private static final String ID = "org.eclipse.papyrus.infra.emf.nattable.celleditor.configuration.SingleEEnumTypeCellEditorConfiguration.ComboBox";//$NON-NLS-1$
+ 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()
@@ -67,14 +67,17 @@ public class SingleEEnumTypeCellEditorConfiguration implements ICellAxisConfigur * @param table
* @param axisElement
* @return
- * <code>true</code> if axisElement is a {@link EEnum} {@link EStructuralFeature}
+ * <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;
+ EStructuralFeature feature = (EStructuralFeature) representedElement;
+ if (!feature.isMany()) {
+ EClassifier eType = feature.getEType();
+ return eType instanceof EEnum;
+ }
}
return false;
}
@@ -89,7 +92,7 @@ public class SingleEEnumTypeCellEditorConfiguration implements ICellAxisConfigur @Override
public void configureCellEditor(final IConfigRegistry configRegistry, Object axis, String configLabel) {
Object representedElement = AxisUtils.getRepresentedElement(axis);
- EEnum eenum =(EEnum)((EStructuralFeature) representedElement).getEType();
+ EEnum eenum = (EEnum) ((EStructuralFeature) representedElement).getEType();
IDisplayConverter displayConverter = new DisplayConverter() {
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 index ea0a025c8b2..abf75fe4cd0 100644 --- 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 @@ -32,12 +32,12 @@ import org.eclipse.papyrus.infra.tools.util.TypesConstants; * @author MA244259
*
*/
-public class SingleIntegerCellEditorConfiguration implements ICellAxisConfiguration{
+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$
+ 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()
@@ -58,7 +58,7 @@ public class SingleIntegerCellEditorConfiguration implements ICellAxisConfigurat 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)
*
@@ -71,10 +71,12 @@ public class SingleIntegerCellEditorConfiguration implements ICellAxisConfigurat 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());
+ if (!feature.isMany()) {
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+ return TypesConstants.INTEGER.equals(datatype.getName());
+ }
}
}
return false;
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 index b8fb2a6b080..9086799d37d 100644 --- 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 @@ -32,12 +32,12 @@ import org.eclipse.papyrus.infra.tools.util.TypesConstants; * @author MA244259
*
*/
-public class SingleStringCellEditorConfiguration implements ICellAxisConfiguration{
+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$
+ 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()
@@ -58,7 +58,7 @@ public class SingleStringCellEditorConfiguration implements ICellAxisConfigurati 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)
*
@@ -71,10 +71,12 @@ public class SingleStringCellEditorConfiguration implements ICellAxisConfigurati 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());
+ if (!feature.isMany()) {
+ EClassifier etype = feature.getEType();
+ if (etype instanceof EDataType) {
+ EDataType datatype = (EDataType) etype;
+ return TypesConstants.STRING.equals(datatype.getName());
+ }
}
}
return false;
@@ -91,7 +93,7 @@ public class SingleStringCellEditorConfiguration implements ICellAxisConfigurati 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);
+ // 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/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml index 2d3f0ffe010..69c20bbcec5 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/plugin.xml @@ -15,6 +15,18 @@ class="org.eclipse.papyrus.uml.nattable.config.UMLMultiReferenceTextualCellEditorWithButtonConfiguration" order="401"> </configuration> + <cellAxisConfiguration + class="org.eclipse.papyrus.uml.nattable.config.UMLStereotypeSingleBooleanCellEditorConfiguration" + order="410"> + </cellAxisConfiguration> + <cellAxisConfiguration + class="org.eclipse.papyrus.uml.nattable.config.UMLStereotypeSingleIntegerCellEditorConfiguration" + order="420"> + </cellAxisConfiguration> + <cellAxisConfiguration + class="org.eclipse.papyrus.uml.nattable.config.UMLStereotypeSingleStringCellEditorConfiguration" + order="430"> + </cellAxisConfiguration> </extension> <extension point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider"> diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleBooleanCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleBooleanCellEditorConfiguration.java new file mode 100644 index 00000000000..63fb8bf4858 --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleBooleanCellEditorConfiguration.java @@ -0,0 +1,67 @@ +/***************************************************************************** + * 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.uml.nattable.config; + +import org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleBooleanCellEditorConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; +import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils; +import org.eclipse.papyrus.uml.tools.utils.PrimitivesTypesUtils; +import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Type; + +/** + * @author VL222926 + * + */ +public class UMLStereotypeSingleBooleanCellEditorConfiguration extends SingleBooleanCellEditorConfiguration { + + /** + * the id of this editor + */ + private static final String ID = "org.eclipse.papyrus.uml.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.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration#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) { + final String id = AxisUtils.getPropertyId(axisElement); + if (id != null && id.startsWith(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX)) { + Property prop = UMLTableUtils.getRealStereotypeProperty(table.getContext(), id); + if (prop != null && !prop.isMultivalued()) { + Type type = prop.getType(); + if (type instanceof DataType) { + final String name = type.getName(); + return PrimitivesTypesUtils.UML_BOOLEAN.equals(name); + } + } + } + return false; + } +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleIntegerCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleIntegerCellEditorConfiguration.java new file mode 100644 index 00000000000..9456d0f6a70 --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleIntegerCellEditorConfiguration.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * 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.uml.nattable.config; + +import org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleIntegerCellEditorConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; +import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils; +import org.eclipse.papyrus.uml.tools.utils.PrimitivesTypesUtils; +import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Type; + +/** + * @author VL222926 + * + */ +public class UMLStereotypeSingleIntegerCellEditorConfiguration extends SingleIntegerCellEditorConfiguration { + + /** + * the id of this editor + */ + private static final String ID = "org.eclipse.papyrus.uml.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.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration#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) { + final String id = AxisUtils.getPropertyId(axisElement); + if (id != null && id.startsWith(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX)) { + Property prop = UMLTableUtils.getRealStereotypeProperty(table.getContext(), id); + if (prop != null && !prop.isMultivalued()) { + Type type = prop.getType(); + if (type instanceof DataType) { + final String name = type.getName(); + return PrimitivesTypesUtils.UML_INTEGER.equals(name); + } + } + } + return false; + } +} diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleStringCellEditorConfiguration.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleStringCellEditorConfiguration.java new file mode 100644 index 00000000000..f8453d3090f --- /dev/null +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLStereotypeSingleStringCellEditorConfiguration.java @@ -0,0 +1,68 @@ +/***************************************************************************** + * 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.uml.nattable.config; + +import org.eclipse.papyrus.infra.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; +import org.eclipse.papyrus.uml.nattable.utils.UMLTableUtils; +import org.eclipse.papyrus.uml.tools.utils.PrimitivesTypesUtils; +import org.eclipse.uml2.uml.DataType; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.Type; + +/** + * @author VL222926 + * + */ +public class UMLStereotypeSingleStringCellEditorConfiguration extends SingleStringCellEditorConfiguration { + + /** + * the id of this editor + */ + private static final String ID = "org.eclipse.papyrus.uml.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.emf.nattable.celleditor.config.SingleStringCellEditorConfiguration#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) { + final String id = AxisUtils.getPropertyId(axisElement); + if (id != null && id.startsWith(UMLTableUtils.PROPERTY_OF_STEREOTYPE_PREFIX)) { + Property prop = UMLTableUtils.getRealStereotypeProperty(table.getContext(), id); + if (prop != null && !prop.isMultivalued()) { + Type type = prop.getType(); + if (type instanceof DataType) { + final String name = type.getName(); + return PrimitivesTypesUtils.UML_STRING.equals(name); + } + } + } + return false; + } +} |