[nobug]: Updating ModuleCore API. Committed for MDE.
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/ModuleCore.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/ModuleCore.java
index 941bd20..16bab1b 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/ModuleCore.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/ModuleCore.java
@@ -28,10 +28,13 @@
import org.eclipse.wst.common.modulecore.internal.impl.ModuleURIUtil;
import org.eclipse.wst.common.modulecore.internal.impl.PlatformURLModuleConnection;
import org.eclipse.wst.common.modulecore.internal.resources.VirtualContainer;
+import org.eclipse.wst.common.modulecore.internal.resources.VirtualFile;
import org.eclipse.wst.common.modulecore.internal.resources.VirtualFolder;
import org.eclipse.wst.common.modulecore.internal.util.EclipseResourceAdapter;
import org.eclipse.wst.common.modulecore.resources.IVirtualContainer;
+import org.eclipse.wst.common.modulecore.resources.IVirtualFile;
import org.eclipse.wst.common.modulecore.resources.IVirtualFolder;
+import org.eclipse.wst.common.modulecore.resources.IVirtualReference;
/**
* <p>
@@ -273,14 +276,22 @@
return ModuleURIUtil.getDeployedName(aFullyQualifiedModuleURI);
}
- public static IVirtualContainer create(IProject aProject, String aName) {
- return new VirtualContainer(aProject, aName, new Path("/")); //$NON-NLS-1$
+ public static IVirtualContainer createContainer(IProject aProject, String aComponentName) {
+ return new VirtualContainer(aProject, aComponentName, new Path("/")); //$NON-NLS-1$
}
- public static IVirtualFolder create(IFolder aFolder, String aComponentName, IPath aRuntimePath) {
- return new VirtualFolder(aFolder, aComponentName, aRuntimePath);
+ public static IVirtualFolder createFolder(IProject aProject, String aComponentName, IPath aRuntimePath) {
+ return new VirtualFolder(aProject, aComponentName, aRuntimePath);
}
+ public static IVirtualFile createFile(IProject aProject, String aComponentName, IPath aRuntimePath) {
+ return new VirtualFile(aProject, aComponentName, aRuntimePath);
+ }
+
+ public static IVirtualReference createReference(IVirtualContainer aContainer, IVirtualContainer aReferencedContainer) {
+ return null;
+ }
+
public static ComponentType getComponentType(IVirtualContainer aComponent) {
ModuleCore moduleCore = null;
ComponentType componentType = null;
@@ -295,7 +306,6 @@
return componentType;
}
-
public static void setComponentType(IVirtualContainer component, ComponentType aComponentType) {
ModuleCore moduleCore = null;
try {
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/impl/ModuleCoreURIConverter.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/impl/ModuleCoreURIConverter.java
index 51ce08b..29a9585 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/impl/ModuleCoreURIConverter.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/impl/ModuleCoreURIConverter.java
@@ -85,7 +85,7 @@
try {
String componentName = ModuleCore.getDeployedName(aNewURI);
- IVirtualContainer component = ModuleCore.create(containingProject, componentName);
+ IVirtualContainer component = ModuleCore.createContainer(containingProject, componentName);
URI deployPathSegment = ModuleURIUtil.trimToDeployPathSegment(aNewURI);
IVirtualFile newFile = component.getFile(new Path(deployPathSegment.path()));
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/operation/ComponentCreationOperation.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/operation/ComponentCreationOperation.java
index b52b8ed..e5c7a3d 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/operation/ComponentCreationOperation.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/operation/ComponentCreationOperation.java
@@ -45,7 +45,7 @@
protected void setupComponentType(String typeID) {
ComponentCreationDataModel dataModel = (ComponentCreationDataModel)operationDataModel;
- IVirtualContainer component = ModuleCore.create(dataModel.getProject(), dataModel.getComponentDeployName());
+ IVirtualContainer component = ModuleCore.createContainer(dataModel.getProject(), dataModel.getComponentDeployName());
ComponentType componentType = ModuleCoreFactory.eINSTANCE.createComponentType();
componentType.setModuleTypeId(typeID);
componentType.setVersion(dataModel.getVersion());
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualContainer.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualContainer.java
index 1d9778c..50f308b 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualContainer.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualContainer.java
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.wst.common.modulecore.ComponentResource;
import org.eclipse.wst.common.modulecore.ModuleCore;
import org.eclipse.wst.common.modulecore.WorkbenchComponent;
@@ -30,6 +31,7 @@
public class VirtualContainer extends VirtualResource implements IVirtualContainer {
+
public VirtualContainer(IProject aProject, String aName, IPath aRuntimePath) {
super(aProject, aName, aRuntimePath);
}
@@ -105,14 +107,14 @@
* @see IFolder#getFile(java.lang.String)
*/
public IVirtualFile getFile(String name) {
- return getFile(new Path(name));
+ return new VirtualFile(getComponentHandle(), getRuntimePath().append(name));
}
/**
* @see IFolder#getFolder(java.lang.String)
*/
public IVirtualFolder getFolder(String name) {
- return getFolder(new Path(name));
+ return new VirtualFolder(getComponentHandle(), getRuntimePath().append(name));
}
/**
@@ -191,7 +193,7 @@
// return null;
}
- public void commit() throws CoreException{
+ public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException {
ModuleCore moduleCore = null;
try {
@@ -205,10 +207,62 @@
moduleCore.dispose();
}
}
+ }
+
+ /**
+ * @see IFolder#createLink(org.eclipse.core.runtime.IPath, int,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
+
+ ModuleCore moduleCore = null;
+ try {
+ IFolder resource = getProject().getFolder(aProjectRelativeLocation);
+
+ moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
+ WorkbenchComponent component = moduleCore.findWorkbenchModuleByDeployName(getComponentName());
+
+ ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component);
+ ComponentResource[] resources = root.findModuleResources(getRuntimePath(), false);
+
+ if(resources.length == 0) {
+ ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
+ componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
+ component.getResources().add(componentResource);
+ } else {
+ URI projectRelativeURI = URI.createURI(aProjectRelativeLocation.toString());
+ boolean foundMapping = false;
+ for (int resourceIndx = 0; resourceIndx < resources.length && !foundMapping; resourceIndx++) {
+ if(projectRelativeURI.equals(resources[resourceIndx].getSourcePath()))
+ foundMapping = true;
+ }
+ if(!foundMapping) {
+ ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
+ componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
+ component.getResources().add(componentResource);
+ }
+ }
+
+ createResource(resource, updateFlags, monitor);
+
+ } finally {
+ if (moduleCore != null) {
+ moduleCore.saveIfNecessary(monitor);
+ moduleCore.dispose();
+ }
+ }
}
public int getType() {
- return IResource.ROOT;
+ return IVirtualResource.COMPONENT;
+ }
+
+ public IResource getUnderlyingResource() {
+ return null;
+ }
+
+ public IResource[] getUnderlyingResources() {
+ return NO_RESOURCES;
}
protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) {
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFile.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFile.java
index 7c9f6bc..58ae4b3 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFile.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFile.java
@@ -9,11 +9,19 @@
package org.eclipse.wst.common.modulecore.internal.resources;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.wst.common.modulecore.ComponentResource;
+import org.eclipse.wst.common.modulecore.ModuleCore;
+import org.eclipse.wst.common.modulecore.WorkbenchComponent;
+import org.eclipse.wst.common.modulecore.internal.impl.ResourceTreeRoot;
import org.eclipse.wst.common.modulecore.resources.IVirtualFile;
+import org.eclipse.wst.common.modulecore.resources.IVirtualResource;
public class VirtualFile extends VirtualResource implements IVirtualFile {
@@ -21,46 +29,70 @@
super(aComponentHandle, aRuntimePath);
}
-
+ public VirtualFile(IProject aProject, String aComponentName, IPath aRuntimePath) {
+ super(ComponentHandle.create(aProject, aComponentName), aRuntimePath);
+ }
+
+ /**
+ * @see IFolder#createLink(org.eclipse.core.runtime.IPath, int,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
- throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$
-//
-// ModuleCore moduleCore = null;
-// try {
-// IResource resource = (getType() == IResource.FOLDER) ?
-// (IResource) getProject().getFolder(aProjectRelativeLocation) :
-// (IResource) getProject().getFile(aProjectRelativeLocation);
-//
-// moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
-// WorkbenchComponent component = moduleCore.findWorkbenchModuleByDeployName(getComponentHandle().getName());
-//
-// ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
-// componentResource.setRuntimePath(URI.createURI(getRuntimePath().toOSString()));
-//
-// if(!resource.exists()) {
-// resource.
-// }
-//
-// } finally {
-// if(moduleCore != null) {
-// moduleCore.saveIfNecessary(monitor);
-// moduleCore.dispose();
-// }
-// }
-
-
- }
-
+
+ ModuleCore moduleCore = null;
+ try {
+ IFile resource = getProject().getFile(aProjectRelativeLocation);
+
+ moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
+ WorkbenchComponent component = moduleCore.findWorkbenchModuleByDeployName(getComponentName());
+
+ ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component);
+ ComponentResource[] resources = root.findModuleResources(getRuntimePath(), false);
+
+ if(resources.length == 0) {
+ ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
+ componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
+ component.getResources().add(componentResource);
+ } else {
+ URI projectRelativeURI = URI.createURI(aProjectRelativeLocation.toString());
+ boolean foundMapping = false;
+ for (int resourceIndx = 0; resourceIndx < resources.length && !foundMapping; resourceIndx++) {
+ if(projectRelativeURI.equals(resources[resourceIndx].getSourcePath()))
+ foundMapping = true;
+ }
+ if(!foundMapping) {
+ ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
+ componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
+ component.getResources().add(componentResource);
+ }
+ }
+
+ } finally {
+ if (moduleCore != null) {
+ moduleCore.saveIfNecessary(monitor);
+ moduleCore.dispose();
+ }
+ }
+ }
+
public int getType() {
- return IResource.FILE;
+ return IVirtualResource.FILE;
}
- public IFile getRealFile() {
+ public IResource getUnderlyingResource() {
+ return getUnderlyingFile();
+ }
+
+ public IResource[] getUnderlyingResources() {
+ return getUnderlyingFiles();
+ }
+
+ public IFile getUnderlyingFile() {
return getProject().getFile(getProjectRelativePath());
}
- public IFile[] getRealFiles() {
- return new IFile[] {getRealFile()};
+ public IFile[] getUnderlyingFiles() {
+ return new IFile[] {getUnderlyingFile()};
}
protected void doDeleteMetaModel(int updateFlags,IProgressMonitor monitor) {
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFolder.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFolder.java
index 6664947..fd6ba7c 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFolder.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualFolder.java
@@ -8,35 +8,21 @@
**************************************************************************************************/
package org.eclipse.wst.common.modulecore.internal.resources;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.wst.common.modulecore.ComponentResource;
import org.eclipse.wst.common.modulecore.ModuleCore;
import org.eclipse.wst.common.modulecore.WorkbenchComponent;
-import org.eclipse.wst.common.modulecore.internal.impl.ResourceTreeRoot;
import org.eclipse.wst.common.modulecore.resources.IVirtualContainer;
import org.eclipse.wst.common.modulecore.resources.IVirtualFolder;
import org.eclipse.wst.common.modulecore.resources.IVirtualResource;
-public class VirtualFolder extends VirtualContainer implements IVirtualFolder {
-
- private final Set realFolders = new HashSet();
-
- public VirtualFolder(IFolder aRealFolder, String aComponentName, IPath aRuntimePath) {
-
- super(aRealFolder.getProject(), aComponentName, aRuntimePath);
- realFolders.add(aRealFolder);
- }
+public class VirtualFolder extends VirtualContainer implements IVirtualFolder {
/**
* <p>
@@ -67,66 +53,11 @@
// TODO WTP:Implement this method
public void create(int updateFlags, IProgressMonitor monitor) throws CoreException {
- IVirtualContainer container = ModuleCore.create(getProject(), getComponentHandle().getName());
- IVirtualFolder root = container.getFolder(new Path("/")); //$NON-NLS-1$
- IFolder realFolder = getProject().getFolder(root.getProjectRelativePath());
+ IVirtualContainer container = ModuleCore.createContainer(getProject(), getComponentHandle().getName());
+ IFolder realFolder = getProject().getFolder(container.getProjectRelativePath());
IFolder newFolder = realFolder.getFolder(getRuntimePath());
- createResource(newFolder, updateFlags, monitor);
-
- }
-
- /**
- * @see IFolder#createLink(org.eclipse.core.runtime.IPath, int,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
-
- ModuleCore moduleCore = null;
- try {
- IFolder resource = getProject().getFolder(aProjectRelativeLocation);
-
- moduleCore = ModuleCore.getModuleCoreForWrite(getProject());
- WorkbenchComponent component = moduleCore.findWorkbenchModuleByDeployName(getComponentHandle().getName());
-
- ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component);
- ComponentResource[] resources = root.findModuleResources(getRuntimePath(), false);
-
- if(resources.length == 0) {
- ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
- componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
- component.getResources().add(componentResource);
- } else {
- URI projectRelativeURI = URI.createURI(aProjectRelativeLocation.toString());
- boolean foundMapping = false;
- for (int resourceIndx = 0; resourceIndx < resources.length && !foundMapping; resourceIndx++) {
- if(projectRelativeURI.equals(resources[resourceIndx].getSourcePath()))
- foundMapping = true;
- }
- if(!foundMapping) {
- ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(resource);
- componentResource.setRuntimePath(URI.createURI(getRuntimePath().toString()));
- component.getResources().add(componentResource);
- }
- }
-
- createResource(resource, updateFlags, monitor);
-
- } finally {
- if (moduleCore != null) {
- moduleCore.saveIfNecessary(monitor);
- moduleCore.dispose();
- }
- }
- }
-
- private void createResource(IContainer resource, int updateFlags, IProgressMonitor monitor) throws CoreException {
-
- if (!resource.getParent().exists())
- createResource(resource.getParent(), updateFlags, monitor);
- if (!resource.exists())
- ((IFolder) resource).create(updateFlags, true, monitor);
-
- }
+ createResource(newFolder, updateFlags, monitor);
+ }
// TODO WTP:Implement this method
public boolean exists(IPath path) {
@@ -159,19 +90,23 @@
}
public int getType() {
- return IResource.FOLDER;
+ return IVirtualResource.FOLDER;
+ }
+
+ public IResource getUnderlyingResource() {
+ return getUnderlyingFolder();
+ }
+
+ public IResource[] getUnderlyingResources() {
+ return getUnderlyingFolders();
}
- public void commit() throws CoreException {
-
- }
-
- public IFolder getRealFolder() {
+ public IFolder getUnderlyingFolder() {
return getProject().getFolder(getProjectRelativePath());
}
- public IFolder[] getRealFolders() {
- return new IFolder[] {getRealFolder()};
+ public IFolder[] getUnderlyingFolders() {
+ return new IFolder[] {getUnderlyingFolder()};
}
protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) {
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualResource.java
index c9418ed..9d1e9a9 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualResource.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/internal/resources/VirtualResource.java
@@ -12,6 +12,8 @@
import java.util.Arrays;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxyVisitor;
@@ -31,12 +33,14 @@
public abstract class VirtualResource implements IVirtualResource {
+ protected static final IResource[] NO_RESOURCES = null;
private ComponentHandle componentHandle;
private IPath runtimePath;
private int hashCode;
private String toString;
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
protected VirtualResource(ComponentHandle aComponentHandle, IPath aRuntimePath) {
componentHandle = aComponentHandle;
runtimePath = aRuntimePath;
@@ -177,7 +181,7 @@
public IVirtualContainer getParent() {
if(getRuntimePath().segmentCount() > 0)
return new VirtualFolder(getComponentHandle(), getRuntimePath().removeLastSegments(1));
- return ModuleCore.create(getProject(), getComponentName());
+ return ModuleCore.createContainer(getProject(), getComponentName());
}
public IProject getProject() {
@@ -227,8 +231,17 @@
protected ComponentHandle getComponentHandle() {
return componentHandle;
}
+
+ protected void createResource(IContainer resource, int updateFlags, IProgressMonitor monitor) throws CoreException {
- private boolean isPotentalMatch(IPath aRuntimePath) {
+ if (!resource.getParent().exists())
+ createResource(resource.getParent(), updateFlags, monitor);
+ if (!resource.exists() && resource.getType() == IResource.FOLDER) {
+ ((IFolder) resource).create(updateFlags, true, monitor);
+ }
+ }
+
+ protected boolean isPotentalMatch(IPath aRuntimePath) {
return aRuntimePath.isPrefixOf(getRuntimePath());
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualContainer.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualContainer.java
index 1d9abf5..da10271 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualContainer.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualContainer.java
@@ -12,12 +12,15 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-
-public interface IVirtualContainer extends IVirtualResource {
-
- /*====================================================================
- * Constants defining which members are wanted:
- *====================================================================*/
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+/**
+ *
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IVirtualContainer extends IVirtualResource {
/**
* Returns whether a resource of some type with the given path
@@ -177,8 +180,7 @@
* @return the (handle of the) member folder
* @see #getFile(IPath)
*/
- public IVirtualFolder getFolder(IPath path);
-
+ public IVirtualFolder getFolder(IPath path);
/**
* Returns a handle to the file with the given name in this folder.
@@ -274,6 +276,83 @@
*/
public IVirtualResource[] members(int memberFlags) throws CoreException;
- public void commit() throws CoreException;
+ /**
+ * Create the underlying model elements if they do not already exist. Resources
+ * may be created as a result of this method if the mapped path does not exist.
+ *
+ * @param updateFlags Any of IVirtualResource or IResource update flags. If a
+ * resource must be created, the updateFlags will be supplied to the
+ * resource creation operation.
+ * @param aMonitor
+ * @throws CoreException
+ */
+ public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException;
+
+ /**
+ * Creates a new file resource as a member of this handle's parent resource.
+ * The file's contents will be located in the file specified by the given
+ * file system path. The given path must be either an absolute file system
+ * path, or a relative path whose first segment is the name of a workspace path
+ * variable.
+ * <p>
+ * The <code>ALLOW_MISSING_LOCAL</code> update flag controls how this
+ * method deals with cases where the local file system file to be linked does
+ * not exist, or is relative to a workspace path variable that is not defined.
+ * If <code>ALLOW_MISSING_LOCAL</code> is specified, the operation will suceed
+ * even if the local file is missing, or the path is relative to an undefined
+ * variable. If <code>ALLOW_MISSING_LOCAL</code> is not specified, the operation
+ * will fail in the case where the local file system file does not exist or the
+ * path is relative to an undefined variable.
+ * </p>
+ * <p>
+ * Update flags other than <code>ALLOW_MISSING_LOCAL</code> are ignored.
+ * </p>
+ * <p>
+ * This method synchronizes this resource with the local file system at the given
+ * location.
+ * </p>
+ * <p>
+ * This method changes resources; these changes will be reported
+ * in a subsequent resource change event, including an indication
+ * that the file has been added to its parent.
+ * </p>
+ * <p>
+ * This method is long-running; progress and cancellation are provided
+ * by the given progress monitor.
+ * </p>
+ *
+ * @param localLocation a file system path where the file should be linked
+ * @param updateFlags bit-wise or of update flag constants
+ * (only ALLOW_MISSING_LOCAL is relevant here)
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting is not desired
+ * @exception CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li> This resource already exists in the workspace.</li>
+ * <li> The workspace contains a resource of a different type
+ * at the same path as this resource.</li>
+ * <li> The parent of this resource does not exist.</li>
+ * <li> The parent of this resource is not an open project</li>
+ * <li> The name of this resource is not valid (according to
+ * <code>IWorkspace.validateName</code>).</li>
+ * <li> The corresponding location in the local file system does not exist, or
+ * is relative to an undefined variable, and <code>ALLOW_MISSING_LOCAL</code> is
+ * not specified.</li>
+ * <li> The corresponding location in the local file system is occupied
+ * by a directory (as opposed to a file).</li>
+ * <li> Resource changes are disallowed during certain types of resource change
+ * event notification. See <code>IVirtualResourceChangeEvent</code> for more details.</li>
+ * <li>The team provider for the project which contains this folder does not permit
+ * linked resources.</li>
+ * <li>This folder's project contains a nature which does not permit linked resources.</li>
+ * </ul>
+ * @exception OperationCanceledException if the operation is canceled.
+ * Cancelation can occur even if no progress monitor is provided.
+ * @see IVirtualResource#isLinked()
+ * @see IVirtualResource#ALLOW_MISSING_LOCAL
+ * @since 2.1
+ */
+ public void createLink(IPath aProjectRelativePath, int updateFlags, IProgressMonitor monitor) throws CoreException;
+
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFile.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFile.java
index b5971f4..25682ed 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFile.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFile.java
@@ -11,81 +11,16 @@
package org.eclipse.wst.common.modulecore.resources;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-
-public interface IVirtualFile extends IVirtualResource {
-
- /**
- * Creates a new file resource as a member of this handle's parent resource.
- * The file's contents will be located in the file specified by the given
- * file system path. The given path must be either an absolute file system
- * path, or a relative path whose first segment is the name of a workspace path
- * variable.
- * <p>
- * The <code>ALLOW_MISSING_LOCAL</code> update flag controls how this
- * method deals with cases where the local file system file to be linked does
- * not exist, or is relative to a workspace path variable that is not defined.
- * If <code>ALLOW_MISSING_LOCAL</code> is specified, the operation will suceed
- * even if the local file is missing, or the path is relative to an undefined
- * variable. If <code>ALLOW_MISSING_LOCAL</code> is not specified, the operation
- * will fail in the case where the local file system file does not exist or the
- * path is relative to an undefined variable.
- * </p>
- * <p>
- * Update flags other than <code>ALLOW_MISSING_LOCAL</code> are ignored.
- * </p>
- * <p>
- * This method synchronizes this resource with the local file system at the given
- * location.
- * </p>
- * <p>
- * This method changes resources; these changes will be reported
- * in a subsequent resource change event, including an indication
- * that the file has been added to its parent.
- * </p>
- * <p>
- * This method is long-running; progress and cancellation are provided
- * by the given progress monitor.
- * </p>
- *
- * @param localLocation a file system path where the file should be linked
- * @param updateFlags bit-wise or of update flag constants
- * (only ALLOW_MISSING_LOCAL is relevant here)
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @exception CoreException if this method fails. Reasons include:
- * <ul>
- * <li> This resource already exists in the workspace.</li>
- * <li> The workspace contains a resource of a different type
- * at the same path as this resource.</li>
- * <li> The parent of this resource does not exist.</li>
- * <li> The parent of this resource is not an open project</li>
- * <li> The name of this resource is not valid (according to
- * <code>IWorkspace.validateName</code>).</li>
- * <li> The corresponding location in the local file system does not exist, or
- * is relative to an undefined variable, and <code>ALLOW_MISSING_LOCAL</code> is
- * not specified.</li>
- * <li> The corresponding location in the local file system is occupied
- * by a directory (as opposed to a file).</li>
- * <li> Resource changes are disallowed during certain types of resource change
- * event notification. See <code>IVirtualResourceChangeEvent</code> for more details.</li>
- * <li>The team provider for the project which contains this folder does not permit
- * linked resources.</li>
- * <li>This folder's project contains a nature which does not permit linked resources.</li>
- * </ul>
- * @exception OperationCanceledException if the operation is canceled.
- * Cancelation can occur even if no progress monitor is provided.
- * @see IVirtualResource#isLinked()
- * @see IVirtualResource#ALLOW_MISSING_LOCAL
- * @since 2.1
- */
- public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException;
-
+/**
+ * Represents a file that can be navigated through
+ * an abstract ("virtual") path.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IVirtualFile extends IVirtualResource {
- public IFile getRealFile();
+ public IFile getUnderlyingFile();
- public IFile[] getRealFiles();
+ public IFile[] getUnderlyingFiles();
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFolder.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFolder.java
index 495545a..a03224a 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFolder.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualFolder.java
@@ -11,138 +11,16 @@
package org.eclipse.wst.common.modulecore.resources;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
+/**
+ * Represents a folder that can be navigated through
+ * an abstract ("virtual") path.
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ */
+public interface IVirtualFolder extends IVirtualContainer {
-public interface IVirtualFolder extends IVirtualContainer {
-
- /**
- * Creates a new folder resource as a member of this handle's parent resource.
- * <p>
- * The <code>FORCE</code> update flag controls how this method deals with
- * cases where the workspace is not completely in sync with the local file
- * system. If <code>FORCE</code> is not specified, the method will only attempt
- * to create a directory in the local file system if there isn't one already.
- * This option ensures there is no unintended data loss; it is the recommended
- * setting. However, if <code>FORCE</code> is specified, this method will
- * be deemed a success even if there already is a corresponding directory.
- * </p>
- * <p>
- * Update flags other than <code>FORCE</code> are ignored.
- * </p>
- * <p>
- * This method synchronizes this resource with the local file system.
- * </p>
- * <p>
- * This method changes resources; these changes will be reported
- * in a subsequent resource change event, including an indication
- * that the folder has been added to its parent.
- * </p>
- * <p>
- * This method is long-running; progress and cancellation are provided
- * by the given progress monitor.
- * </p>
- *
- * @param updateFlags bit-wise or of update flag constants
- * (only <code>FORCE</code> is relevant here)
- * @param local a flag controlling whether or not the folder will be local
- * after the creation
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @exception CoreException if this method fails. Reasons include:
- * <ul>
- * <li> This resource already exists in the workspace.</li>
- * <li> The workspace contains a resource of a different type
- * at the same path as this resource.</li>
- * <li> The parent of this resource does not exist.</li>
- * <li> The parent of this resource is a project that is not open.</li>
- * <li> The parent contains a resource of a different type
- * at the same path as this resource.</li>
- * <li> The name of this resource is not valid (according to
- * <code>IWorkspace.validateName</code>).</li>
- * <li> The corresponding location in the local file system is occupied
- * by a file (as opposed to a directory).</li>
- * <li> The corresponding location in the local file system is occupied
- * by a folder and <code>FORCE</code> is not specified.</li>
- * <li> Resource changes are disallowed during certain types of resource change
- * event notification. See <code>IVirtualResourceChangeEvent</code> for more details.</li>
- * </ul>
- * @exception OperationCanceledException if the operation is canceled.
- * Cancelation can occur even if no progress monitor is provided.
- * @see IVirtualResourceRuleFactory#createRule(IVirtualResource)
- * @since 2.0
- */
- public void create(int updateFlags, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Creates a new folder resource as a member of this handle's parent resource.
- * The folder's contents will be located in the directory specified by the given
- * file system path. The given path must be either an absolute file system
- * path, or a relative path whose first segment is the name of a workspace path
- * variable.
- * <p>
- * The <code>ALLOW_MISSING_LOCAL</code> update flag controls how this
- * method deals with cases where the local file system directory to be linked does
- * not exist, or is relative to a workspace path variable that is not defined.
- * If <code>ALLOW_MISSING_LOCAL</code> is specified, the operation will suceed
- * even if the local directory is missing, or the path is relative to an
- * undefined variable. If <code>ALLOW_MISSING_LOCAL</code> is not specified, the
- * operation will fail in the case where the local file system directory does
- * not exist or the path is relative to an undefined variable.
- * </p>
- * <p>
- * Update flags other than <code>ALLOW_MISSING_LOCAL</code> are ignored.
- * </p>
- * <p>
- * This method synchronizes this resource with the local file system at the given
- * location.
- * </p>
- * <p>
- * This method changes resources; these changes will be reported
- * in a subsequent resource change event, including an indication
- * that the folder has been added to its parent.
- * </p>
- * <p>
- * This method is long-running; progress and cancellation are provided
- * by the given progress monitor.
- * </p>
- *
- * @param localLocation a file system path where the folder should be linked
- * @param updateFlags bit-wise or of update flag constants
- * (only ALLOW_MISSING_LOCAL is relevant here)
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @exception CoreException if this method fails. Reasons include:
- * <ul>
- * <li> This resource already exists in the workspace.</li>
- * <li> The workspace contains a resource of a different type
- * at the same path as this resource.</li>
- * <li> The parent of this resource does not exist.</li>
- * <li> The parent of this resource is not an open project</li>
- * <li> The name of this resource is not valid (according to
- * <code>IWorkspace.validateName</code>).</li>
- * <li> The corresponding location in the local file system does not exist, or
- * is relative to an undefined variable, and <code>ALLOW_MISSING_LOCAL</code> is
- * not specified.</li>
- * <li> The corresponding location in the local file system is occupied
- * by a file (as opposed to a directory).</li>
- * <li> Resource changes are disallowed during certain types of resource change
- * event notification. See <code>IVirtualResourceChangeEvent</code> for more details.</li>
- * <li>The team provider for the project which contains this folder does not permit
- * linked resources.</li>
- * <li>This folder's project contains a nature which does not permit linked resources.</li>
- * </ul>
- * @exception OperationCanceledException if the operation is canceled.
- * Cancelation can occur even if no progress monitor is provided.
- * @see IVirtualResource#isLinked()
- * @see IVirtualResource#ALLOW_MISSING_LOCAL
- * @since 2.1
- */
- public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException;
-
- public IFolder getRealFolder();
+ public IFolder getUnderlyingFolder();
- public IFolder[] getRealFolders();
+ public IFolder[] getUnderlyingFolders();
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualReference.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualReference.java
new file mode 100644
index 0000000..fe70f4d
--- /dev/null
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualReference.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.common.modulecore.resources;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IVirtualReference {
+
+ public void create(int updateFlags, IProgressMonitor aMonitor);
+
+ public void setRuntimePath(IPath aRuntimePath);
+
+ public IPath getRuntimePath();
+
+ public void setDependencyType(int aDependencyType);
+
+ public int getDependencyType();
+
+
+
+}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualResource.java
index 0dcc87b..fba2463 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualResource.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/modulecore/resources/IVirtualResource.java
@@ -14,7 +14,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -45,7 +44,7 @@
* structures on disk, use {@link #IGNORE_UNDERLYING_RESOURCE}.
* </p>
* <p>
- * The following class is experimental until fully documented.
+ * This interface is not intended to be implemented by clients.
* </p>
*/
public interface IVirtualResource extends ISchedulingRule {
@@ -122,7 +121,19 @@
* <a href="IVirtualResource.html#references">documentation on references</a>
* for more information on why this flag is relevant.
*/
- public static final int IGNORE_UNDERLYING_RESOURCE = 0x400;
+ public static final int IGNORE_UNDERLYING_RESOURCE = 0x400;
+
+ /**
+ * Create a mapping from the supplied location to the runtime path of this
+ * virtual resource. Model changes will occur as a result of this method,
+ * and potentially resource-level creations as well.
+ *
+ * @param aProjectRelativeLocation
+ * @param updateFlags
+ * @param monitor
+ * @throws CoreException
+ */
+ public void createLink(IPath aProjectRelativeLocation, int updateFlags, IProgressMonitor monitor) throws CoreException;
/**
* Remove the resource from the flexible structure. Removing the resource could require
@@ -199,18 +210,12 @@
/**
- * Returns a relative path of the underlying resource with respect to its project. Returns the empty path
- * for projects and the workspace root.
+ * Returns a relative path of the underlying resource with respect to its project.
* <p>
* This is a resource handle operation; the resource need not exist. If this resource does
* exist, its path can be safely assumed to be valid.
* </p>
* <p>
- * A resource's project-relative path indicates the route from the project to the resource.
- * Within a workspace, there is exactly one such path for any given resource. The returned path
- * never has a trailing slash.
- * </p>
- * <p>
* Project-relative paths are recommended over absolute paths, since the former are not affected
* if the project is renamed.
* </p>
@@ -218,16 +223,22 @@
* @return the relative path of this resource with respect to its project
* @see #getWorkspaceRelativePath()
* @see #getProject()
- * @see Path#EMPTY
+ * @see IResource#getProjectRelativePath()
*/
public IPath getProjectRelativePath();
+ /**
+ * Returns the runtime path of this virtual resource. The runtime path
+ * is determined through the metamodel and represents the path that the
+ * underlying resource will be accessed at runtime.
+ *
+ * @return the runtime path of this virtual resource
+ */
public IPath getRuntimePath();
/**
- * Returns the name of this resource. The name of a resource is synonymous with the last segment
- * of its full (or project-relative) path for all resources other than the workspace root. The
- * workspace root's name is the empty string.
+ * Returns the name of this virtual resource. The name of a virtual resource
+ * is synonymous with the last segment of its runtime path.
* <p>
* This is a resource handle operation; the resource need not exist.
* </p>
@@ -235,17 +246,28 @@
* If this resource exists, its name can be safely assumed to be valid.
* </p>
*
- * @return the name of the resource
- * @see #getWorkspaceRelativePath()
- * @see #getProjectRelativePath()
+ * @return the name of the virtual resource
+ * @see #getRuntimePath()
*/
public String getName();
+ /**
+ * Returns the name of the component that contains this virtual resource.
+ * <p>
+ * Each virtual resource is contained by at least one component. A component
+ * represents a logical collection of files. If the underlying resource is
+ * contained by multiple components, then the component name returned by
+ * this method will be determined by how the virtual resource was created.
+ * For each virtual resource, the component name will be the same as the
+ * component name of the parent.
+ *
+ * @return the name of the component that contains the virtual resource
+ */
public String getComponentName();
/**
- * Returns the resource which is the parent of this resource, or <code>null</code> if it has
- * no parent (that is, this resource is the workspace root).
+ * Returns the virtual resource which contains this virtual resource, or <code>null</code> if it has
+ * no parent (that is, the virtual resource represents the root of the component).
* <p>
* The full path of the parent resource is the same as this resource's full path with the last
* segment removed.
@@ -255,15 +277,15 @@
* exist.
* </p>
*
- * @return the parent resource of this resource, or <code>null</code> if it has no parent
+ * @return the container of the virtual resource, or <code>null</code> if this virtual resource represents the root of the component
*/
public IVirtualContainer getParent();
/**
- * Returns the project which contains this resource. Returns itself for projects and
- * <code>null</code> for the workspace root.
+ * Returns the project which contains the component which contains this virtual resource.
* <p>
- * A resource's project is the one named by the first segment of its full path.
+ * The name of the project may not (and most likely will not) be referenced in the
+ * runtime path of this virtual path, but will be referenced by the workspace-relative path.
* </p>
* <p>
* This is a resource handle operation; neither the resource nor the resulting project need
@@ -276,13 +298,12 @@
/**
* Returns the type of this resource. The returned value will be one of <code>FILE</code>,
- * <code>FOLDER</code>, <code>PROJECT</code>, <code>ROOT</code>.
+ * <code>FOLDER</code>, <code>COMPONENT</code>
* <p>
* <ul>
* <li> All resources of type <code>FILE</code> implement <code>IVirtualFile</code>.</li>
* <li> All resources of type <code>FOLDER</code> implement <code>IVirtualFolder</code>.</li>
- * <li> All resources of type <code>PROJECT</code> implement <code>IProject</code>.</li>
- * <li> All resources of type <code>ROOT</code> implement <code>IWorkspaceRoot</code>.</li>
+ * <li> All resources of type <code>COMPONENT</code> implement <code>IVirtualContainer</code>.</li>
* </ul>
* </p>
* <p>
@@ -292,13 +313,37 @@
* @return the type of this resource
* @see #FILE
* @see #FOLDER
- * @see #PROJECT
- * @see #ROOT
+ * @see #COMPONENT
*/
public int getType();
+ /**
+ * A virtual resource is a representation of one or more Eclipse Platform resources.
+ * <p>
+ * Returns the "primary" underlying resource. The resource may or may not exist. The resource
+ * will be contained by the project returned by {@link #getProject()}.
+ * </p>
+ * <p>
+ * Since a virtual resource could represent multiple resources, this method will return
+ * the "primary" resource. For clients that wish to take advantage of the multiple resources
+ * at a single path, use {@link #getUnderlyingResources()}.
+ * @return The primary resource that backs this virtual resource.
+ */
public IResource getUnderlyingResource();
-
+
+ /**
+ * A virtual resource is a representation of one or more Eclipse Platform resources.
+ * <p>
+ * Returns all underlying resources. The resources may or may not exist. The resources
+ * will be contained by the project returned by {@link #getProject()}.
+ * </p>
+ * <p>
+ * Since a virtual resource could represent multiple resources, this method will return
+ * all underlying resources. For clients that prefer to acknowledge only one resource,
+ * at a single path, use {@link #getUnderlyingResource()}.
+ * @return All resources that back this virtual resource.
+ */
+ public IResource[] getUnderlyingResources();
/**
* Returns whether this resource is accessible. For files and folders, this is equivalent to