Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2012-04-02 17:02:47 -0400
committerbvosburgh2012-04-02 17:02:47 -0400
commit3e008a737c56c282f9008886991a8676c325621b (patch)
treefe0b5ba25296171006d222a694adf69c5fea113d
parentbe1ec7a11feff5402813c62bc693d11440ac7f19 (diff)
downloadwebtools.dali-3e008a737c56c282f9008886991a8676c325621b.tar.gz
webtools.dali-3e008a737c56c282f9008886991a8676c325621b.tar.xz
webtools.dali-3e008a737c56c282f9008886991a8676c325621b.zip
add support for JpaProjectsModel
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/ProjectAdapterFactory.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/WorkspaceAdapterFactory.java93
3 files changed, 105 insertions, 34 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
index 060161510c..827bd79016 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
@@ -53,6 +53,13 @@
<adapter type="org.eclipse.jpt.jpa.ui.JpaPlatformUi"/>
</factory>
+ <!-- IWorkspace -> JpaProjectsModel -->
+ <factory
+ adaptableType="org.eclipse.core.resources.IWorkspace"
+ class="org.eclipse.jpt.jpa.ui.internal.WorkspaceAdapterFactory">
+ <adapter type="org.eclipse.jpt.jpa.ui.JpaProjectsModel"/>
+ </factory>
+
<!-- IProject
-> JpaProjectModel
-> JpaRootContextNodeModel
@@ -191,6 +198,7 @@
</proposalComputer>
</extension>
+
<!-- ***** Dali extensions (eat our own dogfood) ***** -->
<extension
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 89b4bb4bc9..8f5ff00a3e 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
@@ -14,14 +14,13 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jpt.common.utility.internal.AbstractTransformer;
import org.eclipse.jpt.common.utility.internal.SimpleFilter;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
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.model.value.CollectionValueModel;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.ui.JpaProjectModel;
+import org.eclipse.jpt.jpa.ui.JpaProjectsModel;
import org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel;
/**
@@ -44,7 +43,7 @@ public class ProjectAdapterFactory
{
private static final Class<?>[] ADAPTER_LIST = new Class[] {
JpaProjectModel.class,
- JpaRootContextNodeModel.class,
+ JpaRootContextNodeModel.class
};
public Class<?>[] getAdapterList() {
@@ -72,12 +71,8 @@ public class ProjectAdapterFactory
return new JpaProjectModelAdapter(this.getJpaProjectsModel(project.getWorkspace()), project);
}
- private CollectionValueModel<JpaProject> getJpaProjectsModel(IWorkspace workspace) {
- return new JpaProjectsModel(this.getJpaProjectManager(workspace));
- }
-
- private JpaProjectManager getJpaProjectManager(IWorkspace workspace) {
- return (JpaProjectManager) workspace.getAdapter(JpaProjectManager.class);
+ private JpaProjectsModel getJpaProjectsModel(IWorkspace workspace) {
+ return (JpaProjectsModel) workspace.getAdapter(JpaProjectsModel.class);
}
private JpaRootContextNodeModel getJpaRootContextNodeModel(IProject project) {
@@ -85,31 +80,6 @@ public class ProjectAdapterFactory
}
- // ********** JPA projects model **********
-
- /**
- * Adapt the JPA project manager's JPA projects list to the collection value
- * model interface.
- */
- /* CU private */ static class JpaProjectsModel
- extends CollectionAspectAdapter<JpaProjectManager, JpaProject>
- {
- JpaProjectsModel(JpaProjectManager jpaProjectManager) {
- super(JpaProjectManager.JPA_PROJECTS_COLLECTION, jpaProjectManager);
- }
-
- @Override
- protected Iterable<JpaProject> getIterable() {
- return this.subject.getJpaProjects();
- }
-
- @Override
- protected int size_() {
- return this.subject.getJpaProjectsSize();
- }
- }
-
-
// ********** JPA project model **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/WorkspaceAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/WorkspaceAdapterFactory.java
new file mode 100644
index 0000000000..96254f916e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/WorkspaceAdapterFactory.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProjectManager;
+import org.eclipse.jpt.jpa.ui.JpaProjectsModel;
+
+/**
+ * Factory to build Dali adapters for an {@link IWorkspace}:<ul>
+ * <li>{@link org.eclipse.jpt.jpa.ui.JpaProjectsModel JpaProjectsModel} -
+ * This adapter will only return a JPA project if it is immediately
+ * available; but it will also notify listeners if the JPA project is
+ * ever created.
+ * This adapter should be used by any process that can temporarily ignore
+ * any uncreated JPA projects but should be notified if the JPA project
+ * <em>is</em> ever created (e.g. UI views).
+ * </ul>
+ * See <code>org.eclipse.jpt.jpa.ui/plugin.xml</code>.
+ */
+public class WorkspaceAdapterFactory
+ implements IAdapterFactory
+{
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {
+ JpaProjectsModel.class
+ };
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof IWorkspace) {
+ return this.getAdapter((IWorkspace) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(IWorkspace workspace, Class<?> adapterType) {
+ if (adapterType == JpaProjectsModel.class) {
+ return this.getJpaProjectsModel(workspace);
+ }
+ return null;
+ }
+
+ private JpaProjectsModel getJpaProjectsModel(IWorkspace workspace) {
+ return new JpaProjectsModelAdapter(this.getJpaProjectManager(workspace));
+ }
+
+ private JpaProjectManager getJpaProjectManager(IWorkspace workspace) {
+ return (JpaProjectManager) workspace.getAdapter(JpaProjectManager.class);
+ }
+
+
+ // ********** JPA projects model **********
+
+ /**
+ * Adapt the JPA project manager's JPA projects list to the collection value
+ * model interface.
+ */
+ /* CU private */ static class JpaProjectsModelAdapter
+ extends CollectionAspectAdapter<JpaProjectManager, JpaProject>
+ implements JpaProjectsModel
+ {
+ JpaProjectsModelAdapter(JpaProjectManager jpaProjectManager) {
+ super(JpaProjectManager.JPA_PROJECTS_COLLECTION, jpaProjectManager);
+ }
+
+ @Override
+ protected Iterable<JpaProject> getIterable() {
+ return this.subject.getJpaProjects();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.getJpaProjectsSize();
+ }
+
+ public IWorkspace getWorkspace() {
+ return this.subject.getWorkspace();
+ }
+ }
+}

Back to the top