[250004] Incorrect "Inconsistent Files" pop-up
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java
index 93c1e35..062a5e5 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ComponentCore.java
@@ -70,6 +70,26 @@
*
* @param aProject
* A valid, accessible project to contain the component
+ * @param checkForComponentFile
+ * A flag to indicate if the presence of the component file should be checked
+ * @return A handle to an IVirtualComponent that may or may not exist or
+ * null if passed project does not contain ModuleCoreNature.
+ * @see org.eclipse.core.runtime.IProgressMonitor#create(int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public static IVirtualComponent createComponent(IProject aProject, boolean checkForComponentFile) {
+ if (aProject == null || !aProject.isAccessible()){
+ return null;
+ }
+ return ComponentImplManager.instance().createComponent(aProject, checkForComponentFile);
+ }
+
+ /**
+ * Return an IVirtualComponent with the given name (aComponentName)
+ * contained by the given project (aProject). Component names should be
+ * unique across a project.
+ *
+ * @param aProject
+ * A valid, accessible project to contain the component
* @return A handle to an IVirtualComponent that may or may not exist or
* null if passed project does not contain ModuleCoreNature.
* @deprecated
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
index 5b8a475..a3704cf 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
@@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
@@ -38,6 +39,7 @@
import org.eclipse.wst.common.componentcore.internal.impl.ArtifactEditModelFactory;
import org.eclipse.wst.common.componentcore.internal.impl.ComponentCoreURIConverter;
import org.eclipse.wst.common.componentcore.internal.impl.ModuleStructuralModelFactory;
+import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResourceFactory;
import org.eclipse.wst.common.componentcore.internal.impl.WTPResourceFactoryRegistry;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.componentcore.internal.util.ModuleCoreMessages;
@@ -165,8 +167,33 @@
}
return null;
}
+ // The existence of this Nature plus the component file on disk makes a flexible project
public static boolean isFlexibleProject(IProject project) {
- return ModuleCoreNature.getModuleCoreNature(project) != null;
+ boolean foundNature = ModuleCoreNature.getModuleCoreNature(project) != null;
+ if (foundNature) {
+ return componentResourceExists(project);
+ }
+ return false;
+ }
+ public static boolean componentResourceExists(IProject project) {
+
+ IFile compFile = project.getFile(StructureEdit.MODULE_META_FILE_NAME);
+ if (compFile.isAccessible())
+ return true;
+ else { //Need to check for legacy file locations also....
+ compFile = project.getFile(ModuleStructuralModel.R1_MODULE_META_FILE_NAME);
+ if (compFile.isAccessible())
+ return true;
+ else {
+ compFile = project.getFile(ModuleStructuralModel.R0_7_MODULE_META_FILE_NAME);
+ if (compFile.isAccessible())
+ return true;
+ else {
+ compFile = project.getFile(WTPModulesResourceFactory.FIRST_WTP_MODULES_SHORT_NAME);
+ return compFile.isAccessible();
+ }
+ }
+ }
}
/**
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java
index a6ce890..46e1ca8 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ModuleStructuralModel.java
@@ -78,8 +78,8 @@
*/
public class ModuleStructuralModel extends EditModel implements IAdaptable {
- private static final String R0_7_MODULE_META_FILE_NAME = ".component";
- private static final String R1_MODULE_META_FILE_NAME = ".settings/.component";
+ public static final String R0_7_MODULE_META_FILE_NAME = ".component";
+ public static final String R1_MODULE_META_FILE_NAME = ".settings/.component";
public static final String MODULE_CORE_ID = "moduleCoreId"; //$NON-NLS-1$
private static final String PROJECT_VERSION_1_5 = "1.5.0";
private boolean useOldFormat = false;
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java
index 2cc2fdc..60a9feb 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/util/ComponentImplManager.java
@@ -169,6 +169,23 @@
return new VirtualComponent(project, new Path("/")); //$NON-NLS-1$
}
+ public IVirtualComponent createComponent(IProject project, boolean checkSettings) {
+ if (checkSettings)
+ return createComponent(project);
+ try {
+ IComponentImplFactory factory = findFactoryForProject(project);
+ if(null != factory){
+ return factory.createComponent(project);
+ }
+ } catch (Exception e) {
+ // Just return a default component
+ }
+ if (ModuleCoreNature.getModuleCoreNature(project) == null){
+ return null;
+ }
+ return new VirtualComponent(project, new Path("/")); //$NON-NLS-1$
+ }
+
public IVirtualComponent createArchiveComponent(IProject aProject, String aComponentName) {
try {
IComponentImplFactory factory = findFactoryForProject(aProject);