diff options
author | Nicolas FAUVERGUE | 2015-01-21 15:51:14 +0000 |
---|---|---|
committer | vincent lorenzo | 2015-01-22 12:18:18 +0000 |
commit | 8afa3c0634f001e24ece06cb045189ab2ccfc036 (patch) | |
tree | 9b963b8a466b25f21897f2440189e374da2996ee | |
parent | 26260ea6d4a8a3e8be9d0af276fc4c26a4bae482 (diff) | |
download | org.eclipse.papyrus-8afa3c0634f001e24ece06cb045189ab2ccfc036.tar.gz org.eclipse.papyrus-8afa3c0634f001e24ece06cb045189ab2ccfc036.tar.xz org.eclipse.papyrus-8afa3c0634f001e24ece06cb045189ab2ccfc036.zip |
455783: [Table] Editing problem for real numbers
https://bugs.eclipse.org/bugs/show_bug.cgi?id=455783
Change-Id: Id16969575d5f0f8bcbd3639f619ebc16e7cf8264
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
(cherry picked from commit 21b102ec75ddb2288dc1b32ae5aa2d5250f16d96)
2 files changed, 66 insertions, 42 deletions
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java index cca150afe35..2ed4577eafa 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/config/UMLFeatureCellEditorConfig.java @@ -9,10 +9,15 @@ * Contributors: * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation * Christian W. Damus (CEA) - bug 402525 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 455783 * *****************************************************************************/ package org.eclipse.papyrus.uml.nattable.config; +import static org.eclipse.nebula.widgets.nattable.util.ObjectUtils.isNotNull; + +import java.math.BigDecimal; + import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; @@ -427,7 +432,25 @@ public class UMLFeatureCellEditorConfig extends EStructuralFeatureEditorConfig { IDisplayConverter converter = null; switch (editorKind) { case SINGLE_REAL: - converter = new DefaultDoubleDisplayConverter(); + converter = new DefaultDoubleDisplayConverter(){ + + @Override + public Object canonicalToDisplayValue(Object canonicalValue) { + // Bug 455783 : + // Redefine this method to manage the display of double number with dot and not with comma + if (isNotNull(canonicalValue)) { + return canonicalValue; + } + return null; + } + + @Override + protected Object convertToNumericValue(String value) { + // Bug 455783 : + // Redefine this method to manage the conversion to double value with the dot and not the comma + return new BigDecimal(value).doubleValue(); + } + }; break; case SINGLE_UML_REFERENCE: converter = new DisplayConverter() { diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/validator/RealDataValidator.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/validator/RealDataValidator.java index 074fbd0076d..dfc8b3b2dbf 100644 --- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/validator/RealDataValidator.java +++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/validator/RealDataValidator.java @@ -1,41 +1,42 @@ -/*****************************************************************************
- * Copyright (c) 2012 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.uml.nattable.validator;
-
-import org.eclipse.nebula.widgets.nattable.data.validate.DataValidator;
-import org.eclipse.papyrus.infra.widgets.validator.RealInputValidator;
-
-/**
- *
- * Validator for Real values
- *
- */
-public class RealDataValidator extends DataValidator {
-
- /**
- *
- * @see org.eclipse.nebula.widgets.nattable.data.validate.DataValidator#validate(int, int, java.lang.Object)
- *
- * @param columnIndex
- * @param rowIndex
- * @param newValue
- * @return
- */
- @Override
- public boolean validate(int columnIndex, int rowIndex, Object newValue) {
- final RealInputValidator validator = new RealInputValidator();
- return validator.isValid(newValue.toString()) == null;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2012 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 + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 455783 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.nattable.validator; + +import org.eclipse.nebula.widgets.nattable.data.validate.DataValidator; +import org.eclipse.papyrus.infra.widgets.validator.RealInputValidator; + +/** + * + * Validator for Real values + * + */ +public class RealDataValidator extends DataValidator { + + /** + * + * @see org.eclipse.nebula.widgets.nattable.data.validate.DataValidator#validate(int, int, java.lang.Object) + * + * @param columnIndex + * @param rowIndex + * @param newValue + * @return + */ + @Override + public boolean validate(int columnIndex, int rowIndex, Object newValue) { + final RealInputValidator validator = new RealInputValidator(); + return newValue != null ? validator.isValid(newValue.toString()) == null : false; + } + +} |