summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonas Fonseca <fonseca@diku.dk>2009-09-20 09:34:37 -0400
committerShawn O. Pearce <spearce@spearce.org>2009-10-01 16:57:32 -0700
commit36b0dcf6cbae6ba25a96bf2b2bd5251f7af8904d (patch)
tree7988c31c04a3ba97cdf65e1f9de2a5f65c0d0372 /org.eclipse.jgit
parent96690904f53241e825a29be9558be319a0bbfba1 (diff)
downloadjgit-36b0dcf6cbae6ba25a96bf2b2bd5251f7af8904d.tar.gz
jgit-36b0dcf6cbae6ba25a96bf2b2bd5251f7af8904d.zip
Make it possible to clear a PlotCommitList
This allows SwingGraphPanes to be reused by simply clearing and re-filling. Requires RevObjectList initialization to not call clear() from its constructor, because this will lead PlotCommitList.clear() to be called before all variables have been initialized. Change-Id: I14a07124441b58cd88c67da088ba52ef9c30b043 Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java8
2 files changed, 14 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
index 7c27a86f49..27077c13a0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
@@ -70,7 +70,15 @@ public class PlotCommitList<L extends PlotLane> extends
private final TreeSet<Integer> freeLanes = new TreeSet<Integer>();
- private HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+ private final HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+
+ @Override
+ public void clear() {
+ super.clear();
+ lanesAllocated = 0;
+ freeLanes.clear();
+ activeLanes.clear();
+ }
@Override
public void source(final RevWalk w) {
@@ -139,7 +147,7 @@ public class PlotCommitList<L extends PlotLane> extends
final PlotCommit c = currCommit.children[i];
if (activeLanes.remove(c.lane)) {
recycleLane((L) c.lane);
- freeLanes.add(Integer.valueOf(c.lane.position));
+ freeLanes.add(Integer.valueOf(c.lane.getPosition()));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java
index 3ae1a71f1b..c67b1006fa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevObjectList.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009, Jonas Fonseca <fonseca@diku.dk>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
* and other copyright owners as documented in the project's IP log.
*
@@ -56,13 +57,12 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
static final int BLOCK_SIZE = 1 << BLOCK_SHIFT;
- Block contents;
+ protected Block contents = new Block(0);
- int size;
+ protected int size = 0;
/** Create an empty object list. */
public RevObjectList() {
- clear();
}
public void add(final int index, final E element) {
@@ -113,7 +113,7 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
size = 0;
}
- static class Block {
+ protected static class Block {
final Object[] contents = new Object[BLOCK_SIZE];
final int shift;