diff options
author | Shawn O. Pearce <sop@google.com> | 2012-04-08 17:09:45 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-04-08 17:09:45 -0700 |
commit | 78f15571e5da3ea347ddc9098f79949c459f097a (patch) | |
tree | 3573876d9b67e84046ea61550a6df4ccb9c914fa | |
parent | 4b6f8c1ef2a4ee120d5769cf9252cdb13fa37aa3 (diff) |
Remove SparseHtmlFile dependency from PatchScript
My hosting environment builds its own custom Gerrit, without
using Maven. In that build process we need to break the dependency
between PatchScript in the server CLASSPATH and SafeHtml, which
isn't available in the server CLASSPATH as its supposed to only be
used in the GWT JavaScript world.
Move the factory that builds the SparseHtmlFile off PatchScript and
into the real client code that needs it, AbstractPatchContentTable
and its two subclasses.
Change-Id: I7375e0962ef53ff83aee2c6abf53bae5eba25286
4 files changed, 39 insertions, 38 deletions
diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/PatchScript.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/PatchScript.java index d4c30ae64c..2308b776cd 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/PatchScript.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/PatchScript.java @@ -14,15 +14,12 @@ package com.google.gerrit.common.data; -import com.google.gerrit.prettify.client.ClientSideFormatter; import com.google.gerrit.prettify.common.EditList; -import com.google.gerrit.prettify.common.PrettyFormatter; import com.google.gerrit.prettify.common.SparseFileContent; -import com.google.gerrit.prettify.common.SparseHtmlFile; import com.google.gerrit.reviewdb.client.AccountDiffPreference; +import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Patch; -import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace; import com.google.gerrit.reviewdb.client.Patch.ChangeType; import org.eclipse.jgit.diff.Edit; @@ -167,36 +164,6 @@ public class PatchScript { return b; } - public SparseHtmlFile getSparseHtmlFileA() { - AccountDiffPreference dp = new AccountDiffPreference(diffPrefs); - dp.setShowWhitespaceErrors(false); - - PrettyFormatter f = ClientSideFormatter.FACTORY.get(); - f.setDiffPrefs(dp); - f.setFileName(a.getPath()); - f.setEditFilter(PrettyFormatter.A); - f.setEditList(edits); - f.format(a); - return f; - } - - public SparseHtmlFile getSparseHtmlFileB() { - AccountDiffPreference dp = new AccountDiffPreference(diffPrefs); - - PrettyFormatter f = ClientSideFormatter.FACTORY.get(); - f.setDiffPrefs(dp); - f.setFileName(b.getPath()); - f.setEditFilter(PrettyFormatter.B); - f.setEditList(edits); - - if (dp.isSyntaxHighlighting() && a.isWholeFile() && !b.isWholeFile()) { - f.format(b.apply(a, edits)); - } else { - f.format(b); - } - return f; - } - public List<Edit> getEdits() { return edits; } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java index f6ab8765bf..8282caa478 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/AbstractPatchContentTable.java @@ -26,7 +26,11 @@ import com.google.gerrit.common.data.AccountInfo; import com.google.gerrit.common.data.AccountInfoCache; import com.google.gerrit.common.data.CommentDetail; import com.google.gerrit.common.data.PatchScript; +import com.google.gerrit.prettify.client.ClientSideFormatter; +import com.google.gerrit.prettify.common.PrettyFormatter; import com.google.gerrit.prettify.common.SparseFileContent; +import com.google.gerrit.prettify.common.SparseHtmlFile; +import com.google.gerrit.reviewdb.client.AccountDiffPreference; import com.google.gerrit.reviewdb.client.Patch; import com.google.gerrit.reviewdb.client.PatchLineComment; import com.google.gerrit.reviewdb.client.PatchSet; @@ -171,6 +175,36 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object> render(s); } + protected SparseHtmlFile getSparseHtmlFileA(PatchScript s) { + AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs()); + dp.setShowWhitespaceErrors(false); + + PrettyFormatter f = ClientSideFormatter.FACTORY.get(); + f.setDiffPrefs(dp); + f.setFileName(s.getA().getPath()); + f.setEditFilter(PrettyFormatter.A); + f.setEditList(s.getEdits()); + f.format(s.getA()); + return f; + } + + protected SparseHtmlFile getSparseHtmlFileB(PatchScript s) { + AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs()); + + PrettyFormatter f = ClientSideFormatter.FACTORY.get(); + f.setDiffPrefs(dp); + f.setFileName(s.getB().getPath()); + f.setEditFilter(PrettyFormatter.B); + f.setEditList(s.getEdits()); + + if (dp.isSyntaxHighlighting() && s.getA().isWholeFile() && !s.getB().isWholeFile()) { + f.format(s.getB().apply(s.getA(), s.getEdits())); + } else { + f.format(s.getB()); + } + return f; + } + protected abstract void render(PatchScript script); protected abstract void onInsertComment(PatchLine pl); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java index c734dc05a3..6379e23121 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/SideBySideTable.java @@ -89,8 +89,8 @@ public class SideBySideTable extends AbstractPatchContentTable { @Override protected void render(final PatchScript script) { - a = script.getSparseHtmlFileA(); - b = script.getSparseHtmlFileB(); + a = getSparseHtmlFileA(script); + b = getSparseHtmlFileB(script); final ArrayList<Object> lines = new ArrayList<Object>(); final SafeHtmlBuilder nc = new SafeHtmlBuilder(); final boolean intraline = diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java index 2684552744..f0f619ebdb 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/patches/UnifiedDiffTable.java @@ -95,8 +95,8 @@ public class UnifiedDiffTable extends AbstractPatchContentTable { @Override protected void render(final PatchScript script) { - final SparseHtmlFile a = script.getSparseHtmlFileA(); - final SparseHtmlFile b = script.getSparseHtmlFileB(); + final SparseHtmlFile a = getSparseHtmlFileA(script); + final SparseHtmlFile b = getSparseHtmlFileB(script); final SafeHtmlBuilder nc = new SafeHtmlBuilder(); // Display the patch header |