Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-07-13 17:44:04 +0000
committerkmoore2010-07-13 17:44:04 +0000
commitf9208ef26384c4a326b66c4bcd91d8750e17d14a (patch)
tree8a57c679bb238d2ee7a335812cfac521f282b178
parent654cb995daa22312be2481b030ea11ec11d9d1b1 (diff)
downloadwebtools.dali-f9208ef26384c4a326b66c4bcd91d8750e17d14a.tar.gz
webtools.dali-f9208ef26384c4a326b66c4bcd91d8750e17d14a.tar.xz
webtools.dali-f9208ef26384c4a326b66c4bcd91d8750e17d14a.zip
Switch progress monitoring to use "new" SubMonitor
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetActionDelegate.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDelegate.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/gen/AbstractJptGenerator.java294
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/AbstractJpaFileCreationOperation.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationOperation.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/synch/SynchronizeClassesJob.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/AbstractXmlResourceProvider.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF2
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java474
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java632
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java124
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_core.properties11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/ClassesGenerator.java264
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/SchemaGenerator.java316
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java25
29 files changed, 1205 insertions, 1369 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
index 9eeede567a..58f9b94289 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
@@ -47,3 +47,6 @@ PLATFORM_ID_DOES_NOT_EXIST=No JPA platform exists for the id: ''{0}''. The JPA p
DALI_EVENT_HANDLER_THREAD_NAME=Dali Event Handler
PREFERENCES_FLUSH_JOB_NAME=Flush Preferences: {0}
KEY_CLASSES_VALIDATOR__CLASS_NOT_FOUND=The class ''{0}'' is required to be in the selected libraries.
+GENERATION_CREATING_LAUNCH_CONFIG_TASK=Creating launch configuration
+GENERATION_SAVING_LAUNCH_CONFIG_TASK=Saving launch config
+GENERATION_LAUNCHING_CONFIG_TASK=Launching config
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
index ec15ff5a9c..bdd4450c92 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
@@ -55,7 +55,9 @@ public class JptCoreMessages {
public static String DALI_EVENT_HANDLER_THREAD_NAME;
public static String PREFERENCES_FLUSH_JOB_NAME;
public static String KEY_CLASSES_VALIDATOR__CLASS_NOT_FOUND;
-
+ public static String GENERATION_CREATING_LAUNCH_CONFIG_TASK;
+ public static String GENERATION_SAVING_LAUNCH_CONFIG_TASK;
+ public static String GENERATION_LAUNCHING_CONFIG_TASK;
private static final String BUNDLE_NAME = "jpa_core"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptCoreMessages.class;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetActionDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetActionDelegate.java
index 77e242db5b..3daaad7cb8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetActionDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 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
@@ -13,7 +13,7 @@ package org.eclipse.jpt.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.NullProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -30,19 +30,14 @@ public abstract class JpaFacetActionDelegate
IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
- monitor = this.nonNullMonitor(monitor);
- try {
- this.execute_(project, fv, config, monitor);
- } finally {
- monitor.done();
- }
+ this.execute_(project, fv, config, monitor);
}
protected void execute_(
- IProject project, @SuppressWarnings("unused") IProjectFacetVersion fv,
+ IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", 1); //$NON-NLS-1$
+ SubMonitor subMonitor = SubMonitor.convert(monitor, 7);
// NB: WTP Natures (including the JavaEMFNature)
// should already be added, as this facet should
@@ -52,30 +47,31 @@ public abstract class JpaFacetActionDelegate
// project settings
JptCorePlugin.setJpaPlatformId(project, dataModel.getStringProperty(PLATFORM_ID));
+ subMonitor.worked(1);
// do NOT use IDataModel.getStringProperty(String) - or the connection profile name can
// be set to an empty string - we want it to be null
JptCorePlugin.setConnectionProfileName(project, (String) dataModel.getProperty(CONNECTION));
+ subMonitor.worked(1);
if (dataModel.getBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_CATALOG)) {
JptCorePlugin.setUserOverrideDefaultCatalog(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_CATALOG));
}
+ subMonitor.worked(1);
+
if (dataModel.getBooleanProperty(USER_WANTS_TO_OVERRIDE_DEFAULT_SCHEMA)) {
JptCorePlugin.setUserOverrideDefaultSchema(project, dataModel.getStringProperty(USER_OVERRIDE_DEFAULT_SCHEMA));
}
+ subMonitor.worked(1);
JptCorePlugin.setDiscoverAnnotatedClasses(project, dataModel.getBooleanProperty(DISCOVER_ANNOTATED_CLASSES));
+ subMonitor.worked(1);
// defaults settings
JptCorePlugin.setDefaultJpaPlatformId(fv.getVersionString(), dataModel.getStringProperty(PLATFORM_ID));
+ subMonitor.worked(1);
//Delegate to LibraryInstallDelegate to configure the project classpath
- ((LibraryInstallDelegate) dataModel.getProperty(JpaFacetInstallDataModelProperties.LIBRARY_PROVIDER_DELEGATE)).execute(new NullProgressMonitor());
-
- monitor.worked(1);
- }
-
- private IProgressMonitor nonNullMonitor(IProgressMonitor monitor) {
- return (monitor != null) ? monitor : new NullProgressMonitor();
+ ((LibraryInstallDelegate) dataModel.getProperty(JpaFacetDataModelProperties.LIBRARY_PROVIDER_DELEGATE)).execute(subMonitor.newChild(1));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
index 9cc71791d3..243b06fb49 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2006, 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.
@@ -13,6 +13,7 @@ import org.eclipse.core.commands.ExecutionException;
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.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -38,34 +39,23 @@ public class JpaFacetInstallDelegate
{
@Override
protected void execute_(
- IProject project, @SuppressWarnings("unused") IProjectFacetVersion fv,
+ IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
// NB: WTP Natures (including the JavaEMFNature)
// should already be added, as this facet should
// always coexist with a module facet.
+ SubMonitor sm = SubMonitor.convert(monitor, 10);
- super.execute_(project, fv, config, monitor);
-
+ super.execute_(project, fv, config, sm.newChild(1));
IJavaProject javaProject = JavaCore.create(project);
IDataModel dataModel = (IDataModel) config;
- try {
- monitor.beginTask("", 3); //$NON-NLS-1$
-
- // project settings
- this.addDbDriverLibraryToClasspath(javaProject, dataModel, monitor);
-
- monitor.worked(1);
+ // project settings
+ this.addDbDriverLibraryToClasspath(javaProject, dataModel, sm.newChild(1));
- // create project XML files
- this.createProjectXml(project, dataModel.getBooleanProperty(CREATE_ORM_XML));
-
- monitor.worked(2);
- }
- finally {
- monitor.done();
- }
+ // create project XML files
+ this.createProjectXml(project, dataModel.getBooleanProperty(CREATE_ORM_XML), sm.newChild(8));
}
protected void addDbDriverLibraryToClasspath(
@@ -100,31 +90,39 @@ public class JpaFacetInstallDelegate
javaProject.setRawClasspath(newClasspath, monitor);
}
- private void createProjectXml(IProject project, boolean buildOrmXml) {
- this.createPersistenceXml(project);
+ private void createProjectXml(IProject project, boolean buildOrmXml, IProgressMonitor monitor) {
+ int tasks = 1 + (buildOrmXml ? 1 : 0);
+ SubMonitor sm = SubMonitor.convert(monitor, tasks);
+ this.createPersistenceXml(project, sm.newChild(1));
if (buildOrmXml) {
- this.createOrmXml(project);
+ this.createOrmXml(project, sm.newChild(1));
}
}
- private void createPersistenceXml(IProject project) {
+ private void createPersistenceXml(IProject project, IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 5);
+
IDataModel config = DataModelFactory.createDataModel(new PersistenceFileCreationDataModelProvider());
config.setProperty(JpaFileCreationDataModelProperties.PROJECT_NAME, project.getName());
+ sm.worked(1);
// default values for all other properties should suffice
try {
- config.getDefaultOperation().execute(null, null);
+ config.getDefaultOperation().execute(sm.newChild(4), null);
} catch (ExecutionException ex) {
JptCorePlugin.log(ex);
}
}
- private void createOrmXml(IProject project) {
+ private void createOrmXml(IProject project, IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 5);
+
IDataModel config = DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
config.setProperty(JpaFileCreationDataModelProperties.PROJECT_NAME, project.getName());
+ sm.worked(1);
// default values for all other properties should suffice
try {
- config.getDefaultOperation().execute(null, null);
+ config.getDefaultOperation().execute(sm.newChild(4), null);
} catch (ExecutionException ex) {
JptCorePlugin.log(ex);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDelegate.java
index 157bf080cc..a219080b26 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetVersionChangeDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * Copyright (c) 2009, 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
@@ -13,6 +13,7 @@ package org.eclipse.jpt.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.core.JptCorePlugin;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
@@ -22,18 +23,13 @@ public class JpaFacetVersionChangeDelegate
@Override
protected void execute_(
IProject project, IProjectFacetVersion fv,
- Object config, IProgressMonitor monitor) throws CoreException {
-
- super.execute_(project, fv, config, monitor);
-
- // need to do a rebuild here
-
- monitor.beginTask("", 1); //$NON-NLS-1$
-
+ Object config, IProgressMonitor monitor) throws CoreException
+ {
+ SubMonitor sm = SubMonitor.convert(monitor, 2);
+ super.execute_(project, fv, config, sm.newChild(1));
+
JptCorePlugin.rebuildJpaProject(project);
-
- monitor.worked(1);
-
+ sm.worked(1);
// nothing further to do here *just* yet
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/gen/AbstractJptGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/gen/AbstractJptGenerator.java
new file mode 100644
index 0000000000..1f942553be
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/gen/AbstractJptGenerator.java
@@ -0,0 +1,294 @@
+/*******************************************************************************
+* Copyright (c) 2008, 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.core.internal.gen;
+
+import java.io.File;
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jpt.core.internal.JptCoreMessages;
+
+public abstract class AbstractJptGenerator
+{
+ private IVMInstall jre;
+ protected ILaunchConfigurationWorkingCopy launchConfig;
+ private ILaunch launch;
+
+ protected final IJavaProject javaProject;
+ protected final String projectLocation;
+
+ private final boolean isDebug = true;
+
+ // ********** constructors **********
+
+ protected AbstractJptGenerator(IJavaProject javaProject) {
+ super();
+ this.javaProject = javaProject;
+ this.projectLocation = javaProject.getProject().getLocation().toString();
+ this.initialize();
+ }
+
+ // ********** behavior **********
+
+ protected void initialize() {
+ try {
+ this.jre = this.getProjectJRE();
+ if (this.jre == null) {
+ String message = "Could not identify the VM."; //$NON-NLS-1$
+ throw new RuntimeException(message);
+ }
+ this.launchConfig = this.buildLaunchConfiguration();
+ }
+ catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void generate(IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 10);
+ this.preGenerate(sm.newChild(2));
+ if (sm.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ sm.subTask(JptCoreMessages.GENERATION_CREATING_LAUNCH_CONFIG_TASK);
+ this.initializeLaunchConfiguration();
+ sm.worked(1);
+ if (sm.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+
+ this.addLaunchListener();
+ sm.worked(1);
+
+ if (sm.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ this.launch = this.saveAndLaunchConfig(sm.newChild(6));
+ }
+
+ private void initializeLaunchConfiguration() {
+ this.specifyJRE();
+
+ this.specifyProject();
+ this.specifyMainType();
+
+ this.specifyProgramArguments();
+ this.specifyWorkingDir();
+
+ this.specifyClasspathProperties();
+ }
+
+ private void addLaunchListener() {
+
+ this.getLaunchManager().addLaunchListener(this.buildLaunchListener());
+ }
+
+ protected abstract void preGenerate(IProgressMonitor monitor);
+
+ protected void postGenerate() {
+ try {
+ if ( ! this.isDebug) {
+ this.removeLaunchConfiguration();
+ }
+ }
+ catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ILaunchesListener2 buildLaunchListener() {
+ return new ILaunchesListener2() {
+
+ public void launchesTerminated(ILaunch[] launches) {
+ for (int i = 0; i < launches.length; i++) {
+ ILaunch launch = launches[i];
+ if (launch.equals(AbstractJptGenerator.this.getLaunch())) {
+
+ AbstractJptGenerator.this.postGenerate();
+ return;
+ }
+ }
+ }
+
+ public void launchesAdded(ILaunch[] launches) {
+ // not interested to this event
+ }
+
+ public void launchesChanged(ILaunch[] launches) {
+ // not interested to this event
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {
+ // not interested to this event
+ }
+ };
+ }
+
+ // ********** Setting Launch Configuration **********
+
+ private void specifyJRE() {
+ String jreName = this.jre.getName();
+ String vmId = this.jre.getVMInstallType().getId();
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreName);
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmId);
+ }
+
+ private void specifyProject() {
+ String projectName = this.getProject().getName();
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
+ }
+
+ protected IProject getProject() {
+ return this.javaProject.getProject();
+ }
+
+ private void specifyMainType() {
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, this.getMainType());
+ }
+
+ protected abstract String getMainType();
+
+ protected abstract void specifyProgramArguments();
+
+ protected void specifyClasspathProperties() {
+ List<String> classpath;
+ try {
+ classpath = this.buildClasspath();
+ }
+ catch (CoreException e) {
+ throw new RuntimeException("An error occured generating a memento", e);
+ }
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ }
+
+ protected abstract List<String> buildClasspath() throws CoreException;
+
+ private void specifyWorkingDir() {
+ File workingDir = new Path(this.projectLocation).toFile();
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath());
+ }
+
+ // ********** ClasspathEntry **********
+
+ protected IRuntimeClasspathEntry getSystemLibraryClasspathEntry() throws CoreException {
+
+ IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
+ return JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath, IRuntimeClasspathEntry.STANDARD_CLASSES);
+ }
+
+ protected IRuntimeClasspathEntry getDefaultProjectClasspathEntry() {
+
+ IRuntimeClasspathEntry projectEntry = JavaRuntime.newDefaultProjectClasspathEntry(this.javaProject);
+ projectEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+
+ return projectEntry;
+ }
+
+ protected static IRuntimeClasspathEntry getArchiveClasspathEntry(IPath archivePath) {
+ IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(archivePath);
+ archiveEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+
+ return archiveEntry;
+ }
+
+
+ // ********** LaunchConfig **********
+
+ private ILaunch saveAndLaunchConfig(IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 10);
+ ILaunchConfiguration configuration = null;
+ ILaunch result = null;
+ try {
+ sm.subTask(JptCoreMessages.GENERATION_SAVING_LAUNCH_CONFIG_TASK);
+ configuration = this.launchConfig.doSave();
+ }
+ catch (CoreException saveException) {
+ throw new RuntimeException("Could not save LaunchConfig", saveException);
+ }
+ sm.worked(1);
+ if (sm.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ try {
+ sm.subTask(JptCoreMessages.GENERATION_LAUNCHING_CONFIG_TASK);
+ result = configuration.launch(ILaunchManager.RUN_MODE, sm.newChild(9));
+ }
+ catch (CoreException launchException) {
+ throw new RuntimeException("An error occured during launch", launchException);
+ }
+ return result;
+ }
+
+ private ILaunchConfigurationWorkingCopy buildLaunchConfiguration() throws CoreException {
+ this.removeLaunchConfiguration();
+
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+
+ return type.newInstance(null, this.getLaunchConfigName());
+ }
+
+ protected abstract String getLaunchConfigName();
+
+ private void removeLaunchConfiguration() throws CoreException {
+
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
+
+ ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
+ for (int i = 0; i < configurations.length; i++) {
+ ILaunchConfiguration configuration = configurations[i];
+ if (configuration.getName().equals(this.getLaunchConfigName())) {
+ configuration.delete();
+ break;
+ }
+ }
+ }
+
+ // ********** Main arguments **********
+
+ protected void appendDebugArgument(StringBuffer sb) {
+ if (this.isDebug) {
+ sb.append(" -debug"); //$NON-NLS-1$
+ }
+ }
+
+ // ********** Queries **********
+
+ protected ILaunch getLaunch() {
+ return this.launch;
+ }
+
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ private IVMInstall getProjectJRE() throws CoreException {
+ return JavaRuntime.getVMInstall(this.javaProject);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/AbstractJpaFileCreationOperation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/AbstractJpaFileCreationOperation.java
index 806bc48a52..96b0246be3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/AbstractJpaFileCreationOperation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/AbstractJpaFileCreationOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
+ * Copyright (c) 2009, 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.
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jpt.core.JpaProject;
@@ -48,10 +49,11 @@ public abstract class AbstractJpaFileCreationOperation
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ SubMonitor sm = SubMonitor.convert(monitor, 5);
// Create source folder if it does not exist
- createSourceFolder();
+ createSourceFolder(sm.newChild(1));
// Create file
- createFile();
+ createFile(sm.newChild(4));
return OK_STATUS;
}
@@ -80,15 +82,15 @@ public abstract class AbstractJpaFileCreationOperation
* This method may return null.
*/
// copied from NewJavaClassOperation
- protected void createSourceFolder() throws ExecutionException {
+ protected void createSourceFolder(IProgressMonitor monitor) throws ExecutionException {
// Get the source folder name from the data model
- String folderPath = model.getStringProperty(SOURCE_FOLDER);
+ String folderPath = this.model.getStringProperty(SOURCE_FOLDER);
IProject project = getProject();
IFolder folder = project.getWorkspace().getRoot().getFolder(new Path(folderPath));
// If folder does not exist, create the folder with the specified path
if (! folder.exists()) {
try {
- folder.create(true, true, null);
+ folder.create(true, true, monitor);
} catch (CoreException e) {
throw new ExecutionException("Could not create folder", e); //$NON-NLS-1$
}
@@ -97,12 +99,12 @@ public abstract class AbstractJpaFileCreationOperation
this.createdSourceFolder = folder;
}
- protected void createFile() {
+ protected void createFile(IProgressMonitor monitor) {
String filePath = getDataModel().getStringProperty(FILE_PATH);
IFile newFile = this.createdSourceFolder.getFile(new Path(filePath));
AbstractXmlResourceProvider resourceProvider = getXmlResourceProvider(newFile);
try {
- resourceProvider.createFileAndResource(getDataModel());
+ resourceProvider.createFileAndResource(getDataModel(), monitor);
}
catch (CoreException e) {
JptCorePlugin.log(e);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationOperation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationOperation.java
index 17a63ec16c..0e0c6a25ff 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationOperation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/operations/OrmFileCreationOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2008, 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.
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.persistence.MappingFileRef;
@@ -38,10 +39,12 @@ public class OrmFileCreationOperation
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus status = super.execute(monitor, info);
+ SubMonitor sm = SubMonitor.convert(monitor, 5);
+ IStatus status = super.execute(sm.newChild(4), info);
if (status.isOK()) {
addMappingFileToPersistenceXml();
+ sm.worked(1);
}
return OK_STATUS;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/synch/SynchronizeClassesJob.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/synch/SynchronizeClassesJob.java
index 331ca73855..5648a5b0eb 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/synch/SynchronizeClassesJob.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/synch/SynchronizeClassesJob.java
@@ -9,7 +9,6 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.synch;
-import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -17,6 +16,7 @@ import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.core.JpaProject;
@@ -32,7 +32,7 @@ import org.eclipse.jpt.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
/**
* Synchronizes the lists of persistent classes in a persistence unit and a
@@ -51,60 +51,62 @@ public class SynchronizeClassesJob extends WorkspaceJob
}
@Override
- public IStatus runInWorkspace(final IProgressMonitor monitor) {
- monitor.beginTask(JptCoreMessages.SYNCHRONIZING_CLASSES_TASK, 200);
-
+ public IStatus runInWorkspace(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
-
+ final SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.SYNCHRONIZING_CLASSES_TASK, 20);
final JpaProject jpaProject = JptCorePlugin.getJpaProject(this.persistenceXmlFile.getProject());
final JpaXmlResource resource = jpaProject.getPersistenceXmlResource();
if (resource == null) {
//the resource would only be null if the persistence.xml file had an invalid content type
return Status.OK_STATUS;
}
-
- monitor.worked(25);
+ if (sm.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ sm.worked(1);
resource.modify(new Runnable() {
- public void run() {
- XmlPersistence persistence = (XmlPersistence) resource.getRootObject();
- XmlPersistenceUnit persistenceUnit;
-
- if (persistence.getPersistenceUnits().size() > 0) {
- persistenceUnit = persistence.getPersistenceUnits().get(0);
- }
- else {
- persistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
- persistenceUnit.setName(jpaProject.getName());
- persistence.getPersistenceUnits().add(persistenceUnit);
- }
-
- persistenceUnit.getClasses().clear();
-
- monitor.worked(25);
-
- for (Iterator<String> stream = mappedClassNames(jpaProject, '$'); stream.hasNext(); ) {
- String fullyQualifiedTypeName = stream.next();
- if ( ! mappingFileContains(jpaProject, fullyQualifiedTypeName)) {
- XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- classRef.setJavaClass(fullyQualifiedTypeName);
- persistenceUnit.getClasses().add(classRef);
- }
- }
-
- monitor.worked(100);
+ public void run() {
+ XmlPersistence persistence = (XmlPersistence) resource.getRootObject();
+ XmlPersistenceUnit persistenceUnit;
+
+ if (persistence.getPersistenceUnits().size() > 0) {
+ persistenceUnit = persistence.getPersistenceUnits().get(0);
}
- });
-
- monitor.done();
+ else {
+ persistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit();
+ persistenceUnit.setName(jpaProject.getName());
+ persistence.getPersistenceUnits().add(persistenceUnit);
+ }
+ sm.worked(1);
+
+ persistenceUnit.getClasses().clear();
+ sm.worked(1);
+ addClassRefs(sm.newChild(17), jpaProject, persistenceUnit);
+ }
+ });
return Status.OK_STATUS;
}
- protected Iterator<String> mappedClassNames(final JpaProject jpaProject, final char enclosingTypeSeparator) {
- return new TransformationIterator<String, String>(jpaProject.mappedJavaSourceClassNames()) {
+ protected void addClassRefs(IProgressMonitor monitor, JpaProject jpaProject, XmlPersistenceUnit persistenceUnit) {
+ Iterable<String> mappedClassNames = getMappedClassNames(jpaProject, '$');
+ final SubMonitor sm = SubMonitor.convert(monitor, CollectionTools.size(mappedClassNames));
+
+ for (String fullyQualifiedTypeName : mappedClassNames) {
+ if ( ! mappingFileContains(jpaProject, fullyQualifiedTypeName)) {
+ XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ classRef.setJavaClass(fullyQualifiedTypeName);
+ persistenceUnit.getClasses().add(classRef);
+ }
+ sm.worked(1);
+ }
+ }
+
+ protected Iterable<String> getMappedClassNames(final JpaProject jpaProject, final char enclosingTypeSeparator) {
+ return new TransformationIterable<String, String>(CollectionTools.iterable(jpaProject.mappedJavaSourceClassNames())) {
@Override
protected String transform(String fullyQualifiedName) {
IType jdtType = SynchronizeClassesJob.this.findType(jpaProject, fullyQualifiedName);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/AbstractXmlResourceProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/AbstractXmlResourceProvider.java
index 803764e6b0..7b232dca0d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/AbstractXmlResourceProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/AbstractXmlResourceProvider.java
@@ -168,14 +168,14 @@ public abstract class AbstractXmlResourceProvider
* It also populates the root of the file.
* @param config - A configuration object used to specify options for creation of the resource
*/
- public JpaXmlResource createFileAndResource(final Object config) throws CoreException {
+ public JpaXmlResource createFileAndResource(final Object config, IProgressMonitor monitor) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) {
createResourceAndUnderlyingFile(config);
}
};
- workspace.run(runnable, this.project, IWorkspace.AVOID_UPDATE, null);
+ workspace.run(runnable, this.project, IWorkspace.AVOID_UPDATE, monitor);
return this.resource;
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
index 1c019134c6..a15b01bacf 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.eclipselink.core;singleton:=true
-Bundle-Version: 1.3.1.qualifier
+Bundle-Version: 1.3.200.qualifier
Bundle-Activator: org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
new file mode 100644
index 0000000000..fc8400c5b5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java
@@ -0,0 +1,474 @@
+/*******************************************************************************
+* Copyright (c) 2008, 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.eclipselink.core.internal.ddlgen;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jpt.core.JpaPlatform;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.internal.JptCoreMessages;
+import org.eclipse.jpt.core.internal.SynchronousJpaProjectUpdater;
+import org.eclipse.jpt.core.internal.gen.AbstractJptGenerator;
+import org.eclipse.jpt.db.ConnectionProfile;
+import org.eclipse.jpt.eclipselink.core.context.persistence.connection.Connection;
+import org.eclipse.jpt.eclipselink.core.context.persistence.customization.Customization;
+import org.eclipse.jpt.eclipselink.core.context.persistence.logging.Logging;
+import org.eclipse.jpt.eclipselink.core.context.persistence.logging.LoggingLevel;
+import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.DdlGenerationType;
+import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.OutputMode;
+import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.SchemaGeneration;
+import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.osgi.util.ManifestElement;
+import org.eclipse.wst.validation.ValidationFramework;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+public abstract class AbstractEclipseLinkDDLGenerator extends AbstractJptGenerator
+{
+ public static final String LAUNCH_CONFIG_NAME = "Dali EclipseLink Table Generation"; //$NON-NLS-1$
+ public static final String DDL_GEN_PACKAGE_NAME = "org.eclipse.jpt.eclipselink.core.ddlgen"; //$NON-NLS-1$
+ public static final String ECLIPSELINK_DDL_GEN_CLASS = DDL_GEN_PACKAGE_NAME + ".Main"; //$NON-NLS-1$
+ public static final String ECLIPSELINK_DDL_GEN_JAR = DDL_GEN_PACKAGE_NAME + "_"; //$NON-NLS-1$
+ public static final String BUNDLE_CLASSPATH = "Bundle-ClassPath"; //$NON-NLS-1$
+ public static final String PROPERTIES_FILE_NAME = "login.properties"; //$NON-NLS-1$
+ public static final String PLUGINS_DIR = "plugins/"; //$NON-NLS-1$
+ public static final String TRUE = "true"; //$NON-NLS-1$
+ public static final String FALSE = "false"; //$NON-NLS-1$
+ public static final String NONE = "NONE"; //$NON-NLS-1$
+
+ private String puName;
+ private JpaProject jpaProject;
+
+ // ********** constructors **********
+
+ protected AbstractEclipseLinkDDLGenerator(String puName, JpaProject jpaProject) {
+ super(JavaCore.create(jpaProject.getProject()));
+ this.puName = puName;
+ this.jpaProject = jpaProject;
+ }
+
+ @Override
+ protected String getLaunchConfigName() {
+ return LAUNCH_CONFIG_NAME;
+ }
+
+ @Override
+ protected String getMainType() {
+ return ECLIPSELINK_DDL_GEN_CLASS;
+ }
+
+ // ********** behavior **********
+
+
+ @Override
+ protected void preGenerate(IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 2);
+ //disconnect since the runtime provider will need to connect to generate the tables
+ ConnectionProfile cp = this.getConnectionProfile();
+ if (cp != null) {
+ cp.disconnect();
+ sm.worked(1);
+ }
+ sm.setWorkRemaining(1);
+ this.saveLoginProperties();
+ sm.worked(1);
+ }
+
+ @Override
+ protected void postGenerate() {
+ super.postGenerate();
+ this.reconnect();
+ this.validateProject();
+ }
+
+ //reconnect since we disconnected in preGenerate(),
+ //use the synchronous JPA project updater so we can ensure
+ //the project is fully updated before validating. bug 277236
+ protected void reconnect() {
+ JpaProject.Updater updater = getJpaProject().getUpdater();
+ getJpaProject().setUpdater(new SynchronousJpaProjectUpdater(getJpaProject()));
+ ConnectionProfile cp = this.getConnectionProfile();
+ if (cp != null) {
+ cp.connect();
+ }
+ getJpaProject().setUpdater(updater);
+ }
+
+ protected void validateProject() {
+ IProject project = this.getJpaProject().getProject();
+ ValidateJob job = new ValidateJob(project);
+ job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(project));
+ job.schedule();
+ }
+
+ /**
+ * Performs validation after tables have been generated
+ */
+ private class ValidateJob extends Job
+ {
+ private IProject project;
+
+
+ public ValidateJob(IProject project) {
+ super(JptCoreMessages.VALIDATE_JOB);
+ this.project = project;
+ }
+
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ ValidationFramework.getDefault().validate(
+ new IProject[] {this.project}, true, false, monitor);
+ }
+ catch (CoreException ce) {
+ status = Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+ }
+
+ private IPath buildJdbcJarPath() {
+ return new Path(this.getJpaProjectConnectionDriverJarList());
+ }
+
+ private String getJpaProjectConnectionDriverJarList() {
+ ConnectionProfile cp = this.getConnectionProfile();
+ return (cp == null) ? "" : cp.getDriverJarList(); //$NON-NLS-1$
+ }
+
+ private IPath buildBootstrapJarPath() {
+ try {
+ File jarInstallDir = this.getBundleParentDir(JptEclipseLinkCorePlugin.PLUGIN_ID);
+
+ List<File> result = new ArrayList<File>();
+ this.findFile(ECLIPSELINK_DDL_GEN_JAR, jarInstallDir, result);
+ if (result.isEmpty()) {
+ throw new RuntimeException("Could not find: " + DDL_GEN_PACKAGE_NAME + ".jar in: " + jarInstallDir);
+ }
+ File ddlGenJarFile = result.get(0);
+ String ddlGenJarPath = ddlGenJarFile.getCanonicalPath();
+ return new Path(ddlGenJarPath);
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void findFile(String fileName, File directory, List<? super File> list) {
+ if(directory.listFiles() == null) {
+ throw new RuntimeException("Could not find directory: " + directory);
+ }
+ for (File file : directory.listFiles()) {
+ if (file.getName().startsWith(fileName)) {
+ list.add(file);
+ }
+ if (file.isDirectory()) {
+ this.findFile(fileName, file, list);
+ }
+ }
+ }
+
+ private File getBundleParentDir(String bundleName) throws IOException {
+
+ if (Platform.inDevelopmentMode()) {
+ Location eclipseHomeLoc = Platform.getInstallLocation();
+ String eclipseHome = eclipseHomeLoc.getURL().getPath();
+ if ( ! eclipseHome.endsWith(PLUGINS_DIR)) {
+ eclipseHome += PLUGINS_DIR;
+ }
+ return new File(eclipseHome);
+ }
+ Bundle bundle = Platform.getBundle(bundleName);
+ return FileLocator.getBundleFile(bundle).getParentFile();
+ }
+
+
+ // ********** Setting Launch Configuration **********
+
+ @Override
+ protected void specifyProgramArguments() {
+ StringBuffer programArguments = new StringBuffer();
+ this.appendPuNameArgument(programArguments);
+ this.appendPropertiesFileArgument(programArguments);
+ this.appendDebugArgument(programArguments);
+
+ this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ }
+
+ @Override
+ protected List<String> buildClasspath() throws CoreException {
+ List<String> classpath = new ArrayList<String>();
+ // DDL_GEN jar
+ classpath.add(getBootstrapJarClasspathEntry().getMemento());
+ // Default Project classpath
+ classpath.add(this.getDefaultProjectClasspathEntry().getMemento());
+ // Osgi Bundles
+ classpath.addAll(this.getPersistenceOsgiBundlesMemento());
+ // JDBC jar
+ classpath.add(getJdbcJarClasspathEntry().getMemento());
+ // System Library
+ classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
+ return classpath;
+ }
+
+ // ********** ClasspathEntry **********
+
+ private IRuntimeClasspathEntry getBootstrapJarClasspathEntry() {
+ return getArchiveClasspathEntry(this.buildBootstrapJarPath());
+ }
+
+ private IRuntimeClasspathEntry getJdbcJarClasspathEntry() {
+ return getArchiveClasspathEntry(this.buildJdbcJarPath());
+ }
+
+ private IRuntimeClasspathEntry getBundleClasspathEntry(String bundleId) {
+ IPath persistClasspath = this.getBundleClasspath(bundleId);
+ IRuntimeClasspathEntry bundleEntry = getArchiveClasspathEntry(persistClasspath);
+
+ return bundleEntry;
+ }
+
+
+ // ********** EclipseLink properties **********
+
+ private void buildProjectLocationProperty(Properties properties) {
+ this.putProperty(properties,
+ SchemaGeneration.ECLIPSELINK_APPLICATION_LOCATION,
+ this.projectLocation);
+ }
+
+ private void buildDDLModeProperties(Properties properties) {
+ this.putProperty(properties,
+ SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
+ DdlGenerationType.DROP_AND_CREATE_TABLES);
+ this.putProperty(properties,
+ SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
+ OutputMode.DATABASE);
+ }
+
+ protected void buildConnectionProperties(Properties properties) {
+ this.putProperty(properties,
+ Connection.ECLIPSELINK_BIND_PARAMETERS,
+ FALSE);
+ }
+
+ private void buildConnectionPoolingProperties(Properties properties) {
+ this.putProperty(properties,
+ Connection.ECLIPSELINK_READ_CONNECTIONS_SHARED,
+ TRUE);
+ }
+
+ private void buildLoggingProperties(Properties properties) {
+ this.putProperty(properties,
+ Logging.ECLIPSELINK_LEVEL,
+ LoggingLevel.FINE);
+ this.putProperty(properties,
+ Logging.ECLIPSELINK_TIMESTAMP,
+ FALSE);
+ this.putProperty(properties,
+ Logging.ECLIPSELINK_THREAD,
+ FALSE);
+ this.putProperty(properties,
+ Logging.ECLIPSELINK_SESSION,
+ FALSE);
+ this.putProperty(properties,
+ Logging.ECLIPSELINK_EXCEPTIONS,
+ TRUE);
+ }
+
+ protected void buildCustomizationProperties(Properties properties) {
+ this.putProperty(properties,
+ Customization.ECLIPSELINK_THROW_EXCEPTIONS,
+ TRUE);
+ }
+
+ protected void putProperty(Properties properties, String key, String value) {
+ properties.put(key, (value == null) ? "" : value); //$NON-NLS-1$
+ }
+
+ protected void buildAllProperties(Properties properties) {
+ this.buildConnectionProperties(properties);
+ this.buildConnectionPoolingProperties(properties);
+ this.buildLoggingProperties(properties);
+ this.buildCustomizationProperties(properties);
+ this.buildDDLModeProperties(properties);
+ this.buildProjectLocationProperty(properties);
+ }
+
+ private void saveLoginProperties() {
+ String propertiesFile = this.projectLocation + "/" + PROPERTIES_FILE_NAME; //$NON-NLS-1$
+
+ Properties elProperties = new Properties();
+
+ this.buildAllProperties(elProperties);
+ FileOutputStream stream = null;
+ try {
+ File file = new File(propertiesFile);
+ if (!file.exists() && ! file.createNewFile()) {
+ throw new RuntimeException("createNewFile() failed: " + file); //$NON-NLS-1$
+ }
+ stream = new FileOutputStream(file);
+ elProperties.store(stream, null);
+ }
+ catch (Exception e) {
+ String message = "Error saving: " + propertiesFile; //$NON-NLS-1$
+ throw new RuntimeException(message, e);
+ }
+ finally {
+ this.closeStream(stream);
+ }
+ }
+
+ private void closeStream(OutputStream stream) {
+ if (stream != null) {
+ try {
+ stream.close();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // ********** Main arguments **********
+
+ private void appendPuNameArgument(StringBuffer sb) {
+ sb.append(" -pu \""); //$NON-NLS-1$
+ sb.append(this.puName);
+ sb.append("\""); //$NON-NLS-1$
+ }
+
+ private void appendPropertiesFileArgument(StringBuffer sb) {
+ sb.append(" -p \""); //$NON-NLS-1$
+ sb.append(this.projectLocation).append("/").append(PROPERTIES_FILE_NAME).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ // ********** Queries **********
+
+ protected JpaPlatform getPlatform() {
+ return this.getJpaProject().getJpaPlatform();
+ }
+
+ protected JpaProject getJpaProject() {
+ return this.jpaProject;
+ }
+
+
+ protected ConnectionProfile getConnectionProfile() {
+ return this.getJpaProject().getConnectionProfile();
+ }
+
+
+ // ********** Bundles *********
+
+ private Collection<String> getPersistenceOsgiBundlesMemento() throws CoreException {
+
+ Collection<String> result = new HashSet<String>();
+ if (javaxPersistenceBundleExists()) {
+ result.add(this.getBundleClasspathEntry(JAVAX_PERSISTENCE_BUNDLE).getMemento());
+ result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_CORE_BUNDLE).getMemento());
+ result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_ASM_BUNDLE).getMemento());
+ result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_ANTLR_BUNDLE).getMemento());
+ result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_JPA_BUNDLE).getMemento());
+ }
+ return result;
+ }
+
+ private IPath getBundleClasspath(String pluginID) {
+ Bundle bundle = Platform.getBundle(pluginID);
+ if (bundle == null) {
+ throw new RuntimeException(pluginID + " cannot be retrieved from the Platform");
+ }
+ return this.getClassPath(bundle);
+ }
+
+ private IPath getClassPath(Bundle bundle) {
+ String path = (String) bundle.getHeaders().get(BUNDLE_CLASSPATH);
+ if (path == null) {
+ path = "."; //$NON-NLS-1$
+ }
+ ManifestElement[] elements = null;
+ try {
+ elements = ManifestElement.parseHeader(BUNDLE_CLASSPATH, path);
+ }
+ catch (BundleException e) {
+ throw new RuntimeException("Error parsing bundle header: " + bundle, e);
+ }
+ if (elements != null) {
+ for (int i = 0; i < elements.length; ++i) {
+ ManifestElement element = elements[i];
+ String value = element.getValue();
+ if (".".equals(value)) { //$NON-NLS-1$
+ value = "/"; //$NON-NLS-1$
+ }
+ URL url = bundle.getEntry(value);
+ if (url != null) {
+ try {
+ URL resolvedURL = FileLocator.resolve(url);
+ String filestring = FileLocator.toFileURL(resolvedURL).getFile();
+ if (filestring.startsWith("file:")) { //$NON-NLS-1$
+ filestring = filestring.substring(filestring.indexOf(':') + 1);
+ }
+ if (filestring.endsWith("!/")) { //$NON-NLS-1$
+ filestring = filestring.substring(0, filestring.lastIndexOf('!'));
+ }
+ File file = new File(filestring);
+ String filePath = file.getCanonicalPath();
+ return new Path(filePath);
+ }
+ catch (IOException e) {
+ throw new RuntimeException("Error locating bundle: " + bundle, e);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ private boolean javaxPersistenceBundleExists() {
+ return Platform.getBundle(JAVAX_PERSISTENCE_BUNDLE) != null;
+ }
+
+ // ********** constants **********
+
+ private static final String JAVAX_PERSISTENCE_BUNDLE = "javax.persistence"; //$NON-NLS-1$
+ private static final String ORG_ECLIPSE_PERSISTENCE_CORE_BUNDLE = "org.eclipse.persistence.core"; //$NON-NLS-1$
+ private static final String ORG_ECLIPSE_PERSISTENCE_ASM_BUNDLE = "org.eclipse.persistence.asm"; //$NON-NLS-1$
+ private static final String ORG_ECLIPSE_PERSISTENCE_ANTLR_BUNDLE = "org.eclipse.persistence.antlr"; //$NON-NLS-1$
+ private static final String ORG_ECLIPSE_PERSISTENCE_JPA_BUNDLE = "org.eclipse.persistence.jpa"; //$NON-NLS-1$
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
index bd2e593e9e..93626b10dc 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java
@@ -9,60 +9,15 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.core.internal.ddlgen;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
import java.util.Properties;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchesListener2;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jpt.core.JpaPlatform;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.internal.JptCoreMessages;
-import org.eclipse.jpt.core.internal.SynchronousJpaProjectUpdater;
import org.eclipse.jpt.db.ConnectionProfile;
import org.eclipse.jpt.eclipselink.core.context.persistence.connection.Connection;
-import org.eclipse.jpt.eclipselink.core.context.persistence.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.context.persistence.logging.Logging;
-import org.eclipse.jpt.eclipselink.core.context.persistence.logging.LoggingLevel;
-import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.OutputMode;
-import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.wst.validation.ValidationFramework;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
/**
* EclipseLinkDLLGenerator launches the EclipseLink DDL generator in a separate VM.
- * For this it will create a Java Configuration named "EclipseLink"
+ * For this it will create a Java Configuration named "Dali EclipseLink Table Generation"
* in the target workspace (note: the configuration will be overridden at each run).
* It will than launch the configuration created with the login information from
* the current Dali project, and passes it to EclipseLink.
@@ -70,599 +25,38 @@ import org.osgi.framework.BundleException;
* Pre-req in PDE environment:
* org.eclipse.jpt.eclipselink.core.ddlgen.jar in ECLIPSE_HOME/plugins
*/
-public class EclipseLinkDDLGenerator
+public class EclipseLinkDDLGenerator extends AbstractEclipseLinkDDLGenerator
{
- static public String ECLIPSELINK_DDL_GEN_JAR_VERSION = "1.0.100"; //$NON-NLS-1$
- static public String LAUNCH_CONFIG_NAME = "EclipseLink"; //$NON-NLS-1$
- static public String DDL_GEN_PACKAGE_NAME = "org.eclipse.jpt.eclipselink.core.ddlgen"; //$NON-NLS-1$
- static public String ECLIPSELINK_DDL_GEN_CLASS = DDL_GEN_PACKAGE_NAME + ".Main"; //$NON-NLS-1$
- static public String ECLIPSELINK_DDL_GEN_JAR = DDL_GEN_PACKAGE_NAME + "_"; //$NON-NLS-1$
- static public String BUNDLE_CLASSPATH = "Bundle-ClassPath"; //$NON-NLS-1$
- static public String PROPERTIES_FILE_NAME = "login.properties"; //$NON-NLS-1$
- static public String PLUGINS_DIR = "plugins/"; //$NON-NLS-1$
- static public String TRUE = "true"; //$NON-NLS-1$
- static public String FALSE = "false"; //$NON-NLS-1$
- static public String NONE = "NONE"; //$NON-NLS-1$
- private IVMInstall jre;
- private ILaunchConfigurationWorkingCopy launchConfig;
- private ILaunch launch;
-
- private String puName;
- private JpaProject jpaProject;
- private String projectLocation;
- private boolean isDebug = false;
-
+
// ********** constructors **********
- public static void generate(String puName, JpaProject project, String projectLocation, IProgressMonitor monitor) {
+ public static void generate(String puName, JpaProject project, IProgressMonitor monitor) {
if (puName == null || puName.length() == 0 || project == null) {
throw new NullPointerException();
}
- new EclipseLinkDDLGenerator(puName, project, projectLocation, monitor).generate();
- }
-
- protected EclipseLinkDDLGenerator(String puName, JpaProject jpaProject, String projectLocation, @SuppressWarnings("unused") IProgressMonitor monitor) {
- super();
- this.puName = puName;
- this.jpaProject = jpaProject;
- this.projectLocation = projectLocation;
- this.initialize();
- }
-
- // ********** behavior **********
-
- protected void initialize() {
- try {
- this.jre = this.getProjectJRE();
- if (this.jre == null) {
- String message = "Could not identify the VM.";
- throw new RuntimeException(message);
- }
- this.launchConfig = this.buildLaunchConfiguration();
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void generate() {
- this.preGenerate();
- String propertiesFile = this.projectLocation + "/" + PROPERTIES_FILE_NAME; //$NON-NLS-1$
-
- this.initializeLaunchConfiguration(this.projectLocation, propertiesFile);
-
- this.saveLoginProperties(this.projectLocation, propertiesFile);
-
- this.addLaunchListener();
- this.launch = this.saveAndLaunchConfig();
- }
-
- private void initializeLaunchConfiguration(String projectLocation, String propertiesFile) {
-
- this.specifyJRE(this.jre.getName(), this.jre.getVMInstallType().getId());
-
- this.specifyProject(this.getJpaProject().getProject().getName());
- this.specifyMainType(ECLIPSELINK_DDL_GEN_CLASS);
-
- this.specifyProgramArguments(this.puName, propertiesFile); // -pu & -p
- this.specifyWorkingDir(projectLocation);
-
- this.specifyClasspathProperties(this.getJpaProject(), this.buildJdbcJarPath(), this.buildBootstrapJarPath());
- }
-
- private void addLaunchListener() {
-
- this.getLaunchManager().addLaunchListener(this.buildLaunchListener());
- }
-
- protected void preGenerate() {
- //disconnect since the runtime provider will need to connect to generate the tables
- ConnectionProfile cp = this.getConnectionProfile();
- if (cp != null) {
- cp.disconnect();
- }
- }
-
- protected void postGenerate() {
- try {
- if ( ! this.isDebug) {
- this.removeLaunchConfiguration(LAUNCH_CONFIG_NAME);
- }
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
- this.reconnect();
- this.validateProject();
- }
-
- //reconnect since we disconnected in preGenerate(),
- //use the synchronous JPA project updater so we can ensure
- //the project is fully updated before validating. bug 277236
- protected void reconnect() {
- JpaProject.Updater updater = getJpaProject().getUpdater();
- getJpaProject().setUpdater(new SynchronousJpaProjectUpdater(getJpaProject()));
- ConnectionProfile cp = this.getConnectionProfile();
- if (cp != null) {
- cp.connect();
- }
- getJpaProject().setUpdater(updater);
- }
-
- protected void validateProject() {
- IProject project = this.getJpaProject().getProject();
- ValidateJob job = new ValidateJob(project);
- job.setRule(project);
- job.schedule();
- }
-
- /**
- * Performs validation after tables have been generated
- */
- private class ValidateJob extends Job
- {
- private IProject project;
-
-
- public ValidateJob(IProject project) {
- super(JptCoreMessages.VALIDATE_JOB);
- this.project = project;
- }
-
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- ValidationFramework.getDefault().validate(
- new IProject[] {this.project}, true, false, monitor);
- }
- catch (CoreException ce) {
- status = Status.CANCEL_STATUS;
- }
- return status;
- }
- }
-
- private IPath buildJdbcJarPath() {
- return new Path(this.getJpaProjectConnectionDriverJarList());
- }
-
- private String getJpaProjectConnectionDriverJarList() {
- ConnectionProfile cp = this.getConnectionProfile();
- return (cp == null) ? "" : cp.getDriverJarList(); //$NON-NLS-1$
- }
-
- private IPath buildBootstrapJarPath() {
- try {
- File jarInstallDir = this.getBundleParentDir(JptEclipseLinkCorePlugin.PLUGIN_ID);
-
- List<File> result = new ArrayList<File>();
- this.findFile(ECLIPSELINK_DDL_GEN_JAR, jarInstallDir, result);
- if (result.isEmpty()) {
- throw new RuntimeException("Could not find: " + DDL_GEN_PACKAGE_NAME + ".jar in: " + jarInstallDir);
- }
- File ddlGenJarFile = result.get(0);
- String ddlGenJarPath = ddlGenJarFile.getCanonicalPath();
- return new Path(ddlGenJarPath);
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void findFile(String fileName, File directory, List<? super File> list) {
- if(directory.listFiles() == null) {
- throw new RuntimeException("Could not find directory: " + directory);
- }
- for (File file : directory.listFiles()) {
- if (file.getName().startsWith(fileName)) {
- list.add(file);
- }
- if (file.isDirectory()) {
- this.findFile(fileName, file, list);
- }
- }
- }
-
- private File getBundleParentDir(String bundleName) throws IOException {
-
- if (Platform.inDevelopmentMode()) {
- Location eclipseHomeLoc = Platform.getInstallLocation();
- String eclipseHome = eclipseHomeLoc.getURL().getPath();
- if ( ! eclipseHome.endsWith(PLUGINS_DIR)) {
- eclipseHome += PLUGINS_DIR;
- }
- return new File(eclipseHome);
- }
- Bundle bundle = Platform.getBundle(bundleName);
- return FileLocator.getBundleFile(bundle).getParentFile();
- }
-
- private ILaunchesListener2 buildLaunchListener() {
- return new ILaunchesListener2() {
-
- public void launchesTerminated(ILaunch[] launches) {
- for (int i = 0; i < launches.length; i++) {
- ILaunch launch = launches[i];
- if (launch.equals(EclipseLinkDDLGenerator.this.getLaunch())) {
-
- EclipseLinkDDLGenerator.this.postGenerate();
- return;
- }
- }
- }
-
- public void launchesAdded(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesChanged(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesRemoved(ILaunch[] launches) {
- // not interested to this event
- }
- };
- }
-
- // ********** Setting Launch Configuration **********
-
- private void specifyJRE(String jreName, String vmId) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreName);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmId);
- }
-
- private void specifyProject(String projectName) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
- }
-
- private void specifyMainType(String mainType) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
- }
-
- private void specifyProgramArguments(String puName, String propertiesPath) {
-
- StringBuffer programArguments = new StringBuffer();
- programArguments.append(this.buildPuNameArgument(puName));
- programArguments.append(this.buildPropertiesFileArgument(propertiesPath));
- programArguments.append(this.buildDebugArgument());
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
- }
-
- private void specifyClasspathProperties(JpaProject project, IPath jdbcJar, IPath bootstrapJar) {
- List<String> classpath = new ArrayList<String>();
- try {
- // DDL_GEN jar
- classpath.add(this.getArchiveClasspathEntry(bootstrapJar).getMemento());
- // Default Project classpath
- classpath.add(this.getDefaultProjectClasspathEntry(project.getJavaProject()).getMemento());
- // Osgi Bundles
- classpath.addAll(this.getPersistenceOsgiBundlesMemento());
- // JDBC jar
- classpath.add(this.getArchiveClasspathEntry(jdbcJar).getMemento());
- // System Library
- classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
- }
- catch (CoreException e) {
- throw new RuntimeException("An error occurs generating a memento", e);
- }
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- }
-
- private void specifyWorkingDir(String projectLocation) {
-
- File workingDir = new Path(projectLocation).toFile();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath());
- }
-
- // ********** ClasspathEntry **********
-
- private IRuntimeClasspathEntry getSystemLibraryClasspathEntry() throws CoreException {
-
- IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
- return JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath, IRuntimeClasspathEntry.STANDARD_CLASSES);
- }
-
- private IRuntimeClasspathEntry getDefaultProjectClasspathEntry(IJavaProject project) {
-
- IRuntimeClasspathEntry projectEntry = JavaRuntime.newDefaultProjectClasspathEntry(project);
- projectEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return projectEntry;
- }
-
- private IRuntimeClasspathEntry getArchiveClasspathEntry(IPath archivePath) {
-
- IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(archivePath);
- archiveEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return archiveEntry;
- }
-
- private IRuntimeClasspathEntry getBundleClasspathEntry(String bundleId) {
-
- IPath persistClasspath = this.getBundleClasspath(bundleId);
- IRuntimeClasspathEntry bundleEntry = this.getArchiveClasspathEntry(persistClasspath);
-
- return bundleEntry;
- }
-
- // ********** LaunchConfig **********
-
- private ILaunch saveAndLaunchConfig() {
- ILaunchConfiguration configuration = null;
- ILaunch result = null;
- try {
- configuration = this.launchConfig.doSave();
- }
- catch (CoreException saveException) {
- throw new RuntimeException("Could not save LaunchConfig", saveException);
- }
- try {
- result = configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- }
- catch (CoreException lauchException) {
- throw new RuntimeException("An error occured during launch", lauchException);
- }
- return result;
+ new EclipseLinkDDLGenerator(puName, project).generate(monitor);
}
- private ILaunchConfigurationWorkingCopy buildLaunchConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy launchConfig = null;
- this.removeLaunchConfiguration( LAUNCH_CONFIG_NAME);
-
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- launchConfig = type.newInstance(null, LAUNCH_CONFIG_NAME);
- return launchConfig;
+ private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject) {
+ super(puName, jpaProject);
}
- private void removeLaunchConfiguration(String launchConfigurationName) throws CoreException {
-
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
- for (int i = 0; i < configurations.length; i++) {
- ILaunchConfiguration configuration = configurations[i];
- if (configuration.getName().equals(launchConfigurationName)) {
- configuration.delete();
- break;
- }
- }
- }
-
- // ********** EclipseLink properties **********
-
- private void buildProjectLocationProperty(Properties properties, String location) {
- this.putProperty(properties,
- SchemaGeneration.ECLIPSELINK_APPLICATION_LOCATION,
- location);
- }
-
- private void buildDDLModeProperties(Properties properties) {
- this.putProperty(properties,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
- DdlGenerationType.DROP_AND_CREATE_TABLES);
- this.putProperty(properties,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
- OutputMode.DATABASE);
- }
-
+ @Override
protected void buildConnectionProperties(Properties properties) {
+ super.buildConnectionProperties(properties);
ConnectionProfile cp = this.getConnectionProfile();
- this.putProperty(properties,
- Connection.ECLIPSELINK_BIND_PARAMETERS,
- FALSE);
this.putProperty(properties,
Connection.ECLIPSELINK_DRIVER,
- (cp == null) ? "" : cp.getDriverClassName());
+ (cp == null) ? "" : cp.getDriverClassName()); //$NON-NLS-1$
this.putProperty(properties,
Connection.ECLIPSELINK_URL,
- (cp == null) ? "" : cp.getURL());
+ (cp == null) ? "" : cp.getURL()); //$NON-NLS-1$
this.putProperty(properties,
Connection.ECLIPSELINK_USER,
- (cp == null) ? "" : cp.getUserName());
+ (cp == null) ? "" : cp.getUserName()); //$NON-NLS-1$
this.putProperty(properties,
Connection.ECLIPSELINK_PASSWORD,
- (cp == null) ? "" : cp.getUserPassword());
- }
-
- private void buildConnectionPoolingProperties(Properties properties) {
- this.putProperty(properties,
- Connection.ECLIPSELINK_READ_CONNECTIONS_SHARED,
- TRUE);
- }
-
- private void buildLoggingProperties(Properties properties) {
- this.putProperty(properties,
- Logging.ECLIPSELINK_LEVEL,
- LoggingLevel.FINE);
- this.putProperty(properties,
- Logging.ECLIPSELINK_TIMESTAMP,
- FALSE);
- this.putProperty(properties,
- Logging.ECLIPSELINK_THREAD,
- FALSE);
- this.putProperty(properties,
- Logging.ECLIPSELINK_SESSION,
- FALSE);
- this.putProperty(properties,
- Logging.ECLIPSELINK_EXCEPTIONS,
- TRUE);
- }
-
- protected void buildCustomizationProperties(Properties properties) {
- this.putProperty(properties,
- Customization.ECLIPSELINK_THROW_EXCEPTIONS,
- TRUE);
- }
-
- protected void putProperty(Properties properties, String key, String value) {
- properties.put(key, (value == null) ? "" : value); //$NON-NLS-1$
- }
-
- protected void buildAllProperties(Properties properties, String projectLocation) {
-
- this.buildConnectionProperties(properties);
-
- this.buildConnectionPoolingProperties(properties);
-
- this.buildLoggingProperties(properties);
-
- this.buildCustomizationProperties(properties);
-
- this.buildDDLModeProperties(properties);
-
- this.buildProjectLocationProperty(properties, projectLocation);
- }
-
- private void saveLoginProperties(String projectLocation, String propertiesFile) {
- Properties elProperties = new Properties();
-
- this.buildAllProperties(elProperties, projectLocation);
-
- try {
- File file = new File(propertiesFile);
- if (!file.exists() && ! file.createNewFile()) {
- throw new RuntimeException("createNewFile() failed: " + file); //$NON-NLS-1$
- }
- FileOutputStream stream = new FileOutputStream(file);
- elProperties.store(stream, null);
- stream.close();
- }
- catch (Exception e) {
- String message = "Error saving: " + propertiesFile;
- throw new RuntimeException(message, e);
- }
- }
-
- // ********** Main arguments **********
-
- private String buildPuNameArgument(String puName) {
- return " -pu \"" + puName + "\""; //$NON-NLS-1$
- }
-
- private String buildPropertiesFileArgument(String propertiesFile) {
- return " -p \"" + propertiesFile + "\""; //$NON-NLS-1$
- }
-
- private String buildDebugArgument() {
- return (this.isDebug) ? " -debug" : ""; //$NON-NLS-1$
- }
-
- // ********** Queries **********
-
- protected JpaPlatform getPlatform() {
- return this.getJpaProject().getJpaPlatform();
- }
-
- protected JpaProject getJpaProject() {
- return this.jpaProject;
- }
-
-
- protected ConnectionProfile getConnectionProfile() {
- return this.getJpaProject().getConnectionProfile();
- }
-
- protected ILaunch getLaunch() {
- return this.launch;
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- private IVMInstall getProjectJRE() throws CoreException {
- return JavaRuntime.getVMInstall(this.getJpaProject().getJavaProject());
- }
-
- // ********** Bundles *********
-
- private Collection<String> getPersistenceOsgiBundlesMemento() throws CoreException {
-
- Collection<String> result = new HashSet<String>();
- if (javaxPersistenceBundleExists()) {
- result.add(this.getBundleClasspathEntry(JAVAX_PERSISTENCE_BUNDLE).getMemento());
- result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_CORE_BUNDLE).getMemento());
- result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_ASM_BUNDLE).getMemento());
- result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_ANTLR_BUNDLE).getMemento());
- result.add(this.getBundleClasspathEntry(ORG_ECLIPSE_PERSISTENCE_JPA_BUNDLE).getMemento());
- }
- return result;
- }
-
- private IPath getBundleClasspath(String pluginID) {
- Bundle bundle = Platform.getBundle(pluginID);
- if (bundle == null) {
- throw new RuntimeException(pluginID + " cannot be retrieved from the Platform");
- }
- return this.getClassPath(bundle);
+ (cp == null) ? "" : cp.getUserPassword()); //$NON-NLS-1$
}
-
- private IPath getClassPath(Bundle bundle) {
- String path = (String) bundle.getHeaders().get(BUNDLE_CLASSPATH);
- if (path == null) {
- path = "."; //$NON-NLS-1$
- }
- ManifestElement[] elements = null;
- try {
- elements = ManifestElement.parseHeader(BUNDLE_CLASSPATH, path);
- }
- catch (BundleException e) {
- throw new RuntimeException("Error parsing bundle header: " + bundle, e);
- }
- if (elements != null) {
- for (int i = 0; i < elements.length; ++i) {
- ManifestElement element = elements[i];
- String value = element.getValue();
- if (".".equals(value)) { //$NON-NLS-1$
- value = "/"; //$NON-NLS-1$
- }
- URL url = bundle.getEntry(value);
- if (url != null) {
- try {
- URL resolvedURL = FileLocator.resolve(url);
- String filestring = FileLocator.toFileURL(resolvedURL).getFile();
- if (filestring.startsWith("file:")) { //$NON-NLS-1$
- filestring = filestring.substring(filestring.indexOf(':') + 1);
- }
- if (filestring.endsWith("!/")) { //$NON-NLS-1$
- filestring = filestring.substring(0, filestring.lastIndexOf('!'));
- }
- File file = new File(filestring);
- String filePath = file.getCanonicalPath();
- return new Path(filePath);
- }
- catch (IOException e) {
- throw new RuntimeException("Error locating bundle: " + bundle, e);
- }
- }
- }
- }
- return null;
- }
-
- private boolean javaxPersistenceBundleExists() {
- return Platform.getBundle(JAVAX_PERSISTENCE_BUNDLE) != null;
- }
-
- // ********** constants **********
-
- private static final String JAVAX_PERSISTENCE_BUNDLE = "javax.persistence"; //$NON-NLS-1$
- private static final String ORG_ECLIPSE_PERSISTENCE_CORE_BUNDLE = "org.eclipse.persistence.core"; //$NON-NLS-1$
- private static final String ORG_ECLIPSE_PERSISTENCE_ASM_BUNDLE = "org.eclipse.persistence.asm"; //$NON-NLS-1$
- private static final String ORG_ECLIPSE_PERSISTENCE_ANTLR_BUNDLE = "org.eclipse.persistence.antlr"; //$NON-NLS-1$
- private static final String ORG_ECLIPSE_PERSISTENCE_JPA_BUNDLE = "org.eclipse.persistence.jpa"; //$NON-NLS-1$
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
index 95b09f6c90..8c408fe046 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v2_0/ddlgen/EclipseLink2_0DDLGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009 Oracle. All rights reserved.
+* Copyright (c) 2009, 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.
@@ -10,40 +10,45 @@
package org.eclipse.jpt.eclipselink.core.internal.v2_0.ddlgen;
import java.util.Properties;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.jpa2.context.persistence.connection.JpaConnection2_0;
import org.eclipse.jpt.db.ConnectionProfile;
-import org.eclipse.jpt.eclipselink.core.context.persistence.connection.Connection;
import org.eclipse.jpt.eclipselink.core.context.persistence.customization.Customization;
-import org.eclipse.jpt.eclipselink.core.internal.ddlgen.EclipseLinkDDLGenerator;
+import org.eclipse.jpt.eclipselink.core.internal.ddlgen.AbstractEclipseLinkDDLGenerator;
/**
- * EclipseLink2_0DDLGenerator
+ * EclipseLink2_0DLLGenerator launches the EclipseLink DDL generator in a separate VM.
+ * For this it will create a Java Configuration named "Dali EclipseLink Table Generation"
+ * in the target workspace (note: the configuration will be overridden at each run).
+ * It will than launch the configuration created with the login information from
+ * the current Dali project, and passes it to EclipseLink.
+ *
+ * Pre-req in PDE environment:
+ * org.eclipse.jpt.eclipselink.core.ddlgen.jar in ECLIPSE_HOME/plugins
*/
-public class EclipseLink2_0DDLGenerator extends EclipseLinkDDLGenerator
+public class EclipseLink2_0DDLGenerator extends AbstractEclipseLinkDDLGenerator
{
static final String VALIDATION_MODE_PROPERTY = "javax.persistence.validation.mode"; //$NON-NLS-1$
// ********** constructors **********
- public static void generate(String puName, JpaProject project, String projectLocation, IProgressMonitor monitor) {
+ public static void generate(String puName, JpaProject project, IProgressMonitor monitor) {
if (puName == null || puName.length() == 0 || project == null) {
throw new NullPointerException();
}
- new EclipseLink2_0DDLGenerator(puName, project, projectLocation, monitor).generate();
+ new EclipseLink2_0DDLGenerator(puName, project).generate(monitor);
}
- private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject, String projectLocation, IProgressMonitor monitor) {
- super(puName, jpaProject, projectLocation, monitor);
+ private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject) {
+ super(puName, jpaProject);
}
// ********** EclipseLink properties **********
@Override
- protected void buildAllProperties(Properties properties, String projectLocation) {
- super.buildAllProperties(properties, projectLocation);
+ protected void buildAllProperties(Properties properties) {
+ super.buildAllProperties(properties);
this.putProperty(properties,
VALIDATION_MODE_PROPERTY,
@@ -61,22 +66,20 @@ public class EclipseLink2_0DDLGenerator extends EclipseLinkDDLGenerator
@Override
protected void buildConnectionProperties(Properties properties) {
+ super.buildConnectionProperties(properties);
ConnectionProfile cp = this.getConnectionProfile();
- this.putProperty(properties,
- Connection.ECLIPSELINK_BIND_PARAMETERS,
- FALSE);
this.putProperty(properties,
JpaConnection2_0.PERSISTENCE_JDBC_DRIVER,
- (cp == null) ? "" : cp.getDriverClassName());
+ (cp == null) ? "" : cp.getDriverClassName()); //$NON-NLS-1$
this.putProperty(properties,
JpaConnection2_0.PERSISTENCE_JDBC_URL,
- (cp == null) ? "" : cp.getURL());
+ (cp == null) ? "" : cp.getURL()); //$NON-NLS-1$
this.putProperty(properties,
JpaConnection2_0.PERSISTENCE_JDBC_USER,
- (cp == null) ? "" : cp.getUserName());
+ (cp == null) ? "" : cp.getUserName()); //$NON-NLS-1$
this.putProperty(properties,
JpaConnection2_0.PERSISTENCE_JDBC_PASSWORD,
- (cp == null) ? "" : cp.getUserPassword());
+ (cp == null) ? "" : cp.getUserPassword()); //$NON-NLS-1$
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties
index 580d720fbf..f59056519e 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui.properties
@@ -381,3 +381,5 @@ TargetServerComposite_jboss = JBoss
EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle = Generating DDL
EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage = Warning: Generating DDL will DROP existing tables and{0}CREATE new tables based on the Entities in your project.{1}Are you sure you want to continue?
EclipseLinkDDLGeneratorUi_error = Error
+ECLIPSELINK_GENERATE_TABLES_JOB = Generating Tables from Entities
+ECLIPSELINK_GENERATE_TABLES_TASK = Generating
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java
index 21c65dd354..04a9a38cc9 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/EclipseLinkUiMessages.java
@@ -386,6 +386,8 @@ public class EclipseLinkUiMessages {
public static String EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle;
public static String EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage;
public static String EclipseLinkDDLGeneratorUi_error;
+ public static String ECLIPSELINK_GENERATE_TABLES_JOB;
+ public static String ECLIPSELINK_GENERATE_TABLES_TASK;
private static final String BUNDLE_NAME = "eclipselink_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = EclipseLinkUiMessages.class;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
index 3e9859d810..fa6ddc15c4 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2009 Oracle. All rights reserved.
+* 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.
@@ -11,12 +11,13 @@ package org.eclipse.jpt.eclipselink.ui.internal.ddlgen;
import java.util.Iterator;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
@@ -73,17 +74,12 @@ public class EclipseLinkDDLGeneratorUi
return;
}
}
- IWorkspaceRunnable runnable = this.buildGenerateDDLRunnable(puName, this.project);
- try {
- ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
- }
- catch (CoreException ex) {
- throw new RuntimeException(ex);
- }
+ WorkspaceJob job = this.buildGenerateDDLJob(puName, this.project);
+ job.schedule();
}
- protected IWorkspaceRunnable buildGenerateDDLRunnable(String puName, JpaProject project) {
- return new GenerateDDLRunnable(puName, project);
+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project) {
+ return new GenerateDDLJob(puName, project);
}
private Shell getCurrentShell() {
@@ -117,24 +113,24 @@ public class EclipseLinkDDLGeneratorUi
// ********** runnable **********
- protected static class GenerateDDLRunnable implements IWorkspaceRunnable {
+ protected static class GenerateDDLJob extends WorkspaceJob {
private final String puName;
private final JpaProject project;
- public GenerateDDLRunnable(String puName, JpaProject project) {
- super();
+ public GenerateDDLJob(String puName, JpaProject project) {
+ super(EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_JOB);
this.puName = puName;
this.project = project;
}
- public void run(IProgressMonitor monitor) {
- String projectLocation = this.project.getProject().getLocation().toString();
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ SubMonitor sm = SubMonitor.convert(monitor, EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_TASK, 1);
try {
- this.ddlGeneratorGenerate(this.puName, this.project, projectLocation, monitor);
+ this.ddlGeneratorGenerate(this.puName, this.project, sm.newChild(1));
}
catch (OperationCanceledException e) {
- return;
- // fall through and tell monitor we are done
+ return Status.CANCEL_STATUS;
}
catch (RuntimeException re) {
String msg = re.getMessage();
@@ -143,14 +139,15 @@ public class EclipseLinkDDLGeneratorUi
this.logError(message);
throw new RuntimeException(re);
}
+ return Status.OK_STATUS;
}
- protected void ddlGeneratorGenerate(String puName, JpaProject project, String projectLocation, IProgressMonitor monitor) {
- EclipseLinkDDLGenerator.generate(puName, project, projectLocation, monitor);
+ protected void ddlGeneratorGenerate(String puName, JpaProject project, IProgressMonitor monitor) {
+ EclipseLinkDDLGenerator.generate(puName, project, monitor);
}
protected void logError(String message) {
- this.displayError(message);
+ this.displayError(message);
}
private void displayError(String message) {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
index e433b0003a..90d0dcacdc 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/v2_0/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009 Oracle. All rights reserved.
+* Copyright (c) 2009, 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.
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.ui.internal.v2_0.ddlgen.wizards;
-import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.eclipselink.core.internal.v2_0.ddlgen.EclipseLink2_0DDLGenerator;
@@ -36,21 +36,21 @@ public class EclipseLink2_0DDLGeneratorUi extends EclipseLinkDDLGeneratorUi
// ********** behavior **********
@Override
- protected IWorkspaceRunnable buildGenerateDDLRunnable(String puName, JpaProject project) {
- return new Generate2_0DDLRunnable(puName, project);
+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project) {
+ return new Generate2_0DDLJob(puName, project);
}
// ********** runnable **********
- protected static class Generate2_0DDLRunnable extends EclipseLinkDDLGeneratorUi.GenerateDDLRunnable {
+ protected static class Generate2_0DDLJob extends EclipseLinkDDLGeneratorUi.GenerateDDLJob {
- public Generate2_0DDLRunnable(String puName, JpaProject project) {
+ public Generate2_0DDLJob(String puName, JpaProject project) {
super(puName, project);
}
@Override
- protected void ddlGeneratorGenerate(String puName, JpaProject project, String projectLocation, IProgressMonitor monitor) {
- EclipseLink2_0DDLGenerator.generate(puName, project, projectLocation, monitor);
+ protected void ddlGeneratorGenerate(String puName, JpaProject project, IProgressMonitor monitor) {
+ EclipseLink2_0DDLGenerator.generate(puName, project, monitor);
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java
index 90489abfa0..3bb6027776 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java
@@ -30,7 +30,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@@ -47,6 +46,7 @@ import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.gen.internal.util.CompilationUnitModifier;
import org.eclipse.jpt.gen.internal.util.FileUtil;
import org.eclipse.jpt.gen.internal.util.UrlUtil;
+import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Bundle;
@@ -56,68 +56,63 @@ import org.osgi.framework.Bundle;
public class PackageGenerator {
private static final String LOGGER_NAME = "org.eclipse.jpt.entities.gen.log"; //$NON-NLS-1$
- private JpaProject jpaProject;
- private ORMGenCustomizer customizer;
- private static OverwriteConfirmer overwriteConfirmer = null;
+ private final JpaProject jpaProject;
+ private final ORMGenCustomizer customizer;
+ private final OverwriteConfirmer overwriteConfirmer;
- static public void setOverwriteConfirmer(OverwriteConfirmer confirmer){
- overwriteConfirmer = confirmer;
- }
- /**
- * @param customizer
- * @param synchronizePersistenceXml
- * @param copyJdbcDrive
- * @throws Exception
- */
- static public void generate(JpaProject jpaProject, ORMGenCustomizer customizer, IProgressMonitor monitor ) throws CoreException {
- PackageGenerator generator = new PackageGenerator();
- generator.setProject(jpaProject);
- generator.setCustomizer(customizer);
-
+ public static void generate(JpaProject jpaProject, ORMGenCustomizer customizer, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) throws CoreException {
+ SubMonitor sm = SubMonitor.convert(monitor, 20);
+ PackageGenerator generator = new PackageGenerator(jpaProject, customizer, overwriteConfirmer);
+ sm.worked(1);
try {
- generator.doGenerate(monitor);
+ generator.doGenerate(sm.newChild(19));
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, JptGenPlugin.PLUGIN_ID, JptGenMessages.Error_Generating_Entities, e));
}
}
+ private PackageGenerator(JpaProject jpaProject, ORMGenCustomizer customizer, OverwriteConfirmer confirmer) {
+ super();
+ this.jpaProject = jpaProject;
+ this.customizer = customizer;
+ this.overwriteConfirmer = confirmer;
+ }
+
private Object getCustomizer() {
return this.customizer;
}
- private void setCustomizer(ORMGenCustomizer customizer2) {
- this.customizer = customizer2;
- }
-
- private void setProject(JpaProject proj ){
- this.jpaProject = proj;
+ private IJavaProject getJavaProject(){
+ return this.jpaProject.getJavaProject();
}
+
- protected void doGenerate(IProgressMonitor monitor ) throws Exception {
- generateInternal( monitor );
+ protected void doGenerate(IProgressMonitor monitor) throws Exception {
+ generateInternal(monitor);
}
- protected void generateInternal(IProgressMonitor progress) throws Exception {
+ protected void generateInternal(IProgressMonitor monitor) throws Exception {
File templDir = prepareTemplatesFolder();
List<String> genClasses = new java.util.ArrayList<String>();
List<String> tableNames = this.customizer.getGenTableNames();
/* .java per table, persistence.xml, refresh package folder */
- String taskName = NLS.bind(JptGenMessages.EntityGenerator_taskName, "Total "+ tableNames.size() + 2);//$NON-NLS-1$
- progress.beginTask(taskName, tableNames.size() + 2);
+ SubMonitor sm = SubMonitor.convert(monitor, tableNames.size() + 2);
for (Iterator<String> iter = tableNames.iterator(); iter.hasNext();) {
+ if (sm.isCanceled()) {
+ return;
+ }
String tableName = iter.next();
- ORMGenTable table = customizer.getTable(tableName);
+ ORMGenTable table = this.customizer.getTable(tableName);
String className = table.getQualifiedClassName();
- generateClass(table, templDir.getAbsolutePath(), progress);
- progress.worked(1);
+ generateClass(table, templDir.getAbsolutePath(), sm.newChild(1, SubMonitor.SUPPRESS_NONE));
- genClasses.add( className );
+ genClasses.add(className);
/*
* add the composite key class to persistence.xml because some
* JPA provider(e.g. Kodo) requires it. Hibernate doesn't seem to care).
@@ -126,16 +121,19 @@ public class PackageGenerator {
genClasses.add(table.getQualifiedCompositeKeyClassName());
}
}
+ if (sm.isCanceled()) {
+ return;
+ }
//update persistence.xml
if (this.customizer.shouldUpdatePersistenceXml()) {
updatePersistenceXml(genClasses);
}
- progress.done();
+ sm.worked(2);
}
private void updatePersistenceXml(final List<String> genClasses) {
- JpaXmlResource resource = jpaProject.getPersistenceXmlResource();
+ JpaXmlResource resource = this.jpaProject.getPersistenceXmlResource();
if (resource == null) {
//the resource would only be null if the persistence.xml file had an invalid content type,
//do not attempt to update
@@ -144,7 +142,7 @@ public class PackageGenerator {
resource.modify(new Runnable() {
public void run() {
- Persistence persistence = jpaProject.getRootContextNode().getPersistenceXml().getPersistence();
+ Persistence persistence = PackageGenerator.this.jpaProject.getRootContextNode().getPersistenceXml().getPersistence();
if (persistence == null) {
// invalid content, do not attempt to update
return;
@@ -153,14 +151,14 @@ public class PackageGenerator {
// create a persistence unit if one doesn't already exist
if (persistence.persistenceUnitsSize() == 0) {
persistenceUnit = persistence.addPersistenceUnit();
- persistenceUnit.setName(jpaProject.getName());
+ persistenceUnit.setName(PackageGenerator.this.jpaProject.getName());
} else {
// we only support one persistence unit - take the first one
persistenceUnit = persistence.persistenceUnits().next();
}
for (Iterator<String> stream = genClasses.iterator(); stream.hasNext();) {
String className = stream.next();
- if (!persistenceUnit.mappingFileRefsContaining(className).hasNext() && !persistenceUnit.specifiesPersistentType(className)) {
+ if (!CollectionTools.isEmpty(persistenceUnit.mappingFileRefsContaining(className)) && !persistenceUnit.specifiesPersistentType(className)) {
ClassRef classRef = persistenceUnit.addSpecifiedClassRef();
classRef.setClassName(className);
}
@@ -179,21 +177,21 @@ public class PackageGenerator {
String templatesPath = "templates/entities/"; //$NON-NLS-1$
Path path = new Path( templatesPath);
URL url = FileLocator.find(bundle, path, null);
- if ( url ==null ) {
+ if (url == null) {
throw new CoreException(new Status(IStatus.ERROR, JptGenPlugin.PLUGIN_ID, JptGenMessages.Templates_notFound + " "+ JptGenPlugin.PLUGIN_ID + "/" + templatesPath) );//$NON-NLS-1$
}
URL templUrl = FileLocator.resolve(url);
//Have this check so that the code would work in both PDE and JARed plug-in at runtime
File templDir = null;
- if( UrlUtil.isJarUrl(templUrl) ){
+ if (UrlUtil.isJarUrl(templUrl)) {
templDir = FileUtil.extractFilesFromBundle( templUrl, bundle, templatesPath );
- }else{
+ } else {
templDir = UrlUtil.getUrlFile(templUrl);
}
- if (templDir==null || !templDir.exists()) {
+ if (templDir == null || !templDir.exists()) {
throw new CoreException(new Status(IStatus.ERROR, JptGenPlugin.PLUGIN_ID, JptGenMessages.Templates_notFound + " "+ JptGenPlugin.PLUGIN_ID ) );//$NON-NLS-1$
}
return templDir;
@@ -211,15 +209,16 @@ public class PackageGenerator {
protected void generateClass(ORMGenTable table, String templateDirPath, IProgressMonitor monitor) throws Exception {
String subTaskName = NLS.bind(JptGenMessages.EntityGenerator_taskName, table.getName());
- SubMonitor sm = SubMonitor.convert(monitor, subTaskName, 100);
+ SubMonitor sm = SubMonitor.convert(monitor, subTaskName, 10);
- try{
+ try {
IFolder javaPackageFolder = getJavaPackageFolder(table, monitor);
IFile javaFile = javaPackageFolder.getFile( table.getClassName() + ".java"); //$NON-NLS-1$
- if( javaFile.exists() ){
- if( overwriteConfirmer!=null && !overwriteConfirmer.overwrite(javaFile.getName()) )
+ if (javaFile.exists()) {
+ if (this.overwriteConfirmer != null && !this.overwriteConfirmer.overwrite(javaFile.getName())) {
return;
+ }
}
//JdkLogChute in this version of Velocity not allow to set log level
//Workaround by preset the log level before Velocity is initialized
@@ -231,23 +230,23 @@ public class PackageGenerator {
vep.setProperty( JdkLogChute.RUNTIME_LOG_JDK_LOGGER, LOGGER_NAME );
VelocityEngine ve = new VelocityEngine();
ve.init(vep);
- sm.worked(20);
+ sm.worked(2);
- generateJavaFile(table, javaFile, ve, "main.java.vm", true/*isDomainClass*/, monitor); //$NON-NLS-1$
- sm.worked(80);
+ generateJavaFile(table, javaFile, ve, "main.java.vm", true/*isDomainClass*/, sm.newChild(6)); //$NON-NLS-1$
if (table.isCompositeKey()) {
IFile compositeKeyFile = javaPackageFolder.getFile( table.getCompositeKeyClassName()+".java"); //$NON-NLS-1$
- generateJavaFile(table, compositeKeyFile, ve, "pk.java.vm", false/*isDomainClass*/, monitor ); //$NON-NLS-1$
+ generateJavaFile(table, compositeKeyFile, ve, "pk.java.vm", false/*isDomainClass*/, sm.newChild(1)); //$NON-NLS-1$
}
-
- javaFile.refreshLocal(1, new NullProgressMonitor());
+ else {
+ sm.setWorkRemaining(1);
+ }
+ javaFile.refreshLocal(1, sm.newChild(1));
- } catch(Throwable e){
+ } catch (Throwable e) {
CoreException ce = new CoreException(new Status(IStatus.ERROR, JptGenPlugin.PLUGIN_ID, JptGenMessages.Templates_notFound + "" + JptGenPlugin.PLUGIN_ID , e) );//$NON-NLS-1$
JptGenPlugin.logException( ce );
}
- sm.setWorkRemaining(0);
}
private void generateJavaFile(ORMGenTable table, IFile javaFile, VelocityEngine ve
@@ -264,7 +263,7 @@ public class PackageGenerator {
if (isDomainClass) {
updateExistingDomainClass(table.getQualifiedClassName(), javaFile, fileContent);
} else {
- javaFile.setContents(new ByteArrayInputStream(fileContent.getBytes()), true, true, monitor );
+ javaFile.setContents(new ByteArrayInputStream(fileContent.getBytes()), true, true, monitor);
}
} else {
createFile(javaFile, new ByteArrayInputStream(fileContent.getBytes()));
@@ -285,8 +284,7 @@ public class PackageGenerator {
/*use CompilationUnitModifier instead of calling WideEnv.getEnv().setFileContent
* so that if the unit is up to date if it is used before file change
* notifications are delivered (see EJB3ImportSchemaWizard.updateExistingDomainClass for example)*/
- IJavaProject project = jpaProject.getJavaProject();
- CompilationUnitModifier modifier = new CompilationUnitModifier(project, className);
+ CompilationUnitModifier modifier = new CompilationUnitModifier(this.getJavaProject(), className);
modifier.setJavaSource(fileContent);
modifier.save();
}
@@ -296,18 +294,14 @@ public class PackageGenerator {
}
public IFolder getJavaPackageFolder(ORMGenTable table, IProgressMonitor monitor) throws CoreException {
- IPackageFragmentRoot root = getDefaultJavaSourceLocation(getJavaProject(), table.getSourceFolder());
+ IPackageFragmentRoot root = getDefaultJavaSourceLocation(this.getJavaProject(), table.getSourceFolder());
String packageName = table.getPackage();
- if( packageName==null ) packageName ="";
+ if (packageName == null) packageName = ""; //$NON-NLS-1$
IPackageFragment packageFragment = root.getPackageFragment(packageName);
if( !packageFragment.exists()){
root.createPackageFragment(packageName, true, monitor);
}
- return (IFolder)packageFragment.getResource();
- }
-
- private IJavaProject getJavaProject(){
- return this.jpaProject.getJavaProject();
+ return (IFolder) packageFragment.getResource();
}
private IPackageFragmentRoot getDefaultJavaSourceLocation(IJavaProject jproject, String sourceFolder){
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
index 4260a4fa79..9f3a358f5e 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.jpt.jaxb.ui;singleton:=true
-Bundle-Version: 1.0.1.qualifier
+Bundle-Version: 1.0.200.qualifier
Bundle-Activator: org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_core.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_core.properties
new file mode 100644
index 0000000000..a04a7c4976
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_core.properties
@@ -0,0 +1,11 @@
+################################################################################
+# 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
+################################################################################
+
+SchemaGenerator_creatingJAXBPropertiesFileTask = Creating jaxb.properties file
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
index 478c762757..e42a280ec7 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
@@ -34,11 +34,13 @@ ClassesGeneratorWizardPage_jaxbLibrariesNotAvailable = \
ClassesGeneratorWizardPage_moxyLibrariesNotAvailable = \
The classpath for this project does not appear to contain the necessary libraries to proceed with class generation.\
\nPlease insure that EclipseLink MOXy is available on the classpath.
+ClassesGeneratorUi_generatingEntities = Generating JAXB Classes from Schema
+ClassesGeneratorUi_generatingEntitiesTask = Generating classes
# SchemaGenerator
SchemaGeneratorWizard_title = JAXB Schema Generation
-SchemaGeneratorWizard_generatingSchema = Generating Schema
+SchemaGeneratorWizard_generatingSchema = Generating JAXB Schema
ProjectWizardPage_desc = Select a Java project.
ProjectWizardPage_project = Project:
@@ -64,4 +66,4 @@ SchemaGeneratorWizardPage_moxyLibrariesNotAvailable = \
The classpath for this project does not appear to contain the necessary libraries to proceed with schema generation.\
\nPlease insure that EclipseLink MOXy is available on the classpath.
-
+SchemaGeneratorWizard_generateSchemaTask=Generating schema {0}
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/ClassesGenerator.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/ClassesGenerator.java
index aa07c9d8fd..1bf7fa6edc 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/ClassesGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/ClassesGenerator.java
@@ -9,54 +9,38 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal;
-import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchesListener2;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jpt.core.internal.gen.AbstractJptGenerator;
import org.eclipse.jpt.utility.internal.StringTools;
/**
* ClassesGenerator
*/
-public class ClassesGenerator
+public class ClassesGenerator extends AbstractJptGenerator
{
- static public String LAUNCH_CONFIG_NAME = "JAXB Run Config"; //$NON-NLS-1$
- static public String JAXB_GENERIC_GEN_CLASS = "com.sun.tools.xjc.XJCFacade"; //$NON-NLS-1$
- static public String JAXB_ECLIPSELINK_GEN_CLASS = "org.eclipse.persistence.jaxb.xjc.MOXyXJC"; //$NON-NLS-1$
+ public static final String LAUNCH_CONFIG_NAME = "JAXB Run Config"; //$NON-NLS-1$
+ public static final String JAXB_GENERIC_GEN_CLASS = "com.sun.tools.xjc.XJCFacade"; //$NON-NLS-1$
+ public static final String JAXB_ECLIPSELINK_GEN_CLASS = "org.eclipse.persistence.jaxb.xjc.MOXyXJC"; //$NON-NLS-1$
- private IVMInstall jre;
- private ILaunchConfigurationWorkingCopy launchConfig;
- private ILaunch launch;
-
- private final IJavaProject javaProject;
private final String xmlSchemaName;
private final String outputDir;
private final String targetPackage;
private final String catalog;
private final String[] bindingsFileNames;
private final String mainType;
- private final boolean isDebug = false;
// ********** static methods **********
@@ -78,8 +62,7 @@ public class ClassesGenerator
targetPackage,
catalog,
useMoxyGenerator,
- bindingsFileNames,
- monitor).generate();
+ bindingsFileNames).generate(monitor);
}
// ********** constructors **********
@@ -91,68 +74,38 @@ public class ClassesGenerator
String targetPackage,
String catalog,
boolean useMoxyGenerator,
- String[] bindingsFileNames,
- @SuppressWarnings("unused") IProgressMonitor monitor) {
- super();
- this.javaProject = javaProject;
+ String[] bindingsFileNames) {
+ super(javaProject);
this.xmlSchemaName = xmlSchemaName;
this.outputDir = outputDir;
this.targetPackage = targetPackage;
this.catalog = catalog;
this.bindingsFileNames = bindingsFileNames;
this.mainType = (useMoxyGenerator) ? JAXB_ECLIPSELINK_GEN_CLASS : JAXB_GENERIC_GEN_CLASS;
-
- this.initialize();
}
- // ********** behavior **********
-
- protected void initialize() {
- try {
- this.jre = this.getProjectJRE();
- if (this.jre == null) {
- String message = "Could not identify the VM."; //$NON-NLS-1$
- throw new RuntimeException(message);
- }
- this.launchConfig = this.buildLaunchConfiguration();
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
+ @Override
+ protected String getMainType() {
+ return this.mainType;
}
- protected void generate() {
- String projectLocation = this.javaProject.getProject().getLocation().toString();
-
- this.initializeLaunchConfiguration(projectLocation);
-
- this.addLaunchListener();
- this.launch = this.saveAndLaunchConfig();
+ @Override
+ protected String getLaunchConfigName() {
+ return LAUNCH_CONFIG_NAME;
}
-
- private void initializeLaunchConfiguration(String projectLocation) {
- this.specifyJRE(this.jre.getName(), this.jre.getVMInstallType().getId());
- this.specifyProject(this.javaProject.getProject().getName());
- this.specifyMainType(this.mainType);
-
- this.specifyProgramArguments(
- this.xmlSchemaName,
- this.outputDir,
- this.targetPackage,
- this.catalog,
- this.bindingsFileNames); // -d -p
- this.specifyWorkingDir(projectLocation);
+ // ********** behavior **********
- this.specifyClasspathProperties(this.javaProject);
+ @Override
+ protected void preGenerate(IProgressMonitor monitor) {
+ //nothing to do yet...
}
+ @Override
protected void postGenerate() {
+ super.postGenerate();
try {
- if ( ! this.isDebug) {
- this.removeLaunchConfiguration(LAUNCH_CONFIG_NAME);
- }
this.javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}
catch (CoreException e) {
@@ -162,174 +115,51 @@ public class ClassesGenerator
// ********** Launch Configuration Setup **********
- private void specifyClasspathProperties(IJavaProject project) {
+ @Override
+ protected List<String> buildClasspath() throws CoreException {
List<String> classpath = new ArrayList<String>();
- try {
- // Default Project classpath
- classpath.add(this.getDefaultProjectClasspathEntry(project).getMemento());
- // System Library
- classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
- // Containers classpath
- for(IRuntimeClasspathEntry containerClasspathEntry: this.getContainersClasspathEntries()) {
- classpath.add(containerClasspathEntry.getMemento());
- }
- }
- catch (CoreException e) {
- throw new RuntimeException("An error occurs generating a memento", e);
+ // Default Project classpath
+ classpath.add(this.getDefaultProjectClasspathEntry().getMemento());
+ // System Library
+ classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
+ // Containers classpath
+ for(IRuntimeClasspathEntry containerClasspathEntry: this.getContainersClasspathEntries()) {
+ classpath.add(containerClasspathEntry.getMemento());
}
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ return classpath;
}
-
- private void specifyJRE(String jreName, String vmId) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreName);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmId);
- }
-
- private void specifyProject(String projectName) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
- }
-
- private void specifyMainType(String mainType) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
- }
-
- private void specifyProgramArguments(
- String xmlSchemaName,
- String outputDir,
- String targetPackage,
- String catalog,
- String[] bindingsFileNames) {
+ @Override
+ protected void specifyProgramArguments() {
StringBuffer programArguments = new StringBuffer();
// options
programArguments.append("-d "); //$NON-NLS-1$
- programArguments.append(outputDir);
- if( ! StringTools.stringIsEmpty(targetPackage)) {
+ programArguments.append(this.outputDir);
+ if( ! StringTools.stringIsEmpty(this.targetPackage)) {
programArguments.append(" -p "); //$NON-NLS-1$
- programArguments.append(targetPackage);
+ programArguments.append(this.targetPackage);
}
- if( ! StringTools.stringIsEmpty(catalog)) {
+ if( ! StringTools.stringIsEmpty(this.catalog)) {
programArguments.append(" -catalog "); //$NON-NLS-1$
- programArguments.append(catalog);
+ programArguments.append(this.catalog);
}
// schema
- programArguments.append(' '); //$NON-NLS-1$
- programArguments.append(xmlSchemaName);
+ programArguments.append(' ');
+ programArguments.append(this.xmlSchemaName);
// bindings
- if( bindingsFileNames.length > 0) {
- for(String bindingsFileName: bindingsFileNames) {
+ if (this.bindingsFileNames.length > 0) {
+ for (String bindingsFileName : this.bindingsFileNames) {
programArguments.append(" -b "); //$NON-NLS-1$
programArguments.append(bindingsFileName);
}
}
this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
}
-
- private void specifyWorkingDir(String projectLocation) {
-
- File workingDir = new Path(projectLocation).toFile();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath());
- }
-
- // ********** LaunchConfig **********
-
- private ILaunchConfigurationWorkingCopy buildLaunchConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy launchConfig = null;
- this.removeLaunchConfiguration(LAUNCH_CONFIG_NAME);
- ILaunchConfigurationType type = this.getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
- launchConfig = type.newInstance(null, LAUNCH_CONFIG_NAME);
- return launchConfig;
- }
-
- private void removeLaunchConfiguration(String launchConfigurationName) throws CoreException {
-
- ILaunchManager manager = getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
- for (int i = 0; i < configurations.length; i++) {
- ILaunchConfiguration configuration = configurations[i];
- if (configuration.getName().equals(launchConfigurationName)) {
- configuration.delete();
- break;
- }
- }
- }
-
- private ILaunch saveAndLaunchConfig() {
- ILaunchConfiguration configuration = null;
- ILaunch result = null;
- try {
- configuration = this.launchConfig.doSave();
- }
- catch (CoreException saveException) {
- throw new RuntimeException("Could not save LaunchConfig", saveException);
- }
- try {
- result = configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- }
- catch (CoreException lauchException) {
- throw new RuntimeException("An error occured during launch", lauchException);
- }
- return result;
- }
-
- private void addLaunchListener() {
-
- this.getLaunchManager().addLaunchListener(this.buildLaunchListener());
- }
-
- private ILaunchesListener2 buildLaunchListener() {
- return new ILaunchesListener2() {
-
- public void launchesTerminated(ILaunch[] launches) {
- for (int i = 0; i < launches.length; i++) {
- ILaunch launch = launches[i];
- if (launch.equals(ClassesGenerator.this.getLaunch())) {
-
- ClassesGenerator.this.postGenerate();
- return;
- }
- }
- }
-
- public void launchesAdded(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesChanged(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesRemoved(ILaunch[] launches) {
- // not interested to this event
- }
- };
- }
-
// ********** Queries **********
- private IRuntimeClasspathEntry getSystemLibraryClasspathEntry() throws CoreException {
-
- IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
- return JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath, IRuntimeClasspathEntry.STANDARD_CLASSES);
- }
-
- private IRuntimeClasspathEntry getDefaultProjectClasspathEntry(IJavaProject project) {
-
- IRuntimeClasspathEntry projectEntry = JavaRuntime.newDefaultProjectClasspathEntry(project);
- projectEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return projectEntry;
- }
-
private List<IRuntimeClasspathEntry> getContainersClasspathEntries() throws CoreException {
ArrayList<IRuntimeClasspathEntry> classpathEntries = new ArrayList<IRuntimeClasspathEntry>();
for(IClasspathEntry classpathEntry: this.javaProject.getRawClasspath()) {
@@ -346,16 +176,4 @@ public class ClassesGenerator
}
return classpathEntries;
}
-
- private IVMInstall getProjectJRE() throws CoreException {
- return JavaRuntime.getVMInstall(this.javaProject);
- }
-
- protected ILaunch getLaunch() {
- return this.launch;
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
new file mode 100644
index 0000000000..45c0742997
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+* 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;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Localized messages used by Dali JAXB Core.
+ *
+ * @version 3.0
+ */
+public class JptJaxbCoreMessages {
+
+ 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/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/SchemaGenerator.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/SchemaGenerator.java
index e5c1d14de5..d177fdcbe8 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/SchemaGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/core/internal/SchemaGenerator.java
@@ -18,10 +18,8 @@ import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
@@ -30,13 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
@@ -44,8 +36,7 @@ import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jpt.core.internal.gen.AbstractJptGenerator;
import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
import org.eclipse.osgi.service.datalocation.Location;
@@ -54,7 +45,7 @@ import org.osgi.framework.Bundle;
/**
* SchemaGenerator
*/
-public class SchemaGenerator
+public class SchemaGenerator extends AbstractJptGenerator
{
static public String LAUNCH_CONFIG_NAME = "JAXB Schema Gen Run Config"; //$NON-NLS-1$
static public String JAXB_SCHEMA_GEN_PACKAGE_NAME = "org.eclipse.jpt.jaxb.core.schemagen"; //$NON-NLS-1$
@@ -73,16 +64,10 @@ public class SchemaGenerator
static public String JAXB_ECLIPSELINK_SCHEMA_GEN_CLASS = "org.eclipse.persistence.jaxb.JAXBContext"; //$NON-NLS-1$
static public String PLUGINS_DIR = "plugins/"; //$NON-NLS-1$
- private IVMInstall jre;
- private ILaunchConfigurationWorkingCopy launchConfig;
- private ILaunch launch;
-
- private final IJavaProject javaProject;
private final String targetSchemaName;
private final String[] sourceClassNames;
private String mainType;
private boolean useMoxy;
- private final boolean isDebug = false;
// ********** static methods **********
@@ -98,8 +83,7 @@ public class SchemaGenerator
new SchemaGenerator(javaProject,
targetSchemaName,
sourceClassNames,
- useMoxy,
- monitor).generate();
+ useMoxy).generate(monitor);
}
// ********** constructors **********
@@ -108,10 +92,8 @@ public class SchemaGenerator
IJavaProject javaProject,
String targetSchemaName,
String[] sourceClassNames,
- boolean useMoxy,
- @SuppressWarnings("unused") IProgressMonitor monitor) {
- super();
- this.javaProject = javaProject;
+ boolean useMoxy) {
+ super(javaProject);
this.targetSchemaName = targetSchemaName;
this.sourceClassNames = sourceClassNames;
this.useMoxy = useMoxy;
@@ -121,39 +103,44 @@ public class SchemaGenerator
this.initialize();
}
- // ********** behavior **********
-
- protected void initialize() {
- try {
- this.jre = this.getProjectJRE();
- if (this.jre == null) {
- String message = "Could not identify the VM."; //$NON-NLS-1$
- throw new RuntimeException(message);
- }
- this.launchConfig = this.buildLaunchConfiguration();
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
+ @Override
+ protected String getMainType() {
+ return this.mainType;
}
- protected void generate() {
+ @Override
+ protected String getLaunchConfigName() {
+ return LAUNCH_CONFIG_NAME;
+ }
+
+
+ // ********** behavior **********
+
+ @Override
+ protected void preGenerate(IProgressMonitor monitor) {
// generate jaxb.properties file if necessary
if (this.useMoxy){
if (!isJaxbPropertiesFilePresent()){
- this.generateJaxbPropertiesFile();
+ this.generateJaxbPropertiesFile(monitor);
}
- else if (!isJaxbContextMoxy(getJaxbPropertiesFile())){
+ else if (!isJaxbContextMoxy()){
//properties file actually specifies a different implementation
//override wizard setting and fall back to generic generation
this.useMoxy = false;
this.mainType = JAXB_SCHEMA_GEN_CLASS;
}
}
- String projectLocation = getProject().getLocation().toString();
- this.initializeLaunchConfiguration(projectLocation);
- this.addLaunchListener();
- this.launch = this.saveAndLaunchConfig();
+ }
+
+ @Override
+ protected void postGenerate() {
+ super.postGenerate();
+ try {
+ this.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -193,15 +180,15 @@ public class SchemaGenerator
return getJaxbPropertiesFile()!= null;
}
- private boolean isJaxbContextMoxy(IFile propertyFile){
+ private boolean isJaxbContextMoxy(){
InputStream in = null;
try {
- in = propertyFile.getContents();
+ in = getJaxbPropertiesFile().getContents();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = reader.readLine();
//jaxb.properties will only contain one property entry, the JAXBContextFactory
- String propertyValue = line.substring(line.indexOf("=") + 1);
+ String propertyValue = line.substring(line.indexOf("=") + 1); //$NON-NLS-1$
if (propertyValue.equals(ECLIPSELINK_JAXB_CONTEXT_FACTORY)){
return true;
}
@@ -221,15 +208,18 @@ public class SchemaGenerator
return false;
}
- private void generateJaxbPropertiesFile(){
+ private void generateJaxbPropertiesFile(IProgressMonitor monitor) {
+ SubMonitor sm = SubMonitor.convert(monitor, 1);
+ sm.subTask(JptJaxbCoreMessages.SchemaGenerator_creatingJAXBPropertiesFileTask);
+
IPackageFragment packageFragment = findPackageFragementForSourceClassName(this.sourceClassNames[0]);
IFolder folder = (IFolder)packageFragment.getResource();
- IFile file = folder.getFile("jaxb.properties");
+ IFile file = folder.getFile(JAXB_PROPERTIES_FILE_NAME);
byte[] bytes;
try {
- bytes = ECLIPSELINK_JAXB_PROPERTIES_FILE_CONTENTS.getBytes("UTF-8");
+ bytes = ECLIPSELINK_JAXB_PROPERTIES_FILE_CONTENTS.getBytes("UTF-8"); //$NON-NLS-1$
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
@@ -238,7 +228,7 @@ public class SchemaGenerator
try {
//the input stream will be closed as a result of calling create
- file.create(contents, IResource.NONE, null);
+ file.create(contents, IResource.NONE, sm.newChild(1));
} catch (CoreException ce) {
throw new RuntimeException(ce);
}
@@ -258,227 +248,56 @@ public class SchemaGenerator
//the existing package fragment was not found
throw new IllegalStateException("Java package must exist for source class");
}
-
- private void initializeLaunchConfiguration(String projectLocation) {
-
- this.specifyJRE(this.jre.getName(), this.jre.getVMInstallType().getId());
-
- this.specifyProject(this.getProject().getName());
- this.specifyMainType(this.mainType);
- this.specifyProgramArguments(
- this.targetSchemaName,
- this.sourceClassNames); // -d -c
- this.specifyWorkingDir(projectLocation);
-
- String jarName = (this.useMoxy) ?
- ECLIPSELINK_JAXB_SCHEMA_GEN_JAR :
- JAXB_SCHEMA_GEN_JAR;
- this.specifyClasspathProperties(this.javaProject, this.buildBootstrapJarPath(jarName));
- }
-
- protected void postGenerate() {
- try {
- if ( ! this.isDebug) {
- this.removeLaunchConfiguration(LAUNCH_CONFIG_NAME);
- }
- this.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
- }
// ********** Launch Configuration Setup **********
- private void specifyClasspathProperties(IJavaProject javaProject, IPath bootstrapJar) {
+ @Override
+ protected List<String> buildClasspath() throws CoreException {
List<String> classpath = new ArrayList<String>();
- try {
- // Schema_Gen jar
- classpath.add(this.getArchiveClasspathEntry(bootstrapJar).getMemento());
- // Default Project classpath
- classpath.add(this.getDefaultProjectClasspathEntry(javaProject).getMemento());
- // System Library
- classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
- }
- catch (CoreException e) {
- throw new RuntimeException("An error occurs generating a memento", e); //$NON-NLS-1$
- }
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
+ // Schema_Gen jar
+ classpath.add(getBootstrapJarClasspathEntry().getMemento());
+ // Default Project classpath
+ classpath.add(this.getDefaultProjectClasspathEntry().getMemento());
+ // System Library
+ classpath.add(this.getSystemLibraryClasspathEntry().getMemento());
+ return classpath;
}
- private void specifyJRE(String jreName, String vmId) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreName);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmId);
- }
-
- private void specifyProject(String projectName) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
- }
-
- private void specifyMainType(String mainType) {
-
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainType);
- }
-
- private void specifyProgramArguments(
- String targetSchemaName,
- String[] sourceClassNames) {
+ @Override
+ protected void specifyProgramArguments() {
StringBuffer programArguments = new StringBuffer();
// sourceClassNames
- StringBuffer sourceClassNamesArguments = this.buildClassNamesArguments(sourceClassNames);
- programArguments.append(sourceClassNamesArguments);
+ this.appendClassNameArguments(programArguments);
// schema
programArguments.append(" -s \""); //$NON-NLS-1$
- programArguments.append(targetSchemaName);
- programArguments.append('"'); //$NON-NLS-1$
+ programArguments.append(this.targetSchemaName);
+ programArguments.append('"');
this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
}
- private StringBuffer buildClassNamesArguments(String[] sourceClassNames) {
-
- StringBuffer classNamesArguments = new StringBuffer();
- for (String className: sourceClassNames) {
- classNamesArguments.append(" -c "); //$NON-NLS-1$
- classNamesArguments.append(className);
- }
- return classNamesArguments;
- }
-
- private void specifyWorkingDir(String projectLocation) {
-
- File workingDir = new Path(projectLocation).toFile();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath());
- }
-
- // ********** LaunchConfig **********
-
- private ILaunchConfigurationWorkingCopy buildLaunchConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy launchConfig = null;
- this.removeLaunchConfiguration(LAUNCH_CONFIG_NAME);
-
- ILaunchManager manager = getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- launchConfig = type.newInstance(null, LAUNCH_CONFIG_NAME);
- return launchConfig;
- }
-
- private void removeLaunchConfiguration(String launchConfigurationName) throws CoreException {
-
- ILaunchManager manager = getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
- for (int i = 0; i < configurations.length; i++) {
- ILaunchConfiguration configuration = configurations[i];
- if (configuration.getName().equals(launchConfigurationName)) {
- configuration.delete();
- break;
- }
- }
- }
-
- private ILaunch saveAndLaunchConfig() {
- ILaunchConfiguration configuration = null;
- ILaunch result = null;
- try {
- configuration = this.launchConfig.doSave();
- }
- catch (CoreException saveException) {
- throw new RuntimeException("Could not save LaunchConfig", saveException);
- }
- try {
- result = configuration.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
- }
- catch (CoreException lauchException) {
- throw new RuntimeException("An error occured during launch", lauchException);
+ private void appendClassNameArguments(StringBuffer sb) {
+ for (String className : this.sourceClassNames) {
+ sb.append(" -c "); //$NON-NLS-1$
+ sb.append(className);
}
- return result;
- }
-
- private void addLaunchListener() {
-
- this.getLaunchManager().addLaunchListener(this.buildLaunchListener());
}
- private ILaunchesListener2 buildLaunchListener() {
- return new ILaunchesListener2() {
-
- public void launchesTerminated(ILaunch[] launches) {
- for (int i = 0; i < launches.length; i++) {
- ILaunch launch = launches[i];
- if (launch.equals(SchemaGenerator.this.getLaunch())) {
- SchemaGenerator.this.postGenerate();
- return;
- }
- }
- }
+ // ********** private methods **********
- public void launchesAdded(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesChanged(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesRemoved(ILaunch[] launches) {
- // not interested to this event
- }
- };
- }
-
- // ********** Queries **********
-
- private IRuntimeClasspathEntry getSystemLibraryClasspathEntry() throws CoreException {
-
- IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
- return JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath, IRuntimeClasspathEntry.STANDARD_CLASSES);
+ private IRuntimeClasspathEntry getBootstrapJarClasspathEntry() {
+ return getArchiveClasspathEntry(this.buildBootstrapJarPath());
}
-
- private IRuntimeClasspathEntry getArchiveClasspathEntry(IPath archivePath) {
-
- IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(archivePath);
- archiveEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return archiveEntry;
- }
-
- private IRuntimeClasspathEntry getDefaultProjectClasspathEntry(IJavaProject project) {
- IRuntimeClasspathEntry projectEntry = JavaRuntime.newDefaultProjectClasspathEntry(project);
- projectEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return projectEntry;
- }
-
- public IProject getProject() {
- return this.javaProject.getProject();
- }
-
- private IVMInstall getProjectJRE() throws CoreException {
- return JavaRuntime.getVMInstall(this.javaProject);
- }
-
- protected ILaunch getLaunch() {
- return this.launch;
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- // ********** private method **********
+ private IPath buildBootstrapJarPath() {
+ String jarName = (this.useMoxy) ?
+ ECLIPSELINK_JAXB_SCHEMA_GEN_JAR :
+ JAXB_SCHEMA_GEN_JAR;
- private IPath buildBootstrapJarPath(String jarName) {
try {
File jarInstallDir = this.getBundleParentDir(JptJaxbUiPlugin.PLUGIN_ID);
@@ -523,5 +342,4 @@ public class SchemaGenerator
Bundle bundle = Platform.getBundle(bundleName);
return FileLocator.getBundleFile(bundle).getParentFile();
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
index a7f800950c..248ca28382 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
@@ -10,13 +10,15 @@
package org.eclipse.jpt.jaxb.ui.internal;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
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.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -62,7 +64,6 @@ public class ClassesGeneratorUi {
* prompt the user with a wizard
*/
protected void generate() {
-
ClassesGeneratorWizard wizard = new ClassesGeneratorWizard(this.javaProject, this.xmlSchemaName);
WizardDialog dialog = new WizardDialog(this.getCurrentShell(), wizard);
dialog.create();
@@ -88,7 +89,7 @@ public class ClassesGeneratorUi {
boolean useMoxyGenerator,
String[] bindingsFileNames) {
- IWorkspaceRunnable runnable = this.buildGenerateEntitiesRunnable(
+ WorkspaceJob job = new GenerateEntitiesJob(
this.javaProject,
this.xmlSchemaName,
outputDir,
@@ -96,24 +97,7 @@ public class ClassesGeneratorUi {
catalog,
useMoxyGenerator,
bindingsFileNames);
- try {
- ResourcesPlugin.getWorkspace().run(runnable, new NullProgressMonitor());
- }
- catch (CoreException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private IWorkspaceRunnable buildGenerateEntitiesRunnable(
- IJavaProject javaProject,
- String xmlSchemaName,
- String outputDir,
- String targetPackage,
- String catalog,
- boolean useMoxyGenerator,
- String[] bindingsFileNames) {
-
- return new GenerateEntitiesRunnable(javaProject, xmlSchemaName, outputDir, targetPackage, catalog, useMoxyGenerator, bindingsFileNames);
+ job.schedule();
}
private Shell getCurrentShell() {
@@ -122,7 +106,7 @@ public class ClassesGeneratorUi {
// ********** Runnable Class **********
- private static class GenerateEntitiesRunnable implements IWorkspaceRunnable {
+ private static class GenerateEntitiesJob extends WorkspaceJob {
private final IJavaProject javaProject;
private final String xmlSchemaName;
private final String outputDir;
@@ -133,7 +117,7 @@ public class ClassesGeneratorUi {
// ********** constructors **********
- public GenerateEntitiesRunnable(
+ public GenerateEntitiesJob(
IJavaProject javaProject,
String xmlSchemaName,
String outputDir,
@@ -142,7 +126,8 @@ public class ClassesGeneratorUi {
boolean useMoxyGenerator,
String[] bindingsFileNames) {
- super();
+ //super(EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_JOB);
+ super(JptJaxbUiMessages.ClassesGeneratorUi_generatingEntities);
this.javaProject = javaProject;
this.xmlSchemaName = xmlSchemaName;
this.outputDir = outputDir;
@@ -150,9 +135,12 @@ public class ClassesGeneratorUi {
this.catalog = catalog;
this.useMoxyGenerator = useMoxyGenerator;
this.bindingsFileNames = bindingsFileNames;
+ this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject()));
}
- public void run(IProgressMonitor monitor) {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ SubMonitor sm = SubMonitor.convert(monitor, JptJaxbUiMessages.ClassesGeneratorUi_generatingEntitiesTask, 1);
try {
this.entitiesGeneratorGenerate(this.javaProject,
this.xmlSchemaName,
@@ -161,10 +149,10 @@ public class ClassesGeneratorUi {
this.catalog,
this.useMoxyGenerator,
this.bindingsFileNames,
- monitor);
+ sm.newChild(1));
}
catch (OperationCanceledException e) {
- return;
+ return Status.CANCEL_STATUS;
// fall through and tell monitor we are done
}
catch (RuntimeException re) {
@@ -174,7 +162,8 @@ public class ClassesGeneratorUi {
this.logError(message);
throw new RuntimeException(re);
}
- }
+ return Status.OK_STATUS;
+ }
private void entitiesGeneratorGenerate(IJavaProject javaProject,
String xmlSchemaName,
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
index 99bbb6dcbf..a7b325c47f 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
@@ -40,6 +40,9 @@ public class JptJaxbUiMessages {
public static String ClassesGeneratorWizardPage_moxyLibrariesNotAvailable;
+ public static String ClassesGeneratorUi_generatingEntities;
+ public static String ClassesGeneratorUi_generatingEntitiesTask;
+
// SchemaGenerator
public static String SchemaGeneratorWizard_title;
public static String SchemaGeneratorWizard_generatingSchema;
@@ -64,6 +67,7 @@ public class JptJaxbUiMessages {
public static String SchemaGeneratorWizardPage_moxyLibrariesNotAvailable;
+ public static String SchemaGeneratorWizard_generateSchemaTask;
private static final String BUNDLE_NAME = "jpt_jaxb_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptJaxbUiMessages.class;
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
index a563e46e25..cdcfcbf1fd 100644
--- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
@@ -14,7 +14,6 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
@@ -23,6 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
@@ -37,6 +37,7 @@ 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.FileTools;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IExportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
@@ -203,17 +204,17 @@ public class SchemaGeneratorWizard extends Wizard implements IExportWizard {
this.targetSchema = targetSchema;
this.useMoxy = useMoxy;
- IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
- this.setRule(ruleFactory.modifyRule(javaProject.getProject()));
+ this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject()));
}
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try{
- SchemaGenerator.generate(javaProject, this.targetSchema, this.sourceClassNames, this.useMoxy, monitor);
+ SubMonitor sm = SubMonitor.convert(monitor, NLS.bind(JptJaxbUiMessages.SchemaGeneratorWizard_generateSchemaTask, this.targetSchema), 1);
+ try {
+ SchemaGenerator.generate(this.javaProject, this.targetSchema, this.sourceClassNames, this.useMoxy, sm.newChild(1));
}
- catch(OperationCanceledException e) {
- //user canceled generation
+ catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
index e4f3b5e25d..cd352c2e5f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/gen/GenerateEntitiesFromSchemaWizard.java
@@ -21,12 +21,10 @@ import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jface.dialogs.Dialog;
@@ -221,11 +219,12 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
} catch (IOException e) {
JptUiPlugin.log(e);
}
+ OverwriteConfirmer overwriteConfirmer = null;
if (shouldShowOverwriteWarning()) {
- PackageGenerator.setOverwriteConfirmer(new OverwriteConfirmer());
+ overwriteConfirmer = new OverwriteConfirmer();
}
- WorkspaceJob genEntitiesJob = new GenerateEntitiesJob(this.jpaProject, getCustomizer());
+ WorkspaceJob genEntitiesJob = new GenerateEntitiesJob(this.jpaProject, getCustomizer(), overwriteConfirmer);
genEntitiesJob.schedule();
return true;
}
@@ -233,27 +232,25 @@ public class GenerateEntitiesFromSchemaWizard extends Wizard
// ********** generate entities job **********
static class GenerateEntitiesJob extends WorkspaceJob {
- JpaProject jpaProject;
- ORMGenCustomizer customizer;
- GenerateEntitiesJob(JpaProject jpaProject, ORMGenCustomizer customizer) {
+ final JpaProject jpaProject;
+ final ORMGenCustomizer customizer;
+ final OverwriteConfirmer confirmer;
+ GenerateEntitiesJob(JpaProject jpaProject, ORMGenCustomizer customizer, OverwriteConfirmer confirmer) {
super(JptUiMessages.EntitiesGenerator_jobName);
this.customizer = customizer;
- this.jpaProject = jpaProject ;
+ this.jpaProject = jpaProject;
+ this.confirmer = confirmer;
IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
this.setRule(ruleFactory.modifyRule(jpaProject.getProject()));
}
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try{
- PackageGenerator.generate(this.jpaProject,this.customizer, monitor);
- }catch(OperationCanceledException e){
- //user canceled generation
- }
+ PackageGenerator.generate(this.jpaProject,this.customizer, this.confirmer, monitor);
return Status.OK_STATUS;
}
+ }
- }
public static boolean shouldShowOverwriteWarning(){
IEclipsePreferences pref = new InstanceScope().getNode(JptUiPlugin.PLUGIN_ID);
boolean ret = ! pref.getBoolean( DONT_SHOW_OVERWRITE_WARNING_DIALOG, false) ;

Back to the top