Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2013-01-22 15:45:26 -0500
committerBrian Vosburgh2013-01-22 16:47:13 -0500
commita2ef3070fb653507ac4e12d3e5666e57a912c1ca (patch)
treec1ff52c1fcf08ce51362812e87e709676d58c78b
parent68b8abab75e757b9f4baf4d72c8f551d64e6d9ad (diff)
downloadwebtools.dali-a2ef3070fb653507ac4e12d3e5666e57a912c1ca.tar.gz
webtools.dali-a2ef3070fb653507ac4e12d3e5666e57a912c1ca.tar.xz
webtools.dali-a2ef3070fb653507ac4e12d3e5666e57a912c1ca.zip
[392601] fix JpaNavigatorContentProvider leak
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProjectManager.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkNavigatorItemContentProviderFactory.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java245
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemContentProviderFactory.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemContentProvider.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemContentProvider.java)6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemLabelProvider.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemLabelProvider.java)6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractNavigatorItemContentProviderFactory.java84
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java6
15 files changed, 386 insertions, 145 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java
index 59fe588ef3..1e4602f495 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. 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.
@@ -32,6 +32,8 @@ import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
* Return a {@link CollectionValueModel} that represents the item's children
* </ul>
*
+ * @param <I> the type of the item for which the provider can supply children
+ * @param <C> the type of the item's children
* @see StaticItemTreeContentProvider
*/
public abstract class AbstractItemTreeContentProvider<I, C>
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java
index 0844615188..4e65cbbe55 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. 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.
@@ -29,8 +29,8 @@ import org.eclipse.ui.navigator.ICommonContentProvider;
public abstract class NavigatorContentProvider
implements ICommonContentProvider
{
- protected final ResourceManager resourceManager;
- protected TreeStateProvider delegate;
+ protected volatile ResourceManager resourceManager;
+ protected volatile ItemTreeStateProviderManager delegate;
/**
@@ -40,7 +40,6 @@ public abstract class NavigatorContentProvider
*/
protected NavigatorContentProvider() {
super();
- this.resourceManager = this.buildResourceManager();
}
/**
@@ -56,10 +55,11 @@ public abstract class NavigatorContentProvider
* here.
*/
public void init(ICommonContentExtensionSite config) {
+ this.resourceManager = this.buildResourceManager();
this.delegate = this.buildDelegate();
}
- protected TreeStateProvider buildDelegate() {
+ protected ItemTreeStateProviderManager buildDelegate() {
return new ItemTreeStateProviderManager(
this.buildItemContentProviderFactory(),
this.buildItemLabelProviderFactory(),
@@ -97,12 +97,7 @@ public abstract class NavigatorContentProvider
}
/**
- * Return whether the specified element has children. This method handles
- * any element that is <em>not</em> handled by the {@link #delegate} but is
- * the parent of element(s) that <em>are</em> handled by the
- * {@link #delegate} (i.e. any third-party element that is to hold the
- * provider's elements; e.g. a project). Return <code>false</code> if the
- * element is to be handled by the {@link #delegate}.
+ * @see #getChildren_(Object)
*/
protected abstract boolean hasChildren_(Object element);
@@ -118,6 +113,10 @@ public abstract class NavigatorContentProvider
* {@link #delegate} (i.e. any third-party element that is to hold the
* provider's elements; e.g. a project). Return <code>null</code> if the
* element is to be handled by the {@link #delegate}.
+ * <p>
+ * We provide this hook for elements that are to be displayed even if their
+ * corresponding model does not yet exist.
+ * @see #hasChildren_(Object)
*/
protected abstract Object[] getChildren_(Object element);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
index 3d3fa813c7..2620e57464 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
@@ -24,6 +24,8 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceTypeCache;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
import org.eclipse.jpt.common.core.utility.command.JobCommand;
import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
+import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
@@ -129,6 +131,17 @@ public interface JpaProject
*/
JpaRootContextNode getRootContextNode();
+ Transformer<JpaProject, JpaRootContextNode> ROOT_CONTEXT_NODE_TRANSFORMER = new RootContextNodeTransformer();
+
+ class RootContextNodeTransformer
+ extends AbstractTransformer<JpaProject, JpaRootContextNode>
+ {
+ @Override
+ protected JpaRootContextNode transform_(JpaProject jpaProject) {
+ return jpaProject.getRootContextNode();
+ }
+ }
+
/**
* The JPA project has been removed from the JPA model. Clean up any
* hooks to external resources etc.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProjectManager.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProjectManager.java
index 0b2087162b..d2c0be41f7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProjectManager.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProjectManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 Oracle. 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.
@@ -13,6 +13,7 @@ import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.reference.BooleanReference;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
/**
* The JPA project manager holds all the JPA projects in an Eclipse workspace
@@ -118,4 +119,16 @@ public interface JpaProjectManager
* @see #addJavaEventListenerFlag(BooleanReference)
*/
void removeJavaEventListenerFlag(BooleanReference flag);
+
+
+ // ********** async event listener flags **********
+
+ /**
+ * The name of the JPA faceted project framework settings file.
+ * Listen for changes to this file to determine when the JPA facet is
+ * added to or removed from a "faceted" project.
+ * @see org.eclipse.jpt.common.core.internal.utility.ProjectTools#hasFacet(org.eclipse.core.resources.IProject, org.eclipse.wst.common.project.facet.core.IProjectFacet)
+ * @see JpaProject#FACET
+ */
+ String FACETED_PROJECT_FRAMEWORK_SETTINGS_FILE_NAME = FacetedProjectFramework.PLUGIN_ID + ".xml"; //$NON-NLS-1$
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java
index d7b4b6ab60..c4a15ef077 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/InternalJpaProjectManager.java
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -39,6 +38,8 @@ import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
+import org.eclipse.jpt.common.core.internal.utility.ResourceChangeAdapter;
+import org.eclipse.jpt.common.core.internal.utility.ResourceProxyVisitorAdapter;
import org.eclipse.jpt.common.core.internal.utility.command.CommandJobCommandAdapter;
import org.eclipse.jpt.common.core.internal.utility.command.JobCommandAdapter;
import org.eclipse.jpt.common.core.internal.utility.command.SimpleJobCommandExecutor;
@@ -66,7 +67,6 @@ import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformManager;
-import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -192,12 +192,6 @@ class InternalJpaProjectManager
IResourceChangeEvent.POST_BUILD;
/**
- * Listen for changes to this file to determine when the JPA facet is
- * added to or removed from a "faceted" project.
- */
- private static final String FACETED_PROJECT_FRAMEWORK_SETTINGS_FILE_NAME = FacetedProjectFramework.PLUGIN_ID + ".xml"; //$NON-NLS-1$
-
- /**
* Listen for Java changes (unless the Dali UI is active).
* @see #javaEventListenersAreActive()
*/
@@ -1217,7 +1211,7 @@ class InternalJpaProjectManager
* JPA project manager for each open Eclipse project that has a JPA facet.
*/
/* CU private */ class ResourceProxyVisitor
- implements IResourceProxyVisitor
+ extends ResourceProxyVisitorAdapter
{
private final IProgressMonitor monitor;
@@ -1226,6 +1220,7 @@ class InternalJpaProjectManager
this.monitor = monitor;
}
+ @Override
public boolean visit(IResourceProxy resourceProxy) {
switch (resourceProxy.getType()) {
case IResource.ROOT :
@@ -1254,18 +1249,13 @@ class InternalJpaProjectManager
}
}
}
-
- @Override
- public String toString() {
- return ObjectTools.toString(this);
- }
}
// ********** resource change listener **********
/* CU private */ class ResourceChangeListener
- implements IResourceChangeListener
+ extends ResourceChangeAdapter
{
/**
* PRE_UNINSTALL is the only facet event we use for
@@ -1278,6 +1268,7 @@ class InternalJpaProjectManager
* <li>project clean
* </ul>
*/
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
switch (event.getType()) {
case IResourceChangeEvent.POST_CHANGE :
@@ -1426,11 +1417,6 @@ class InternalJpaProjectManager
JptJpaCorePlugin.instance().trace(TRACE_OPTION, "\tProject CLEAN event: {0}", project.getName()); //$NON-NLS-1$
InternalJpaProjectManager.this.projectPostCleanBuild(project);
}
-
- @Override
- public String toString() {
- return ObjectTools.toString(this);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkNavigatorItemContentProviderFactory.java
index bdc48a5057..99eefe4448 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkNavigatorItemContentProviderFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkNavigatorItemContentProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -13,10 +13,10 @@ import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistencexml.details.EclipseLinkPersistenceUnitItemContentProvider;
-import org.eclipse.jpt.jpa.ui.internal.platform.generic.GenericNavigatorItemContentProviderFactory;
+import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractNavigatorItemContentProviderFactory;
public class EclipseLinkNavigatorItemContentProviderFactory
- extends GenericNavigatorItemContentProviderFactory
+ extends AbstractNavigatorItemContentProviderFactory
{
// singleton
private static final ItemTreeContentProviderFactory INSTANCE = new EclipseLinkNavigatorItemContentProviderFactory();
@@ -29,7 +29,7 @@ public class EclipseLinkNavigatorItemContentProviderFactory
}
- protected EclipseLinkNavigatorItemContentProviderFactory() {
+ private EclipseLinkNavigatorItemContentProviderFactory() {
super();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java
index 9008aea553..b96e14324c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2013 Oracle. 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.
@@ -15,7 +15,6 @@ import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jpt.common.utility.internal.filter.SimpleFilter;
import org.eclipse.jpt.common.utility.internal.model.value.ElementPropertyValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
@@ -134,9 +133,6 @@ public class ProjectAdapterFactory
* want to wait to retrieve a JPA root context node but wants to be notified
* when it is available.
* <p>
- * Subclass {@link TransformationPropertyValueModel} so we can
- * implement {@link org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel}.
- * <p>
* <strong>NB:</strong> This model operates outside of all the other
* activity synchronized by the JPA project manager; but that should be OK
* since it will be kept synchronized with the JPA manager's collection of
@@ -147,22 +143,11 @@ public class ProjectAdapterFactory
implements JpaRootContextNodeModel
{
JpaRootContextNodeModelAdapter(JpaProjectModel jpaProjectsModel) {
- super(jpaProjectsModel, TRANSFORMER);
+ super(jpaProjectsModel, JpaProject.ROOT_CONTEXT_NODE_TRANSFORMER);
}
public IProject getProject() {
return ((JpaProjectModel) this.valueModel).getProject();
}
-
- private static final Transformer TRANSFORMER = new Transformer();
-
- /* class private */ static class Transformer
- extends AbstractTransformer<JpaProject, JpaRootContextNode>
- {
- @Override
- protected JpaRootContextNode transform_(JpaProject jpaProject) {
- return jpaProject.getRootContextNode();
- }
- }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java
index b22087aa48..fbd66487eb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorContentProvider.java
@@ -9,17 +9,31 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.navigator;
+import java.util.HashMap;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspace;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
+import org.eclipse.jpt.common.core.internal.utility.ResourceChangeAdapter;
import org.eclipse.jpt.common.ui.internal.jface.NavigatorContentProvider;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
import org.eclipse.jpt.jpa.ui.JpaWorkbench;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
/**
* This provider is invoked for:<ul>
@@ -28,14 +42,40 @@ import org.eclipse.ui.PlatformUI;
* <li>JPA context nodes
* </ul>
* See <code>org.eclipse.jpt.jpa.ui/plugin.xml</code>.
+ * <p>
+ * <strong>NB:</strong> We can only refresh the navigator once the navigator
+ * has instantiated and invoked this provider for the first time. At that point
+ * we are listening for resource changes and can force a refresh of the
+ * navigator as the JPA facet is added or removed from the projects.
+ * In particular: If a project is already present and expanded in the navigator,
+ * and this provider has never been invoked (i.e. there are no JPA projects in
+ * the workspace yet), adding the JPA facet to the project will <em>not</em>
+ * result in the "JPA Content" node showing up under the project's node in the
+ * navigator tree. The navigator must be explicitly refreshed,
+ * forcing it to re-examine the provider trigger points and invoking this
+ * provider as a result.
*/
public class JpaNavigatorContentProvider
extends NavigatorContentProvider
{
+ private volatile IResourceChangeListener resourceChangeListener;
+ private final HashMap<IProject, JpaRootContextNodeModel[]> projectChildren = new HashMap<IProject, JpaRootContextNodeModel[]>();
+
+
public JpaNavigatorContentProvider() {
super();
}
+
+ // ********** initialization **********
+
+ @Override
+ public void init(ICommonContentExtensionSite config) {
+ super.init(config);
+ this.resourceChangeListener = new ResourceChangeListener();
+ this.getWorkspace().addResourceChangeListener(this.resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+ }
+
@Override
protected ItemTreeContentProviderFactory buildItemContentProviderFactory() {
return new JpaNavigatorItemContentProviderFactory();
@@ -49,40 +89,213 @@ public class JpaNavigatorContentProvider
@Override
protected ResourceManager buildResourceManager() {
JpaWorkbench jpaWorkbench = this.getJpaWorkbench();
- return (jpaWorkbench != null) ? jpaWorkbench.buildLocalResourceManager() : new LocalResourceManager(JFaceResources.getResources(PlatformUI.getWorkbench().getDisplay()));
+ return (jpaWorkbench != null) ? jpaWorkbench.buildLocalResourceManager() : this.buildResourceManager_();
}
- private JpaWorkbench getJpaWorkbench() {
- return PlatformTools.getAdapter(PlatformUI.getWorkbench(), JpaWorkbench.class);
+ private ResourceManager buildResourceManager_() {
+ return new LocalResourceManager(JFaceResources.getResources(this.getWorkbench().getDisplay()));
}
+
+ // ********** children **********
+
+ /**
+ * @see #getChildren_(Object)
+ */
@Override
protected boolean hasChildren_(Object element) {
- return this.getRootContextNodeModel(element) != null;
+ return this.getChildren_(element) != null;
}
/**
- * We handle the children for an {@link IProject} here and delegate
- * all others.
+ * We handle the children for an {@link IProject} here and allow the
+ * superclass to delegate all others.
*/
@Override
protected Object[] getChildren_(Object element) {
- JpaRootContextNodeModel child = this.getRootContextNodeModel(element);
- return (child == null) ? null : new Object[] {child};
+ return (element instanceof IProject) ?
+ this.getChildren((IProject) element) :
+ null;
+ }
+
+ private Object[] getChildren(IProject project) {
+ synchronized (this.projectChildren) {
+ return this.getChildren_(project);
+ }
+ }
+
+ /**
+ * Pre-condition: {@link #projectChildren} is <code>synchronized</code>
+ */
+ private JpaRootContextNodeModel[] getChildren_(IProject project) {
+ JpaRootContextNodeModel[] children = this.projectChildren.get(project);
+ if (children == null) {
+ children = this.buildChildren(project);
+ this.projectChildren.put(project, children);
+ }
+ return children;
+ }
+
+ private JpaRootContextNodeModel[] buildChildren(IProject project) {
+ return new JpaRootContextNodeModel[] {this.buildChild(project)};
}
/**
* This provider should only be invoked for projects that have the
- * JPA facet; so we return a JPA root context node model for any
+ * JPA facet; so we return a JPA root context node model for <em>any</em>
* project passed in.
* <p>
- * <strong>NB:</strong> There is no way to refresh the navigator when the
- * JPA facet is added to a project. The view must be explicitly refreshed,
- * forcing it to re-examine the provider trigger points.
+ * We return a JPA root context node <em>model</em> (as opposed to simply a
+ * JPA root context node) so a node appears in the navigator tree even if
+ * there is not yet a JPA project. Since this node is returned for any
+ * project with a JPA facet, we must listen for the JPA facet being removed
+ * so, when the JPA facet is removed, we can tell the delegate to
+ * dispose the node's content and label providers (which are listening to
+ * the node for changes etc.).
*/
- private JpaRootContextNodeModel getRootContextNodeModel(Object element) {
- return (element instanceof IProject) ?
- (JpaRootContextNodeModel) ((IProject) element).getAdapter(JpaRootContextNodeModel.class) :
- null;
+ private JpaRootContextNodeModel buildChild(IProject project) {
+ return (JpaRootContextNodeModel) project.getAdapter(JpaRootContextNodeModel.class);
+ }
+
+
+ // ********** facet file changes **********
+
+ /* CU private */ void facetFileChanged(IProject project) {
+ if (ProjectTools.hasFacet(project, JpaProject.FACET)) {
+ this.jpaFacetIsPresent(project);
+ } else {
+ this.jpaFacetIsAbsent(project);
+ }
+ }
+
+ private void jpaFacetIsPresent(IProject project) {
+ synchronized (this.projectChildren) {
+ this.jpaFacetIsPresent_(project);
+ }
+ }
+
+ /**
+ * The specified project <em>has</em> the JPA facet;
+ * refresh the view if necessary.
+ * <p>
+ * Pre-condition: {@link #projectChildren} is <code>synchronized</code>
+ */
+ private void jpaFacetIsPresent_(IProject project) {
+ JpaRootContextNodeModel[] children = this.projectChildren.get(project);
+ if (children == null) {
+ this.delegate.updateChildren(project); // force the viewer to refresh the project
+ }
+ }
+
+ private void jpaFacetIsAbsent(IProject project) {
+ synchronized (this.projectChildren) {
+ this.jpaFacetIsAbsent_(project);
+ }
+ }
+
+ /**
+ * The specified project does <em>not</em> have the JPA facet;
+ * remove the JPA root context node model if necessary.
+ * <p>
+ * Pre-condition: {@link #projectChildren} is <code>synchronized</code>
+ */
+ private void jpaFacetIsAbsent_(IProject project) {
+ JpaRootContextNodeModel[] children = this.projectChildren.remove(project);
+ if (children != null) {
+ for (JpaRootContextNodeModel child : children) { // should be only one...
+ this.delegate.dispose(child);
+ }
+ this.delegate.updateChildren(project); // force the viewer to refresh the project
+ }
+ }
+
+
+ // ********** disposal **********
+
+ @Override
+ public void dispose() {
+ // the delegate will dispose everything, including the JPA root context node models
+ this.getWorkspace().removeResourceChangeListener(this.resourceChangeListener);
+ super.dispose();
+ }
+
+
+ // ********** misc **********
+
+ private IWorkspace getWorkspace() {
+ return this.getJpaWorkbench().getJpaWorkspace().getWorkspace();
+ }
+
+ private JpaWorkbench getJpaWorkbench() {
+ return PlatformTools.getAdapter(this.getWorkbench(), JpaWorkbench.class);
+ }
+
+ private IWorkbench getWorkbench() {
+ return PlatformUI.getWorkbench();
+ }
+
+
+ // ********** resource change listener **********
+
+ /**
+ * Listen for changes to the facet settings file.
+ * @see org.eclipse.jpt.jpa.core.internal.InternalJpaProjectManager#FACETED_PROJECT_FRAMEWORK_SETTINGS_FILE_NAME
+ */
+ /* CU private */ class ResourceChangeListener
+ extends ResourceChangeAdapter
+ {
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ switch (event.getType()) {
+ case IResourceChangeEvent.POST_CHANGE :
+ this.processPostChangeDelta(event.getDelta());
+ break;
+ default :
+ break;
+ }
+ }
+
+ private void processPostChangeDelta(IResourceDelta delta) {
+ IResource resource = delta.getResource();
+ switch (resource.getType()) {
+ case IResource.ROOT :
+ this.processPostChangeDeltaChildren(delta);
+ break;
+ case IResource.PROJECT :
+ this.processPostChangeDeltaChildren(delta);
+ break;
+ case IResource.FOLDER :
+ if (((IFolder) resource).getName().equals(".settings")) { //$NON-NLS-1$
+ this.processPostChangeDeltaChildren(delta);
+ }
+ break;
+ case IResource.FILE :
+ IFile file = (IFile) resource;
+ if (file.getName().equals(JpaProjectManager.FACETED_PROJECT_FRAMEWORK_SETTINGS_FILE_NAME)) {
+ this.checkForFacetFileChanges(file, delta);
+ }
+ break;
+ default :
+ break;
+ }
+ }
+
+ private void processPostChangeDeltaChildren(IResourceDelta delta) {
+ for (IResourceDelta child : delta.getAffectedChildren()) {
+ this.processPostChangeDelta(child); // recurse
+ }
+ }
+
+ private void checkForFacetFileChanges(IFile file, IResourceDelta delta) {
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ case IResourceDelta.REMOVED :
+ case IResourceDelta.CHANGED :
+ JpaNavigatorContentProvider.this.facetFileChanged(file.getProject());
+ break;
+ default :
+ break;
+ }
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemContentProviderFactory.java
index 013390e4cd..356be5e2c8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemContentProviderFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemContentProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -42,6 +42,8 @@ public class JpaNavigatorItemContentProviderFactory
}
public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
+ // we hand JpaRootContextNodeModel differently because it can exist when the
+ // JPA facet is present by the JPA project may not yet be present...
if (item instanceof JpaRootContextNodeModel) {
return this.buildRootContextNodeModelProvider((JpaRootContextNodeModel) item, manager);
}
@@ -50,7 +52,7 @@ public class JpaNavigatorItemContentProviderFactory
}
protected ItemTreeContentProvider buildRootContextNodeModelProvider(JpaRootContextNodeModel item, Manager manager) {
- return new RootContextNodeModelItemContentProvider(item, manager);
+ return new JpaRootContextNodeModelItemContentProvider(item, manager);
}
private ItemTreeContentProviderFactory getDelegate(Object element) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java
index 3896f30bb6..6106cb19f3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaNavigatorItemLabelProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -36,6 +36,8 @@ public class JpaNavigatorItemLabelProviderFactory
}
public ItemExtendedLabelProvider buildProvider(Object item, ItemExtendedLabelProvider.Manager manager) {
+ // we hand JpaRootContextNodeModel differently because it can exist when the
+ // JPA facet is present by the JPA project may not yet be present...
if (item instanceof JpaRootContextNodeModel) {
return this.buildRootContextNodeModelProvider((JpaRootContextNodeModel) item, manager);
}
@@ -44,7 +46,7 @@ public class JpaNavigatorItemLabelProviderFactory
}
protected ItemExtendedLabelProvider buildRootContextNodeModelProvider(JpaRootContextNodeModel item, ItemExtendedLabelProvider.Manager manager) {
- return new RootContextNodeModelItemLabelProvider(item, manager);
+ return new JpaRootContextNodeModelItemLabelProvider(item, manager);
}
private ItemExtendedLabelProviderFactory getDelegate(Object item) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemContentProvider.java
index 72737540fe..90c976a3a2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -19,10 +19,10 @@ import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
-public class RootContextNodeModelItemContentProvider
+public class JpaRootContextNodeModelItemContentProvider
extends AbstractItemTreeContentProvider<JpaRootContextNodeModel, PersistenceXml>
{
- public RootContextNodeModelItemContentProvider(JpaRootContextNodeModel rootContextModel, Manager manager) {
+ public JpaRootContextNodeModelItemContentProvider(JpaRootContextNodeModel rootContextModel, Manager manager) {
super(rootContextModel, manager);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemLabelProvider.java
index e566176918..7dd4d080ba 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/RootContextNodeModelItemLabelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/navigator/JpaRootContextNodeModelItemLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -22,10 +22,10 @@ import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
import org.eclipse.jpt.jpa.ui.JptJpaUiImages;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-public class RootContextNodeModelItemLabelProvider
+public class JpaRootContextNodeModelItemLabelProvider
extends AbstractItemExtendedLabelProvider<JpaRootContextNodeModel>
{
- public RootContextNodeModelItemLabelProvider(JpaRootContextNodeModel rootContextNodeModel, ItemExtendedLabelProvider.Manager manager) {
+ public JpaRootContextNodeModelItemLabelProvider(JpaRootContextNodeModel rootContextNodeModel, ItemExtendedLabelProvider.Manager manager) {
super(rootContextNodeModel, manager);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractNavigatorItemContentProviderFactory.java
new file mode 100644
index 0000000000..03ded6090e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractNavigatorItemContentProviderFactory.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.platform.base;
+
+import org.eclipse.jpt.common.ui.internal.jface.StaticItemTreeContentProvider;
+import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
+import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider.Manager;
+import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
+import org.eclipse.jpt.jpa.ui.internal.platform.generic.JavaPersistentTypeItemContentProvider;
+import org.eclipse.jpt.jpa.ui.internal.platform.generic.OrmPersistentTypeItemContentProvider;
+import org.eclipse.jpt.jpa.ui.internal.platform.generic.OrmXmlItemContentProvider;
+import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistenceUnitItemContentProvider;
+import org.eclipse.jpt.jpa.ui.internal.platform.generic.PersistenceXmlItemContentProvider;
+
+/**
+ * This factory builds item content providers for the JPA content in the
+ * Project Explorer.
+ */
+public abstract class AbstractNavigatorItemContentProviderFactory
+ implements ItemTreeContentProviderFactory
+{
+ protected AbstractNavigatorItemContentProviderFactory() {
+ super();
+ }
+
+ public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
+ if (item instanceof PersistenceXml) {
+ return this.buildPersistenceXmlProvider((PersistenceXml) item, manager);
+ }
+ if (item instanceof PersistenceUnit) {
+ return this.buildPersistenceUnitProvider((PersistenceUnit) item, manager);
+ }
+ if (item instanceof OrmXml) {
+ return this.buildOrmXmlProvider((OrmXml) item, manager);
+ }
+ if (item instanceof OrmPersistentType) {
+ return this.buildOrmPersistentTypeProvider((OrmPersistentType) item, manager);
+ }
+ if (item instanceof JavaPersistentType) {
+ return this.buildJavaPersistentTypeProvider((JavaPersistentType) item, manager);
+ }
+ if (item instanceof PersistentAttribute) {
+ return this.buildPersistentAttributeProvider((PersistentAttribute) item, manager);
+ }
+ return null;
+ }
+
+ protected ItemTreeContentProvider buildPersistenceXmlProvider(PersistenceXml item, Manager manager) {
+ return new PersistenceXmlItemContentProvider(item, manager);
+ }
+
+ protected ItemTreeContentProvider buildPersistenceUnitProvider(PersistenceUnit item, Manager manager) {
+ return new PersistenceUnitItemContentProvider(item, manager);
+ }
+
+ protected ItemTreeContentProvider buildOrmXmlProvider(OrmXml item, Manager manager) {
+ return new OrmXmlItemContentProvider(item, manager);
+ }
+
+ protected ItemTreeContentProvider buildOrmPersistentTypeProvider(OrmPersistentType item, Manager manager) {
+ return new OrmPersistentTypeItemContentProvider(item, manager);
+ }
+
+ protected ItemTreeContentProvider buildJavaPersistentTypeProvider(JavaPersistentType item, Manager manager) {
+ return new JavaPersistentTypeItemContentProvider(item, manager);
+ }
+
+ protected ItemTreeContentProvider buildPersistentAttributeProvider(PersistentAttribute item, @SuppressWarnings("unused") Manager manager) {
+ return new StaticItemTreeContentProvider(item.getParent());
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java
index d14343d11a..345c824881 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemContentProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -9,23 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.platform.generic;
-import org.eclipse.jpt.common.ui.internal.jface.StaticItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider.Manager;
import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
+import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractNavigatorItemContentProviderFactory;
-/**
- * This factory builds item content providers for the JPA content in the
- * Common Navigator.
- */
public class GenericNavigatorItemContentProviderFactory
- implements ItemTreeContentProviderFactory
+ extends AbstractNavigatorItemContentProviderFactory
{
// singleton
private static final ItemTreeContentProviderFactory INSTANCE = new GenericNavigatorItemContentProviderFactory();
@@ -38,53 +26,7 @@ public class GenericNavigatorItemContentProviderFactory
}
- protected GenericNavigatorItemContentProviderFactory() {
+ private GenericNavigatorItemContentProviderFactory() {
super();
}
-
- public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
- if (item instanceof PersistenceXml) {
- return this.buildPersistenceXmlProvider((PersistenceXml) item, manager);
- }
- if (item instanceof PersistenceUnit) {
- return this.buildPersistenceUnitProvider((PersistenceUnit) item, manager);
- }
- if (item instanceof OrmXml) {
- return this.buildOrmXmlProvider((OrmXml) item, manager);
- }
- if (item instanceof OrmPersistentType) {
- return this.buildOrmPersistentTypeProvider((OrmPersistentType) item, manager);
- }
- if (item instanceof JavaPersistentType) {
- return this.buildJavaPersistentTypeProvider((JavaPersistentType) item, manager);
- }
- if (item instanceof PersistentAttribute) {
- return this.buildPersistentAttributeProvider((PersistentAttribute) item, manager);
- }
- return null;
- }
-
- protected ItemTreeContentProvider buildPersistenceXmlProvider(PersistenceXml item, Manager manager) {
- return new PersistenceXmlItemContentProvider(item, manager);
- }
-
- protected ItemTreeContentProvider buildPersistenceUnitProvider(PersistenceUnit item, Manager manager) {
- return new PersistenceUnitItemContentProvider(item, manager);
- }
-
- protected ItemTreeContentProvider buildOrmXmlProvider(OrmXml item, Manager manager) {
- return new OrmXmlItemContentProvider(item, manager);
- }
-
- protected ItemTreeContentProvider buildOrmPersistentTypeProvider(OrmPersistentType item, Manager manager) {
- return new OrmPersistentTypeItemContentProvider(item, manager);
- }
-
- protected ItemTreeContentProvider buildJavaPersistentTypeProvider(JavaPersistentType item, Manager manager) {
- return new JavaPersistentTypeItemContentProvider(item, manager);
- }
-
- protected ItemTreeContentProvider buildPersistentAttributeProvider(PersistentAttribute item, @SuppressWarnings("unused") Manager manager) {
- return new StaticItemTreeContentProvider(item.getParent());
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java
index d8cfe87723..2a1b8c9981 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceXmlItemContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. 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.
@@ -46,12 +46,12 @@ public class PersistenceXmlItemContentProvider
@Override
protected ListIterable<PersistenceUnit> getListIterable() {
- return subject.getPersistenceUnits();
+ return this.subject.getPersistenceUnits();
}
@Override
protected int size_() {
- return subject.getPersistenceUnitsSize();
+ return this.subject.getPersistenceUnitsSize();
}
}

Back to the top