Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Fullbright2013-04-08 09:41:31 -0400
committerPaul Fullbright2013-04-08 09:41:55 -0400
commit6b55ffc5e9731a03886a7e5713304f6f8ee2c433 (patch)
treee4a5f7c1729f9d166aa369d40d1a99dc7b13493c
parent64dfea83348929564979d8b8d580fd8263866f33 (diff)
downloadwebtools.dali-6b55ffc5e9731a03886a7e5713304f6f8ee2c433.tar.gz
webtools.dali-6b55ffc5e9731a03886a7e5713304f6f8ee2c433.tar.xz
webtools.dali-6b55ffc5e9731a03886a7e5713304f6f8ee2c433.zip
oxm xml file wizard
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF3
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java7
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationOperation.java112
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JavaProjectTools.java24
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF1
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/NewJptFileWizardPage.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java)6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml16
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JavaTypeAdapterFactory.java54
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JaxbPackageAdapterFactory.java54
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/plugin.xml21
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core.properties7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/JptJaxbEclipseLinkCoreMessages.java9
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProperties.java26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProvider.java198
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationOperation.java31
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/oxm/OxmXmlResourceProvider.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/AbstractELJaxb_2_1_PlatformDefinition.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_4/ELJaxb_2_4_PlatformDefinition.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/.classpath2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.icobin0 -> 894 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.pngbin0 -> 548 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.icobin0 -> 15902 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.pngbin0 -> 3334 bytes
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.properties5
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.xml49
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/property_files/jpt_jaxb_eclipselink_ui.properties17
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiImages.java28
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiMessages.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileOptionsWizardPage.java84
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileWizard.java299
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/operations/AbstractJpaFileCreationOperation.java102
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/build.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java5
40 files changed, 1133 insertions, 128 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
index 3fd92bfaaa..b05f21fd03 100644
--- a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.jpt.common.core.internal.bun
Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
+Require-Bundle: org.eclipse.core.commands;bundle-version="[3.6.100,4.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java
index 44ea96a541..006ce4be8d 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java
@@ -16,6 +16,8 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.internal.utility.PathTools;
@@ -112,6 +114,11 @@ public abstract class AbstractJptFileCreationDataModelProvider
IContainer container = this.getContainer();
return (container == null) ? null : container.getProject();
}
+
+ protected IJavaProject getJavaProject() {
+ IProject project = getProject();
+ return (project == null) ? null : JavaCore.create(project);
+ }
/**
* Return a best guess source location for the for the specified project
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationOperation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationOperation.java
new file mode 100644
index 0000000000..938d44b048
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationOperation.java
@@ -0,0 +1,112 @@
+package org.eclipse.jpt.common.core.internal.operations;
+
+import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+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.SubMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResourceProvider;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+public abstract class AbstractJptFileCreationOperation
+ extends AbstractDataModelOperation {
+
+ /**
+ * Will be null until container is created or verified to exist
+ */
+ protected IContainer container;
+
+ /**
+ * Will be null until file is created or verified to exist
+ */
+ protected IFile file;
+
+
+ protected AbstractJptFileCreationOperation(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ SubMonitor sm = SubMonitor.convert(monitor, 5);
+ // Create folder if it does not exist
+ createContainer(sm.newChild(1));
+ // Create file
+ createFile(sm.newChild(4));
+ return OK_STATUS;
+ }
+
+ protected IContainer getContainer() throws ExecutionException {
+ IPath containerPath = (IPath) getDataModel().getProperty(CONTAINER_PATH);
+ IContainer container = PathTools.getContainer(containerPath);
+ if (container == null) {
+ throw new ExecutionException("No container path specified"); //$NON-NLS-1$
+ }
+ return container;
+ }
+
+ protected IProject getProject() throws ExecutionException {
+ return getContainer().getProject();
+ }
+
+ /**
+ * This method will create the container as specified in the data model if it does not exist.
+ */
+ protected void createContainer(IProgressMonitor monitor) throws ExecutionException {
+ IContainer container = getContainer();
+ if (! container.exists()) {
+ if (container.getType() == IResource.PROJECT) {
+ throw new ExecutionException("Project does not exist"); //$NON-NLS-1$
+ }
+ else if (container.getType() == IResource.FOLDER) {
+ try {
+ ((IFolder) container).create(true, true, monitor);
+ }
+ catch (CoreException e) {
+ throw new ExecutionException("Could not create folder", e); //$NON-NLS-1$
+ }
+ }
+ else {
+ throw new ExecutionException("Container is not a project or folder"); //$NON-NLS-1$
+ }
+ }
+ this.container = container;
+ }
+
+ protected void createFile(IProgressMonitor monitor) throws ExecutionException {
+ String fileName = getDataModel().getStringProperty(FILE_NAME);
+ IFile newFile = this.container.getFile(new Path(fileName));
+ JptXmlResourceProvider resourceProvider = getXmlResourceProvider(newFile);
+ try {
+ resourceProvider.createFileAndResource(getDataModel(), monitor);
+ }
+ catch (CoreException e) {
+ throw new ExecutionException("Could not create file", e); //$NON-NLS-1$
+ }
+ this.file = newFile;
+ }
+
+ @Override
+ public ISchedulingRule getSchedulingRule() {
+ try {
+ return this.getProject();
+ } catch (ExecutionException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ protected abstract JptXmlResourceProvider getXmlResourceProvider(IFile file);
+}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JavaProjectTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JavaProjectTools.java
index 313f9a05f3..83691eb756 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JavaProjectTools.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JavaProjectTools.java
@@ -24,6 +24,8 @@ import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.predicate.CriterionPredicate;
+import org.eclipse.jpt.common.utility.predicate.Predicate;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
/**
* {@link IJavaProject} convenience methods.
@@ -38,6 +40,28 @@ public final class JavaProjectTools {
return null;
}
}
+
+ /**
+ * Returns an iterable of *existing* {@link IPackageFragment}s for the given project that have
+ * the specified name
+ */
+ public static Iterable<IPackageFragment> getPackageFragments(
+ final IJavaProject javaProject, final String packageName) {
+
+ return IterableTools.filter(
+ IterableTools.transform(
+ getPackageFragmentRoots(javaProject),
+ new Transformer<IPackageFragmentRoot, IPackageFragment>() {
+ public IPackageFragment transform(IPackageFragmentRoot pfr) {
+ return pfr.getPackageFragment(packageName);
+ }
+ }),
+ new Predicate<IPackageFragment>() {
+ public boolean evaluate(IPackageFragment pf) {
+ return pf.exists();
+ }
+ });
+ }
public static Iterable<IPackageFragmentRoot> getSourceFolders(IJavaProject javaProject) {
return IterableTools.filter(
diff --git a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
index 1607c5623d..c7a5c4488f 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
@@ -22,6 +22,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.3.100,4.0.0)",
org.eclipse.ui.views.properties.tabbed;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.200,2.0.0)",
org.eclipse.wst.common.project.facet.ui;bundle-version="[1.3.0,2.0.0)"
Import-Package: com.ibm.icu.text;version="4.0.1"
Dali-Comment: *NO* EclipseLink friends!
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/NewJptFileWizardPage.java
index 858052f718..8f9971e142 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/NewJptFileWizardPage.java
@@ -7,7 +7,7 @@
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.orm;
+package org.eclipse.jpt.common.ui.internal.wizards;
import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*;
import org.eclipse.core.runtime.IPath;
@@ -16,13 +16,13 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-public class MappingFileNewFileWizardPage
+public class NewJptFileWizardPage
extends WizardNewFileCreationPage {
protected IDataModel dataModel;
- public MappingFileNewFileWizardPage(
+ public NewJptFileWizardPage(
String pageName, IStructuredSelection selection, IDataModel dataModel,
String title, String description) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
index 0ec739ab4e..eb604f155d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/plugin.xml
@@ -70,7 +70,21 @@
adaptableType="org.eclipse.jdt.core.IPackageFragment">
<adapter type="org.eclipse.jpt.jaxb.core.context.JaxbPackage"/>
</factory>
-
+
+ <!-- JaxbPackage -> IPackageFragment -->
+ <factory
+ class="org.eclipse.jpt.jaxb.core.internal.context.JaxbPackageAdapterFactory"
+ adaptableType="org.eclipse.jpt.jaxb.core.context.JaxbPackage">
+ <adapter type="org.eclipse.jdt.core.IPackageFragment"/>
+ </factory>
+
+ <!-- JavaType -> IPackageFragment -->
+ <factory
+ class="org.eclipse.jpt.jaxb.core.internal.context.JavaTypeAdapterFactory"
+ adaptableType="org.eclipse.jpt.jaxb.core.context.java.JavaType">
+ <adapter type="org.eclipse.jdt.core.IPackageFragment"/>
+ </factory>
+
<!-- JaxbLibraryProviderInstallOperationConfigAdapterFactory -> JaxbPlatformConfig -->
<factory
class="org.eclipse.jpt.jaxb.core.internal.libprov.JaxbLibraryProviderInstallOperationConfigAdapterFactory"
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JavaTypeAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JavaTypeAdapterFactory.java
new file mode 100644
index 0000000000..2f96505133
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JavaTypeAdapterFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.context;
+
+import java.util.Iterator;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jpt.common.core.internal.utility.JavaProjectTools;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.context.java.JavaType;
+
+public class JavaTypeAdapterFactory
+ implements IAdapterFactory {
+
+ private static final Class<?>[] ADAPTER_LIST = new Class[] { IPackageFragment.class };
+
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof JavaType) {
+ return getAdapter((JavaType) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(JavaType javaType, Class<?> adapterType) {
+ if (adapterType == IPackageFragment.class) {
+ return getPackageFragment(javaType);
+ }
+ return null;
+ }
+
+ private IPackageFragment getPackageFragment(JavaType javaType) {
+ JaxbProject jaxbProject = javaType.getJaxbProject();
+ if (jaxbProject != null) {
+ Iterator<IPackageFragment> packageFragments
+ = JavaProjectTools.getPackageFragments(jaxbProject.getJavaProject(), javaType.getJaxbPackage().getName()).iterator();
+ if (packageFragments.hasNext()) {
+ return packageFragments.next();
+ }
+ }
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JaxbPackageAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JaxbPackageAdapterFactory.java
new file mode 100644
index 0000000000..1db4b1ed2d
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/JaxbPackageAdapterFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.context;
+
+import java.util.Iterator;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jpt.common.core.internal.utility.JavaProjectTools;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+
+public class JaxbPackageAdapterFactory
+ implements IAdapterFactory {
+
+ private static final Class<?>[] ADAPTER_LIST = new Class[] { IPackageFragment.class };
+
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof JaxbPackage) {
+ return getAdapter((JaxbPackage) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(JaxbPackage packageFragment, Class<?> adapterType) {
+ if (adapterType == IPackageFragment.class) {
+ return getPackageFragment(packageFragment);
+ }
+ return null;
+ }
+
+ private IPackageFragment getPackageFragment(JaxbPackage jaxbPackage) {
+ JaxbProject jaxbProject = jaxbPackage.getJaxbProject();
+ if (jaxbProject != null) {
+ Iterator<IPackageFragment> packageFragments
+ = JavaProjectTools.getPackageFragments(jaxbProject.getJavaProject(), jaxbPackage.getName()).iterator();
+ if (packageFragments.hasNext()) {
+ return packageFragments.next();
+ }
+ }
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
index 98786039db..2aed0838a4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.300,4.0.0)",
+Require-Bundle: org.eclipse.core.commands;bundle-version="[3.6.100,4.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.300,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.7.100,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.7.0,4.0.0)",
@@ -23,6 +24,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.300,4.0.0)",
org.eclipse.text;bundle-version="[3.5.200,4.0.0)",
org.eclipse.wst.common.emf;bundle-version="[1.2.100,2.0.0)",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.2.101,2.0.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.200,2.0.0)",
org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)",
org.eclipse.wst.validation;bundle-version="[1.2.300,2.0.0)",
org.eclipse.xsd;bundle-version="[2.8.0,3.0.0)"
@@ -35,6 +37,7 @@ Export-Package: org.eclipse.jpt.jaxb.eclipselink.core,
org.eclipse.jpt.jaxb.eclipselink.core.internal.context.oxm;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.context.xpath.java;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.libval;x-internal:=true,
+ org.eclipse.jpt.jaxb.eclipselink.core.internal.operations,
org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.binary;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.source;x-internal:=true,
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/plugin.xml
index 1f5253957e..1e9d7b7b5b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/plugin.xml
@@ -31,6 +31,27 @@
</extension>
+ <!-- ***** expressions ***** -->
+
+ <extension point="org.eclipse.core.expressions.definitions">
+ <!-- A test for determining whether something adapts to a JaxbPlatformConfig
+ and has an eclipselink platform.
+ Force activation of the wst facet plug-in containing the property tester.
+ Possible usage:
+ <adapt type="org.eclipse.jpt.jaxb.core.platform.JaxbPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jaxb.eclipselink.reference.hasEclipseLinkPlatform"/>
+ </adapt>
+ -->
+ <definition id="org.eclipse.jpt.jaxb.eclipselink.reference.hasEclipseLinkPlatform">
+ <test
+ property="org.eclipse.jpt.jaxb.core.jaxbPlatformGroup"
+ value="eclipselink"
+ forcePluginActivation="true"/>
+ </definition>
+
+ </extension>
+
+
<extension
point="org.eclipse.core.expressions.propertyTesters">
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core.properties
index b85987030b..ccbac0aaef 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/property_files/jpt_jaxb_eclipselink_core.properties
@@ -11,3 +11,10 @@
# JptJaxbEclipseLinkCoreMessages
EL_JAXB_USER_LIBRARY_VALIDATOR__NO_XJC_CLASSES=Class generation may not be available if com.sun.tools.xjc and com.sun.xml.bind jars are not on project classpath.
+
+# OXM file creation validation messages
+VALIDATE__NEW_OXM_FILE__PROJECT_NOT_JAXB = Project does not have the JAXB facet
+VALIDATE__NEW_OXM_FILE__PROJECT_NOT_ECLIPSELINK = Project is not an EclipseLink JAXB project
+VALIDATE__NEW_OXM_FILE__CONTAINER_QUESTIONABLE = File folder may not be acceptable for this project
+VALIDATE__NEW_OXM_FILE__PACKAGE_UNSPECIFIED = No package name specified
+VALIDATE__NEW_OXM_FILE__PACKAGE_DOESNT_EXIST = Package does not exist in this project \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/JptJaxbEclipseLinkCoreMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/JptJaxbEclipseLinkCoreMessages.java
index a965b50433..88f4187022 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/JptJaxbEclipseLinkCoreMessages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/JptJaxbEclipseLinkCoreMessages.java
@@ -23,7 +23,14 @@ public class JptJaxbEclipseLinkCoreMessages {
}
public static String EL_JAXB_USER_LIBRARY_VALIDATOR__NO_XJC_CLASSES;
-
+
+ public static String VALIDATE__NEW_OXM_FILE__PROJECT_NOT_JAXB;
+ public static String VALIDATE__NEW_OXM_FILE__PROJECT_NOT_ECLIPSELINK;
+ public static String VALIDATE__NEW_OXM_FILE__CONTAINER_QUESTIONABLE;
+ public static String VALIDATE__NEW_OXM_FILE__PACKAGE_UNSPECIFIED;
+ public static String VALIDATE__NEW_OXM_FILE__PACKAGE_DOESNT_EXIST;
+
+
private JptJaxbEclipseLinkCoreMessages() {
throw new UnsupportedOperationException();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProperties.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProperties.java
new file mode 100644
index 0000000000..5f2610c858
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProperties.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.core.internal.operations;
+
+import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
+
+public interface OxmFileCreationDataModelProperties
+ extends JptFileCreationDataModelProperties {
+
+ /**
+ * Required, type {@link String}, identifies the version of the file to create
+ */
+ String VERSION = "OxmFileCreationDataModelProperties.VERSION"; //$NON-NLS-1$
+
+ /**
+ * Required, type {@link String}, identifies the package name of the oxm file
+ */
+ String PACKAGE_NAME = "OxmFileCreationDataModelProperties.PACKAGE_NAME"; //$NON-NLS-1$
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProvider.java
new file mode 100644
index 0000000000..3e8595c34e
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationDataModelProvider.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.core.internal.operations;
+
+import java.util.Set;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jpt.common.core.internal.operations.AbstractJptFileCreationDataModelProvider;
+import org.eclipse.jpt.common.core.internal.utility.JavaProjectTools;
+import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
+import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.jaxb.core.JaxbPreferences;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.JaxbProjectManager;
+import org.eclipse.jpt.jaxb.core.JaxbWorkspace;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformManager;
+import org.eclipse.jpt.jaxb.eclipselink.core.JptJaxbEclipseLinkCoreMessages;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.plugin.JptJaxbEclipseLinkCorePlugin;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlBindings;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+
+public class OxmFileCreationDataModelProvider
+ extends AbstractJptFileCreationDataModelProvider
+ implements OxmFileCreationDataModelProperties {
+
+ public OxmFileCreationDataModelProvider() {
+ super();
+ }
+
+
+ @Override
+ public IDataModelOperation getDefaultOperation() {
+ return new OxmFileCreationOperation(getDataModel());
+ }
+
+ @Override
+ public Set<String> getPropertyNames() {
+ Set<String> propertyNames = super.getPropertyNames();
+ propertyNames.add(VERSION);
+ propertyNames.add(PACKAGE_NAME);
+ return propertyNames;
+ }
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(VERSION)) {
+ return getDefaultVersion();
+ }
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ protected String getDefaultFileName() {
+ return "oxm.xml";
+ }
+
+ protected final String getDefaultVersion() {
+ IProject project = this.getProject();
+ if (project == null) {
+ return null;
+ }
+ JaxbProject jaxbProject = getJaxbProject_(project);
+ JaxbPlatformDefinition jaxbPlatformDef = (jaxbProject != null) ? jaxbProject.getPlatform().getDefinition() : getJaxbPlatformDefinition();
+ return jaxbPlatformDef.getMostRecentSupportedResourceType(getContentType()).getVersion();
+ }
+
+ protected String getPackageName() {
+ return getStringProperty(PACKAGE_NAME);
+ }
+
+ protected IContentType getContentType() {
+ return EXmlBindings.CONTENT_TYPE;
+ }
+
+ protected JaxbPlatformDefinition getJaxbPlatformDefinition() {
+ IProject project = getProject();
+ return (project == null) ? null : getJaxbPlatformDefinition(project);
+ }
+
+ protected JaxbPlatformDefinition getJaxbPlatformDefinition(IProject project) {
+ String jaxbPlatformID = JaxbPreferences.getJaxbPlatformID(project);
+ JaxbPlatformManager jaxbPlatformManager = getJaxbPlatformManager();
+ return (jaxbPlatformManager == null) ? null : jaxbPlatformManager.getJaxbPlatformDefinition(jaxbPlatformID);
+ }
+
+ protected JaxbProject getJaxbProject() {
+ return getJaxbProject(getProject());
+ }
+
+ protected JaxbProject getJaxbProject(IProject project) {
+ return (project == null) ? null : getJaxbProject_(project);
+ }
+
+ protected JaxbProject getJaxbProject_(IProject project) {
+ JaxbProjectManager jaxbProjectManager = getJaxbProjectManager();
+ return (jaxbProjectManager == null) ? null : jaxbProjectManager.getJaxbProject(project);
+ }
+
+ protected JaxbPlatformManager getJaxbPlatformManager() {
+ JaxbWorkspace jaxbWorkspace = getJaxbWorkspace();
+ return (jaxbWorkspace == null) ? null : jaxbWorkspace.getJaxbPlatformManager();
+ }
+
+ protected JaxbProjectManager getJaxbProjectManager() {
+ JaxbWorkspace jaxbWorkspace = getJaxbWorkspace();
+ return (jaxbWorkspace == null) ? null : jaxbWorkspace.getJaxbProjectManager();
+ }
+
+ protected JaxbWorkspace getJaxbWorkspace() {
+ return (JaxbWorkspace) ResourcesPlugin.getWorkspace().getAdapter(JaxbWorkspace.class);
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public IStatus validate(String propertyName) {
+ IStatus status = super.validate(propertyName);
+ if (! status.isOK()) {
+ return status;
+ }
+
+ if (propertyName.equals(PACKAGE_NAME)) {
+ status = validatePackageName();
+ }
+ if (! status.isOK()) {
+ return status;
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ protected IStatus validateContainerPathAndFileName() {
+ IStatus status = super.validateContainerPathAndFileName();
+ if (! status.isOK()) {
+ return status;
+ }
+ IContainer container = getContainer();
+ IProject project = container.getProject();
+ if ( ! ProjectTools.hasFacet(project, JaxbProject.FACET)) {
+ return JptJaxbEclipseLinkCorePlugin.instance().buildErrorStatus(JptJaxbEclipseLinkCoreMessages.VALIDATE__NEW_OXM_FILE__PROJECT_NOT_JAXB);
+ }
+ if (! isEclipseLink(project)) {
+ return JptJaxbEclipseLinkCorePlugin.instance().buildErrorStatus(JptJaxbEclipseLinkCoreMessages.VALIDATE__NEW_OXM_FILE__PROJECT_NOT_ECLIPSELINK);
+ }
+ ProjectResourceLocator resourceLocator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class);
+ if ( ! resourceLocator.locationIsValid(container)) {
+ return JptJaxbEclipseLinkCorePlugin.instance().buildWarningStatus(JptJaxbEclipseLinkCoreMessages.VALIDATE__NEW_OXM_FILE__CONTAINER_QUESTIONABLE);
+ }
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus validatePackageName() {
+ String packageName = getPackageName();
+ if (StringTools.isBlank(packageName)) {
+ return JptJaxbEclipseLinkCorePlugin.instance().buildWarningStatus(JptJaxbEclipseLinkCoreMessages.VALIDATE__NEW_OXM_FILE__PACKAGE_UNSPECIFIED);
+ }
+
+ IStatus status = JavaConventions.validatePackageName(packageName, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5);
+ if (! status.isOK()) {
+ return status;
+ }
+
+ IJavaProject javaProject = getJavaProject();
+ if (javaProject != null && IterableTools.isEmpty(JavaProjectTools.getPackageFragments(javaProject, packageName))) {
+ return JptJaxbEclipseLinkCorePlugin.instance().buildWarningStatus(JptJaxbEclipseLinkCoreMessages.VALIDATE__NEW_OXM_FILE__PACKAGE_DOESNT_EXIST);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ protected boolean isEclipseLink(IProject project) {
+ JaxbPlatformDefinition def = getJaxbPlatformDefinition(project);
+ return def != null
+ && ObjectTools.equals(
+ def.getConfig().getGroupConfig(),
+ getJaxbPlatformManager().getJaxbPlatformGroupConfig("eclipselink"));
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationOperation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationOperation.java
new file mode 100644
index 0000000000..13c82a5659
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/operations/OxmFileCreationOperation.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.core.internal.operations;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jpt.common.core.internal.operations.AbstractJptFileCreationOperation;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResourceProvider;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.oxm.OxmXmlResourceProvider;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+public class OxmFileCreationOperation
+ extends AbstractJptFileCreationOperation
+ implements OxmFileCreationDataModelProperties {
+
+ public OxmFileCreationOperation(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+
+ @Override
+ protected JptXmlResourceProvider getXmlResourceProvider(IFile file) {
+ return OxmXmlResourceProvider.getXmlResourceProvider(file);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/oxm/OxmXmlResourceProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/oxm/OxmXmlResourceProvider.java
index 2d83aa72c8..77347a493b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/oxm/OxmXmlResourceProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/resource/oxm/OxmXmlResourceProvider.java
@@ -9,13 +9,15 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.oxm;
+import static org.eclipse.jpt.jaxb.eclipselink.core.internal.operations.OxmFileCreationDataModelProperties.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jpt.common.core.internal.resource.xml.AbstractJptXmlResourceProvider;
+import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlBindings;
-import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.OxmFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
public class OxmXmlResourceProvider
extends AbstractJptXmlResourceProvider {
@@ -48,8 +50,13 @@ public class OxmXmlResourceProvider
@Override
protected void populateRoot(Object config) {
+ IDataModel dataModel = (IDataModel) config;
EXmlBindings xmlBindings = OxmFactory.eINSTANCE.createEXmlBindings();
- xmlBindings.setDocumentVersion(Oxm.SCHEMA_VERSION_2_4); // TODO - for now
+ xmlBindings.setDocumentVersion(dataModel.getStringProperty(VERSION));
+ String packageName = dataModel.getStringProperty(PACKAGE_NAME);
+ if (! StringTools.isBlank(packageName)) {
+ xmlBindings.setPackageName(packageName);
+ }
getResourceContents().add(xmlBindings);
}
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/AbstractELJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/AbstractELJaxb_2_1_PlatformDefinition.java
index 498f6d63d0..7c808f51b1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/AbstractELJaxb_2_1_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/AbstractELJaxb_2_1_PlatformDefinition.java
@@ -31,6 +31,7 @@ import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlValu
import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlInverseReferenceAnnotationDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlPathAnnotationDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.resource.java.XmlPathsAnnotationDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
public abstract class AbstractELJaxb_2_1_PlatformDefinition
@@ -54,9 +55,14 @@ public abstract class AbstractELJaxb_2_1_PlatformDefinition
}
public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
+ if (contentType.equals(Oxm.CONTENT_TYPE)) {
+ return getMostRecentOxmResourceType();
+ }
return getGenericJaxbPlatformDefinition().getMostRecentSupportedResourceType(contentType);
}
+ protected abstract JptResourceType getMostRecentOxmResourceType();
+
@Override
protected AnnotationDefinition[] buildAnnotationDefinitions() {
return ArrayTools.addAll(
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
index b4c4dcad93..cd043e2dd5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_PlatformDefinition.java
@@ -9,8 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1;
+import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jaxb.core.internal.jaxb21.GenericJaxb_2_1_PlatformDefinition;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
public class ELJaxb_2_1_PlatformDefinition
@@ -46,4 +48,9 @@ public class ELJaxb_2_1_PlatformDefinition
protected String getConfigId() {
return ID;
}
+
+ @Override
+ protected JptResourceType getMostRecentOxmResourceType() {
+ return Oxm.RESOURCE_TYPE_2_1;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
index 8626c307af..4af45872cd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_2/ELJaxb_2_2_PlatformDefinition.java
@@ -9,7 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2;
+import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
public class ELJaxb_2_2_PlatformDefinition
@@ -41,4 +43,9 @@ public class ELJaxb_2_2_PlatformDefinition
protected String getConfigId() {
return ID;
}
+
+ @Override
+ protected JptResourceType getMostRecentOxmResourceType() {
+ return Oxm.RESOURCE_TYPE_2_2;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
index 9feba9a15f..ec44174a67 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_3/ELJaxb_2_3_PlatformDefinition.java
@@ -9,8 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_3;
+import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.AbstractELJaxb_2_2_PlatformDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
public class ELJaxb_2_3_PlatformDefinition
@@ -41,4 +43,9 @@ public class ELJaxb_2_3_PlatformDefinition
protected String getConfigId() {
return ID;
}
+
+ @Override
+ protected JptResourceType getMostRecentOxmResourceType() {
+ return Oxm.RESOURCE_TYPE_2_3;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_4/ELJaxb_2_4_PlatformDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_4/ELJaxb_2_4_PlatformDefinition.java
index ca4d6ce811..18884a11da 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_4/ELJaxb_2_4_PlatformDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_4/ELJaxb_2_4_PlatformDefinition.java
@@ -9,8 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_4;
+import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_2.AbstractELJaxb_2_2_PlatformDefinition;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
public class ELJaxb_2_4_PlatformDefinition
@@ -41,4 +43,9 @@ public class ELJaxb_2_4_PlatformDefinition
protected String getConfigId() {
return ID;
}
+
+ @Override
+ protected JptResourceType getMostRecentOxmResourceType() {
+ return Oxm.RESOURCE_TYPE_2_4;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/.classpath b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/.classpath
index 1aba5a72b2..a75e20028d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/.classpath
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="property_files"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<accessrules>
@@ -9,6 +10,7 @@
<accessrule kind="accessible" pattern="org/eclipse/jpt/common/ui/**"/>
<accessrule kind="accessible" pattern="org/eclipse/jpt/common/core/**"/>
<accessrule kind="accessible" pattern="org/eclipse/jpt/common/utility/**"/>
+ <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
</accessrules>
</classpathentry>
<classpathentry kind="output" path="bin"/>
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
index bd7bdab724..24d2edfad6 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/META-INF/MANIFEST.MF
@@ -21,7 +21,10 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.5.2,4.0.0)",
org.eclipse.jpt.jaxb.ui;bundle-version="[1.1.0,2.0.0)",
org.eclipse.swt;bundle-version="[3.7.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.8.0,4.0.0)",
- org.eclipse.ui.workbench;bundle-version="[3.7.0,4.0.0)"
+ org.eclipse.ui.workbench;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.wst.common.frameworks;bundle-version="[1.2.200,2.0.0)",
+ org.eclipse.wst.common.frameworks.ui;bundle-version="[1.2.201,2.0.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.4.300,2.0.0)"
Export-Package: org.eclipse.jpt.jaxb.eclipselink.ui,
org.eclipse.jpt.jaxb.eclipselink.ui.internal;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.ui.internal.commands;x-internal:=true,
@@ -29,4 +32,5 @@ Export-Package: org.eclipse.jpt.jaxb.eclipselink.ui,
org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_1;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_2;x-internal:=true,
org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_3;x-internal:=true,
- org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_4;x-internal:=true
+ org.eclipse.jpt.jaxb.eclipselink.ui.internal.v2_4;x-internal:=true,
+ org.eclipse.jpt.jaxb.eclipselink.ui.internal.wizards.oxm
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.ico b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.ico
new file mode 100644
index 0000000000..d7d29e27b0
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.ico
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.png b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.png
new file mode 100644
index 0000000000..b6fed59484
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/buttons/new-oxm-file.png
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.ico b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.ico
new file mode 100644
index 0000000000..6af820c0b5
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.ico
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.png b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.png
new file mode 100644
index 0000000000..e14a3dfd98
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/images/wizards/oxm-file-banner.png
Binary files differ
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.properties
index affebbc075..4d06021699 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.properties
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.properties
@@ -23,3 +23,8 @@ pluginName= Dali Java Persistence Tools - EclipseLink MOXy Support - UI
providerName=Eclipse Web Tools Platform
addEclipseLinkJaxbPropertyCommand=Add EclipseLink JAXB property
+
+# wizard properties
+eclipseLinkWizardCategoryName=EclipseLink
+newOxmFileWizardName = EclipseLink MOXy OXM File
+newOxmFileWizardDesc = Create an EclipseLink MOXy OXM File
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.xml b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.xml
index 999c14c8de..65206d79f9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.xml
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/plugin.xml
@@ -87,4 +87,53 @@
</extension>
+
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+
+ <commonWizard
+ menuGroupId="org.eclipse.jpt.jaxb.ui.menu.jaxb"
+ type="new"
+ wizardId="org.eclipse.jpt.jaxb.eclipselink.ui.wizard.newOxmFile"
+ associatedExtensionId="org.eclipse.jpt.jaxb.ui.jaxbNavigatorContent">
+ <enablement>
+ <and>
+ <or>
+ <instanceof value="org.eclipse.core.resources.IProject"/>
+ <instanceof value="org.eclipse.core.resources.IFolder"/>
+ <instanceof value="org.eclipse.jdt.core.IPackageFragmentRoot"/>
+ <instanceof value="org.eclipse.jdt.core.IPackageFragment"/>
+ </or>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <reference definitionId="org.eclipse.jpt.jaxb.reference.hasJaxbFacet"/>
+ </adapt>
+ <adapt type="org.eclipse.jpt.jaxb.core.platform.JaxbPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jaxb.eclipselink.reference.hasEclipseLinkPlatform"/>
+ </adapt>
+ </and>
+ </enablement>
+ </commonWizard>
+
+ </extension>
+
+
+ <extension
+ point="org.eclipse.ui.newWizards">
+
+ <category
+ id="org.eclipse.jpt.jaxb.eclipselink"
+ name="%eclipseLinkWizardCategoryName"
+ parentCategory="org.eclipse.jpt.jaxb"/>
+
+ <wizard
+ id="org.eclipse.jpt.jaxb.eclipselink.ui.wizard.newOxmFile"
+ name="%newOxmFileWizardName"
+ icon="$nl$/images/buttons/new-oxm-file.png"
+ class="org.eclipse.jpt.jaxb.eclipselink.ui.internal.wizards.oxm.OxmFileWizard"
+ category="org.eclipse.jpt.jaxb/org.eclipse.jpt.jaxb.eclipselink">
+ <description>%newOxmFileWizardDesc</description>
+ </wizard>
+
+ </extension>
+
</plugin>
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/property_files/jpt_jaxb_eclipselink_ui.properties b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/property_files/jpt_jaxb_eclipselink_ui.properties
new file mode 100644
index 0000000000..259ebfc38d
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/property_files/jpt_jaxb_eclipselink_ui.properties
@@ -0,0 +1,17 @@
+################################################################################
+# Copyright (c) 2010, 2013 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
+################################################################################
+
+# JptJaxbEclipseLinkUiMessages
+OXM_FILE_WIZARD__TITLE = New EclipseLink MOXy OXM File
+OXM_FILE_WIZARD__NEW_FILE_PAGE__TITLE = OXM File
+OXM_FILE_WIZARD__NEW_FILE_PAGE__DESC = Specify OXM file name and location
+OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__TITLE = OXM File
+OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__DESC = Specify OXM file options
+OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__PACKAGE_NAME_LABEL = &Package name: \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiImages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiImages.java
index 5452b695d8..8f4f1a945c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiImages.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiImages.java
@@ -29,30 +29,36 @@ import org.eclipse.jpt.jaxb.eclipselink.ui.internal.plugin.JptJaxbEclipseLinkUiP
// TODO add corresponding ImageDescriptorTest...
@SuppressWarnings("nls")
public final class JptJaxbEclipseLinkUiImages {
-
+
// ********** directories **********
-
+
private static final String OBJECTS_ = JptCommonUiImages.OBJECTS_;
-
-
+ private static final String WIZARDS_ = JptCommonUiImages.WIZARDS_;
+
+
// ********** oxm **********
-
+
public static final ImageDescriptor OXM_FILE = buildImageDescriptor(OBJECTS_ + "oxm-file.gif");
-
+
// ********** mappings **********
-
+
public static final ImageDescriptor XML_INVERSE_REFERENCE = buildImageDescriptor(OBJECTS_ + "xml-inverse-reference.gif");
public static final ImageDescriptor XML_JOIN_NODES = buildImageDescriptor(OBJECTS_ + "xml-join-nodes.gif");
public static final ImageDescriptor XML_TRANSFORMATION = buildImageDescriptor(OBJECTS_ + "xml-transformation.gif");
-
-
+
+
+ // ********** wizard banners **********
+
+ public static final ImageDescriptor OXM_FILE_BANNER = buildImageDescriptor(WIZARDS_ + "oxm-file-banner.png");
+
+
// ********** misc **********
-
+
private static ImageDescriptor buildImageDescriptor(String path) {
return JptJaxbEclipseLinkUiPlugin.instance().buildImageDescriptor(path);
}
-
+
private JptJaxbEclipseLinkUiImages() {
throw new UnsupportedOperationException();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiMessages.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiMessages.java
new file mode 100644
index 0000000000..7d8766e95f
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/JptJaxbEclipseLinkUiMessages.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JptJaxbEclipseLinkUiMessages {
+
+ private static final String BUNDLE_NAME = "jpt_jaxb_eclipselink_ui"; //$NON-NLS-1$
+ private static final Class<?> BUNDLE_CLASS = JptJaxbEclipseLinkUiMessages.class;
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
+ }
+
+
+ public static String OXM_FILE_WIZARD__TITLE;
+ public static String OXM_FILE_WIZARD__NEW_FILE_PAGE__TITLE;
+ public static String OXM_FILE_WIZARD__NEW_FILE_PAGE__DESC;
+ public static String OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__TITLE;
+ public static String OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__DESC;
+ public static String OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__PACKAGE_NAME_LABEL;
+
+
+ private JptJaxbEclipseLinkUiMessages() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileOptionsWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileOptionsWizardPage.java
new file mode 100644
index 0000000000..0801fcf1ee
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileOptionsWizardPage.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.ui.internal.wizards.oxm;
+
+import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*;
+import static org.eclipse.jpt.jaxb.eclipselink.core.internal.operations.OxmFileCreationDataModelProperties.PACKAGE_NAME;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiMessages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+
+public class OxmFileOptionsWizardPage
+ extends DataModelWizardPage {
+
+ private Label packageNameLabel;
+
+ private Text packageNameText;
+
+
+ public OxmFileOptionsWizardPage(
+ String pageName, IDataModel dataModel,
+ String title, String description) {
+
+ super(dataModel, pageName);
+ setTitle(title);
+ setDescription(description);
+ setPageComplete(false);
+ }
+
+
+ @Override
+ protected String[] getValidationPropertyNames() {
+ return new String[] {
+ CONTAINER_PATH,
+ FILE_NAME,
+ PACKAGE_NAME
+ };
+ }
+
+ @Override
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+
+ this.packageNameLabel = new Label(composite, SWT.NONE);
+ this.packageNameLabel.setText(JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__PACKAGE_NAME_LABEL);
+ data = new GridData();
+ this.packageNameLabel.setLayoutData(data);
+
+ this.packageNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+ data.grabExcessHorizontalSpace = true;
+ this.packageNameText.setLayoutData(data);
+ this.synchHelper.synchText(this.packageNameText, PACKAGE_NAME, null);
+
+// new Label(composite, SWT.NONE);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID());
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+}
+
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileWizard.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileWizard.java
new file mode 100644
index 0000000000..fe75d4f0fb
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.ui/src/org/eclipse/jpt/jaxb/eclipselink/ui/internal/wizards/oxm/OxmFileWizard.java
@@ -0,0 +1,299 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.eclipselink.ui.internal.wizards.oxm;
+
+import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.*;
+import java.lang.reflect.InvocationTargetException;
+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.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.Path;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
+import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
+import org.eclipse.jpt.common.ui.internal.wizards.NewJptFileWizardPage;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.operations.OxmFileCreationDataModelProperties;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.operations.OxmFileCreationDataModelProvider;
+import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiImages;
+import org.eclipse.jpt.jaxb.eclipselink.ui.JptJaxbEclipseLinkUiMessages;
+import org.eclipse.jpt.jaxb.eclipselink.ui.internal.plugin.JptJaxbEclipseLinkUiPlugin;
+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.internal.datamodel.IDataModelPausibleOperation;
+import org.eclipse.wst.common.frameworks.internal.dialog.ui.MessageDialog;
+import org.eclipse.wst.common.frameworks.internal.ui.ErrorDialog;
+import org.eclipse.wst.common.frameworks.internal.ui.WTPCommonUIResourceHandler;
+
+public class OxmFileWizard
+ extends Wizard
+ implements INewWizard {
+
+ protected IDataModel config;
+
+ protected IStructuredSelection initialSelection;
+
+ protected IStructuredSelection mungedSelection;
+
+ private IWizardPage firstPage;
+
+ private IWizardPage secondPage;
+
+
+ public OxmFileWizard() {
+ super();
+ this.config = DataModelFactory.createDataModel(new OxmFileCreationDataModelProvider());
+ setWindowTitle(JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__TITLE);
+ setDefaultPageImageDescriptor(JptJaxbEclipseLinkUiImages.OXM_FILE_BANNER);
+ }
+
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.initialSelection = selection;
+ this.mungedSelection = selection;
+
+ if (selection == null || selection.isEmpty()) {
+ return;
+ }
+
+ Object firstSelection = selection.getFirstElement();
+
+ IPackageFragment pkg = extractPackage(firstSelection);
+ IContainer container = extractContainer(pkg, firstSelection);
+
+ while (container != null && ! container.exists()) {
+ container = container.getParent(); // default container sometimes is a non-existent folder
+ }
+ if (container != null) {
+ this.mungedSelection = new StructuredSelection(container);
+ }
+
+ if (pkg != null) {
+ this.config.setProperty(OxmFileCreationDataModelProperties.PACKAGE_NAME, pkg.getElementName());
+ }
+ }
+
+ private IPackageFragment extractPackage(Object selection) {
+ return PlatformTools.getAdapter(selection, IPackageFragment.class);
+ }
+
+ private JaxbProject getJaxbProject(Object selection) {
+ IProject project = getProject(selection);
+ return (project == null) ? null : getJaxbProject(project);
+ }
+
+ private IProject getProject(Object selection) {
+ return PlatformTools.getAdapter(selection, IProject.class);
+ }
+
+ private JaxbProject getJaxbProject(IProject project) {
+ return (JaxbProject) project.getAdapter(JaxbProject.class);
+ }
+
+ private IContainer extractContainer(IPackageFragment pkg, Object selection) {
+ if (pkg != null) {
+ IResource resource = pkg.getResource();
+ if (resource instanceof IContainer) {
+ return (IContainer) resource;
+ }
+ }
+ IResource resource = PlatformTools.getAdapter(selection, IResource.class);
+ if (resource == null) {
+ return null;
+ }
+ if (resource instanceof IProject) {
+ return getDefaultContainer((IProject) selection);
+ }
+ if (resource instanceof IContainer) {
+ return (IContainer) selection;
+ }
+ return resource.getParent();
+ }
+
+ private IContainer getDefaultContainer(IProject project) {
+ if (ProjectTools.hasFacet(project, JaxbProject.FACET)) {
+ ProjectResourceLocator locator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class);
+ return locator.getDefaultLocation();
+ }
+ return project;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ this.firstPage = buildOxmFileNewFileWizardPage();
+ this.secondPage = buildOxmFileOptionsWizardPage();
+ addPage(this.firstPage);
+ addPage(this.secondPage);
+ }
+
+ protected NewJptFileWizardPage buildOxmFileNewFileWizardPage() {
+ return new NewJptFileWizardPage(
+ "Page_1", this.mungedSelection, this.config,
+ JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__NEW_FILE_PAGE__TITLE,
+ JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__NEW_FILE_PAGE__DESC);
+ }
+
+ protected OxmFileOptionsWizardPage buildOxmFileOptionsWizardPage() {
+ return new OxmFileOptionsWizardPage(
+ "Page_2", this.config,
+ JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__TITLE,
+ JptJaxbEclipseLinkUiMessages.OXM_FILE_WIZARD__FILE_OPTIONS_PAGE__DESC);
+ }
+
+ @Override
+ public boolean canFinish() {
+ // override so that visit to second page is not necessary
+ // allow warnings
+ return this.firstPage.isPageComplete() && this.config.validate().getSeverity() != IStatus.ERROR;
+ }
+
+ protected IDataModelPausibleOperation getOperation() {
+ return (IDataModelPausibleOperation) this.config.getDefaultOperation();
+ }
+
+ @Override
+ public boolean performFinish() {
+ createOxmFile();
+ try {
+ postPerformFinish();
+ } catch (Exception e) {
+ JptJaxbEclipseLinkUiPlugin.instance().logError(e);
+ }
+ return true;
+ }
+
+ protected boolean createOxmFile() {
+ try {
+ final IStatus st = runOperations();
+
+ if (st.getSeverity() == IStatus.ERROR) {
+ JptJaxbEclipseLinkUiPlugin.instance().getLog().log(st);
+ Throwable t = st.getException() == null ? new CoreException(st) : st.getException();
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ t, 0, false);
+ }
+ else if(st.getSeverity() == IStatus.WARNING){
+ MessageDialog.openWarning(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_2, new Object[]{getWindowTitle()}),
+ st.getMessage(),
+ st, IStatus.WARNING);
+ }
+ }
+ catch (Exception e) {
+ JptJaxbEclipseLinkUiPlugin.instance().logError(e);
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ e, 0, false);
+ }
+ return true;
+ }
+
+ protected IStatus runOperations() {
+
+ class CatchThrowableRunnableWithProgress
+ implements IRunnableWithProgress {
+
+ public IStatus status = null;
+ public Throwable caught = null;
+
+ public void run(IProgressMonitor pm) {
+ try {
+ status = getOperation().execute(pm, null);
+ }
+ catch (Throwable e) {
+ caught = e;
+ }
+ }
+ }
+
+ CatchThrowableRunnableWithProgress runnable = new CatchThrowableRunnableWithProgress();
+
+ try {
+ getContainer().run(true, false, runnable);
+ }
+ catch (Throwable e) {
+ runnable.caught = e;
+ }
+
+ if (runnable.caught == null) {
+ return runnable.status;
+ }
+
+ JptJaxbEclipseLinkUiPlugin.instance().logError(runnable.caught);
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ runnable.caught, 0, false);
+ return JptJaxbEclipseLinkUiPlugin.instance().buildErrorStatus(runnable.caught);
+ }
+
+ protected void postPerformFinish()
+ throws InvocationTargetException {
+
+ try {
+ IPath containerPath = (IPath) this.config.getProperty(CONTAINER_PATH);
+ String fileName = this.config.getStringProperty(FILE_NAME);
+ IContainer container = PathTools.getContainer(containerPath);
+ IFile file = container.getFile(new Path(fileName));
+ openEditor(file);
+ }
+ catch (Exception cantOpen) {
+ throw new InvocationTargetException(cantOpen);
+ }
+ }
+
+ private void openEditor(final IFile file) {
+ if (file != null) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IDE.openEditor(page, file, true);
+ }
+ catch (PartInitException e) {
+ JptJaxbEclipseLinkUiPlugin.instance().logError(e);
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ this.config.dispose();
+ }
+} \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java
index 92275935dc..385b0d8499 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/schemagen/NewSchemaFileWizardPage.java
@@ -106,7 +106,7 @@ public class NewSchemaFileWizardPage extends WizardNewFileCreationPage {
}
this.overrideFileExistsWarning();
- //TODO move this validation to the dataModel - see MappingFileNewFileWizardPage
+ //TODO move this validation to the dataModel - see NewJptFileWizardPage
// Validate Project
valid = ProjectTools.isJavaProject(this.getProject());
if( ! valid) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/operations/AbstractJpaFileCreationOperation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/operations/AbstractJpaFileCreationOperation.java
index 033b4d91d8..3e1fde232c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/operations/AbstractJpaFileCreationOperation.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/operations/AbstractJpaFileCreationOperation.java
@@ -10,70 +10,20 @@
package org.eclipse.jpt.jpa.core.internal.operations;
-import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.CONTAINER_PATH;
-import static org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties.FILE_NAME;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-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.SubMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.core.internal.utility.PathTools;
-import org.eclipse.jpt.common.core.resource.xml.JptXmlResourceProvider;
+import org.eclipse.jpt.common.core.internal.operations.AbstractJptFileCreationOperation;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
public abstract class AbstractJpaFileCreationOperation
- extends AbstractDataModelOperation
-{
- /**
- * Will be null until container is created or verified to exist
- */
- protected IContainer container;
-
- /**
- * Will be null until file is created or verified to exist
- */
- protected IFile file;
-
+ extends AbstractJptFileCreationOperation {
protected AbstractJpaFileCreationOperation(IDataModel dataModel) {
super(dataModel);
}
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- SubMonitor sm = SubMonitor.convert(monitor, 5);
- // Create folder if it does not exist
- createContainer(sm.newChild(1));
- // Create file
- createFile(sm.newChild(4));
- return OK_STATUS;
- }
-
- protected IContainer getContainer() throws ExecutionException {
- IPath containerPath = (IPath) getDataModel().getProperty(CONTAINER_PATH);
- IContainer container = PathTools.getContainer(containerPath);
- if (container == null) {
- throw new ExecutionException("No container path specified"); //$NON-NLS-1$
- }
- return container;
- }
-
- protected IProject getProject() throws ExecutionException {
- return getContainer().getProject();
- }
-
protected JpaProject getJpaProject() throws ExecutionException {
IProject project = getProject();
JpaProject jpaProject = this.getJpaProject(project);
@@ -100,52 +50,4 @@ public abstract class AbstractJpaFileCreationOperation
protected JpaProject.Reference getJpaProjectReference(IProject project) {
return (JpaProject.Reference) project.getAdapter(JpaProject.Reference.class);
}
-
- /**
- * This method will create the container as specified in the data model if it does not exist.
- */
- protected void createContainer(IProgressMonitor monitor) throws ExecutionException {
- IContainer container = getContainer();
- if (! container.exists()) {
- if (container.getType() == IResource.PROJECT) {
- throw new ExecutionException("Project does not exist"); //$NON-NLS-1$
- }
- else if (container.getType() == IResource.FOLDER) {
- try {
- ((IFolder) container).create(true, true, monitor);
- }
- catch (CoreException e) {
- throw new ExecutionException("Could not create folder", e); //$NON-NLS-1$
- }
- }
- else {
- throw new ExecutionException("Container is not a project or folder"); //$NON-NLS-1$
- }
- }
- this.container = container;
- }
-
- protected void createFile(IProgressMonitor monitor) throws ExecutionException {
- String fileName = getDataModel().getStringProperty(FILE_NAME);
- IFile newFile = this.container.getFile(new Path(fileName));
- JptXmlResourceProvider resourceProvider = getXmlResourceProvider(newFile);
- try {
- resourceProvider.createFileAndResource(getDataModel(), monitor);
- }
- catch (CoreException e) {
- throw new ExecutionException("Could not create file", e); //$NON-NLS-1$
- }
- this.file = newFile;
- }
-
- @Override
- public ISchedulingRule getSchedulingRule() {
- try {
- return this.getProject();
- } catch (ExecutionException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- protected abstract JptXmlResourceProvider getXmlResourceProvider(IFile file);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/build.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/build.properties
index 18a62e43cd..05367cd481 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/build.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/build.properties
@@ -13,6 +13,7 @@ output.. = bin/
bin.includes = .,\
META-INF/,\
about.html,\
+ images/,\
plugin.xml,\
plugin.properties
jars.compile.order = .
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
index 3fba53a282..6d60d7d46c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
@@ -11,9 +11,9 @@ package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.common.ui.internal.wizards.NewJptFileWizardPage;
import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
import org.eclipse.jpt.jpa.eclipselink.ui.JptJpaEclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileNewFileWizardPage;
import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileOptionsWizardPage;
import org.eclipse.jpt.jpa.ui.internal.wizards.orm.MappingFileWizard;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
@@ -38,8 +38,8 @@ public class EclipseLinkMappingFileWizard
@Override
- protected MappingFileNewFileWizardPage buildMappingFileNewFileWizardPage() {
- return new MappingFileNewFileWizardPage(
+ protected NewJptFileWizardPage buildMappingFileNewFileWizardPage() {
+ return new NewJptFileWizardPage(
"Page_1", this.mungedSelection, getDataModel(),
JptJpaEclipseLinkUiMessages.MAPPING_FILE_WIZARD_PAGE_NEW_FILE_TITLE,
JptJpaEclipseLinkUiMessages.MAPPING_FILE_WIZARD_PAGE_NEW_FILE_DESC);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java
index f93efeb2bd..5fb242f354 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/MappingFileWizard.java
@@ -35,6 +35,7 @@ import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.core.internal.utility.ProjectTools;
import org.eclipse.jpt.common.core.internal.utility.PathTools;
import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
+import org.eclipse.jpt.common.ui.internal.wizards.NewJptFileWizardPage;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.JpaContextModel;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
@@ -196,8 +197,8 @@ public class MappingFileWizard extends Wizard
addPage(this.secondPage);
}
- protected MappingFileNewFileWizardPage buildMappingFileNewFileWizardPage() {
- return new MappingFileNewFileWizardPage(
+ protected NewJptFileWizardPage buildMappingFileNewFileWizardPage() {
+ return new NewJptFileWizardPage(
"Page_1", this.mungedSelection, getDataModel(),
JptJpaUiMessages.MappingFileWizardPage_newFile_title,
JptJpaUiMessages.MappingFileWizardPage_newFile_desc);

Back to the top