Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2013-03-26 14:02:52 -0400
committerBrian Vosburgh2013-03-26 14:02:52 -0400
commita30076b576848997543e9a98da2f642f208b6120 (patch)
tree8ab6100e20202662e45367057ad3fcd6c96e4fe4 /common/plugins/org.eclipse.jpt.common.core/src
parent3c552473cb9129701368c2234f6df1187528fc70 (diff)
downloadwebtools.dali-a30076b576848997543e9a98da2f642f208b6120.tar.gz
webtools.dali-a30076b576848997543e9a98da2f642f208b6120.tar.xz
webtools.dali-a30076b576848997543e9a98da2f642f208b6120.zip
refactor common.core Tools classes
Diffstat (limited to 'common/plugins/org.eclipse.jpt.common.core/src')
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/InternalJptResourceTypeManager.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptResourceTypeReferencePropertyTester.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/InternalLibraryValidatorManager.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/InternalResourceLocatorManager.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryModel.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ConfigurationElementTools.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ContentTypeTools.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ExtensionPointTools.java164
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PathTools.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java227
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/TypeTools.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java4
20 files changed, 386 insertions, 317 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/InternalJptResourceTypeManager.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/InternalJptResourceTypeManager.java
index 2bec149af8..3903d1b0a3 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/InternalJptResourceTypeManager.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/InternalJptResourceTypeManager.java
@@ -25,7 +25,7 @@ import org.eclipse.jpt.common.core.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.core.JptResourceTypeManager;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.ConfigurationElementTools;
+import org.eclipse.jpt.common.core.internal.utility.ExtensionPointTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.SimpleAssociation;
import org.eclipse.jpt.common.utility.internal.StringTools;
@@ -260,7 +260,7 @@ public class InternalJptResourceTypeManager
}
private void logMissingAttribute(IConfigurationElement element, String attributeName) {
- this.getPlugin().logError(ConfigurationElementTools.buildMissingAttributeMessage(element, attributeName));
+ this.getPlugin().logError(ExtensionPointTools.buildMissingAttributeMessage(element, attributeName));
}
private void logInvalidContentType(IConfigurationElement element, String resourceTypeID, String contentTypeID) {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptResourceTypeReferencePropertyTester.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptResourceTypeReferencePropertyTester.java
index 9a5138089f..42eaa1d750 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptResourceTypeReferencePropertyTester.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptResourceTypeReferencePropertyTester.java
@@ -15,7 +15,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.core.JptResourceTypeReference;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ContentTypeTools;
/**
* Property tester for {@link JptResourceTypeReference}.
@@ -73,7 +73,7 @@ public class JptResourceTypeReferencePropertyTester
}
private boolean resourceTypeIsKindOf(JptResourceTypeReference ref, IContentType contentType, String version) {
- JptResourceType resourceType = PlatformTools.getResourceType(contentType, version);
+ JptResourceType resourceType = ContentTypeTools.getResourceType(contentType, version);
return (resourceType != null) && ref.getResourceType().isKindOf(resourceType);
}
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/InternalLibraryValidatorManager.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/InternalLibraryValidatorManager.java
index 046dd51eac..2ea9a8a1c5 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/InternalLibraryValidatorManager.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/InternalLibraryValidatorManager.java
@@ -20,7 +20,7 @@ import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.jpt.common.core.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.InternalJptWorkspace;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.ConfigurationElementTools;
+import org.eclipse.jpt.common.core.internal.utility.ExtensionPointTools;
import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.common.core.libval.LibraryValidator;
import org.eclipse.jpt.common.core.libval.LibraryValidatorManager;
@@ -197,7 +197,7 @@ public class InternalLibraryValidatorManager
}
private void logMissingAttribute(IConfigurationElement element, String attributeName) {
- this.getPlugin().logError(ConfigurationElementTools.buildMissingAttributeMessage(element, attributeName));
+ this.getPlugin().logError(ExtensionPointTools.buildMissingAttributeMessage(element, attributeName));
}
private void logMultipleEnablements(IConfigurationElement element) {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java
index 7810163b03..780edc42d0 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java
@@ -14,7 +14,7 @@ import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ExtensionPointTools;
import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.common.core.libval.LibraryValidator;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
@@ -100,7 +100,7 @@ class LibraryValidatorConfig {
}
private LibraryValidator buildLibraryValidator() {
- return PlatformTools.instantiate(this.pluginID, this.manager.getExtensionPointName(), this.className, LibraryValidator.class);
+ return ExtensionPointTools.instantiate(this.pluginID, this.manager.getExtensionPointName(), this.className, LibraryValidator.class);
}
@Override
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 265eaa422e..44ea96a541 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
@@ -18,7 +18,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jpt.common.core.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
@@ -105,7 +105,7 @@ public abstract class AbstractJptFileCreationDataModelProvider
protected IContainer getContainer() {
IPath containerPath = getContainerPath();
- return (containerPath == null) ? null : PlatformTools.getContainer(containerPath);
+ return (containerPath == null) ? null : PathTools.getContainer(containerPath);
}
protected IProject getProject() {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/InternalResourceLocatorManager.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/InternalResourceLocatorManager.java
index ad5e66257a..6f77af1434 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/InternalResourceLocatorManager.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/InternalResourceLocatorManager.java
@@ -23,7 +23,7 @@ import org.eclipse.jpt.common.core.JptCommonCoreMessages;
import org.eclipse.jpt.common.core.internal.InternalJptWorkspace;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.internal.resource.ResourceLocatorConfig.Priority;
-import org.eclipse.jpt.common.core.internal.utility.ConfigurationElementTools;
+import org.eclipse.jpt.common.core.internal.utility.ExtensionPointTools;
import org.eclipse.jpt.common.core.resource.ResourceLocator;
import org.eclipse.jpt.common.core.resource.ResourceLocatorManager;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
@@ -221,7 +221,7 @@ public class InternalResourceLocatorManager
}
private void logMissingAttribute(IConfigurationElement element, String attributeName) {
- this.getPlugin().logError(ConfigurationElementTools.buildMissingAttributeMessage(element, attributeName));
+ this.getPlugin().logError(ExtensionPointTools.buildMissingAttributeMessage(element, attributeName));
}
private void logInvalidPriority(IConfigurationElement element, String priority) {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java
index 592922eae2..b48fbf7261 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java
@@ -15,7 +15,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
@@ -40,7 +40,7 @@ public class ModuleResourceLocator
@Override
public IPath getRuntimePath(IProject project, IPath resourcePath) {
IVirtualFolder rootFolder = this.getRootFolder(project);
- IFile file = PlatformTools.getFile(resourcePath);
+ IFile file = PathTools.getFile(resourcePath);
IVirtualFile vFile = this.getVirtualFile(rootFolder, file);
if (vFile != null) {
return vFile.getRuntimePath().makeRelative();
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java
index 35deeae644..a792eb32e6 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java
@@ -15,7 +15,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
import org.eclipse.pde.core.project.IBundleProjectService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -47,7 +47,7 @@ public class PluginResourceLocator
public IPath getRuntimePath(IProject project, IPath resourcePath) {
IContainer bundleRoot = this.getBundleRoot(project);
if (bundleRoot != null) {
- IFile file = PlatformTools.getFile(resourcePath);
+ IFile file = PathTools.getFile(resourcePath);
if (bundleRoot.contains(file)) {
return resourcePath.makeRelativeTo(bundleRoot.getFullPath());
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java
index 7215ef0984..d3e1abf7ae 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java
@@ -16,7 +16,7 @@ import org.eclipse.core.expressions.Expression;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ExtensionPointTools;
import org.eclipse.jpt.common.core.resource.ResourceLocator;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.predicate.CriterionPredicate;
@@ -107,7 +107,7 @@ class ResourceLocatorConfig
}
private ResourceLocator buildResourceLocator() {
- return PlatformTools.instantiate(this.pluginID, this.manager.getExtensionPointName(), this.className, ResourceLocator.class);
+ return ExtensionPointTools.instantiate(this.pluginID, this.manager.getExtensionPointName(), this.className, ResourceLocator.class);
}
@Override
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java
index 8d4932adea..3de43174db 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java
@@ -24,7 +24,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.internal.utility.PackageFragmentRootTools;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.PathTools;
import org.eclipse.jpt.common.core.resource.ResourceLocator;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.iterable.TransformationIterable;
@@ -165,7 +165,7 @@ public class SimpleJavaResourceLocator
}
protected IPath getRuntimePath_(IProject project, IPath resourcePath) throws JavaModelException {
- IFile file = PlatformTools.getFile(resourcePath);
+ IFile file = PathTools.getFile(resourcePath);
for (IContainer sourceFolder : this.getSourceFolders(project)) {
if (sourceFolder.contains(file)) {
return resourcePath.makeRelativeTo(sourceFolder.getFullPath());
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryModel.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryModel.java
index 9ca8e4f44c..350edf21d6 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryModel.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryModel.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.common.core.internal.resource.java.binary;
import org.eclipse.jpt.common.core.AnnotationProvider;
import org.eclipse.jpt.common.core.JptResourceModelListener;
import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ContentTypeTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceModel;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
import org.eclipse.jpt.common.utility.internal.ListenerList;
@@ -69,7 +69,7 @@ abstract class RootBinaryModel
// ********** JptResourceModel implementation **********
public JptResourceType getResourceType() {
- return PlatformTools.getResourceType(JavaResourcePackageFragmentRoot.JAR_CONTENT_TYPE);
+ return ContentTypeTools.getResourceType(JavaResourcePackageFragmentRoot.JAR_CONTENT_TYPE);
}
public void addResourceModelListener(JptResourceModelListener listener) {
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
index e02a89cfc3..7e663edb02 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
@@ -14,7 +14,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jpt.common.core.AnnotationProvider;
import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ContentTypeTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageInfoCompilationUnit;
@@ -64,7 +64,7 @@ public final class SourcePackageInfoCompilationUnit
// ********** JptResourceModel implementation **********
public JptResourceType getResourceType() {
- return PlatformTools.getResourceType(PACKAGE_INFO_CONTENT_TYPE);
+ return ContentTypeTools.getResourceType(PACKAGE_INFO_CONTENT_TYPE);
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java
index 3f86747b94..d9f402dfe6 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java
@@ -18,7 +18,7 @@ import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jpt.common.core.AnnotationProvider;
import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ContentTypeTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.AstNodeType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
@@ -88,7 +88,7 @@ public final class SourceTypeCompilationUnit
// ********** JpaResourceModel implementation **********
public JptResourceType getResourceType() {
- return PlatformTools.getResourceType(CONTENT_TYPE);
+ return ContentTypeTools.getResourceType(CONTENT_TYPE);
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ConfigurationElementTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ConfigurationElementTools.java
deleted file mode 100644
index c43aa37dcd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ConfigurationElementTools.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.jpt.common.core.JptCommonCoreMessages;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * {@link IConfigurationElement} utility methods.
- */
-public class ConfigurationElementTools {
- /**
- * Return a helpful message indicating the specified attribute is missing
- * from the specified element.
- */
- public static String buildMissingAttributeMessage(IConfigurationElement element, String attributeName) {
- return bind(JptCommonCoreMessages.REGISTRY_MISSING_ATTRIBUTE,
- attributeName,
- element.getName(),
- element.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
- element.getContributor().getName()
- );
- }
-
- /**
- * Return a helpful message indicating the specified attribute
- * from the specified element has an invalid value.
- */
- public static String buildInvalidValueMessage(IConfigurationElement element, String attributeName, String invalidValue) {
- return bind(JptCommonCoreMessages.REGISTRY_INVALID_VALUE,
- invalidValue,
- attributeName,
- element.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
- element.getContributor().getName()
- );
- }
-
- private static String bind(String msg, Object... args) {
- return NLS.bind(msg, args);
- }
-
- private ConfigurationElementTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ContentTypeTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ContentTypeTools.java
new file mode 100644
index 0000000000..50aa988f5b
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ContentTypeTools.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 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.common.core.internal.utility;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.core.JptWorkspace;
+import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
+
+/**
+ * {@link IContentType} utility methods
+ */
+public class ContentTypeTools {
+
+
+ // ********** resource type **********
+
+ /**
+ * Return the resource type corresponding to the specified content type.
+ */
+ public static JptResourceType getResourceType(IContentType contentType) {
+ JptWorkspace jptWorkspace = getJptWorkspace();
+ return (jptWorkspace == null) ? null : jptWorkspace.getResourceTypeManager().getResourceType(contentType);
+ }
+
+ /**
+ * Return the resource type corresponding to the specified content type
+ * and version.
+ */
+ public static JptResourceType getResourceType(IContentType contentType, String version) {
+ JptWorkspace jptWorkspace = getJptWorkspace();
+ return (jptWorkspace == null) ? null : jptWorkspace.getResourceTypeManager().getResourceType(contentType, version);
+ }
+
+ private static JptWorkspace getJptWorkspace() {
+ return PlatformTools.getAdapter(PathTools.getWorkspace(), JptWorkspace.class);
+ }
+
+
+ // ********** file content type **********
+
+ /**
+ * Return the specified file's content type,
+ * using the Eclipse platform's content type manager.
+ */
+ public static IContentType contentType(IFile file) {
+ String fileName = file.getName();
+ InputStream fileContents = null;
+ try {
+ fileContents = file.getContents();
+ } catch (CoreException ex) {
+ // seems like we can ignore any exception that might occur here;
+ // e.g. we get a FNFE if the workspace is out of sync with the O/S file system
+ // JptCorePlugin.log(ex);
+
+ // look for content type based on the file name only(?)
+ return findContentTypeFor(fileName);
+ }
+
+ IContentType contentType = null;
+ try {
+ contentType = findContentTypeFor(fileContents, fileName);
+ } catch (IOException ex) {
+ JptCommonCorePlugin.instance().logError(ex);
+ } finally {
+ try {
+ fileContents.close();
+ } catch (IOException ex) {
+ JptCommonCorePlugin.instance().logError(ex);
+ }
+ }
+ return contentType;
+ }
+
+ private static IContentType findContentTypeFor(InputStream fileContents, String fileName) throws IOException {
+ return getContentTypeManager().findContentTypeFor(fileContents, fileName);
+ }
+
+ private static IContentType findContentTypeFor(String fileName) {
+ return getContentTypeManager().findContentTypeFor(fileName);
+ }
+
+ private static IContentTypeManager getContentTypeManager() {
+ return Platform.getContentTypeManager();
+ }
+
+
+ // ********** disabled constructor **********
+
+ private ContentTypeTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ExtensionPointTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ExtensionPointTools.java
new file mode 100644
index 0000000000..de7b53b667
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ExtensionPointTools.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package org.eclipse.jpt.common.core.internal.utility;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jpt.common.core.JptCommonCoreMessages;
+import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
+import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Bundle;
+
+/**
+ * {@link IConfigurationElement} utility methods.
+ */
+public class ExtensionPointTools {
+
+ // ********** instantiation **********
+
+ /**
+ * Load the specified class, using the specified bundle, and, if it is a
+ * sub-type of the specified interface, instantiate it and return the resulting
+ * object, cast appropriately.
+ * Log an error and return <code>null</code> for any of the following
+ * conditions:<ul>
+ * <li>the bundle cannot be resolved
+ * <li>the class fails to load
+ * <li>the loaded class is not a sub-type of the specified interface
+ * <li>the loaded class cannot be instantiated
+ * </ul>
+ */
+ public static <T> T instantiate(String pluginID, String extensionPoint, String className, Class<T> interfaze) {
+ Class<T> clazz = loadClass(pluginID, extensionPoint, className, interfaze);
+ return (clazz == null) ? null : instantiate(pluginID, extensionPoint, clazz);
+ }
+
+ /**
+ * Load the specified class, using the specified bundle, and cast it to the
+ * specified interface before returning it.
+ * Log an error and return <code>null</code> for any of the following
+ * conditions:<ul>
+ * <li>the bundle cannot be resolved
+ * <li>the class fails to load
+ * <li>the loaded class is not a sub-type of the specified interface
+ * </ul>
+ */
+ private static <T> Class<T> loadClass(String pluginID, String extensionPoint, String className, Class<T> interfaze) {
+ Bundle bundle = Platform.getBundle(pluginID);
+ if (bundle == null) {
+ logError(JptCommonCoreMessages.REGISTRY_MISSING_BUNDLE, pluginID);
+ return null;
+ }
+
+ Class<?> clazz;
+ try {
+ clazz = bundle.loadClass(className);
+ } catch (Exception ex) {
+ logFailedClassLoad(ex, pluginID, extensionPoint, className);
+ return null;
+ }
+
+ if ( ! interfaze.isAssignableFrom(clazz)) {
+ logFailedInterfaceAssignment(pluginID, extensionPoint, clazz, interfaze);
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ Class<T> clazzT = (Class<T>) clazz;
+ return clazzT;
+ }
+
+ private static void logFailedClassLoad(Exception ex, String pluginID, String extensionPoint, String className) {
+ logError(ex, JptCommonCoreMessages.REGISTRY_FAILED_CLASS_LOAD,
+ className,
+ extensionPoint,
+ pluginID
+ );
+ }
+
+ private static void logFailedInterfaceAssignment(String pluginID, String extensionPoint, Class<?> clazz, Class<?> interfaze) {
+ logError(JptCommonCoreMessages.REGISTRY_FAILED_INTERFACE_ASSIGNMENT,
+ clazz.getName(),
+ extensionPoint,
+ pluginID,
+ interfaze.getName()
+ );
+ }
+
+ /**
+ * Instantiate the specified class.
+ * Log an error and return <code>null</code> if the instantiation fails.
+ */
+ private static <T> T instantiate(String pluginID, String extensionPoint, Class<T> clazz) {
+ try {
+ return clazz.newInstance();
+ } catch (Exception ex) {
+ logFailedInstantiation(ex, pluginID, extensionPoint, clazz);
+ return null;
+ }
+ }
+
+ private static void logFailedInstantiation(Exception ex, String pluginID, String extensionPoint, Class<?> clazz) {
+ logError(ex, JptCommonCoreMessages.REGISTRY_FAILED_INSTANTIATION,
+ clazz.getName(),
+ extensionPoint,
+ pluginID
+ );
+ }
+
+ private static void logError(String msg, Object... args) {
+ JptCommonCorePlugin.instance().logError(msg, args);
+ }
+
+ private static void logError(Throwable ex, String msg, Object... args) {
+ JptCommonCorePlugin.instance().logError(ex, msg, args);
+ }
+
+
+ // ********** error messages **********
+
+ /**
+ * Return a helpful message indicating the specified attribute is missing
+ * from the specified element.
+ */
+ public static String buildMissingAttributeMessage(IConfigurationElement element, String attributeName) {
+ return bind(JptCommonCoreMessages.REGISTRY_MISSING_ATTRIBUTE,
+ attributeName,
+ element.getName(),
+ element.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
+ element.getContributor().getName()
+ );
+ }
+
+ /**
+ * Return a helpful message indicating the specified attribute
+ * from the specified element has an invalid value.
+ */
+ public static String buildInvalidValueMessage(IConfigurationElement element, String attributeName, String invalidValue) {
+ return bind(JptCommonCoreMessages.REGISTRY_INVALID_VALUE,
+ invalidValue,
+ attributeName,
+ element.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
+ element.getContributor().getName()
+ );
+ }
+
+ private static String bind(String msg, Object... args) {
+ return NLS.bind(msg, args);
+ }
+
+
+ // ********** disabled constructor **********
+
+ private ExtensionPointTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PathTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PathTools.java
new file mode 100644
index 0000000000..b4cda34bef
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PathTools.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 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.common.core.internal.utility;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * {@link IPath} utility methods
+ */
+public class PathTools {
+
+ // ********** paths **********
+
+ /**
+ * Return the {@link IContainer} with the workspace-relative "full" path
+ */
+ public static IContainer getContainer(IPath fullContainerPath) {
+ // changed to handle non-workspace projects
+ String projectName = fullContainerPath.segment(0).toString();
+ IPath projectRelativePath = fullContainerPath.removeFirstSegments(1);
+ IProject project = getWorkspaceRoot().getProject(projectName);
+ return (projectRelativePath.isEmpty()) ? project : project.getFolder(projectRelativePath);
+ }
+
+ /**
+ * Return the {@link IFile} with the workspace relative "full" path
+ */
+ public static IFile getFile(IPath fullFilePath) {
+ // changed to handle non-workspace projects
+ String projectName = fullFilePath.segment(0).toString();
+ IPath projectRelativePath = fullFilePath.removeFirstSegments(1);
+ IProject project = getWorkspaceRoot().getProject(projectName);
+ return project.getFile(projectRelativePath);
+ }
+
+ private static IWorkspaceRoot getWorkspaceRoot() {
+ return getWorkspace().getRoot();
+ }
+
+ static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+
+ // ********** disabled constructor **********
+
+ private PathTools() {
+ super();
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java
index 54db2d6716..a87e0bfd18 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java
@@ -9,30 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.common.core.internal.utility;
-import java.io.IOException;
-import java.io.InputStream;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.jpt.common.core.JptCommonCoreMessages;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.JptWorkspace;
-import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.osgi.framework.Bundle;
/**
- * A collection of utilities for dealing with the Eclipse platform API.
+ * {@link Platform} utility methods
*/
public class PlatformTools {
@@ -48,214 +31,16 @@ public class PlatformTools {
}
- // ********** resources **********
-
- /**
- * Return the {@link IContainer} with the workspace-relative "full" path
- */
- public static IContainer getContainer(IPath fullContainerPath) {
- // changed to handle non-workspace projects
- String projectName = fullContainerPath.segment(0).toString();
- IPath projectRelativePath = fullContainerPath.removeFirstSegments(1);
- IProject project = getWorkspaceRoot().getProject(projectName);
- return (projectRelativePath.isEmpty()) ? project : project.getFolder(projectRelativePath);
- }
-
- /**
- * Return the {@link IFile} with the workspace relative "full" path
- */
- public static IFile getFile(IPath fullFilePath) {
- // changed to handle non-workspace projects
- String projectName = fullFilePath.segment(0).toString();
- IPath projectRelativePath = fullFilePath.removeFirstSegments(1);
- IProject project = getWorkspaceRoot().getProject(projectName);
- return project.getFile(projectRelativePath);
- }
-
- private static IWorkspaceRoot getWorkspaceRoot() {
- return getWorkspace().getRoot();
- }
-
- private static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
-
- // ********** resource type **********
-
- public static JptResourceType getResourceType(IContentType contentType) {
- JptWorkspace jptWorkspace = getJptWorkspace();
- return (jptWorkspace == null) ? null : jptWorkspace.getResourceTypeManager().getResourceType(contentType);
- }
-
- public static JptResourceType getResourceType(IContentType contentType, String version) {
- JptWorkspace jptWorkspace = getJptWorkspace();
- return (jptWorkspace == null) ? null : jptWorkspace.getResourceTypeManager().getResourceType(contentType, version);
- }
-
- private static JptWorkspace getJptWorkspace() {
- return getAdapter(getWorkspace(), JptWorkspace.class);
- }
-
-
- // ********** content type **********
-
- /**
- * Return the specified file's content type,
- * using the Eclipse platform's content type manager.
- */
- public static IContentType getContentType(IFile file) {
- String fileName = file.getName();
- InputStream fileContents = null;
- try {
- fileContents = file.getContents();
- } catch (CoreException ex) {
- // seems like we can ignore any exception that might occur here;
- // e.g. we get a FNFE if the workspace is out of sync with the O/S file system
- // JptCorePlugin.log(ex);
-
- // look for content type based on the file name only(?)
- return findContentTypeFor(fileName);
- }
-
- IContentType contentType = null;
- try {
- contentType = findContentTypeFor(fileContents, fileName);
- } catch (IOException ex) {
- JptCommonCorePlugin.instance().logError(ex);
- } finally {
- try {
- fileContents.close();
- } catch (IOException ex) {
- JptCommonCorePlugin.instance().logError(ex);
- }
- }
- return contentType;
- }
-
- private static IContentType findContentTypeFor(InputStream fileContents, String fileName) throws IOException {
- return getContentTypeManager().findContentTypeFor(fileContents, fileName);
- }
-
- private static IContentType findContentTypeFor(String fileName) {
- return getContentTypeManager().findContentTypeFor(fileName);
- }
-
- private static IContentTypeManager getContentTypeManager() {
- return Platform.getContentTypeManager();
- }
-
-
- // ********** instantiation **********
-
- /**
- * Load the specified class, using the specified bundle, and, if it is a
- * sub-type of the specified interface, instantiate it and return the resulting
- * object, cast appropriately.
- * Log an error and return <code>null</code> for any of the following
- * conditions:<ul>
- * <li>the bundle cannot be resolved
- * <li>the class fails to load
- * <li>the loaded class is not a sub-type of the specified interface
- * <li>the loaded class cannot be instantiated
- * </ul>
- */
- public static <T> T instantiate(String pluginID, String extensionPoint, String className, Class<T> interfaze) {
- Class<T> clazz = loadClass(pluginID, extensionPoint, className, interfaze);
- return (clazz == null) ? null : instantiate(pluginID, extensionPoint, clazz);
- }
-
- /**
- * Load the specified class, using the specified bundle, and cast it to the
- * specified interface before returning it.
- * Log an error and return <code>null</code> for any of the following
- * conditions:<ul>
- * <li>the bundle cannot be resolved
- * <li>the class fails to load
- * <li>the loaded class is not a sub-type of the specified interface
- * </ul>
- */
- private static <T> Class<T> loadClass(String pluginID, String extensionPoint, String className, Class<T> interfaze) {
- Bundle bundle = Platform.getBundle(pluginID);
- if (bundle == null) {
- logError(JptCommonCoreMessages.REGISTRY_MISSING_BUNDLE, pluginID);
- return null;
- }
-
- Class<?> clazz;
- try {
- clazz = bundle.loadClass(className);
- } catch (Exception ex) {
- logFailedClassLoad(ex, pluginID, extensionPoint, className);
- return null;
- }
-
- if ( ! interfaze.isAssignableFrom(clazz)) {
- logFailedInterfaceAssignment(pluginID, extensionPoint, clazz, interfaze);
- return null;
- }
-
- @SuppressWarnings("unchecked")
- Class<T> clazzT = (Class<T>) clazz;
- return clazzT;
- }
-
- private static void logFailedClassLoad(Exception ex, String pluginID, String extensionPoint, String className) {
- logError(ex, JptCommonCoreMessages.REGISTRY_FAILED_CLASS_LOAD,
- className,
- extensionPoint,
- pluginID
- );
- }
-
- private static void logFailedInterfaceAssignment(String pluginID, String extensionPoint, Class<?> clazz, Class<?> interfaze) {
- logError(JptCommonCoreMessages.REGISTRY_FAILED_INTERFACE_ASSIGNMENT,
- clazz.getName(),
- extensionPoint,
- pluginID,
- interfaze.getName()
- );
- }
-
- /**
- * Instantiate the specified class.
- * Log an error and return <code>null</code> if the instantiation fails.
- */
- private static <T> T instantiate(String pluginID, String extensionPoint, Class<T> clazz) {
- try {
- return clazz.newInstance();
- } catch (Exception ex) {
- logFailedInstantiation(ex, pluginID, extensionPoint, clazz);
- return null;
- }
- }
-
- private static void logFailedInstantiation(Exception ex, String pluginID, String extensionPoint, Class<?> clazz) {
- logError(ex, JptCommonCoreMessages.REGISTRY_FAILED_INSTANTIATION,
- clazz.getName(),
- extensionPoint,
- pluginID
- );
- }
-
- private static void logError(String msg, Object... args) {
- JptCommonCorePlugin.instance().logError(msg, args);
- }
-
- private static void logError(Throwable ex, String msg, Object... args) {
- JptCommonCorePlugin.instance().logError(ex, msg, args);
- }
-
-
// ********** workspace preferences **********
public static String getNewTextFileLineDelimiter() {
IScopeContext[] contexts = new IScopeContext[] { DefaultScope.INSTANCE };
return Platform.getPreferencesService().getString(
- Platform.PI_RUNTIME,
- Platform.PREF_LINE_SEPARATOR,
- StringTools.CR,
- contexts);
+ Platform.PI_RUNTIME,
+ Platform.PREF_LINE_SEPARATOR,
+ StringTools.CR,
+ contexts
+ );
}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/TypeTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/TypeTools.java
index 774d1f4198..d6d4cdf297 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/TypeTools.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/TypeTools.java
@@ -167,24 +167,27 @@ public final class TypeTools {
}
public static boolean hasPublicZeroArgConstructor(IType type) {
- boolean hasDefinedConstructor = false;
try {
- for (IMethod method : type.getMethods()) {
- if (method.isConstructor()) {
- if ((method.getNumberOfParameters() == 0) && (Flags.isPublic(method.getFlags()))) {
- return true;
- }
- hasDefinedConstructor = true;
- }
- }
- //When there's no defined constructor, the default constructor is in place.
- if (!hasDefinedConstructor) {
- return true;
- }
+ return hasPublicZeroArgConstructor_(type);
} catch (JavaModelException ex) {
JptCommonCorePlugin.instance().logError(ex);
+ return false;
}
- return false;
+ }
+
+ private static boolean hasPublicZeroArgConstructor_(IType type) throws JavaModelException {
+ boolean ctorDefined = false;
+ for (IMethod method : type.getMethods()) {
+ if (method.isConstructor()) {
+ if ((method.getNumberOfParameters() == 0) && (Flags.isPublic(method.getFlags()))) {
+ return true;
+ }
+ ctorDefined = true;
+ }
+ }
+ // if there are no constructors defined in the source,
+ // the compiler generates a default constructor
+ return ! ctorDefined;
}
public static final Predicate<IType> IS_INTERFACE = new IsInterface();
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
index ea3c64e154..689631aebc 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/xml/JptXmlResource.java
@@ -28,7 +28,7 @@ import org.eclipse.jpt.common.core.JptResourceModel;
import org.eclipse.jpt.common.core.JptResourceModelListener;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.core.internal.plugin.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.internal.utility.ContentTypeTools;
import org.eclipse.jpt.common.utility.internal.ListenerList;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jst.j2ee.internal.xml.J2EEXmlDtDEntityResolver;
@@ -97,7 +97,7 @@ public class JptXmlResource
}
protected JptResourceType getResourceType(String version) {
- return (this.contentType == null) ? null : PlatformTools.getResourceType(this.contentType, version);
+ return (this.contentType == null) ? null : ContentTypeTools.getResourceType(this.contentType, version);
}

Back to the top