Improved visualisation of artifacts in views by removing line breaks

This patch fixes several issues with artifact names that contain line.
Line breaks caused problems in some of the visualisations such as the PlantUML
view. This patch fixes this issue by removing line breaks in three different
places:
 * the ArtifactHelper.getArtifactLabel() method, used, e.g., by the matrix view;
 * the Connections.getLabel() and Connections.getOriginLabel() methods which are
used by the PlantUML view; and
 * the OfficeHandler.getDisplayName() methods which fixes issues in the OfficeView.

Change-Id: I884271ebcd8d34533445e6ee15833eda2d684709
diff --git a/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/ArtifactHelper.java b/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/ArtifactHelper.java
index 8fd8c96..8706105 100644
--- a/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/ArtifactHelper.java
+++ b/bundles/org.eclipse.capra.core/src/org/eclipse/capra/core/helpers/ArtifactHelper.java
@@ -27,7 +27,8 @@
 
 public class ArtifactHelper {
 
-	private static final String CHARACTERS_TO_BE_REMOVED = "[\", \']";
+	private static final String QUOTE_CHARACTERS = "[\"\']";
+	private static final String NEWLINE_CHARACTERS = "[\r\n]+";
 
 	private EObject artifactModel;
 
@@ -44,6 +45,10 @@
 	// IArtifactHandler<?>.
 	private static Collection<? extends IArtifactHandler<?>> handlers = ExtensionPointHelper.getArtifactHandlers();
 
+	private String sanitize(String input) {
+		return input.replaceAll(QUOTE_CHARACTERS, " ").replaceAll(NEWLINE_CHARACTERS, " ");
+	}
+
 	/**
 	 * @param artifactModel
 	 */
@@ -147,7 +152,7 @@
 		}
 		// remove unwanted characters like ", '
 		if (artifactLabel != null) {
-			return artifactLabel.replaceAll(CHARACTERS_TO_BE_REMOVED, " ");
+			return sanitize(artifactLabel);
 		} else {
 			// This can happen if the trace model contains elements for which
 			// the artifact handler is not available.
diff --git a/bundles/org.eclipse.capra.handler.office/src/org/eclipse/capra/handler/office/OfficeHandler.java b/bundles/org.eclipse.capra.handler.office/src/org/eclipse/capra/handler/office/OfficeHandler.java
index e3ee3bf..e8366a5 100644
--- a/bundles/org.eclipse.capra.handler.office/src/org/eclipse/capra/handler/office/OfficeHandler.java
+++ b/bundles/org.eclipse.capra.handler.office/src/org/eclipse/capra/handler/office/OfficeHandler.java
@@ -40,7 +40,7 @@
 		// an EObject, or if it is Adaptable to an EObject
 		ArtifactMetaModelAdapter adapter = ExtensionPointHelper.getArtifactWrapperMetaModelAdapter().get();
 		EObject wrapper = adapter.createArtifact(artifactModel, this.getClass().getName(), officeObject.getUri(),
-				officeObject.getData(), officeObject.getUri());
+				this.getDisplayName(officeObject), officeObject.getUri());
 		return wrapper;
 	}
 
@@ -56,13 +56,14 @@
 
 	@Override
 	public String getDisplayName(CapraOfficeObject officeObject) {
-		int minAllowed = Activator.getDefault().getPreferenceStore()
-				.getInt(OfficePreferences.CHAR_COUNT);
+		int minAllowed = Activator.getDefault().getPreferenceStore().getInt(OfficePreferences.CHAR_COUNT);
 		String text = officeObject.toString();
 		int textLength = Math.min(text.length(), minAllowed);
 		if (textLength == minAllowed) {
 			text = text.substring(0, textLength) + "...";
 		}
+		// Remove new lines
+		text = text.replaceAll("\\R+", " ");
 		return text;
 	}
 
diff --git a/bundles/org.eclipse.capra.ui.plantuml/src/org/eclipse/capra/ui/plantuml/Connections.java b/bundles/org.eclipse.capra.ui.plantuml/src/org/eclipse/capra/ui/plantuml/Connections.java
index 6d5f273..4b501bf 100644
--- a/bundles/org.eclipse.capra.ui.plantuml/src/org/eclipse/capra/ui/plantuml/Connections.java
+++ b/bundles/org.eclipse.capra.ui.plantuml/src/org/eclipse/capra/ui/plantuml/Connections.java
@@ -34,11 +34,12 @@
  * Helper class for generating PlantUML diagrams from a collection of
  * {@link Connection}
  *
- * @author Anthony Anjorin, Salome Maro
+ * @author Anthony Anjorin, Salome Maro, Jan-Philipp Steghöfer
  */
 public class Connections {
 
-	private static final String CHARACTERS_TO_BE_REMOVED = "[\", \']";
+	private static final String QUOTE_CHARACTERS = "[\"\']";
+	private static final String NEWLINE_CHARACTERS = "[\r\n]+";
 	private List<Connection> connections;
 	private EObject origin;
 
@@ -48,7 +49,11 @@
 	private Map<String, String> id2Location;
 
 	private ArtifactHelper artifactHelper;
-	
+
+	private String sanitize(String input) {
+		return input.replaceAll(QUOTE_CHARACTERS, " ").replaceAll(NEWLINE_CHARACTERS, " ");
+	}
+
 	Connections(List<Connection> connections, List<EObject> selectedObjects, EObject artifactModel) {
 		this.artifactHelper = new ArtifactHelper(artifactModel);
 		this.connections = connections;
@@ -78,7 +83,7 @@
 	}
 
 	public String originLabel() {
-		return id2Label.get(object2Id.get(origin));
+		return sanitize(id2Label.get(object2Id.get(origin)));
 	}
 
 	public String originLocation() {
@@ -101,7 +106,7 @@
 	}
 
 	public String label(String id) {
-		return id2Label.get(id);
+		return sanitize(id2Label.get(id));
 	}
 
 	public String location(String id) {