Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Fullbright2013-04-08 21:47:18 +0000
committerPaul Fullbright2013-04-08 21:48:04 +0000
commit4d16f59ad20dc788eb7f2c59b9fa92d38ef0cba6 (patch)
treece8c4c0939a644c89203ab7b257067255e4fe568 /jaxb/plugins
parent9a4e805e479c2b96a476b85b05a010e1a9434c1e (diff)
downloadwebtools.dali-4d16f59ad20dc788eb7f2c59b9fa92d38ef0cba6.tar.gz
webtools.dali-4d16f59ad20dc788eb7f2c59b9fa92d38ef0cba6.tar.xz
webtools.dali-4d16f59ad20dc788eb7f2c59b9fa92d38ef0cba6.zip
put add schema to library action in jobv201304090106
Diffstat (limited to 'jaxb/plugins')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiMessages.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java71
3 files changed, 57 insertions, 20 deletions
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 72802c6270..7fbffe7d15 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
@@ -10,6 +10,8 @@
# JptJaxbUiMessages
+ADD_SCHEMA_TO_LIBRARY_JOB__NAME=Adding schema to project schema library
+
JAVA_PROJECT_WIZARD_PAGE_PROJECT=Project:
JAVA_PROJECT_WIZARD_PAGE_DESTINATION_PROJECT=Select destination project:
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiMessages.java
index ddef4cc777..a9f791d908 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/JptJaxbUiMessages.java
@@ -21,7 +21,9 @@ public class JptJaxbUiMessages {
static {
NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
}
-
+
+ public static String ADD_SCHEMA_TO_LIBRARY_JOB__NAME;
+
public static String JAVA_PROJECT_WIZARD_PAGE_PROJECT;
public static String JAVA_PROJECT_WIZARD_PAGE_DESTINATION_PROJECT;
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 431a27abc5..d4549b5af0 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
@@ -17,6 +17,9 @@ 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.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -165,14 +168,14 @@ public class ClassesGeneratorWizard
IFolder folder = this.getJavaProject().getProject().getFolder(this.destinationFolder);
this.createFolderIfNotExist(folder);
}
-
+
if (this.performsGeneration) {
- if (this.displayOverwritingClassesWarning(this.generatorOptions)) {
- this.scheduleGenerateJaxbClassesJob();
- this.addSchemaToLibrary();
+ if (displayOverwritingClassesWarning(this.generatorOptions)) {
+ doGenerateJaxbClasses();
+ doAddSchemaToLibrary();
}
}
-
+
return true;
}
@@ -370,7 +373,7 @@ public class ClassesGeneratorWizard
}
}
- private void scheduleGenerateJaxbClassesJob() {
+ private void doGenerateJaxbClasses() {
try {
WorkspaceJob generateJaxbClassesJob =
new GenerateJaxbClassesJob(
@@ -394,26 +397,56 @@ public class ClassesGeneratorWizard
}
}
- private void addSchemaToLibrary() {
- JaxbProject jaxbProject = getJaxbProject();
+ private void doAddSchemaToLibrary() {
+ try {
+ JaxbProject jaxbProject = getJaxbProject();
+ if (jaxbProject == null) {
+ return;
+ }
+ WorkspaceJob addSchemaToLibraryJob = new AddSchemaToLibraryJob(jaxbProject, getSchemaLocation());
+ addSchemaToLibraryJob.schedule();
+ }
+ catch(RuntimeException re) {
+ JptJaxbUiPlugin.instance().logError(re);
+
+ String msg = re.getMessage();
+ String message = (msg == null) ? re.toString() : msg;
+ this.logError(message);
+ }
+ }
+
+
+ protected class AddSchemaToLibraryJob
+ extends WorkspaceJob {
- if (jaxbProject == null) {
- return;
+ private final JaxbProject jaxbProject;
+ private final String schemaLocation;
+
+
+ protected AddSchemaToLibraryJob(JaxbProject jaxbProject, String schemaLocation) {
+ super(JptJaxbUiMessages.ADD_SCHEMA_TO_LIBRARY_JOB__NAME);
+ this.jaxbProject = jaxbProject;
+ this.schemaLocation = schemaLocation;
}
- String schemaLocation = getSchemaLocation();
- String resolvedUri = XsdUtil.getResolvedUri(schemaLocation);
- XSDSchema schema = XSDImpl.buildXSDModel(resolvedUri);
- if (schema != null) {
- SchemaLibrary schemaLib = jaxbProject.getSchemaLibrary();
- List<String> schemas = new Vector<String>(schemaLib.getSchemaLocations());
- if (! schemas.contains(schemaLocation)) {
- schemas.add(schemaLocation);
- schemaLib.setSchemaLocations(schemas);
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ String resolvedUri = XsdUtil.getResolvedUri(this.schemaLocation);
+ XSDSchema schema = XSDImpl.buildXSDModel(resolvedUri);
+ if (schema != null) {
+ SchemaLibrary schemaLib = this.jaxbProject.getSchemaLibrary();
+ List<String> schemas = new Vector<String>(schemaLib.getSchemaLocations());
+ if (! schemas.contains(this.schemaLocation)) {
+ schemas.add(this.schemaLocation);
+ schemaLib.setSchemaLocations(schemas);
+ }
}
+ return Status.OK_STATUS;
}
}
+
protected void logError(String message) {
this.displayError(message);
}

Back to the top