535656: [Table] Cell containing multiple values are not displayed
correctly in generated document

Update PapyrusService.getGendocTable method to build differently a table
cell label when the cell contains a collection : instead of displaying a
label of the collection, display a collection of label

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=535656

Change-Id: I7f558e4bfc47ba4d0f59382e4e82b95a14a70be4
Signed-off-by: ANNE HAUGOMMARD <anne.haugommard@atos.net>
diff --git a/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus/src/org/eclipse/gendoc/bundle/acceleo/papyrus/service/PapyrusServices.java b/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus/src/org/eclipse/gendoc/bundle/acceleo/papyrus/service/PapyrusServices.java
index c8b4a08..5f8e6db 100644
--- a/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus/src/org/eclipse/gendoc/bundle/acceleo/papyrus/service/PapyrusServices.java
+++ b/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus/src/org/eclipse/gendoc/bundle/acceleo/papyrus/service/PapyrusServices.java
@@ -12,6 +12,7 @@
  *  Anne Haugommard (Atos) anne.haugommard@atos.net - Remove references to Papyrus Documentation services
  *  Mohamed Ali Bach Tobji (Atos) mohamed-ali.bachtobji@atos.net - fix bug #515404 : add getPapyrusTables method
  *  Antonio Campesino Robles (Ericsson) - Support for Tree tables, Bug 531275 
+ *  Anne Haugommard (Atos for PlasticOmnium ) - Fix bug #535656 for table cells containing collections
  *****************************************************************************/
 package org.eclipse.gendoc.bundle.acceleo.papyrus.service;
 
@@ -441,12 +442,7 @@
 			for (int columnPosition = 0; columnPosition < nattableModelManager.getColumnCount(); columnPosition++) {
 				org.eclipse.gendoc.table.Cell cell = TableFactory.eINSTANCE.createCell();
 			   	Object value = nattableModelManager.getDataValue(columnPosition, rowPosition);
-				LabelProviderCellContextElementWrapper contextElement = new LabelProviderCellContextElementWrapper();
-				contextElement.setObject(value);
-				contextElement.setConfigRegistry(configRegistry);
-				ILabelProvider bodylabelProvider = serv.getLabelProvider(Constants.TABLE_LABEL_PROVIDER_CONTEXT, contextElement);
-				contextElement.setCell(layer);
-				String label = bodylabelProvider.getText(value); 
+				String label = getCellLabel(configRegistry, serv, layer, value); 
 				cell.setLabel(label);
 				isEmpty = isEmpty && label.isEmpty();
 				row.getCells().add(cell);
@@ -460,6 +456,34 @@
 		return gendocTable;
 	}
 
+	// Fix bug #535656 : Display cell label as a collection of labels instead of a label of collections
+	private String getCellLabel(ConfigRegistry configRegistry, LabelProviderService serv, ILayerCell layer,
+			Object value) {
+		String label ="";
+		String COLLECTION_SEPARATOR = "\n";
+		if (value == null) {
+			// Return ""
+		}
+		else if (value instanceof Collection) {
+			/** Compute all labels and separate by <code>COLLECTION_SEPARATOR</code> */
+			List<String> labels = new LinkedList<String>();
+			for (Object collectionElement : (Collection)value) {
+				labels.add(getCellLabel(configRegistry,serv,layer,collectionElement));
+			}
+			return String.join(COLLECTION_SEPARATOR, labels);
+			
+		} else {
+			LabelProviderCellContextElementWrapper contextElement = new LabelProviderCellContextElementWrapper();
+			contextElement.setObject(value);
+			contextElement.setConfigRegistry(configRegistry);
+			ILabelProvider bodylabelProvider = serv.getLabelProvider(Constants.TABLE_LABEL_PROVIDER_CONTEXT,
+					contextElement);
+			contextElement.setCell(layer);
+			label = bodylabelProvider.getText(value);
+		}
+		return label;
+	}
+
 	/**
 	 * Get a label of Papyrus table axis  
 	 * @param nattableModelManager