Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornhauge2011-09-06 20:02:37 +0000
committernhauge2011-09-06 20:02:37 +0000
commit177c0ce9a362909bad69ec017ac7727b8568a2db (patch)
treeed5f735b5238dbf4e9123020a32a3730878bb0ba
parentc7b6768457818d5e97d94375451b98a3aee7c428 (diff)
downloadwebtools.dali-177c0ce9a362909bad69ec017ac7727b8568a2db.tar.gz
webtools.dali-177c0ce9a362909bad69ec017ac7727b8568a2db.tar.xz
webtools.dali-177c0ce9a362909bad69ec017ac7727b8568a2db.zip
[356331] - Patch from Stefan, see bug for details.
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java15
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java3
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java28
6 files changed, 43 insertions, 9 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
index f296c865e8..90d4002feb 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
@@ -420,7 +420,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
headerTextString = JPAEditorUtil.returnSimpleName(headerTextString);
try {
if (cu.hasUnsavedChanges()) {
- headerTextString = "* " + headerTextString; //$NON-NLS-1$
+ headerTextString = JPAEditorConstants.HEADER_PREFIX_DIRTY + headerTextString;
}
} catch (JavaModelException e) {
JPADiagramEditorPlugin.logError("Cannot check compilation unit for unsaved changes", e); //$NON-NLS-1$
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
index a16a1d6f45..dbd7c252f4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
@@ -185,7 +185,7 @@ public class GraphicsUpdater {
if (ga == null)
return;
final Text txt = (Text)ga.getGraphicsAlgorithmChildren().get(0);
- if (!txt.getValue().equals(newHeader)) {
+ if (!JPAEditorUtil.areHeadersEqual(txt.getValue(), newHeader)) {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(txt);
RecordingCommand rc = new RecordingCommand(ted) {
protected void doExecute() {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
index 600b0072e0..52e14edfd1 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
@@ -25,6 +25,8 @@ import org.eclipse.jpt.jpa.core.MappingKeys;
public class JPAEditorConstants {
+ public static final String HEADER_PREFIX_DIRTY = "* "; //$NON-NLS-1$
+
public static Hashtable<String, String> PRIMITIVE_TO_WRAPPER = new Hashtable<String,String>();
public static HashSet<String> WRAPPER_SIMPLE_NAMES = new HashSet<String>();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
index 3dc6702c4c..b39be13e2b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
@@ -1470,5 +1470,20 @@ public class JPAEditorUtil {
return isAdded;
}
+ public static String cutOffStringPrefix(String s, String prefix) {
+ if (s.startsWith(prefix))
+ return s.substring(prefix.length());
+ return s;
+ }
+
+ public static String cutOffHeaderDirtyPrefix(String header) {
+ return cutOffStringPrefix(header, JPAEditorConstants.HEADER_PREFIX_DIRTY);
+ }
+
+ public static boolean areHeadersEqual(String h1, String h2) {
+ h1 = cutOffHeaderDirtyPrefix(h1);
+ h2 = cutOffHeaderDirtyPrefix(h2);
+ return h1.equals(h2);
+ }
} \ No newline at end of file
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java
index 2ec73c6736..779e2d6388 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java
@@ -30,6 +30,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.modelintegration.util.
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.preferences.JPAEditorPreferenceInitializerTest;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.preferences.JPAEditorPreferencesPageTest;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.provider.JPAEditorToolBehaviorProviderTest;
+import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.JPAEditorUtilTest;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.JPASolverTest;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@@ -55,7 +56,7 @@ import org.junit.runners.Suite.SuiteClasses;
DirectEditAttributeFeatureTest.class,
EditorTest.class,
JPAEditorToolBehaviorProviderTest.class,
-// JPAEditorUtilTest.class,
+ JPAEditorUtilTest.class,
JPASolverTest.class,
// OpenMiniatureViewFeatureTest.class,
// RefactorAttributeTypeFeatureTest.class,
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
index 2432c59650..5ebd271e76 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
@@ -156,7 +156,7 @@ public class JPAEditorUtilTest {
assertEquals("fdsjfjslkdjflks\"", res);
}
- @Test
+ //@Test
public void testGetJPType() throws Exception {
String TEST_PROJECT = "Test";
@@ -216,7 +216,7 @@ public class JPAEditorUtilTest {
}
- @Test
+ //@Test
public void testCreateImports() throws Exception {
String TEST_PROJECT = "Test";
JpaProject jpaProject = null;
@@ -250,7 +250,7 @@ public class JPAEditorUtilTest {
assertTrue(sp.getY() == 4);
}
- @Test
+ //@Test
public void testGetText() throws Exception {
String TEST_PROJECT = "Test";
JpaProject jpaProject = null;
@@ -288,7 +288,7 @@ public class JPAEditorUtilTest {
}
- @Test
+ //@Test
public void testSetJPTNameInShape() {
final String NEW_NAME = "NewJPTName";
ContainerShape cs = EasyMock.createMock(ContainerShape.class);
@@ -309,7 +309,7 @@ public class JPAEditorUtilTest {
JPAEditorUtil.setJPTNameInShape(cs, NEW_NAME, peUtil);
}
- @Test
+ //@Test
public void testCreateBendPointList1() {
FreeFormConnection c = EasyMock.createMock(FreeFormConnection.class);
Anchor startAnchor = EasyMock.createMock(Anchor.class);
@@ -353,7 +353,7 @@ public class JPAEditorUtilTest {
}
- @Test
+ //@Test
public void testCreateBendPointList2() {
FreeFormConnection c = EasyMock.createMock(FreeFormConnection.class);
Anchor startAnchor = EasyMock.createMock(Anchor.class);
@@ -399,4 +399,20 @@ public class JPAEditorUtilTest {
return JavaCore.createCompilationUnitFrom(file);
}
+ @Test
+ public void testAreHeadersEqual() {
+ assertTrue(JPAEditorUtil.areHeadersEqual("header", "header"));
+ assertTrue(JPAEditorUtil.areHeadersEqual(JPAEditorConstants.HEADER_PREFIX_DIRTY + "header", "header"));
+ assertTrue(JPAEditorUtil.areHeadersEqual("header", JPAEditorConstants.HEADER_PREFIX_DIRTY + "header"));
+
+ assertFalse(JPAEditorUtil.areHeadersEqual("header", "headers"));
+ assertFalse(JPAEditorUtil.areHeadersEqual("headers", "header"));
+
+ assertFalse(JPAEditorUtil.areHeadersEqual(JPAEditorConstants.HEADER_PREFIX_DIRTY + "headers", "header"));
+ assertFalse(JPAEditorUtil.areHeadersEqual(JPAEditorConstants.HEADER_PREFIX_DIRTY + "header", "headers"));
+
+ assertFalse(JPAEditorUtil.areHeadersEqual("headers", JPAEditorConstants.HEADER_PREFIX_DIRTY + "header"));
+ assertFalse(JPAEditorUtil.areHeadersEqual("header", JPAEditorConstants.HEADER_PREFIX_DIRTY + "headers"));
+ }
+
}

Back to the top