Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authortle2012-07-12 20:22:50 -0400
committertle2012-07-12 20:22:50 -0400
commit2110afedf1e96d8c1020703338c16fe135b80214 (patch)
treeb58c900d236644ccc00f5790a92514593373a2d1 /jaxb
parent387de26fce49153df720e9f14e3e6c38f8c41f7b (diff)
downloadwebtools.dali-2110afedf1e96d8c1020703338c16fe135b80214.tar.gz
webtools.dali-2110afedf1e96d8c1020703338c16fe135b80214.tar.xz
webtools.dali-2110afedf1e96d8c1020703338c16fe135b80214.zip
352865 - SQL script generation does not open the generated script
Diffstat (limited to 'jaxb')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.core.gen/src/org/eclipse/jpt/dbws/eclipselink/core/gen/Main.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/property_files/jpt_dbws_ui.properties2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java47
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/JptDbwsUiMessages.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/Main.java22
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/internal/Tools.java22
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java18
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java121
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java16
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/Main.java28
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/internal/Tools.java22
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/gen/GenerateJaxbClassesJob.java96
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java15
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java132
22 files changed, 310 insertions, 293 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.core.gen/src/org/eclipse/jpt/dbws/eclipselink/core/gen/Main.java b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.core.gen/src/org/eclipse/jpt/dbws/eclipselink/core/gen/Main.java
index 4f6f4451a6..797c931eb6 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.core.gen/src/org/eclipse/jpt/dbws/eclipselink/core/gen/Main.java
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.core.gen/src/org/eclipse/jpt/dbws/eclipselink/core/gen/Main.java
@@ -72,14 +72,14 @@ public class Main
DBWSBuilderModel model = this.buildBuilderModel(this.builderFile);
if(model == null) {
this.logMessage(INFO, JptDbwsCoreMessages.NO_GENERATION_PERFORMED);
- return;
+ this.generationFailed();
}
builder.setProperties(model.properties);
builder.setOperations(model.operations);
if( ! this.jdbcDriverIsOnClasspath(builder.getDriver())) {
- return;
+ this.generationFailed();
}
DBWSPackager packager = this.buildEclipsePackager();
@@ -92,13 +92,13 @@ public class Main
}
catch(WSDLException e) {
this.logMessage(SEVERE, JptDbwsCoreMessages.WSDL_EXCEPTION, e.getMessage());
- return;
+ this.generationFailed();
}
catch(Exception e) {
//TODO Clean-up Stage dir. ?
this.logMessage(SEVERE, JptDbwsCoreMessages.GENERATION_FAILED, e.getMessage());
e.printStackTrace();
- return;
+ this.generationFailed();
}
this.logMessage(INFO, JptDbwsCoreMessages.GENERATION_COMPLETED);
return;
@@ -192,7 +192,11 @@ public class Main
private void logMessage(Level level, String key) {
Tools.logMessage(level, Tools.getString(key));
}
-
+
+ private void generationFailed() {
+ System.exit(1);
+ }
+
// ********** argument queries **********
private String getArgumentBuilderFile(String[] args) {
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/property_files/jpt_dbws_ui.properties b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/property_files/jpt_dbws_ui.properties
index 0d62c677d0..5c444f1371 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/property_files/jpt_dbws_ui.properties
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/property_files/jpt_dbws_ui.properties
@@ -44,6 +44,8 @@ DbwsGeneratorUi_dbwsNotOnClasspathMessage = \
DbwsGeneratorUi_notJavaProject = Not a java project
DbwsGeneratorUi_notWebDynamicProject = Not a WebDynamic project
+DbwsGeneratorUi_generatingDbws = Generating Database Web Services
+
BuilderXmlWizardPage_xmlCatalogTableTitle = XML Catalog
BuilderXmlWizardPage_xmlCatalogKeyColumn = Key
BuilderXmlWizardPage_xmlCatalogUriColumn = URI \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java
index 7313ad6ac4..5726995d22 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/core/internal/gen/DbwsGenerator.java
@@ -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.
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.Path;
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 @@ public class DbwsGenerator extends AbstractJptGenerator
// ********** static methods **********
- public static void generate(
+ public static JptGenerator generate(
IJavaProject javaProject,
String builderFileName,
String stageDirName,
@@ -48,7 +49,7 @@ public class DbwsGenerator extends AbstractJptGenerator
if (javaProject == null) {
throw new NullPointerException();
}
- new DbwsGenerator(javaProject,
+ return new DbwsGenerator(javaProject,
builderFileName,
stageDirName,
driverJarList).generate(monitor);
@@ -56,7 +57,7 @@ public class DbwsGenerator extends AbstractJptGenerator
// ********** constructors **********
- private DbwsGenerator(
+ public DbwsGenerator(
IJavaProject javaProject,
String builderFileName,
String stageDirName,
@@ -126,7 +127,7 @@ public class DbwsGenerator extends AbstractJptGenerator
// packageAs
programArguments.append(" -packageAs eclipse"); //$NON-NLS-1$
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ this.getLaunchConfig().setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
}
// ********** private methods **********
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java
index de2e5e81d3..8ca85f0a91 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/DbwsGeneratorUi.java
@@ -16,11 +16,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
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.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
@@ -28,9 +24,12 @@ import org.eclipse.jdt.core.JavaModelException;
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.ui.gen.AbstractJptGenerateJob;
+import org.eclipse.jpt.common.utility.internal.StringTools;
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;
@@ -250,26 +249,40 @@ public class DbwsGeneratorUi
// ********** generate DBWS job **********
- public static class GenerateDbwsJob extends WorkspaceJob {
- private final IJavaProject project;
- final String builderFileName;
- final String stageDirName;
- final String driverJarList;
+ public static class GenerateDbwsJob extends AbstractJptGenerateJob {
+ private final String builderFileName;
+ private final String stageDirName;
+ private final String driverJarList;
- public GenerateDbwsJob(IJavaProject project, String builderFileName, String stageDirName, String driverJarList) {
- super(JptDbwsUiMessages.DbwsGeneratorWizard_generatingDbws);
+ public GenerateDbwsJob(IJavaProject javaProject, String builderFileName, String stageDirName, String driverJarList) {
+ super(JptDbwsUiMessages.DbwsGeneratorWizard_generatingDbws, javaProject);
- this.project = project ;
this.builderFileName = builderFileName;
this.stageDirName = stageDirName;
this.driverJarList = driverJarList;
}
+ // ********** overwrite AbstractJptGenerateJob **********
+
@Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- DbwsGenerator.generate(this.project, this.builderFileName, this.stageDirName, this.driverJarList, monitor);
- return Status.OK_STATUS;
+ protected JptGenerator buildGenerator() {
+ return new DbwsGenerator(this.getJavaProject(), this.builderFileName, this.stageDirName, this.driverJarList);
}
-
+
+ @Override
+ protected void postGenerate() {
+ this.refreshProject();
+ }
+
+ @Override
+ protected String getJobName() {
+ return JptDbwsUiMessages.DbwsGeneratorUi_generatingDbws;
+ }
+
+ @Override
+ protected void jptPluginLogException(Exception exception) {
+ JptDbwsUiPlugin.log(exception);
+ }
+
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/JptDbwsUiMessages.java b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/JptDbwsUiMessages.java
index 1610eac2a3..c123fcfed7 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/JptDbwsUiMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/JptDbwsUiMessages.java
@@ -48,6 +48,8 @@ public class JptDbwsUiMessages {
public static String DbwsGeneratorUi_notJavaProject;
public static String DbwsGeneratorUi_notWebDynamicProject;
+ public static String DbwsGeneratorUi_generatingDbws;
+
public static String BuilderXmlWizardPage_xmlCatalogTableTitle;
public static String BuilderXmlWizardPage_xmlCatalogKeyColumn;
public static String BuilderXmlWizardPage_xmlCatalogUriColumn;
diff --git a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java
index 5b91e00fa6..327a463419 100644
--- a/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java
+++ b/jaxb/plugins/org.eclipse.jpt.dbws.eclipselink.ui/src/org/eclipse/jpt/dbws/eclipselink/ui/internal/wizards/gen/DbwsGeneratorWizard.java
@@ -13,7 +13,6 @@ 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.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -127,7 +126,7 @@ public class DbwsGeneratorWizard extends Wizard implements IWorkbenchWizard {
this.jdbcDriversPage.finish(); // persist settings
if(DbwsGeneratorUi.displayOverridingWebContentWarning(this.getShell())) {
- this.generateDbws(driverJarList);
+ this.scheduleGenerateDbwsJob(driverJarList);
}
return true;
}
@@ -179,7 +178,7 @@ public class DbwsGeneratorWizard extends Wizard implements IWorkbenchWizard {
return relativePath.toOSString();
}
- private void generateDbws(String driverJarList) {
+ private void scheduleGenerateDbwsJob(String driverJarList) {
String stageDirName = this.getJavaProject().getProject().getLocation().toOSString();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/Main.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/Main.java
index 9f6a922785..30f3f39893 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/Main.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/Main.java
@@ -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.
@@ -9,6 +9,9 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.schemagen;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -80,12 +83,13 @@ public class Main
this.generateSchema(jaxbContext);
}
else {
- System.out.println(Tools.bind(JptJaxbCoreMessages.SCHEMA_NOT_CREATED, this.targetSchemaName));
+ Tools.logMessage(INFO, Tools.bind(JptJaxbCoreMessages.SCHEMA_NOT_CREATED, this.targetSchemaName));
+ System.exit(1);
}
}
private JAXBContext buildJaxbContext() {
- System.out.println(Tools.getString(JptJaxbCoreMessages.LOADING_CLASSES));
+ Tools.logMessage(INFO, Tools.getString(JptJaxbCoreMessages.LOADING_CLASSES));
JAXBContext jaxbContext = null;
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -101,7 +105,7 @@ public class Main
}
private void generateSchema(JAXBContext jaxbContext) {
- System.out.println(Tools.getString(JptJaxbCoreMessages.GENERATING_SCHEMA));
+ Tools.logMessage(INFO, Tools.getString(JptJaxbCoreMessages.GENERATING_SCHEMA));
System.out.flush();
SchemaOutputResolver schemaOutputResolver =
@@ -121,10 +125,10 @@ public class Main
for(String className: classNames) {
try {
sourceClasses.add(loader.loadClass(className));
- System.out.println(className);
+ Tools.logMessage(INFO, className);
}
catch (ClassNotFoundException e) {
- System.err.println(Tools.bind(JptJaxbCoreMessages.NOT_FOUND, className));
+ Tools.logMessage(SEVERE, Tools.bind(JptJaxbCoreMessages.NOT_FOUND, className));
}
}
System.out.flush();
@@ -135,11 +139,11 @@ public class Main
String message = ex.getMessage();
Throwable linkedEx = ex.getLinkedException();
if(message != null && message.indexOf(NO_FACTORY_CLASS) > -1) {
- System.err.println(message);
+ Tools.logMessage(SEVERE, message);
}
else if(linkedEx != null && linkedEx instanceof ClassNotFoundException) {
String errorMessage = Tools.bind(JptJaxbCoreMessages.CONTEXT_FACTORY_NOT_FOUND, linkedEx.getMessage());
- System.err.println(errorMessage);
+ Tools.logMessage(SEVERE, errorMessage);
}
else {
ex.printStackTrace();
@@ -231,7 +235,7 @@ class JptSchemaOutputResolver extends SchemaOutputResolver {
StreamResult result = new StreamResult(file);
result.setSystemId(file.toURL().toExternalForm());
- System.out.print(Tools.bind(JptJaxbCoreMessages.SCHEMA_GENERATED, file));
+ Tools.logMessage(INFO, Tools.bind(JptJaxbCoreMessages.SCHEMA_GENERATED, file));
return result;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/internal/Tools.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/internal/Tools.java
index 6427661dcd..8696c5c2ff 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/internal/Tools.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core.schemagen/src/org/eclipse/jpt/jaxb/core/schemagen/internal/Tools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2010 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.
@@ -9,8 +9,11 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.schemagen.internal;
+import static java.util.logging.Level.SEVERE;
+
import java.io.File;
import java.text.MessageFormat;
+import java.util.logging.Level;
/**
* Tools
@@ -92,6 +95,23 @@ public final class Tools
return path.substring(0, path.lastIndexOf(File.separator));
}
+ private static void logMessage_(Level level, String message) {
+ if(level == SEVERE) {
+ System.err.println('\n' + message);
+ }
+ else {
+ System.out.println('\n' + message);
+ }
+ }
+
+ public static void logMessage(Level level, String key, Object argument) {
+ Tools.logMessage_(level, Tools.bind(key, argument));
+ }
+
+ public static void logMessage(Level level, String key) {
+ Tools.logMessage_(level, Tools.getString(key));
+ }
+
// ********** NLS utilities **********
public static String getString(String key) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
index 067fcecf05..44826c38ab 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/property_files/jpt_jaxb_core.properties
@@ -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,9 +12,6 @@ CONTEXT_MODEL_SYNC_JOB_NAME=Synchronize JAXB project: ''{0}''
UPDATE_JOB_NAME=Update JAXB project: ''{0}''
PREFERENCES_FLUSH_JOB_NAME=Flush Preferences: {0}
-ClassesGenerator_generatingClasses = Generating JAXB Classes from Schema
-ClassesGenerator_generatingClassesTask = Generating classes
-
JaxbFacetConfig_validatePlatformNotSpecified = Platform must be specified
JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion = Platform does not support the current JAXB facet version
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
index 1ddbcdc20f..c207546e9e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JptJaxbCoreMessages.java
@@ -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.
@@ -20,9 +20,6 @@ public class JptJaxbCoreMessages {
public static String UPDATE_JOB_NAME;
public static String PREFERENCES_FLUSH_JOB_NAME;
- public static String ClassesGenerator_generatingClasses;
- public static String ClassesGenerator_generatingClassesTask;
-
public static String JaxbFacetConfig_validatePlatformNotSpecified;
public static String JaxbFacetConfig_validatePlatformDoesNotSupportFacetVersion;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java
index 5562320863..c958be6936 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/ClassesGenerator.java
@@ -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 @@ package org.eclipse.jpt.jaxb.core.internal.gen;
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.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.gen.JptGenerator;
import org.eclipse.jpt.common.core.internal.gen.AbstractJptGenerator;
import org.eclipse.jpt.common.utility.internal.StringTools;
@@ -50,7 +52,7 @@ public class ClassesGenerator extends AbstractJptGenerator
// ********** static methods **********
- public static void generate(
+ public static JptGenerator generate(
IJavaProject javaProject,
String schemaPathOrUri,
String outputDir,
@@ -65,7 +67,7 @@ public class ClassesGenerator extends AbstractJptGenerator
if (javaProject == null) {
throw new NullPointerException();
}
- new ClassesGenerator(javaProject,
+ return new ClassesGenerator(javaProject,
schemaPathOrUri,
outputDir,
targetPackage,
@@ -136,7 +138,7 @@ public class ClassesGenerator extends AbstractJptGenerator
// ********** constructors **********
- protected ClassesGenerator(
+ public ClassesGenerator(
IJavaProject javaProject,
String schemaPathOrUri,
String outputDir,
@@ -321,7 +323,7 @@ public class ClassesGenerator extends AbstractJptGenerator
programArguments.append(StringTools.quote(bindingsFileName));
}
}
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ this.getLaunchConfig().setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
}
@@ -329,15 +331,15 @@ public class ClassesGenerator extends AbstractJptGenerator
private List<IRuntimeClasspathEntry> getContainersClasspathEntries() throws CoreException {
ArrayList<IRuntimeClasspathEntry> classpathEntries = new ArrayList<IRuntimeClasspathEntry>();
- for(IClasspathEntry classpathEntry: this.javaProject.getRawClasspath()) {
+ for(IClasspathEntry classpathEntry: this.getJavaProject().getRawClasspath()) {
if(classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
- IClasspathContainer container = JavaCore.getClasspathContainer(classpathEntry.getPath(), this.javaProject);
+ IClasspathContainer container = JavaCore.getClasspathContainer(classpathEntry.getPath(), this.getJavaProject());
if(container != null && container.getKind() == IClasspathContainer.K_SYSTEM) {
classpathEntries.add(
JavaRuntime.newRuntimeContainerClasspathEntry(
container.getPath(),
IRuntimeClasspathEntry.BOOTSTRAP_CLASSES,
- this.javaProject));
+ this.getJavaProject()));
}
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java
deleted file mode 100644
index 0db2a9e337..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/GenerateJaxbClassesJob.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
-* 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.gen;
-
-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.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.jaxb.core.internal.JptJaxbCoreMessages;
-
-/**
- * GenerateJaxbClassesJob
- */
-public class GenerateJaxbClassesJob extends WorkspaceJob {
- private final IJavaProject javaProject;
- private final String absoluteLocalXsdUri;
- private final String outputDir;
- private final String targetPackage;
- private final String catalog;
- private final boolean usesMoxyGenerator;
- private final String[] bindingsFileNames;
- private final ClassesGeneratorOptions generatorOptions;
- private final ClassesGeneratorExtensionOptions generatorExtensionOptions;
-
- // ********** constructors **********
-
- public GenerateJaxbClassesJob(
- IJavaProject javaProject,
- String absoluteLocalXsdUri,
- String outputDir,
- String targetPackage,
- String catalog,
- boolean usesMoxyGenerator,
- String[] bindingsFileNames,
- ClassesGeneratorOptions generatorOptions,
- ClassesGeneratorExtensionOptions generatorExtensionOptions) {
-
- super(JptJaxbCoreMessages.ClassesGenerator_generatingClasses);
- if (javaProject == null) {
- throw new RuntimeException("Project is null"); //$NON-NLS-1$
- }
- else if (StringTools.stringIsEmpty(absoluteLocalXsdUri)) {
- throw new RuntimeException("Schema cannot be empty"); //$NON-NLS-1$
- }
- else if(StringTools.stringIsEmpty(outputDir)) {
- throw new RuntimeException("Output directory cannot be empty"); //$NON-NLS-1$
- }
- this.javaProject = javaProject;
- this.absoluteLocalXsdUri = absoluteLocalXsdUri;
- this.outputDir = outputDir;
- this.targetPackage = targetPackage;
- this.catalog = catalog;
- this.usesMoxyGenerator = usesMoxyGenerator;
- this.bindingsFileNames = bindingsFileNames;
- this.generatorOptions = generatorOptions;
- this.generatorExtensionOptions = generatorExtensionOptions;
- this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject()));
- }
-
- @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));
- }
- catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- // fall through and tell monitor we are done
- }
- catch (RuntimeException re) {
- throw new RuntimeException(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) {
-
- ClassesGenerator.generate(javaProject,
- absoluteLocalXsdUri,
- outputDir,
- targetPackage,
- catalog,
- usesMoxyGenerator,
- bindingsFileNames,
- generatorOptions,
- generatorExtensionOptions,
- monitor);
- return;
- }
-} \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
index 2d821a9114..13f32b8883 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/gen/SchemaGenerator.java
@@ -18,6 +18,7 @@ import java.io.UnsupportedEncodingException;
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.IPackageFragment;
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 @@ public class SchemaGenerator extends AbstractJptGenerator
// ********** static methods **********
- public static void generate(
+ public static JptGenerator generate(
IJavaProject javaProject,
String targetSchemaName,
String[] sourceClassNames,
@@ -71,7 +73,7 @@ public class SchemaGenerator extends AbstractJptGenerator
if (javaProject == null) {
throw new NullPointerException();
}
- new SchemaGenerator(javaProject,
+ return new SchemaGenerator(javaProject,
targetSchemaName,
sourceClassNames,
useMoxy).generate(monitor);
@@ -79,7 +81,7 @@ public class SchemaGenerator extends AbstractJptGenerator
// ********** constructors **********
- protected SchemaGenerator(
+ public SchemaGenerator(
IJavaProject javaProject,
String targetSchemaName,
String[] sourceClassNames,
@@ -155,7 +157,7 @@ public class SchemaGenerator extends AbstractJptGenerator
programArguments.append(this.targetSchemaName);
programArguments.append('"');
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
+ this.getLaunchConfig().setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments.toString());
}
// ********** private methods **********
@@ -174,7 +176,7 @@ public class SchemaGenerator extends AbstractJptGenerator
* Returns null if no "jaxb.properties" file is found.
*/
private IFile getJaxbPropertiesFile() {
- return getJaxbPropertiesFileFromPackageRoots(JDTTools.getJavaSourceFolders(this.javaProject));
+ return getJaxbPropertiesFileFromPackageRoots(JDTTools.getJavaSourceFolders(this.getJavaProject()));
}
private IFile getJaxbPropertiesFileFromPackageRoots(Iterable<IPackageFragmentRoot> packageFragmentRoots){
@@ -277,7 +279,7 @@ public class SchemaGenerator extends AbstractJptGenerator
String packageName = sourceClassName.substring(0, sourceClassName.lastIndexOf('.'));
//Find the existing package fragment where we want to generate
- for (IPackageFragmentRoot pfr : JDTTools.getJavaSourceFolders(this.javaProject)) {
+ for (IPackageFragmentRoot pfr : JDTTools.getJavaSourceFolders(this.getJavaProject())) {
//use the package of the first source class as the package for generation
IPackageFragment packageFragment = pfr.getPackageFragment(packageName);
if (packageFragment.exists()){
@@ -293,7 +295,7 @@ public class SchemaGenerator extends AbstractJptGenerator
}
private IPackageFragmentRoot getFirstJavaSourceFolder() {
- Iterator<IPackageFragmentRoot> i = JDTTools.getJavaSourceFolders(this.javaProject).iterator();
+ Iterator<IPackageFragmentRoot> i = JDTTools.getJavaSourceFolders(this.getJavaProject()).iterator();
return i.hasNext() ? i.next() : null;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/Main.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/Main.java
index 0ae05f139f..2521f3b1a5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/Main.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/Main.java
@@ -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.
@@ -9,6 +9,9 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.schemagen;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -81,12 +84,13 @@ public class Main
this.generateSchema(jaxbContext);
}
else {
- Tools.bind(JptEclipseLinkJaxbCoreMessages.SCHEMA_NOT_CREATED, this.targetSchemaName);
+ Tools.logMessage(INFO, Tools.bind(JptEclipseLinkJaxbCoreMessages.SCHEMA_NOT_CREATED, this.targetSchemaName));
+ this.generationFailed();
}
}
private JAXBContext buildJaxbContext() {
- System.out.println(Tools.getString(JptEclipseLinkJaxbCoreMessages.LOADING_CLASSES));
+ Tools.logMessage(INFO, Tools.getString(JptEclipseLinkJaxbCoreMessages.LOADING_CLASSES));
JAXBContext jaxbContext = null;
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -107,7 +111,7 @@ public class Main
}
private void generateSchema(JAXBContext jaxbContext) {
- System.out.println(Tools.getString(JptEclipseLinkJaxbCoreMessages.GENERATING_SCHEMA));
+ Tools.logMessage(INFO, Tools.getString(JptEclipseLinkJaxbCoreMessages.GENERATING_SCHEMA));
System.out.flush();
SchemaOutputResolver schemaOutputResolver =
@@ -127,10 +131,10 @@ public class Main
for(String className: classNames) {
try {
sourceClasses.add(loader.loadClass(className));
- System.out.println(className);
+ Tools.logMessage(INFO, className);
}
catch (ClassNotFoundException e) {
- System.err.println(Tools.bind(JptEclipseLinkJaxbCoreMessages.NOT_FOUND, className));
+ Tools.logMessage(SEVERE, Tools.bind(JptEclipseLinkJaxbCoreMessages.NOT_FOUND, className));
}
}
System.out.flush();
@@ -141,12 +145,12 @@ public class Main
String message = ex.getMessage();
Throwable linkedEx = ex.getLinkedException();
if(message != null && message.indexOf(NO_FACTORY_CLASS) > -1) {
- System.err.println(message);
+ Tools.logMessage(SEVERE, message);
}
else if(linkedEx != null && linkedEx instanceof ClassNotFoundException) {
String errorMessage = Tools.bind(
JptEclipseLinkJaxbCoreMessages.CONTEXT_FACTORY_NOT_FOUND, linkedEx.getMessage());
- System.err.println(errorMessage);
+ Tools.logMessage(SEVERE, errorMessage);
}
else {
ex.printStackTrace();
@@ -156,7 +160,7 @@ public class Main
private void handleClassCastException(ClassCastException ex) {
String message = ex.getMessage();
if(message != null && message.indexOf(CANNOT_BE_CAST_TO_JAXBCONTEXT) > -1) {
- System.err.println(Tools.getString(JptEclipseLinkJaxbCoreMessages.PROPERTIES_FILE_NOT_FOUND));
+ Tools.logMessage(SEVERE, Tools.getString(JptEclipseLinkJaxbCoreMessages.PROPERTIES_FILE_NOT_FOUND));
}
else {
ex.printStackTrace();
@@ -219,6 +223,10 @@ public class Main
}
return false;
}
+
+ private void generationFailed() {
+ System.exit(1);
+ }
}
@@ -247,7 +255,7 @@ class JptSchemaOutputResolver extends SchemaOutputResolver {
StreamResult result = new StreamResult(file);
result.setSystemId(file.toURI().toURL().toString());
- System.out.print(Tools.bind(JptEclipseLinkJaxbCoreMessages.SCHEMA_GENERATED, file));
+ Tools.logMessage(INFO, Tools.bind(JptEclipseLinkJaxbCoreMessages.SCHEMA_GENERATED, file));
return result;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/internal/Tools.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/internal/Tools.java
index 5a32e4c09c..bb9247042d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/internal/Tools.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core.schemagen/src/org/eclipse/jpt/jaxb/eclipselink/core/schemagen/internal/Tools.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2010 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.
@@ -9,8 +9,11 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.schemagen.internal;
+import static java.util.logging.Level.SEVERE;
+
import java.io.File;
import java.text.MessageFormat;
+import java.util.logging.Level;
/**
* Tools
@@ -92,6 +95,23 @@ public final class Tools
return path.substring(0, path.lastIndexOf(File.separator));
}
+ private static void logMessage_(Level level, String message) {
+ if(level == SEVERE) {
+ System.err.println('\n' + message);
+ }
+ else {
+ System.out.println('\n' + message);
+ }
+ }
+
+ public static void logMessage(Level level, String key, Object argument) {
+ Tools.logMessage_(level, Tools.bind(key, argument));
+ }
+
+ public static void logMessage(Level level, String key) {
+ Tools.logMessage_(level, Tools.getString(key));
+ }
+
// ********** NLS utilities **********
public static String getString(String key) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
index 89a4a4d393..e8031a1416 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/META-INF/MANIFEST.MF
@@ -34,7 +34,9 @@ Require-Bundle: org.eclipse.debug.core;bundle-version="[3.4.0,4.0.0)",
Export-Package: org.eclipse.jpt.jaxb.ui,
org.eclipse.jpt.jaxb.ui.internal;x-internal:=true,
org.eclipse.jpt.jaxb.ui.internal.actions;x-internal:=true,
+ org.eclipse.jpt.jaxb.ui.internal.commands;x-internal:=true,
org.eclipse.jpt.jaxb.ui.internal.filters;x-internal:=true,
+ org.eclipse.jpt.jaxb.ui.internal.gen;x-internal:=true,
org.eclipse.jpt.jaxb.ui.internal.jaxb21;x-internal:=true,
org.eclipse.jpt.jaxb.ui.internal.jaxb22;x-internal:=true,
org.eclipse.jpt.jaxb.ui.internal.navigator;x-internal:=true,
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
index 8917ccd0b3..ee858abba5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties
@@ -156,7 +156,12 @@ SchemaGeneratorWizardPage_moxyLibrariesNotAvailable = \
SchemaGeneratorWizard_generateSchemaTask = Generating schema {0}
-#NewSchemaFileWizardPage
+# JptGenerateJob
+
+GenerateJaxbClassesJob_generatingClasses = Generating JAXB Classes from Schema
+GenerateJaxbClassesJob_generatingClassesTask = Generating classes
+
+# NewSchemaFileWizardPage
NewSchemaFileWizardPage_errorNotJavaProject = Not a Java project
NewSchemaFileWizardPage_overwriteExistingSchemas = Schema generation may overwrite existing schemas in the specified directory.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
index f67d113c5e..154e971329 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/ClassesGeneratorUi.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2010 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.
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.ui.internal;
import java.util.List;
import java.util.Vector;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.emf.common.util.URI;
@@ -26,9 +27,9 @@ import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.SchemaLibrary;
import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorExtensionOptions;
import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorOptions;
-import org.eclipse.jpt.jaxb.core.internal.gen.GenerateJaxbClassesJob;
import org.eclipse.jpt.jaxb.core.xsd.XsdUtil;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.gen.GenerateJaxbClassesJob;
import org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.ClassesGeneratorWizard;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
index ef7689b1aa..ebb46df73c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2010 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.
@@ -156,6 +156,10 @@ public class JptJaxbUiMessages {
public static String NewSchemaFileWizardPage_errorNotJavaProject;
public static String NewSchemaFileWizardPage_overwriteExistingSchemas;
+ // JptGenerateJob
+
+ public static String GenerateJaxbClassesJob_generatingClasses;
+ public static String GenerateJaxbClassesJob_generatingClassesTask;
// new project wizard
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/gen/GenerateJaxbClassesJob.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/gen/GenerateJaxbClassesJob.java
new file mode 100644
index 0000000000..11cc53f86e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/gen/GenerateJaxbClassesJob.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+* 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.jaxb.ui.internal.gen;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jpt.common.core.gen.JptGenerator;
+import org.eclipse.jpt.common.ui.gen.AbstractJptGenerateJob;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGenerator;
+import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorExtensionOptions;
+import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorOptions;
+import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
+import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
+
+/**
+ * GenerateJaxbClassesJob
+ */
+public class GenerateJaxbClassesJob extends AbstractJptGenerateJob {
+ private final String absoluteLocalXsdUri;
+ private final String outputDir;
+ private final String targetPackage;
+ private final String catalog;
+ private final boolean usesMoxyGenerator;
+ private final String[] bindingsFileNames;
+ private final ClassesGeneratorOptions generatorOptions;
+ private final ClassesGeneratorExtensionOptions generatorExtensionOptions;
+
+ // ********** constructors **********
+
+ public GenerateJaxbClassesJob(
+ IJavaProject javaProject,
+ String absoluteLocalXsdUri,
+ String outputDir,
+ String targetPackage,
+ String catalog,
+ boolean usesMoxyGenerator,
+ String[] bindingsFileNames,
+ ClassesGeneratorOptions generatorOptions,
+ ClassesGeneratorExtensionOptions generatorExtensionOptions) {
+
+ super(JptJaxbUiMessages.GenerateJaxbClassesJob_generatingClasses, javaProject);
+ if (javaProject == null) {
+ throw new RuntimeException("Project is null"); //$NON-NLS-1$
+ }
+ else if (StringTools.stringIsEmpty(absoluteLocalXsdUri)) {
+ throw new RuntimeException("Schema cannot be empty"); //$NON-NLS-1$
+ }
+ else if(StringTools.stringIsEmpty(outputDir)) {
+ throw new RuntimeException("Output directory cannot be empty"); //$NON-NLS-1$
+ }
+ this.absoluteLocalXsdUri = absoluteLocalXsdUri;
+ this.outputDir = outputDir;
+ this.targetPackage = targetPackage;
+ this.catalog = catalog;
+ this.usesMoxyGenerator = usesMoxyGenerator;
+ this.bindingsFileNames = bindingsFileNames;
+ this.generatorOptions = generatorOptions;
+ this.generatorExtensionOptions = generatorExtensionOptions;
+ }
+
+ // ********** overwrite AbstractJptGenerateJob **********
+
+ @Override
+ protected JptGenerator buildGenerator() {
+ return new ClassesGenerator(this.getJavaProject(),
+ this.absoluteLocalXsdUri,
+ this.outputDir,
+ this.targetPackage,
+ this.catalog,
+ this.usesMoxyGenerator,
+ this.bindingsFileNames,
+ this.generatorOptions,
+ this.generatorExtensionOptions); }
+
+ @Override
+ protected void postGenerate() {
+ this.refreshProject();
+ }
+
+ @Override
+ protected String getJobName() {
+ return JptJaxbUiMessages.GenerateJaxbClassesJob_generatingClassesTask;
+ }
+
+ @Override
+ protected void jptPluginLogException(Exception exception) {
+ JptJaxbUiPlugin.log(exception);
+ }
+} \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
index 5218c0f4a5..a0412a1671 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen;
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;
@@ -32,11 +33,11 @@ import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.SchemaLibrary;
import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorExtensionOptions;
import org.eclipse.jpt.jaxb.core.internal.gen.ClassesGeneratorOptions;
-import org.eclipse.jpt.jaxb.core.internal.gen.GenerateJaxbClassesJob;
import org.eclipse.jpt.jaxb.core.xsd.XsdUtil;
import org.eclipse.jpt.jaxb.ui.JptJaxbUiPlugin;
import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiIcons;
import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
+import org.eclipse.jpt.jaxb.ui.internal.gen.GenerateJaxbClassesJob;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
@@ -158,9 +159,9 @@ public class ClassesGeneratorWizard
}
if (this.performsGeneration) {
- if (displayOverwritingClassesWarning(this.generatorOptions)) {
- generateJaxbClasses();
- addSchemaToLibrary();
+ if (this.displayOverwritingClassesWarning(this.generatorOptions)) {
+ this.scheduleGenerateJaxbClassesJob();
+ this.addSchemaToLibrary();
}
}
@@ -346,9 +347,9 @@ public class ClassesGeneratorWizard
}
}
- private void generateJaxbClasses() {
+ private void scheduleGenerateJaxbClassesJob() {
try {
- WorkspaceJob job =
+ WorkspaceJob generateJaxbClassesJob =
new GenerateJaxbClassesJob(
this.getJavaProject(),
this.getLocalSchemaUri().toString(),
@@ -359,7 +360,7 @@ public class ClassesGeneratorWizard
this.bindingsFileNames,
this.generatorOptions,
this.generatorExtensionOptions);
- job.schedule();
+ generateJaxbClassesJob.schedule();
}
catch(RuntimeException re) {
JptJaxbUiPlugin.log(re);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
index 67fb5ff2d2..ff8a540923 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java
@@ -10,25 +10,18 @@
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.IResourceRuleFactory;
import org.eclipse.core.resources.ResourcesPlugin;
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.OperationCanceledException;
import org.eclipse.core.runtime.Path;
-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.IPackageFragment;
@@ -36,7 +29,8 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.core.gen.JptGenerator;
+import org.eclipse.jpt.common.ui.gen.AbstractJptGenerateJob;
import org.eclipse.jpt.common.utility.internal.ArrayTools;
import org.eclipse.jpt.common.utility.internal.FileTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
@@ -48,10 +42,6 @@ import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
@@ -115,25 +105,19 @@ public class SchemaGeneratorWizard extends Wizard implements INewWizard
}
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();
-// Delaying the release of "open file" functionality (see bug 322567)
-// 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 **********
@@ -260,84 +244,58 @@ public class SchemaGeneratorWizard extends Wizard implements INewWizard
// ********** generate schema job **********
- static class GenerateSchemaJob extends WorkspaceJob {
- private final IJavaProject javaProject;
+ static class GenerateSchemaJob extends AbstractJptGenerateJob {
private final String[] sourceClassNames;
private final String targetSchema;
private final boolean useMoxy;
-
- GenerateSchemaJob(IJavaProject project, String[] sourceClassNames, String targetSchema, boolean useMoxy) {
- super(JptJaxbUiMessages.SchemaGeneratorWizard_generatingSchema);
+ private final IPath schemaPath;
+ private final String schemaName;
+
+ // ********** constructor **********
+
+ protected GenerateSchemaJob(IJavaProject javaProject, String[] sourceClassNames, String targetSchema,
+ boolean useMoxy, IPath schemaPath, String schemaName) {
+
+ super(JptJaxbUiMessages.SchemaGeneratorWizard_generatingSchema, javaProject);
- this.javaProject = project ;
this.sourceClassNames = sourceClassNames;
this.targetSchema = targetSchema;
this.useMoxy = useMoxy;
-
- this.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(this.javaProject.getProject()));
+ this.schemaPath = schemaPath;
+ this.schemaName = schemaName;
}
+ // ********** overwrite AbstractJptGenerateJob **********
+
@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));
- }
- catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
+ protected JptGenerator buildGenerator() {
+ return new SchemaGenerator(this.getJavaProject(), this.targetSchema, this.sourceClassNames, this.useMoxy);
}
- }
-
- // ********** 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()));
+
+ @Override
+ protected void postGenerate() {
+ this.refreshProject();
+ this.openGeneratedSchemaFile();
}
@Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- try {
- this.postGeneration(this.schemaFile);
- }
- catch (InvocationTargetException e) {
- throw new CoreException(new Status(IStatus.ERROR, JptJaxbUiPlugin.PLUGIN_ID, "error", e)); //$NON-NLS-1$
- }
- return Status.OK_STATUS;
+ protected String getJobName() {
+ return NLS.bind(JptJaxbUiMessages.SchemaGeneratorWizard_generateSchemaTask, this.targetSchema);
}
-
- private void postGeneration(IFile schemaFile) throws InvocationTargetException {
- try {
- this.openEditor(schemaFile);
- }
- catch (Exception cantOpen) {
- throw new InvocationTargetException(cantOpen);
- }
+
+ @Override
+ protected void jptPluginLogException(Exception exception) {
+ JptJaxbUiPlugin.log(exception);
}
-
- 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) {
- JptJaxbUiPlugin.log(e);
- }
- }
- });
- }
+
+ // ********** internal methods **********
+
+ private void openGeneratedSchemaFile() {
+
+ IContainer container = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(this.schemaPath);
+ IFile schemaFile = container.getFile(new Path(this.schemaName));
+
+ this.openEditor(schemaFile);
}
}
} \ No newline at end of file

Back to the top