Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 215483 Details for
Bug 322567
JAXB schema generation should open the generated schema
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch 1
patch-322567 - May 11 2012.txt (text/plain), 81.57 KB, created by
Tran Le
on 2012-05-11 11:03:04 EDT
(
hide
)
Description:
Proposed patch 1
Filename:
MIME Type:
Creator:
Tran Le
Created:
2012-05-11 11:03:04 EDT
Size:
81.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jpt.common.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF,v >retrieving revision 1.12 >diff -u -r1.12 MANIFEST.MF >--- META-INF/MANIFEST.MF 15 Mar 2012 22:43:42 -0000 1.12 >+++ META-INF/MANIFEST.MF 11 May 2012 05:36:32 -0000 >@@ -28,6 +28,7 @@ > org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)" > Dali-Comment: We friend 'utility' to all non-EclipseLink, non-test bundles > Export-Package: org.eclipse.jpt.common.core, >+ org.eclipse.jpt.common.core.gen, > org.eclipse.jpt.common.core.internal; > x-friends:="org.eclipse.jpt.jpa.core, > org.eclipse.jpt.jaxb.core", >Index: src/org/eclipse/jpt/common/core/gen/JptGenerator.java >=================================================================== >RCS file: src/org/eclipse/jpt/common/core/gen/JptGenerator.java >diff -N src/org/eclipse/jpt/common/core/gen/JptGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/common/core/gen/JptGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+/******************************************************************************* >+* Copyright (c) 2012 Oracle. All rights reserved. >+* This program and the accompanying materials are made available under the >+* terms of the Eclipse Public License v1.0, which accompanies this distribution >+* and is available at http://www.eclipse.org/legal/epl-v10.html. >+* >+* Contributors: >+* Oracle - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.jpt.common.core.gen; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; >+ >+public interface JptGenerator >+{ >+ JptGenerator generate(IProgressMonitor monitor); >+ >+ void addLaunchConfigListener(LaunchConfigListener listener); >+ >+ void removeLaunchConfigListener(LaunchConfigListener listener); >+} >Index: src/org/eclipse/jpt/common/core/gen/LaunchConfigListener.java >=================================================================== >RCS file: src/org/eclipse/jpt/common/core/gen/LaunchConfigListener.java >diff -N src/org/eclipse/jpt/common/core/gen/LaunchConfigListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/common/core/gen/LaunchConfigListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,16 @@ >+/******************************************************************************* >+* Copyright (c) 2012 Oracle. All rights reserved. >+* This program and the accompanying materials are made available under the >+* terms of the Eclipse Public License v1.0, which accompanies this distribution >+* and is available at http://www.eclipse.org/legal/epl-v10.html. >+* >+* Contributors: >+* Oracle - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.jpt.common.core.gen; >+ >+public interface LaunchConfigListener >+{ >+ void launchCompleted(boolean generationSuccessful); >+ >+} >Index: src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractJptGenerator.java >--- src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java 28 Mar 2012 22:46:49 -0000 1.7 >+++ src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java 11 May 2012 05:36:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2008, 2011 Oracle. All rights reserved. >+* Copyright (c) 2008, 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -12,19 +12,19 @@ > import java.io.File; > import java.io.IOException; > import java.util.ArrayList; >+import java.util.Iterator; > import java.util.List; > > import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; > 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.NullProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.SubMonitor; >+import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.ILaunch; > import org.eclipse.debug.core.ILaunchConfiguration; >@@ -32,17 +32,22 @@ > import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.core.ILaunchManager; > import org.eclipse.debug.core.ILaunchesListener2; >+import org.eclipse.debug.core.model.IProcess; > 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.common.core.JptCommonCorePlugin; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; > import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages; >+import org.eclipse.jpt.common.utility.internal.CollectionTools; >+import org.eclipse.jpt.common.utility.internal.ListenerList; > import org.eclipse.osgi.service.datalocation.Location; > import org.osgi.framework.Bundle; > >-public abstract class AbstractJptGenerator >+public abstract class AbstractJptGenerator implements JptGenerator > { > public static final String PLUGINS_DIR = "plugins/"; //$NON-NLS-1$ > >@@ -52,6 +57,7 @@ > > protected final IJavaProject javaProject; > protected final String projectLocation; >+ protected final ListenerList<LaunchConfigListener> launchConfigListenerList; > > private boolean isDebug = false; > >@@ -61,6 +67,7 @@ > super(); > this.javaProject = javaProject; > this.projectLocation = javaProject.getProject().getLocation().toString(); >+ this.launchConfigListenerList = this.buildLaunchConfigListenerList(); > this.initialize(); > } > >@@ -82,19 +89,19 @@ > > protected void initialize() { > try { >+ this.launchConfig = this.buildLaunchConfiguration(); > 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) { >+ public JptGenerator generate(IProgressMonitor monitor) { > SubMonitor sm = SubMonitor.convert(monitor, 10); > this.preGenerate(sm.newChild(2)); > if (sm.isCanceled()) { >@@ -114,8 +121,9 @@ > throw new OperationCanceledException(); > } > this.launch = this.saveAndLaunchConfig(sm.newChild(6)); >+ return this; > } >- >+ > private void initializeLaunchConfiguration() { > this.specifyJRE(); > >@@ -133,22 +141,37 @@ > this.getLaunchManager().addLaunchListener(this.buildLaunchListener()); > } > >+ private void removeLaunchListener(ILaunchesListener2 listener) { >+ >+ this.getLaunchManager().removeLaunchListener(listener); >+ } >+ > protected abstract void preGenerate(IProgressMonitor monitor); > >- protected void postGenerate() { >+ protected void postGenerate(boolean generationSuccessful) { > try { > if( ! this.isDebug) { > this.removeLaunchConfiguration(); > } >- this.refreshProject(); >+ this.notifyLaunchConfigListeners(generationSuccessful); > } > catch(CoreException e) { > throw new RuntimeException(e); > } > } > >- protected void refreshProject() throws CoreException { >- this.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); >+ private void notifyLaunchConfigListeners(boolean generationSuccessful) { >+ for(LaunchConfigListener launchConfigListener : this.launchConfigListenerList.getListeners()) { >+ launchConfigListener.launchCompleted(generationSuccessful); >+ } >+ } >+ >+ private void generationSuccessful() { >+ this.postGenerate(true); >+ } >+ >+ private void generationFailed() { >+ this.postGenerate(false); > } > > private ILaunchesListener2 buildLaunchListener() { >@@ -159,16 +182,39 @@ > ILaunch launch = launches[i]; > if (launch.equals(AbstractJptGenerator.this.getLaunch())) { > try { >- AbstractJptGenerator.this.postGenerate(); >- AbstractJptGenerator.this.launch = null; >+ if(launch.isTerminated()) { >+ if(this.generationIsSuccessful(launch)) { >+ AbstractJptGenerator.this.generationSuccessful(); >+ } >+ else { >+ AbstractJptGenerator.this.generationFailed(); >+ } >+ AbstractJptGenerator.this.launch = null; >+ } > } > finally { >- AbstractJptGenerator.this.getLaunchManager().removeLaunchListener(this); >+ AbstractJptGenerator.this.removeLaunchListener(this); > } > return; > } > } > } >+ >+ private boolean generationIsSuccessful(ILaunch launch) { >+ Iterator<IProcess> processes = CollectionTools.iterator(launch.getProcesses()); >+ int exitValue = 0xFFFF; >+ while (processes.hasNext()) { >+ IProcess process = (IProcess)processes.next(); >+ try { >+ exitValue = process.getExitValue(); >+ break; >+ } >+ catch (DebugException e) { >+ throw new RuntimeException(e); >+ } >+ } >+ return (exitValue == 0); >+ } > > public void launchesAdded(ILaunch[] launches) { > // not interested to this event >@@ -386,5 +432,18 @@ > protected void setDebug(boolean isDebug) { > this.isDebug = isDebug; > } >+ >+ // ********** listener ********** > >+ private ListenerList<LaunchConfigListener> buildLaunchConfigListenerList() { >+ return new ListenerList<LaunchConfigListener>(LaunchConfigListener.class); >+ } >+ >+ public void addLaunchConfigListener(LaunchConfigListener listener) { >+ this.launchConfigListenerList.add(listener); >+ } >+ >+ public void removeLaunchConfigListener(LaunchConfigListener listener) { >+ this.launchConfigListenerList.remove(listener); >+ } > } >#P org.eclipse.jpt.dbws.eclipselink.ui >Index: src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java,v >retrieving revision 1.2 >diff -u -r1.2 DbwsGenerator.java >--- src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java 9 Nov 2011 14:58:16 -0000 1.2 >+++ src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java 11 May 2012 05:36:33 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; > import org.eclipse.jdt.launching.IRuntimeClasspathEntry; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator; > import org.eclipse.jpt.common.utility.internal.StringTools; > >@@ -39,7 +40,7 @@ > > // ********** static methods ********** > >- public static void generate( >+ public static JptGenerator generate( > IJavaProject javaProject, > String builderFileName, > String stageDirName, >@@ -48,7 +49,7 @@ > if (javaProject == null) { > throw new NullPointerException(); > } >- new DbwsGenerator(javaProject, >+ return new DbwsGenerator(javaProject, > builderFileName, > stageDirName, > driverJarList).generate(monitor); >@@ -56,7 +57,7 @@ > > // ********** constructors ********** > >- private DbwsGenerator( >+ public DbwsGenerator( > IJavaProject javaProject, > String builderFileName, > String stageDirName, >Index: src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java,v >retrieving revision 1.2 >diff -u -r1.2 DbwsGeneratorUi.java >--- src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java 10 Feb 2012 20:49:22 -0000 1.2 >+++ src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java 11 May 2012 05:36:33 -0000 >@@ -14,12 +14,13 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.WorkspaceJob; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; > 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.Status; > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IJavaProject; >@@ -28,9 +29,14 @@ > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.window.Window; > import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; >+import org.eclipse.jpt.common.ui.internal.util.SWTUtil; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; > import org.eclipse.jpt.dbws.eclipselink.core.internal.gen.DbwsGenerator; >+import org.eclipse.jpt.dbws.eclipselink.ui.JptDbwsUiPlugin; > import org.eclipse.jpt.dbws.eclipselink.ui.internal.wizards.gen.DbwsGeneratorWizard; >-import org.eclipse.jpt.common.utility.internal.StringTools; > import org.eclipse.persistence.oxm.XMLContext; > import org.eclipse.persistence.oxm.XMLUnmarshaller; > import org.eclipse.persistence.tools.dbws.DBWSBuilderModel; >@@ -251,25 +257,106 @@ > // ********** generate DBWS job ********** > > public static class GenerateDbwsJob extends WorkspaceJob { >- private final IJavaProject project; >+ private final IJavaProject javaProject; > final String builderFileName; > final String stageDirName; > final String driverJarList; >+ private final SynchronizedBoolean generationCompleted; >+ private boolean generationSuccessful; > >- public GenerateDbwsJob(IJavaProject project, String builderFileName, String stageDirName, String driverJarList) { >+ public GenerateDbwsJob(IJavaProject javaProject, String builderFileName, String stageDirName, String driverJarList) { > super(JptDbwsUiMessages.DbwsGeneratorWizard_generatingDbws); > >- this.project = project ; >+ this.javaProject = javaProject ; > this.builderFileName = builderFileName; > this.stageDirName = stageDirName; > this.driverJarList = driverJarList; >+ this.generationCompleted = new SynchronizedBoolean(false); >+ this.generationSuccessful = false; > } > > @Override > public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { >- DbwsGenerator.generate(this.project, this.builderFileName, this.stageDirName, this.driverJarList, monitor); >+ this.dbwsGeneratorGenerate(monitor); > return Status.OK_STATUS; > } >+ >+ private void dbwsGeneratorGenerate(IProgressMonitor monitor) { >+ JptGenerator dbwsGenerator = new DbwsGenerator(this.javaProject, this.builderFileName, this.stageDirName, this.driverJarList); >+ LaunchConfigListener launchListener = this.buildLaunchListener(); >+ dbwsGenerator.addLaunchConfigListener(launchListener); >+ dbwsGenerator.generate(monitor); >+ try { >+ this.generationCompleted.waitUntilTrue(); >+ } >+ catch (InterruptedException e) { >+ this.logException(e); >+ } >+ finally { >+ dbwsGenerator.removeLaunchConfigListener(launchListener); >+ } >+ >+ this.postGenerate(this.generationSuccessful); >+ } >+ >+ protected void postGenerate(boolean generationSuccessful) { >+ if( ! generationSuccessful) { >+ this.displayError("Generation Failed"); //TODO >+ return; >+ } >+ else { >+ this.refreshProject(); >+ } >+ } >+ >+ private void refreshProject() { >+ try { >+ this.javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); >+ } >+ catch (CoreException e) { >+ this.logException(e); >+ } >+ } >+ >+ private LaunchConfigListener buildLaunchListener() { >+ return new LaunchConfigListener() { >+ >+ public void launchCompleted(boolean generationSuccessful) { >+ GenerateDbwsJob.this.generationSuccessful = generationSuccessful; >+ GenerateDbwsJob.this.generationCompleted.setTrue(); >+ } >+ }; >+ } >+ >+ protected void logException(Exception exception) { >+ String msg = exception.getMessage(); >+ String message = (msg == null) ? exception.toString() : msg; >+ this.displayError(message); >+ JptDbwsUiPlugin.log(exception); >+ } >+ >+ private void displayError(final String message) { >+ SWTUtil.syncExec(new Runnable() { >+ public void run() { >+ MessageDialog.openError( >+ getShell(), >+ "Error", //TODO >+ message >+ ); >+ } >+ }); >+ } >+ >+ protected Shell getShell() { >+ Display display = Display.getCurrent(); >+ Shell shell = (display == null) ? null : display.getActiveShell(); >+ if (shell == null && display != null) { >+ Shell[] shells = display.getShells(); >+ if (shells.length > 0) >+ shell = shells[0]; >+ } >+ return shell; >+ } > > } > } >Index: src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java,v >retrieving revision 1.2 >diff -u -r1.2 DbwsGeneratorWizard.java >--- src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java 10 Feb 2012 20:49:22 -0000 1.2 >+++ src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java 11 May 2012 05:36:33 -0000 >@@ -13,7 +13,6 @@ > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.WorkspaceJob; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IPath; > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IJavaProject; >@@ -127,7 +126,7 @@ > this.jdbcDriversPage.finish(); // persist settings > > if(DbwsGeneratorUi.displayOverridingWebContentWarning(this.getShell())) { >- this.generateDbws(driverJarList); >+ this.scheduleGenerateDbwsJob(driverJarList); > } > return true; > } >@@ -179,7 +178,7 @@ > return relativePath.toOSString(); > } > >- private void generateDbws(String driverJarList) { >+ private void scheduleGenerateDbwsJob(String driverJarList) { > > String stageDirName = this.getJavaProject().getProject().getLocation().toOSString(); > >#P org.eclipse.jpt.jaxb.core >Index: src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java,v >retrieving revision 1.7 >diff -u -r1.7 ClassesGenerator.java >--- src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java 9 Nov 2011 14:58:15 -0000 1.7 >+++ src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java 11 May 2012 05:36:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2010, 2011 Oracle. All rights reserved. >+* Copyright (c) 2010, 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -12,6 +12,7 @@ > import java.io.File; > import java.util.ArrayList; > import java.util.List; >+ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.Path; >@@ -25,6 +26,7 @@ > import org.eclipse.jdt.launching.IRuntimeClasspathEntry; > import org.eclipse.jdt.launching.IVMInstall; > import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator; > import org.eclipse.jpt.common.utility.internal.StringTools; > >@@ -50,7 +52,7 @@ > > // ********** static methods ********** > >- public static void generate( >+ public static JptGenerator generate( > IJavaProject javaProject, > String schemaPathOrUri, > String outputDir, >@@ -65,7 +67,7 @@ > if (javaProject == null) { > throw new NullPointerException(); > } >- new ClassesGenerator(javaProject, >+ return new ClassesGenerator(javaProject, > schemaPathOrUri, > outputDir, > targetPackage, >@@ -136,7 +138,7 @@ > > // ********** constructors ********** > >- protected ClassesGenerator( >+ public ClassesGenerator( > IJavaProject javaProject, > String schemaPathOrUri, > String outputDir, >Index: src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java,v >retrieving revision 1.4 >diff -u -r1.4 GenerateJaxbClassesJob.java >--- src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java 22 Apr 2011 22:00:28 -0000 1.4 >+++ src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java 11 May 2012 05:36:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2010 Oracle. All rights reserved. >+* Copyright (c) 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -9,16 +9,22 @@ > *******************************************************************************/ > package org.eclipse.jpt.jaxb.core.internal.gen; > >+import org.eclipse.core.resources.IResource; > 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.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.OperationCanceledException; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.SubMonitor; > import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; > import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; >+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin; > import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages; > > /** >@@ -34,6 +40,8 @@ > private final String[] bindingsFileNames; > private final ClassesGeneratorOptions generatorOptions; > private final ClassesGeneratorExtensionOptions generatorExtensionOptions; >+ private final SynchronizedBoolean generationCompleted; >+ private boolean generationSuccessful; > > // ********** constructors ********** > >@@ -68,54 +76,83 @@ > this.generatorOptions = generatorOptions; > this.generatorExtensionOptions = generatorExtensionOptions; > this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject())); >+ this.generationCompleted = new SynchronizedBoolean(false); >+ this.generationSuccessful = false; > } > > @Override > public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { > SubMonitor sm = SubMonitor.convert(monitor, JptJaxbCoreMessages.ClassesGenerator_generatingClassesTask, 1); > try { >- this.classesGeneratorGenerate(this.javaProject, >- this.absoluteLocalXsdUri, >- this.outputDir, >- this.targetPackage, >- this.catalog, >- this.usesMoxyGenerator, >- this.bindingsFileNames, >- this.generatorOptions, >- this.generatorExtensionOptions, >- sm.newChild(1)); >+ this.classesGeneratorGenerate(sm.newChild(1)); > } > catch (OperationCanceledException e) { > return Status.CANCEL_STATUS; > // fall through and tell monitor we are done > } > catch (RuntimeException re) { >- throw new RuntimeException(re); >+ this.logException(re); > } > return Status.OK_STATUS; > } > >- private void classesGeneratorGenerate(IJavaProject javaProject, >- String absoluteLocalXsdUri, >- String outputDir, >- String targetPackage, >- String catalog, >- boolean usesMoxyGenerator, >- String[] bindingsFileNames, >- ClassesGeneratorOptions generatorOptions, >- ClassesGeneratorExtensionOptions generatorExtensionOptions, >- IProgressMonitor monitor) { >+ private void classesGeneratorGenerate(IProgressMonitor monitor) { >+ >+ JptGenerator classesGenerator = new ClassesGenerator(this.javaProject, >+ this.absoluteLocalXsdUri, >+ this.outputDir, >+ this.targetPackage, >+ this.catalog, >+ this.usesMoxyGenerator, >+ this.bindingsFileNames, >+ this.generatorOptions, >+ this.generatorExtensionOptions); >+ >+ LaunchConfigListener launchListener = this.buildLaunchListener(); >+ classesGenerator.addLaunchConfigListener(launchListener); >+ classesGenerator.generate(monitor); >+ try { >+ this.generationCompleted.waitUntilTrue(); >+ } >+ catch (InterruptedException e) { >+ this.logException(e); >+ } >+ finally { >+ classesGenerator.removeLaunchConfigListener(launchListener); >+ } >+ this.postGenerate(this.generationSuccessful); >+ } > >- ClassesGenerator.generate(javaProject, >- absoluteLocalXsdUri, >- outputDir, >- targetPackage, >- catalog, >- usesMoxyGenerator, >- bindingsFileNames, >- generatorOptions, >- generatorExtensionOptions, >- monitor); >- return; >+ >+ protected void postGenerate(boolean generationSuccessful) { >+ if( ! generationSuccessful) { >+ JptJaxbCorePlugin.log("ClassesGenerator: Generation Failed"); //TODO >+ return; >+ } >+ else { >+ this.refreshProject(); >+ } >+ } >+ >+ private void refreshProject() { >+ try { >+ this.javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); >+ } >+ catch (CoreException e) { >+ this.logException(e); >+ } >+ } >+ >+ private LaunchConfigListener buildLaunchListener() { >+ return new LaunchConfigListener() { >+ >+ public void launchCompleted(boolean generationSuccessful) { >+ GenerateJaxbClassesJob.this.generationSuccessful = generationSuccessful; >+ GenerateJaxbClassesJob.this.generationCompleted.setTrue(); >+ } >+ }; >+ } >+ protected void logException(Exception exception) { >+ JptJaxbCorePlugin.log(exception); > } > } >\ No newline at end of file >Index: src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java,v >retrieving revision 1.7 >diff -u -r1.7 SchemaGenerator.java >--- src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java 2 Apr 2012 23:02:57 -0000 1.7 >+++ src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java 11 May 2012 05:36:34 -0000 >@@ -18,6 +18,7 @@ > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; >+ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IResource; >@@ -30,6 +31,7 @@ > import org.eclipse.jdt.core.IPackageFragmentRoot; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator; > import org.eclipse.jpt.common.core.internal.utility.JDTTools; > import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages; >@@ -62,7 +64,7 @@ > > // ********** static methods ********** > >- public static void generate( >+ public static JptGenerator generate( > IJavaProject javaProject, > String targetSchemaName, > String[] sourceClassNames, >@@ -71,7 +73,7 @@ > if (javaProject == null) { > throw new NullPointerException(); > } >- new SchemaGenerator(javaProject, >+ return new SchemaGenerator(javaProject, > targetSchemaName, > sourceClassNames, > useMoxy).generate(monitor); >@@ -79,7 +81,7 @@ > > // ********** constructors ********** > >- protected SchemaGenerator( >+ public SchemaGenerator( > IJavaProject javaProject, > String targetSchemaName, > String[] sourceClassNames, >#P org.eclipse.jpt.jaxb.ui >Index: src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java,v >retrieving revision 1.10 >diff -u -r1.10 ClassesGeneratorWizard.java >--- src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java 12 Apr 2012 00:42:32 -0000 1.10 >+++ src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java 11 May 2012 05:36:35 -0000 >@@ -11,13 +11,13 @@ > > import java.util.List; > import java.util.Vector; >+ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.WorkspaceJob; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.emf.common.util.URI; > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.IJavaProject; >@@ -160,9 +160,9 @@ > } > > if (this.performsGeneration) { >- if (displayOverwritingClassesWarning(this.generatorOptions)) { >- generateJaxbClasses(); >- addSchemaToLibrary(); >+ if (this.displayOverwritingClassesWarning(this.generatorOptions)) { >+ this.scheduleGenerateJaxbClassesJob(); >+ this.addSchemaToLibrary(); > } > } > >@@ -348,9 +348,9 @@ > } > } > >- private void generateJaxbClasses() { >+ private void scheduleGenerateJaxbClassesJob() { > try { >- WorkspaceJob job = >+ WorkspaceJob generateJaxbClassesJob = > new GenerateJaxbClassesJob( > this.getJavaProject(), > this.getLocalSchemaUri().toString(), >@@ -361,7 +361,7 @@ > this.bindingsFileNames, > this.generatorOptions, > this.generatorExtensionOptions); >- job.schedule(); >+ generateJaxbClassesJob.schedule(); > } > catch(RuntimeException re) { > JptJaxbUiPlugin.log(re); >Index: src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java,v >retrieving revision 1.7 >diff -u -r1.7 SchemaGeneratorWizard.java >--- src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java 11 Apr 2012 22:54:15 -0000 1.7 >+++ src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java 11 May 2012 05:36:35 -0000 >@@ -10,13 +10,13 @@ > package org.eclipse.jpt.jaxb.ui.internal.wizards.schemagen; > > import java.io.File; >-import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; > import java.util.List; > > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IResourceRuleFactory; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.resources.WorkspaceJob; >@@ -25,6 +25,7 @@ > 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.OperationCanceledException; > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Status; >@@ -33,19 +34,25 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IPackageFragment; > import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; > import org.eclipse.jpt.common.ui.internal.util.SWTUtil; > import org.eclipse.jpt.common.utility.internal.ArrayTools; > import org.eclipse.jpt.common.utility.internal.FileTools; > import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; > import org.eclipse.jpt.jaxb.core.internal.gen.SchemaGenerator; > import org.eclipse.jpt.jaxb.core.internal.operations.SchemaFileCreationDataModelProvider; > import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin; > import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons; > import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; > import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.INewWizard; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPage; >@@ -115,24 +122,19 @@ > } > > protected void scheduleGenerateSchemaJob(String[] sourceClassNames) { >- >+ >+ IPath schemaPath = this.newSchemaFileWizardPage.getContainerFullPath(); >+ String schemaName = this.newSchemaFileWizardPage.getFileName(); >+ > WorkspaceJob genSchemaJob = new GenerateSchemaJob( > this.targetProject, > sourceClassNames, > this.getTargetSchema(), >- this.usesMoxy()); >+ this.usesMoxy(), >+ schemaPath, >+ schemaName); > genSchemaJob.schedule(); > >- IPath schemaPath = this.newSchemaFileWizardPage.getContainerFullPath(); >- String schemaName = this.newSchemaFileWizardPage.getFileName(); >- >- IContainer container = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(schemaPath); >- IFile schemaFile = container.getFile(new Path(schemaName)); >- >- OpenSchemaFileJob openSchemaFileJob = new OpenSchemaFileJob( >- this.targetProject, >- schemaFile); >- openSchemaFileJob.schedule(); > } > > // ********** intra-wizard methods ********** >@@ -264,63 +266,99 @@ > private final String[] sourceClassNames; > private final String targetSchema; > private final boolean useMoxy; >+ private final IPath schemaPath; >+ private final String schemaName; >+ private final SynchronizedBoolean generationCompleted; >+ private boolean generationSuccessful; > >- GenerateSchemaJob(IJavaProject project, String[] sourceClassNames, String targetSchema, boolean useMoxy) { >+ GenerateSchemaJob(IJavaProject project, String[] sourceClassNames, String targetSchema, >+ boolean useMoxy, IPath schemaPath, String schemaName) { >+ > super(JptJaxbUiMessages.SchemaGeneratorWizard_generatingSchema); > > this.javaProject = project ; > this.sourceClassNames = sourceClassNames; > this.targetSchema = targetSchema; > this.useMoxy = useMoxy; >+ this.schemaPath = schemaPath; >+ this.schemaName = schemaName; >+ this.generationCompleted = new SynchronizedBoolean(false); >+ this.generationSuccessful = false; > >- this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject())); >+ IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); >+ this.setRule(ruleFactory.modifyRule(this.javaProject.getProject())); > } > > @Override > public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { > 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)); >- } >+ this.schemaGeneratorGenerate(sm.newChild(1)); >+ } > catch (OperationCanceledException e) { > return Status.CANCEL_STATUS; > } >+ catch (RuntimeException re) { >+ this.logException(re); >+ } > return Status.OK_STATUS; > } >- } >- >- // ********** open schema file job ********** > >- public static class OpenSchemaFileJob extends WorkspaceJob { >- private final IJavaProject javaProject; >- private final IFile schemaFile; >- >- public OpenSchemaFileJob(IJavaProject javaProject, IFile schemaFile) { >- super(JptJaxbUiMessages.SchemaGeneratorWizard_openSchemaFileJobName); >- this.javaProject = javaProject; >- this.schemaFile = schemaFile; >- IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); >- this.setRule(ruleFactory.modifyRule(this.javaProject.getProject())); >- } >+ private void schemaGeneratorGenerate(IProgressMonitor monitor) { >+ JptGenerator schemaGenerator = new SchemaGenerator(this.javaProject, this.targetSchema, this.sourceClassNames, this.useMoxy); > >- @Override >- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { >+ LaunchConfigListener launchListener = this.buildLaunchListener(); >+ schemaGenerator.addLaunchConfigListener(launchListener); >+ schemaGenerator.generate(monitor); > try { >- this.postGeneration(this.schemaFile); >- } >- catch (InvocationTargetException e) { >- throw new CoreException(new Status(IStatus.ERROR, JptJaxbUiPlugin.PLUGIN_ID, "error", e)); //$NON-NLS-1$ >+ this.generationCompleted.waitUntilTrue(); > } >- return Status.OK_STATUS; >+ catch (InterruptedException e) { >+ this.logException(e); >+ } >+ finally { >+ schemaGenerator.removeLaunchConfigListener(launchListener); >+ } >+ >+ this.postGenerate(this.generationSuccessful); > } > >- private void postGeneration(IFile schemaFile) throws InvocationTargetException { >+ protected void postGenerate(boolean generationSuccessful) { >+ if( ! generationSuccessful) { >+ this.displayError("Generation Failed"); //TODO >+ return; >+ } >+ else { >+ this.refreshProject(); >+ this.openGeneratedSchemaFile(); >+ } >+ } >+ >+ private void refreshProject() { > try { >- this.openEditor(schemaFile); >+ this.javaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); > } >- catch (Exception cantOpen) { >- throw new InvocationTargetException(cantOpen); >- } >+ catch (CoreException e) { >+ this.logException(e); >+ } >+ } >+ >+ private LaunchConfigListener buildLaunchListener() { >+ return new LaunchConfigListener() { >+ >+ public void launchCompleted(boolean generationSuccessful) { >+ GenerateSchemaJob.this.generationSuccessful = generationSuccessful; >+ GenerateSchemaJob.this.generationCompleted.setTrue(); >+ } >+ }; >+ } >+ >+ private void openGeneratedSchemaFile() { >+ >+ IContainer container = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(this.schemaPath); >+ IFile schemaFile = container.getFile(new Path(this.schemaName)); >+ >+ this.openEditor(schemaFile); > } > > private void openEditor(final IFile file) { >@@ -338,5 +376,35 @@ > }); > } > } >+ >+ protected void logException(Exception exception) { >+ String msg = exception.getMessage(); >+ String message = (msg == null) ? exception.toString() : msg; >+ this.displayError(message); >+ JptJaxbUiPlugin.log(exception); >+ } >+ >+ private void displayError(final String message) { >+ SWTUtil.syncExec(new Runnable() { >+ public void run() { >+ MessageDialog.openError( >+ getShell(), >+ "Error", //TODO >+ message >+ ); >+ } >+ }); >+ } >+ >+ protected Shell getShell() { >+ Display display = Display.getCurrent(); >+ Shell shell = (display == null) ? null : display.getActiveShell(); >+ if (shell == null && display != null) { >+ Shell[] shells = display.getShells(); >+ if (shells.length > 0) >+ shell = shells[0]; >+ } >+ return shell; >+ } > } > } >\ No newline at end of file >#P org.eclipse.jpt.jpa.eclipselink.core >Index: src/org/eclipse/jpt/jpa/eclipselink/core/builder/EclipseLinkStaticWeavingBuilder.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/builder/EclipseLinkStaticWeavingBuilder.java,v >retrieving revision 1.1 >diff -u -r1.1 EclipseLinkStaticWeavingBuilder.java >--- src/org/eclipse/jpt/jpa/eclipselink/core/builder/EclipseLinkStaticWeavingBuilder.java 25 Apr 2012 22:06:28 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/eclipselink/core/builder/EclipseLinkStaticWeavingBuilder.java 11 May 2012 05:36:35 -0000 >@@ -12,10 +12,16 @@ > import java.util.Map; > > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; >+import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; > import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin; > import org.eclipse.jpt.jpa.eclipselink.core.internal.weave.StaticWeave; > >@@ -24,6 +30,9 @@ > public static final String BUILDER_ID = JptJpaEclipseLinkCorePlugin.PLUGIN_ID + ".builder"; //$NON-NLS-1$ > > private EclipseLinkStaticWeavingBuilderConfigurator configurator; >+ >+ private final SynchronizedBoolean generationCompleted = new SynchronizedBoolean(false); >+ private boolean generationSuccessful; > > // ********** overrides ********** > >@@ -33,26 +42,66 @@ > @Override > protected IProject[] build(int kind, Map<String, String> parameters, IProgressMonitor monitor) throws CoreException > { >- StaticWeave.weave( >- JavaCore.create(this.getProject()), >- this.configurator.getSourceLocationPreference(), >- this.configurator.getTargetLocationPreference(), >- this.configurator.getLogLevelPreference(), >- this.configurator.getPersistenceInfoPreference(), >- monitor); >+ this.staticWeaveGeneratorGenerate(monitor); > > return new IProject[0]; > } > >+ private void staticWeaveGeneratorGenerate(IProgressMonitor monitor) throws CoreException { >+ this.generationSuccessful = false; >+ >+ JptGenerator staticWeaveGenerator = new StaticWeave( >+ this.getJavaProject(), >+ this.configurator.getSourceLocationPreference(), >+ this.configurator.getTargetLocationPreference(), >+ this.configurator.getLogLevelPreference(), >+ this.configurator.getPersistenceInfoPreference()); >+ >+ LaunchConfigListener launchListener = this.buildLaunchListener(); >+ staticWeaveGenerator.addLaunchConfigListener(launchListener); >+ staticWeaveGenerator.generate(monitor); >+ try { >+ this.generationCompleted.waitUntilTrue(); >+ } >+ catch (InterruptedException e) { >+ throw new RuntimeException(e); >+ } >+ finally { >+ staticWeaveGenerator.removeLaunchConfigListener(launchListener); >+ } >+ this.postGenerate(this.generationSuccessful); >+ } >+ >+ protected void postGenerate(boolean generationSuccessful) throws CoreException { >+ if( ! generationSuccessful) { >+ throw new RuntimeException("Weaving Failed"); //TODO >+ } >+ else { >+ this.refreshProject(); >+ } >+ } >+ >+ private void refreshProject() throws CoreException { >+ this.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); >+ } >+ >+ private LaunchConfigListener buildLaunchListener() { >+ return new LaunchConfigListener() { >+ >+ public void launchCompleted(boolean generationSuccessful) { >+ EclipseLinkStaticWeavingBuilder.this.generationSuccessful = generationSuccessful; >+ EclipseLinkStaticWeavingBuilder.this.generationCompleted.setTrue(); >+ } >+ }; >+ } >+ >+ private IJavaProject getJavaProject() { >+ return JavaCore.create(this.getProject()); >+ } >+ > @Override > protected void startupOnInitialize() { > super.startupOnInitialize(); > this.configurator = new EclipseLinkStaticWeavingBuilderConfigurator(this.getProject()); > } >- >- @Override >- protected void clean(IProgressMonitor monitor) throws CoreException { >- super.clean(monitor); >- >- } > } >Index: src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractEclipseLinkDDLGenerator.java >--- src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java 28 Mar 2012 22:46:47 -0000 1.7 >+++ src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/AbstractEclipseLinkDDLGenerator.java 11 May 2012 05:36:35 -0000 >@@ -20,17 +20,13 @@ > 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.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; >@@ -38,7 +34,6 @@ > import org.eclipse.jpt.jpa.core.JpaPlatform; > import org.eclipse.jpt.jpa.core.JpaProject; > import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlEnumValue; >-import org.eclipse.jpt.jpa.core.internal.JptCoreMessages; > import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; > import org.eclipse.jpt.jpa.db.ConnectionProfile; > import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin; >@@ -50,7 +45,6 @@ > import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.OutputMode; > import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.SchemaGeneration; > import org.eclipse.osgi.util.ManifestElement; >-import org.eclipse.wst.validation.ValidationFramework; > import org.osgi.framework.Bundle; > import org.osgi.framework.BundleException; > >@@ -112,10 +106,10 @@ > } > > @Override >- protected void postGenerate() { >- super.postGenerate(); >+ protected void postGenerate(boolean generationSuccessful) { >+ super.postGenerate(generationSuccessful); >+ > this.reconnect(); >- this.validateProject(); > } > > // ********** Setting Launch Configuration ********** >@@ -184,10 +178,6 @@ > } > } > >- protected void validateProject() { >- new ValidateJob(this.jpaProject.getProject()).schedule(); >- } >- > // ********** ClasspathEntry ********** > > private IRuntimeClasspathEntry getJdbcJarClasspathEntry() { >@@ -340,30 +330,6 @@ > JpaXmlResource persistenceXmlResource = this.jpaProject.getPersistenceXmlResource(); > return ! this.jpaProject.getJavaProject().isOnClasspath(persistenceXmlResource.getFile()); > } >- >- /** >- * Performs validation after tables have been generated >- */ >- /* CU private */ class ValidateJob >- extends Job >- { >- private final IProject[] projects; >- >- ValidateJob(IProject project) { >- super(JptCoreMessages.VALIDATE_JOB); >- this.projects = new IProject[] {project}; >- } >- >- @Override >- protected IStatus run(IProgressMonitor monitor) { >- try { >- ValidationFramework.getDefault().validate(this.projects, true, false, monitor); >- } catch (CoreException ex) { >- throw new RuntimeException(ex); >- } >- return Status.OK_STATUS; >- } >- } > > private IPath buildJdbcJarPath() { > return new Path(this.getJpaProjectConnectionDriverJarList()); >Index: src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLink2_0DDLGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLink2_0DDLGenerator.java,v >retrieving revision 1.1 >diff -u -r1.1 EclipseLink2_0DDLGenerator.java >--- src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLink2_0DDLGenerator.java 7 Oct 2011 12:52:50 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLink2_0DDLGenerator.java 11 May 2012 05:36:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2009, 2011 Oracle. All rights reserved. >+* Copyright (c) 2009, 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -10,7 +10,9 @@ > package org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen; > > import java.util.Properties; >+ > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.jpa.core.JpaProject; > import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0; > import org.eclipse.jpt.jpa.db.ConnectionProfile; >@@ -30,17 +32,17 @@ > 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, OutputMode outputMode, IProgressMonitor monitor) { >+ >+ public static JptGenerator generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { > if (puName == null || puName.length() == 0 || project == null) { > throw new NullPointerException(); > } >- new EclipseLink2_0DDLGenerator(puName, project, outputMode).generate(monitor); >+ return new EclipseLink2_0DDLGenerator(puName, project, outputMode).generate(monitor); > } > >- private EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { >+ // ********** constructors ********** >+ >+ public EclipseLink2_0DDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { > super(puName, jpaProject, outputMode); > } > >Index: src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java,v >retrieving revision 1.3 >diff -u -r1.3 EclipseLinkDDLGenerator.java >--- src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java 7 Oct 2011 12:52:50 -0000 1.3 >+++ src/org/eclipse/jpt/jpa/eclipselink/core/internal/ddlgen/EclipseLinkDDLGenerator.java 11 May 2012 05:36:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2008, 2011 Oracle. All rights reserved. >+* Copyright (c) 2008, 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -10,7 +10,9 @@ > package org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen; > > import java.util.Properties; >+ > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.jpa.core.JpaProject; > import org.eclipse.jpt.jpa.db.ConnectionProfile; > import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.Connection; >@@ -29,16 +31,17 @@ > public class EclipseLinkDDLGenerator extends AbstractEclipseLinkDDLGenerator > { > >- // ********** constructors ********** > >- public static void generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { >+ public static JptGenerator generate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { > if (puName == null || puName.length() == 0 || project == null) { > throw new NullPointerException(); > } >- new EclipseLinkDDLGenerator(puName, project, outputMode).generate(monitor); >+ return new EclipseLinkDDLGenerator(puName, project, outputMode).generate(monitor); > } >+ >+ // ********** constructors ********** > >- private EclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { >+ public EclipseLinkDDLGenerator(String puName, JpaProject jpaProject, OutputMode outputMode) { > super(puName, jpaProject, outputMode); > } > >Index: src/org/eclipse/jpt/jpa/eclipselink/core/internal/weave/StaticWeave.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/weave/StaticWeave.java,v >retrieving revision 1.3 >diff -u -r1.3 StaticWeave.java >--- src/org/eclipse/jpt/jpa/eclipselink/core/internal/weave/StaticWeave.java 28 Feb 2012 17:29:25 -0000 1.3 >+++ src/org/eclipse/jpt/jpa/eclipselink/core/internal/weave/StaticWeave.java 11 May 2012 05:36:35 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; > import org.eclipse.jdt.launching.IRuntimeClasspathEntry; > import org.eclipse.jdt.launching.JavaRuntime; >+import org.eclipse.jpt.common.core.gen.JptGenerator; > import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator; > import org.eclipse.jpt.common.utility.internal.StringTools; > >@@ -42,7 +43,7 @@ > > // ********** static methods ********** > >- public static void weave( >+ public static JptGenerator weave( > IJavaProject javaProject, > String source, > String target, >@@ -54,7 +55,7 @@ > throw new NullPointerException("javaProject is null"); //$NON-NLS-1$ > } > >- new StaticWeave(javaProject, >+ return new StaticWeave(javaProject, > source, > target, > loglevel, >@@ -63,7 +64,7 @@ > > // ********** constructors ********** > >- protected StaticWeave( >+ public StaticWeave( > IJavaProject javaProject, > String source, > String target, >@@ -77,8 +78,6 @@ > this.persistenceinfo = persistenceinfo; > > this.mainType = WEAVING_CLASS; >- >- this.setDebug(false); > } > > // ********** overrides ********** >@@ -98,12 +97,6 @@ > // do nothing > } > >- @Override >- protected void refreshProject() throws CoreException { >- // do nothing >- // 370895 - Static weaving results in infinite builder loop when enabled >- } >- > // ********** behavior ********** > > @Override >#P org.eclipse.jpt.jpa.eclipselink.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.15 >diff -u -r1.15 MANIFEST.MF >--- META-INF/MANIFEST.MF 24 Apr 2012 18:04:54 -0000 1.15 >+++ META-INF/MANIFEST.MF 11 May 2012 05:36:36 -0000 >@@ -34,7 +34,8 @@ > org.eclipse.ui.views;bundle-version="[3.6.100,4.0.0)", > org.eclipse.wst.common.emf;bundle-version="[1.2.100,2.0.0)", > org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)", >- org.eclipse.wst.common.frameworks.ui;bundle-version="[1.1.200,2.0.0)" >+ org.eclipse.wst.common.frameworks.ui;bundle-version="[1.1.200,2.0.0)", >+ org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)" > Export-Package: org.eclipse.jpt.jpa.eclipselink.ui, > org.eclipse.jpt.jpa.eclipselink.ui.internal;x-internal:=true, > org.eclipse.jpt.jpa.eclipselink.ui.internal.commands;x-internal:=true, >Index: src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java,v >retrieving revision 1.6 >diff -u -r1.6 EclipseLinkDDLGeneratorUi.java >--- src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java 25 Oct 2011 23:57:33 -0000 1.6 >+++ src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/EclipseLinkDDLGeneratorUi.java 11 May 2012 05:36:36 -0000 >@@ -9,32 +9,13 @@ > *******************************************************************************/ > package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen; > >-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.Status; >-import org.eclipse.core.runtime.SubMonitor; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.jface.dialogs.MessageDialog; >-import org.eclipse.jface.window.Window; > import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog; >-import org.eclipse.jpt.common.ui.internal.util.SWTUtil; >-import org.eclipse.jpt.common.utility.internal.StringTools; > import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; > import org.eclipse.jpt.jpa.core.JpaPlatform; > import org.eclipse.jpt.jpa.core.JpaProject; > import org.eclipse.jpt.jpa.core.context.persistence.Persistence; > import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; >-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.OutputMode; >-import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.EclipseLinkDDLGenerator; >-import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiPlugin; >-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages; > import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards.GenerateDDLWizard; >-import org.eclipse.osgi.util.NLS; >-import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; > >@@ -45,14 +26,15 @@ > public class EclipseLinkDDLGeneratorUi > { > private final JpaProject project; >- private static final String CR = StringTools.CR; > >- // ********** constructors ********** >+ // ********** static method ********** > > public static void generate(JpaProject project) { > new EclipseLinkDDLGeneratorUi(project).generate(); > } > >+ // ********** constructors ********** >+ > protected EclipseLinkDDLGeneratorUi(JpaProject project) { > super(); > if (project == null) { >@@ -68,41 +50,22 @@ > PersistenceUnit persistenceUnit = this.getPersistenceUnits().iterator().next(); // Take the first persistenceUnit > String puName = persistenceUnit.getName(); > >- GenerateDDLWizard wizard = new GenerateDDLWizard(this.project); >+ GenerateDDLWizard wizard = this.buildGenerateDDLWizard(this.project, puName); > WizardDialog wizardDialog = new WizardDialog(this.getCurrentShell(), wizard); > wizardDialog.create(); > if(wizard.getPageCount() > 0) { >- int returnCode = wizardDialog.open(); >- if (returnCode == Window.CANCEL) { >- return; >- } >- } >- OutputMode outputMode = wizard.getOutputMode(); >- >- if((outputMode != OutputMode.sql_script) && ( ! this.displayGeneratingDDLWarning())) { >- return; >+ wizardDialog.open(); > } >- WorkspaceJob job = this.buildGenerateDDLJob(puName, this.project, outputMode); >- job.schedule(); > } > >- protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) { >- return new GenerateDDLJob(puName, project, outputMode); >+ protected GenerateDDLWizard buildGenerateDDLWizard(JpaProject project, String puName) { >+ return new GenerateDDLWizard(project, puName); > } >- >+ > private Shell getCurrentShell() { > return Display.getCurrent().getActiveShell(); > } > >- private boolean displayGeneratingDDLWarning() { >- if (!OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) { >- return true; >- } else { >- OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getCurrentShell()); >- return dialog.open() == IDialogConstants.YES_ID; >- } >- } >- > // ********** Persistence Unit ********** > > protected JpaPlatform getPlatform() { >@@ -116,91 +79,4 @@ > protected Persistence getPersistence() { > return this.project.getRootContextNode().getPersistenceXml().getPersistence(); > } >- >- // ********** runnable ********** >- >- protected static class GenerateDDLJob extends WorkspaceJob { >- private final String puName; >- private final JpaProject project; >- private final OutputMode outputMode; >- >- public GenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) { >- super(EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_JOB); >- this.puName = puName; >- this.project = project; >- this.outputMode = outputMode; >- } >- >- @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, this.outputMode, sm.newChild(1)); >- } >- catch (OperationCanceledException e) { >- return Status.CANCEL_STATUS; >- } >- catch (RuntimeException re) { >- this.logException(re); >- } >- return Status.OK_STATUS; >- } >- >- protected void ddlGeneratorGenerate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { >- EclipseLinkDDLGenerator.generate(puName, project, outputMode, monitor); >- } >- >- protected void logException(RuntimeException re) { >- String msg = re.getMessage(); >- String message = (msg == null) ? re.toString() : msg; >- this.displayError(message); >- JptJpaEclipseLinkUiPlugin.log(re); >- } >- >- private void displayError(final String message) { >- SWTUtil.syncExec(new Runnable() { >- public void run() { >- MessageDialog.openError( >- getShell(), >- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_error, >- message >- ); >- } >- }); >- } >- >- protected Shell getShell() { >- Display display = Display.getCurrent(); >- Shell shell = (display == null) ? null : display.getActiveShell(); >- if (shell == null && display != null) { >- Shell[] shells = display.getShells(); >- if (shells.length > 0) >- shell = shells[0]; >- } >- return shell; >- } >- } >- >- // ********** overwrite dialog ********** >- >- static class OverwriteConfirmerDialog extends OptionalMessageDialog { >- >- private static final String ID= "dontShowOverwriteExistingTablesFromClasses.warning"; //$NON-NLS-1$ >- >- OverwriteConfirmerDialog(Shell parent) { >- super(ID, parent, >- EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle, >- NLS.bind(EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage, CR, CR + CR), >- MessageDialog.WARNING, >- new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, >- 1); >- } >- >- @Override >- protected void createButtonsForButtonBar(Composite parent) { >- this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); >- this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); >- } >- >- } > } >Index: src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java,v >retrieving revision 1.1 >diff -u -r1.1 EclipseLink2_0DDLGeneratorUi.java >--- src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java 7 Oct 2011 12:53:14 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0DDLGeneratorUi.java 11 May 2012 05:36:36 -0000 >@@ -9,11 +9,7 @@ > *******************************************************************************/ > package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards; > >-import org.eclipse.core.resources.WorkspaceJob; >-import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jpt.jpa.core.JpaProject; >-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.OutputMode; >-import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.EclipseLink2_0DDLGenerator; > import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.EclipseLinkDDLGeneratorUi; > > /** >@@ -37,22 +33,8 @@ > // ********** behavior ********** > > @Override >- protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) { >- return new Generate2_0DDLJob(puName, project, outputMode); >- } >- >- // ********** runnable ********** >- >- protected static class Generate2_0DDLJob extends EclipseLinkDDLGeneratorUi.GenerateDDLJob { >- >- public Generate2_0DDLJob(String puName, JpaProject project, OutputMode outputMode) { >- super(puName, project, outputMode); >- } >- >- @Override >- protected void ddlGeneratorGenerate(String puName, JpaProject project, OutputMode outputMode, IProgressMonitor monitor) { >- EclipseLink2_0DDLGenerator.generate(puName, project, outputMode, monitor); >- } >+ protected GenerateDDLWizard buildGenerateDDLWizard(JpaProject project, String puName) { >+ return new EclipseLink2_0GenerateDDLWizard(project, puName); > } > } > >Index: src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0GenerateDDLWizard.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0GenerateDDLWizard.java >diff -N src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0GenerateDDLWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/EclipseLink2_0GenerateDDLWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+* Copyright (c) 2012 Oracle. All rights reserved. >+* This program and the accompanying materials are made available under the >+* terms of the Eclipse Public License v1.0, which accompanies this distribution >+* and is available at http://www.eclipse.org/legal/epl-v10.html. >+* >+* Contributors: >+* Oracle - initial API and implementation >+*******************************************************************************/ >+package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.WorkspaceJob; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.OutputMode; >+import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.EclipseLink2_0DDLGenerator; >+import org.eclipse.wst.validation.ValidationFramework; >+ >+/** >+ * EclipseLink2_0GenerateDDLWizard >+ */ >+public class EclipseLink2_0GenerateDDLWizard extends GenerateDDLWizard { >+ >+ public EclipseLink2_0GenerateDDLWizard(JpaProject jpaProject, String puName) { >+ super(jpaProject, puName); >+ } >+ >+ @Override >+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) { >+ return new Generate2_0DDLJob(puName, project, outputMode); >+ } >+ >+ // ********** generate ddl job ********** >+ >+ protected static class Generate2_0DDLJob extends GenerateDDLWizard.GenerateDDLJob { >+ >+ public Generate2_0DDLJob(String puName, JpaProject jpaProject, OutputMode outputMode) { >+ super(puName, jpaProject, outputMode); >+ } >+ >+ @Override >+ protected JptGenerator buildDDLGenerator(String puName, JpaProject project, OutputMode outputMode) { >+ return new EclipseLink2_0DDLGenerator(puName, project, outputMode); >+ } >+ >+ @Override >+ protected void postGenerate(boolean generationSuccessful) { >+ super.postGenerate(generationSuccessful); >+ >+ if((outputMode != OutputMode.database) && generationSuccessful) { >+ this.validateProject(); >+ } >+ } >+ >+ /** >+ * Performs validation after tables have been generated >+ */ >+ protected void validateProject() { >+ IProject[] projects = new IProject[] {this.jpaProject.getProject()}; >+ try { >+ ValidationFramework.getDefault().validate(projects, true, false, new NullProgressMonitor()); >+ } >+ catch (CoreException e) { >+ this.logException(e); >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java,v >retrieving revision 1.3 >diff -u -r1.3 GenerateDDLWizard.java >--- src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java 7 Oct 2011 12:53:14 -0000 1.3 >+++ src/org/eclipse/jpt/jpa/eclipselink/ui/internal/ddlgen/wizards/GenerateDDLWizard.java 11 May 2012 05:36:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2007, 2011 Oracle. All rights reserved. >+* Copyright (c) 2007, 2012 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -9,28 +9,69 @@ > *******************************************************************************/ > package org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards; > >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceRuleFactory; >+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.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubMonitor; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.jpt.common.core.gen.JptGenerator; >+import org.eclipse.jpt.common.core.gen.LaunchConfigListener; >+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog; >+import org.eclipse.jpt.common.ui.internal.util.SWTUtil; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean; > import org.eclipse.jpt.jpa.core.JpaProject; > import org.eclipse.jpt.jpa.db.ConnectionProfile; > import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.OutputMode; >+import org.eclipse.jpt.jpa.eclipselink.core.internal.ddlgen.EclipseLinkDDLGenerator; >+import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiPlugin; >+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages; >+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; > import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; > import org.eclipse.jpt.jpa.ui.internal.wizards.DatabaseSchemaWizardPage; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.ide.IDE; > > /** > * GenerateDDLWizard > */ > public class GenerateDDLWizard extends Wizard { > >+ private static final String CR = StringTools.CR; >+ > private JpaProject jpaProject; >- >+ private String puName; >+ private JptGenerator ddlGenerator; >+ > private DatabaseSchemaWizardPage dbSettingsPage; > private GenerationOutputModeWizardPage generationOutputModePage; > > // ********** constructor ********** > >- public GenerateDDLWizard(JpaProject jpaProject) { >+ public GenerateDDLWizard(JpaProject jpaProject, String puName) { > super(); > this.jpaProject = jpaProject; >+ this.puName = puName; > this.setWindowTitle(JptUiMessages.GenerateDDLWizard_title); > } > >@@ -49,14 +90,31 @@ > > @Override > public boolean performFinish() { >- return (this.getJpaProjectConnectionProfile() != null); >+ OutputMode outputMode = this.getOutputMode(); >+ >+ if((outputMode != OutputMode.sql_script) && ( ! this.displayGeneratingDDLWarning())) { >+ return false; >+ } >+ >+ this.scheduleGenerateDDLJob(outputMode); >+ return true; > } > > @Override > public boolean canFinish() { > return this.dbSettingsPageCanFinish() && this.generationOutputModePageCanFinish(); > } >- >+ >+ protected void scheduleGenerateDDLJob(OutputMode outputMode) { >+ >+ WorkspaceJob generateDDLJob = this.buildGenerateDDLJob(this.puName, this.jpaProject, outputMode); >+ generateDDLJob.schedule(); >+ } >+ >+ protected WorkspaceJob buildGenerateDDLJob(String puName, JpaProject project, OutputMode outputMode) { >+ return new GenerateDDLJob(puName, project, outputMode); >+ } >+ > // ********** intra-wizard methods ********** > > public OutputMode getOutputMode() { >@@ -76,4 +134,194 @@ > private ConnectionProfile getJpaProjectConnectionProfile() { > return this.jpaProject.getConnectionProfile(); > } >+ >+ private boolean displayGeneratingDDLWarning() { >+ if (!OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) { >+ return true; >+ } else { >+ OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getCurrentShell()); >+ return dialog.open() == IDialogConstants.YES_ID; >+ } >+ } >+ >+ private Shell getCurrentShell() { >+ return Display.getCurrent().getActiveShell(); >+ } >+ >+ private JptGenerator getDDLGenerator() { >+ return ddlGenerator; >+ } >+ >+ protected void setDDLGenerator(JptGenerator ddlGenerator) { >+ this.ddlGenerator = ddlGenerator; >+ } >+ >+ // ********** overwrite dialog ********** >+ >+ static class OverwriteConfirmerDialog extends OptionalMessageDialog { >+ >+ private static final String ID= "dontShowOverwriteExistingTablesFromClasses.warning"; //$NON-NLS-1$ >+ >+ OverwriteConfirmerDialog(Shell parent) { >+ super(ID, parent, >+ EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningTitle, >+ NLS.bind(EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_generatingDDLWarningMessage, CR, CR + CR), >+ MessageDialog.WARNING, >+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, >+ 1); >+ } >+ >+ @Override >+ protected void createButtonsForButtonBar(Composite parent) { >+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false); >+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); >+ } >+ >+ } >+ >+ // ********** generate ddl job ********** >+ >+ protected static class GenerateDDLJob extends WorkspaceJob { >+ protected final String puName; >+ protected final JpaProject jpaProject; >+ protected final OutputMode outputMode; >+ private final SynchronizedBoolean generationCompleted; >+ private boolean generationSuccessful; >+ >+ public GenerateDDLJob(String puName, JpaProject jpaProject, OutputMode outputMode) { >+ super(EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_JOB); >+ this.puName = puName; >+ this.jpaProject = jpaProject; >+ this.outputMode = outputMode; >+ this.generationCompleted = new SynchronizedBoolean(false); >+ this.generationSuccessful = false; >+ >+ IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); >+ this.setRule(ruleFactory.modifyRule(this.jpaProject.getProject())); >+ } >+ >+ @Override >+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { >+ SubMonitor sm = SubMonitor.convert(monitor, EclipseLinkUiMessages.ECLIPSELINK_GENERATE_TABLES_TASK, 1); >+ try { >+ this.ddlGeneratorGenerate(sm.newChild(1)); >+ } >+ catch (OperationCanceledException e) { >+ return Status.CANCEL_STATUS; >+ } >+ catch (RuntimeException re) { >+ this.logException(re); >+ } >+ return Status.OK_STATUS; >+ } >+ >+ protected void ddlGeneratorGenerate(IProgressMonitor monitor) { >+ JptGenerator ddlGenerator = this.buildDDLGenerator(this.puName, this.jpaProject, this.outputMode); >+ >+ LaunchConfigListener launchListener = this.buildLaunchListener(); >+ ddlGenerator.addLaunchConfigListener(launchListener); >+ ddlGenerator.generate(monitor); >+ try { >+ this.generationCompleted.waitUntilTrue(); >+ } >+ catch (InterruptedException e) { >+ this.logException(e); >+ } >+ finally { >+ ddlGenerator.removeLaunchConfigListener(launchListener); >+ } >+ >+ this.postGenerate(this.generationSuccessful); >+ } >+ >+ protected void postGenerate(boolean generationSuccessful) { >+ if( ! generationSuccessful) { >+ this.displayError("Generation Failed"); //TODO >+ return; >+ } >+ if((this.outputMode != OutputMode.database) && generationSuccessful) { >+ this.refreshProject(); >+ this.openGeneratedSqlFile(); >+ } >+ } >+ >+ private void refreshProject() { >+ try { >+ this.jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); >+ } >+ catch (CoreException e) { >+ this.logException(e); >+ } >+ } >+ >+ private LaunchConfigListener buildLaunchListener() { >+ return new LaunchConfigListener() { >+ >+ public void launchCompleted(boolean generationSuccessful) { >+ GenerateDDLJob.this.generationSuccessful = generationSuccessful; >+ GenerateDDLJob.this.generationCompleted.setTrue(); >+ } >+ }; >+ } >+ >+ protected JptGenerator buildDDLGenerator(String puName, JpaProject project, OutputMode outputMode) { >+ return new EclipseLinkDDLGenerator(puName, project, outputMode); >+ } >+ >+ private void openGeneratedSqlFile() { >+ >+ IJavaProject javaProject = this.jpaProject.getJavaProject(); >+ IPath projecName = new Path(javaProject.getProject().getName()); >+ IContainer container = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(projecName); >+ IFile sqlFile = container.getFile(new Path("createDDL.sql")); //TODO >+ >+ this.openEditor(sqlFile); >+ } >+ >+ private void openEditor(final IFile file) { >+ if(file != null) { >+ SWTUtil.asyncExec(new Runnable() { >+ public void run() { >+ try { >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ IDE.openEditor(page, file, true); >+ } >+ catch (PartInitException e) { >+ JptJpaUiPlugin.log(e); >+ } >+ } >+ }); >+ } >+ } >+ >+ protected void logException(Exception exception) { >+ String msg = exception.getMessage(); >+ String message = (msg == null) ? exception.toString() : msg; >+ this.displayError(message); >+ JptJpaEclipseLinkUiPlugin.log(exception); >+ } >+ >+ private void displayError(final String message) { >+ SWTUtil.syncExec(new Runnable() { >+ public void run() { >+ MessageDialog.openError( >+ getShell(), >+ EclipseLinkUiMessages.EclipseLinkDDLGeneratorUi_error, >+ message >+ ); >+ } >+ }); >+ } >+ >+ protected Shell getShell() { >+ Display display = Display.getCurrent(); >+ Shell shell = (display == null) ? null : display.getActiveShell(); >+ if (shell == null && display != null) { >+ Shell[] shells = display.getShells(); >+ if (shells.length > 0) >+ shell = shells[0]; >+ } >+ return shell; >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 322567
: 215483