diff options
author | bvosburgh | 2012-02-10 20:49:25 +0000 |
---|---|---|
committer | bvosburgh | 2012-02-10 20:49:25 +0000 |
commit | 4716e39927cfe910fa7424870986a195d608b51f (patch) | |
tree | 800ca22e27d3d87fbd1f64968ca69efa5ceba413 /jpa_diagram_editor | |
parent | 52f37be9bfbf1b7c0d451e99d938725ac497eed0 (diff) | |
download | webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.gz webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.xz webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.zip |
rework JpaProjectManager
Diffstat (limited to 'jpa_diagram_editor')
21 files changed, 85 insertions, 293 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/META-INF/MANIFEST.MF b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/META-INF/MANIFEST.MF index 847814eaa4..99dad592f8 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/META-INF/MANIFEST.MF +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/META-INF/MANIFEST.MF @@ -8,7 +8,7 @@ Bundle-Activator: org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorP Bundle-ActivationPolicy: lazy Bundle-ClassPath: . Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)", org.eclipse.emf.transaction;bundle-version="[1.4.0,2.0.0)", diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java index 095a8d7845..e008d5cc69 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2010 SAP AG. + * Copyright (c) 2005, 2012 SAP AG 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 @@ -18,7 +18,6 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal; import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import java.util.List; - import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -45,12 +44,11 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jpt.common.core.internal.utility.PlatformTools; import org.eclipse.jpt.jpa.core.JpaStructureNode; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.ui.internal.selection.DefaultJpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.SelectionManagerFactory; +import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager; import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages; import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.ui.JPADiagramEditorInput; import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil; @@ -286,8 +284,7 @@ public class JPADiagramEditor extends DiagramEditor { (PictogramElement) m); if ((bo == null) || (!(bo instanceof JpaStructureNode))) return; - selectionManager.select(new DefaultJpaSelection( - (JpaStructureNode) bo), null); + selectionManager.setSelection((JpaStructureNode) bo); return; } } @@ -306,7 +303,7 @@ public class JPADiagramEditor extends DiagramEditor { ISelectionManagerFactory { public JpaSelectionManager getSelectionManager(IWorkbenchWindow window) { - return SelectionManagerFactory.getSelectionManager(window); + return PlatformTools.getAdapter(window, JpaSelectionManager.class); } } diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java index ea7ca502ac..c9e4c146f5 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java @@ -174,7 +174,8 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature { final IJPAEditorFeatureProvider fp) { BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { public void run() { - pu.getJpaProject().updateAndWait(); + // TODO figure out why this was necessary: + // pu.getJpaProject().updateAndWait(); final int x = pict.getGraphicsAlgorithm().getX(); final int y = pict.getGraphicsAlgorithm().getY(); final int width = pict.getGraphicsAlgorithm().getWidth(); 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 2196274861..086de3b17b 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 @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2010 SAP AG. + * Copyright (c) 2005, 2011 SAP AG 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 @@ -270,11 +270,7 @@ public class ModelIntegrationUtil { public static JpaProject getProjectByDiagram(String diagramName) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diagramName); - try { - return JpaArtifactFactory.instance().getJpaProject(project); - } catch (CoreException e) { - return null; - } + return JpaArtifactFactory.instance().getJpaProject(project); } public static boolean isDiagramOpen(String diagramName) { 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 fac5383172..fe09b1dee6 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 @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2011 SAP AG. + * Copyright (c) 2005, 2011 SAP AG 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 @@ -290,15 +290,11 @@ public class JPAEditorUtil { return null; IType tp = cu.findPrimaryType(); if (tp == null) - return null;; + return null; name = tp.getFullyQualifiedName(); IJavaProject jp = cu.getJavaProject(); JpaProject proj = null; - try { - proj = JpaArtifactFactory.instance().getJpaProject(jp.getProject()); - } catch (CoreException e) { - JPADiagramEditorPlugin.logError("Cannot obtain the JPA project.", e); //$NON-NLS-1$ - } + proj = JpaArtifactFactory.instance().getJpaProject(jp.getProject()); if (proj == null) return null; PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(proj); @@ -394,45 +390,38 @@ public class JPAEditorUtil { public static void createRegisterEntityInXMLJob(final JpaProject jpaProject, final String classFQN) { final JpaXmlResource resource = jpaProject.getPersistenceXmlResource(); - resource.modify(new Runnable() { - public void run() { - XmlPersistence xmlPersistence = (XmlPersistence) resource.getRootObject(); - EList<XmlPersistenceUnit> persistenceUnits = xmlPersistence.getPersistenceUnits(); - XmlPersistenceUnit persistenceUnit = persistenceUnits.get(0); // Multiply persistence unit support - boolean registered = false; - Iterator<XmlJavaClassRef> it = persistenceUnit.getClasses().iterator(); - while (it.hasNext()) { - String className = it.next().getJavaClass(); - if (classFQN.equals(className)) { - registered = true; - break; - } - } - if (!registered) { - XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef(); - classRef.setJavaClass(classFQN); - persistenceUnit.getClasses().add(classRef); - } + XmlPersistence xmlPersistence = (XmlPersistence) resource.getRootObject(); + EList<XmlPersistenceUnit> persistenceUnits = xmlPersistence.getPersistenceUnits(); + XmlPersistenceUnit persistenceUnit = persistenceUnits.get(0); // Multiply persistence unit support + boolean registered = false; + for (XmlJavaClassRef ref : persistenceUnit.getClasses()) { + String className = ref.getJavaClass(); + if (classFQN.equals(className)) { + registered = true; + break; } - }); + } + if (!registered) { + XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef(); + classRef.setJavaClass(classFQN); + persistenceUnit.getClasses().add(classRef); + } + resource.save(); } public static void createUnregisterEntityFromXMLJob(final JpaProject jpaProject, final String classFQN) { - final JpaXmlResource resource = jpaProject.getPersistenceXmlResource(); - - resource.modify(new Runnable() { - public void run() { - XmlPersistence xmlPersistence = (XmlPersistence) resource.getRootObject(); - EList<XmlPersistenceUnit> persistenceUnits = xmlPersistence.getPersistenceUnits(); - XmlPersistenceUnit persistenceUnit = persistenceUnits.get(0);// Multiply persistence unit support - EList<XmlJavaClassRef> cRefs = persistenceUnit.getClasses(); - for (XmlJavaClassRef cRef : cRefs) - if (cRef.getJavaClass().equals(classFQN)) { - cRefs.remove(cRef); - break; - } + JpaXmlResource resource = jpaProject.getPersistenceXmlResource(); + XmlPersistence xmlPersistence = (XmlPersistence) resource.getRootObject(); + EList<XmlPersistenceUnit> persistenceUnits = xmlPersistence.getPersistenceUnits(); + XmlPersistenceUnit persistenceUnit = persistenceUnits.get(0);// Multiply persistence unit support + EList<XmlJavaClassRef> cRefs = persistenceUnit.getClasses(); + for (XmlJavaClassRef ref : cRefs) { + if (ref.getJavaClass().equals(classFQN)) { + cRefs.remove(ref); + break; } - }); + } + resource.save(); } public static void createImports(ICompilationUnit cu, String typeFQN) { diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java index 6e68ace118..2a55ae729f 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2011 SAP AG. + * Copyright (c) 2005, 2011 SAP AG 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 @@ -50,16 +50,15 @@ import org.eclipse.jdt.ui.refactoring.RenameSupport; import org.eclipse.jpt.common.core.JptResourceModel; import org.eclipse.jpt.common.core.resource.java.Annotation; import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType; +import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind; import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind; import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable; import org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper; import org.eclipse.jpt.jpa.core.JpaFile; import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.MappingKeys; import org.eclipse.jpt.jpa.core.context.AttributeMapping; import org.eclipse.jpt.jpa.core.context.Embeddable; @@ -447,7 +446,6 @@ public class JpaArtifactFactory { ICompilationUnit cu = fp.getCompilationUnit(jpt); try { JpaProject jpaProject = jpt.getJpaProject(); - jpaProject.updateAndWait(); JPAEditorUtil.discardWorkingCopy(cu); cu.delete(true, new NullProgressMonitor()); return true; @@ -1363,7 +1361,6 @@ public class JpaArtifactFactory { */ public JavaPersistentType getJPT(String name, PersistenceUnit pu) { - pu.getJpaProject().updateAndWait(); JavaPersistentType jpt = (JavaPersistentType) pu.getPersistentType(name); int cnt = 0; while ((jpt == null) && (cnt < MAX_NUM_OF_ITERATIONS)) { @@ -2229,8 +2226,8 @@ public class JpaArtifactFactory { return relTypeName; } - public JpaProject getJpaProject(IProject project) throws CoreException { - return JptJpaCorePlugin.getJpaProject(project); + public JpaProject getJpaProject(IProject project) { + return (JpaProject) project.getAdapter(JpaProject.class); } public String getIdType(JavaPersistentType jpt) { 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 5c6885618e..16845b34e9 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 @@ -7,7 +7,7 @@ Bundle-Version: 1.0.100.qualifier Bundle-Activator: org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPAEditorTestsActivator Bundle-ActivationPolicy: lazy Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.easymock;bundle-version="[2.4.0,3.0.0)", org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)", org.eclipse.emf.transaction;bundle-version="[1.4.0,2.0.0)", diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java index 2704eb6efd..e892d936b0 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java @@ -46,7 +46,6 @@ import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; import org.eclipse.jpt.jpa.core.JpaFile; import org.eclipse.jpt.jpa.core.JpaProject; import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; import org.eclipse.jpt.jpa.core.context.PersistentType; import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; @@ -122,7 +121,7 @@ public class JPACreateFactory { addJar(javaProject, eclipseLinkJarName()); } project.refreshLocal(IResource.DEPTH_INFINITE, null); - jpaProject = JptJpaCorePlugin.getJpaProject(project); + jpaProject = this.getJpaProject(project); int cnt = 0; while ((jpaProject == null) && (cnt < 1000)){ try { @@ -130,7 +129,7 @@ public class JPACreateFactory { } catch (InterruptedException e) { e.printStackTrace(); } - jpaProject = JptJpaCorePlugin.getJpaProject(project); + jpaProject = this.getJpaProject(project); cnt++; } jpaProject.setDiscoversAnnotatedClasses(true); @@ -138,6 +137,10 @@ public class JPACreateFactory { return jpaProject; } + private JpaProject getJpaProject(IProject p) { + return (JpaProject) p.getAdapter(JpaProject.class); + } + public static String eclipseLinkJarName() { return getSystemProperty(ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY); } @@ -539,7 +542,7 @@ public class JPACreateFactory { } public static PersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); + JpaFile jpaFile = getJpaFile(file); for (JpaStructureNode node : getRootNodes(jpaFile)) { PersistentType entity = (PersistentType) node; return entity; @@ -556,7 +559,7 @@ public class JPACreateFactory { public static Set<ReadOnlyPersistentAttribute> getEntityFields(IFile file){ Set<ReadOnlyPersistentAttribute> result = new HashSet<ReadOnlyPersistentAttribute>(); - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); + JpaFile jpaFile = getJpaFile(file); if(jpaFile == null){ return result; } @@ -568,6 +571,10 @@ public class JPACreateFactory { } return result; } + + private static JpaFile getJpaFile(IFile file) { + return (JpaFile) file.getAdapter(JpaFile.class); + } public void addAttributes(IFile entity, String attName, String attType, String annotation, String attActName, boolean isCollection){ JavaPersistentType javaPersistentType = (JavaPersistentType)getPersistentType(entity); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPAEditorTestsActivator.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPAEditorTestsActivator.java index 0986bff109..7571ee0ddb 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPAEditorTestsActivator.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPAEditorTestsActivator.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2010 SAP AG. + * Copyright (c) 2005, 2011 SAP AG 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 @@ -15,7 +15,11 @@ *******************************************************************************/ package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Plugin; +import org.eclipse.jpt.common.utility.internal.ReflectionTools; +import org.eclipse.jpt.jpa.core.JpaProjectManager; +import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.osgi.framework.BundleContext; public class JPAEditorTestsActivator extends Plugin { @@ -29,19 +33,19 @@ public class JPAEditorTestsActivator extends Plugin { // The shared instance private static JPAEditorTestsActivator plugin; - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; + JpaProjectManager jpaProjectManager = this.getJpaProjectManager(); + ReflectionTools.executeMethod(jpaProjectManager, "executeCommandsSynchronously"); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ + protected JpaProjectManager getJpaProjectManager() { + return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class); + } + + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java index d16b031506..b6484a2b10 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java @@ -15,22 +15,18 @@ *******************************************************************************/ package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.editor; -import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertNotNull; - import org.easymock.EasyMock; import org.eclipse.gef.EditPart; import org.eclipse.graphiti.mm.pictograms.PictogramElement; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelection; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionManager; -import org.eclipse.jpt.jpa.ui.internal.selection.JpaSelectionParticipant; +import org.eclipse.jpt.jpa.ui.selection.JpaSelectionManager; import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor; import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; @@ -94,8 +90,7 @@ public class EditorTest { // test JpaSelectionManager manager = EasyMock .createMock(JpaSelectionManager.class); - manager.select(isA(JpaSelection.class), - (JpaSelectionParticipant) eq(null)); + manager.setSelection(isA(JpaStructureNode.class)); replay(manager); JPADiagramEditor.ISelectionManagerFactory factory = EasyMock diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java index a700ef5c66..018126740e 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java @@ -19,7 +19,6 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.replay; import static org.junit.Assert.assertNotNull; - import org.easymock.EasyMock; import org.eclipse.core.resources.IFile; import org.eclipse.graphiti.dt.IDiagramTypeProvider; @@ -30,7 +29,6 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.ClickAddAttributeButtonFeature; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; @@ -54,7 +52,6 @@ public class ClickAddFeatureTest { @Before public void setUp() throws Exception { System.setProperty(JPACreateFactory.JPA_JAR_NAME_SYSTEM_PROPERTY, "C:\\lib\\persistence-api-1.0.jar"); - JptJpaCorePlugin.getJpaProjectManager(); factory = JPACreateFactory.instance(); jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis()); assertNotNull(jpaProject); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java index 3ac34cc448..9d6264b2b0 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java @@ -22,10 +22,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; - import org.easymock.EasyMock; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -46,7 +44,6 @@ import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent; import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent; import org.eclipse.jpt.common.utility.model.listener.ListChangeListener; import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory; @@ -65,7 +62,6 @@ public class CreateDeleteOnlyAttributeTest { @Before public void setUp() throws Exception{ - JptJpaCorePlugin.getJpaProjectManager(); factory = JPACreateFactory.instance(); jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis()); assertNotNull(jpaProject); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java index 7ed4a57752..2406595dd6 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java @@ -549,22 +549,6 @@ public class CreateRelationFeaturesTest { } - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node : getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java index 5367a27c13..2e90717f4f 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java @@ -96,22 +96,6 @@ public class SaveEntityFeatureTest { ft.execute(ctx); } - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node : getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java index 84b5695802..d6195301f1 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java @@ -65,26 +65,10 @@ public class JPAProjectListenerTest { IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1"); Thread.sleep(2000); featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entity)); + expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity)); expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes(); } - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node : getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java index 80f7416c95..34e3ba1189 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java @@ -74,7 +74,7 @@ public class ModelIntegrationTest { entityFile = factory.createEntity(jpaProject, "org.eclipse.Entity1"); Thread.sleep(2000); featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entityFile)); + expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entityFile)); expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entityFile)).anyTimes(); } @@ -87,7 +87,7 @@ public class ModelIntegrationTest { ICompilationUnit cu = createCompilationUnitFrom(entityFile); IJPAEditorUtil ut = EasyMock.createMock(IJPAEditorUtil.class); - JavaPersistentType inputJptType = getPersistentType(entityFile); + JavaPersistentType inputJptType = (JavaPersistentType) JPACreateFactory.getPersistentType(entityFile); expect(ut.getJPType(cu)).andStubReturn(inputJptType); expect(featureProvider.getJPAEditorUtil()).andStubReturn(ut); Diagram d = EasyMock.createMock(Diagram.class); @@ -124,7 +124,7 @@ public class ModelIntegrationTest { ICompilationUnit cu = createCompilationUnitFrom(entityFile); IJPAEditorUtil ut = EasyMock.createMock(IJPAEditorUtil.class); - JavaPersistentType inputJptType = getPersistentType(entityFile); + JavaPersistentType inputJptType = (JavaPersistentType) JPACreateFactory.getPersistentType(entityFile); expect(ut.getJPType(cu)).andStubReturn(inputJptType); expect(featureProvider.getJPAEditorUtil()).andStubReturn(ut); Diagram d = EasyMock.createMock(Diagram.class); @@ -197,22 +197,6 @@ public class ModelIntegrationTest { - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node : getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } 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 4d947ab6c1..4c8dfe3d51 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 @@ -17,7 +17,6 @@ package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.modelintegration.util import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; - import org.easymock.EasyMock; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; @@ -26,7 +25,6 @@ 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; @@ -77,7 +75,6 @@ public class ModelIntegrationUtilTest { JPADiagramEditorPlugin p = new JPADiagramEditorPlugin(); p.start(bc); - JptJpaCorePlugin.getJpaProjectManager(); IPreferenceStore store = JPADiagramEditorPlugin.getDefault().getPreferenceStore(); store.putValue(JPAEditorPreferenceInitializer.PROPERTY_DIAGRAM_FOLDER, "diagrams"); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java index 5a5312c80c..d2cc65a4d5 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java @@ -68,27 +68,11 @@ public class CreateRelationAttributesTest { IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1"); Thread.sleep(2000); featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entity)); + expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity)); expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes(); replay(featureProvider); } - public static PersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node : getRootNodes(jpaFile)) { - PersistentType entity = (PersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file); if (!cu.isWorkingCopy()) diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java index 1bad2f4de7..f313512e5d 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java @@ -74,27 +74,11 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest { IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1"); Thread.sleep(2000); featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entity)); + expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity)); expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes(); replay(featureProvider); } - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node: getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java index ffcc157fed..7f420ed395 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java @@ -1,7 +1,7 @@ /******************************************************************************* * <copyright> * - * Copyright (c) 2005, 2011 SAP AG. + * Copyright (c) 2005, 2011 SAP AG 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 @@ -18,15 +18,13 @@ package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.relation; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.replay; -import static org.junit.Assert.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; - import java.util.Iterator; import java.util.Properties; - import org.easymock.EasyMock; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IncrementalProjectBuilder; @@ -36,12 +34,8 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType; import org.eclipse.jpt.common.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper; -import org.eclipse.jpt.jpa.core.JpaFile; import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.context.AttributeMapping; import org.eclipse.jpt.jpa.core.context.Embeddable; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; @@ -69,7 +63,7 @@ import org.junit.Before; import org.junit.Test; -@SuppressWarnings({ "unused" }) +@SuppressWarnings({ "unused", "nls" }) public class CreateRelationsTest { private IJPAEditorFeatureProvider featureProvider; @@ -89,15 +83,13 @@ public class CreateRelationsTest { @Before public void setUp() throws Exception { - JptJpaCorePlugin.getJpaProjectManager(); factory = JPACreateFactory.instance(); jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis()); assertNotNull(jpaProject); IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1"); - Thread.sleep(2000); featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entity)); + expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity)); expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes(); assertNotNull(jpaProject); @@ -113,13 +105,6 @@ public class CreateRelationsTest { t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getQualifiedName()); - int c = 0; - while ((t1 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - jpaProject.update(null); - Thread.sleep(200); - t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getQualifiedName()); - c++; - } expect(featureProvider.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class)); cu1 = JavaCore.createCompilationUnitFrom(customerFile); @@ -131,13 +116,6 @@ public class CreateRelationsTest { t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getQualifiedName()); - c = 0; - while ((t2 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - jpaProject.update(null); - Thread.sleep(200); - t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getQualifiedName()); - c++; - } expect(featureProvider.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class)); cu2 = JavaCore.createCompilationUnitFrom(addressFile); @@ -155,27 +133,11 @@ public class CreateRelationsTest { IFile entity20 = factory.createEntity(jpa20Project, "org.eclipse.Entity1"); Thread.sleep(2000); featureProvider20 = EasyMock.createMock(IJPAEditorFeatureProvider.class); - expect(featureProvider20.getBusinessObjectForPictogramElement(null)).andReturn(getPersistentType(entity20)); + expect(featureProvider20.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity20)); expect(featureProvider20.getCompilationUnit(isA(JavaPersistentType.class))) .andReturn(JavaCore.createCompilationUnitFrom(entity20)).anyTimes(); } - public static JavaPersistentType getPersistentType(IFile file){ - JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); - for (JpaStructureNode node: getRootNodes(jpaFile)) { - JavaPersistentType entity = (JavaPersistentType) node; - return entity; - } - return null; - } - - private static Iterable<JpaStructureNode> getRootNodes(JpaFile jpaFile) { - if(jpaFile == null){ - return EmptyIterable.instance(); - } - return jpaFile.getRootStructureNodes(); - } - public ICompilationUnit createCompilationUnitFrom(IFile file) { return JavaCore.createCompilationUnitFrom(file); } @@ -339,13 +301,6 @@ public class CreateRelationsTest { assertNotNull(customerType); JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, customerType.getQualifiedName()); - int c = 0; - while ((t1 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, customerType.getQualifiedName()); - c++; - } expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class)); ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(customerFile); @@ -357,12 +312,7 @@ public class CreateRelationsTest { JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, addressType.getQualifiedName()); - while ((t2 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, addressType.getQualifiedName()); - c++; - } + expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class)); ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(addressFile); expect(featureProvider20.getCompilationUnit(t2)).andStubReturn(cu2); @@ -417,13 +367,6 @@ public class CreateRelationsTest { assertNotNull(employeeType); JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getQualifiedName()); - int c = 0; - while ((t1 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getQualifiedName()); - c++; - } expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class)); ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(employeeFile); @@ -435,12 +378,7 @@ public class CreateRelationsTest { JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getQualifiedName()); - while ((t2 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getQualifiedName()); - c++; - } + expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class)); ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(projectFile); expect(featureProvider20.getCompilationUnit(t2)).andStubReturn(cu2); @@ -488,13 +426,6 @@ public class CreateRelationsTest { JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getQualifiedName()); - int c = 0; - while ((t1 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getQualifiedName()); - c++; - } expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class)); ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(employeeFile); @@ -503,14 +434,6 @@ public class CreateRelationsTest { Embeddable emb = JpaArtifactFactory.instance().getPersistenceUnit(t1).getEmbeddable("com.test.EmployeerId"); Iterator<AttributeMapping> embIt = emb.getAllAttributeMappings().iterator(); - int c1 = 0; - while ((embIt.hasNext() == false) && (c1 < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - emb.update(); - embIt = emb.getAllAttributeMappings().iterator(); - c1++; - } assertTrue(projectFile.exists()); JavaResourceAbstractType projectType = jpa20Project.getJavaResourceType("com.Person"); @@ -518,12 +441,6 @@ public class CreateRelationsTest { JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getQualifiedName()); - while ((t2 == null) && (c < MAX_NUM_OF_ITERATIONS)) { - Thread.sleep(200); - jpa20Project.update(null); - t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getQualifiedName()); - c++; - } expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class)); ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(projectFile); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/CreateDeleteEntity.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/CreateDeleteEntity.java index 79dc0715c8..668cf6eb16 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/CreateDeleteEntity.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/CreateDeleteEntity.java @@ -19,13 +19,11 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType; import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; import org.eclipse.jpt.jpa.core.context.PersistentType; import org.eclipse.jpt.jpa.core.context.persistence.Persistence; @@ -45,7 +43,6 @@ public class CreateDeleteEntity { @Before public void setUp() throws Exception { - JptJpaCorePlugin.getJpaProjectManager(); factory = JPACreateFactory.instance(); jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis()); assertNotNull(jpaProject); @@ -107,12 +104,10 @@ public class CreateDeleteEntity { // updater = new SynchronousJpaProjectUpdater(jpaProject); // updater.start(); jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); - JptJpaCorePlugin.rebuildJpaProject(jpaProject.getProject()); persistenceType = jpaProject.getJavaResourceType("com.Entity1"); c = 0; while ((persistenceType != null) && (c < 250)) { Thread.sleep(500); - jpaProject = JptJpaCorePlugin.getJpaProject(jpaProject.getProject()); persistenceType = jpaProject.getJavaResourceType("com.Entity1"); c++; } |