Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-04-17 14:23:48 +0000
committerJean Michel-Lemieux2002-04-17 14:23:48 +0000
commit127b4e9e279f024cfbc9e48d150ee9eff1ee5c53 (patch)
treee91418ee6c223079d2b1fb88333d3218abed3a85
parentdc4e7cdea235a92cbd4ac065443045de16caa93a (diff)
downloadeclipse.platform.team-127b4e9e279f024cfbc9e48d150ee9eff1ee5c53.tar.gz
eclipse.platform.team-127b4e9e279f024cfbc9e48d150ee9eff1ee5c53.tar.xz
eclipse.platform.team-127b4e9e279f024cfbc9e48d150ee9eff1ee5c53.zip
Removed copied code to compute resource dirty state.
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java67
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java76
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java51
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java54
6 files changed, 82 insertions, 172 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
index 4acf934e7..322d56cb8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
@@ -127,7 +127,7 @@ public class CVSDecorationRunnable implements Runnable {
boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
int type = resource.getType();
if(type == IResource.FILE || computeDeepDirtyCheck) {
- isDirty = isDirty(resource);
+ isDirty = CVSDecorator.isDirty(resource);
}
// compute decorations
@@ -257,69 +257,4 @@ public class CVSDecorationRunnable implements Runnable {
return overlays;
}
}
-
- private boolean isDirty(ICVSFile cvsFile) {
- try {
- // file is dirty or file has been merged by an update
- if(!cvsFile.isIgnored()) {
- return cvsFile.isModified();
- } else {
- return false;
- }
- } catch (CVSException e) {
- //if we get an error report it to the log but assume dirty
- CVSUIPlugin.log(e.getStatus());
- return true;
- }
- }
-
- private boolean isDirty(IFile file) {
- return isDirty(CVSWorkspaceRoot.getCVSFileFor(file));
- }
-
- private boolean isDirty(IResource resource) {
- if(resource.getType() == IResource.FILE) {
- return isDirty((IFile) resource);
- }
-
- final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null)); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
-
- // a project can't be dirty, continue with its children
- if (resource.getType() == IResource.PROJECT) {
- return true;
- }
-
- // if the resource does not exist in the workbench or on the file system, stop searching.
- if(!resource.exists()) {
- return false;
- }
-
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
-
- if (!cvsResource.isManaged()) {
- if (cvsResource.isIgnored()) {
- return false;
- } else {
- // new resource, show as dirty
- throw DECORATOR_EXCEPTION;
- }
- }
- if (!cvsResource.isFolder()) {
- if(isDirty((ICVSFile) cvsResource)) {
- throw DECORATOR_EXCEPTION;
- }
- }
- // no change -- keep looking in children
- return true;
- }
- }, IResource.DEPTH_INFINITE, true);
- } catch (CoreException e) {
- //if our exception was caught, we know there's a dirty child
- return e == DECORATOR_EXCEPTION;
- }
- return false;
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
index 87c974b40..b3aaa19ae 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
@@ -14,6 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -24,18 +25,24 @@ import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.core.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.ui.internal.DecoratorDefinition;
import org.eclipse.ui.internal.DecoratorManager;
import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -273,8 +280,7 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
/*
* Return the ILabelDecorator for our CVS decorator, null if its not active.
- */
-
+ */
private static ILabelDecorator findCVSDecorator() {
DecoratorManager decoratorManager = WorkbenchPlugin.getDefault().getDecoratorManager();
DecoratorDefinition[] definitions = decoratorManager.getDecoratorDefinitions();
@@ -440,5 +446,69 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
// refresh the decorators in the resource delta listener
deconfiguredProjects.add(project);
}
+
+ public static boolean isDirty(ICVSFile cvsFile) {
+ try {
+ // file is dirty or file has been merged by an update
+ if(!cvsFile.isIgnored()) {
+ return cvsFile.isModified();
+ } else {
+ return false;
+ }
+ } catch (CVSException e) {
+ //if we get an error report it to the log but assume dirty
+ CVSUIPlugin.log(e.getStatus());
+ return true;
+ }
+ }
+
+ public static boolean isDirty(IFile file) {
+ return isDirty(CVSWorkspaceRoot.getCVSFileFor(file));
+ }
+
+ public static boolean isDirty(IResource resource) {
+ if(resource.getType() == IResource.FILE) {
+ return isDirty((IFile) resource);
+ }
+
+ final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null)); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ resource.accept(new IResourceVisitor() {
+ public boolean visit(IResource resource) throws CoreException {
+
+ // a project can't be dirty, continue with its children
+ if (resource.getType() == IResource.PROJECT) {
+ return true;
+ }
+
+ // if the resource does not exist in the workbench or on the file system, stop searching.
+ if(!resource.exists()) {
+ return false;
+ }
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+
+ if (!cvsResource.isManaged()) {
+ if (cvsResource.isIgnored()) {
+ return false;
+ } else {
+ // new resource, show as dirty
+ throw DECORATOR_EXCEPTION;
+ }
+ }
+ if (!cvsResource.isFolder()) {
+ if(isDirty((ICVSFile) cvsResource)) {
+ throw DECORATOR_EXCEPTION;
+ }
+ }
+ // no change -- keep looking in children
+ return true;
+ }
+ }, IResource.DEPTH_INFINITE, true);
+ } catch (CoreException e) {
+ //if our exception was caught, we know there's a dirty child
+ return e == DECORATOR_EXCEPTION;
+ }
+ return false;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
index fbcfacc2f..ce65c3878 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithAction.java
@@ -21,56 +21,7 @@ import org.eclipse.team.ui.actions.TeamAction;
public abstract class ReplaceWithAction extends TeamAction {
private boolean confirmOverwrite = true;
-
- /**
- * Copied from CVSDecorationRunnable
- */
- protected boolean isDirty(IResource resource) {
- final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null)); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
-
- // a project can't be dirty, continue with its children
- if (resource.getType() == IResource.PROJECT) {
- return true;
- }
-
- // if the resource does not exist in the workbench or on the file system, stop searching.
- if(!resource.exists()) {
- return false;
- }
-
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- try {
- if (!cvsResource.isManaged()) {
- if (cvsResource.isIgnored()) {
- return false;
- } else {
- // new resource, show as dirty
- throw DECORATOR_EXCEPTION;
- }
- }
- if (!cvsResource.isFolder()) {
- if (((ICVSFile) cvsResource).isModified()) {
- // file has changed, show as dirty
- throw DECORATOR_EXCEPTION;
- }
- }
- } catch (CVSException e) {
- return true;
- }
- // no change -- keep looking in children
- return true;
- }
- }, IResource.DEPTH_INFINITE, true);
- } catch (CoreException e) {
- //if our exception was caught, we know there's a dirty child
- return e == DECORATOR_EXCEPTION;
- }
- return false;
- }
-
+
/**
* The user is attempting to load a project that already exists in
* the workspace. Prompt the user to confirm overwrite and return
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
index f59f7f36e..5a9f94bee 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
@@ -20,6 +20,7 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -33,7 +34,7 @@ public class ReplaceWithRemoteAction extends ReplaceWithAction {
List targetResources = new ArrayList();
for (int i = 0; i < candidateResources.length; i++) {
IResource resource = candidateResources[i];
- if (isDirty(resource) && getConfirmOverwrite()) {
+ if (CVSDecorator.isDirty(resource) && getConfirmOverwrite()) {
if (confirmOverwrite(Policy.bind("ReplaceWithRemoteAction.localChanges", resource.getName()))) { //$NON-NLS-1$
targetResources.add(resource);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
index de5a9e7c1..07df54e86 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
@@ -29,6 +29,7 @@ import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -52,7 +53,7 @@ public class ReplaceWithTagAction extends ReplaceWithAction {
final IResource[] resources = getSelectedResources();
boolean isAnyDirty = false;
for (int i = 0; i < resources.length; i++) {
- if(isDirty(resources[i])) {
+ if(CVSDecorator.isDirty(resources[i])) {
isAnyDirty = true;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
index b499067f1..7bb5f7a40 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
@@ -39,6 +39,7 @@ import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.ui.CVSDecorator;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.actions.TeamAction;
@@ -50,55 +51,6 @@ public class TagAction extends TeamAction {
// The previously remembered tag
private static String previousTag = ""; //$NON-NLS-1$
- /**
- * Copied from CVSDecorationRunnable
- */
- protected boolean isDirty(IResource resource) {
- final CoreException DECORATOR_EXCEPTION = new CoreException(new Status(IStatus.OK, "id", 1, "", null)); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- resource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
-
- // a project can't be dirty, continue with its children
- if (resource.getType() == IResource.PROJECT) {
- return true;
- }
-
- // if the resource does not exist in the workbench or on the file system, stop searching.
- if (!resource.exists()) {
- return false;
- }
-
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- try {
- if (!cvsResource.isManaged()) {
- if (cvsResource.isIgnored()) {
- return false;
- } else {
- // new resource, show as dirty
- throw DECORATOR_EXCEPTION;
- }
- }
- if (!cvsResource.isFolder()) {
- if (((ICVSFile) cvsResource).isModified()) {
- // file has changed, show as dirty
- throw DECORATOR_EXCEPTION;
- }
- }
- } catch (CVSException e) {
- return true;
- }
- // no change -- keep looking in children
- return true;
- }
- }, IResource.DEPTH_INFINITE, true);
- } catch (CoreException e) {
- //if our exception was caught, we know there's a dirty child
- return e == DECORATOR_EXCEPTION;
- }
- return false;
- }
-
/*
* @see IActionDelegate#run(IAction)
*/
@@ -110,7 +62,7 @@ public class TagAction extends TeamAction {
final IResource[] resources = getSelectedResources();
boolean isAnyDirty = false;
for (int i = 0; i < resources.length; i++) {
- if(isDirty(resources[i])) {
+ if(CVSDecorator.isDirty(resources[i])) {
isAnyDirty = true;
}
}
@@ -135,7 +87,7 @@ public class TagAction extends TeamAction {
if (result[0] == null) return;
Hashtable table = getProviderMapping();
Set keySet = table.keySet();
- monitor.beginTask("", keySet.size() * 1000); //$NON-NLS-1$
+ monitor.beginTask(null, keySet.size() * 1000);
Iterator iterator = keySet.iterator();
while (iterator.hasNext()) {

Back to the top