Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authornhauge2011-03-30 21:40:31 +0000
committernhauge2011-03-30 21:40:31 +0000
commitf7a541b4666b1e3d793ec0cbe89d713fb247e521 (patch)
treec00e8162dd8091e6fea78a0b89ad7598c1b9bb3c /jpa
parent53feae24c47576df4f0313f90eaa4c7635554bd2 (diff)
downloadwebtools.dali-f7a541b4666b1e3d793ec0cbe89d713fb247e521.tar.gz
webtools.dali-f7a541b4666b1e3d793ec0cbe89d713fb247e521.tar.xz
webtools.dali-f7a541b4666b1e3d793ec0cbe89d713fb247e521.zip
[340175] Re-institute support for custom variables for the JPA facet. These are being used by adopting products and have requested that they remain available for library
provider enablement condition evaluation (filtering).
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetDataModelProvider.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/RuntimeChangedListener.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/libprov/JpaLibraryProviderInstallOperationConfig.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java78
5 files changed, 128 insertions, 4 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
index 0172b1c125..827e4f921e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
@@ -11,8 +11,10 @@ package org.eclipse.jpt.jpa.core.internal;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
@@ -77,6 +79,7 @@ import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.JpaRootContextNode2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.JavaResourcePersistentType2_0;
+import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
@@ -1414,10 +1417,14 @@ public abstract class AbstractJpaProject
}
protected void validateLibraryProvider_(List<IMessage> messages) throws CoreException {
+ Map<String, Object> enablementVariables = new HashMap<String, Object>();
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, getJpaPlatform().getId());
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, getJpaPlatform().getDescription());
+
ILibraryProvider libraryProvider = LibraryProviderFramework.getCurrentProvider(getProject(), JpaFacet.FACET);
IFacetedProject facetedProject = ProjectFacetsManager.create(getProject());
IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(JpaFacet.FACET);
- if ( ! libraryProvider.isEnabledFor(facetedProject, facetVersion)) {
+ if ( ! libraryProvider.isEnabledFor(facetedProject, facetVersion, enablementVariables)) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetDataModelProvider.java
index b342c07b07..0d4ef5ff90 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/JpaFacetDataModelProvider.java
@@ -12,7 +12,9 @@ package org.eclipse.jpt.jpa.core.internal.facet;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -233,7 +235,16 @@ public abstract class JpaFacetDataModelProvider
if (pfv == null) {
return null;
}
- LibraryInstallDelegate lp = new LibraryInstallDelegate(fpjwc, pfv);
+
+ Map<String, Object> customEnablementVariables = new HashMap<String, Object>();
+ JpaPlatformDescription jpaPlatform = getPlatform();
+ String jpaPlatformId = (jpaPlatform == null) ? "" : jpaPlatform.getId();
+ customEnablementVariables.put(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, jpaPlatformId);
+ customEnablementVariables.put(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, jpaPlatform);
+
+ LibraryInstallDelegate lp = new LibraryInstallDelegate(fpjwc, pfv, customEnablementVariables);
lp.addListener(buildLibraryProviderListener());
return lp;
}
@@ -387,7 +398,16 @@ public abstract class JpaFacetDataModelProvider
protected void adjustLibraryProviders() {
LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
+
if (lid != null) {
+ JpaPlatformDescription jpaPlatform = getPlatform();
+ String jpaPlatformId = (jpaPlatform == null) ? "" : jpaPlatform.getId();
+
+ lid.setEnablementContextVariable(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, jpaPlatformId);
+ lid.setEnablementContextVariable(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, jpaPlatform);
+
List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
= new ArrayList<JpaLibraryProviderInstallOperationConfig>();
// add the currently selected one first
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/RuntimeChangedListener.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/RuntimeChangedListener.java
index 59d4ef4ee1..88d881e740 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/RuntimeChangedListener.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/facet/RuntimeChangedListener.java
@@ -9,12 +9,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.facet;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jpt.jpa.core.JpaFacet;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -32,7 +37,10 @@ public class RuntimeChangedListener
}
IProjectFacetVersion pfv = fpb.getProjectFacetVersion(JpaFacet.FACET);
if (pfv != null) {
- LibraryInstallDelegate lp = new LibraryInstallDelegate(fpb, pfv);
+ Map<String, Object> enablementVariables = new HashMap<String, Object>();
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, getJpaPlatformId(fpb.getProject()));
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, getJpaPlatformDescription(fpb.getProject()));
+ LibraryInstallDelegate lp = new LibraryInstallDelegate(fpb, pfv, enablementVariables);
try {
lp.execute(new NullProgressMonitor());
}
@@ -46,4 +54,10 @@ public class RuntimeChangedListener
JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project);
return (jpaProject == null) ? null : jpaProject.getJpaPlatform().getId();
}
+
+ protected JpaPlatformDescription getJpaPlatformDescription(IProject project) {
+ JpaProject jpaProject = JptJpaCorePlugin.getJpaProject(project);
+ return (jpaProject == null) ? null : jpaProject.getJpaPlatform().getDescription();
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/libprov/JpaLibraryProviderInstallOperationConfig.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/libprov/JpaLibraryProviderInstallOperationConfig.java
index 2607704330..9ec2b342ae 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/libprov/JpaLibraryProviderInstallOperationConfig.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/libprov/JpaLibraryProviderInstallOperationConfig.java
@@ -16,6 +16,13 @@ import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
public interface JpaLibraryProviderInstallOperationConfig
extends JptLibraryProviderInstallOperationConfig {
+ /** enablement expression for jpa platform id (String) */
+ public static final String JPA_PLATFORM_ENABLEMENT_EXP = "jpaPlatform"; //$NON-NLS-1$
+
+ /** enablement expression for jpa platform description (JpaPlatformDescription) */
+ public static final String JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP = "jpaPlatformDescription"; //$NON-NLS-1$
+
+ /** property of all jpa library provider install operation configs */
public static final String PROP_JPA_PLATFORM = "JPA_PLATFORM"; //$NON-NLS-1$
JpaPlatformDescription getJpaPlatform();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java
index 201b8e1df5..9b89e05d06 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/properties/JpaProjectPropertiesPage.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.jpa.ui.internal.properties;
import static org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi.createInstallLibraryPanel;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -67,9 +68,11 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.internal.JptCoreMessages;
+import org.eclipse.jpt.jpa.core.internal.platform.JpaPlatformDescriptionImpl;
import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.jpa.core.libprov.JpaLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformDescription;
+import org.eclipse.jpt.jpa.core.platform.JpaPlatformGroupDescription;
import org.eclipse.jpt.jpa.db.Catalog;
import org.eclipse.jpt.jpa.db.ConnectionAdapter;
import org.eclipse.jpt.jpa.db.ConnectionListener;
@@ -102,6 +105,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
/**
@@ -375,9 +379,61 @@ public class JpaProjectPropertiesPage
}
@Override
+ protected LibraryInstallDelegate createLibraryInstallDelegate(IFacetedProject project, IProjectFacetVersion fv) {
+ Map<String, Object> enablementVariables = new HashMap<String, Object>();
+
+ //TODO Ask Paul about these empty enablement variables - trying to reproduce Helios functionality
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, ""); //$NON-NLS-1$
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, new JpaPlatformDescription() {
+
+ public boolean supportsJpaFacetVersion(IProjectFacetVersion jpaFacetVersion) {
+ return false;
+ }
+
+ public boolean isDefault() {
+ return false;
+ }
+
+ public String getPluginId() {
+ return null;
+ }
+
+ public String getLabel() {
+ return null;
+ }
+
+ public String getId() {
+ return null;
+ }
+
+ public JpaPlatformGroupDescription getGroup() {
+ return null;
+ }
+
+ public String getFactoryClassName() {
+ return null;
+ }
+ });
+
+ LibraryInstallDelegate lid = new LibraryInstallDelegate(project, fv, enablementVariables);
+ lid.addListener(buildLibraryProviderListener());
+ return lid;
+ }
+
+ @Override
protected void adjustLibraryProviders() {
LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
+
if (lid != null) {
+ JpaPlatformDescription jpaPlatform =
+ JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatform(this.platformIdModel.getValue());
+ String jpaPlatformId = (jpaPlatform == null) ? "" : jpaPlatform.getId();
+
+ lid.setEnablementContextVariable(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, jpaPlatformId);
+ lid.setEnablementContextVariable(
+ JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, jpaPlatform);
+
List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
= new ArrayList<JpaLibraryProviderInstallOperationConfig>();
// add the currently selected one first
@@ -395,7 +451,7 @@ public class JpaProjectPropertiesPage
}
}
for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) {
- jpaConfig.setJpaPlatform(JptJpaCorePlugin.getJpaPlatformManager().getJpaPlatform(this.platformIdModel.getValue()));
+ jpaConfig.setJpaPlatform(jpaPlatform);
}
}
}
@@ -743,6 +799,10 @@ public class JpaProjectPropertiesPage
// user is unable to unset the platform, so no validation necessary
/* library provider */
+ IStatus lpStatus = validateLibraryProvider();
+ if (lpStatus != null){
+ statuses.get(Integer.valueOf(lpStatus.getSeverity())).add(lpStatus);
+ }
super.performValidation(statuses);
/* connection */
@@ -792,6 +852,22 @@ public class JpaProjectPropertiesPage
}
}
+ private IStatus validateLibraryProvider() {
+ LibraryInstallDelegate libInstallDelegate = getLibraryInstallDelegate();
+
+ if( libInstallDelegate != null ) {
+ Map<String, Object> enablementVariables = new HashMap<String, Object>();
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_ENABLEMENT_EXP, this.platformIdModel.getValue());
+ enablementVariables.put(JpaLibraryProviderInstallOperationConfig.JPA_PLATFORM_DESCRIPTION_ENABLEMENT_EXP, this.jpaProjectModel.getValue().getJpaPlatform().getDescription());
+
+ if (! libInstallDelegate.getLibraryProvider().isEnabledFor(
+ getFacetedProject(), getProjectFacetVersion(), enablementVariables)) {
+ return buildErrorStatus(JptCoreMessages.VALIDATE_LIBRARY_PROVIDER_INVALID);
+ }
+ }
+ return null;
+ }
+
// ********** UI model adapters **********

Back to the top