Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-12-09 04:34:25 +0000
committerpfullbright2010-12-09 04:34:25 +0000
commitd18b3557305b77a9536c69a0f11fbc37046a3216 (patch)
tree599fbb209526c461cd7597b8b95dfd0943e7e880
parentb37e86953a4a5e564d2706c7d6cb0303aea44048 (diff)
downloadwebtools.dali-d18b3557305b77a9536c69a0f11fbc37046a3216.tar.gz
webtools.dali-d18b3557305b77a9536c69a0f11fbc37046a3216.tar.xz
webtools.dali-d18b3557305b77a9536c69a0f11fbc37046a3216.zip
re-orged project properties/prefs; added jaxb project properties, facet version change
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF3
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java60
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java16
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/JptJaxbCoreMessages.java)20
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetConfig.java187
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetDelegate.java43
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java127
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDelegate.java38
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfig.java38
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfigFactory.java21
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeDelegate.java26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml70
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties3
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java408
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java147
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java166
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java21
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProperties.java28
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProvider.java261
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java253
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeConfigToDataModelAdapterFactory.java36
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProperties.java16
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProvider.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.properties7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.xml51
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java506
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JptProjectPropertiesPage.java423
37 files changed, 1991 insertions, 1059 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
index 458eeef0b6..4087ee44f2 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/META-INF/MANIFEST.MF
@@ -30,11 +30,12 @@ Export-Package: org.eclipse.jpt.jaxb.core,
org.eclipse.jpt.jaxb.core.internal.gen;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.jaxb21;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.jaxb22;x-internal:=true,
- org.eclipse.jpt.jaxb.core.internal.libprov;x-internal:=true,
+ org.eclipse.jpt.jaxb.core.internal.libprov,
org.eclipse.jpt.jaxb.core.internal.operations;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.platform;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.resource.java;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.resource.java.binary;x-internal:=true,
org.eclipse.jpt.jaxb.core.internal.resource.java.source;x-internal:=true,
+ org.eclipse.jpt.jaxb.core.internal.validation,
org.eclipse.jpt.jaxb.core.platform,
org.eclipse.jpt.jaxb.core.resource.java
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
index 5b364e6335..15818ef777 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
@@ -160,9 +160,7 @@
</action>
<action facet="jpt.jaxb" type="version-change" id="jpt.jaxb.version-change">
- <!--
- TODO - once there is config. This is here now to simply allow the version change.
- -->
+ <config-factory class="org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeConfigFactory"/>
<delegate class="org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeDelegate"/>
</action>
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
index 4e444c4aa0..4c36a685f3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
@@ -11,4 +11,7 @@
SchemaGenerator_creatingJAXBPropertiesFileTask = Creating jaxb.properties file
ClassesGenerator_generatingClasses = Generating JAXB Classes from Schema
-ClassesGenerator_generatingClassesTask = Generating classes \ No newline at end of file
+ClassesGenerator_generatingClassesTask = Generating classes
+
+JaxbFacetConfig_validatePlatformNotSpecified = Platform must be specified
+JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion = Platform does not support the current JAXB facet version
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
index e51fc631b4..7cd6b604c3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JptJaxbCorePlugin.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jaxb.core;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
@@ -18,8 +19,11 @@ import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.jaxb.core.internal.platform.JaxbPlatformManagerImpl;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformManager;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.osgi.framework.BundleContext;
+import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
/**
@@ -46,10 +50,15 @@ public class JptJaxbCorePlugin
public static final String PLUGIN_ID_ = PLUGIN_ID + '.';
/**
- * The key for storing a JAXB project's platform ID in the Eclipse project's preferences.
+ * The node for storing a JAXB project's platform in the project's preferences.
*/
- private static final String JAXB_PLATFORM_PREF_KEY = PLUGIN_ID_ + "jaxbPlatform"; //$NON-NLS-1$
-
+ public static final String PLATFORM_PREF_NODE = "platform"; //$NON-NLS-1$
+
+ /**
+ * The key for storing the platform id
+ */
+ public static final String PLATFORM_ID_PREF_KEY = "platform-id"; //$NON-NLS-1$
+
/**
* The key for storing the default JAXB platform ID for JAXB 2.1 in the workspace preferences.
*/
@@ -109,12 +118,18 @@ public class JptJaxbCorePlugin
return JaxbPlatformManagerImpl.instance();
}
-
- /**
- * Set the {@link JaxbPlatformDescription} associated with the specified Eclipse project.
- */
- public static void setJaxbPlatform(IProject project, JaxbPlatformDescription platform) {
- JptCorePlugin.setProjectPreference(project, JAXB_PLATFORM_PREF_KEY, platform.getId());
+ public static Preferences getProjectPreferences(IProject project) {
+ try {
+ IFacetedProject fproj = ProjectFacetsManager.create(project);
+ return fproj.getPreferences(JaxbFacet.FACET);
+ }
+ catch (BackingStoreException bse) {
+ log(bse);
+ }
+ catch (CoreException ce) {
+ log(ce);
+ }
+ return null;
}
/**
@@ -192,29 +207,34 @@ public class JptJaxbCorePlugin
* Return the JAXB platform ID associated with the specified Eclipse project.
*/
public static String getJaxbPlatformId(IProject project) {
- return JptCorePlugin.getProjectPreferences(project).get(JAXB_PLATFORM_PREF_KEY, GenericJaxbPlatform.VERSION_2_1.getId());
+ Preferences prefs = getProjectPreferences(project);
+ Preferences platformPrefs = prefs.node(PLATFORM_PREF_NODE);
+ return platformPrefs.get(PLATFORM_ID_PREF_KEY, GenericJaxbPlatform.VERSION_2_1.getId());
}
/**
- * Return the JAXB platform description associated with the specified Eclipse project.
+ * Return the {@link JaxbPlatformDescription} associated with the specified Eclipse project.
*/
public static JaxbPlatformDescription getJaxbPlatformDescription(IProject project) {
String jpaPlatformId = getJaxbPlatformId(project);
return getJaxbPlatformManager().getJaxbPlatform(jpaPlatformId);
}
-
+
/**
- * Set the JAXB platform ID associated with the specified Eclipse project.
+ * Set the {@link JaxbPlatformDescription} associated with the specified Eclipse project.
*/
- public static void setJaxbPlatformId(IProject project, String jpaPlatformId) {
- JptCorePlugin.setProjectPreference(project, JAXB_PLATFORM_PREF_KEY, jpaPlatformId);
- }
-
- public static void clearProjectPreferences(IProject project) {
- JptCorePlugin.clearProjectPreferences(project, JAXB_PLATFORM_PREF_KEY);
+ public static void setJaxbPlatform(IProject project, JaxbPlatformDescription platform) {
+ Preferences prefs = getProjectPreferences(project);
+ Preferences platformPrefs = prefs.node(PLATFORM_PREF_NODE);
+ platformPrefs.put(PLATFORM_ID_PREF_KEY, platform.getId());
+ try {
+ platformPrefs.flush();
+ }
+ catch (BackingStoreException bse) {
+ log(bse);
+ }
}
-
/**
* Log the specified status.
*/
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
index fc7a96ac32..176e8f0001 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
@@ -77,24 +77,24 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public abstract class AbstractJaxbProject
extends AbstractJaxbNode
- implements JaxbProject
-{
+ implements JaxbProject {
+
/**
* The Eclipse project corresponding to the JAXB project.
*/
protected final IProject project;
-
+
/**
* The vendor-specific JAXB platform that builds the JAXB project
* and all its contents.
*/
protected final JaxbPlatform jaxbPlatform;
-
+
/**
- * The JPA files associated with the JPA project:
- * persistence.xml
- * orm.xml
+ * The JAXB files associated with the JAXB project:
* java
+ * jaxb.index
+ * platform-specific files
*/
protected final Vector<JaxbFile> jaxbFiles = new Vector<JaxbFile>();
@@ -166,7 +166,7 @@ public abstract class AbstractJaxbProject
}
this.project = config.getProject();
this.jaxbPlatform = config.getJaxbPlatform();
-
+
this.modifySharedDocumentCommandExecutor = this.buildModifySharedDocumentCommandExecutor();
this.resourceModelListener = this.buildResourceModelListener();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/JptJaxbCoreMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
index 833543b626..eaf7920ee9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/JptJaxbCoreMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
@@ -7,31 +7,33 @@
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal.gen;
+package org.eclipse.jpt.jaxb.core.internal;
import org.eclipse.osgi.util.NLS;
/**
* Localized messages used by Dali JAXB Core.
- *
- * @version 3.0
*/
public class JptJaxbCoreMessages {
- public static String SchemaGenerator_creatingJAXBPropertiesFileTask;
-
public static String ClassesGenerator_generatingClasses;
public static String ClassesGenerator_generatingClassesTask;
-
-
+
+ public static String JaxbFacetConfig_validatePlatformNotSpecified;
+ public static String JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion;
+
+ public static String SchemaGenerator_creatingJAXBPropertiesFileTask;
+
+
private static final String BUNDLE_NAME = "jpt_jaxb_core"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptJaxbCoreMessages.class;
+
static {
NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
}
-
+
+
private JptJaxbCoreMessages() {
throw new UnsupportedOperationException();
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetConfig.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetConfig.java
new file mode 100644
index 0000000000..b89cb69406
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetConfig.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.core.internal.facet;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.wst.common.project.facet.core.ActionConfig;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public abstract class JaxbFacetConfig
+ extends ActionConfig {
+
+ private PropertyChangeSupport changeSupport;
+
+ public static final String FACETED_PROJECT_WORKING_COPY_PROPERTY = "facetedProjectWorkingCopy";
+
+ public static final String PROJECT_FACET_VERSION_PROPERTY = "projectFacetVersion";
+
+ public static final String PLATFORM_PROPERTY = "platform";
+ private JaxbPlatformDescription platform;
+
+ public static final String LIBRARY_INSTALL_DELEGATE_PROPERTY = "libraryInstallDelegate";
+ private LibraryInstallDelegate libraryInstallDelegate;
+
+
+
+ protected JaxbFacetConfig() {
+ super();
+ this.changeSupport = new PropertyChangeSupport(this);
+ }
+
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ this.changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ this.changeSupport.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public void setFacetedProjectWorkingCopy(IFacetedProjectWorkingCopy fpjwc) {
+ IFacetedProjectWorkingCopy oldFpjwc = getFacetedProjectWorkingCopy();
+ super.setFacetedProjectWorkingCopy(fpjwc);
+ this.changeSupport.firePropertyChange(FACETED_PROJECT_WORKING_COPY_PROPERTY, oldFpjwc, fpjwc);
+ }
+
+ @Override
+ public void setProjectFacetVersion(IProjectFacetVersion fv) {
+ IProjectFacetVersion oldFv = getProjectFacetVersion();
+ super.setProjectFacetVersion(fv);
+ this.changeSupport.firePropertyChange(PROJECT_FACET_VERSION_PROPERTY, oldFv, fv);
+ adjustLibraryProviders();
+ if (getLibraryInstallDelegate() != null && getLibraryInstallDelegate().getProjectFacetVersion().equals(getProjectFacetVersion())) {
+ getLibraryInstallDelegate().dispose();
+ setLibraryInstallDelegate(buildLibraryInstallDelegate());
+ }
+ }
+
+ public JaxbPlatformDescription getPlatform() {
+ if (this.platform != null) {
+ return this.platform;
+ }
+ return getExistingPlatform();
+ }
+
+ public void setPlatform(JaxbPlatformDescription platform) {
+ JaxbPlatformDescription oldPlatform = this.platform;
+ this.platform = platform;
+ this.changeSupport.firePropertyChange(PLATFORM_PROPERTY, oldPlatform, platform);
+ adjustLibraryProviders();
+ }
+
+ protected JaxbPlatformDescription getExistingPlatform() {
+ IProject project = getFacetedProjectWorkingCopy().getProject();
+ return (project == null) ? null : JptJaxbCorePlugin.getJaxbPlatformDescription(project);
+ }
+
+ public LibraryInstallDelegate getLibraryInstallDelegate() {
+ if (this.libraryInstallDelegate == null) {
+ this.libraryInstallDelegate = buildLibraryInstallDelegate();
+ }
+ return this.libraryInstallDelegate;
+ }
+
+ protected LibraryInstallDelegate buildLibraryInstallDelegate() {
+ IFacetedProjectWorkingCopy fpjwc = this.getFacetedProjectWorkingCopy();
+ if (fpjwc == null) {
+ return null;
+ }
+ IProjectFacetVersion pfv = this.getProjectFacetVersion();
+ if (pfv == null) {
+ return null;
+ }
+ LibraryInstallDelegate lid = new LibraryInstallDelegate(fpjwc, pfv);
+ lid.addListener(buildLibraryInstallDelegateListener());
+ return lid;
+ }
+
+ protected IPropertyChangeListener buildLibraryInstallDelegateListener() {
+ return new IPropertyChangeListener() {
+ public void propertyChanged(String property, Object oldValue, Object newValue ) {
+ if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
+ adjustLibraryProviders();
+ }
+ }
+ };
+ }
+
+ protected void adjustLibraryProviders() {
+ LibraryInstallDelegate lid = getLibraryInstallDelegate();
+ if (lid != null) {
+// List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
+// = new ArrayList<JpaLibraryProviderInstallOperationConfig>();
+// // add the currently selected one first
+// JpaLibraryProviderInstallOperationConfig currentJpaConfig = null;
+// LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig();
+// if (config instanceof JpaLibraryProviderInstallOperationConfig) {
+// currentJpaConfig = (JpaLibraryProviderInstallOperationConfig) config;
+// jpaConfigs.add(currentJpaConfig);
+// }
+// for (ILibraryProvider lp : lid.getLibraryProviders()) {
+// config = lid.getLibraryProviderOperationConfig(lp);
+// if (config instanceof JpaLibraryProviderInstallOperationConfig
+// && ! config.equals(currentJpaConfig)) {
+// jpaConfigs.add((JpaLibraryProviderInstallOperationConfig) config);
+// }
+// }
+// for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) {
+// jpaConfig.setJpaPlatformId(getPlatformId());
+// }
+ }
+ }
+
+ public void setLibraryInstallDelegate(LibraryInstallDelegate libraryInstallDelegate) {
+ LibraryInstallDelegate oldLibraryInstallDelegate = this.libraryInstallDelegate;
+ this.libraryInstallDelegate = libraryInstallDelegate;
+ this.changeSupport.firePropertyChange(
+ LIBRARY_INSTALL_DELEGATE_PROPERTY, oldLibraryInstallDelegate, libraryInstallDelegate);
+ }
+
+
+ // ********** validation **********
+
+ protected static IStatus OK_STATUS = Status.OK_STATUS;
+
+ protected static IStatus buildErrorStatus(String message) {
+ return buildStatus(IStatus.ERROR, message);
+ }
+
+ protected static IStatus buildStatus(int severity, String message) {
+ return new Status(severity, JptJaxbCorePlugin.PLUGIN_ID, message);
+ }
+
+
+ @Override
+ public IStatus validate() {
+ IStatus status = validatePlatform();
+ if (status.isOK()) {
+ status = this.libraryInstallDelegate.validate();
+ }
+
+ return status;
+ }
+
+ protected IStatus validatePlatform() {
+ return (getPlatform() == null) ?
+ buildErrorStatus(JptJaxbCoreMessages.JaxbFacetConfig_validatePlatformNotSpecified)
+ : OK_STATUS;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetDelegate.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetDelegate.java
new file mode 100644
index 0000000000..fab3be7448
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetDelegate.java
@@ -0,0 +1,43 @@
+package org.eclipse.jpt.jaxb.core.internal.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+
+public abstract class JaxbFacetDelegate
+ implements IDelegate {
+
+ public final void execute(
+ IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+
+ this.execute_(project, fv, config, monitor);
+ }
+
+ protected void execute_(
+ IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+
+ SubMonitor subMonitor = SubMonitor.convert(monitor, 7);
+
+ JaxbFacetConfig jaxbConfig = (JaxbFacetConfig) config;
+
+ // project settings
+ JaxbPlatformDescription platform = jaxbConfig.getPlatform();
+ JptJaxbCorePlugin.setJaxbPlatform(project, platform);
+ subMonitor.worked(1);
+
+ // defaults settings
+ JptJaxbCorePlugin.setDefaultJaxbPlatform(fv, platform);
+ subMonitor.worked(1);
+
+ //Delegate to LibraryInstallDelegate to configure the project classpath
+ jaxbConfig.getLibraryInstallDelegate().execute(subMonitor.newChild(1));
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
index 72802e9409..9f59aeca9e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallConfig.java
@@ -9,136 +9,11 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.facet;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.wst.common.project.facet.core.ActionConfig;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
public class JaxbFacetInstallConfig
- extends ActionConfig {
-
- private PropertyChangeSupport changeSupport;
-
- public static final String FACETED_PROJECT_WORKING_COPY_PROPERTY = "facetedProjectWorkingCopy";
-
- public static final String PROJECT_FACET_VERSION_PROPERTY = "projectFacetVersion";
-
- public static final String PLATFORM_PROPERTY = "platform";
- private JaxbPlatformDescription platform;
-
- public static final String LIBRARY_INSTALL_DELEGATE_PROPERTY = "libraryInstallDelegate";
- private LibraryInstallDelegate libraryInstallDelegate;
-
-
+ extends JaxbFacetConfig {
public JaxbFacetInstallConfig() {
super();
- this.changeSupport = new PropertyChangeSupport(this);
- }
-
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- this.changeSupport.addPropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- this.changeSupport.removePropertyChangeListener(listener);
- }
-
- @Override
- public void setFacetedProjectWorkingCopy(IFacetedProjectWorkingCopy fpjwc) {
- IFacetedProjectWorkingCopy oldFpjwc = getFacetedProjectWorkingCopy();
- super.setFacetedProjectWorkingCopy(fpjwc);
- this.changeSupport.firePropertyChange(FACETED_PROJECT_WORKING_COPY_PROPERTY, oldFpjwc, fpjwc);
- }
-
- @Override
- public void setProjectFacetVersion(IProjectFacetVersion fv) {
- IProjectFacetVersion oldFv = getProjectFacetVersion();
- super.setProjectFacetVersion(fv);
- this.changeSupport.firePropertyChange(PROJECT_FACET_VERSION_PROPERTY, oldFv, fv);
- adjustLibraryProviders();
- if (getLibraryInstallDelegate() != null && getLibraryInstallDelegate().getProjectFacetVersion().equals(getProjectFacetVersion())) {
- getLibraryInstallDelegate().dispose();
- setLibraryInstallDelegate(buildLibraryInstallDelegate());
- }
- }
-
- public JaxbPlatformDescription getPlatform() {
- return this.platform;
- }
-
- public void setPlatform(JaxbPlatformDescription platform) {
- JaxbPlatformDescription oldPlatform = this.platform;
- this.platform = platform;
- this.changeSupport.firePropertyChange(PLATFORM_PROPERTY, oldPlatform, platform);
- adjustLibraryProviders();
- }
-
- public LibraryInstallDelegate getLibraryInstallDelegate() {
- if (this.libraryInstallDelegate == null) {
- this.libraryInstallDelegate = buildLibraryInstallDelegate();
- }
- return this.libraryInstallDelegate;
- }
-
- protected LibraryInstallDelegate buildLibraryInstallDelegate() {
- IFacetedProjectWorkingCopy fpjwc = this.getFacetedProjectWorkingCopy();
- if (fpjwc == null) {
- return null;
- }
- IProjectFacetVersion pfv = this.getProjectFacetVersion();
- if (pfv == null) {
- return null;
- }
- LibraryInstallDelegate lid = new LibraryInstallDelegate(fpjwc, pfv);
- lid.addListener(buildLibraryInstallDelegateListener());
- return lid;
- }
-
- protected IPropertyChangeListener buildLibraryInstallDelegateListener() {
- return new IPropertyChangeListener() {
- public void propertyChanged(String property, Object oldValue, Object newValue ) {
- if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
- adjustLibraryProviders();
- }
- }
- };
- }
-
- protected void adjustLibraryProviders() {
- LibraryInstallDelegate lid = getLibraryInstallDelegate();
- if (lid != null) {
-// List<JpaLibraryProviderInstallOperationConfig> jpaConfigs
-// = new ArrayList<JpaLibraryProviderInstallOperationConfig>();
-// // add the currently selected one first
-// JpaLibraryProviderInstallOperationConfig currentJpaConfig = null;
-// LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig();
-// if (config instanceof JpaLibraryProviderInstallOperationConfig) {
-// currentJpaConfig = (JpaLibraryProviderInstallOperationConfig) config;
-// jpaConfigs.add(currentJpaConfig);
-// }
-// for (ILibraryProvider lp : lid.getLibraryProviders()) {
-// config = lid.getLibraryProviderOperationConfig(lp);
-// if (config instanceof JpaLibraryProviderInstallOperationConfig
-// && ! config.equals(currentJpaConfig)) {
-// jpaConfigs.add((JpaLibraryProviderInstallOperationConfig) config);
-// }
-// }
-// for (JpaLibraryProviderInstallOperationConfig jpaConfig : jpaConfigs) {
-// jpaConfig.setJpaPlatformId(getPlatformId());
-// }
- }
- }
-
- public void setLibraryInstallDelegate(LibraryInstallDelegate libraryInstallDelegate) {
- LibraryInstallDelegate oldLibraryInstallDelegate = this.libraryInstallDelegate;
- this.libraryInstallDelegate = libraryInstallDelegate;
- this.changeSupport.firePropertyChange(
- LIBRARY_INSTALL_DELEGATE_PROPERTY, oldLibraryInstallDelegate, libraryInstallDelegate);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDelegate.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDelegate.java
index 0fa6e8a733..7005f688a9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDelegate.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetInstallDelegate.java
@@ -9,44 +9,8 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal.facet;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
public class JaxbFacetInstallDelegate
- implements IDelegate {
-
- public final void execute(
- IProject project, IProjectFacetVersion fv,
- Object config, IProgressMonitor monitor) throws CoreException {
-
- this.execute_(project, fv, config, monitor);
- }
+ extends JaxbFacetDelegate {
- protected void execute_(
- IProject project, IProjectFacetVersion fv,
- Object config, IProgressMonitor monitor) throws CoreException {
-
- SubMonitor subMonitor = SubMonitor.convert(monitor, 7);
-
- JaxbFacetInstallConfig jaxbConfig = (JaxbFacetInstallConfig) config;
-
- // project settings
- JaxbPlatformDescription platform = jaxbConfig.getPlatform();
- JptJaxbCorePlugin.setJaxbPlatform(project, platform);
- subMonitor.worked(1);
-
- // defaults settings
- JptJaxbCorePlugin.setDefaultJaxbPlatform(fv, platform);
- subMonitor.worked(1);
-
- //Delegate to LibraryInstallDelegate to configure the project classpath
- jaxbConfig.getLibraryInstallDelegate().execute(subMonitor.newChild(1));
- }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
index 86229d8d5e..53e1d9a43c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetUninstallDelegate.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.jaxb.core.internal.facet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -23,6 +22,5 @@ public class JaxbFacetUninstallDelegate
public void execute(IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
- JptJaxbCorePlugin.clearProjectPreferences(project);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfig.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfig.java
new file mode 100644
index 0000000000..23a6610355
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfig.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.core.internal.facet;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
+
+
+public class JaxbFacetVersionChangeConfig
+ extends JaxbFacetConfig {
+
+ public JaxbFacetVersionChangeConfig() {
+ super();
+ }
+
+
+ // **************** validation ********************************************
+
+ @Override
+ protected IStatus validatePlatform() {
+ IStatus status = super.validatePlatform();
+
+ if (status.isOK()) {
+ if (! getPlatform().supportsJaxbFacetVersion(getProjectFacetVersion())) {
+ status = buildErrorStatus(JptJaxbCoreMessages.JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion);
+ }
+ }
+
+ return status;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfigFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfigFactory.java
new file mode 100644
index 0000000000..a11fce67fa
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeConfigFactory.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.core.internal.facet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.project.facet.core.IActionConfigFactory;
+
+public class JaxbFacetVersionChangeConfigFactory
+ implements IActionConfigFactory {
+
+ public Object create() throws CoreException {
+ return new JaxbFacetVersionChangeConfig();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeDelegate.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeDelegate.java
new file mode 100644
index 0000000000..2c7a4bc95f
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/facet/JaxbFacetVersionChangeDelegate.java
@@ -0,0 +1,26 @@
+package org.eclipse.jpt.jaxb.core.internal.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+
+public class JaxbFacetVersionChangeDelegate
+ extends JaxbFacetDelegate {
+
+ @Override
+ protected void execute_(
+ IProject project, IProjectFacetVersion fv, Object config,
+ IProgressMonitor monitor) throws CoreException {
+
+ SubMonitor sm = SubMonitor.convert(monitor, 2);
+ super.execute_(project, fv, config, sm.newChild(1));
+
+ JptJaxbCorePlugin.getProjectManager().rebuildJaxbProject(project);
+ sm.worked(1);
+ // nothing further to do here *just* yet
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java
index 1fb44212bd..7ed664d419 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.jpt.utility.internal.StringTools;
/**
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
index 473e918bb2..ea13340f02 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
@@ -39,6 +39,7 @@ import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jpt.core.internal.gen.AbstractJptGenerator;
import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.Bundle;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties
index d27ed4373f..8481687c67 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.properties
@@ -28,6 +28,8 @@ jaxbWizardCategoryName = JAXB
generateJaxbClasses = JAXB Classes...
+jaxbNode = JAXB
+
generateSchemaFromClassesName = Schema from JAXB Classes
generateSchemaFromClassesDesc = Generate a Schema from JAXB classes
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml
index a4aef2d893..5aed04abb3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/plugin.xml
@@ -26,6 +26,12 @@
<adapter type="org.eclipse.wst.common.frameworks.datamodel.IDataModel"/>
</factory>
+ <factory
+ class="org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetVersionChangeConfigToDataModelAdapterFactory"
+ adaptableType="org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeConfig">
+ <adapter type="org.eclipse.wst.common.frameworks.datamodel.IDataModel"/>
+ </factory>
+
</extension>
@@ -181,6 +187,66 @@
<extension
+ point="org.eclipse.ui.preferencePages">
+
+ <!-- no actual preferences yet
+ <page
+ id="org.eclipse.jpt.jaxb.ui.jaxbPreferences"
+ category="org.eclipse.jpt.ui.preferences"
+ class="org.eclipse.jpt.jaxb.ui.internal.preferences.JaxbPreferencesPage"
+ name="%jaxbNode"/>
+ -->
+
+ <!--
+ <page
+ id="org.eclipse.jpt.jaxb.ui.jaxbProblemSeveritiesPreferences"
+ category="org.eclipse.jpt.jaxb.ui.jaxbPreferences"
+ class="org.eclipse.jpt.jaxb.ui.internal.preferences.JaxbProblemSeveritiesPage"
+ name="%jaxbProblemSeveritiesNode">
+ </page>
+ -->
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.propertyPages">
+
+ <page
+ id="org.eclipse.jpt.jaxb.ui.jaxbProjectProperties"
+ name="%jaxbNode"
+ class="org.eclipse.jpt.jaxb.ui.internal.properties.JaxbProjectPropertiesPage">
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jaxb"/>
+ </adapt>
+ </enabledWhen>
+ </page>
+
+ <!--
+ <page
+ id="org.eclipse.jpt.ui.jaxbProblemSeveritiesProperties"
+ name="%jaxbProblemSeveritiesNode"
+ category="org.eclipse.jpt.jaxb.ui.jaxbProjectProperties"
+ class="org.eclipse.jpt.jaxb.ui.internal.preferences.JaxbProblemSeveritiesPage">
+ <enabledWhen>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jaxb"/>
+ </adapt>
+ </enabledWhen>
+ </page>
+ -->
+
+ </extension>
+
+
+ <extension
point="org.eclipse.wst.common.project.facet.ui.images">
<image facet="jpt.jaxb" path="icons/full/etool16/jaxb_facet.gif"/>
@@ -195,6 +261,10 @@
<page class="org.eclipse.jpt.jaxb.ui.internal.wizards.facet.JaxbFacetInstallPage"/>
</wizard-pages>
+ <wizard-pages action="jpt.jaxb.version-change">
+ <page class="org.eclipse.jpt.jaxb.ui.internal.wizards.facet.JaxbFacetVersionChangePage"/>
+ </wizard-pages>
+
</extension>
</plugin>
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
index f6d00bea92..d2d3dca5b7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
@@ -140,6 +140,5 @@ JaxbProjectWizard_firstPage_desc = Configure JAXB project settings.
JaxbFacetWizardPage_title = JAXB Facet
JaxbFacetWizardPage_desc = Configure JAXB settings.
JaxbFacetWizardPage_platformLabel = &Platform
+JaxbFacetWizardPage_facetsPageLink = <a>Change JAXB version ...</a>
JaxbFacetWizardPage_jaxbImplementationLabel = JAXB implementation
-
-JaxbFacetDataModel_validatePlatformNotSpecified = Platform must be specified
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
index e2e54d257e..ef457c3d21 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
@@ -141,11 +141,9 @@ public class JptJaxbUiMessages {
public static String JaxbFacetWizardPage_title;
public static String JaxbFacetWizardPage_desc;
public static String JaxbFacetWizardPage_platformLabel;
+ public static String JaxbFacetWizardPage_facetsPageLink;
public static String JaxbFacetWizardPage_jaxbImplementationLabel;
- public static String JaxbFacetDataModel_validatePlatformNotSpecified;
-
-
private static final String BUNDLE_NAME = "jpt_jaxb_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptJaxbUiMessages.class;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java
new file mode 100644
index 0000000000..243476d058
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/properties/JaxbProjectPropertiesPage.java
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.jaxb.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.List;
+import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.jaxb.core.JaxbFacet;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.libprov.JaxbLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
+import org.eclipse.jpt.ui.internal.properties.JptProjectPropertiesPage;
+import org.eclipse.jpt.ui.internal.utility.swt.SWTTools;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.utility.internal.model.value.AspectPropertyValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.BufferedWritablePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.CompositeCollectionValueModel;
+import org.eclipse.jpt.utility.internal.model.value.PropertyCollectionValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SetCollectionValueModel;
+import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.StaticCollectionValueModel;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.event.CollectionAddEvent;
+import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.listener.CollectionChangeAdapter;
+import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import com.ibm.icu.text.Collator;
+
+/**
+ * Way more complicated UI than you would think....
+ */
+public class JaxbProjectPropertiesPage
+ extends JptProjectPropertiesPage {
+
+ public static final String PROP_ID = "org.eclipse.jpt.jaxb.ui.jaxbProjectPropertiesPage"; //$NON-NLS-1$
+
+ private PropertyValueModel<JaxbProject> jaxbProjectModel;
+
+ private BufferedWritablePropertyValueModel<JaxbPlatformDescription> platformModel;
+ private PropertyChangeListener platformListener;
+
+
+ @SuppressWarnings("unchecked")
+ /* private */ static final Comparator<String> STRING_COMPARATOR = Collator.getInstance();
+
+
+ // ************ construction ************
+
+ public JaxbProjectPropertiesPage() {
+ super();
+ }
+
+
+ @Override
+ protected void buildModels() {
+ this.jaxbProjectModel = new JaxbProjectModel(this.projectModel);
+
+ this.platformModel = this.buildPlatformModel();
+ this.platformListener = this.buildPlatformListener();
+ }
+
+
+ // ***** platform ID model
+
+ private BufferedWritablePropertyValueModel<JaxbPlatformDescription> buildPlatformModel() {
+ return new BufferedWritablePropertyValueModel<JaxbPlatformDescription>(
+ new PlatformModel(this.jaxbProjectModel), this.trigger);
+ }
+
+ private PropertyChangeListener buildPlatformListener(){
+ return new PropertyChangeListener() {
+ public void propertyChanged(PropertyChangeEvent event) {
+ JaxbProjectPropertiesPage.this.platformChanged((JaxbPlatformDescription) event.getNewValue());
+ }
+ };
+ }
+
+ void platformChanged(JaxbPlatformDescription newPlatform) {
+ if ( ! this.getControl().isDisposed()) {
+ // handle null, in the case the jpa facet is changed via the facets page,
+ // the library install delegate is temporarily null
+ adjustLibraryProviders();
+ }
+ }
+
+
+ // ********** LibraryFacetPropertyPage implementation **********
+
+ @Override
+ public IProjectFacetVersion getProjectFacetVersion() {
+ return this.getFacetedProject().getInstalledVersion(JaxbFacet.FACET);
+ }
+
+ @Override
+ protected void adjustLibraryProviders() {
+ LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
+ if (lid != null) {
+ List<JaxbLibraryProviderInstallOperationConfig> jaxbConfigs
+ = new ArrayList<JaxbLibraryProviderInstallOperationConfig>();
+ // add the currently selected one first
+ JaxbLibraryProviderInstallOperationConfig currentJaxbConfig = null;
+ LibraryProviderOperationConfig config = lid.getLibraryProviderOperationConfig();
+ if (config instanceof JaxbLibraryProviderInstallOperationConfig) {
+ currentJaxbConfig = (JaxbLibraryProviderInstallOperationConfig) config;
+ jaxbConfigs.add(currentJaxbConfig);
+ }
+ for (ILibraryProvider lp : lid.getLibraryProviders()) {
+ config = lid.getLibraryProviderOperationConfig(lp);
+ if (config instanceof JaxbLibraryProviderInstallOperationConfig
+ && ! config.equals(currentJaxbConfig)) {
+ jaxbConfigs.add((JaxbLibraryProviderInstallOperationConfig) config);
+ }
+ }
+ for (JaxbLibraryProviderInstallOperationConfig jaxbConfig : jaxbConfigs) {
+ jaxbConfig.setJaxbPlatform(this.platformModel.getValue());
+ }
+ }
+ }
+
+
+ // ********** page **********
+
+ @Override
+ protected void createWidgets(Composite parent) {
+ buildPlatformGroup(parent);
+
+ Control libraryProviderComposite = createInstallLibraryPanel(
+ parent,
+ getLibraryInstallDelegate(),
+ JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel);
+
+ libraryProviderComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JaxbHelpContextIds.PROPERTIES_JAVA_PERSISTENCE);
+ }
+
+ @Override
+ protected void engageListeners() {
+ super.engageListeners();
+ this.platformModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.platformListener);
+ }
+
+ @Override
+ public void disengageListeners() {
+ this.platformModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformListener);
+ super.disengageListeners();
+ }
+
+
+ // ********** platform group **********
+
+ private void buildPlatformGroup(Composite composite) {
+ Group group = new Group(composite, SWT.NONE);
+ group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Combo platformDropDown = this.buildDropDown(group);
+ SWTTools.bind(
+ buildPlatformChoicesModel(),
+ this.platformModel,
+ platformDropDown,
+ JAXB_PLATFORM_LABEL_CONVERTER);
+
+ buildFacetsPageLink(group, JptJaxbUiMessages.JaxbFacetWizardPage_facetsPageLink);
+ }
+
+ /**
+ * Add the project's JAXB platform if it is not on the list of valid
+ * platforms.
+ * <p>
+ * This is probably only useful if the project is corrupted
+ * and has a platform that exists in the registry but is not on the
+ * list of valid platforms for the project's JAXB facet version.
+ * Because, if the project's JAXB platform is completely invalid, there
+ * would be no JAXB project!
+ */
+ @SuppressWarnings("unchecked")
+ private ListValueModel<JaxbPlatformDescription> buildPlatformChoicesModel() {
+ return new SortedListValueModelAdapter<JaxbPlatformDescription>(
+ new SetCollectionValueModel<JaxbPlatformDescription>(
+ new CompositeCollectionValueModel<CollectionValueModel<JaxbPlatformDescription>, JaxbPlatformDescription>(
+ new PropertyCollectionValueModelAdapter<JaxbPlatformDescription>(this.platformModel),
+ buildRegistryPlatformsModel())),
+ JAXB_PLATFORM_COMPARATOR);
+ }
+
+ private CollectionValueModel<JaxbPlatformDescription> buildRegistryPlatformsModel() {
+ Iterable<JaxbPlatformDescription> enabledPlatforms =
+ new FilteringIterable<JaxbPlatformDescription>(
+ JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatforms()) {
+ @Override
+ protected boolean accept(JaxbPlatformDescription o) {
+ return o.supportsJaxbFacetVersion(getProjectFacetVersion());
+ }
+ };
+ return new StaticCollectionValueModel<JaxbPlatformDescription>(enabledPlatforms);
+ }
+
+ private static final Comparator<JaxbPlatformDescription> JAXB_PLATFORM_COMPARATOR =
+ new Comparator<JaxbPlatformDescription>() {
+ public int compare(JaxbPlatformDescription desc1, JaxbPlatformDescription desc2) {
+ return STRING_COMPARATOR.compare(desc1.getLabel(), desc2.getLabel());
+ }
+ };
+
+ private static final StringConverter<JaxbPlatformDescription> JAXB_PLATFORM_LABEL_CONVERTER =
+ new StringConverter<JaxbPlatformDescription>() {
+ public String convertToString(JaxbPlatformDescription desc) {
+ return desc.getLabel();
+ }
+ };
+
+
+ // ********** OK/Revert/Apply behavior **********
+
+ @Override
+ protected boolean projectRebuildRequired() {
+ return this.platformModel.isBuffering();
+ }
+
+ @Override
+ protected void rebuildProject() {
+ // if the JAXB platform is changed, we need to completely rebuild the JAXB project
+ JptJaxbCorePlugin.getProjectManager().rebuildJaxbProject(getProject());
+ }
+
+ @Override
+ protected BufferedWritablePropertyValueModel<?>[] buildBufferedModels() {
+ return new BufferedWritablePropertyValueModel[] {
+ this.platformModel
+ };
+ }
+
+
+ // ********** validation **********
+
+ @Override
+ protected Model[] buildValidationModels() {
+ return new Model[] {
+ platformModel
+ };
+ }
+
+ @Override
+ protected void performValidation(Map<Integer, ArrayList<IStatus>> statuses) {
+ /* platform */
+ // user is unable to unset the platform, so no validation necessary
+
+ /* library provider */
+ super.performValidation(statuses);
+ }
+
+
+ // ********** UI model adapters **********
+
+ /**
+ * Treat the JAXB project as an "aspect" of the Eclipse project (IProject);
+ * but the JAXB project is stored in the JAXB model, not the Eclipse project
+ * itself....
+ * We also need to listen for the JAXB project to be rebuilt if the user
+ * changes the Eclipse project's JAXB platform (which is stored in the
+ * Eclipse project's preferences).
+ */
+ static class JaxbProjectModel
+ extends AspectPropertyValueModelAdapter<IProject, JaxbProject> {
+
+// /**
+// * The JAXB project's platform is stored as a preference.
+// * If it changes, a new JAXB project is built.
+// */
+// private final IPreferenceChangeListener preferenceChangeListener;
+
+ /**
+ * The JAXB project may also change via another page (notably, the project facets page).
+ * In that case, the preference change occurs before we actually have another project,
+ * so we must listen to the projects manager
+ */
+ private final CollectionChangeListener projectManagerListener;
+
+
+ JaxbProjectModel(PropertyValueModel<IProject> projectModel) {
+ super(projectModel);
+// this.preferenceChangeListener = buildPreferenceChangeListener();
+ this.projectManagerListener = buildProjectManagerListener();
+ }
+
+// private IPreferenceChangeListener buildPreferenceChangeListener() {
+// return new IPreferenceChangeListener() {
+// public void preferenceChange(PreferenceChangeEvent event) {
+// if (event.getKey().equals(JptJaxbCorePlugin.JAXB_PLATFORM_PREF_KEY)) {
+// platformChanged();
+// }
+// }
+// @Override
+// public String toString() {
+// return "preference change listener"; //$NON-NLS-1$
+// }
+// };
+// }
+
+ private CollectionChangeListener buildProjectManagerListener() {
+ return new CollectionChangeAdapter() {
+ // we are only looking for the project rebuild *add* event here so we can
+ // determine if the platform has changed.
+ // the other events are unimportant in this case
+ @Override
+ public void itemsAdded(CollectionAddEvent event) {
+ platformChanged();
+ }
+ };
+ }
+
+ void platformChanged() {
+ this.propertyChanged();
+ }
+
+ @Override
+ protected void engageSubject_() {
+// getPreferences().addPreferenceChangeListener(this.preferenceChangeListener);
+ JptJaxbCorePlugin.getProjectManager().addCollectionChangeListener(
+ JaxbProjectManager.JAXB_PROJECTS_COLLECTION,
+ this.projectManagerListener);
+ }
+
+ @Override
+ protected void disengageSubject_() {
+// getPreferences().removePreferenceChangeListener(this.preferenceChangeListener);
+ JptJaxbCorePlugin.getProjectManager().removeCollectionChangeListener(
+ JaxbProjectManager.JAXB_PROJECTS_COLLECTION,
+ this.projectManagerListener);
+ }
+
+ @Override
+ protected JaxbProject buildValue_() {
+ return JptJaxbCorePlugin.getJaxbProject(this.subject);
+ }
+
+// private IEclipsePreferences getPreferences() {
+// return JptCorePlugin.getProjectPreferences(this.subject);
+// }
+ }
+
+
+ /**
+ * Treat the JAXB platform as an "aspect" of the JAXB project.
+ * The platform ID is stored in the project preferences.
+ * The platform ID does not change for a JAXB project - if the user wants a
+ * different platform, we build an entirely new JAXB project.
+ */
+ static class PlatformModel
+ extends AspectPropertyValueModelAdapter<JaxbProject, JaxbPlatformDescription> {
+
+ PlatformModel(PropertyValueModel<JaxbProject> jaxbProjectModel) {
+ super(jaxbProjectModel);
+ }
+
+ @Override
+ protected JaxbPlatformDescription buildValue_() {
+ return this.subject.getJaxbPlatform().getDescription();
+ }
+
+ @Override
+ public void setValue_(JaxbPlatformDescription newPlatform) {
+ JptJaxbCorePlugin.setJaxbPlatform(this.subject.getProject(), newPlatform);
+ }
+
+ @Override
+ protected void engageSubject_() {
+ // the platform ID does not change
+ }
+
+ @Override
+ protected void disengageSubject_() {
+ // the platform ID does not change
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java
index 54fb896f49..dbae27a4fa 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetInstallPage.java
@@ -9,158 +9,13 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.ui.internal.wizards.facet;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
import org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetInstallDataModelProperties;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage;
-
public class JaxbFacetInstallPage
- extends DataModelFacetInstallPage
+ extends JaxbFacetPage
implements JaxbFacetInstallDataModelProperties {
public JaxbFacetInstallPage() {
super("jpt.jaxb.facet.install.page");
- setTitle(JptJaxbUiMessages.JaxbFacetWizardPage_title);
- setDescription(JptJaxbUiMessages.JaxbFacetWizardPage_desc);
- setImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER));
- }
-
-
- @Override
- public void setConfig(Object config) {
- if (! (config instanceof IDataModel)) {
- config = Platform.getAdapterManager().loadAdapter(config, IDataModel.class.getName());
- }
- super.setConfig(config);
- }
-
- @Override
- protected Composite createTopLevelComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- addSubComposites(composite);
-
- Dialog.applyDialogFont(parent);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.DIALOG_JPA_FACET);
-
- return composite;
- }
-
- protected void addSubComposites(Composite composite) {
- new PlatformGroup(composite);
- new ClasspathConfigGroup(composite);
- }
-
- protected Button createButton(Composite container, int span, String text, int style) {
- Button button = new Button(container, SWT.NONE | style);
- button.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = span;
- button.setLayoutData(gd);
- return button;
- }
-
- protected Combo createCombo(Composite container, int span, boolean fillHorizontal) {
- Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
- GridData gd;
- if (fillHorizontal) {
- gd = new GridData(GridData.FILL_HORIZONTAL);
- }
- else {
- gd = new GridData();
- }
- gd.horizontalSpan = span;
- combo.setLayoutData(gd);
- return combo;
- }
-
- @Override
- protected String[] getValidationPropertyNames() {
- return new String[] {
- PLATFORM,
- LIBRARY_INSTALL_DELEGATE
- };
- }
-
- @Override
- public boolean isPageComplete() {
- if (! super.isPageComplete()) {
- return false;
- }
- else {
- IStatus status = this.model.validate();
- if (status.getSeverity() == IStatus.ERROR) {
- setErrorMessage(status.getMessage());
- return false;
- };
- setErrorMessage(null);
- return true;
- }
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible) {
- setErrorMessage();
- }
- }
-
- protected final IWorkbenchHelpSystem getHelpSystem() {
- return PlatformUI.getWorkbench().getHelpSystem();
- }
-
-
- protected final class PlatformGroup
- {
- private final Combo platformCombo;
-
-
- public PlatformGroup(Composite composite) {
- Group group = new Group(composite, SWT.NONE);
- group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_JPA_PLATFORM);
-
- this.platformCombo = createCombo(group, 1, true);
- JaxbFacetInstallPage.this.synchHelper.synchCombo(platformCombo, PLATFORM, null);
- }
- }
-
-
- protected final class ClasspathConfigGroup {
-
- public ClasspathConfigGroup(Composite composite) {
-
- LibraryInstallDelegate librariesInstallDelegate
- = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_INSTALL_DELEGATE);
-
- Composite librariesComposite
- = (Composite) LibraryProviderFrameworkUi.createInstallLibraryPanel(
- composite, librariesInstallDelegate,
- JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel);
- librariesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(librariesComposite, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH);
- }
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java
new file mode 100644
index 0000000000..99d5dcdb17
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetPage.java
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
+import org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetDataModelProperties;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetInstallPage;
+
+
+public abstract class JaxbFacetPage
+ extends DataModelFacetInstallPage
+ implements JaxbFacetDataModelProperties {
+
+ protected JaxbFacetPage(String pageName) {
+ super(pageName);
+ setTitle(JptJaxbUiMessages.JaxbFacetWizardPage_title);
+ setDescription(JptJaxbUiMessages.JaxbFacetWizardPage_desc);
+ setImageDescriptor(JptJaxbUiPlugin.getImageDescriptor(JptJaxbUiIcons.JAXB_WIZ_BANNER));
+ }
+
+
+ @Override
+ public void setConfig(Object config) {
+ if (! (config instanceof IDataModel)) {
+ config = Platform.getAdapterManager().loadAdapter(config, IDataModel.class.getName());
+ }
+ super.setConfig(config);
+ }
+
+ @Override
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+
+ addSubComposites(composite);
+
+ Dialog.applyDialogFont(parent);
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.DIALOG_JPA_FACET);
+
+ return composite;
+ }
+
+ protected void addSubComposites(Composite composite) {
+ new PlatformGroup(composite);
+ new ClasspathConfigGroup(composite);
+ }
+
+ protected Button createButton(Composite container, int span, String text, int style) {
+ Button button = new Button(container, SWT.NONE | style);
+ button.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ button.setLayoutData(gd);
+ return button;
+ }
+
+ protected Combo createCombo(Composite container, int span, boolean fillHorizontal) {
+ Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+ GridData gd;
+ if (fillHorizontal) {
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ }
+ else {
+ gd = new GridData();
+ }
+ gd.horizontalSpan = span;
+ combo.setLayoutData(gd);
+ return combo;
+ }
+
+ @Override
+ protected String[] getValidationPropertyNames() {
+ return new String[] {
+ PLATFORM,
+ LIBRARY_INSTALL_DELEGATE
+ };
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ if (! super.isPageComplete()) {
+ return false;
+ }
+ else {
+ IStatus status = this.model.validate();
+ if (status.getSeverity() == IStatus.ERROR) {
+ setErrorMessage(status.getMessage());
+ return false;
+ };
+ setErrorMessage(null);
+ return true;
+ }
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ setErrorMessage();
+ }
+ }
+
+ protected final IWorkbenchHelpSystem getHelpSystem() {
+ return PlatformUI.getWorkbench().getHelpSystem();
+ }
+
+
+ protected final class PlatformGroup
+ {
+ private final Combo platformCombo;
+
+
+ public PlatformGroup(Composite composite) {
+ Group group = new Group(composite, SWT.NONE);
+ group.setText(JptJaxbUiMessages.JaxbFacetWizardPage_platformLabel);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(group, JpaHelpContextIds.DIALOG_JPA_PLATFORM);
+
+ this.platformCombo = createCombo(group, 1, true);
+ JaxbFacetPage.this.synchHelper.synchCombo(platformCombo, PLATFORM, null);
+ }
+ }
+
+
+ protected final class ClasspathConfigGroup {
+
+ public ClasspathConfigGroup(Composite composite) {
+
+ LibraryInstallDelegate librariesInstallDelegate
+ = (LibraryInstallDelegate) getDataModel().getProperty(LIBRARY_INSTALL_DELEGATE);
+
+ Composite librariesComposite
+ = (Composite) LibraryProviderFrameworkUi.createInstallLibraryPanel(
+ composite, librariesInstallDelegate,
+ JptJaxbUiMessages.JaxbFacetWizardPage_jaxbImplementationLabel);
+ librariesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(librariesComposite, JpaHelpContextIds.NEW_JPA_PROJECT_CONTENT_PAGE_CLASSPATH);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java
new file mode 100644
index 0000000000..4f11932622
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/JaxbFacetVersionChangePage.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet;
+
+import org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model.JaxbFacetVersionChangeDataModelProperties;
+
+public class JaxbFacetVersionChangePage
+ extends JaxbFacetPage
+ implements JaxbFacetVersionChangeDataModelProperties {
+
+ public JaxbFacetVersionChangePage() {
+ super("jpt.jaxb.facet.versionChange.page");
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProperties.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProperties.java
new file mode 100644
index 0000000000..61957b2f39
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProperties.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet.model;
+
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties;
+
+public interface JaxbFacetDataModelProperties
+ extends IDataModelProperties {
+
+ static final String PREFIX_
+ = JaxbFacetDataModelProperties.class.getSimpleName() + "."; //$NON-NLS-1$
+
+ public static final String JAXB_FACET_INSTALL_CONFIG
+ = PREFIX_ + "JAVA_FACET_INSTALL_CONFIG"; //$NON-NLS-1$
+
+ public static final String PLATFORM
+ = PREFIX_ + "PLATFORM"; //$NON-NLS-1$
+
+ public static final String LIBRARY_INSTALL_DELEGATE
+ = PREFIX_ + "LIBRARY_INSTALL_DELEGATE"; //$NON-NLS-1$
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProvider.java
new file mode 100644
index 0000000000..5e7126d77e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetDataModelProvider.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet.model;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Comparator;
+import java.util.Set;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jpt.jaxb.core.JaxbFacet;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetConfig;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+
+
+public abstract class JaxbFacetDataModelProvider
+ extends FacetInstallDataModelProvider
+ implements JaxbFacetDataModelProperties {
+
+ protected static final DataModelPropertyDescriptor[] EMPTY_DMPD_ARRAY = new DataModelPropertyDescriptor[0];
+
+
+ protected static final Comparator<DataModelPropertyDescriptor> DMPD_COMPARATOR =
+ new Comparator<DataModelPropertyDescriptor>() {
+ public int compare(DataModelPropertyDescriptor dmpd1, DataModelPropertyDescriptor dmpd2) {
+ return dmpd1.getPropertyDescription().compareTo(dmpd2.getPropertyDescription());
+ }
+ };
+
+
+ private JaxbFacetConfig config;
+
+ private PropertyChangeListener configListener;
+
+ private IPropertyChangeListener libraryInstallDelegateListener;
+
+
+ protected JaxbFacetDataModelProvider(JaxbFacetConfig config) {
+ super();
+ this.config = config;
+ this.configListener = buildConfigListener();
+ this.config.addPropertyChangeListener(this.configListener);
+ this.libraryInstallDelegateListener = buildLibraryInstallDelegateListener();
+ }
+
+
+ protected PropertyChangeListener buildConfigListener() {
+ return new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals(JaxbFacetConfig.FACETED_PROJECT_WORKING_COPY_PROPERTY)) {
+
+ }
+ else if (evt.getPropertyName().equals(JaxbFacetConfig.PROJECT_FACET_VERSION_PROPERTY)) {
+ if (! isPropertySet(PLATFORM)) {
+ JaxbFacetDataModelProvider.this.config.setPlatform(getDefaultPlatform());
+ }
+ }
+ else if (evt.getPropertyName().equals(JaxbFacetConfig.LIBRARY_INSTALL_DELEGATE_PROPERTY)) {
+ LibraryInstallDelegate oldLid = (LibraryInstallDelegate) evt.getOldValue();
+ if (oldLid != null) {
+ oldLid.removeListener(JaxbFacetDataModelProvider.this.libraryInstallDelegateListener);
+ }
+ LibraryInstallDelegate newLid = (LibraryInstallDelegate) evt.getNewValue();
+ if (newLid != null) {
+ newLid.addListener(JaxbFacetDataModelProvider.this.libraryInstallDelegateListener);
+ }
+ setLibraryInstallDelegate(newLid);
+ }
+ }
+ };
+ }
+
+ protected IPropertyChangeListener buildLibraryInstallDelegateListener() {
+ return new IPropertyChangeListener() {
+ public void propertyChanged(String property, Object oldValue, Object newValue ) {
+ JaxbFacetDataModelProvider.this.getDataModel().notifyPropertyChange(
+ LIBRARY_INSTALL_DELEGATE, IDataModel.VALUE_CHG);
+ }
+ };
+ }
+
+ @Override
+ public Set getPropertyNames() {
+ Set names = super.getPropertyNames();
+ names.add(JAXB_FACET_INSTALL_CONFIG);
+ names.add(PLATFORM);
+ names.add(LIBRARY_INSTALL_DELEGATE);
+ return names;
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ getDataModel().setProperty(JAXB_FACET_INSTALL_CONFIG, this.config);
+
+ if (this.config.getPlatform() != null) {
+ getDataModel().setProperty(PLATFORM, this.config.getPlatform());
+ }
+ else {
+ this.config.setPlatform(getDefaultPlatform());
+ }
+
+ if (this.config.getLibraryInstallDelegate() != null) {
+ getDataModel().setProperty(LIBRARY_INSTALL_DELEGATE, this.config.getLibraryInstallDelegate());
+ this.config.getLibraryInstallDelegate().addListener(this.libraryInstallDelegateListener);
+ }
+ }
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(FACET_ID)) {
+ return JaxbFacet.ID;
+ }
+ else if (propertyName.equals(PLATFORM)) {
+ return getDefaultPlatform();
+ }
+ else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) {
+ // means that library install delegate has not been initialized
+ LibraryInstallDelegate lid = this.config.getLibraryInstallDelegate();
+ setLibraryInstallDelegate(lid);
+ return lid;
+ }
+
+ return super.getDefaultProperty(propertyName);
+ }
+
+ protected JaxbPlatformDescription getDefaultPlatform() {
+ return JptJaxbCorePlugin.getDefaultPlatform(getProjectFacetVersion());
+ }
+
+ @Override
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ boolean ok = super.propertySet(propertyName, propertyValue);
+
+ if (propertyName.equals(FACET_VERSION)) {
+ this.model.notifyPropertyChange(PLATFORM, IDataModel.DEFAULT_CHG);
+ }
+ else if (propertyName.equals(FACETED_PROJECT_WORKING_COPY)) {
+ getFacetedProjectWorkingCopy().addListener(
+ new IFacetedProjectListener() {
+ public void handleEvent(IFacetedProjectEvent event) {
+ LibraryInstallDelegate lid = getLibraryInstallDelegate();
+ if (lid != null) {
+ // may be null while model is being built up
+ // ... or in tests
+ lid.refresh();
+ }
+ }
+ },
+ IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
+ }
+ else if (propertyName.equals(JAXB_FACET_INSTALL_CONFIG)) {
+ return false;
+ }
+ else if (propertyName.equals(PLATFORM)) {
+ this.config.setPlatform((JaxbPlatformDescription) propertyValue);
+ }
+ else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) {
+ this.config.setLibraryInstallDelegate((LibraryInstallDelegate) propertyValue);
+ }
+
+ return ok;
+ }
+
+ @Override
+ public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
+ if (propertyName.equals(PLATFORM)) {
+ return this.buildValidPlatformDescriptors();
+ }
+
+ return super.getValidPropertyDescriptors(propertyName);
+ }
+
+ protected DataModelPropertyDescriptor[] buildValidPlatformDescriptors() {
+ Iterable<JaxbPlatformDescription> validPlatformDescriptions = buildValidPlatformDescriptions();
+ Iterable<DataModelPropertyDescriptor> validPlatformDescriptors =
+ new TransformationIterable<JaxbPlatformDescription, DataModelPropertyDescriptor>(validPlatformDescriptions) {
+ @Override
+ protected DataModelPropertyDescriptor transform(JaxbPlatformDescription description) {
+ return buildPlatformDescriptor(description);
+ }
+ };
+ return ArrayTools.sort(ArrayTools.array(validPlatformDescriptors, EMPTY_DMPD_ARRAY), DMPD_COMPARATOR);
+ }
+
+ protected Iterable<JaxbPlatformDescription> buildValidPlatformDescriptions() {
+ return new FilteringIterable<JaxbPlatformDescription>(
+ JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatforms()) {
+ @Override
+ protected boolean accept(JaxbPlatformDescription o) {
+ return o.supportsJaxbFacetVersion(getProjectFacetVersion());
+ }
+ };
+ }
+
+ @Override
+ public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
+ if (propertyName.equals(PLATFORM)) {
+ return buildPlatformDescriptor(getPlatform());
+ }
+
+ return super.getPropertyDescriptor(propertyName);
+ }
+
+ protected DataModelPropertyDescriptor buildPlatformDescriptor(JaxbPlatformDescription desc) {
+ return new DataModelPropertyDescriptor(desc, desc.getLabel());
+ }
+
+ @Override
+ public IStatus validate(String propertyName) {
+ return this.config.validate();
+ }
+
+ protected IFacetedProjectWorkingCopy getFacetedProjectWorkingCopy() {
+ return (IFacetedProjectWorkingCopy) this.config.getFacetedProjectWorkingCopy();
+ }
+
+ protected IProjectFacetVersion getProjectFacetVersion() {
+ return (IProjectFacetVersion) this.config.getProjectFacetVersion();
+ }
+
+ protected JaxbPlatformDescription getPlatform() {
+ return (JaxbPlatformDescription) getProperty(PLATFORM);
+ }
+
+ protected LibraryInstallDelegate getLibraryInstallDelegate() {
+ return (LibraryInstallDelegate) getProperty(LIBRARY_INSTALL_DELEGATE);
+ }
+
+ protected void setLibraryInstallDelegate(LibraryInstallDelegate lid) {
+ getDataModel().setProperty(LIBRARY_INSTALL_DELEGATE, lid);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ this.config.removePropertyChangeListener(this.configListener);
+ if (this.config.getLibraryInstallDelegate() != null) {
+ this.config.getLibraryInstallDelegate().removeListener(this.libraryInstallDelegateListener);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java
index be2889ea9d..98ae9b5765 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProperties.java
@@ -9,17 +9,8 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties;
public interface JaxbFacetInstallDataModelProperties
- extends IDataModelProperties {
+ extends JaxbFacetDataModelProperties {
- public static final String JAXB_FACET_INSTALL_CONFIG
- = "JaxbFacetInstallDataModelProperties.JAVA_FACET_INSTALL_CONFIG"; //$NON-NLS-1$
-
- public static final String PLATFORM
- = "JaxbFacetInstallDataModelProperties.PLATFORM"; //$NON-NLS-1$
-
- public static final String LIBRARY_INSTALL_DELEGATE
- = "JaxbFacetInstallDataModelProperties.LIBRARY_INSTALL_DELEGATE"; //$NON-NLS-1$
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java
index e80ad2037c..750f80f586 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetInstallDataModelProvider.java
@@ -9,266 +9,17 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.ui.internal.wizards.facet.model;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Comparator;
-import java.util.Set;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.jaxb.core.JaxbFacet;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallConfig;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
-import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
-import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
public class JaxbFacetInstallDataModelProvider
- extends FacetInstallDataModelProvider
+ extends JaxbFacetDataModelProvider
implements JaxbFacetInstallDataModelProperties {
- protected static final DataModelPropertyDescriptor[] EMPTY_DMPD_ARRAY = new DataModelPropertyDescriptor[0];
-
-
- protected static final Comparator<DataModelPropertyDescriptor> DMPD_COMPARATOR =
- new Comparator<DataModelPropertyDescriptor>() {
- public int compare(DataModelPropertyDescriptor dmpd1, DataModelPropertyDescriptor dmpd2) {
- return dmpd1.getPropertyDescription().compareTo(dmpd2.getPropertyDescription());
- }
- };
-
- protected static IStatus buildErrorStatus(String message) {
- return buildStatus(IStatus.ERROR, message);
- }
-
- protected static IStatus buildStatus(int severity, String message) {
- return new Status(severity, JptJaxbUiPlugin.PLUGIN_ID, message);
- }
-
-
- private JaxbFacetInstallConfig config;
-
- private PropertyChangeListener configListener;
-
- private IPropertyChangeListener libraryInstallDelegateListener;
-
-
public JaxbFacetInstallDataModelProvider() {
this(new JaxbFacetInstallConfig());
}
public JaxbFacetInstallDataModelProvider(JaxbFacetInstallConfig config) {
- super();
- this.config = config;
- this.configListener = buildConfigListener();
- this.config.addPropertyChangeListener(this.configListener);
- this.libraryInstallDelegateListener = buildLibraryInstallDelegateListener();
- }
-
-
- protected PropertyChangeListener buildConfigListener() {
- return new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals(JaxbFacetInstallConfig.FACETED_PROJECT_WORKING_COPY_PROPERTY)) {
-
- }
- else if (evt.getPropertyName().equals(JaxbFacetInstallConfig.LIBRARY_INSTALL_DELEGATE_PROPERTY)) {
- LibraryInstallDelegate oldLid = (LibraryInstallDelegate) evt.getOldValue();
- if (oldLid != null) {
- oldLid.removeListener(JaxbFacetInstallDataModelProvider.this.libraryInstallDelegateListener);
- }
- LibraryInstallDelegate newLid = (LibraryInstallDelegate) evt.getNewValue();
- if (newLid != null) {
- newLid.addListener(JaxbFacetInstallDataModelProvider.this.libraryInstallDelegateListener);
- }
- setLibraryInstallDelegate(newLid);
- }
- }
- };
- }
-
- protected IPropertyChangeListener buildLibraryInstallDelegateListener() {
- return new IPropertyChangeListener() {
- public void propertyChanged(String property, Object oldValue, Object newValue ) {
- JaxbFacetInstallDataModelProvider.this.getDataModel().notifyPropertyChange(
- LIBRARY_INSTALL_DELEGATE, IDataModel.VALUE_CHG);
- }
- };
- }
-
- @Override
- public Set getPropertyNames() {
- Set names = super.getPropertyNames();
- names.add(JAXB_FACET_INSTALL_CONFIG);
- names.add(PLATFORM);
- names.add(LIBRARY_INSTALL_DELEGATE);
- return names;
- }
-
- @Override
- public void init() {
- super.init();
- getDataModel().setProperty(JAXB_FACET_INSTALL_CONFIG, this.config);
- if (this.config.getPlatform() != null) {
- getDataModel().setProperty(PLATFORM, this.config.getPlatform());
- }
- else {
- this.config.setPlatform(getDefaultPlatform());
- }
- }
-
- @Override
- public Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(FACET_ID)) {
- return JaxbFacet.ID;
- }
- else if (propertyName.equals(PLATFORM)) {
- return getDefaultPlatform();
- }
- else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) {
- // means that library install delegate has not been initialized
- LibraryInstallDelegate lid = this.config.getLibraryInstallDelegate();
- setLibraryInstallDelegate(lid);
- return lid;
- }
-
- return super.getDefaultProperty(propertyName);
- }
-
- protected JaxbPlatformDescription getDefaultPlatform() {
- return JptJaxbCorePlugin.getDefaultPlatform(getProjectFacetVersion());
- }
-
- @Override
- public boolean propertySet(String propertyName, Object propertyValue) {
- boolean ok = super.propertySet(propertyName, propertyValue);
-
- if (propertyName.equals(FACET_VERSION)) {
- this.model.notifyPropertyChange(PLATFORM, IDataModel.DEFAULT_CHG);
- }
- else if (propertyName.equals(FACETED_PROJECT_WORKING_COPY)) {
- getFacetedProjectWorkingCopy().addListener(
- new IFacetedProjectListener() {
- public void handleEvent(IFacetedProjectEvent event) {
- LibraryInstallDelegate lid = getLibraryInstallDelegate();
- if (lid != null) {
- // may be null while model is being built up
- // ... or in tests
- lid.refresh();
- }
- }
- },
- IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
- }
- else if (propertyName.equals(JAXB_FACET_INSTALL_CONFIG)) {
- return false;
- }
- else if (propertyName.equals(PLATFORM)) {
- this.config.setPlatform((JaxbPlatformDescription) propertyValue);
- }
- else if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) {
- this.config.setLibraryInstallDelegate((LibraryInstallDelegate) propertyValue);
- }
-
- return ok;
- }
-
- @Override
- public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
- if (propertyName.equals(PLATFORM)) {
- return this.buildValidPlatformDescriptors();
- }
-
- return super.getValidPropertyDescriptors(propertyName);
- }
-
- protected DataModelPropertyDescriptor[] buildValidPlatformDescriptors() {
- Iterable<JaxbPlatformDescription> validPlatformDescriptions = buildValidPlatformDescriptions();
- Iterable<DataModelPropertyDescriptor> validPlatformDescriptors =
- new TransformationIterable<JaxbPlatformDescription, DataModelPropertyDescriptor>(validPlatformDescriptions) {
- @Override
- protected DataModelPropertyDescriptor transform(JaxbPlatformDescription description) {
- return buildPlatformDescriptor(description);
- }
- };
- return ArrayTools.sort(ArrayTools.array(validPlatformDescriptors, EMPTY_DMPD_ARRAY), DMPD_COMPARATOR);
- }
-
- protected Iterable<JaxbPlatformDescription> buildValidPlatformDescriptions() {
- return new FilteringIterable<JaxbPlatformDescription>(
- JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatforms()) {
- @Override
- protected boolean accept(JaxbPlatformDescription o) {
- return o.supportsJaxbFacetVersion(getProjectFacetVersion());
- }
- };
- }
-
- @Override
- public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
- if (propertyName.equals(PLATFORM)) {
- return buildPlatformDescriptor(getPlatform());
- }
-
- return super.getPropertyDescriptor(propertyName);
- }
-
- protected DataModelPropertyDescriptor buildPlatformDescriptor(JaxbPlatformDescription desc) {
- return new DataModelPropertyDescriptor(desc, desc.getLabel());
- }
-
- @Override
- public IStatus validate(String propertyName) {
- if (propertyName.equals(PLATFORM)) {
- return validatePlatform();
- }
- if (propertyName.equals(LIBRARY_INSTALL_DELEGATE)) {
- return getLibraryInstallDelegate().validate();
- }
-
- return super.validate(propertyName);
- }
-
- protected IStatus validatePlatform() {
- return (getPlatform() == null) ?
- buildErrorStatus(JptJaxbUiMessages.JaxbFacetDataModel_validatePlatformNotSpecified)
- : OK_STATUS;
- }
-
- protected IFacetedProjectWorkingCopy getFacetedProjectWorkingCopy() {
- return (IFacetedProjectWorkingCopy) this.config.getFacetedProjectWorkingCopy();
- }
-
- protected IProjectFacetVersion getProjectFacetVersion() {
- return (IProjectFacetVersion) this.config.getProjectFacetVersion();
- }
-
- protected JaxbPlatformDescription getPlatform() {
- return (JaxbPlatformDescription) getProperty(PLATFORM);
- }
-
- protected LibraryInstallDelegate getLibraryInstallDelegate() {
- return (LibraryInstallDelegate) getProperty(LIBRARY_INSTALL_DELEGATE);
- }
-
- protected void setLibraryInstallDelegate(LibraryInstallDelegate lid) {
- getDataModel().setProperty(LIBRARY_INSTALL_DELEGATE, lid);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- this.config.removePropertyChangeListener(this.configListener);
+ super(config);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeConfigToDataModelAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeConfigToDataModelAdapterFactory.java
new file mode 100644
index 0000000000..dc74680868
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeConfigToDataModelAdapterFactory.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet.model;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeConfig;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+
+public class JaxbFacetVersionChangeConfigToDataModelAdapterFactory
+ implements IAdapterFactory {
+
+ private static final Class<?>[] ADAPTER_LIST = new Class[] { IDataModel.class };
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObj, Class adapterType) {
+ if (adapterType == IDataModel.class) {
+ JaxbFacetVersionChangeDataModelProvider provider
+ = new JaxbFacetVersionChangeDataModelProvider((JaxbFacetVersionChangeConfig) adaptableObj);
+ return DataModelFactory.createDataModel( provider );
+ }
+
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProperties.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProperties.java
new file mode 100644
index 0000000000..60e7749baa
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProperties.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet.model;
+
+
+public interface JaxbFacetVersionChangeDataModelProperties
+ extends JaxbFacetDataModelProperties {
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProvider.java
new file mode 100644
index 0000000000..e8ab670c10
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/facet/model/JaxbFacetVersionChangeDataModelProvider.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.jaxb.ui.internal.wizards.facet.model;
+
+import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetVersionChangeConfig;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
+
+public class JaxbFacetVersionChangeDataModelProvider
+ extends JaxbFacetDataModelProvider
+ implements JaxbFacetVersionChangeDataModelProperties {
+
+ public JaxbFacetVersionChangeDataModelProvider() {
+ this(new JaxbFacetVersionChangeConfig());
+ }
+
+ public JaxbFacetVersionChangeDataModelProvider(JaxbFacetVersionChangeConfig config) {
+ super(config);
+ }
+
+
+ @Override
+ protected Iterable<JaxbPlatformDescription> buildValidPlatformDescriptions() {
+ // add existing platform to list of choices
+ Iterable<JaxbPlatformDescription> validPlatformDescs = super.buildValidPlatformDescriptions();
+ if (! CollectionTools.contains(validPlatformDescs, getPlatform())) {
+ validPlatformDescs = new CompositeIterable(getPlatform(), validPlatformDescs);
+ }
+ return validPlatformDescs;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
index 33f99933b5..479f5e555c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
@@ -57,10 +57,9 @@ synchronizeClasses = Synchronize Class List
makePersistent = Make Persistent...
persistenceEditor=Persistence XML Editor
-jpaProblemSeveritiesPageName=Errors/Warnings
-jpaPreferencePage = Java Persistence
-
-jpaProjectPropertiesPage = Java Persistence
+javaPersistenceNode = Java Persistence
+jpaNode = JPA
+jpaProblemSeveritiesNode = Errors/Warnings
jpaPerspective = JPA
jpaPerspectiveDescription = This perspective is designed to support Java Persistence (JPA) development. It offers a Project Explorer, JPA Details, JPA Structure and a Data Source Explorer.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
index 0d982e5861..205e41443a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
@@ -937,15 +937,20 @@
<page
id="org.eclipse.jpt.ui.preferences"
- class="org.eclipse.jpt.ui.internal.preferences.JpaPreferencesPage"
- name="%jpaPreferencePage">
- </page>
+ name="%javaPersistenceNode"
+ class="org.eclipse.ui.internal.dialogs.EmptyPreferencePage"/>
<page
+ id="org.eclipse.jpt.ui.jpaPreferences"
category="org.eclipse.jpt.ui.preferences"
+ class="org.eclipse.jpt.ui.internal.preferences.JpaPreferencesPage"
+ name="%jpaNode"/>
+
+ <page
+ id="org.eclipse.jpt.ui.jpaProblemSeveritiesPreferences"
+ category="org.eclipse.jpt.ui.jpaPreferences"
class="org.eclipse.jpt.ui.internal.preferences.JpaProblemSeveritiesPage"
- id="org.eclipse.jpt.ui.preferences.problemSeverities"
- name="%jpaProblemSeveritiesPageName">
+ name="%jpaProblemSeveritiesNode">
</page>
</extension>
@@ -955,35 +960,37 @@
point="org.eclipse.ui.propertyPages">
<page
- id="org.eclipse.jpt.ui.jpaProjectPropertiesPage"
- name="%jpaProjectPropertiesPage"
+ id="org.eclipse.jpt.ui.jpaProjectProperties"
+ name="%jpaNode"
class="org.eclipse.jpt.ui.internal.properties.JpaProjectPropertiesPage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- forcePluginActivation="true"
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jpa"/>
+ </adapt>
</enabledWhen>
</page>
+
<page
- id="org.eclipse.jpt.ui.propertyPages.problemSeverities"
- name="%jpaProblemSeveritiesPageName"
- category="org.eclipse.jpt.ui.jpaProjectPropertiesPage"
- class="org.eclipse.jpt.ui.internal.preferences.JpaProblemSeveritiesPage">
+ id="org.eclipse.jpt.ui.jpaProblemSeveritiesProperties"
+ name="%jpaProblemSeveritiesNode"
+ category="org.eclipse.jpt.ui.jpaProjectProperties"
+ class="org.eclipse.jpt.ui.internal.preferences.JpaProblemSeveritiesPage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- forcePluginActivation="true"
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jpa"/>
+ </adapt>
</enabledWhen>
</page>
+
</extension>
-
+
<extension
point="org.eclipse.ui.views">
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
index 1372744239..74ea6c47dc 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
@@ -129,7 +129,7 @@ JpaMakePersistentWizardPage_selectedTypesPersistentError=All selected types are
JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The XML mapping file does not exist
JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError=The XML mapping file is not listed in the persistence.xml
-JpaPreferencesPage_Description=Expand the tree to edit preferences for a specific feature.
+JpaPreferencesPage_Description=Expand the tree to edit preferences for a particular JPA feature.
JpaProblemSeveritiesPage_Description=Select the severity level for the following optional Java Persistence validation problems:
JpaProblemSeveritiesPage_Error=Error
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
index 9db0bd2b57..780ab61833 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
@@ -116,13 +116,13 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
* The unique identifier for this page when it is shown in the IDE
* preferences dialog.
*/
- private static final String JPT_PREFERENCES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.preferences.problemSeverities"; //$NON-NLS-1$
+ private static final String JPT_PREFERENCES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.jpaProblemSeveritiesPreferences"; //$NON-NLS-1$
/**
* The unique identifier for this page when it is shown in the project
* preferences dialog.
*/
- private static final String JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.propertyPages.problemSeverities"; //$NON-NLS-1$
+ private static final String JPT_PROPERTY_PAGES_PROBLEM_SEVERITIES_ID = "org.eclipse.jpt.ui.jpaProblemSeveritiesProperties"; //$NON-NLS-1$
/**
* A constant used to store and retrieve the preference key (message ID) from
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
index 9723b4c729..1eb3537aab 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
@@ -10,34 +10,19 @@
package org.eclipse.jpt.ui.internal.properties;
import static org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderFrameworkUi.createInstallLibraryPanel;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jpt.core.JpaDataSource;
import org.eclipse.jpt.core.JpaFacet;
import org.eclipse.jpt.core.JpaProject;
@@ -63,7 +48,6 @@ import org.eclipse.jpt.ui.internal.jpa2.Jpa2_0ProjectFlagModel;
import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
import org.eclipse.jpt.ui.internal.util.SWTUtil;
import org.eclipse.jpt.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.BitTools;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.NotBooleanTransformer;
@@ -83,7 +67,6 @@ import org.eclipse.jpt.utility.internal.model.value.ExtendedListValueModelWrappe
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.PropertyCollectionValueModelAdapter;
import org.eclipse.jpt.utility.internal.model.value.SetCollectionValueModel;
-import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
import org.eclipse.jpt.utility.internal.model.value.StaticCollectionValueModel;
import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
@@ -91,26 +74,21 @@ import org.eclipse.jpt.utility.internal.model.value.TransformationWritableProper
import org.eclipse.jpt.utility.model.Model;
import org.eclipse.jpt.utility.model.event.CollectionAddEvent;
import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.utility.model.listener.ChangeListener;
import org.eclipse.jpt.utility.model.listener.CollectionChangeAdapter;
import org.eclipse.jpt.utility.model.listener.CollectionChangeListener;
import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.utility.model.listener.SimpleChangeListener;
import org.eclipse.jpt.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
-import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
-import org.eclipse.jst.common.project.facet.ui.libprov.LibraryFacetPropertyPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -122,54 +100,48 @@ 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;
-import org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage;
-
import com.ibm.icu.text.Collator;
/**
* Way more complicated UI than you would think....
*/
public class JpaProjectPropertiesPage
- extends LibraryFacetPropertyPage
-{
- public static final String PROP_ID = "org.eclipse.jpt.ui.jpaProjectPropertiesPage"; //$NON-NLS-1$
-
- private final WritablePropertyValueModel<IProject> projectModel;
- private final PropertyValueModel<JpaProject> jpaProjectModel;
- private final BufferedWritablePropertyValueModel.Trigger trigger;
-
- private final BufferedWritablePropertyValueModel<String> platformIdModel;
- private final PropertyChangeListener platformIdListener;
-
- private final BufferedWritablePropertyValueModel<String> connectionModel;
- private final PropertyValueModel<ConnectionProfile> connectionProfileModel;
- private final PropertyValueModel<Boolean> disconnectedModel;
- private final PropertyChangeListener disconnectedModelListener;
+ extends JptProjectPropertiesPage {
+
+ public static final String PROP_ID = "org.eclipse.jpt.ui.jpaProjectProperties"; //$NON-NLS-1$
+
+ private PropertyValueModel<JpaProject> jpaProjectModel;
+
+ private BufferedWritablePropertyValueModel<String> platformIdModel;
+ private PropertyChangeListener platformIdListener;
+
+ private BufferedWritablePropertyValueModel<String> connectionModel;
+ private PropertyValueModel<ConnectionProfile> connectionProfileModel;
+ private PropertyValueModel<Boolean> disconnectedModel;
+ private PropertyChangeListener disconnectedModelListener;
private Link connectLink;
-
- private final BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultCatalogFlagModel;
- private final BufferedWritablePropertyValueModel<String> userOverrideDefaultCatalogModel;
- private final WritablePropertyValueModel<String> defaultCatalogModel;
- private final ListValueModel<String> catalogChoicesModel;
-
- private final BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultSchemaFlagModel;
- private final BufferedWritablePropertyValueModel<String> userOverrideDefaultSchemaModel;
- private final WritablePropertyValueModel<String> defaultSchemaModel;
- private final ListValueModel<String> schemaChoicesModel;
-
- private final BufferedWritablePropertyValueModel<Boolean> discoverAnnotatedClassesModel;
- private final WritablePropertyValueModel<Boolean> listAnnotatedClassesModel;
-
- private final PropertyValueModel<Boolean> jpa2_0ProjectFlagModel;
-
- private final BufferedWritablePropertyValueModel<String> metamodelSourceFolderModel;
- private final ListValueModel<String> javaSourceFolderChoicesModel;
+
+ private BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultCatalogFlagModel;
+ private BufferedWritablePropertyValueModel<String> userOverrideDefaultCatalogModel;
+ private WritablePropertyValueModel<String> defaultCatalogModel;
+ private ListValueModel<String> catalogChoicesModel;
+
+ private BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultSchemaFlagModel;
+ private BufferedWritablePropertyValueModel<String> userOverrideDefaultSchemaModel;
+ private WritablePropertyValueModel<String> defaultSchemaModel;
+ private ListValueModel<String> schemaChoicesModel;
+
+ private BufferedWritablePropertyValueModel<Boolean> discoverAnnotatedClassesModel;
+ private WritablePropertyValueModel<Boolean> listAnnotatedClassesModel;
+
+ private PropertyValueModel<Boolean> jpa2_0ProjectFlagModel;
+
+ private BufferedWritablePropertyValueModel<String> metamodelSourceFolderModel;
+ private ListValueModel<String> javaSourceFolderChoicesModel;
+
private static final String BUILD_PATHS_PROPERTY_PAGE_ID = "org.eclipse.jdt.ui.propertyPages.BuildPathsPropertyPage"; //$NON-NLS-1$
-
- private final ChangeListener validationListener;
-
+
@SuppressWarnings("unchecked")
/* private */ static final Comparator<String> STRING_COMPARATOR = Collator.getInstance();
@@ -179,15 +151,15 @@ public class JpaProjectPropertiesPage
public JpaProjectPropertiesPage() {
super();
-
- this.projectModel = new SimplePropertyValueModel<IProject>();
+ }
+
+ @Override
+ protected void buildModels() {
this.jpaProjectModel = new JpaProjectModel(this.projectModel);
- this.trigger = new BufferedWritablePropertyValueModel.Trigger();
-
+
this.platformIdModel = this.buildPlatformIdModel();
this.platformIdListener = this.buildPlatformIdListener();
- this.platformIdModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener);
-
+
this.connectionModel = this.buildConnectionModel();
this.connectionProfileModel = this.buildConnectionProfileModel();
this.disconnectedModel = this.buildDisconnectedModel();
@@ -210,9 +182,6 @@ public class JpaProjectPropertiesPage
this.metamodelSourceFolderModel = this.buildMetamodelSourceFolderModel();
this.javaSourceFolderChoicesModel = this.buildJavaSourceFolderChoicesModel();
-
- this.validationListener = this.buildValidationListener();
- this.engageValidationListener();
}
// ***** platform ID model
@@ -383,11 +352,6 @@ public class JpaProjectPropertiesPage
return flagIsSet(this.userOverrideDefaultCatalogFlagModel);
}
- /* private */ static boolean flagIsSet(PropertyValueModel<Boolean> flagModel) {
- Boolean flag = flagModel.getValue();
- return (flag != null) && flag.booleanValue();
- }
-
private String getUserOverrideDefaultCatalog() {
return this.userOverrideDefaultCatalogModel.getValue();
}
@@ -411,24 +375,8 @@ public class JpaProjectPropertiesPage
public IProjectFacetVersion getProjectFacetVersion() {
return this.getFacetedProject().getInstalledVersion(JpaFacet.FACET);
}
-
- @Override
- protected LibraryInstallDelegate createLibraryInstallDelegate(IFacetedProject project, IProjectFacetVersion fv) {
- LibraryInstallDelegate lid = new LibraryInstallDelegate(project, fv, null);
- lid.addListener(buildLibraryProviderListener());
- return lid;
- }
-
- protected IPropertyChangeListener buildLibraryProviderListener() {
- return new IPropertyChangeListener() {
- public void propertyChanged(String property, Object oldValue, Object newValue ) {
- if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
- adjustLibraryProviders();
- }
- }
- };
- }
+ @Override
protected void adjustLibraryProviders() {
LibraryInstallDelegate lid = this.getLibraryInstallDelegate();
if (lid != null) {
@@ -456,50 +404,40 @@ public class JpaProjectPropertiesPage
// ********** page **********
-
+
@Override
- protected Control createPageContents(Composite parent) {
- this.projectModel.setValue(this.getProject());
+ protected void createWidgets(Composite parent) {
+ this.buildPlatformGroup(parent);
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
-
- this.buildPlatformGroup(composite);
-
Control libraryProviderComposite = createInstallLibraryPanel(
- composite,
+ parent,
this.getLibraryInstallDelegate(),
JptUiMessages.JpaFacetWizardPage_jpaImplementationLabel);
-
+
libraryProviderComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- this.buildConnectionGroup(composite);
- this.buildPersistentClassManagementGroup(composite);
- this.buildMetamodelGroup(composite);
-
- Dialog.applyDialogFont(composite);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE);
+
+ this.buildConnectionGroup(parent);
+ this.buildPersistentClassManagementGroup(parent);
+ this.buildMetamodelGroup(parent);
- adjustLibraryProviders();
- this.updateValidation();
-
- return composite;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE);
}
-
- /**
- * Don't allow {@link org.eclipse.jface.preference.PreferencePage#computeSize()}
- * to cache the page's size, since the size of the "Library" panel can
- * change depending on the user's selection from the drop-down list.
- */
+
@Override
- public Point computeSize() {
- return this.doComputeSize();
+ protected void engageListeners() {
+ super.engageListeners();
+ this.platformIdModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener);
+ this.disconnectedModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
}
-
-
+
+ @Override
+ protected void disengageListeners() {
+ this.platformIdModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener);
+ this.disconnectedModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
+ super.disengageListeners();
+ }
+
+
// ********** platform group **********
private void buildPlatformGroup(Composite composite) {
@@ -507,35 +445,15 @@ public class JpaProjectPropertiesPage
group.setText(JptUiMessages.JpaFacetWizardPage_platformLabel);
group.setLayout(new GridLayout());
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Combo platformDropDown = this.buildDropDown(group);
+
+ Combo platformDropDown = buildDropDown(group);
SWTTools.bind(
- this.buildPlatformChoicesModel(),
+ buildPlatformChoicesModel(),
this.platformIdModel,
platformDropDown,
- JPA_PLATFORM_LABEL_CONVERTER
- );
+ JPA_PLATFORM_LABEL_CONVERTER);
- Link facetsPageLink = this.buildLink(group, JptUiMessages.JpaFacetWizardPage_facetsPageLink);
- facetsPageLink.addSelectionListener(this.buildFacetsPageLinkListener()); // the link will be GCed
- System.out.println(facetsPageLink.isEnabled());
- }
-
- private SelectionListener buildFacetsPageLinkListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- JpaProjectPropertiesPage.this.openProjectFacetsPage();
- }
- @Override
- public String toString() {
- return "facets page link listener"; //$NON-NLS-1$
- }
- };
- }
-
- protected void openProjectFacetsPage() {
- ((IWorkbenchPreferenceContainer)getContainer()).openPage(FacetsPropertyPage.ID, null);
+ buildFacetsPageLink(group, JptUiMessages.JpaFacetWizardPage_facetsPageLink);
}
/**
@@ -623,8 +541,7 @@ public class JpaProjectPropertiesPage
this.connectLink = this.buildLink(group, buildConnectLinkText());
SWTTools.controlEnabledState(this.disconnectedModel, this.connectLink);
this.connectLink.addSelectionListener(this.buildConnectLinkListener()); // the link will be GCed
- this.disconnectedModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
-
+
// override default catalog
Button overrideDefaultCatalogCheckBox = this.buildCheckBox(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultCatalogLabel);
SWTTools.bind(this.userOverrideDefaultCatalogFlagModel, overrideDefaultCatalogCheckBox);
@@ -779,134 +696,21 @@ public class JpaProjectPropertiesPage
container.openPage(BUILD_PATHS_PROPERTY_PAGE_ID, null);
}
- // ********** widgets **********
-
- private Button buildCheckBox(Composite parent, int horizontalSpan, String text) {
- return this.buildButton(parent, horizontalSpan, text, SWT.CHECK);
- }
-
- private Button buildRadioButton(Composite parent, int horizontalSpan, String text) {
- return this.buildButton(parent, horizontalSpan, text, SWT.RADIO);
- }
-
- private Button buildButton(Composite parent, int horizontalSpan, String text, int style) {
- Button button = new Button(parent, SWT.NONE | style);
- button.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = horizontalSpan;
- button.setLayoutData(gd);
- return button;
- }
-
- private Combo buildDropDown(Composite parent) {
- return this.buildDropDown(parent, 1);
- }
-
- private Combo buildDropDown(Composite parent, int horizontalSpan) {
- Combo combo = new Combo(parent, SWT.READ_ONLY);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = horizontalSpan;
- combo.setLayoutData(gd);
- return combo;
- }
-
- private Label buildLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = 1;
- label.setLayoutData(gd);
- return label;
- }
-
- private Link buildLink(Composite parent, String text) {
- Link link = new Link(parent, SWT.NONE);
- GridData data = new GridData(GridData.END, GridData.CENTER, false, false);
- data.horizontalSpan = 2;
- link.setLayoutData(data);
- link.setText(text);
- return link;
- }
-
-
// ********** OK/Revert/Apply behavior **********
-
+
@Override
- public boolean performOk() {
- super.performOk();
-
- try {
- // true=fork; false=uncancellable
- this.buildOkProgressMonitorDialog().run(true, false, this.buildOkRunnableWithProgress());
- }
- catch (InterruptedException ex) {
- return false;
- }
- catch (InvocationTargetException ex) {
- throw new RuntimeException(ex.getTargetException());
- }
-
- return true;
- }
-
- private IRunnableContext buildOkProgressMonitorDialog() {
- return new ProgressMonitorDialog(this.getShell());
- }
-
- private IRunnableWithProgress buildOkRunnableWithProgress() {
- return new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- IWorkspace ws = ResourcesPlugin.getWorkspace();
- try {
- // the build we execute in #performOk_() locks the workspace root,
- // so we need to use the workspace root as our scheduling rule here
- ws.run(
- JpaProjectPropertiesPage.this.buildOkWorkspaceRunnable(),
- ws.getRoot(),
- IWorkspace.AVOID_UPDATE,
- monitor
- );
- }
- catch (CoreException ex) {
- throw new InvocationTargetException(ex);
- }
- }
- };
- }
-
- /* private */ IWorkspaceRunnable buildOkWorkspaceRunnable() {
- return new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- JpaProjectPropertiesPage.this.performOk_(monitor);
- }
- };
- }
-
- void performOk_(IProgressMonitor monitor) throws CoreException {
- if (this.isBuffering()) {
- boolean platformChanged = this.platformIdModel.isBuffering();
- this.trigger.accept();
- if (platformChanged) {
- // if the JPA platform is changed, we need to completely rebuild the JPA project
- JptCorePlugin.rebuildJpaProject(this.getProject());
- }
- this.getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
- }
+ protected boolean projectRebuildRequired() {
+ return this.platformIdModel.isBuffering();
}
-
- /**
- * Return whether any of the models are buffering a change.
- */
- private boolean isBuffering() {
- for (BufferedWritablePropertyValueModel<?> model : this.buildBufferedModels()) {
- if (model.isBuffering()) {
- return true;
- }
- }
- return false;
+
+ @Override
+ protected void rebuildProject() {
+ // if the JPA platform is changed, we need to completely rebuild the JPA project
+ JptCorePlugin.rebuildJpaProject(this.getProject());
}
-
- private BufferedWritablePropertyValueModel<?>[] buildBufferedModels() {
+
+ @Override
+ protected BufferedWritablePropertyValueModel<?>[] buildBufferedModels() {
return new BufferedWritablePropertyValueModel[] {
this.platformIdModel,
this.connectionModel,
@@ -918,53 +722,12 @@ public class JpaProjectPropertiesPage
this.metamodelSourceFolderModel
};
}
-
- @Override
- protected void performDefaults() {
- super.performDefaults();
- this.trigger.reset();
- }
-
-
- // ********** dispose **********
-
- @Override
- public void dispose() {
- this.disengageValidationListener();
- this.platformIdModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener);
- this.disconnectedModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
- super.dispose();
- }
-
-
+
+
// ********** validation **********
- private ChangeListener buildValidationListener() {
- return new SimpleChangeListener() {
- @Override
- protected void modelChanged() {
- JpaProjectPropertiesPage.this.validate();
- }
- @Override
- public String toString() {
- return "validation listener"; //$NON-NLS-1$
- }
- };
- }
-
- void validate() {
- if ( ! this.getControl().isDisposed()) {
- this.updateValidation();
- }
- }
-
- private void engageValidationListener() {
- for (Model model : this.buildValidationModels()) {
- model.addChangeListener(this.validationListener);
- }
- }
-
- private Model[] buildValidationModels() {
+ @Override
+ protected Model[] buildValidationModels() {
return new Model[] {
this.platformIdModel,
this.connectionModel,
@@ -975,36 +738,14 @@ public class JpaProjectPropertiesPage
this.discoverAnnotatedClassesModel
};
}
-
- private void disengageValidationListener() {
- for (Model model : this.buildReverseValidationModels()) {
- model.removeChangeListener(this.validationListener);
- }
- }
-
- private Model[] buildReverseValidationModels() {
- return ArrayTools.reverse(this.buildValidationModels());
- }
-
- private static final Integer ERROR_STATUS = Integer.valueOf(IStatus.ERROR);
- private static final Integer WARNING_STATUS = Integer.valueOf(IStatus.WARNING);
- private static final Integer INFO_STATUS = Integer.valueOf(IStatus.INFO);
- private static final Integer OK_STATUS = Integer.valueOf(IStatus.OK);
-
+
@Override
- protected IStatus performValidation() {
- HashMap<Integer, ArrayList<IStatus>> statuses = new HashMap<Integer, ArrayList<IStatus>>();
- statuses.put(ERROR_STATUS, new ArrayList<IStatus>());
- statuses.put(WARNING_STATUS, new ArrayList<IStatus>());
- statuses.put(INFO_STATUS, new ArrayList<IStatus>());
- statuses.put(OK_STATUS, CollectionTools.list(Status.OK_STATUS));
-
+ protected void performValidation(Map<Integer, ArrayList<IStatus>> statuses) {
/* platform */
// user is unable to unset the platform, so no validation necessary
/* library provider */
- IStatus lpStatus = super.performValidation();
- statuses.get(Integer.valueOf(lpStatus.getSeverity())).add(lpStatus);
+ super.performValidation(statuses);
/* connection */
ConnectionProfile connectionProfile = this.getConnectionProfile();
@@ -1013,8 +754,7 @@ public class JpaProjectPropertiesPage
if (connectionProfile == null) {
statuses.get(ERROR_STATUS).add(this.buildErrorStatus(NLS.bind(
JptCoreMessages.VALIDATE_CONNECTION_INVALID,
- connectionName
- )));
+ connectionName)));
}
else if ( ! connectionProfile.isActive()) {
statuses.get(INFO_STATUS).add(this.buildInfoStatus(JptCoreMessages.VALIDATE_CONNECTION_NOT_CONNECTED));
@@ -1052,38 +792,9 @@ public class JpaProjectPropertiesPage
)));
}
}
-
- if ( ! statuses.get(ERROR_STATUS).isEmpty()) {
- return statuses.get(ERROR_STATUS).get(0);
- }
- else if ( ! statuses.get(WARNING_STATUS).isEmpty()) {
- return statuses.get(WARNING_STATUS).get(0);
- }
- else if ( ! statuses.get(INFO_STATUS).isEmpty()) {
- return statuses.get(INFO_STATUS).get(0);
- }
- else {
- return statuses.get(OK_STATUS).get(0);
- }
}
- private IStatus buildInfoStatus(String message) {
- return this.buildStatus(IStatus.INFO, message);
- }
-
- private IStatus buildWarningStatus(String message) {
- return this.buildStatus(IStatus.WARNING, message);
- }
-
- private IStatus buildErrorStatus(String message) {
- return this.buildStatus(IStatus.ERROR, message);
- }
-
- private IStatus buildStatus(int severity, String message) {
- return new Status(severity, JptCorePlugin.PLUGIN_ID, message);
- }
-
-
+
// ********** UI model adapters **********
/**
@@ -1095,14 +806,8 @@ public class JpaProjectPropertiesPage
* Eclipse project's preferences).
*/
static class JpaProjectModel
- extends AspectPropertyValueModelAdapter<IProject, JpaProject>
- {
- /**
- * The JPA project's platform is stored as a preference.
- * If it changes, a new JPA project is built.
- */
- private final IPreferenceChangeListener preferenceChangeListener;
-
+ extends AspectPropertyValueModelAdapter<IProject, JpaProject> {
+
/**
* The JPA project may also change via another page (notably, the project facets page).
* In that case, the preference change occurs before we actually have another project,
@@ -1113,24 +818,9 @@ public class JpaProjectPropertiesPage
JpaProjectModel(PropertyValueModel<IProject> projectModel) {
super(projectModel);
- this.preferenceChangeListener = this.buildPreferenceChangeListener();
this.projectManagerListener = buildProjectManagerListener();
}
- private IPreferenceChangeListener buildPreferenceChangeListener() {
- return new IPreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- if (event.getKey().equals(JptCorePlugin.getJpaPlatformIdPrefKey())) {
- JpaProjectModel.this.platformChanged();
- }
- }
- @Override
- public String toString() {
- return "preference change listener"; //$NON-NLS-1$
- }
- };
- }
-
private CollectionChangeListener buildProjectManagerListener() {
return new CollectionChangeAdapter() {
// we are only looking for the project rebuild *add* event here so we can
@@ -1149,14 +839,12 @@ public class JpaProjectPropertiesPage
@Override
protected void engageSubject_() {
- this.getPreferences().addPreferenceChangeListener(this.preferenceChangeListener);
JptCorePlugin.getJpaProjectManager().addCollectionChangeListener(
JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectManagerListener);
}
@Override
protected void disengageSubject_() {
- this.getPreferences().removePreferenceChangeListener(this.preferenceChangeListener);
JptCorePlugin.getJpaProjectManager().removeCollectionChangeListener(
JpaProjectManager.JPA_PROJECTS_COLLECTION, this.projectManagerListener);
}
@@ -1165,13 +853,9 @@ public class JpaProjectPropertiesPage
protected JpaProject buildValue_() {
return JptCorePlugin.getJpaProject(this.subject);
}
-
- private IEclipsePreferences getPreferences() {
- return JptCorePlugin.getProjectPreferences(this.subject);
- }
}
-
-
+
+
/**
* The JPA project's data source is an auxiliary object that never changes;
* so if we have a JPA project, we have a JPA data source also.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JptProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JptProjectPropertiesPage.java
new file mode 100644
index 0000000000..10bde19d08
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JptProjectPropertiesPage.java
@@ -0,0 +1,423 @@
+package org.eclipse.jpt.ui.internal.properties;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.utility.internal.ArrayTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.model.value.BufferedWritablePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.model.Model;
+import org.eclipse.jpt.utility.model.listener.ChangeListener;
+import org.eclipse.jpt.utility.model.listener.SimpleChangeListener;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
+import org.eclipse.jst.common.project.facet.ui.libprov.LibraryFacetPropertyPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage;
+
+
+public abstract class JptProjectPropertiesPage
+ extends LibraryFacetPropertyPage {
+
+ protected final WritablePropertyValueModel<IProject> projectModel;
+ protected final BufferedWritablePropertyValueModel.Trigger trigger;
+
+ protected final ChangeListener validationListener;
+
+
+ public JptProjectPropertiesPage() {
+ super();
+
+ this.projectModel = new SimplePropertyValueModel<IProject>();
+ this.trigger = new BufferedWritablePropertyValueModel.Trigger();
+
+ buildModels();
+
+ this.validationListener = this.buildValidationListener();
+ }
+
+
+ /**
+ * Build any additional models needed by this page. The project model has been created at this
+ * point.
+ */
+ protected abstract void buildModels();
+
+
+ // ********** convenience methods **********
+
+ protected static boolean flagIsSet(PropertyValueModel<Boolean> flagModel) {
+ Boolean flag = flagModel.getValue();
+ return (flag != null) && flag.booleanValue();
+ }
+
+
+ // ********** LibraryFacetPropertyPage implementation **********
+
+ @Override
+ protected LibraryInstallDelegate createLibraryInstallDelegate(IFacetedProject project, IProjectFacetVersion fv) {
+ LibraryInstallDelegate lid = new LibraryInstallDelegate(project, fv, null);
+ lid.addListener(buildLibraryProviderListener());
+ return lid;
+ }
+
+ protected IPropertyChangeListener buildLibraryProviderListener() {
+ return new IPropertyChangeListener() {
+ public void propertyChanged(String property, Object oldValue, Object newValue ) {
+ if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
+ adjustLibraryProviders();
+ }
+ }
+ };
+ }
+
+ protected abstract void adjustLibraryProviders();
+
+
+ // ********** page **********
+
+ @Override
+ protected Control createPageContents(Composite parent) {
+ if (this.projectModel.getValue() != null) {
+ disengageListeners();
+ }
+
+ this.projectModel.setValue(getProject());
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ composite.setLayout(layout);
+
+ createWidgets(composite);
+
+ Dialog.applyDialogFont(composite);
+
+ adjustLibraryProviders();
+
+ engageListeners();
+ updateValidation();
+
+ return composite;
+ }
+
+ /**
+ * Build specific widgets. Layout and validation will be taken care of.
+ */
+ protected abstract void createWidgets(Composite parent);
+
+ protected void engageListeners() {
+ engageValidationListener();
+ }
+
+ protected void disengageListeners() {
+ disengageValidationListener();
+ }
+
+ protected Link buildFacetsPageLink(Composite parent, String text) {
+ Link facetsPageLink = buildLink(parent, text);
+ facetsPageLink.addSelectionListener(buildFacetsPageLinkListener()); // the link will be GCed
+ return facetsPageLink;
+ }
+
+ private SelectionListener buildFacetsPageLinkListener() {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openProjectFacetsPage();
+ }
+ @Override
+ public String toString() {
+ return "facets page link listener"; //$NON-NLS-1$
+ }
+ };
+ }
+
+ protected void openProjectFacetsPage() {
+ ((IWorkbenchPreferenceContainer)getContainer()).openPage(FacetsPropertyPage.ID, null);
+ }
+
+ /**
+ * Don't allow {@link org.eclipse.jface.preference.PreferencePage#computeSize()}
+ * to cache the page's size, since the size of the "Library" panel can
+ * change depending on the user's selection from the drop-down list.
+ */
+ @Override
+ public Point computeSize() {
+ return this.doComputeSize();
+ }
+
+
+ // ********** widgets **********
+
+ protected Button buildCheckBox(Composite parent, int horizontalSpan, String text) {
+ return buildButton(parent, horizontalSpan, text, SWT.CHECK);
+ }
+
+ protected Button buildRadioButton(Composite parent, int horizontalSpan, String text) {
+ return buildButton(parent, horizontalSpan, text, SWT.RADIO);
+ }
+
+ protected Button buildButton(Composite parent, int horizontalSpan, String text, int style) {
+ Button button = new Button(parent, SWT.NONE | style);
+ button.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = horizontalSpan;
+ button.setLayoutData(gd);
+ return button;
+ }
+
+ protected Combo buildDropDown(Composite parent) {
+ return buildDropDown(parent, 1);
+ }
+
+ protected Combo buildDropDown(Composite parent, int horizontalSpan) {
+ Combo combo = new Combo(parent, SWT.READ_ONLY);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = horizontalSpan;
+ combo.setLayoutData(gd);
+ return combo;
+ }
+
+ protected Label buildLabel(Composite parent, String text) {
+ Label label = new Label(parent, SWT.LEFT);
+ label.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 1;
+ label.setLayoutData(gd);
+ return label;
+ }
+
+ protected Link buildLink(Composite parent, String text) {
+ Link link = new Link(parent, SWT.NONE);
+ GridData data = new GridData(GridData.END, GridData.CENTER, false, false);
+ data.horizontalSpan = 2;
+ link.setLayoutData(data);
+ link.setText(text);
+ return link;
+ }
+
+
+ // ********** OK/Revert/Apply behavior **********
+
+ @Override
+ public boolean performOk() {
+ super.performOk();
+
+ try {
+ // true=fork; false=uncancellable
+ this.buildOkProgressMonitorDialog().run(true, false, this.buildOkRunnableWithProgress());
+ }
+ catch (InterruptedException ex) {
+ return false;
+ }
+ catch (InvocationTargetException ex) {
+ throw new RuntimeException(ex.getTargetException());
+ }
+
+ return true;
+ }
+
+ private IRunnableContext buildOkProgressMonitorDialog() {
+ return new ProgressMonitorDialog(this.getShell());
+ }
+
+ private IRunnableWithProgress buildOkRunnableWithProgress() {
+ return new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ try {
+ // the build we execute in #performOk_() locks the workspace root,
+ // so we need to use the workspace root as our scheduling rule here
+ ws.run(
+ buildOkWorkspaceRunnable(),
+ ws.getRoot(),
+ IWorkspace.AVOID_UPDATE,
+ monitor);
+ }
+ catch (CoreException ex) {
+ throw new InvocationTargetException(ex);
+ }
+ }
+ };
+ }
+
+ /* private */ IWorkspaceRunnable buildOkWorkspaceRunnable() {
+ return new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ performOk_(monitor);
+ }
+ };
+ }
+
+ // ********** OK/Revert/Apply behavior **********
+
+ void performOk_(IProgressMonitor monitor) throws CoreException {
+ if (isBuffering()) {
+ boolean rebuild = projectRebuildRequired();
+ this.trigger.accept();
+ if (rebuild) {
+ rebuildProject();
+ }
+ this.getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ }
+ }
+
+ protected abstract boolean projectRebuildRequired();
+
+ protected abstract void rebuildProject();
+
+ /**
+ * Return whether any of the models are buffering a change.
+ */
+ private boolean isBuffering() {
+ for (BufferedWritablePropertyValueModel<?> model : buildBufferedModels()) {
+ if (model.isBuffering()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected abstract BufferedWritablePropertyValueModel<?>[] buildBufferedModels();
+
+ @Override
+ protected void performDefaults() {
+ super.performDefaults();
+ this.trigger.reset();
+ }
+
+
+ // ********** dispose **********
+
+ @Override
+ public void dispose() {
+ disengageListeners();
+ super.dispose();
+ }
+
+
+ // ********** validation **********
+
+ private ChangeListener buildValidationListener() {
+ return new SimpleChangeListener() {
+ @Override
+ protected void modelChanged() {
+ validate();
+ }
+ @Override
+ public String toString() {
+ return "validation listener"; //$NON-NLS-1$
+ }
+ };
+ }
+
+ protected void validate() {
+ if ( ! getControl().isDisposed()) {
+ updateValidation();
+ }
+ }
+
+ private void engageValidationListener() {
+ for (Model model : buildValidationModels()) {
+ model.addChangeListener(this.validationListener);
+ }
+ }
+
+ protected abstract Model[] buildValidationModels();
+
+ private void disengageValidationListener() {
+ for (Model model : buildReverseValidationModels()) {
+ model.removeChangeListener(this.validationListener);
+ }
+ }
+
+ protected Model[] buildReverseValidationModels() {
+ return ArrayTools.reverse(buildValidationModels());
+ }
+
+ protected static final Integer ERROR_STATUS = Integer.valueOf(IStatus.ERROR);
+ protected static final Integer WARNING_STATUS = Integer.valueOf(IStatus.WARNING);
+ protected static final Integer INFO_STATUS = Integer.valueOf(IStatus.INFO);
+ protected static final Integer OK_STATUS = Integer.valueOf(IStatus.OK);
+
+ protected IStatus buildInfoStatus(String message) {
+ return this.buildStatus(IStatus.INFO, message);
+ }
+
+ protected IStatus buildWarningStatus(String message) {
+ return this.buildStatus(IStatus.WARNING, message);
+ }
+
+ protected IStatus buildErrorStatus(String message) {
+ return this.buildStatus(IStatus.ERROR, message);
+ }
+
+ protected IStatus buildStatus(int severity, String message) {
+ return new Status(severity, JptCorePlugin.PLUGIN_ID, message);
+ }
+
+ @Override
+ protected IStatus performValidation() {
+ HashMap<Integer, ArrayList<IStatus>> statuses = new HashMap<Integer, ArrayList<IStatus>>();
+ statuses.put(ERROR_STATUS, new ArrayList<IStatus>());
+ statuses.put(WARNING_STATUS, new ArrayList<IStatus>());
+ statuses.put(INFO_STATUS, new ArrayList<IStatus>());
+ statuses.put(OK_STATUS, CollectionTools.list(Status.OK_STATUS));
+
+ performValidation(statuses);
+
+ if ( ! statuses.get(ERROR_STATUS).isEmpty()) {
+ return statuses.get(ERROR_STATUS).get(0);
+ }
+ else if ( ! statuses.get(WARNING_STATUS).isEmpty()) {
+ return statuses.get(WARNING_STATUS).get(0);
+ }
+ else if ( ! statuses.get(INFO_STATUS).isEmpty()) {
+ return statuses.get(INFO_STATUS).get(0);
+ }
+ else {
+ return statuses.get(OK_STATUS).get(0);
+ }
+ }
+
+ protected void performValidation(Map<Integer, ArrayList<IStatus>> statuses) {
+ /* library provider */
+ IStatus lpStatus = super.performValidation();
+ statuses.get(Integer.valueOf(lpStatus.getSeverity())).add(lpStatus);
+ }
+}

Back to the top