Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbProject.java32
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbContextRoot.java33
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbPackage.java26
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmFile.java79
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmXmlBindings.java61
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/ELJaxbProjectImpl.java29
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRoot.java60
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRootImpl.java161
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbPackageImpl.java56
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java27
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/EXmlBindings.java10
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/Oxm.java11
12 files changed, 522 insertions, 63 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbProject.java
new file mode 100644
index 0000000000..ec4e8b37fd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/ELJaxbProject.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core;
+
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+
+/**
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface ELJaxbProject
+ extends JaxbProject {
+
+ /**
+ * Return all oxm resource models within the project
+ */
+ Iterable<JptXmlResource> getOxmResources();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbContextRoot.java
new file mode 100644
index 0000000000..465ed9942f
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbContextRoot.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core.context;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmFile;
+
+public interface ELJaxbContextRoot
+ extends JaxbContextRoot {
+
+ // ***** oxm files *****
+
+ static String OXM_FILES_COLLECTION = "oxmFiles"; //$NON-NLS-1$
+
+ /**
+ * The set of oxm files.
+ */
+ Iterable<OxmFile> getOxmFiles();
+
+ int getOxmFilesSize();
+
+ /**
+ * Return the (first) oxm file with the given package name
+ */
+ OxmFile getOxmFile(String packageName);
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbPackage.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbPackage.java
new file mode 100644
index 0000000000..2fc60c13eb
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/ELJaxbPackage.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core.context;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmFile;
+
+public interface ELJaxbPackage
+ extends JaxbPackage {
+
+ static final String OXM_FILE_PROPERTY = "oxmFile"; //$NON-NLS-1$
+
+ /**
+ * The oxm file associated with this package.
+ * This will be the first oxm file encountered that specifies this package.
+ * May be null.
+ */
+ OxmFile getOxmFile();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmFile.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmFile.java
new file mode 100644
index 0000000000..63e057a383
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmFile.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core.context.oxm;
+
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.ELJaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlBindings;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
+
+public class OxmFile
+ extends AbstractJaxbContextNode {
+
+ // never null
+ protected JptXmlResource oxmResource;
+
+ /**
+ * The resource type will only change if the XML file's version changes
+ * (since, if the content type changes, we get garbage-collected).
+ */
+ protected JptResourceType resourceType;
+
+ /**
+ * The root element of the oxm file.
+ */
+ protected OxmXmlBindings xmlBindings;
+
+
+
+ public OxmFile(ELJaxbContextRoot parent, JptXmlResource oxmResource) {
+ super(parent);
+ this.oxmResource = oxmResource;
+ this.resourceType = oxmResource.getResourceType();
+ this.xmlBindings = buildXmlBindings();
+ }
+
+
+ @Override
+ public ELJaxbContextRoot getContextRoot() {
+ return (ELJaxbContextRoot) super.getContextRoot();
+ }
+
+ public JptXmlResource getOxmResource() {
+ return this.oxmResource;
+ }
+
+ public String getPackageName() {
+ return (this.xmlBindings == null) ? null : this.xmlBindings.getPackageName();
+ }
+
+
+ // ***** xml bindings *****
+
+ protected OxmXmlBindings buildXmlBindings() {
+ // if less than 2.3, then there is no context model support
+ if (this.resourceType.isKindOf(Oxm.RESOURCE_TYPE_2_3)) {
+ return new OxmXmlBindings(this, (EXmlBindings) this.oxmResource.getRootObject());
+ }
+ return null;
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange() {
+ return new SimpleTextRange(0, 0, 0); // simple beginning of document
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmXmlBindings.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmXmlBindings.java
new file mode 100644
index 0000000000..5b6aec9410
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/context/oxm/OxmXmlBindings.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core.context.oxm;
+
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.EXmlBindings;
+
+public class OxmXmlBindings
+ extends AbstractJaxbContextNode {
+
+ protected EXmlBindings eXmlBindings;
+
+ public final static String PACKAGE_NAME_PROPERTY = "packageName"; //$NON-NLS-1$
+ protected String packageName;
+
+
+ public OxmXmlBindings(OxmFile parent, EXmlBindings eXmlBindings) {
+ super(parent);
+ this.eXmlBindings = eXmlBindings;
+ this.packageName = buildPackageName();
+ }
+
+
+ // ***** package name *****
+
+ public String getPackageName() {
+ return this.packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.eXmlBindings.setPackageName(packageName);
+ setPackageName_(packageName);
+ }
+
+ protected void setPackageName_(String packageName) {
+ String oldPackageName = this.packageName;
+ this.packageName = packageName;
+ firePropertyChanged(PACKAGE_NAME_PROPERTY, oldPackageName, packageName);
+ }
+
+ protected String buildPackageName() {
+ return this.eXmlBindings.getPackageName();
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange() {
+ TextRange textRange = this.eXmlBindings.getValidationTextRange();
+ return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/ELJaxbProjectImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/ELJaxbProjectImpl.java
new file mode 100644
index 0000000000..77ab2673c5
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/ELJaxbProjectImpl.java
@@ -0,0 +1,29 @@
+package org.eclipse.jpt.jaxb.eclipselink.core.internal;
+
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jpt.jaxb.core.JaxbFile;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbProject;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbProject;
+import org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm.Oxm;
+
+public class ELJaxbProjectImpl
+ extends AbstractJaxbProject
+ implements ELJaxbProject {
+
+ public ELJaxbProjectImpl(JaxbProject.Config config) {
+ super(config);
+ }
+
+
+ public Iterable<JptXmlResource> getOxmResources() {
+ return new TransformationIterable<JaxbFile, JptXmlResource>(
+ getJaxbFiles(Oxm.CONTENT_TYPE)) {
+ @Override
+ protected JptXmlResource transform(JaxbFile o) {
+ return (JptXmlResource) o.getResourceModel();
+ }
+ };
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRoot.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRoot.java
deleted file mode 100644
index b162386a60..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRoot.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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.context;
-
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
-import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextRoot;
-import org.eclipse.jpt.jaxb.core.resource.jaxbprops.JaxbPropertiesResource;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.validation.ELJaxbValidationMessageBuilder;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.validation.ELJaxbValidationMessages;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public class ELJaxbContextRoot
- extends AbstractJaxbContextRoot {
-
-
- public ELJaxbContextRoot(JaxbProject jaxbProject) {
- super(jaxbProject);
- }
-
-
- // **************** validation ********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- validateJaxbProperties(messages, reporter);
- }
-
- protected void validateJaxbProperties(List<IMessage> messages, IReporter reporter) {
- String factoryProp = "javax.xml.bind.context.factory";
- String factoryPropValue = "org.eclipse.persistence.jaxb.JAXBContextFactory";
-
- for (JaxbPackage jp : getPackages()) {
- String pn = jp.getName();
- JaxbPropertiesResource jpr = getJaxbProject().getJaxbPropertiesResource(pn);
- if (jpr != null && StringTools.stringsAreEqual(jpr.getProperty(factoryProp), factoryPropValue)) {
- return;
- }
- }
-
- messages.add(
- ELJaxbValidationMessageBuilder.buildMessage(
- IMessage.HIGH_SEVERITY,
- ELJaxbValidationMessages.PROJECT_MISSING_ECLIPSELINK_JAXB_CONTEXT_FACTORY,
- getJaxbProject()));
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRootImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRootImpl.java
new file mode 100644
index 0000000000..6984c455e8
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbContextRootImpl.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.context;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Vector;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
+import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextRoot;
+import org.eclipse.jpt.jaxb.core.resource.jaxbprops.JaxbPropertiesResource;
+import org.eclipse.jpt.jaxb.eclipselink.core.ELJaxbProject;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.ELJaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmFile;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.validation.ELJaxbValidationMessageBuilder;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.validation.ELJaxbValidationMessages;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+
+public class ELJaxbContextRootImpl
+ extends AbstractJaxbContextRoot
+ implements ELJaxbContextRoot {
+
+ protected List<OxmFile> oxmFiles;
+
+
+ public ELJaxbContextRootImpl(JaxbProject jaxbProject) {
+ super(jaxbProject);
+ }
+
+
+ // ***** overrides *****
+
+ @Override
+ public ELJaxbProject getJaxbProject() {
+ return (ELJaxbProject) super.getJaxbProject();
+ }
+
+ // ***** initialize/update *****
+
+ @Override
+ protected void initialize() {
+
+ // initialize oxm files *first*
+ this.oxmFiles = new Vector<OxmFile>(); // can't do this statically, since this gets called during constructor
+ for (JptXmlResource oxmResource : getJaxbProject().getOxmResources()) {
+ this.oxmFiles.add(buildOxmFile(oxmResource));
+ }
+
+ super.initialize();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ for (OxmFile oxmFile : getOxmFiles()) {
+ oxmFile.synchronizeWithResourceModel();
+ }
+ }
+
+ @Override
+ public void update() {
+
+ // update oxm files *first*
+
+ Collection<JptXmlResource>
+ unmatchedOxmResources = CollectionTools.collection(getJaxbProject().getOxmResources());
+
+ for (OxmFile oxmFile : getOxmFiles()) {
+ JptXmlResource oxmResource = oxmFile.getOxmResource();
+ if (! unmatchedOxmResources.remove(oxmResource)) {
+ removeOxmFile(oxmFile);
+ }
+ }
+
+ for (JptXmlResource oxmResource : unmatchedOxmResources) {
+ addOxmFile(buildOxmFile(oxmResource));
+ }
+
+ super.update();
+ }
+
+
+ // ***** oxm files *****
+
+ public Iterable<OxmFile> getOxmFiles() {
+ return new SnapshotCloneIterable(this.oxmFiles);
+ }
+
+ public int getOxmFilesSize() {
+ return this.oxmFiles.size();
+ }
+
+ protected void addOxmFile(OxmFile oxmFile) {
+ addItemToCollection(oxmFile, this.oxmFiles, OXM_FILES_COLLECTION);
+ }
+
+ protected void removeOxmFile(OxmFile oxmFile) {
+ removeItemFromCollection(oxmFile, this.oxmFiles, OXM_FILES_COLLECTION);
+ }
+
+ public OxmFile getOxmFile(String packageName) {
+ for (OxmFile oxmFile : getOxmFiles()) {
+ if (packageName.equals(oxmFile.getPackageName())) {
+ return oxmFile;
+ }
+ }
+ return null;
+ }
+
+ protected OxmFile buildOxmFile(JptXmlResource oxmResource) {
+ return new OxmFile(this, oxmResource);
+ }
+
+
+ // ***** validation *****
+
+ @Override
+ public TextRange getValidationTextRange() {
+ return TextRange.Empty.instance(); //?
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+
+ validateJaxbProperties(messages, reporter);
+ }
+
+ protected void validateJaxbProperties(List<IMessage> messages, IReporter reporter) {
+ String factoryProp = "javax.xml.bind.context.factory";
+ String factoryPropValue = "org.eclipse.persistence.jaxb.JAXBContextFactory";
+
+ for (JaxbPackage jp : getPackages()) {
+ String pn = jp.getName();
+ JaxbPropertiesResource jpr = getJaxbProject().getJaxbPropertiesResource(pn);
+ if (jpr != null && StringTools.stringsAreEqual(jpr.getProperty(factoryProp), factoryPropValue)) {
+ return;
+ }
+ }
+
+ messages.add(
+ ELJaxbValidationMessageBuilder.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ ELJaxbValidationMessages.PROJECT_MISSING_ECLIPSELINK_JAXB_CONTEXT_FACTORY,
+ getJaxbProject()));
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbPackageImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbPackageImpl.java
new file mode 100644
index 0000000000..23477391e4
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/context/ELJaxbPackageImpl.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jaxb.eclipselink.core.internal.context;
+
+import org.eclipse.jpt.jaxb.core.internal.context.GenericPackage;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.ELJaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.ELJaxbPackage;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.oxm.OxmFile;
+
+public class ELJaxbPackageImpl
+ extends GenericPackage
+ implements ELJaxbPackage {
+
+ protected OxmFile oxmFile;
+
+
+ public ELJaxbPackageImpl(ELJaxbContextRoot parent, String name) {
+ super(parent, name);
+ this.oxmFile = parent.getOxmFile(name);
+ }
+
+
+ @Override
+ public ELJaxbContextRoot getContextRoot() {
+ return (ELJaxbContextRoot) super.getContextRoot();
+ }
+
+
+ // ***** sync/update *****
+
+ @Override
+ public void update() {
+ super.update();
+ setOxmFile(getContextRoot().getOxmFile(getName()));
+ }
+
+
+ // ***** oxm file *****
+
+ public OxmFile getOxmFile() {
+ return this.oxmFile;
+ }
+
+ protected void setOxmFile(OxmFile oxmFile) {
+ OxmFile old = this.oxmFile;
+ this.oxmFile = oxmFile;
+ firePropertyChanged(OXM_FILE_PROPERTY, old, oxmFile);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
index cedaa85079..8a4b2d567a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/internal/v2_1/ELJaxb_2_1_Factory.java
@@ -12,10 +12,12 @@ package org.eclipse.jpt.jaxb.eclipselink.core.internal.v2_1;
import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.JaxbFactory;
import org.eclipse.jpt.jaxb.core.JaxbProject;
+import org.eclipse.jpt.jaxb.core.JaxbProject.Config;
import org.eclipse.jpt.jaxb.core.context.JaxbClass;
import org.eclipse.jpt.jaxb.core.context.JaxbClassMapping;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
import org.eclipse.jpt.jaxb.core.context.JaxbElementFactoryMethod;
+import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentAttribute;
import org.eclipse.jpt.jaxb.core.context.XmlAnyAttributeMapping;
import org.eclipse.jpt.jaxb.core.context.XmlAnyElementMapping;
@@ -27,7 +29,10 @@ import org.eclipse.jpt.jaxb.core.context.XmlElementsMapping;
import org.eclipse.jpt.jaxb.core.context.XmlRegistry;
import org.eclipse.jpt.jaxb.core.context.XmlValueMapping;
import org.eclipse.jpt.jaxb.core.internal.AbstractJaxbFactory;
-import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.ELJaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.context.ELJaxbContextRoot;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.ELJaxbProjectImpl;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.ELJaxbContextRootImpl;
+import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.ELJaxbPackageImpl;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaClassMapping;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaElementFactoryMethod;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.context.java.ELJavaXmlAnyAttributeMapping;
@@ -63,12 +68,30 @@ public class ELJaxb_2_1_Factory
}
+ // ***** core model *****
+
+ @Override
+ public JaxbProject buildJaxbProject(Config config) {
+ return new ELJaxbProjectImpl(config);
+ }
+
+
+ // ***** non-resource context nodes *****
+
@Override
public JaxbContextRoot buildContextRoot(JaxbProject parent) {
- return new ELJaxbContextRoot(parent);
+ return new ELJaxbContextRootImpl(parent);
}
@Override
+ public JaxbPackage buildPackage(JaxbContextRoot parent, String packageName) {
+ return new ELJaxbPackageImpl((ELJaxbContextRoot) parent, packageName);
+ }
+
+
+ // ***** java context nodes *****
+
+ @Override
public JaxbElementFactoryMethod buildJavaElementFactoryMethod(
XmlRegistry parent, JavaResourceMethod resourceMethod) {
return new ELJavaElementFactoryMethod(parent, resourceMethod);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/EXmlBindings.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/EXmlBindings.java
index ff5656d803..7332df9234 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/EXmlBindings.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/EXmlBindings.java
@@ -993,13 +993,21 @@ public class EXmlBindings extends ERootObjectImpl
return new SimpleRootTranslator(Oxm.XML_BINDINGS, OxmPackage.eINSTANCE.getEXmlBindings(), buildTranslatorChildren());
}
- private static Translator[] buildTranslatorChildren() {
+ protected static Translator[] buildTranslatorChildren() {
return new Translator[] {
buildVersionTranslator(SCHEMA_LOCATIONS),
buildNamespaceTranslator(Oxm.SCHEMA_NAMESPACE),
buildSchemaNamespaceTranslator(),
buildSchemaLocationTranslator(Oxm.SCHEMA_NAMESPACE, SCHEMA_LOCATIONS),
+ buildPackageNameTranslator(),
EJavaType.buildTranslator()
};
}
+
+ protected static Translator buildPackageNameTranslator() {
+ return new Translator(
+ Oxm.PACKAGE_NAME,
+ OxmPackage.eINSTANCE.getEXmlBindings_PackageName(),
+ Translator.DOM_ATTRIBUTE);
+ }
} \ No newline at end of file
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/Oxm.java b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/Oxm.java
index ee07532241..f5f73c48b5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/Oxm.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.eclipselink.core/src/org/eclipse/jpt/jaxb/eclipselink/core/resource/oxm/Oxm.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.jaxb.eclipselink.core.resource.oxm;
import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.jaxb.eclipselink.core.internal.plugin.JptJaxbEclipseLinkCorePlugin;
public interface Oxm {
@@ -21,20 +23,29 @@ public interface Oxm {
String SCHEMA_VERSION_2_1 = "2.1";
String SCHEMA_LOCATION_2_1 = "http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_1.xsd";
+ JptResourceType RESOURCE_TYPE_2_1 = PlatformTools.getResourceType(CONTENT_TYPE, SCHEMA_VERSION_2_1);
+
String SCHEMA_VERSION_2_2 = "2.2";
String SCHEMA_LOCATION_2_2 = "http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_2.xsd";
+ JptResourceType RESOURCE_TYPE_2_2 = PlatformTools.getResourceType(CONTENT_TYPE, SCHEMA_VERSION_2_2);
+
String SCHEMA_VERSION_2_3 = "2.3";
String SCHEMA_LOCATION_2_3 = "http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_3.xsd";
+ JptResourceType RESOURCE_TYPE_2_3 = PlatformTools.getResourceType(CONTENT_TYPE, SCHEMA_VERSION_2_3);
+
String SCHEMA_VERSION_2_4 = "2.4";
String SCHEMA_LOCATION_2_4 = "http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_4.xsd";
+ JptResourceType RESOURCE_TYPE_2_4 = PlatformTools.getResourceType(CONTENT_TYPE, SCHEMA_VERSION_2_4);
+
// Oxm specific nodes
String JAVA_ATTRIBUTES = "java-attributes"; //$NON-NLS-1$
String JAVA_TYPE = "java-type"; //$NON-NLS-1$
String JAVA_TYPES = "java-types"; //$NON-NLS-1$
+ String PACKAGE_NAME = "package-name"; //$NON-NLS-1$
String XML_ANY_ATTRIBUTE = "xml-any-attribute"; //$NON-NLS-1$
String XML_ANY_ELEMENT = "xml-any-element"; //$NON-NLS-1$
String XML_ATTRIBUTE = "xml-attribute"; //$NON-NLS-1$

Back to the top