Merge "Add formatter to render images"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/Module.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/Module.java
index 4c91b4d..70506c5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/Module.java
@@ -17,12 +17,12 @@
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.annotations.PluginName;
+import com.google.gerrit.extensions.client.GerritTopMenu;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.webui.BranchWebLink;
import com.google.gerrit.extensions.webui.DiffWebLink;
import com.google.gerrit.extensions.webui.FileWebLink;
-import com.google.gerrit.extensions.webui.GerritTopMenu;
import com.google.gerrit.extensions.webui.ProjectWebLink;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.gerrit.server.config.FactoryModule;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/XDocs.gwt.xml b/src/main/java/com/googlesource/gerrit/plugins/xdocs/XDocs.gwt.xml
index 405a81f..e65b2d0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/XDocs.gwt.xml
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/XDocs.gwt.xml
@@ -19,6 +19,7 @@
<inherits name="com.google.gwt.user.User"/>
<!-- Other module inherits -->
<inherits name="com.google.gerrit.GerritGwtUICommon"/>
+ <inherits name="com.google.gerrit.extensions.Extensions"/>
<inherits name="com.google.gerrit.Plugin"/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.google.gwt.json.JSON"/>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeApi.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeApi.java
index 4f30993..0a3b3e1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeApi.java
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.xdocs.client;
+import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.plugin.client.rpc.RestApi;
import com.google.gwt.user.client.rpc.AsyncCallback;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeInfo.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeInfo.java
index 38c4cf9..d95b5f4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeInfo.java
@@ -16,6 +16,7 @@
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.Natives;
+import com.google.gerrit.extensions.client.ChangeStatus;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeStatus.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeStatus.java
deleted file mode 100644
index ed789cc..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ChangeStatus.java
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.xdocs.client;
-
-/* Current state within the basic workflow of the change **/
-public enum ChangeStatus {
-
- /**
- * Change is open and pending review, or review is in progress.
- *
- * <p>
- * This is the default state assigned to a change when it is first created
- * in the database. A change stays in the NEW state throughout its review
- * cycle, until the change is submitted or abandoned.
- *
- * <p>
- * Changes in the NEW state can be moved to:
- * <ul>
- * <li>{@link #SUBMITTED} - when the Submit Patch Set action is used;
- * <li>{@link #ABANDONED} - when the Abandon action is used.
- * </ul>
- */
- NEW,
-
- /**
- * Change is open, but has been submitted to the merge queue.
- *
- * <p>
- * A change enters the SUBMITTED state when an authorized user presses the
- * "submit" action through the web UI, requesting that Gerrit merge the
- * change's current patch set into the destination branch.
- *
- * <p>
- * Typically a change resides in the SUBMITTED for only a brief sub-second
- * period while the merge queue fires and the destination branch is updated.
- * However, if a dependency commit (directly or transitively) is not yet
- * merged into the branch, the change will hang in the SUBMITTED state
- * indefinitely.
- *
- * <p>
- * Changes in the SUBMITTED state can be moved to:
- * <ul>
- * <li>{@link #NEW} - when a replacement patch set is supplied, OR when a
- * merge conflict is detected;
- * <li>{@link #MERGED} - when the change has been successfully merged into
- * the destination branch;
- * <li>{@link #ABANDONED} - when the Abandon action is used.
- * </ul>
- */
- SUBMITTED,
-
- /**
- * Change is a draft change that only consists of draft patchsets.
- *
- * <p>
- * This is a change that is not meant to be submitted or reviewed yet. If
- * the uploader publishes the change, it becomes a NEW change.
- * Publishing is a one-way action, a change cannot return to DRAFT status.
- * Draft changes are only visible to the uploader and those explicitly
- * added as reviewers.
- *
- * <p>
- * Changes in the DRAFT state can be moved to:
- * <ul>
- * <li>{@link #NEW} - when the change is published, it becomes a new change;
- * </ul>
- */
- DRAFT,
-
- /**
- * Change is closed, and submitted to its destination branch.
- *
- * <p>
- * Once a change has been merged, it cannot be further modified by adding a
- * replacement patch set. Draft comments however may be published,
- * supporting a post-submit review.
- */
- MERGED,
-
- /**
- * Change is closed, but was not submitted to its destination branch.
- *
- * <p>
- * Once a change has been abandoned, it cannot be further modified by adding
- * a replacement patch set, and it cannot be merged. Draft comments however
- * may be published, permitting reviewers to send constructive feedback.
- */
- ABANDONED
-}
\ No newline at end of file
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/FileInfo.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/FileInfo.java
index 8fff48b..88941a4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/FileInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/FileInfo.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.xdocs.client;
import com.google.gerrit.client.rpc.Natives;
-import com.google.gerrit.reviewdb.client.Patch;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
@@ -23,6 +22,7 @@
import java.util.Comparator;
public class FileInfo extends JavaScriptObject {
+ public static final String COMMIT_MSG = "/COMMIT_MSG";
public final native String path() /*-{ return this.path; }-*/;
public final native boolean binary() /*-{ return this.binary || false; }-*/;
@@ -30,9 +30,9 @@
Collections.sort(Natives.asList(list), new Comparator<FileInfo>() {
@Override
public int compare(FileInfo a, FileInfo b) {
- if (Patch.COMMIT_MSG.equals(a.path())) {
+ if (COMMIT_MSG.equals(a.path())) {
return -1;
- } else if (Patch.COMMIT_MSG.equals(b.path())) {
+ } else if (COMMIT_MSG.equals(b.path())) {
return 1;
}
return a.path().compareTo(b.path());
@@ -41,7 +41,7 @@
}
public static String getFileName(String path) {
- String fileName = Patch.COMMIT_MSG.equals(path)
+ String fileName = COMMIT_MSG.equals(path)
? "Commit Message"
: path;
int s = fileName.lastIndexOf('/');
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ListChangesOption.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ListChangesOption.java
deleted file mode 100644
index 83f1b82..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/ListChangesOption.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2014 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.xdocs.client;
-
-import java.util.EnumSet;
-
-/** Output options available for retrieval of change details. */
-public enum ListChangesOption {
- LABELS(0),
- DETAILED_LABELS(8),
-
- /** Return information on the current patch set of the change. */
- CURRENT_REVISION(1),
- ALL_REVISIONS(2),
-
- /** If revisions are included, parse the commit object. */
- CURRENT_COMMIT(3),
- ALL_COMMITS(4),
-
- /** If a patch set is included, include the files of the patch set. */
- CURRENT_FILES(5),
- ALL_FILES(6),
-
- /** If accounts are included, include detailed account info. */
- DETAILED_ACCOUNTS(7),
-
- /** Include messages associated with the change. */
- MESSAGES(9),
-
- /** Include allowed actions client could perform. */
- CURRENT_ACTIONS(10),
-
- /** Set the reviewed boolean for the caller. */
- REVIEWED(11),
-
- /** Include draft comments for the caller. */
- DRAFT_COMMENTS(12),
-
- /** Include download commands for the caller. */
- DOWNLOAD_COMMANDS(13),
-
- /** Include patch set weblinks. */
- WEB_LINKS(14);
-
- private final int value;
-
- private ListChangesOption(int v) {
- this.value = v;
- }
-
- public int getValue() {
- return value;
- }
-
- public static EnumSet<ListChangesOption> fromBits(int v) {
- EnumSet<ListChangesOption> r = EnumSet.noneOf(ListChangesOption.class);
- for (ListChangesOption o : ListChangesOption.values()) {
- if ((v & (1 << o.value)) != 0) {
- r.add(o);
- v &= ~(1 << o.value);
- }
- if (v == 0) {
- return r;
- }
- }
- if (v != 0) {
- throw new IllegalArgumentException("unknown " + Integer.toHexString(v));
- }
- return r;
- }
-
- public static int toBits(EnumSet<ListChangesOption> set) {
- int r = 0;
- for (ListChangesOption o : set) {
- r |= 1 << o.value;
- }
- return r;
- }
-}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/PatchSetSelectBox.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/PatchSetSelectBox.java
index 21190a2..a25620d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/PatchSetSelectBox.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/PatchSetSelectBox.java
@@ -37,8 +37,6 @@
UNIFIED_DIFF
}
- private static final String COMMIT_MSG = "/COMMIT_MSG";
-
private final DiffView diffView;
private final DisplaySide side;
private final ChangeInfo change;
@@ -79,7 +77,7 @@
add(createLink(list.get(i)));
}
- if (!COMMIT_MSG.equals(path)) {
+ if (!FileInfo.COMMIT_MSG.equals(path)) {
add(createDownloadLink());
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/XDocDiffScreen.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/XDocDiffScreen.java
index 0f6877f..b3d4690 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/XDocDiffScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/client/XDocDiffScreen.java
@@ -24,10 +24,12 @@
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.InlineHTML;
import com.google.gwt.user.client.ui.InlineHyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
+import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
import com.googlesource.gerrit.plugins.xdocs.client.ChangeInfo.EditInfo;
import com.googlesource.gerrit.plugins.xdocs.client.ChangeInfo.RevisionInfo;
@@ -190,7 +192,19 @@
p.setStyleName("xdocs-file-header");
p.add(new InlineHyperlink(change.project(), "/admin/projects/" + change.project()));
p.add(new Label("/"));
- p.add(new Label(path));
+
+ SafeHtmlBuilder html = new SafeHtmlBuilder();
+ if (FileInfo.COMMIT_MSG.equals(path)) {
+ html.append("Commit Message");
+ } else {
+ int s = path.lastIndexOf('/') + 1;
+ html.append(path.substring(0, s));
+ html.openElement("b");
+ html.append(path.substring(s));
+ html.closeElement("b");
+ }
+ p.add(new InlineHTML(html.toSafeHtml()));
+
return p;
}