Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-09-15 19:18:10 +0000
committerkmoore2011-09-15 19:18:10 +0000
commit1a20e304bf91fd5234c34513288fcd46e52aff43 (patch)
tree282652f9510826740cd9e82a5c752938180f3cbe
parent5b877f3ad1b96c8a5a22fc9086e4222125de158b (diff)
downloadwebtools.dali-1a20e304bf91fd5234c34513288fcd46e52aff43.tar.gz
webtools.dali-1a20e304bf91fd5234c34513288fcd46e52aff43.tar.xz
webtools.dali-1a20e304bf91fd5234c34513288fcd46e52aff43.zip
350474 - submitting patch for Stefan for inclusion in 3.0.1
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java8
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/META-INF/MANIFEST.MF3
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/util/ModelIntegrationUtilTest.java34
3 files changed, 36 insertions, 9 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
index c38d3ba0fb..2196274861 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
@@ -25,7 +25,6 @@ import java.util.Properties;
import java.util.WeakHashMap;
import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
import org.eclipse.core.resources.IContainer;
@@ -133,7 +132,7 @@ public class ModelIntegrationUtil {
return null;
}
- private static IPath copyExistingXMIContentAndDeleteFile(IProject project,
+ public static IPath copyExistingXMIContentAndDeleteFile(IProject project,
String diagramName, IFileStore newXMIFile) throws JavaModelException, CoreException {
String xmiFileName = diagramName + "." + DIAGRAM_FILE_EXTENSION; //$NON-NLS-1$
IPath folderPath = copyExistingXMIContent(project, xmiFileName, newXMIFile);
@@ -141,11 +140,6 @@ public class ModelIntegrationUtil {
return folderPath;
IPath projectPath = project.getFullPath();
folderPath = projectPath.append(getDiagramsXMLFolderPath(project));
- IFileStore xmlFileStore = EFS.getLocalFileSystem().getStore(folderPath.append(diagramName).addFileExtension(DIAGRAM_XML_FILE_EXTENSION));
- IFileInfo info = xmlFileStore.fetchInfo();
- if(!info.exists()){
- xmlFileStore.mkdir(EFS.NONE, null);
- }
return folderPath;
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/META-INF/MANIFEST.MF b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/META-INF/MANIFEST.MF
index 46c5be058d..0eb87ed868 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/META-INF/MANIFEST.MF
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/META-INF/MANIFEST.MF
@@ -25,7 +25,8 @@ Require-Bundle: org.easymock;bundle-version="[2.4.0,3.0.0)",
org.eclipse.wst.common.frameworks;bundle-version="[1.2.0,2.0.0)",
org.eclipse.wst.common.modulecore;bundle-version="[1.2.1,2.0.0)",
org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.junit4;bundle-version="[4.8.1,5.0.0)"
+ org.junit4;bundle-version="[4.8.1,5.0.0)",
+ org.eclipse.core.filesystem;bundle-version="[1.3.100,2.0.0)"
Export-Package: org.eclipse.jpt.jpadiagrameditor.ui.tests.internal;x-internal:=true,
org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.editor;x-internal:=true,
org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature;x-internal:=true,
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/util/ModelIntegrationUtilTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/util/ModelIntegrationUtilTest.java
index 692bbd5519..4d947ab6c1 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/util/ModelIntegrationUtilTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/util/ModelIntegrationUtilTest.java
@@ -24,8 +24,17 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.BasicInternalEList;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.preferences.JPAEditorPreferenceInitializer;
+import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory;
import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleListener;
@SuppressWarnings("unchecked")
@@ -55,5 +64,28 @@ public class ModelIntegrationUtilTest {
assertNotNull(p);
assertEquals(2, p.segmentCount());
assertEquals(p.segment(0), "src");
- }
+ }
+
+ @Test
+ public void copyExistingXMIContentAndDeleteFileTest() throws Exception {
+ Bundle b = EasyMock.createMock(Bundle.class);
+ BundleContext bc = EasyMock.createMock(BundleContext.class);
+ EasyMock.expect(bc.getBundle()).andStubReturn(b);
+ EasyMock.expect(b.getSymbolicName()).andStubReturn("jpa_editor");
+ bc.addBundleListener(EasyMock.isA(BundleListener.class));
+ EasyMock.replay(bc, b);
+
+ JPADiagramEditorPlugin p = new JPADiagramEditorPlugin();
+ p.start(bc);
+ JptJpaCorePlugin.getJpaProjectManager();
+
+ IPreferenceStore store = JPADiagramEditorPlugin.getDefault().getPreferenceStore();
+ store.putValue(JPAEditorPreferenceInitializer.PROPERTY_DIAGRAM_FOLDER, "diagrams");
+ store.getString(JPAEditorPreferenceInitializer.PROPERTY_DIAGRAM_FOLDER);
+
+ JPACreateFactory factory = JPACreateFactory.instance();
+ JpaProject jpaProject = factory.createJPAProject("Test_" + System.currentTimeMillis());
+ assertNotNull(jpaProject);
+ ModelIntegrationUtil.copyExistingXMIContentAndDeleteFile(jpaProject.getProject(), "diagram_name", null);
+ }
}

Back to the top