فهرست منبع

Fixed Issue 87: [SCTCompare] Linebreak is not correctly shown in compare view

Andreas Mülder 10 سال پیش
والد
کامیت
65334c6dd8

+ 2 - 1
plugins/org.yakindu.sct.compare/META-INF/MANIFEST.MF

@@ -16,7 +16,8 @@ Require-Bundle: org.eclipse.ui,
  com.google.guava;bundle-version="10.0.1",
  org.eclipse.gmf.runtime.notation;bundle-version="1.7.0",
  org.yakindu.sct.model.sgraph;bundle-version="2.1.1",
- org.eclipse.emf.compare.diagram
+ org.eclipse.emf.compare.diagram,
+ org.eclipse.emf.compare.edit;bundle-version="4.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: statecharts.org

+ 9 - 0
plugins/org.yakindu.sct.compare/plugin.xml

@@ -25,4 +25,13 @@
          </nsURI>
       </processor>
    </extension>
+  <extension
+         point="org.eclipse.emf.compare.edit.adapterFactory">
+      <factory
+            class="org.yakindu.sct.compare.labelprovider.SCTCompareAdapterFactory"
+              supportedTypes="org.eclipse.emf.edit.provider.IItemLabelProvider"
+            ranking="11"
+            uri="http://www.eclipse.org/emf/compare">
+      </factory>
+</extension>
 </plugin>

+ 38 - 0
plugins/org.yakindu.sct.compare/src/org/yakindu/sct/compare/labelprovider/SCTCompareAdapterFactory.java

@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2015 committers of YAKINDU and others.
+ * 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.compare.labelprovider;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.compare.AttributeChange;
+import org.eclipse.emf.compare.provider.spec.AttributeChangeItemProviderSpec;
+import org.eclipse.emf.compare.provider.spec.CompareItemProviderAdapterFactorySpec;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class SCTCompareAdapterFactory extends CompareItemProviderAdapterFactorySpec {
+	@Override
+	public Adapter createAttributeChangeAdapter() {
+		return new AttributeChangeItemProviderSpec(this) {
+			@Override
+			protected String getValueText(AttributeChange attChange) {
+				String result = super.getValueText(attChange);
+				return removeLineFeed(result);
+			}
+
+			protected String removeLineFeed(String string) {
+				return string.replaceAll("[\\t\\n\\r]", " ").replaceAll("\\s+", " ");
+			}
+		};
+	}
+}