Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jaxb
diff options
context:
space:
mode:
authortle2012-04-11 18:54:15 -0400
committertle2012-04-11 18:54:15 -0400
commitb58d0a60e323bd0bc6dd8332c67e5603ea3a1d6c (patch)
tree453e5f8dcda6a87dd2f40e283959c7a01cf8e9d6 /jaxb
parentbacc598574927d1502f1cd3a5aa2768c1bef5a27 (diff)
downloadwebtools.dali-b58d0a60e323bd0bc6dd8332c67e5603ea3a1d6c.tar.gz
webtools.dali-b58d0a60e323bd0bc6dd8332c67e5603ea3a1d6c.tar.xz
webtools.dali-b58d0a60e323bd0bc6dd8332c67e5603ea3a1d6c.zip
322567 - JAXB schema generation should open the generated schema
Diffstat (limited to 'jaxb')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/SchemaGeneratorWizard.java88
3 files changed, 84 insertions, 6 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 4f9963daf7..8917ccd0b3 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
@@ -128,6 +128,7 @@ ClassesGeneratorUi_generatingClassesWarningMessage = \
SchemaGeneratorWizard_title = New JAXB Schema File
SchemaGeneratorWizard_generatingSchema = Generating JAXB Schema
+SchemaGeneratorWizard_openSchemaFileJobName = Open XSD File
SchemaGeneratorProjectWizardPage_title = JAXB schema file
SchemaGeneratorProjectWizardPage_desc = Specify default file name and location
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 a71c8df345..ef7689b1aa 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
@@ -129,6 +129,7 @@ public class JptJaxbUiMessages {
// SchemaGenerator
public static String SchemaGeneratorWizard_title;
public static String SchemaGeneratorWizard_generatingSchema;
+ public static String SchemaGeneratorWizard_openSchemaFileJobName;
public static String SchemaGeneratorProjectWizardPage_title;
public static String SchemaGeneratorProjectWizardPage_desc;
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 4f44a8ab64..50422d52a5 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,10 +10,14 @@
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;
@@ -22,6 +26,7 @@ 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;
@@ -31,6 +36,7 @@ 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.utility.internal.ArrayTools;
import org.eclipse.jpt.common.utility.internal.FileTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
@@ -42,6 +48,10 @@ 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;
@@ -99,15 +109,30 @@ public class SchemaGeneratorWizard extends Wizard implements INewWizard
this.targetProject = this.getJavaProject();
String[] sourceClassNames = this.buildSourceClassNames(this.getAllCheckedItems());
-
+
+ this.scheduleGenerateSchemaJob(sourceClassNames);
+ return true;
+ }
+
+ protected void scheduleGenerateSchemaJob(String[] sourceClassNames) {
+
WorkspaceJob genSchemaJob = new GenerateSchemaJob(
- this.targetProject,
- sourceClassNames,
- this.getTargetSchema(),
- this.usesMoxy());
+ this.targetProject,
+ sourceClassNames,
+ this.getTargetSchema(),
+ this.usesMoxy());
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));
- return true;
+ OpenSchemaFileJob openSchemaFileJob = new OpenSchemaFileJob(
+ this.targetProject,
+ schemaFile);
+ openSchemaFileJob.schedule();
}
// ********** intra-wizard methods **********
@@ -263,4 +288,55 @@ public class SchemaGeneratorWizard extends Wizard implements INewWizard
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()));
+ }
+
+ @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;
+ }
+
+ private void postGeneration(IFile schemaFile) throws InvocationTargetException {
+ try {
+ this.openEditor(schemaFile);
+ }
+ catch (Exception cantOpen) {
+ throw new InvocationTargetException(cantOpen);
+ }
+ }
+
+ 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);
+ }
+ }
+ });
+ }
+ }
+ }
} \ No newline at end of file

Back to the top