diff options
3 files changed, 21 insertions, 10 deletions
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 8fd8c96b..8706105b 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 @@ import org.eclipse.emf.ecore.util.EcoreUtil; 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 @@ public class ArtifactHelper { // 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 @@ public class ArtifactHelper { } // 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 e3ee3bf3..e8366a5b 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 @@ public class OfficeHandler extends AbstractArtifactHandler<CapraOfficeObject> { // 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 @@ public class OfficeHandler extends AbstractArtifactHandler<CapraOfficeObject> { @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 6d5f273f..4b501bfb 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 @@ import com.google.common.base.Strings; * 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 @@ public class Connections { 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 class Connections { } public String originLabel() { - return id2Label.get(object2Id.get(origin)); + return sanitize(id2Label.get(object2Id.get(origin))); } public String originLocation() { @@ -101,7 +106,7 @@ public class Connections { } public String label(String id) { - return id2Label.get(id); + return sanitize(id2Label.get(id)); } public String location(String id) { |