Show commit message on the per-file review pages.
When reviewing changes the review may be interrupted for any number of reasons. When continuing the review process the review might have forgotten the content of the commit message. This change shows the commit message at the per-file review page. The area for the commit message is limited in order to preserve the space for the diff view(s). If the commit message doesn't fit into the commit message area a vertical/horizontal scrollbar will appear. The commit message for the patch set to the right side (the "new version") of the PatchScreen is cached to avoid one RPC every time the patch screen switches to next/prev file. Bug: issue 426 Bug: issue 680 Change-Id: I8db497e44cadab6be8895e1c477516d3b3b2d9c2 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com> Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
c25b07b89c
commit
9b218bc0ad
@@ -70,6 +70,7 @@ import com.google.gerrit.client.changes.PublishCommentScreen;
|
|||||||
import com.google.gerrit.client.patches.PatchScreen;
|
import com.google.gerrit.client.patches.PatchScreen;
|
||||||
import com.google.gerrit.client.ui.Screen;
|
import com.google.gerrit.client.ui.Screen;
|
||||||
import com.google.gerrit.common.auth.SignInMode;
|
import com.google.gerrit.common.auth.SignInMode;
|
||||||
|
import com.google.gerrit.common.data.PatchSetDetail;
|
||||||
import com.google.gerrit.reviewdb.Account;
|
import com.google.gerrit.reviewdb.Account;
|
||||||
import com.google.gerrit.reviewdb.AccountGroup;
|
import com.google.gerrit.reviewdb.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
@@ -124,7 +125,7 @@ public class Dispatcher {
|
|||||||
|
|
||||||
private static void select(final String token) {
|
private static void select(final String token) {
|
||||||
if (token.startsWith("patch,")) {
|
if (token.startsWith("patch,")) {
|
||||||
patch(token, null, 0, null);
|
patch(token, null, 0, null, null);
|
||||||
|
|
||||||
} else if (token.startsWith("change,publish,")) {
|
} else if (token.startsWith("change,publish,")) {
|
||||||
publish(token);
|
publish(token);
|
||||||
@@ -268,7 +269,8 @@ public class Dispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void patch(String token, final Patch.Key id,
|
public static void patch(String token, final Patch.Key id,
|
||||||
final int patchIndex, final PatchTable patchTable) {
|
final int patchIndex, final PatchSetDetail patchSetDetail,
|
||||||
|
final PatchTable patchTable) {
|
||||||
GWT.runAsync(new AsyncSplit(token) {
|
GWT.runAsync(new AsyncSplit(token) {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
Gerrit.display(token, select());
|
Gerrit.display(token, select());
|
||||||
@@ -282,6 +284,7 @@ public class Dispatcher {
|
|||||||
return new PatchScreen.SideBySide( //
|
return new PatchScreen.SideBySide( //
|
||||||
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
||||||
patchIndex, //
|
patchIndex, //
|
||||||
|
patchSetDetail, //
|
||||||
patchTable //
|
patchTable //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -291,6 +294,7 @@ public class Dispatcher {
|
|||||||
return new PatchScreen.Unified( //
|
return new PatchScreen.Unified( //
|
||||||
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
||||||
patchIndex, //
|
patchIndex, //
|
||||||
|
patchSetDetail, //
|
||||||
patchTable //
|
patchTable //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,42 +14,29 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.client.changes;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
import com.google.gerrit.common.data.AccountInfoCache;
|
||||||
import com.google.gerrit.reviewdb.Change;
|
import com.google.gerrit.reviewdb.Change;
|
||||||
import com.google.gerrit.reviewdb.PatchSetInfo;
|
import com.google.gerrit.reviewdb.PatchSetInfo;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
|
||||||
|
|
||||||
public class ChangeDescriptionBlock extends Composite {
|
public class ChangeDescriptionBlock extends Composite {
|
||||||
private final ChangeInfoBlock infoBlock;
|
private final ChangeInfoBlock infoBlock;
|
||||||
private final HTML description;
|
private final CommitMessageBlock messageBlock;
|
||||||
|
|
||||||
public ChangeDescriptionBlock() {
|
public ChangeDescriptionBlock() {
|
||||||
infoBlock = new ChangeInfoBlock();
|
infoBlock = new ChangeInfoBlock();
|
||||||
description = new HTML();
|
messageBlock = new CommitMessageBlock();
|
||||||
description.setStyleName(Gerrit.RESOURCES.css().changeScreenDescription());
|
|
||||||
|
|
||||||
final HorizontalPanel hp = new HorizontalPanel();
|
final HorizontalPanel hp = new HorizontalPanel();
|
||||||
hp.add(infoBlock);
|
hp.add(infoBlock);
|
||||||
hp.add(description);
|
hp.add(messageBlock);
|
||||||
initWidget(hp);
|
initWidget(hp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(final Change chg, final PatchSetInfo info,
|
public void display(final Change chg, final PatchSetInfo info,
|
||||||
final AccountInfoCache acc) {
|
final AccountInfoCache acc) {
|
||||||
infoBlock.display(chg, acc);
|
infoBlock.display(chg, acc);
|
||||||
|
messageBlock.display(info.getMessage());
|
||||||
SafeHtml msg = new SafeHtmlBuilder().append(info.getMessage());
|
|
||||||
msg = msg.linkify();
|
|
||||||
msg = CommentLinkProcessor.apply(msg);
|
|
||||||
msg = new SafeHtmlBuilder().openElement("p").append(msg).closeElement("p");
|
|
||||||
msg = msg.replaceAll("\n\n", "</p><p>");
|
|
||||||
msg = msg.replaceAll("\n", "<br />");
|
|
||||||
SafeHtml.set(description, msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (C) 2010 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.google.gerrit.client.changes;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||||
|
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||||
|
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||||
|
|
||||||
|
public class CommitMessageBlock extends Composite {
|
||||||
|
private final HTML description;
|
||||||
|
|
||||||
|
public CommitMessageBlock() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommitMessageBlock(String height) {
|
||||||
|
description = new HTML();
|
||||||
|
description.setStyleName(Gerrit.RESOURCES.css().changeScreenDescription());
|
||||||
|
if (height != null) {
|
||||||
|
ScrollPanel scrollPanel = new ScrollPanel();
|
||||||
|
scrollPanel.setHeight(height);
|
||||||
|
scrollPanel.add(description);
|
||||||
|
initWidget(scrollPanel);
|
||||||
|
} else {
|
||||||
|
initWidget(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(final String commitMessage) {
|
||||||
|
SafeHtml msg = new SafeHtmlBuilder().append(commitMessage);
|
||||||
|
msg = msg.linkify();
|
||||||
|
msg = CommentLinkProcessor.apply(msg);
|
||||||
|
msg = new SafeHtmlBuilder().openElement("p").append(msg).closeElement("p");
|
||||||
|
msg = msg.replaceAll("\n\n", "</p><p>");
|
||||||
|
msg = msg.replaceAll("\n", "<br />");
|
||||||
|
SafeHtml.set(description, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -147,7 +147,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
|
|||||||
|
|
||||||
patchTable = new PatchTable();
|
patchTable = new PatchTable();
|
||||||
patchTable.setSavePointerId("PatchTable " + patchSet.getId());
|
patchTable.setSavePointerId("PatchTable " + patchSet.getId());
|
||||||
patchTable.display(info.getKey(), detail.getPatches());
|
patchTable.display(detail);
|
||||||
|
|
||||||
body.add(infoTable);
|
body.add(infoTable);
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
for (Patch p : detail.getPatches()) {
|
for (Patch p : detail.getPatches()) {
|
||||||
SideBySide link = new PatchLink.SideBySide(p.getFileName(), p.getKey(), 0, null);
|
SideBySide link = new PatchLink.SideBySide(p.getFileName(), p.getKey(), 0, null, null);
|
||||||
Window.open(link.getElement().toString(), p.getFileName(), null);
|
Window.open(link.getElement().toString(), p.getFileName(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel implements O
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
for (Patch p : detail.getPatches()) {
|
for (Patch p : detail.getPatches()) {
|
||||||
Unified link = new PatchLink.Unified(p.getFileName(), p.getKey(), 0, null);
|
Unified link = new PatchLink.Unified(p.getFileName(), p.getKey(), 0, null, null);
|
||||||
Window.open(link.getElement().toString(), p.getFileName(), null);
|
Window.open(link.getElement().toString(), p.getFileName(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import com.google.gerrit.client.patches.PatchScreen;
|
|||||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||||
import com.google.gerrit.client.ui.NavigationTable;
|
import com.google.gerrit.client.ui.NavigationTable;
|
||||||
import com.google.gerrit.client.ui.PatchLink;
|
import com.google.gerrit.client.ui.PatchLink;
|
||||||
|
import com.google.gerrit.common.data.PatchSetDetail;
|
||||||
import com.google.gerrit.reviewdb.Patch;
|
import com.google.gerrit.reviewdb.Patch;
|
||||||
import com.google.gerrit.reviewdb.PatchSet;
|
|
||||||
import com.google.gerrit.reviewdb.Patch.Key;
|
import com.google.gerrit.reviewdb.Patch.Key;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
@@ -46,7 +46,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PatchTable extends Composite {
|
public class PatchTable extends Composite {
|
||||||
private final FlowPanel myBody;
|
private final FlowPanel myBody;
|
||||||
private PatchSet.Id psid;
|
private PatchSetDetail detail;
|
||||||
private Command onLoadCommand;
|
private Command onLoadCommand;
|
||||||
private MyTable myTable;
|
private MyTable myTable;
|
||||||
private String savePointerId;
|
private String savePointerId;
|
||||||
@@ -57,12 +57,21 @@ public class PatchTable extends Composite {
|
|||||||
initWidget(myBody);
|
initWidget(myBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(final PatchSet.Id id, final List<Patch> list) {
|
public int indexOf(Patch.Key patch) {
|
||||||
psid = id;
|
for (int i = 0; i < patchList.size(); i++) {
|
||||||
myTable = null;
|
if (patchList.get(i).getKey().equals(patch)) {
|
||||||
patchList = list;
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
final DisplayCommand cmd = new DisplayCommand(list);
|
public void display(PatchSetDetail detail) {
|
||||||
|
this.detail = detail;
|
||||||
|
this.patchList = detail.getPatches();
|
||||||
|
myTable = null;
|
||||||
|
|
||||||
|
final DisplayCommand cmd = new DisplayCommand(patchList);
|
||||||
if (cmd.execute()) {
|
if (cmd.execute()) {
|
||||||
cmd.initMeter();
|
cmd.initMeter();
|
||||||
DeferredCommand.addCommand(cmd);
|
DeferredCommand.addCommand(cmd);
|
||||||
@@ -144,9 +153,9 @@ public class PatchTable extends Composite {
|
|||||||
PatchLink link;
|
PatchLink link;
|
||||||
if (patchType == PatchScreen.Type.SIDE_BY_SIDE
|
if (patchType == PatchScreen.Type.SIDE_BY_SIDE
|
||||||
&& patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
&& patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
||||||
link = new PatchLink.SideBySide("", thisKey, index, this);
|
link = new PatchLink.SideBySide("", thisKey, index, detail, this);
|
||||||
} else {
|
} else {
|
||||||
link = new PatchLink.Unified("", thisKey, index, this);
|
link = new PatchLink.Unified("", thisKey, index, detail, this);
|
||||||
}
|
}
|
||||||
SafeHtmlBuilder text = new SafeHtmlBuilder();
|
SafeHtmlBuilder text = new SafeHtmlBuilder();
|
||||||
text.append(before);
|
text.append(before);
|
||||||
@@ -274,11 +283,13 @@ public class PatchTable extends Composite {
|
|||||||
|
|
||||||
Widget nameCol;
|
Widget nameCol;
|
||||||
if (patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
if (patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
||||||
nameCol = new PatchLink.SideBySide(patch.getFileName(), patch.getKey(), row - 1,
|
nameCol =
|
||||||
PatchTable.this);
|
new PatchLink.SideBySide(patch.getFileName(), patch.getKey(),
|
||||||
|
row - 1, detail, PatchTable.this);
|
||||||
} else {
|
} else {
|
||||||
nameCol = new PatchLink.Unified(patch.getFileName(), patch.getKey(), row - 1,
|
nameCol =
|
||||||
PatchTable.this);
|
new PatchLink.Unified(patch.getFileName(), patch.getKey(), row - 1,
|
||||||
|
detail, PatchTable.this);
|
||||||
}
|
}
|
||||||
if (patch.getSourceFileName() != null) {
|
if (patch.getSourceFileName() != null) {
|
||||||
final String text;
|
final String text;
|
||||||
@@ -300,16 +311,16 @@ public class PatchTable extends Composite {
|
|||||||
|
|
||||||
int C_UNIFIED = C_SIDEBYSIDE + 1;
|
int C_UNIFIED = C_SIDEBYSIDE + 1;
|
||||||
if (patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
if (patch.getPatchType() == Patch.PatchType.UNIFIED) {
|
||||||
table.setWidget(row, C_SIDEBYSIDE,
|
table.setWidget(row, C_SIDEBYSIDE, new PatchLink.SideBySide(Util.C
|
||||||
new PatchLink.SideBySide(Util.C.patchTableDiffSideBySide(), patch.getKey(), row - 1,
|
.patchTableDiffSideBySide(), patch.getKey(), row - 1, detail,
|
||||||
PatchTable.this));
|
PatchTable.this));
|
||||||
|
|
||||||
} else if (patch.getPatchType() == Patch.PatchType.BINARY) {
|
} else if (patch.getPatchType() == Patch.PatchType.BINARY) {
|
||||||
C_UNIFIED = C_SIDEBYSIDE + 2;
|
C_UNIFIED = C_SIDEBYSIDE + 2;
|
||||||
}
|
}
|
||||||
table.setWidget(row, C_UNIFIED,
|
table.setWidget(row, C_UNIFIED, new PatchLink.Unified(Util.C
|
||||||
new PatchLink.Unified(Util.C.patchTableDiffUnified(), patch.getKey(), row - 1,
|
.patchTableDiffUnified(), patch.getKey(), row - 1, detail,
|
||||||
PatchTable.this));
|
PatchTable.this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendHeader(final SafeHtmlBuilder m) {
|
void appendHeader(final SafeHtmlBuilder m) {
|
||||||
@@ -599,7 +610,7 @@ public class PatchTable extends Composite {
|
|||||||
|
|
||||||
void initMeter() {
|
void initMeter() {
|
||||||
if (meter == null) {
|
if (meter == null) {
|
||||||
meter = new ProgressBar(Util.M.loadingPatchSet(psid.get()));
|
meter = new ProgressBar(Util.M.loadingPatchSet(detail.getPatchSet().getId().get()));
|
||||||
PatchTable.this.myBody.clear();
|
PatchTable.this.myBody.clear();
|
||||||
PatchTable.this.myBody.add(meter);
|
PatchTable.this.myBody.add(meter);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,10 +281,7 @@ public class PublishCommentScreen extends AccountScreen implements
|
|||||||
draftsPanel.add(panel);
|
draftsPanel.add(panel);
|
||||||
// Parent table can be null here since we are not showing any
|
// Parent table can be null here since we are not showing any
|
||||||
// next/previous links
|
// next/previous links
|
||||||
panel.add(new PatchLink.SideBySide(fn, patchKey, 0, null /*
|
panel.add(new PatchLink.SideBySide(fn, patchKey, 0, null, null));
|
||||||
* parent
|
|
||||||
* table
|
|
||||||
*/));
|
|
||||||
priorFile = fn;
|
priorFile = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
// Copyright (C) 2010 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.google.gerrit.client.patches;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.changes.PatchTable;
|
||||||
|
import com.google.gerrit.client.changes.Util;
|
||||||
|
import com.google.gerrit.client.ui.ChangeLink;
|
||||||
|
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||||
|
import com.google.gerrit.reviewdb.Change;
|
||||||
|
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||||
|
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
||||||
|
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
||||||
|
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||||
|
|
||||||
|
class NavLinks extends Composite {
|
||||||
|
private final KeyCommandSet keys;
|
||||||
|
private final Grid table;
|
||||||
|
|
||||||
|
private InlineHyperlink prev;
|
||||||
|
private InlineHyperlink next;
|
||||||
|
|
||||||
|
private KeyCommand prevKey;
|
||||||
|
private KeyCommand nextKey;
|
||||||
|
|
||||||
|
NavLinks(KeyCommandSet kcs, Change.Id forChange) {
|
||||||
|
keys = kcs;
|
||||||
|
table = new Grid(1, 3);
|
||||||
|
initWidget(table);
|
||||||
|
|
||||||
|
final CellFormatter fmt = table.getCellFormatter();
|
||||||
|
table.setStyleName(Gerrit.RESOURCES.css().sideBySideScreenLinkTable());
|
||||||
|
fmt.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
|
||||||
|
fmt.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
|
||||||
|
fmt.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
|
||||||
|
|
||||||
|
final ChangeLink up = new ChangeLink("", forChange);
|
||||||
|
SafeHtml.set(up, SafeHtml.asis(Util.C.upToChangeIconLink()));
|
||||||
|
table.setWidget(0, 1, up);
|
||||||
|
}
|
||||||
|
|
||||||
|
void display(int patchIndex, PatchScreen.Type type, PatchTable fileList) {
|
||||||
|
if (fileList != null) {
|
||||||
|
prev = fileList.getPreviousPatchLink(patchIndex, type);
|
||||||
|
next = fileList.getNextPatchLink(patchIndex, type);
|
||||||
|
} else {
|
||||||
|
prev = null;
|
||||||
|
next = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev != null) {
|
||||||
|
if (keys != null && prevKey == null) {
|
||||||
|
prevKey = new KeyCommand(0, '[', PatchUtil.C.previousFileHelp()) {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
prev.go();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
keys.add(prevKey);
|
||||||
|
}
|
||||||
|
table.setWidget(0, 0, prev);
|
||||||
|
} else {
|
||||||
|
if (keys != null && prevKey != null) {
|
||||||
|
keys.remove(prevKey);
|
||||||
|
prevKey = null;
|
||||||
|
}
|
||||||
|
table.clearCell(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next != null) {
|
||||||
|
if (keys != null && nextKey == null) {
|
||||||
|
nextKey = new KeyCommand(0, ']', PatchUtil.C.nextFileHelp()) {
|
||||||
|
@Override
|
||||||
|
public void onKeyPress(KeyPressEvent event) {
|
||||||
|
next.go();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
keys.add(nextKey);
|
||||||
|
}
|
||||||
|
table.setWidget(0, 2, next);
|
||||||
|
} else {
|
||||||
|
if (keys != null && nextKey != null) {
|
||||||
|
keys.remove(nextKey);
|
||||||
|
nextKey = null;
|
||||||
|
}
|
||||||
|
table.clearCell(0, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,11 +18,11 @@ import com.google.gerrit.client.Dispatcher;
|
|||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.RpcStatus;
|
import com.google.gerrit.client.RpcStatus;
|
||||||
import com.google.gerrit.client.changes.ChangeScreen;
|
import com.google.gerrit.client.changes.ChangeScreen;
|
||||||
|
import com.google.gerrit.client.changes.CommitMessageBlock;
|
||||||
import com.google.gerrit.client.changes.PatchTable;
|
import com.google.gerrit.client.changes.PatchTable;
|
||||||
import com.google.gerrit.client.changes.Util;
|
import com.google.gerrit.client.changes.Util;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
import com.google.gerrit.client.ui.ChangeLink;
|
|
||||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||||
import com.google.gerrit.client.ui.Screen;
|
import com.google.gerrit.client.ui.Screen;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
@@ -48,15 +48,12 @@ import com.google.gwt.user.client.DeferredCommand;
|
|||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
import com.google.gwt.user.client.ui.DisclosurePanel;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
|
||||||
import com.google.gwtjsonrpc.client.VoidResult;
|
import com.google.gwtjsonrpc.client.VoidResult;
|
||||||
|
|
||||||
public abstract class PatchScreen extends Screen implements
|
public abstract class PatchScreen extends Screen implements
|
||||||
@@ -65,8 +62,8 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
|
|
||||||
public static class SideBySide extends PatchScreen {
|
public static class SideBySide extends PatchScreen {
|
||||||
public SideBySide(final Patch.Key id, final int patchIndex,
|
public SideBySide(final Patch.Key id, final int patchIndex,
|
||||||
final PatchTable patchTable) {
|
final PatchSetDetail patchSetDetail, final PatchTable patchTable) {
|
||||||
super(id, patchIndex, patchTable);
|
super(id, patchIndex, patchSetDetail, patchTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,8 +79,8 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
|
|
||||||
public static class Unified extends PatchScreen {
|
public static class Unified extends PatchScreen {
|
||||||
public Unified(final Patch.Key id, final int patchIndex,
|
public Unified(final Patch.Key id, final int patchIndex,
|
||||||
final PatchTable patchTable) {
|
final PatchSetDetail patchSetDetail, final PatchTable patchTable) {
|
||||||
super(id, patchIndex, patchTable);
|
super(id, patchIndex, patchSetDetail, patchTable);
|
||||||
final PatchScriptSettings s = settingsPanel.getValue();
|
final PatchScriptSettings s = settingsPanel.getValue();
|
||||||
s.getPrettySettings().setSyntaxHighlighting(false);
|
s.getPrettySettings().setSyntaxHighlighting(false);
|
||||||
settingsPanel.setValue(s);
|
settingsPanel.setValue(s);
|
||||||
@@ -103,6 +100,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
// Which patch set id's are being diff'ed
|
// Which patch set id's are being diff'ed
|
||||||
private static PatchSet.Id diffSideA = null;
|
private static PatchSet.Id diffSideA = null;
|
||||||
private static PatchSet.Id diffSideB = null;
|
private static PatchSet.Id diffSideB = null;
|
||||||
|
|
||||||
private static Boolean historyOpen = null;
|
private static Boolean historyOpen = null;
|
||||||
private static final OpenHandler<DisclosurePanel> cacheOpenState =
|
private static final OpenHandler<DisclosurePanel> cacheOpenState =
|
||||||
new OpenHandler<DisclosurePanel>() {
|
new OpenHandler<DisclosurePanel>() {
|
||||||
@@ -123,6 +121,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
private static Change.Id currentChangeId = null;
|
private static Change.Id currentChangeId = null;
|
||||||
|
|
||||||
protected final Patch.Key patchKey;
|
protected final Patch.Key patchKey;
|
||||||
|
protected PatchSetDetail patchSetDetail;
|
||||||
protected PatchTable fileList;
|
protected PatchTable fileList;
|
||||||
protected PatchSet.Id idSideA;
|
protected PatchSet.Id idSideA;
|
||||||
protected PatchSet.Id idSideB;
|
protected PatchSet.Id idSideB;
|
||||||
@@ -133,6 +132,9 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
private FlowPanel contentPanel;
|
private FlowPanel contentPanel;
|
||||||
private Label noDifference;
|
private Label noDifference;
|
||||||
private AbstractPatchContentTable contentTable;
|
private AbstractPatchContentTable contentTable;
|
||||||
|
private CommitMessageBlock commitMessageBlock;
|
||||||
|
private NavLinks topNav;
|
||||||
|
private NavLinks bottomNav;
|
||||||
|
|
||||||
private int rpcSequence;
|
private int rpcSequence;
|
||||||
private PatchScript lastScript;
|
private PatchScript lastScript;
|
||||||
@@ -150,9 +152,6 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
/** Link to the screen for the next file, null if not applicable */
|
/** Link to the screen for the next file, null if not applicable */
|
||||||
private InlineHyperlink nextFileLink;
|
private InlineHyperlink nextFileLink;
|
||||||
|
|
||||||
private static final char SHORTCUT_PREVIOUS_FILE = '[';
|
|
||||||
private static final char SHORTCUT_NEXT_FILE = ']';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How this patch should be displayed in the patch screen.
|
* How this patch should be displayed in the patch screen.
|
||||||
*/
|
*/
|
||||||
@@ -161,8 +160,9 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected PatchScreen(final Patch.Key id, final int patchIndex,
|
protected PatchScreen(final Patch.Key id, final int patchIndex,
|
||||||
final PatchTable patchTable) {
|
final PatchSetDetail detail, final PatchTable patchTable) {
|
||||||
patchKey = id;
|
patchKey = id;
|
||||||
|
patchSetDetail = detail;
|
||||||
fileList = patchTable;
|
fileList = patchTable;
|
||||||
|
|
||||||
// If we have any diff side stored, make sure they are applicable to the
|
// If we have any diff side stored, make sure they are applicable to the
|
||||||
@@ -270,8 +270,17 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
|| (historyOpen != null && historyOpen));
|
|| (historyOpen != null && historyOpen));
|
||||||
historyPanel.addOpenHandler(cacheOpenState);
|
historyPanel.addOpenHandler(cacheOpenState);
|
||||||
historyPanel.addCloseHandler(cacheCloseState);
|
historyPanel.addCloseHandler(cacheCloseState);
|
||||||
add(historyPanel);
|
|
||||||
add(settingsPanel);
|
|
||||||
|
VerticalPanel vp = new VerticalPanel();
|
||||||
|
vp.add(historyPanel);
|
||||||
|
vp.add(settingsPanel);
|
||||||
|
commitMessageBlock = new CommitMessageBlock("6em");
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.setWidth("100%");
|
||||||
|
hp.add(vp);
|
||||||
|
hp.add(commitMessageBlock);
|
||||||
|
add(hp);
|
||||||
|
|
||||||
noDifference = new Label(PatchUtil.C.noDifference());
|
noDifference = new Label(PatchUtil.C.noDifference());
|
||||||
noDifference.setStyleName(Gerrit.RESOURCES.css().patchNoDifference());
|
noDifference.setStyleName(Gerrit.RESOURCES.css().patchNoDifference());
|
||||||
@@ -280,35 +289,23 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
contentTable = createContentTable();
|
contentTable = createContentTable();
|
||||||
contentTable.fileList = fileList;
|
contentTable.fileList = fileList;
|
||||||
|
|
||||||
add(createNextPrevLinks());
|
topNav =
|
||||||
|
new NavLinks(keysNavigation, patchKey.getParentKey().getParentKey());
|
||||||
|
bottomNav = new NavLinks(null, patchKey.getParentKey().getParentKey());
|
||||||
|
|
||||||
|
add(topNav);
|
||||||
contentPanel = new FlowPanel();
|
contentPanel = new FlowPanel();
|
||||||
contentPanel.setStyleName(Gerrit.RESOURCES.css()
|
contentPanel.setStyleName(Gerrit.RESOURCES.css()
|
||||||
.sideBySideScreenSideBySideTable());
|
.sideBySideScreenSideBySideTable());
|
||||||
contentPanel.add(noDifference);
|
contentPanel.add(noDifference);
|
||||||
contentPanel.add(contentTable);
|
contentPanel.add(contentTable);
|
||||||
add(contentPanel);
|
add(contentPanel);
|
||||||
add(createNextPrevLinks());
|
add(bottomNav);
|
||||||
|
|
||||||
// This must be done after calling createNextPrevLinks(), which initializes
|
if (fileList != null) {
|
||||||
// these fields
|
topNav.display(patchIndex, getPatchScreenType(), fileList);
|
||||||
if (previousFileLink != null) {
|
bottomNav.display(patchIndex, getPatchScreenType(), fileList);
|
||||||
installLinkShortCut(previousFileLink, SHORTCUT_PREVIOUS_FILE, PatchUtil.C
|
|
||||||
.previousFileHelp());
|
|
||||||
}
|
}
|
||||||
if (nextFileLink != null) {
|
|
||||||
installLinkShortCut(nextFileLink, SHORTCUT_NEXT_FILE, PatchUtil.C
|
|
||||||
.nextFileHelp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void installLinkShortCut(final InlineHyperlink link, char shortcut,
|
|
||||||
String help) {
|
|
||||||
keysNavigation.add(new KeyCommand(0, shortcut, help) {
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(KeyPressEvent event) {
|
|
||||||
link.go();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setReviewedByCurrentUser(boolean reviewed) {
|
void setReviewedByCurrentUser(boolean reviewed) {
|
||||||
@@ -330,36 +327,28 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Widget createNextPrevLinks() {
|
|
||||||
final Grid table = new Grid(1, 3);
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
table.setStyleName(Gerrit.RESOURCES.css().sideBySideScreenLinkTable());
|
|
||||||
fmt.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
|
|
||||||
fmt.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
|
|
||||||
fmt.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
|
|
||||||
|
|
||||||
if (fileList != null) {
|
|
||||||
previousFileLink =
|
|
||||||
fileList.getPreviousPatchLink(patchIndex, getPatchScreenType());
|
|
||||||
table.setWidget(0, 0, previousFileLink);
|
|
||||||
|
|
||||||
nextFileLink =
|
|
||||||
fileList.getNextPatchLink(patchIndex, getPatchScreenType());
|
|
||||||
table.setWidget(0, 2, nextFileLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
final ChangeLink up =
|
|
||||||
new ChangeLink("", patchKey.getParentKey().getParentKey());
|
|
||||||
SafeHtml.set(up, SafeHtml.asis(Util.C.upToChangeIconLink()));
|
|
||||||
table.setWidget(0, 1, up);
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLoad() {
|
protected void onLoad() {
|
||||||
super.onLoad();
|
super.onLoad();
|
||||||
refresh(true);
|
if (patchSetDetail == null) {
|
||||||
|
Util.DETAIL_SVC.patchSetDetail(idSideB,
|
||||||
|
new GerritCallback<PatchSetDetail>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(PatchSetDetail result) {
|
||||||
|
patchSetDetail = result;
|
||||||
|
if (fileList == null) {
|
||||||
|
fileList = new PatchTable();
|
||||||
|
fileList.display(result);
|
||||||
|
patchIndex = fileList.indexOf(patchKey);
|
||||||
|
topNav.display(patchIndex, getPatchScreenType(), fileList);
|
||||||
|
bottomNav.display(patchIndex, getPatchScreenType(), fileList);
|
||||||
|
}
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
refresh(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -417,6 +406,20 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
setWindowTitle(PatchUtil.M.patchWindowTitle(cid.abbreviate(), fileName));
|
setWindowTitle(PatchUtil.M.patchWindowTitle(cid.abbreviate(), fileName));
|
||||||
setPageTitle(PatchUtil.M.patchPageTitle(cid.abbreviate(), path));
|
setPageTitle(PatchUtil.M.patchPageTitle(cid.abbreviate(), path));
|
||||||
|
|
||||||
|
if (idSideB.equals(patchSetDetail.getPatchSet().getId())) {
|
||||||
|
commitMessageBlock.setVisible(true);
|
||||||
|
commitMessageBlock.display(patchSetDetail.getInfo().getMessage());
|
||||||
|
} else {
|
||||||
|
commitMessageBlock.setVisible(false);
|
||||||
|
Util.DETAIL_SVC.patchSetDetail(idSideB,
|
||||||
|
new GerritCallback<PatchSetDetail>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(PatchSetDetail result) {
|
||||||
|
commitMessageBlock.display(result.getInfo().getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
historyTable.display(script.getHistory());
|
historyTable.display(script.getHistory());
|
||||||
historyPanel.setVisible(true);
|
historyPanel.setVisible(true);
|
||||||
|
|
||||||
@@ -500,7 +503,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
Util.DETAIL_SVC.patchSetDetail(psid,
|
Util.DETAIL_SVC.patchSetDetail(psid,
|
||||||
new GerritCallback<PatchSetDetail>() {
|
new GerritCallback<PatchSetDetail>() {
|
||||||
public void onSuccess(final PatchSetDetail result) {
|
public void onSuccess(final PatchSetDetail result) {
|
||||||
fileList.display(psid, result.getPatches());
|
fileList.display(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ package com.google.gerrit.client.ui;
|
|||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
import com.google.gerrit.client.Dispatcher;
|
||||||
import com.google.gerrit.client.changes.PatchTable;
|
import com.google.gerrit.client.changes.PatchTable;
|
||||||
|
import com.google.gerrit.common.data.PatchSetDetail;
|
||||||
import com.google.gerrit.reviewdb.Patch;
|
import com.google.gerrit.reviewdb.Patch;
|
||||||
|
|
||||||
public abstract class PatchLink extends InlineHyperlink {
|
public abstract class PatchLink extends InlineHyperlink {
|
||||||
protected Patch.Key patchKey;
|
protected Patch.Key patchKey;
|
||||||
protected int patchIndex;
|
protected int patchIndex;
|
||||||
|
protected PatchSetDetail patchSetDetail;
|
||||||
protected PatchTable parentPatchTable;
|
protected PatchTable parentPatchTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,14 +30,17 @@ public abstract class PatchLink extends InlineHyperlink {
|
|||||||
* @param patchKey The key for this patch
|
* @param patchKey The key for this patch
|
||||||
* @param patchIndex The index of the current patch in the patch set
|
* @param patchIndex The index of the current patch in the patch set
|
||||||
* @param historyToken The history token
|
* @param historyToken The history token
|
||||||
|
* @parma patchSetDetail Detailed information about the patch set.
|
||||||
* @param parentPatchTable The table used to display this link
|
* @param parentPatchTable The table used to display this link
|
||||||
*/
|
*/
|
||||||
public PatchLink(final String text, final Patch.Key patchKey,
|
public PatchLink(final String text, final Patch.Key patchKey,
|
||||||
final int patchIndex, final String historyToken,
|
final int patchIndex, final String historyToken,
|
||||||
PatchTable parentPatchTable) {
|
final PatchSetDetail patchSetDetail,
|
||||||
|
final PatchTable parentPatchTable) {
|
||||||
super(text, historyToken);
|
super(text, historyToken);
|
||||||
this.patchKey = patchKey;
|
this.patchKey = patchKey;
|
||||||
this.patchIndex = patchIndex;
|
this.patchIndex = patchIndex;
|
||||||
|
this.patchSetDetail = patchSetDetail;
|
||||||
this.parentPatchTable = parentPatchTable;
|
this.parentPatchTable = parentPatchTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,23 +50,26 @@ public abstract class PatchLink extends InlineHyperlink {
|
|||||||
getTargetHistoryToken(), //
|
getTargetHistoryToken(), //
|
||||||
patchKey, //
|
patchKey, //
|
||||||
patchIndex, //
|
patchIndex, //
|
||||||
|
patchSetDetail, //
|
||||||
parentPatchTable //
|
parentPatchTable //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SideBySide extends PatchLink {
|
public static class SideBySide extends PatchLink {
|
||||||
public SideBySide(final String text, final Patch.Key patchKey,
|
public SideBySide(final String text, final Patch.Key patchKey,
|
||||||
final int patchIndex, PatchTable parentPatchTable) {
|
final int patchIndex, PatchSetDetail patchSetDetail,
|
||||||
super(text, patchKey, patchIndex, Dispatcher
|
PatchTable parentPatchTable) {
|
||||||
.toPatchSideBySide(patchKey), parentPatchTable);
|
super(text, patchKey, patchIndex, Dispatcher.toPatchSideBySide(patchKey),
|
||||||
|
patchSetDetail, parentPatchTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Unified extends PatchLink {
|
public static class Unified extends PatchLink {
|
||||||
public Unified(final String text, final Patch.Key patchKey,
|
public Unified(final String text, final Patch.Key patchKey,
|
||||||
final int patchIndex, PatchTable parentPatchTable) {
|
final int patchIndex, PatchSetDetail patchSetDetail,
|
||||||
super(text, patchKey, patchIndex,
|
PatchTable parentPatchTable) {
|
||||||
Dispatcher.toPatchUnified(patchKey), parentPatchTable);
|
super(text, patchKey, patchIndex, Dispatcher.toPatchUnified(patchKey),
|
||||||
|
patchSetDetail, parentPatchTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user