Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-02-28 11:01:17 -0500
committerJean Michel-Lemieux2002-02-28 11:01:17 -0500
commitff4ccf5556ccf7ab43228bc3ad82c443c07bd759 (patch)
tree8661dba2bc7db804ff002623844c38bb119794a2
parente117819dad8a376fb891f1355bb30dd9069035ae (diff)
downloadeclipse.platform.team-ff4ccf5556ccf7ab43228bc3ad82c443c07bd759.tar.gz
eclipse.platform.team-ff4ccf5556ccf7ab43228bc3ad82c443c07bd759.tar.xz
eclipse.platform.team-ff4ccf5556ccf7ab43228bc3ad82c443c07bd759.zip
refactoring IResource
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java102
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java47
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java38
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java61
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java145
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java82
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java2
14 files changed, 178 insertions, 337 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
index a63157e39..ea37f7bcb 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSException.java
@@ -13,114 +13,70 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.ccvs.core.CVSStatus;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
/**
- * This is an exception that is thrown by the cvs-adaptor
- * for vcm
- *
- * @see CoreExcpetion
+ * A checked expection representing a failure in the CVS plugin.
+ * <p>
+ * CVS exceptions contain a status object describing the cause of
+ * the exception.
+ * </p>
+ *
+ * @see IStatus
*/
-
public class CVSException extends TeamException {
-
- public CVSException(
- int severity,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(new ResourceStatus(severity, code, path, message, exception));
- }
- public CVSException(
- int severity,
- int code,
- IPath path,
- String message) {
- this(severity, code, path, message, null);
- }
- public CVSException(
- int severity,
- int code,
- IPath path,
- Throwable exception) {
- this(severity, code, path, null, exception);
- }
- public CVSException(
- int severity,
- int code,
- String message,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, message, null));
+
+ /*
+ * Helpers for creating CVS exceptions
+ */
+ public CVSException(int severity, int code, String message, Exception e) {
+ super(new CVSStatus(severity, code, message, null));
}
- public CVSException(
- int severity,
- int code,
- String message) {
+
+ public CVSException(int severity, int code, String message) {
this(severity, code, message, null);
}
- public CVSException(
- int severity,
- int code,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, null, e));
-
- }
-
public CVSException(String message) {
- super(new Status(IStatus.ERROR, CVSProviderPlugin.ID, UNABLE, message, null));
+ super(new CVSStatus(IStatus.ERROR, UNABLE, message, null));
}
- public CVSException(String message, IPath path) {
- this(message, path, null);
- }
-
public CVSException(String message, Exception e) {
this(IStatus.ERROR, UNABLE, message, e);
}
public CVSException(String message, IPath path, Throwable throwable) {
- this(new ResourceStatus(IStatus.ERROR, path, message, throwable));
+ this(new CVSStatus(IStatus.ERROR, path, message, throwable));
}
+
public CVSException(IStatus status) {
super(status);
}
-
+
/*
* Static helper methods for creating exceptions
*/
- public static CVSException wrapException(IResource resource, String message,IOException e) {
+ public static CVSException wrapException(
+ IResource resource,
+ String message,
+ IOException e) {
// NOTE: we should record the resource somehow
// We should also inlcude the IO message
- return new CVSException(new Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- IO_FAILED,
- message,
- e));
+ return new CVSException(new CVSStatus(IStatus.ERROR, IO_FAILED, message, e));
}
+
/*
* Static helper methods for creating exceptions
*/
public static CVSException wrapException(IResource resource, String message, CoreException e) {
- return new CVSException(new Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- UNABLE,
- message,
- e));
+ return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, message, e));
}
+
/*
* Static helper methods for creating exceptions
*/
public static CVSException wrapException(Exception e) {
- return new CVSException(new Status(
- IStatus.ERROR,
- CVSProviderPlugin.ID,
- UNABLE,
- e.getMessage() != null ? e.getMessage() : "", //$NON-NLS-1$
- e));
+ return new CVSException(new CVSStatus(IStatus.ERROR, UNABLE, e.getMessage() != null ? e.getMessage() : "", e)); //$NON-NLS-1$
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
index b9889d438..f12a519cb 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
@@ -970,10 +970,6 @@ public class CVSTeamProvider implements ITeamNature, ITeamProvider {
return new TeamException(statusFor(e));
}
- public static TeamException wrapException(CVSException e, List errors) {
- // NOTE: Need to find out how to pass MultiStatus. Is it up to me to subclass?
- return e;
- }
private static IStatus statusFor(CoreException e) {
// We should be taking out any status from the CVSException
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
index 3a8495bc1..1991e57d0 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/CVSServerException.java
@@ -57,7 +57,7 @@ public class CVSServerException extends CVSException {
if (children.length > 0) {
return new CVSServerException(message, children);
} else {
- return new CVSServerException(new Status(IStatus.ERROR, CVSProviderPlugin.ID, CVSStatus.SERVER_ERROR, message, null));
+ return new CVSServerException(new CVSStatus(IStatus.ERROR, CVSStatus.SERVER_ERROR, message, null));
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java
deleted file mode 100644
index cf07cb05b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/ResourceStatus.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.connection;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-/**
- *
- */
-public class ResourceStatus extends Status {
-
- private IPath path;
-
-
- public ResourceStatus(
- int type,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(type, CVSProviderPlugin.ID, code, message, exception);
- this.path = path;
- }
- public ResourceStatus(int code, String message) {
- this(getSeverity(code), code, null, message, null);
- }
- public ResourceStatus(int code, IPath path, String message) {
- this(getSeverity(code), code, path, message, null);
- }
- public ResourceStatus(
- int code,
- IPath path,
- String message,
- Throwable exception) {
- this(getSeverity(code), code, path, message, exception);
- }
- public IPath getPath() {
- return path;
- }
- protected static int getSeverity(int code) {
- return code;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java
index e1438007c..2b1f23a81 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSFileNotFoundException.java
@@ -5,13 +5,8 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
/**
* This exception represents the attemp to access a file/folder
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
index f804e2f0b..43c8f92fd 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
@@ -5,36 +5,23 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import java.io.File;
-
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.core.sync.ILocalSyncElement;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.LocalSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProvider;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
public class CVSLocalSyncElement extends LocalSyncElement {
- protected ICVSResource cvsResource;
protected IRemoteResource base;
protected IResource local;
public CVSLocalSyncElement(IResource local, IRemoteResource base) {
-
this.local = local;
- this.base = base;
-
- if(local.getType() != IResource.FILE) {
- this.cvsResource = new EclipseFolder(local);
- } else {
- this.cvsResource = new EclipseFile(local);
- }
+ this.base = base;
}
/*
@@ -62,6 +49,7 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* @see ILocalSyncElement#isDirty()
*/
public boolean isDirty() {
+ ICVSResource cvsResource = getCVSResourceFor(getLocal());
if(cvsResource == null) {
return false;
} else {
@@ -94,14 +82,14 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* @see ILocalSyncElement#isCheckedOut()
*/
public boolean isCheckedOut() {
- return cvsResource != null;
+ return getLocal() != null;
}
/*
* @see ILocalSyncElement#hasRemote()
*/
public boolean hasRemote() {
- return cvsResource != null;
+ return getLocal() != null;
}
/*
@@ -115,12 +103,14 @@ public class CVSLocalSyncElement extends LocalSyncElement {
* Answers the CVS resource for this sync element
*/
public ICVSResource getCVSResource() {
- return cvsResource;
+ return getCVSResourceFor(getLocal());
}
+
/*
* @see LocalSyncElement#isIgnored(IResource)
*/
protected boolean isIgnored(IResource child) {
+ ICVSResource cvsResource = getCVSResourceFor(getLocal());
if(cvsResource==null || !cvsResource.isFolder() ) {
return false;
} else {
@@ -132,4 +122,12 @@ public class CVSLocalSyncElement extends LocalSyncElement {
}
}
}
+
+ private ICVSResource getCVSResourceFor(IResource resource) {
+ if(resource.getType() != IResource.FILE) {
+ return new EclipseFolder((IContainer)resource);
+ } else {
+ return new EclipseFile((IFile)resource);
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
index 15313538e..bd5d77de3 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
@@ -5,10 +5,8 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -16,31 +14,29 @@ import java.text.ParseException;
import java.util.Date;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
-import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* Represents handles to CVS resource on the local file system. Synchronization
* information is taken from the CVS subdirectories.
- *
- * @see LocalFolder
- * @see LocalFile
*/
public class EclipseFile extends EclipseResource implements ICVSFile {
/**
* Create a handle based on the given local resource.
*/
- public EclipseFile(IFile file) {
+ protected EclipseFile(IFile file) {
super(file);
}
- public long getSize() {
+ public long getSize() {
+ return getIOFile().length();
}
public InputStream getInputStream() throws CVSException {
@@ -52,6 +48,16 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
}
public OutputStream getOutputStream() throws CVSException {
+ return new ByteArrayOutputStream() {
+ public void close() throws IOException {
+ try {
+ getIFile().setContents(new ByteArrayInputStream(toByteArray()), true /*force*/, true /*keep history*/, null);
+ super.close();
+ } catch(CoreException e) {
+ throw new IOException("Error setting file contents: " + e.getMessage());
+ }
+ }
+ };
}
/*
@@ -125,27 +131,10 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
* This is to be used by the Copy handler. The filename of the form .#filename
*/
public void moveTo(String filename) throws CVSException {
- getIFile().m
-
- // Move the file to newFile (we know we do not need the
- // original any more anyway)
- // If this file exists then overwrite it
- LocalFile file;
try {
- file = (LocalFile)getParent().getFile(filename);
- } catch(ClassCastException e) {
- throw CVSException.wrapException(e);
- }
-
- // We are deleting the old .#filename if it exists
- if (file.exists()) {
- file.delete();
- }
-
- boolean success = ioResource.renameTo(file.getFile());
-
- if (!success) {
- throw new CVSException(Policy.bind("LocalFile.moveFailed", ioResource.toString(), file.toString())); //$NON-NLS-1$
+ getIFile().move(new Path(filename), true /*force*/, true /*keep history*/, null);
+ } catch(CoreException e) {
+ throw new CVSException(e.getStatus());
}
}
@@ -163,13 +152,17 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
CVSProviderPlugin.getSynchronizer().deleteResourceSync(getIOFile());
}
- private IFile getIFile() {
- return (IFile)resource;
- }
/*
* @see ICVSFile#setReadOnly()
*/
public void setReadOnly(boolean readOnly) throws CVSException {
getIFile().setReadOnly(readOnly);
}
+
+ /*
+ * Typecasting helper
+ */
+ private IFile getIFile() {
+ return (IFile)resource;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
index 1280928b6..2c144d9b2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
@@ -5,19 +5,19 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import java.io.File;
-import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IContainer;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
@@ -29,7 +29,7 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
*/
public class EclipseFolder extends EclipseResource implements ICVSFolder {
- public EclipseFolder(IContainer container) {
+ protected EclipseFolder(IContainer container) {
super(container);
}
@@ -38,66 +38,72 @@ public class EclipseFolder extends EclipseResource implements ICVSFolder {
* @see ICVSFolder#getFolders()
*/
public ICVSFolder[] getFolders() throws CVSException {
-
- IContainer folder = (IContainer)resource;
-
- if(!resource.exists()) {
- return new ICVSFolder[0];
- }
-
- final List folders = new ArrayList();
-
- ResourceSyncInfo[] syncDirs = CVSProviderPlugin.getSynchronizer().members(getIOFile());
- for (int i = 0; i < syncDirs.length; i++) {
- if(syncDirs[i].isDirectory()) {
- folders.add(new EclipseFolder(folder.getFolder(new Path(syncDirs[i].getName()))));
- }
- }
-
- IResource[] members = folder.members();
- for (int i = 0; i < members.length; i++) {
- IResource child = members[i];
- if(child.getType()!=IResource.FILE) {
- EclipseFolder childFolder = new EclipseFolder(child);
- if(!childFolder.isIgnored() && !folders.contains(childFolder)) {
- folders.add(childFolder);
- }
+ try {
+ IContainer folder = (IContainer)resource;
+
+ if(!resource.exists()) {
+ return new ICVSFolder[0];
}
+
+ final List folders = new ArrayList();
+
+ ResourceSyncInfo[] syncDirs = CVSProviderPlugin.getSynchronizer().members(getIOFile());
+ for (int i = 0; i < syncDirs.length; i++) {
+ if(syncDirs[i].isDirectory()) {
+ folders.add(new EclipseFolder(folder.getFolder(new Path(syncDirs[i].getName()))));
+ }
+ }
+
+ IResource[] members = folder.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource child = members[i];
+ if(child.getType()!=IResource.FILE) {
+ EclipseFolder childFolder = new EclipseFolder((IContainer)child);
+ if(!childFolder.isIgnored() && !folders.contains(childFolder)) {
+ folders.add(childFolder);
+ }
+ }
+ }
+ return (ICVSFolder[]) folders.toArray(new ICVSFolder[folders.size()]);
+ } catch(CoreException e) {
+ throw new CVSException(e.getStatus());
}
- return (ICVSFolder[]) folders.toArray(new ICVSFolder[folders.size()]);
}
/**
* @see ICVSFolder#getFiles()
*/
public ICVSFile[] getFiles() throws CVSException {
-
- IContainer folder = (IContainer)resource;
-
- if(!resource.exists()) {
- return new ICVSFolder[0];
- }
-
- final List files = new ArrayList();
-
- ResourceSyncInfo[] syncFiles = CVSProviderPlugin.getSynchronizer().members(getIOFile());
- for (int i = 0; i < syncFiles.length; i++) {
- if(!syncFiles[i].isDirectory()) {
- files.add(new EclipseFolder(folder.getFile(new Path(syncFiles[i].getName()))));
- }
- }
-
- IResource[] members = folder.members();
- for (int i = 0; i < members.length; i++) {
- IResource child = members[i];
- if(child.getType()==IResource.FILE) {
- EclipseFolder childFile = new EclipseFile(child);
- if(!childFile.isIgnored() && !files.contains(childFile)) {
- files.add(childFile);
- }
+ try {
+ IContainer folder = (IContainer)resource;
+
+ if(!resource.exists()) {
+ return new ICVSFile[0];
+ }
+
+ final List files = new ArrayList();
+
+ ResourceSyncInfo[] syncFiles = CVSProviderPlugin.getSynchronizer().members(getIOFile());
+ for (int i = 0; i < syncFiles.length; i++) {
+ if(!syncFiles[i].isDirectory()) {
+ files.add(new EclipseFile((IFile)folder.getFile(new Path(syncFiles[i].getName()))));
+ }
}
- }
- return (ICVSFile[]) files.toArray(new ICVSFile[files.size()]);
+
+ IResource[] members = folder.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource child = members[i];
+ if(child.getType()==IResource.FILE) {
+ EclipseFile childFile = new EclipseFile((IFile)child);
+ if(!childFile.isIgnored() && !files.contains(childFile)) {
+ files.add(childFile);
+ }
+ }
+ }
+ return (ICVSFile[]) files.toArray(new ICVSFile[files.size()]);
+ } catch(CoreException e) {
+ throw new CVSException(e.getStatus());
+ }
}
/**
@@ -120,11 +126,15 @@ public class EclipseFolder extends EclipseResource implements ICVSFolder {
* @see ICVSFolder#mkdir()
*/
public void mkdir() throws CVSException {
- if(resource.getType()==IResource.PROJECT) {
- ((IProject)resource).create(null);
- } else {
- ((IFolder)resource).create(false /*don't force*/, true /*make local*/, null);
- }
+ try {
+ if(resource.getType()==IResource.PROJECT) {
+ ((IProject)resource).create(null);
+ } else {
+ ((IFolder)resource).create(false /*don't force*/, true /*make local*/, null);
+ }
+ } catch (CoreException e) {
+ throw new CVSException(e.getStatus());
+ }
}
/**
@@ -225,4 +235,19 @@ public class EclipseFolder extends EclipseResource implements ICVSFolder {
}
return super.isIgnored();
}
+
+ /*
+ * @see ICVSFolder#getChild(String)
+ */
+ public ICVSResource getChild(String path) throws CVSException {
+ IResource child = ((IContainer)resource).findMember(path);
+ if(child!=null) {
+ if(child.getType()==IResource.FILE) {
+ return new EclipseFile((IFile)child);
+ } else {
+ return new EclipseFolder((IContainer)child);
+ }
+ }
+ return null;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
index 8cb648ed2..63907f38f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
@@ -9,6 +9,7 @@ import java.io.File;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.core.IIgnoreInfo;
import org.eclipse.team.core.TeamPlugin;
@@ -44,7 +45,7 @@ public abstract class EclipseResource implements ICVSResource {
/*
* Creates a CVS handle to the provided resource
*/
- public EclipseResource(IResource resource) {
+ protected EclipseResource(IResource resource) {
Assert.isNotNull(resource);
this.resource = resource;
}
@@ -56,7 +57,7 @@ public abstract class EclipseResource implements ICVSResource {
*/
public String getRelativePath(ICVSFolder root) throws CVSException {
try {
- LocalResource rootFolder;
+ EclipseResource rootFolder;
String result;
rootFolder = (EclipseResource)root;
result = Util.getRelativePath(rootFolder.getPath(), getPath());
@@ -69,8 +70,12 @@ public abstract class EclipseResource implements ICVSResource {
/*
* @see ICVSResource#delete()
*/
- public void delete() {
- resource.delete(true /*force*/, null);
+ public void delete() throws CVSException {
+ try {
+ resource.delete(true /*force*/, null);
+ } catch(CoreException e) {
+ throw new CVSException(e.getStatus());
+ }
}
/*
@@ -180,7 +185,7 @@ public abstract class EclipseResource implements ICVSResource {
* @see ICVSResource#getPath()
*/
public String getPath() {
- return resource.getFullPath();
+ return resource.getFullPath().toString();
}
/*
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
index ce8c55128..95f647ca7 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
@@ -34,7 +34,7 @@ public class LocalFile extends LocalResource implements ICVSFile {
/**
* Create a handle based on the given local resource.
*/
- public LocalFile(File file) {
+ protected LocalFile(File file) {
super(file);
}
@@ -58,8 +58,10 @@ public class LocalFile extends LocalResource implements ICVSFile {
}
}
- public void setReadOnly() throws CVSException {
- ioResource.setReadOnly();
+ public void setReadOnly(boolean readOnly) throws CVSException {
+ if(readOnly) {
+ ioResource.setReadOnly();
+ }
}
public String getTimeStamp() throws CVSFileNotFoundException {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java
index 4c689b834..9911a74b2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFolder.java
@@ -25,7 +25,7 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
*/
public class LocalFolder extends LocalResource implements ICVSFolder {
- public LocalFolder(File ioResource) {
+ protected LocalFolder(File ioResource) {
super(ioResource);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
index e3b2a06b6..b619a8650 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
@@ -42,7 +42,7 @@ public abstract class LocalResource implements ICVSResource {
/**
* A local handle
*/
- public LocalResource(File ioResource) {
+ protected LocalResource(File ioResource) {
Assert.isNotNull(ioResource);
this.ioResource = ioResource;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java
deleted file mode 100644
index c5a4ee972..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/NotCVSFolderException.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.resources;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.connection.ResourceStatus;
-
-/**
- * This Exception indicates that you have tried to call
- * a CVSFolder-Specific function on a folder that is not
- * (yet) a cvs-folder.
- */
-public class NotCVSFolderException extends CVSException {
-
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- String message,
- Throwable exception) {
- super(new ResourceStatus(severity, code, path, message, exception));
- }
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- String message) {
- this(severity, code, path, message, null);
- }
- public NotCVSFolderException(
- int severity,
- int code,
- IPath path,
- Throwable exception) {
- this(severity, code, path, null, exception);
- }
- public NotCVSFolderException(
- int severity,
- int code,
- String message,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, message, null));
- }
- public NotCVSFolderException(
- int severity,
- int code,
- String message) {
- this(severity, code, message, null);
- }
-
- public NotCVSFolderException(
- int severity,
- int code,
- Exception e) {
- super(new Status(severity, CVSProviderPlugin.ID, code, null, e));
-
- }
-
- public NotCVSFolderException(String message) {
- super(new Status(IStatus.ERROR, CVSProviderPlugin.ID, IStatus.ERROR, message, null));
- }
-
- public NotCVSFolderException(String message, IPath path) {
- this(message, path, null);
- }
-
- public NotCVSFolderException(String message, IPath path, Throwable throwable) {
- this(new ResourceStatus(IStatus.ERROR, path, message, throwable));
- }
- public NotCVSFolderException(IStatus status) {
- super(status);
- }
-}
-
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index 8fea7a8a4..ebc2f958c 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -320,7 +320,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
};
}
- public void setReadOnly() throws CVSException {
+ public void setReadOnly(boolean readOnly) throws CVSException {
}
/**

Back to the top