Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-06-10 17:32:45 -0400
committerJean Michel-Lemieux2004-06-10 17:32:45 -0400
commitff28fb03d73498bbac2bf5afca550a468186341f (patch)
tree4ae83d2c51078e3ee7416486914ec48b43d569aa /examples
parent76f1b89e5e9336bd3d1fad4591cac9b80ddaa5af (diff)
downloadeclipse.platform.team-ff28fb03d73498bbac2bf5afca550a468186341f.tar.gz
eclipse.platform.team-ff28fb03d73498bbac2bf5afca550a468186341f.tar.xz
eclipse.platform.team-ff28fb03d73498bbac2bf5afca550a468186341f.zip
updated validateEdit test scenarios and example
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java61
1 files changed, 59 insertions, 2 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
index 554b9a480..57b9463ab 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
@@ -8,7 +8,6 @@ package org.eclipse.team.examples.pessimistic;
import java.io.*;
import java.util.*;
-
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -568,7 +567,14 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
boolean change= preferences.getBoolean(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT);
if (change) {
try {
- resource.touch(null);
+ if(resource.getType() == IResource.FILE) {
+ try {
+ appendText((IFile)resource, getRandomSnippet(), false);
+ } catch (IOException e1) {
+ }
+ } else {
+ resource.touch(null);
+ }
} catch (CoreException e) {
PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problems touching resource: " + resource);
}
@@ -576,6 +582,57 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
return change;
}
+ public void appendText(IFile file, String text, boolean prepend) throws CoreException, IOException {
+ String contents = getFileContents(file);
+ StringBuffer buffer = new StringBuffer();
+ if (prepend) {
+ buffer.append(text);
+ }
+ buffer.append(contents);
+ if (!prepend) {
+ buffer.append(System.getProperty("line.separator") + text);
+ }
+ file.setContents(new ByteArrayInputStream(buffer.toString().getBytes()), false, false, null);
+ }
+
+ public static String getFileContents(IFile file) throws IOException, CoreException {
+ StringBuffer buf = new StringBuffer();
+ Reader reader = new InputStreamReader(new BufferedInputStream(file.getContents()));
+ try {
+ int c;
+ while ((c = reader.read()) != -1) buf.append((char)c);
+ } finally {
+ reader.close();
+ }
+ return buf.toString();
+ }
+
+ public static String getRandomSnippet() {
+ switch ((int) Math.round(Math.random() * 10)) {
+ case 0 :
+ return "este e' o meu conteudo (portuguese)";
+ case 1 :
+ return "Dann brauchen wir aber auch einen deutschen Satz!";
+ case 2 :
+ return "I'll be back";
+ case 3 :
+ return "don't worry, be happy";
+ case 4 :
+ return "there is no imagination for more sentences";
+ case 5 :
+ return "customize yours";
+ case 6 :
+ return "foo";
+ case 7 :
+ return "bar";
+ case 8 :
+ return "foobar";
+ case 9 :
+ return "case 9";
+ default :
+ return "these are my contents";
+ }
+ }
/*
* Notifies listeners that the state of the resources has changed.

Back to the top