Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2012-02-10 20:49:25 +0000
committerbvosburgh2012-02-10 20:49:25 +0000
commit4716e39927cfe910fa7424870986a195d608b51f (patch)
tree800ca22e27d3d87fbd1f64968ca69efa5ceba413 /jaxb/plugins/org.eclipse.jpt.jaxb.core/src
parent52f37be9bfbf1b7c0d451e99d938725ac497eed0 (diff)
downloadwebtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.gz
webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.tar.xz
webtools.dali-4716e39927cfe910fa7424870986a195d608b51f.zip
rework JpaProjectManager
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java45
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java31
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java46
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JaxbPlatformTester.java63
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/ResourceAdapterFactory.java51
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libprov/JaxbLibraryProviderInstallOperationConfigAdapterFactory.java46
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformTester.java54
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/AbstractJaxbFileResourceModel.java129
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbindex/JaxbIndexResourceImpl.java174
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbprops/JaxbPropertiesResourceImpl.java100
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidator.java11
14 files changed, 473 insertions, 305 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
index 61f6cd5f40..d8fbf291a5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/GenericJaxbProjectManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -33,14 +33,15 @@ import org.eclipse.jdt.core.IElementChangedListener;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.utility.CallbackJobSynchronizer;
-import org.eclipse.jpt.common.core.internal.utility.JobCommand;
import org.eclipse.jpt.common.core.internal.utility.JobSynchronizer;
-import org.eclipse.jpt.common.utility.Command;
-import org.eclipse.jpt.common.utility.internal.AsynchronousCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.SimpleCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StatefulCommandExecutor;
+import org.eclipse.jpt.common.core.utility.command.JobCommand;
+import org.eclipse.jpt.common.utility.ExceptionHandler;
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
+import org.eclipse.jpt.common.utility.internal.command.AsynchronousExtendedCommandExecutor;
+import org.eclipse.jpt.common.utility.internal.command.SimpleStatefulExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
import org.eclipse.jpt.common.utility.synchronizers.CallbackSynchronizer;
@@ -139,7 +140,23 @@ class GenericJaxbProjectManager
* Determine how Resource and Java change events are
* handled (i.e. synchronously or asynchronously).
*/
- private volatile StatefulCommandExecutor eventHandler = new AsynchronousCommandExecutor(JptCommonCoreMessages.DALI_EVENT_HANDLER_THREAD_NAME);
+ private volatile StatefulCommandExecutor eventHandler =
+ new AsynchronousExtendedCommandExecutor(
+ JptCommonCoreMessages.DALI_EVENT_HANDLER_THREAD_NAME,
+ new LocalExceptionHandler()
+ );
+
+ /* CU private */ class LocalExceptionHandler
+ implements ExceptionHandler
+ {
+ public void handleException(Throwable t) {
+ JptJaxbCorePlugin.log(t);
+ }
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+ }
/**
* Listen for<ul>
@@ -263,7 +280,11 @@ class GenericJaxbProjectManager
JavaCore.removeElementChangedListener(this.javaElementChangeListener);
FacetedProjectFramework.removeListener(this.facetedProjectListener);
this.getWorkspace().removeResourceChangeListener(this.resourceChangeListener);
- this.eventHandler.stop();
+ try {
+ this.eventHandler.stop();
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
this.clearJaxbProjects();
}
@@ -673,9 +694,9 @@ class GenericJaxbProjectManager
/**
* This method is called (via reflection) when the test plug-in is loaded.
- * @see JptCoreTestsPlugin#start(BundleContext)
+ * @see JptJaxbCoreTestsPlugin#start(BundleContext)
*/
- public void handleEventsSynchronously() {
+ public void handleEventsSynchronously() throws InterruptedException {
try {
this.lock.acquire();
this.handleEventsSynchronously_();
@@ -684,9 +705,9 @@ class GenericJaxbProjectManager
}
}
- private void handleEventsSynchronously_() {
+ private void handleEventsSynchronously_() throws InterruptedException {
this.eventHandler.stop();
- this.eventHandler = new SimpleCommandExecutor();
+ this.eventHandler = new SimpleStatefulExtendedCommandExecutor();
this.eventHandler.start();
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
index a4eb6c5099..92a7831390 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,7 +10,7 @@
package org.eclipse.jpt.jaxb.core;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jpt.common.core.IResourcePart;
+import org.eclipse.jpt.common.core.ResourceReference;
import org.eclipse.jpt.common.utility.model.Model;
/**
@@ -27,7 +27,7 @@ import org.eclipse.jpt.common.utility.model.Model;
* @since 3.0
*/
public interface JaxbNode
- extends Model, IAdaptable, IResourcePart
+ extends Model, IAdaptable, ResourceReference
{
/**
* Return the JAXB project the node belongs to.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
index ca7799c966..df8afc4081 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,7 +19,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-import org.eclipse.jpt.common.utility.CommandExecutor;
+import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.synchronizers.CallbackSynchronizer;
import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
import org.eclipse.jpt.jaxb.core.context.JaxbContextRoot;
@@ -367,20 +367,20 @@ public interface JaxbProject
// ********** modifying shared documents **********
/**
- * Set a thread-specific implementation of the {@link CommandExecutor}
+ * Set a thread-specific implementation of the {@link ExtendedCommandExecutor}
* interface that will be used to execute a command to modify a shared
* document. If necessary, the command executor can be cleared by
* setting it to null.
* This allows background clients to modify documents that are
- * already present in the UI. See implementations of {@link CommandExecutor}.
+ * already present in the UI. See implementations of {@link ExtendedCommandExecutor}.
*/
- void setThreadLocalModifySharedDocumentCommandExecutor(CommandExecutor commandExecutor);
+ void setThreadLocalModifySharedDocumentCommandExecutor(ExtendedCommandExecutor commandExecutor);
/**
* Return the project-wide implementation of the
- * {@link CommandExecutor} interface.
+ * {@link ExtendedCommandExecutor} interface.
*/
- CommandExecutor getModifySharedDocumentCommandExecutor();
+ ExtendedCommandExecutor getModifySharedDocumentCommandExecutor();
// ********** construction config **********
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
index b1e56f477e..8357f5f173 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -16,7 +16,7 @@ import java.util.Set;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.core.internal.utility.jdt.JDTModifiedDeclaration.Adapter;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.Tools;
@@ -91,9 +91,9 @@ public abstract class AbstractJaxbNode
// ********** IAdaptable implementation **********
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
+ return PlatformTools.getAdapter(this, adapter);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
index 92e72ced1c..686bbb11b3 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -38,17 +38,17 @@ import org.eclipse.jpt.common.core.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.JptResourceModel;
import org.eclipse.jpt.common.core.JptResourceModelListener;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.jpt.common.core.resource.ResourceLocator;
+import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageInfoCompilationUnit;
-import org.eclipse.jpt.common.utility.Command;
-import org.eclipse.jpt.common.utility.CommandExecutor;
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.internal.BitTools;
import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.ThreadLocalCommandExecutor;
+import org.eclipse.jpt.common.utility.internal.command.ThreadLocalExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
@@ -182,7 +182,7 @@ public abstract class AbstractJaxbProject
/**
* Support for modifying documents shared with the UI.
*/
- protected final ThreadLocalCommandExecutor modifySharedDocumentCommandExecutor;
+ protected final ThreadLocalExtendedCommandExecutor modifySharedDocumentCommandExecutor;
// ********** constructor/initialization **********
@@ -230,8 +230,8 @@ public abstract class AbstractJaxbProject
return this.project;
}
- protected ThreadLocalCommandExecutor buildModifySharedDocumentCommandExecutor() {
- return new ThreadLocalCommandExecutor();
+ protected ThreadLocalExtendedCommandExecutor buildModifySharedDocumentCommandExecutor() {
+ return new ThreadLocalExtendedCommandExecutor();
}
protected InitialResourceProxyVisitor buildInitialResourceProxyVisitor() {
@@ -390,7 +390,7 @@ public abstract class AbstractJaxbProject
return null;
}
}
- else if (! isInAcceptableResourceLocation(file)) {
+ else if (! fileResourceLocationIsValid(file)) {
return null;
}
@@ -420,9 +420,12 @@ public abstract class AbstractJaxbProject
}
/* (non-java resource) file is in acceptable resource location */
- protected boolean isInAcceptableResourceLocation(IFile file) {
- ResourceLocator resourceLocator = JptCommonCorePlugin.getResourceLocator(getProject());
- return resourceLocator.acceptResourceLocation(getProject(), file.getParent());
+ protected boolean fileResourceLocationIsValid(IFile file) {
+ return this.getProjectResourceLocator().resourceLocationIsValid(file.getParent());
+ }
+
+ protected ProjectResourceLocator getProjectResourceLocator() {
+ return (ProjectResourceLocator) this.project.getAdapter(ProjectResourceLocator.class);
}
/**
@@ -1465,11 +1468,11 @@ public abstract class AbstractJaxbProject
// ********** support for modifying documents shared with the UI **********
- public void setThreadLocalModifySharedDocumentCommandExecutor(CommandExecutor commandExecutor) {
+ public void setThreadLocalModifySharedDocumentCommandExecutor(ExtendedCommandExecutor commandExecutor) {
this.modifySharedDocumentCommandExecutor.set(commandExecutor);
}
- public CommandExecutor getModifySharedDocumentCommandExecutor() {
+ public ExtendedCommandExecutor getModifySharedDocumentCommandExecutor() {
return this.modifySharedDocumentCommandExecutor;
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java
new file mode 100644
index 0000000000..df776cf336
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.core.internal;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+
+/**
+ * Factory to build Dali adapters for an {@link IJavaElement}:<ul>
+ * <li>{@link JaxbPlatformDescription}
+ * </ul>
+ * See <code>org.eclipse.jpt.jaxb.core/plugin.xml</code>.
+ */
+public class JavaElementAdapterFactory
+ implements IAdapterFactory
+{
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {
+ JaxbPlatformDescription.class
+ };
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof IJavaElement) {
+ return this.getAdapter((IJavaElement) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(IJavaElement javaElement, Class<?> adapterType) {
+ if (adapterType == JaxbPlatformDescription.class) {
+ return javaElement.getResource().getAdapter(JaxbPlatformDescription.class);
+ }
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JaxbPlatformTester.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JaxbPlatformTester.java
deleted file mode 100644
index 6cd7bda963..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JaxbPlatformTester.java
+++ /dev/null
@@ -1,63 +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.core.internal;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
-import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
-import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformGroupDescription;
-
-
-public class JaxbPlatformTester
- extends PropertyTester {
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (! (property.equals("jaxbPlatform") || property.equals("jaxbPlatformGroup"))
- || ! (expectedValue instanceof String)) { //$NON-NLS-1$
- return false;
- }
-
- JaxbPlatformDescription platform = null;
-
- if (receiver instanceof IResource) {
- platform = platform(((IResource) receiver).getProject());
- }
- else if (receiver instanceof IJavaElement) {
- platform = platform(((IJavaElement) receiver).getResource().getProject());
- }
- else if (receiver instanceof JaxbPlatformDescription) {
- platform = (JaxbPlatformDescription) receiver;
- }
- else if (receiver instanceof JaxbLibraryProviderInstallOperationConfig) {
- platform = ((JaxbLibraryProviderInstallOperationConfig) receiver).getJaxbPlatform();
- }
-
- if (property.equals("jaxbPlatform")) {
- JaxbPlatformDescription otherPlatform = JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatform((String) expectedValue);
- return platform == null ? false : platform.equals(otherPlatform);
- }
- if (property.equals("jaxbPlatformGroup")) {
- JaxbPlatformGroupDescription group = (platform == null) ? null : platform.getGroup();
- JaxbPlatformGroupDescription otherGroup = JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatformGroup((String) expectedValue);
- return group == null ? false : group.equals(otherGroup);
- }
- return false;
- }
-
- private JaxbPlatformDescription platform(IProject project) {
- return (project == null)
- ? null
- : JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatform(JptJaxbCorePlugin.getJaxbPlatformId(project));
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/ResourceAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/ResourceAdapterFactory.java
new file mode 100644
index 0000000000..85857f5824
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/ResourceAdapterFactory.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.core.internal;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+
+/**
+ * Factory to build Dali adapters for an {@link IResource}:<ul>
+ * <li>{@link JaxbPlatformDescription}
+ * </ul>
+ * See <code>org.eclipse.jpt.jaxb.core/plugin.xml</code>.
+ */
+public class ResourceAdapterFactory
+ implements IAdapterFactory
+{
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {
+ JaxbPlatformDescription.class
+ };
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof IResource) {
+ return this.getAdapter((IResource) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(IResource resource, Class<?> adapterType) {
+ if (adapterType == JaxbPlatformDescription.class) {
+ return this.getJaxbPlatformDescription(resource);
+ }
+ return null;
+ }
+
+ private JaxbPlatformDescription getJaxbPlatformDescription(IResource resource) {
+ return JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatform(JptJaxbCorePlugin.getJaxbPlatformId(resource.getProject()));
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libprov/JaxbLibraryProviderInstallOperationConfigAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libprov/JaxbLibraryProviderInstallOperationConfigAdapterFactory.java
new file mode 100644
index 0000000000..0fede72a1b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/libprov/JaxbLibraryProviderInstallOperationConfigAdapterFactory.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.core.internal.libprov;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jpt.jaxb.core.libprov.JaxbLibraryProviderInstallOperationConfig;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+
+/**
+ * Factory to build Dali adapters for an {@link JaxbLibraryProviderInstallOperationConfig}:<ul>
+ * <li>{@link JaxbPlatformDescription}
+ * </ul>
+ * See <code>org.eclipse.jpt.jaxb.core/plugin.xml</code>.
+ */
+public class JaxbLibraryProviderInstallOperationConfigAdapterFactory
+ implements IAdapterFactory
+{
+ private static final Class<?>[] ADAPTER_LIST = new Class[] {
+ JaxbPlatformDescription.class
+ };
+
+ public Class<?>[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
+ if (adaptableObject instanceof JaxbLibraryProviderInstallOperationConfig) {
+ return this.getAdapter((JaxbLibraryProviderInstallOperationConfig) adaptableObject, adapterType);
+ }
+ return null;
+ }
+
+ private Object getAdapter(JaxbLibraryProviderInstallOperationConfig config, Class<?> adapterType) {
+ if (adapterType == JaxbPlatformDescription.class) {
+ return config.getJaxbPlatform();
+ }
+ return null;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformTester.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformTester.java
new file mode 100644
index 0000000000..599dc4e1ac
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/platform/JaxbPlatformTester.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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.core.internal.platform;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jpt.common.utility.internal.Tools;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
+import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformGroupDescription;
+
+/**
+ * Property tester for {@link JaxbPlatformDescription}.
+ * See <code>org.eclipse.jpt.jaxb.core/plugin.xml</code>
+ */
+public class JaxbPlatformTester
+ extends PropertyTester
+{
+ public static final String JAXB_PLATFORM = "jaxbPlatform"; //$NON-NLS-1$
+ public static final String JAXB_PLATFORM_GROUP = "jaxbPlatformGroup"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof JaxbPlatformDescription) {
+ return this.test((JaxbPlatformDescription) receiver, property, expectedValue);
+ }
+ return false;
+ }
+
+ private boolean test(JaxbPlatformDescription platform, String property, Object expectedValue) {
+ if (property.equals(JAXB_PLATFORM)) {
+ JaxbPlatformDescription expected = this.getJaxbPlatform(expectedValue);
+ return Tools.valuesAreEqual(platform, expected);
+ }
+ if (property.equals(JAXB_PLATFORM_GROUP)) {
+ JaxbPlatformGroupDescription expected = this.getJaxbPlatformGroup(expectedValue);
+ return Tools.valuesAreEqual(platform.getGroup(), expected);
+ }
+ return false;
+ }
+
+ private JaxbPlatformDescription getJaxbPlatform(Object id) {
+ return JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatform((String) id);
+ }
+
+ private JaxbPlatformGroupDescription getJaxbPlatformGroup(Object id) {
+ return JptJaxbCorePlugin.getJaxbPlatformManager().getJaxbPlatformGroup((String) id);
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/AbstractJaxbFileResourceModel.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/AbstractJaxbFileResourceModel.java
new file mode 100644
index 0000000000..82237263e9
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/AbstractJaxbFileResourceModel.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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.core.internal.resource;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jpt.common.core.JptResourceModel;
+import org.eclipse.jpt.common.core.JptResourceModelListener;
+import org.eclipse.jpt.common.utility.internal.ListenerList;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+
+public abstract class AbstractJaxbFileResourceModel<S>
+ implements JptResourceModel
+{
+ protected final IFile file;
+
+ /**
+ * This is <code>null</code> if there is no package name.
+ */
+ protected final String packageName;
+
+ protected final S state;
+
+ protected final ListenerList<JptResourceModelListener> resourceModelListenerList =
+ new ListenerList<JptResourceModelListener>(JptResourceModelListener.class);
+
+
+ protected AbstractJaxbFileResourceModel(IFile file) {
+ super();
+ if (file == null) {
+ throw new NullPointerException();
+ }
+ this.file = file;
+ this.packageName = this.buildPackageName();
+ this.state = this.buildState();
+ this.load();
+ }
+
+ protected String buildPackageName() {
+ String pkg = this.buildPackageName_();
+ return StringTools.stringIsEmpty(pkg) ? null : pkg;
+ }
+
+ protected String buildPackageName_() {
+ IJavaElement javaElement = JavaCore.create(this.file.getParent());
+ if ((javaElement != null) && (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT)) {
+ return ((IPackageFragment) javaElement).getElementName();
+ }
+ return null;
+ }
+
+ protected abstract S buildState();
+
+ public String getPackageName() {
+ return this.packageName;
+ }
+
+ protected void reload() {
+ this.load();
+ }
+
+ protected void load() {
+ InputStream stream = null;
+ try {
+ stream = this.file.getContents();
+ if (stream != null) {
+ this.load(new BufferedInputStream(stream));
+ }
+ } catch (Exception ex) {
+ JptJaxbCorePlugin.log(ex);
+ } finally {
+ this.closeStream(stream);
+ }
+ }
+
+ /**
+ * The specified stream is not <code>null</code>.
+ */
+ protected abstract void load(InputStream stream) throws IOException;
+
+ protected void closeStream(InputStream stream) {
+ try {
+ if (stream != null) {
+ stream.close();
+ }
+ } catch (IOException ex) {
+ JptJaxbCorePlugin.log(ex);
+ }
+ }
+
+ public void update() {
+ this.reload();
+ this.resourceModelChanged();
+ }
+
+
+ // ********** JptResourceModel implementation **********
+
+ public IFile getFile() {
+ return this.file;
+ }
+
+ public void addResourceModelListener(JptResourceModelListener listener) {
+ this.resourceModelListenerList.add(listener);
+ }
+
+ public void removeResourceModelListener(JptResourceModelListener listener) {
+ this.resourceModelListenerList.remove(listener);
+ }
+
+ protected void resourceModelChanged() {
+ for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
+ listener.resourceModelChanged(this);
+ }
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbindex/JaxbIndexResourceImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbindex/JaxbIndexResourceImpl.java
index a1d1335731..4e17fb10e4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbindex/JaxbIndexResourceImpl.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbindex/JaxbIndexResourceImpl.java
@@ -1,11 +1,11 @@
/*******************************************************************************
- * 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
+ * Copyright (c) 2011, 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.core.internal.resource.jaxbindex;
@@ -13,131 +13,79 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.List;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.common.core.JptResourceModelListener;
import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.Transformer;
import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.resource.AbstractJaxbFileResourceModel;
import org.eclipse.jpt.jaxb.core.resource.jaxbindex.JaxbIndexResource;
-
+/**
+ * JAXB index
+ */
public class JaxbIndexResourceImpl
- implements JaxbIndexResource {
-
- protected final ListenerList<JptResourceModelListener> resourceModelListenerList =
- new ListenerList<JptResourceModelListener>(JptResourceModelListener.class);
-
-
- protected IFile file;
-
- protected String packageName;
-
- protected final List<String> classNames = new Vector<String>();
-
-
+ extends AbstractJaxbFileResourceModel<Vector<String>>
+ implements JaxbIndexResource
+{
public JaxbIndexResourceImpl(IFile file) {
- super();
- if (file == null) {
- throw new IllegalArgumentException("file cannot be null");
- }
- this.file = file;
- this.packageName = buildPackageName();
- buildClassNames();
+ super(file);
}
-
-
- protected String buildPackageName() {
- IJavaElement javaElement = JavaCore.create(this.file.getParent());
- if (javaElement != null && javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
- return ((IPackageFragment) javaElement).getElementName();
- }
- return null;
+
+ @Override
+ protected Vector<String> buildState() {
+ return new Vector<String>();
}
-
- private void buildClassNames() {
- InputStream stream = null;
-
- try {
- stream = file.getContents();
- }
- catch (CoreException ce) {
- JptJaxbCorePlugin.log(ce);
- return;
- }
-
- if (stream != null) {
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- try {
- String line = reader.readLine();
- while (line != null) {
- String className = line.trim();
- this.classNames.add(className);
- line = reader.readLine();
- }
- }
- catch (Exception ex) {
- JptJaxbCorePlugin.log(ex);
- }
- finally {
- try {
- reader.close();
- }
- catch (IOException ioe) {
- JptJaxbCorePlugin.log(ioe);
- }
- }
- }
+
+ @Override
+ protected void reload() {
+ this.state.clear();
+ super.reload();
}
-
- public String getPackageName() {
- return this.packageName;
+
+ @Override
+ protected void load(InputStream stream) throws IOException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ String line = reader.readLine();
+ while (line != null) {
+ this.state.add(line.trim());
+ line = reader.readLine();
+ }
}
-
+
public Iterable<String> getFullyQualifiedClassNames() {
- String packageName = getPackageName();
- final String packagePrefix = StringTools.stringIsEmpty(packageName) ? "" : packageName + ".";
+ return (this.packageName == null) ?
+ this.getSimpleClassNames() :
+ this.getPrefixedClassNames();
+ }
+
+ protected Iterable<String> getSimpleClassNames() {
+ return new SnapshotCloneIterable<String>(this.state);
+ }
+
+ protected Iterable<String> getPrefixedClassNames() {
return new TransformationIterable<String, String>(
- new SnapshotCloneIterable<String>(this.classNames)) {
- @Override
- protected String transform(String shortClassName) {
- return packagePrefix + shortClassName;
- }
- };
+ this.getSimpleClassNames(),
+ new PrefixTransformer(this.packageName + '.')
+ );
}
-
- void update() {
- this.classNames.clear();
- buildClassNames();
- resourceModelChanged();
+
+ protected class PrefixTransformer
+ implements Transformer<String, String>
+ {
+ protected final String prefix;
+ protected PrefixTransformer(String prefix) {
+ super();
+ this.prefix = prefix;
+ }
+ public String transform(String string) {
+ return this.prefix + string;
+ }
}
-
-
- // ********** JptResourceModel implementation **********
-
+
public JptResourceType getResourceType() {
return JptJaxbCorePlugin.JAXB_INDEX_RESOURCE_TYPE;
}
-
- public void addResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.add(listener);
- }
-
- public void removeResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.remove(listener);
- }
-
- protected void resourceModelChanged() {
- for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
- listener.resourceModelChanged(this);
- }
- }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbprops/JaxbPropertiesResourceImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbprops/JaxbPropertiesResourceImpl.java
index 67a308902b..be6842c4aa 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbprops/JaxbPropertiesResourceImpl.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/jaxbprops/JaxbPropertiesResourceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011, 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.
@@ -13,107 +13,43 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.common.core.JptResourceModelListener;
import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
+import org.eclipse.jpt.jaxb.core.internal.resource.AbstractJaxbFileResourceModel;
import org.eclipse.jpt.jaxb.core.resource.jaxbprops.JaxbPropertiesResource;
-
+/**
+ * JAXB index
+ */
public class JaxbPropertiesResourceImpl
+ extends AbstractJaxbFileResourceModel<Properties>
implements JaxbPropertiesResource
{
- protected final IFile file;
-
- protected final String packageName;
-
- protected final Properties properties = new Properties();
-
- protected final ListenerList<JptResourceModelListener> resourceModelListenerList =
- new ListenerList<JptResourceModelListener>(JptResourceModelListener.class);
-
-
public JaxbPropertiesResourceImpl(IFile file) {
- super();
- if (file == null) {
- throw new NullPointerException();
- }
- this.file = file;
- this.packageName = this.buildPackageName();
- this.loadProperties();
- }
-
- protected String buildPackageName() {
- IJavaElement javaElement = JavaCore.create(this.file.getParent());
- if ((javaElement != null) && (javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT)) {
- return ((IPackageFragment) javaElement).getElementName();
- }
- return null;
- }
-
- protected void reloadProperties() {
- this.properties.clear();
- this.loadProperties();
+ super(file);
}
- protected void loadProperties() {
- InputStream stream = null;
- try {
- stream = this.file.getContents();
- if (stream != null) {
- this.properties.load(stream);
- }
- } catch (Exception ex) {
- JptJaxbCorePlugin.log(ex);
- } finally {
- this.closeStream(stream);
- }
+ @Override
+ protected Properties buildState() {
+ return new Properties();
}
- protected void closeStream(InputStream stream) {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException ex) {
- JptJaxbCorePlugin.log(ex);
- }
+ @Override
+ protected void reload() {
+ this.state.clear();
+ super.reload();
}
- void update() {
- this.reloadProperties();
- this.resourceModelChanged();
- }
-
- public String getPackageName() {
- return this.packageName;
+ @Override
+ protected void load(InputStream stream) throws IOException {
+ this.state.load(stream);
}
public String getProperty(String propertyName) {
- return this.properties.getProperty(propertyName);
+ return this.state.getProperty(propertyName);
}
-
- // ********** JptResourceModel implementation **********
-
public JptResourceType getResourceType() {
return JptJaxbCorePlugin.JAXB_PROPERTIES_RESOURCE_TYPE;
}
-
- public void addResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.add(listener);
- }
-
- public void removeResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.remove(listener);
- }
-
- protected void resourceModelChanged() {
- for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
- listener.resourceModelChanged(this);
- }
- }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidator.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidator.java
index e743b5e569..e22b76e706 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidator.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/validation/JaxbValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 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.
@@ -13,9 +13,8 @@ import org.eclipse.core.resources.IMarker;
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.IProgressMonitor;
-import org.eclipse.jpt.common.core.IResourcePart;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
@@ -113,11 +112,9 @@ public class JaxbValidator
}
private IMessage adjustMessage(IMessage message) {
- IAdaptable targetObject = (IAdaptable) message.getTargetObject();
- IResource targetResource = ((IResourcePart) targetObject.getAdapter(IResourcePart.class)).getResource();
- message.setTargetObject(targetResource);
+ message.setTargetObject(PlatformTools.getAdapter(message.getTargetObject(), IResource.class));
if (message.getLineNumber() == IMessage.LINENO_UNSET) {
- message.setAttribute(IMarker.LOCATION, " ");
+ message.setAttribute(IMarker.LOCATION, " "); //$NON-NLS-1$
}
return message;
}

Back to the top