/**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emfforms.spi.spreadsheet.core.converter.EMFFormsSpreadsheetValueConverter#setCellValue(org.apache.poi.ss.usermodel.Cell,
  *     java.lang.Object, org.eclipse.emf.ecore.EStructuralFeature,
  *     org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
  */
 @Override
 public void setCellValue(
     Cell cell,
     Object fromObject,
     EStructuralFeature eStructuralFeature,
     ViewModelContext viewModelContext)
     throws EMFFormsConverterException {
   final EDataType eDataType = EAttribute.class.cast(eStructuralFeature).getEAttributeType();
   final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance();
   final StringBuilder result = new StringBuilder();
   for (final Object value : (List<?>) fromObject) {
     if (result.length() != 0) {
       result.append(SEPARATOR);
     }
     result.append(eFactory.convertToString(eDataType, value));
   }
   String valueString = result.toString();
   if (isDecimalNumber(eDataType.getInstanceClass())) {
     valueString =
         valueString.replace(
             '.',
             DecimalFormatSymbols.getInstance(localeProvider.getLocale()).getDecimalSeparator());
   }
   cell.setCellValue(valueString);
   cell.setCellStyle(
       (CellStyle) viewModelContext.getContextValue(EMFFormsCellStyleConstants.TEXT));
 }
Ejemplo n.º 2
0
 /**
  * Get the value of the named AD parameter for the activity as a string. Works with several types,
  * not just strings -- enums, for example.
  *
  * @param element
  * @param parameterName
  * @return null if the parameter is not found
  */
 public static String getParameterString(EPlanElement element, String parameterName) {
   EObject data = element.getData();
   if (data == null) return null;
   EStructuralFeature feature;
   try {
     feature = getParameterFeature(data, parameterName);
   } catch (UndefinedParameterException e) {
     return null;
   }
   Object object = data.eGet(feature);
   if (object instanceof EEnumLiteral) {
     EEnumLiteral literal = (EEnumLiteral) object;
     return literal.getName();
   }
   EClassifier type = feature.getEType();
   if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     String string = factory.convertToString(dataType, object);
     return string;
   }
   LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
   return String.valueOf(object);
 }
 @Override
 public String convertToString(EDataType eDataType, Object instanceValue) {
   // TODO Auto-generated method stub
   return delegate.convertToString(eDataType, instanceValue);
 }