Remove old change screen
The following code was removed: UI: * ChangeScreen (1) * SideBySide (1) * NewChangeScreenBar Database columns in the accounts table: * change_screen * reverse_patch_set_order * comment_visibility_strategy Change-Id: I7ec4a0beb51dd6cb2f7c364df40e7cb5bea786d2
This commit is contained in:
parent
d9d64ecd6a
commit
36934dc6ef
@ -1550,11 +1550,6 @@ Only used when `gerrit.reportBugUrl` is set.
|
|||||||
+
|
+
|
||||||
Defaults to "Report Bug".
|
Defaults to "Report Bug".
|
||||||
|
|
||||||
[[gerrit.changeScreen]]gerrit.changeScreen::
|
|
||||||
+
|
|
||||||
Default change screen UI to direct users to. Valid values are
|
|
||||||
`OLD_UI` and `CHANGE_SCREEN2`. Default is `CHANGE_SCREEN2`.
|
|
||||||
|
|
||||||
[[gerrit.disableReverseDnsLookup]]gerrit.disableReverseDnsLookup::
|
[[gerrit.disableReverseDnsLookup]]gerrit.disableReverseDnsLookup::
|
||||||
+
|
+
|
||||||
Disables reverse DNS lookup during computing ref log entry for identified user.
|
Disables reverse DNS lookup during computing ref log entry for identified user.
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 33 KiB |
@ -902,7 +902,6 @@ link:#preferences-info[PreferencesInfo] entity.
|
|||||||
"time_format": "HHMM_12",
|
"time_format": "HHMM_12",
|
||||||
"size_bar_in_change_table": true,
|
"size_bar_in_change_table": true,
|
||||||
"review_category_strategy": "ABBREV",
|
"review_category_strategy": "ABBREV",
|
||||||
"comment_visibility_strategy": "EXPAND_RECENT",
|
|
||||||
"diff_view": "SIDE_BY_SIDE",
|
"diff_view": "SIDE_BY_SIDE",
|
||||||
"my": [
|
"my": [
|
||||||
{
|
{
|
||||||
@ -957,7 +956,6 @@ link:#preferences-input[PreferencesInput] entity.
|
|||||||
"time_format": "HHMM_12",
|
"time_format": "HHMM_12",
|
||||||
"size_bar_in_change_table": true,
|
"size_bar_in_change_table": true,
|
||||||
"review_category_strategy": "NAME",
|
"review_category_strategy": "NAME",
|
||||||
"comment_visibility_strategy": "EXPAND_RECENT",
|
|
||||||
"diff_view": "SIDE_BY_SIDE",
|
"diff_view": "SIDE_BY_SIDE",
|
||||||
"my": [
|
"my": [
|
||||||
{
|
{
|
||||||
@ -1006,7 +1004,6 @@ link:#preferences-info[PreferencesInfo] entity.
|
|||||||
"time_format": "HHMM_12",
|
"time_format": "HHMM_12",
|
||||||
"size_bar_in_change_table": true,
|
"size_bar_in_change_table": true,
|
||||||
"review_category_strategy": "NAME",
|
"review_category_strategy": "NAME",
|
||||||
"comment_visibility_strategy": "EXPAND_RECENT",
|
|
||||||
"diff_view": "SIDE_BY_SIDE",
|
"diff_view": "SIDE_BY_SIDE",
|
||||||
"my": [
|
"my": [
|
||||||
{
|
{
|
||||||
@ -1380,8 +1377,6 @@ Allowed values are `STD`, `US`, `ISO`, `EURO`, `UK`.
|
|||||||
|`time_format` ||
|
|`time_format` ||
|
||||||
The format to display the time in.
|
The format to display the time in.
|
||||||
Allowed values are `HHMM_12`, `HHMM_24`.
|
Allowed values are `HHMM_12`, `HHMM_24`.
|
||||||
|`reverse_patch_set_order` |not set if `false`|
|
|
||||||
Whether to display the patch sets in reverse order.
|
|
||||||
|`relative_date_in_change_table` |not set if `false`|
|
|`relative_date_in_change_table` |not set if `false`|
|
||||||
Whether to show relative dates in the changes table.
|
Whether to show relative dates in the changes table.
|
||||||
|`size_bar_in_change_table` |not set if `false`|
|
|`size_bar_in_change_table` |not set if `false`|
|
||||||
@ -1391,15 +1386,9 @@ Whether to show change number in the change table.
|
|||||||
|`review_category_strategy` ||
|
|`review_category_strategy` ||
|
||||||
The strategy used to displayed info in the review category column.
|
The strategy used to displayed info in the review category column.
|
||||||
Allowed values are `NONE`, `NAME`, `EMAIL`, `USERNAME`, `ABBREV`.
|
Allowed values are `NONE`, `NAME`, `EMAIL`, `USERNAME`, `ABBREV`.
|
||||||
|`comment_visibility_strategy` ||
|
|
||||||
The strategy used to display the comments.
|
|
||||||
Allowed values are `COLLAPSE_ALL`, `EXPAND_MOST_RECENT`, `EXPAND_RECENT`, `EXPAND_ALL`.
|
|
||||||
|`diff_view` ||
|
|`diff_view` ||
|
||||||
The type of diff view to show.
|
The type of diff view to show.
|
||||||
Allowed values are `SIDE_BY_SIDE`, `UNIFIED_DIFF`.
|
Allowed values are `SIDE_BY_SIDE`, `UNIFIED_DIFF`.
|
||||||
|`change_screen` ||
|
|
||||||
The change screen to use.
|
|
||||||
Allowed values are `OLD_UI`, `CHANGE_SCREEN2`.
|
|
||||||
|=====================================
|
|=====================================
|
||||||
|
|
||||||
[[preferences-input]]
|
[[preferences-input]]
|
||||||
@ -1429,8 +1418,6 @@ Allowed values are `STD`, `US`, `ISO`, `EURO`, `UK`.
|
|||||||
|`time_format` |optional|
|
|`time_format` |optional|
|
||||||
The format to display the time in.
|
The format to display the time in.
|
||||||
Allowed values are `HHMM_12`, `HHMM_24`.
|
Allowed values are `HHMM_12`, `HHMM_24`.
|
||||||
|`reverse_patch_set_order` |optional|
|
|
||||||
Whether to display the patch sets in reverse order.
|
|
||||||
|`relative_date_in_change_table` |optional|
|
|`relative_date_in_change_table` |optional|
|
||||||
Whether to show relative dates in the changes table.
|
Whether to show relative dates in the changes table.
|
||||||
|`size_bar_in_change_table` |optional|
|
|`size_bar_in_change_table` |optional|
|
||||||
@ -1440,15 +1427,9 @@ Whether to show change number in the change table.
|
|||||||
|`review_category_strategy` |optional|
|
|`review_category_strategy` |optional|
|
||||||
The strategy used to displayed info in the review category column.
|
The strategy used to displayed info in the review category column.
|
||||||
Allowed values are `NONE`, `NAME`, `EMAIL`, `USERNAME`, `ABBREV`.
|
Allowed values are `NONE`, `NAME`, `EMAIL`, `USERNAME`, `ABBREV`.
|
||||||
|`comment_visibility_strategy` |optional|
|
|
||||||
The strategy used to display the comments.
|
|
||||||
Allowed values are `COLLAPSE_ALL`, `EXPAND_MOST_RECENT`, `EXPAND_RECENT`, `EXPAND_ALL`.
|
|
||||||
|`diff_view` |optional|
|
|`diff_view` |optional|
|
||||||
The type of diff view to show.
|
The type of diff view to show.
|
||||||
Allowed values are `SIDE_BY_SIDE`, `UNIFIED_DIFF`.
|
Allowed values are `SIDE_BY_SIDE`, `UNIFIED_DIFF`.
|
||||||
|`change_screen` |optional|
|
|
||||||
The change screen to use.
|
|
||||||
Allowed values are `OLD_UI`, `CHANGE_SCREEN2`.
|
|
||||||
|=====================================
|
|=====================================
|
||||||
|
|
||||||
[[diff-preferences-info]]
|
[[diff-preferences-info]]
|
||||||
|
@ -698,20 +698,6 @@ controls below the change info block.
|
|||||||
|
|
||||||
image::images/user-review-ui-change-screen-plugin-extensions.png[width=800, link="images/user-review-ui-change-screen-plugin-extensions.png"]
|
image::images/user-review-ui-change-screen-plugin-extensions.png[width=800, link="images/user-review-ui-change-screen-plugin-extensions.png"]
|
||||||
|
|
||||||
[[old-change-screen]]
|
|
||||||
=== Old Change Screen
|
|
||||||
|
|
||||||
In addition to the normal change screen, this Gerrit version still
|
|
||||||
includes the old change screen that was used in earlier Gerrit
|
|
||||||
versions. Users that want to continue using the old change screen can
|
|
||||||
configure it in their preferences under
|
|
||||||
`Settings` > `Preferences` > `Change View`:
|
|
||||||
|
|
||||||
image::images/user-review-ui-change-view-preference.png[width=800, link="images/user-review-ui-change-view-preference.png"]
|
|
||||||
|
|
||||||
[WARNING]
|
|
||||||
The old change screen will be removed in a later version of Gerrit.
|
|
||||||
|
|
||||||
[[side-by-side]]
|
[[side-by-side]]
|
||||||
== Side-by-Side Diff Screen
|
== Side-by-Side Diff Screen
|
||||||
|
|
||||||
@ -1156,15 +1142,6 @@ Limitations of the new review UI:
|
|||||||
- The new side-by-side diff screen isn't able to highlight line
|
- The new side-by-side diff screen isn't able to highlight line
|
||||||
endings.
|
endings.
|
||||||
|
|
||||||
- Unified diff view is missing:
|
|
||||||
+
|
|
||||||
By setting `Diff View (New Change Screen)` in the user preferences to
|
|
||||||
`Unified Diff` the new change screen can be configured to open the file
|
|
||||||
diffs in the old unified diff view.
|
|
||||||
|
|
||||||
Users preferring the old review UI can link:#old-change-screen[
|
|
||||||
configure the change view] in their preferences.
|
|
||||||
|
|
||||||
GERRIT
|
GERRIT
|
||||||
------
|
------
|
||||||
Part of link:index.html[Gerrit Code Review]
|
Part of link:index.html[Gerrit Code Review]
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
// Copyright (C) 2008 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.common.data;
|
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ApprovalDetail {
|
|
||||||
public static List<ApprovalDetail> sort(Collection<ApprovalDetail> ads,
|
|
||||||
final int owner) {
|
|
||||||
List<ApprovalDetail> sorted = new ArrayList<>(ads);
|
|
||||||
Collections.sort(sorted, new Comparator<ApprovalDetail>() {
|
|
||||||
@Override
|
|
||||||
public int compare(ApprovalDetail o1, ApprovalDetail o2) {
|
|
||||||
int byOwner = (o2.account.get() == owner ? 1 : 0)
|
|
||||||
- (o1.account.get() == owner ? 1 : 0);
|
|
||||||
return byOwner != 0 ? byOwner : (o1.hasNonZero - o2.hasNonZero);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return sorted;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Account.Id account;
|
|
||||||
protected List<PatchSetApproval> approvals;
|
|
||||||
protected boolean canRemove;
|
|
||||||
private Set<String> votable;
|
|
||||||
|
|
||||||
private transient Set<String> approved;
|
|
||||||
private transient Set<String> rejected;
|
|
||||||
private transient Map<String, Integer> values;
|
|
||||||
private transient int hasNonZero;
|
|
||||||
|
|
||||||
protected ApprovalDetail() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApprovalDetail(final Account.Id id) {
|
|
||||||
account = id;
|
|
||||||
approvals = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Account.Id getAccount() {
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canRemove() {
|
|
||||||
return canRemove;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanRemove(boolean removeable) {
|
|
||||||
canRemove = removeable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void approved(String label) {
|
|
||||||
if (approved == null) {
|
|
||||||
approved = new HashSet<>();
|
|
||||||
}
|
|
||||||
approved.add(label);
|
|
||||||
hasNonZero = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rejected(String label) {
|
|
||||||
if (rejected == null) {
|
|
||||||
rejected = new HashSet<>();
|
|
||||||
}
|
|
||||||
rejected.add(label);
|
|
||||||
hasNonZero = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void votable(String label) {
|
|
||||||
if (votable == null) {
|
|
||||||
votable = new HashSet<>();
|
|
||||||
}
|
|
||||||
votable.add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void value(String label, int value) {
|
|
||||||
if (values == null) {
|
|
||||||
values = new HashMap<>();
|
|
||||||
}
|
|
||||||
values.put(label, value);
|
|
||||||
if (value != 0) {
|
|
||||||
hasNonZero = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isApproved(String label) {
|
|
||||||
return approved != null && approved.contains(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRejected(String label) {
|
|
||||||
return rejected != null && rejected.contains(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canVote(String label) {
|
|
||||||
return votable != null && votable.contains(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue(String label) {
|
|
||||||
if (values == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Integer v = values.get(label);
|
|
||||||
return v != null ? v : 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,286 +0,0 @@
|
|||||||
// Copyright (C) 2008 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.common.data;
|
|
||||||
|
|
||||||
import com.google.gerrit.extensions.common.SubmitType;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** Detail necessary to display a change. */
|
|
||||||
public class ChangeDetail {
|
|
||||||
protected AccountInfoCache accounts;
|
|
||||||
protected boolean allowsAnonymous;
|
|
||||||
protected boolean canAbandon;
|
|
||||||
protected boolean canEditCommitMessage;
|
|
||||||
protected boolean canCherryPick;
|
|
||||||
protected boolean canEditHashtags;
|
|
||||||
protected boolean canPublish;
|
|
||||||
protected boolean canRebase;
|
|
||||||
protected boolean canRestore;
|
|
||||||
protected boolean canRevert;
|
|
||||||
protected boolean canDeleteDraft;
|
|
||||||
protected Change change;
|
|
||||||
protected boolean starred;
|
|
||||||
protected List<ChangeInfo> dependsOn;
|
|
||||||
protected List<ChangeInfo> neededBy;
|
|
||||||
protected List<PatchSet> patchSets;
|
|
||||||
protected Set<PatchSet.Id> patchSetsWithDraftComments;
|
|
||||||
protected List<SubmitRecord> submitRecords;
|
|
||||||
protected SubmitType submitType;
|
|
||||||
protected SubmitTypeRecord submitTypeRecord;
|
|
||||||
protected boolean canSubmit;
|
|
||||||
protected boolean mergeable;
|
|
||||||
protected List<ChangeMessage> messages;
|
|
||||||
protected PatchSet.Id currentPatchSetId;
|
|
||||||
protected PatchSetDetail currentDetail;
|
|
||||||
protected boolean canEdit;
|
|
||||||
protected boolean canEditTopicName;
|
|
||||||
|
|
||||||
public ChangeDetail() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccountInfoCache getAccounts() {
|
|
||||||
return accounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccounts(AccountInfoCache aic) {
|
|
||||||
accounts = aic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllowsAnonymous() {
|
|
||||||
return allowsAnonymous;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllowsAnonymous(final boolean anon) {
|
|
||||||
allowsAnonymous = anon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canAbandon() {
|
|
||||||
return canAbandon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanAbandon(final boolean a) {
|
|
||||||
canAbandon = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canEditCommitMessage() {
|
|
||||||
return canEditCommitMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanEditCommitMessage(final boolean a) {
|
|
||||||
canEditCommitMessage = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canCherryPick() {
|
|
||||||
return canCherryPick;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanCherryPick(final boolean a) {
|
|
||||||
canCherryPick = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getCanEditHashtags() {
|
|
||||||
return canEditHashtags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanEditHashtags(final boolean a) {
|
|
||||||
canEditHashtags = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canPublish() {
|
|
||||||
return canPublish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanPublish(final boolean a) {
|
|
||||||
canPublish = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canRebase() {
|
|
||||||
return canRebase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanRebase(final boolean a) {
|
|
||||||
canRebase = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canRestore() {
|
|
||||||
return canRestore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanRestore(final boolean a) {
|
|
||||||
canRestore = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canRevert() {
|
|
||||||
return canRevert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanRevert(boolean a) {
|
|
||||||
canRevert = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSubmit() {
|
|
||||||
return canSubmit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanSubmit(boolean a) {
|
|
||||||
canSubmit = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canDeleteDraft() {
|
|
||||||
return canDeleteDraft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanDeleteDraft(boolean a) {
|
|
||||||
canDeleteDraft = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canEditTopicName() {
|
|
||||||
return canEditTopicName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanEditTopicName(boolean a) {
|
|
||||||
canEditTopicName = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Change getChange() {
|
|
||||||
return change;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChange(final Change change) {
|
|
||||||
this.change = change;
|
|
||||||
this.currentPatchSetId = change.currentPatchSetId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStarred() {
|
|
||||||
return starred;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStarred(final boolean s) {
|
|
||||||
starred = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChangeInfo> getDependsOn() {
|
|
||||||
return dependsOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDependsOn(List<ChangeInfo> d) {
|
|
||||||
dependsOn = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChangeInfo> getNeededBy() {
|
|
||||||
return neededBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNeededBy(List<ChangeInfo> d) {
|
|
||||||
neededBy = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChangeMessage> getMessages() {
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessages(List<ChangeMessage> m) {
|
|
||||||
messages = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PatchSet> getPatchSets() {
|
|
||||||
return patchSets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPatchSets(List<PatchSet> s) {
|
|
||||||
patchSets = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPatchSetsWithDraftComments(Set<PatchSet.Id> pwdc) {
|
|
||||||
this.patchSetsWithDraftComments = pwdc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDraftComments(PatchSet.Id id) {
|
|
||||||
return patchSetsWithDraftComments.contains(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmitRecords(List<SubmitRecord> all) {
|
|
||||||
submitRecords = all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubmitRecord> getSubmitRecords() {
|
|
||||||
return submitRecords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubmitTypeRecord(SubmitTypeRecord submitTypeRecord) {
|
|
||||||
this.submitTypeRecord = submitTypeRecord;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubmitTypeRecord getSubmitTypeRecord() {
|
|
||||||
return submitTypeRecord;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCurrentPatchSet(final PatchSetDetail detail) {
|
|
||||||
return currentPatchSetId != null
|
|
||||||
&& detail.getPatchSet().getId().equals(currentPatchSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatchSet getCurrentPatchSet() {
|
|
||||||
if (currentPatchSetId != null) {
|
|
||||||
// We search through the list backwards because its *very* likely
|
|
||||||
// that the current patch set is also the last patch set.
|
|
||||||
//
|
|
||||||
for (int i = patchSets.size() - 1; i >= 0; i--) {
|
|
||||||
final PatchSet ps = patchSets.get(i);
|
|
||||||
if (ps.getId().equals(currentPatchSetId)) {
|
|
||||||
return ps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatchSetDetail getCurrentPatchSetDetail() {
|
|
||||||
return currentDetail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentPatchSetDetail(PatchSetDetail d) {
|
|
||||||
currentDetail = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentPatchSetId(final PatchSet.Id id) {
|
|
||||||
currentPatchSetId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return currentDetail != null ? currentDetail.getInfo().getMessage() : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanEdit(boolean a) {
|
|
||||||
canEdit = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canEdit() {
|
|
||||||
return canEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMergeable(boolean m) {
|
|
||||||
mergeable = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMergeable() {
|
|
||||||
return mergeable;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,6 @@ package com.google.gerrit.common.data;
|
|||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Account.FieldName;
|
import com.google.gerrit.reviewdb.client.Account.FieldName;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
|
||||||
import com.google.gerrit.reviewdb.client.AuthType;
|
import com.google.gerrit.reviewdb.client.AuthType;
|
||||||
@ -53,7 +52,6 @@ public class GerritConfig implements Cloneable {
|
|||||||
protected String anonymousCowardName;
|
protected String anonymousCowardName;
|
||||||
protected int suggestFrom;
|
protected int suggestFrom;
|
||||||
protected int changeUpdateDelay;
|
protected int changeUpdateDelay;
|
||||||
protected AccountGeneralPreferences.ChangeScreen changeScreen;
|
|
||||||
protected List<String> archiveFormats;
|
protected List<String> archiveFormats;
|
||||||
protected int largeChangeSize;
|
protected int largeChangeSize;
|
||||||
protected String replyLabel;
|
protected String replyLabel;
|
||||||
@ -278,14 +276,6 @@ public class GerritConfig implements Cloneable {
|
|||||||
changeUpdateDelay = seconds;
|
changeUpdateDelay = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountGeneralPreferences.ChangeScreen getChangeScreen() {
|
|
||||||
return changeScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChangeScreen(AccountGeneralPreferences.ChangeScreen ui) {
|
|
||||||
this.changeScreen = ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLargeChangeSize() {
|
public int getLargeChangeSize() {
|
||||||
return largeChangeSize;
|
return largeChangeSize;
|
||||||
}
|
}
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
// Copyright (C) 2009 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.common.data;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Result from adding or removing a reviewer from a change.
|
|
||||||
*/
|
|
||||||
public class ReviewerResult {
|
|
||||||
protected List<Error> errors;
|
|
||||||
protected ChangeDetail change;
|
|
||||||
protected int memberCount;
|
|
||||||
protected boolean askForConfirmation;
|
|
||||||
|
|
||||||
public ReviewerResult() {
|
|
||||||
errors = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addError(final Error e) {
|
|
||||||
errors.add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Error> getErrors() {
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangeDetail getChange() {
|
|
||||||
return change;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChange(final ChangeDetail d) {
|
|
||||||
change = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMemberCount() {
|
|
||||||
return memberCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemberCount(final int memberCount) {
|
|
||||||
this.memberCount = memberCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean askForConfirmation() {
|
|
||||||
return askForConfirmation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAskForConfirmation(final boolean askForConfirmation) {
|
|
||||||
this.askForConfirmation = askForConfirmation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Error {
|
|
||||||
public static enum Type {
|
|
||||||
/** Name supplied does not match to a registered account or account group. */
|
|
||||||
REVIEWER_NOT_FOUND,
|
|
||||||
|
|
||||||
/** The account is inactive. */
|
|
||||||
ACCOUNT_INACTIVE,
|
|
||||||
|
|
||||||
/** The account is not permitted to see the change. */
|
|
||||||
CHANGE_NOT_VISIBLE,
|
|
||||||
|
|
||||||
/** The groups has no members. */
|
|
||||||
GROUP_EMPTY,
|
|
||||||
|
|
||||||
/** The groups has too many members. */
|
|
||||||
GROUP_HAS_TOO_MANY_MEMBERS,
|
|
||||||
|
|
||||||
/** The group is not allowed to be added as reviewer. */
|
|
||||||
GROUP_NOT_ALLOWED,
|
|
||||||
|
|
||||||
/** Could not remove this reviewer from the change due to ORMException. */
|
|
||||||
COULD_NOT_REMOVE,
|
|
||||||
|
|
||||||
/** Not permitted to remove this reviewer from the change. */
|
|
||||||
REMOVE_NOT_PERMITTED
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Type type;
|
|
||||||
protected String name;
|
|
||||||
|
|
||||||
protected Error() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Error(final Type type, final String who) {
|
|
||||||
this.type = type;
|
|
||||||
this.name = who;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return type + " " + name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -68,11 +68,8 @@ import com.google.gerrit.client.api.ExtensionScreen;
|
|||||||
import com.google.gerrit.client.change.ChangeScreen2;
|
import com.google.gerrit.client.change.ChangeScreen2;
|
||||||
import com.google.gerrit.client.change.FileTable;
|
import com.google.gerrit.client.change.FileTable;
|
||||||
import com.google.gerrit.client.changes.AccountDashboardScreen;
|
import com.google.gerrit.client.changes.AccountDashboardScreen;
|
||||||
import com.google.gerrit.client.changes.ChangeScreen;
|
|
||||||
import com.google.gerrit.client.changes.CustomDashboardScreen;
|
import com.google.gerrit.client.changes.CustomDashboardScreen;
|
||||||
import com.google.gerrit.client.changes.PatchTable;
|
|
||||||
import com.google.gerrit.client.changes.ProjectDashboardScreen;
|
import com.google.gerrit.client.changes.ProjectDashboardScreen;
|
||||||
import com.google.gerrit.client.changes.PublishCommentScreen;
|
|
||||||
import com.google.gerrit.client.changes.QueryScreen;
|
import com.google.gerrit.client.changes.QueryScreen;
|
||||||
import com.google.gerrit.client.dashboards.DashboardInfo;
|
import com.google.gerrit.client.dashboards.DashboardInfo;
|
||||||
import com.google.gerrit.client.dashboards.DashboardList;
|
import com.google.gerrit.client.dashboards.DashboardList;
|
||||||
@ -82,14 +79,12 @@ import com.google.gerrit.client.documentation.DocScreen;
|
|||||||
import com.google.gerrit.client.editor.EditScreen;
|
import com.google.gerrit.client.editor.EditScreen;
|
||||||
import com.google.gerrit.client.groups.GroupApi;
|
import com.google.gerrit.client.groups.GroupApi;
|
||||||
import com.google.gerrit.client.groups.GroupInfo;
|
import com.google.gerrit.client.groups.GroupInfo;
|
||||||
import com.google.gerrit.client.patches.PatchScreen;
|
import com.google.gerrit.client.patches.UnifiedPatchScreen;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
import com.google.gerrit.client.rpc.RestApi;
|
||||||
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;
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
@ -99,19 +94,11 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.RunAsyncCallback;
|
import com.google.gwt.core.client.RunAsyncCallback;
|
||||||
import com.google.gwt.http.client.URL;
|
import com.google.gwt.http.client.URL;
|
||||||
import com.google.gwt.user.client.Cookies;
|
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwtorm.client.KeyUtil;
|
import com.google.gwtorm.client.KeyUtil;
|
||||||
|
|
||||||
public class Dispatcher {
|
public class Dispatcher {
|
||||||
public static final String COOKIE_CS2 = "gerrit_cs2";
|
public static String toSideBySide(PatchSet.Id diffBase, Patch.Key id) {
|
||||||
public static boolean changeScreen2;
|
|
||||||
|
|
||||||
public static String toPatchSideBySide(final Patch.Key id) {
|
|
||||||
return toPatch("", null, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toPatchSideBySide(PatchSet.Id diffBase, Patch.Key id) {
|
|
||||||
return toPatch("", diffBase, id);
|
return toPatch("", diffBase, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,18 +117,18 @@ public class Dispatcher {
|
|||||||
return toPatch("unified", diffBase, revision, fileName, null, 0);
|
return toPatch("unified", diffBase, revision, fileName, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toPatchUnified(final Patch.Key id) {
|
public static String toUnified(PatchSet.Id diffBase, Patch.Key id) {
|
||||||
return toPatch("unified", null, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toPatchUnified(PatchSet.Id diffBase, Patch.Key id) {
|
|
||||||
return toPatch("unified", diffBase, id);
|
return toPatch("unified", diffBase, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toPatch(String type, PatchSet.Id diffBase, Patch.Key id) {
|
public static String toPatch(String type, PatchSet.Id diffBase, Patch.Key id) {
|
||||||
return toPatch(type, diffBase, id.getParentKey(), id.get(), null, 0);
|
return toPatch(type, diffBase, id.getParentKey(), id.get(), null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toEditScreen(PatchSet.Id revision, String fileName) {
|
||||||
|
return toPatch("edit", null, revision, fileName, null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
private static String toPatch(String type, PatchSet.Id diffBase,
|
private static String toPatch(String type, PatchSet.Id diffBase,
|
||||||
PatchSet.Id revision, String fileName, DisplaySide side, int line) {
|
PatchSet.Id revision, String fileName, DisplaySide side, int line) {
|
||||||
Change.Id c = revision.getParentKey();
|
Change.Id c = revision.getParentKey();
|
||||||
@ -151,7 +138,8 @@ public class Dispatcher {
|
|||||||
p.append(diffBase.get()).append("..");
|
p.append(diffBase.get()).append("..");
|
||||||
}
|
}
|
||||||
p.append(revision.getId()).append("/").append(KeyUtil.encode(fileName));
|
p.append(revision.getId()).append("/").append(KeyUtil.encode(fileName));
|
||||||
if (type != null && !type.isEmpty()) {
|
if (type != null && !type.isEmpty()
|
||||||
|
&& (!"sidebyside".equals(type) || preferUnified())) {
|
||||||
p.append(",").append(type);
|
p.append(",").append(type);
|
||||||
}
|
}
|
||||||
if (side == DisplaySide.A && line > 0) {
|
if (side == DisplaySide.A && line > 0) {
|
||||||
@ -162,28 +150,6 @@ public class Dispatcher {
|
|||||||
return p.toString();
|
return p.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toPatch(final PatchScreen.Type type, final Patch.Key id) {
|
|
||||||
if (type == PatchScreen.Type.SIDE_BY_SIDE) {
|
|
||||||
return toPatchSideBySide(id);
|
|
||||||
} else {
|
|
||||||
return toPatchUnified(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toEditScreen(PatchSet.Id revision, String fileName) {
|
|
||||||
Change.Id c = revision.getParentKey();
|
|
||||||
StringBuilder p = new StringBuilder();
|
|
||||||
p.append("/c/").append(c).append("/");
|
|
||||||
p.append(revision.getId()).append("/").append(KeyUtil.encode(fileName));
|
|
||||||
p.append(",edit");
|
|
||||||
return p.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toPublish(PatchSet.Id ps) {
|
|
||||||
Change.Id c = ps.getParentKey();
|
|
||||||
return "/c/" + c + "/" + ps.get() + ",publish";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toGroup(final AccountGroup.Id id) {
|
public static String toGroup(final AccountGroup.Id id) {
|
||||||
return ADMIN_GROUPS + id.toString();
|
return ADMIN_GROUPS + id.toString();
|
||||||
}
|
}
|
||||||
@ -275,7 +241,6 @@ public class Dispatcher {
|
|||||||
Gerrit.display(token, new MyGroupsListScreen());
|
Gerrit.display(token, new MyGroupsListScreen());
|
||||||
|
|
||||||
} else if (/* DEPRECATED URL */matchPrefix("/c2/", token)) {
|
} else if (/* DEPRECATED URL */matchPrefix("/c2/", token)) {
|
||||||
changeScreen2 = true;
|
|
||||||
change(token);
|
change(token);
|
||||||
} else if (/* LEGACY URL */matchPrefix("all,", token)) {
|
} else if (/* LEGACY URL */matchPrefix("all,", token)) {
|
||||||
redirectFromLegacyToken(token, legacyAll(token));
|
redirectFromLegacyToken(token, legacyAll(token));
|
||||||
@ -384,11 +349,11 @@ public class Dispatcher {
|
|||||||
|
|
||||||
private static String legacyPatch(String token) {
|
private static String legacyPatch(String token) {
|
||||||
if (/* LEGACY URL */matchPrefix("patch,sidebyside,", token)) {
|
if (/* LEGACY URL */matchPrefix("patch,sidebyside,", token)) {
|
||||||
return toPatchSideBySide(Patch.Key.parse(skip(token)));
|
return toPatch("", null, Patch.Key.parse(skip(token)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/* LEGACY URL */matchPrefix("patch,unified,", token)) {
|
if (/* LEGACY URL */matchPrefix("patch,unified,", token)) {
|
||||||
return toPatchUnified(Patch.Key.parse(skip(token)));
|
return toPatch("unified", null, Patch.Key.parse(skip(token)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -553,9 +518,7 @@ public class Dispatcher {
|
|||||||
panel = null;
|
panel = null;
|
||||||
}
|
}
|
||||||
Gerrit.display(token, panel == null
|
Gerrit.display(token, panel == null
|
||||||
? (isChangeScreen2()
|
? new ChangeScreen2(id, null, null, false, mode)
|
||||||
? new ChangeScreen2(id, null, null, false, mode)
|
|
||||||
: new ChangeScreen(id))
|
|
||||||
: new NotFoundScreen());
|
: new NotFoundScreen());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -593,19 +556,15 @@ public class Dispatcher {
|
|||||||
rest = rest.substring(0, at);
|
rest = rest.substring(0, at);
|
||||||
}
|
}
|
||||||
Patch.Key p = new Patch.Key(ps, KeyUtil.decode(rest));
|
Patch.Key p = new Patch.Key(ps, KeyUtil.decode(rest));
|
||||||
patch(token, base, p, side, line, 0,
|
patch(token, base, p, side, line, panel);
|
||||||
null, null, null, panel);
|
|
||||||
} else {
|
} else {
|
||||||
if (panel == null) {
|
if (panel == null) {
|
||||||
Gerrit.display(token, isChangeScreen2()
|
Gerrit.display(token,
|
||||||
? new ChangeScreen2(id,
|
new ChangeScreen2(id,
|
||||||
base != null
|
base != null
|
||||||
? String.valueOf(base.get())
|
? String.valueOf(base.get())
|
||||||
: null,
|
: null,
|
||||||
String.valueOf(ps.get()), false, FileTable.Mode.REVIEW)
|
String.valueOf(ps.get()), false, FileTable.Mode.REVIEW));
|
||||||
: new ChangeScreen(id));
|
|
||||||
} else if ("publish".equals(panel)) {
|
|
||||||
publish(ps);
|
|
||||||
} else {
|
} else {
|
||||||
Gerrit.display(token, new NotFoundScreen());
|
Gerrit.display(token, new NotFoundScreen());
|
||||||
}
|
}
|
||||||
@ -627,125 +586,50 @@ public class Dispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChangeScreen2() {
|
private static void patch(String token,
|
||||||
if (changeScreen2) {
|
PatchSet.Id baseId,
|
||||||
return true;
|
Patch.Key id,
|
||||||
}
|
DisplaySide side,
|
||||||
|
int line,
|
||||||
AccountGeneralPreferences.ChangeScreen ui = null;
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
ui = Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences()
|
|
||||||
.getChangeScreen();
|
|
||||||
}
|
|
||||||
String v = Cookies.getCookie(Dispatcher.COOKIE_CS2);
|
|
||||||
if (v != null) {
|
|
||||||
changeScreen2 = "1".equals(v);
|
|
||||||
return changeScreen2;
|
|
||||||
}
|
|
||||||
if (ui == null) {
|
|
||||||
ui = Gerrit.getConfig().getChangeScreen();
|
|
||||||
}
|
|
||||||
return ui == AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void publish(final PatchSet.Id ps) {
|
|
||||||
String token = toPublish(ps);
|
|
||||||
new AsyncSplit(token) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
Gerrit.display(token, select());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Screen select() {
|
|
||||||
return new PublishCommentScreen(ps);
|
|
||||||
}
|
|
||||||
}.onSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void patch(String token, PatchSet.Id base, Patch.Key id,
|
|
||||||
int patchIndex, PatchSetDetail patchSetDetail,
|
|
||||||
PatchTable patchTable, PatchScreen.TopView topView) {
|
|
||||||
patch(token, base, id, null, 0, patchIndex,
|
|
||||||
patchSetDetail, patchTable, topView, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void patch(String token, PatchSet.Id baseId,
|
|
||||||
Patch.Key id, DisplaySide side, int line,
|
|
||||||
int patchIndex, PatchSetDetail patchSetDetail,
|
|
||||||
PatchTable patchTable, PatchScreen.TopView topView,
|
|
||||||
String panelType) {
|
String panelType) {
|
||||||
if (id == null) {
|
|
||||||
Gerrit.display(token, new NotFoundScreen());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String panel = panelType;
|
String panel = panelType;
|
||||||
if (panel == null) {
|
if (panel == null) {
|
||||||
int c = token.lastIndexOf(',');
|
int c = token.lastIndexOf(',');
|
||||||
panel = 0 <= c ? token.substring(c + 1) : "";
|
panel = 0 <= c ? token.substring(c + 1) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("".equals(panel)) {
|
if ("".equals(panel) || /* DEPRECATED URL */"cm".equals(panel)) {
|
||||||
if (isChangeScreen2()) {
|
if (preferUnified()) {
|
||||||
if (Gerrit.isSignedIn()
|
unified1(token, baseId, id);
|
||||||
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
} else {
|
||||||
.getGeneralPreferences().getDiffView())) {
|
|
||||||
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable,
|
|
||||||
topView, PatchScreen.Type.UNIFIED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sbs2(token, baseId, id, side, line, false);
|
sbs2(token, baseId, id, side, line, false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
} else if ("sidebyside".equals(panel)) {
|
||||||
PatchScreen.Type.SIDE_BY_SIDE);
|
sbs2(token, null, id, side, line, false);
|
||||||
return;
|
|
||||||
} else if ("unified".equals(panel)) {
|
} else if ("unified".equals(panel)) {
|
||||||
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
unified1(token, baseId, id);
|
||||||
PatchScreen.Type.UNIFIED);
|
} else if ("edit".equals(panel)) {
|
||||||
return;
|
sbs2(token, null, id, side, line, true);
|
||||||
} else if ("cm".equals(panel)) {
|
} else {
|
||||||
if (Gerrit.isSignedIn()
|
Gerrit.display(token, new NotFoundScreen());
|
||||||
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences().getDiffView())) {
|
|
||||||
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable,
|
|
||||||
topView, PatchScreen.Type.UNIFIED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sbs2(token, baseId, id, side, line, false);
|
|
||||||
return;
|
|
||||||
} else if ("".equals(panel) || "sidebyside".equals(panel)) {
|
|
||||||
sbs1(token, baseId, id, patchIndex, patchSetDetail, patchTable, topView,
|
|
||||||
PatchScreen.Type.SIDE_BY_SIDE);
|
|
||||||
return;
|
|
||||||
} else if (panel.equals("edit")) {
|
|
||||||
sbs2(token, null, id, null, 0, true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Gerrit.display(token, new NotFoundScreen());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sbs1(final String token, final PatchSet.Id baseId,
|
private static boolean preferUnified() {
|
||||||
final Patch.Key id, final int patchIndex,
|
return Gerrit.isSignedIn()
|
||||||
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
|
&& DiffView.UNIFIED_DIFF.equals(Gerrit.getUserAccount()
|
||||||
final PatchScreen.TopView topView, final PatchScreen.Type type) {
|
.getGeneralPreferences()
|
||||||
|
.getDiffView());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void unified1(final String token,
|
||||||
|
final PatchSet.Id baseId,
|
||||||
|
final Patch.Key id) {
|
||||||
GWT.runAsync(new AsyncSplit(token) {
|
GWT.runAsync(new AsyncSplit(token) {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
PatchScreen.TopView top = topView == null
|
UnifiedPatchScreen.TopView top = Gerrit.getPatchScreenTopView();
|
||||||
? Gerrit.getPatchScreenTopView()
|
Gerrit.display(token, new UnifiedPatchScreen(id, top, baseId));
|
||||||
: topView;
|
|
||||||
switch (type) {
|
|
||||||
case SIDE_BY_SIDE:
|
|
||||||
Gerrit.display(token, new PatchScreen.SideBySide(id, patchIndex,
|
|
||||||
patchSetDetail, patchTable, top, baseId));
|
|
||||||
break;
|
|
||||||
case UNIFIED:
|
|
||||||
Gerrit.display(token, new PatchScreen.Unified(id, patchIndex,
|
|
||||||
patchSetDetail, patchTable, top, baseId));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -31,14 +31,13 @@ import com.google.gerrit.client.config.ConfigServerApi;
|
|||||||
import com.google.gerrit.client.extensions.TopMenu;
|
import com.google.gerrit.client.extensions.TopMenu;
|
||||||
import com.google.gerrit.client.extensions.TopMenuItem;
|
import com.google.gerrit.client.extensions.TopMenuItem;
|
||||||
import com.google.gerrit.client.extensions.TopMenuList;
|
import com.google.gerrit.client.extensions.TopMenuList;
|
||||||
import com.google.gerrit.client.patches.PatchScreen;
|
import com.google.gerrit.client.patches.UnifiedPatchScreen;
|
||||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
import com.google.gerrit.client.rpc.Natives;
|
||||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
import com.google.gerrit.client.ui.LinkMenuBar;
|
||||||
import com.google.gerrit.client.ui.LinkMenuItem;
|
import com.google.gerrit.client.ui.LinkMenuItem;
|
||||||
import com.google.gerrit.client.ui.MorphingTabPanel;
|
import com.google.gerrit.client.ui.MorphingTabPanel;
|
||||||
import com.google.gerrit.client.ui.PatchLink;
|
|
||||||
import com.google.gerrit.client.ui.ProjectLinkMenuItem;
|
import com.google.gerrit.client.ui.ProjectLinkMenuItem;
|
||||||
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;
|
||||||
@ -125,7 +124,7 @@ public class Gerrit implements EntryPoint {
|
|||||||
private static SearchPanel searchPanel;
|
private static SearchPanel searchPanel;
|
||||||
private static final Dispatcher dispatcher = new Dispatcher();
|
private static final Dispatcher dispatcher = new Dispatcher();
|
||||||
private static ViewSite<Screen> body;
|
private static ViewSite<Screen> body;
|
||||||
private static PatchScreen patchScreen;
|
private static UnifiedPatchScreen patchScreen;
|
||||||
private static String lastChangeListToken;
|
private static String lastChangeListToken;
|
||||||
private static String lastViewToken;
|
private static String lastViewToken;
|
||||||
|
|
||||||
@ -139,7 +138,7 @@ public class Gerrit implements EntryPoint {
|
|||||||
Window.Location.reload();
|
Window.Location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PatchScreen.TopView getPatchScreenTopView() {
|
public static UnifiedPatchScreen.TopView getPatchScreenTopView() {
|
||||||
if (patchScreen == null) {
|
if (patchScreen == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -205,8 +204,8 @@ public class Gerrit implements EntryPoint {
|
|||||||
*/
|
*/
|
||||||
public static void updateMenus(Screen view) {
|
public static void updateMenus(Screen view) {
|
||||||
LinkMenuBar diffBar = menuBars.get(GerritTopMenu.DIFFERENCES.menuName);
|
LinkMenuBar diffBar = menuBars.get(GerritTopMenu.DIFFERENCES.menuName);
|
||||||
if (view instanceof PatchScreen) {
|
if (view instanceof UnifiedPatchScreen) {
|
||||||
patchScreen = (PatchScreen) view;
|
patchScreen = (UnifiedPatchScreen) view;
|
||||||
menuLeft.setVisible(diffBar, true);
|
menuLeft.setVisible(diffBar, true);
|
||||||
menuLeft.selectTab(menuLeft.getWidgetIndex(diffBar));
|
menuLeft.selectTab(menuLeft.getWidgetIndex(diffBar));
|
||||||
} else {
|
} else {
|
||||||
@ -637,12 +636,10 @@ public class Gerrit implements EntryPoint {
|
|||||||
LinkMenuBar diffBar = new LinkMenuBar();
|
LinkMenuBar diffBar = new LinkMenuBar();
|
||||||
menuBars.put(GerritTopMenu.DIFFERENCES.menuName, diffBar);
|
menuBars.put(GerritTopMenu.DIFFERENCES.menuName, diffBar);
|
||||||
menuLeft.addInvisible(diffBar, C.menuDiff());
|
menuLeft.addInvisible(diffBar, C.menuDiff());
|
||||||
addDiffLink(diffBar, CC.patchTableDiffSideBySide(), PatchScreen.Type.SIDE_BY_SIDE);
|
addDiffLink(diffBar, C.menuDiffCommit(), UnifiedPatchScreen.TopView.COMMIT);
|
||||||
addDiffLink(diffBar, CC.patchTableDiffUnified(), PatchScreen.Type.UNIFIED);
|
addDiffLink(diffBar, C.menuDiffPreferences(), UnifiedPatchScreen.TopView.PREFERENCES);
|
||||||
addDiffLink(diffBar, C.menuDiffCommit(), PatchScreen.TopView.COMMIT);
|
addDiffLink(diffBar, C.menuDiffPatchSets(), UnifiedPatchScreen.TopView.PATCH_SETS);
|
||||||
addDiffLink(diffBar, C.menuDiffPreferences(), PatchScreen.TopView.PREFERENCES);
|
addDiffLink(diffBar, C.menuDiffFiles(), UnifiedPatchScreen.TopView.FILES);
|
||||||
addDiffLink(diffBar, C.menuDiffPatchSets(), PatchScreen.TopView.PATCH_SETS);
|
|
||||||
addDiffLink(diffBar, C.menuDiffFiles(), PatchScreen.TopView.FILES);
|
|
||||||
|
|
||||||
final LinkMenuBar projectsBar = new LinkMenuBar();
|
final LinkMenuBar projectsBar = new LinkMenuBar();
|
||||||
menuBars.put(GerritTopMenu.PROJECTS.menuName, projectsBar);
|
menuBars.put(GerritTopMenu.PROJECTS.menuName, projectsBar);
|
||||||
@ -890,7 +887,7 @@ public class Gerrit implements EntryPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addDiffLink(final LinkMenuBar m, final String text,
|
private static void addDiffLink(final LinkMenuBar m, final String text,
|
||||||
final PatchScreen.TopView tv) {
|
final UnifiedPatchScreen.TopView tv) {
|
||||||
m.addItem(new LinkMenuItem(text, "") {
|
m.addItem(new LinkMenuItem(text, "") {
|
||||||
@Override
|
@Override
|
||||||
public void go() {
|
public void go() {
|
||||||
@ -943,23 +940,6 @@ public class Gerrit implements EntryPoint {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addDiffLink(final LinkMenuBar m, final String text,
|
|
||||||
final PatchScreen.Type type) {
|
|
||||||
m.addItem(new LinkMenuItem(text, "") {
|
|
||||||
@Override
|
|
||||||
public void go() {
|
|
||||||
if (patchScreen != null) {
|
|
||||||
patchScreen.setTopView(PatchScreen.TopView.MAIN);
|
|
||||||
if (type == patchScreen.getPatchScreenType()) {
|
|
||||||
AnchorElement.as(getElement()).blur();
|
|
||||||
} else {
|
|
||||||
new PatchLink("", type, patchScreen).go();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addDocLink(final LinkMenuBar m, final String text,
|
private static void addDocLink(final LinkMenuBar m, final String text,
|
||||||
final String href) {
|
final String href) {
|
||||||
final Anchor atag = anchor(text, selfRedirect("/Documentation/" + href));
|
final Anchor atag = anchor(text, selfRedirect("/Documentation/" + href));
|
||||||
|
@ -221,8 +221,6 @@ public interface GerritCss extends CssResource {
|
|||||||
String sectionHeader();
|
String sectionHeader();
|
||||||
String selectPatchSetOldVersion();
|
String selectPatchSetOldVersion();
|
||||||
String sideBySideScreenLinkTable();
|
String sideBySideScreenLinkTable();
|
||||||
String sideBySideScreenSideBySideTable();
|
|
||||||
String sideBySideTableBinaryHeader();
|
|
||||||
String singleLine();
|
String singleLine();
|
||||||
String skipLine();
|
String skipLine();
|
||||||
String smallHeading();
|
String smallHeading();
|
||||||
|
@ -25,8 +25,6 @@ public interface AccountConstants extends Constants {
|
|||||||
String registeredOn();
|
String registeredOn();
|
||||||
String accountId();
|
String accountId();
|
||||||
|
|
||||||
String commentVisibilityLabel();
|
|
||||||
String changeScreenLabel();
|
|
||||||
String diffViewLabel();
|
String diffViewLabel();
|
||||||
String maximumPageSizeFieldLabel();
|
String maximumPageSizeFieldLabel();
|
||||||
String dateFormatLabel();
|
String dateFormatLabel();
|
||||||
@ -34,7 +32,6 @@ public interface AccountConstants extends Constants {
|
|||||||
String showSiteHeader();
|
String showSiteHeader();
|
||||||
String useFlashClipboard();
|
String useFlashClipboard();
|
||||||
String copySelfOnEmails();
|
String copySelfOnEmails();
|
||||||
String reversePatchSetOrder();
|
|
||||||
String reviewCategoryLabel();
|
String reviewCategoryLabel();
|
||||||
String messageShowInReviewCategoryNone();
|
String messageShowInReviewCategoryNone();
|
||||||
String messageShowInReviewCategoryName();
|
String messageShowInReviewCategoryName();
|
||||||
@ -51,9 +48,6 @@ public interface AccountConstants extends Constants {
|
|||||||
String myMenuUrl();
|
String myMenuUrl();
|
||||||
String myMenuReset();
|
String myMenuReset();
|
||||||
|
|
||||||
String changeScreenOldUi();
|
|
||||||
String changeScreenNewUi();
|
|
||||||
|
|
||||||
String tabAccountSummary();
|
String tabAccountSummary();
|
||||||
String tabPreferences();
|
String tabPreferences();
|
||||||
String tabWatchedProjects();
|
String tabWatchedProjects();
|
||||||
|
@ -8,8 +8,6 @@ accountId = Account ID
|
|||||||
showSiteHeader = Show Site Header
|
showSiteHeader = Show Site Header
|
||||||
useFlashClipboard = Use Flash Clipboard Widget
|
useFlashClipboard = Use Flash Clipboard Widget
|
||||||
copySelfOnEmails = CC Me On Comments I Write
|
copySelfOnEmails = CC Me On Comments I Write
|
||||||
reversePatchSetOrder = Display Patch Sets In Reverse Order (deprecated: Old Change Screen)
|
|
||||||
|
|
||||||
reviewCategoryLabel = Display In Review Category
|
reviewCategoryLabel = Display In Review Category
|
||||||
messageShowInReviewCategoryNone = None (default)
|
messageShowInReviewCategoryNone = None (default)
|
||||||
messageShowInReviewCategoryName = Show Name
|
messageShowInReviewCategoryName = Show Name
|
||||||
@ -18,9 +16,7 @@ messageShowInReviewCategoryUsername = Show Username
|
|||||||
messageShowInReviewCategoryAbbrev = Show Abbreviated Name
|
messageShowInReviewCategoryAbbrev = Show Abbreviated Name
|
||||||
|
|
||||||
maximumPageSizeFieldLabel = Maximum Page Size:
|
maximumPageSizeFieldLabel = Maximum Page Size:
|
||||||
commentVisibilityLabel = Comment Visibility (deprecated: Old Change Screen):
|
diffViewLabel = Diff View:
|
||||||
changeScreenLabel = Change View:
|
|
||||||
diffViewLabel = Diff View (New Change Screen):
|
|
||||||
dateFormatLabel = Date/Time Format:
|
dateFormatLabel = Date/Time Format:
|
||||||
contextWholeFile = Whole File
|
contextWholeFile = Whole File
|
||||||
buttonSaveChanges = Save Changes
|
buttonSaveChanges = Save Changes
|
||||||
|
@ -17,7 +17,6 @@ package com.google.gerrit.client.account;
|
|||||||
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DEFAULT_PAGESIZE;
|
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DEFAULT_PAGESIZE;
|
||||||
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.PAGESIZE_CHOICES;
|
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.PAGESIZE_CHOICES;
|
||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.StringListPanel;
|
import com.google.gerrit.client.StringListPanel;
|
||||||
import com.google.gerrit.client.config.ConfigServerApi;
|
import com.google.gerrit.client.config.ConfigServerApi;
|
||||||
@ -27,7 +26,6 @@ import com.google.gerrit.client.rpc.Natives;
|
|||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ReviewCategoryStrategy;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
@ -49,7 +47,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private CheckBox showSiteHeader;
|
private CheckBox showSiteHeader;
|
||||||
private CheckBox useFlashClipboard;
|
private CheckBox useFlashClipboard;
|
||||||
private CheckBox copySelfOnEmails;
|
private CheckBox copySelfOnEmails;
|
||||||
private CheckBox reversePatchSetOrder;
|
|
||||||
private CheckBox relativeDateInChangeTable;
|
private CheckBox relativeDateInChangeTable;
|
||||||
private CheckBox sizeBarInChangeTable;
|
private CheckBox sizeBarInChangeTable;
|
||||||
private CheckBox legacycidInChangeTable;
|
private CheckBox legacycidInChangeTable;
|
||||||
@ -57,8 +54,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
private ListBox dateFormat;
|
private ListBox dateFormat;
|
||||||
private ListBox timeFormat;
|
private ListBox timeFormat;
|
||||||
private ListBox reviewCategoryStrategy;
|
private ListBox reviewCategoryStrategy;
|
||||||
private ListBox commentVisibilityStrategy;
|
|
||||||
private ListBox changeScreen;
|
|
||||||
private ListBox diffView;
|
private ListBox diffView;
|
||||||
private StringListPanel myMenus;
|
private StringListPanel myMenus;
|
||||||
private Button save;
|
private Button save;
|
||||||
@ -70,7 +65,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
showSiteHeader = new CheckBox(Util.C.showSiteHeader());
|
showSiteHeader = new CheckBox(Util.C.showSiteHeader());
|
||||||
useFlashClipboard = new CheckBox(Util.C.useFlashClipboard());
|
useFlashClipboard = new CheckBox(Util.C.useFlashClipboard());
|
||||||
copySelfOnEmails = new CheckBox(Util.C.copySelfOnEmails());
|
copySelfOnEmails = new CheckBox(Util.C.copySelfOnEmails());
|
||||||
reversePatchSetOrder = new CheckBox(Util.C.reversePatchSetOrder());
|
|
||||||
maximumPageSize = new ListBox();
|
maximumPageSize = new ListBox();
|
||||||
for (final short v : PAGESIZE_CHOICES) {
|
for (final short v : PAGESIZE_CHOICES) {
|
||||||
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
maximumPageSize.addItem(Util.M.rowsPerPage(v), String.valueOf(v));
|
||||||
@ -93,32 +87,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
Util.C.messageShowInReviewCategoryAbbrev(),
|
Util.C.messageShowInReviewCategoryAbbrev(),
|
||||||
AccountGeneralPreferences.ReviewCategoryStrategy.ABBREV.name());
|
AccountGeneralPreferences.ReviewCategoryStrategy.ABBREV.name());
|
||||||
|
|
||||||
commentVisibilityStrategy = new ListBox();
|
|
||||||
commentVisibilityStrategy.addItem(
|
|
||||||
com.google.gerrit.client.changes.Util.C.messageCollapseAll(),
|
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.COLLAPSE_ALL.name());
|
|
||||||
commentVisibilityStrategy.addItem(
|
|
||||||
com.google.gerrit.client.changes.Util.C.messageExpandMostRecent(),
|
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_MOST_RECENT.name());
|
|
||||||
commentVisibilityStrategy.addItem(
|
|
||||||
com.google.gerrit.client.changes.Util.C.messageExpandRecent(),
|
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT.name());
|
|
||||||
commentVisibilityStrategy.addItem(
|
|
||||||
com.google.gerrit.client.changes.Util.C.messageExpandAll(),
|
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_ALL.name());
|
|
||||||
|
|
||||||
changeScreen = new ListBox();
|
|
||||||
changeScreen.addItem(
|
|
||||||
Util.M.changeScreenServerDefault(
|
|
||||||
getLabel(Gerrit.getConfig().getChangeScreen())),
|
|
||||||
"");
|
|
||||||
changeScreen.addItem(
|
|
||||||
Util.C.changeScreenOldUi(),
|
|
||||||
AccountGeneralPreferences.ChangeScreen.OLD_UI.name());
|
|
||||||
changeScreen.addItem(
|
|
||||||
Util.C.changeScreenNewUi(),
|
|
||||||
AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2.name());
|
|
||||||
|
|
||||||
diffView = new ListBox();
|
diffView = new ListBox();
|
||||||
diffView.addItem(
|
diffView.addItem(
|
||||||
com.google.gerrit.client.changes.Util.C.sideBySide(),
|
com.google.gerrit.client.changes.Util.C.sideBySide(),
|
||||||
@ -165,7 +133,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
sizeBarInChangeTable = new CheckBox(Util.C.showSizeBarInChangeTable());
|
sizeBarInChangeTable = new CheckBox(Util.C.showSizeBarInChangeTable());
|
||||||
legacycidInChangeTable = new CheckBox(Util.C.showLegacycidInChangeTable());
|
legacycidInChangeTable = new CheckBox(Util.C.showLegacycidInChangeTable());
|
||||||
|
|
||||||
final Grid formGrid = new Grid(13, 2);
|
final Grid formGrid = new Grid(11, 2);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
@ -181,11 +149,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
row++;
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, "");
|
formGrid.setText(row, labelIdx, "");
|
||||||
formGrid.setWidget(row, fieldIdx, reversePatchSetOrder);
|
|
||||||
row++;
|
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.reviewCategoryLabel());
|
|
||||||
formGrid.setWidget(row, fieldIdx, reviewCategoryStrategy);
|
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.maximumPageSizeFieldLabel());
|
formGrid.setText(row, labelIdx, Util.C.maximumPageSizeFieldLabel());
|
||||||
@ -208,12 +171,8 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
formGrid.setWidget(row, fieldIdx, legacycidInChangeTable);
|
formGrid.setWidget(row, fieldIdx, legacycidInChangeTable);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.commentVisibilityLabel());
|
formGrid.setText(row, labelIdx, "");
|
||||||
formGrid.setWidget(row, fieldIdx, commentVisibilityStrategy);
|
formGrid.setWidget(row, fieldIdx, legacycidInChangeTable);
|
||||||
row++;
|
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.changeScreenLabel());
|
|
||||||
formGrid.setWidget(row, fieldIdx, changeScreen);
|
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
|
formGrid.setText(row, labelIdx, Util.C.diffViewLabel());
|
||||||
@ -239,16 +198,12 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
e.listenTo(showSiteHeader);
|
e.listenTo(showSiteHeader);
|
||||||
e.listenTo(useFlashClipboard);
|
e.listenTo(useFlashClipboard);
|
||||||
e.listenTo(copySelfOnEmails);
|
e.listenTo(copySelfOnEmails);
|
||||||
e.listenTo(reversePatchSetOrder);
|
|
||||||
e.listenTo(maximumPageSize);
|
e.listenTo(maximumPageSize);
|
||||||
e.listenTo(dateFormat);
|
e.listenTo(dateFormat);
|
||||||
e.listenTo(timeFormat);
|
e.listenTo(timeFormat);
|
||||||
e.listenTo(relativeDateInChangeTable);
|
e.listenTo(relativeDateInChangeTable);
|
||||||
e.listenTo(sizeBarInChangeTable);
|
e.listenTo(sizeBarInChangeTable);
|
||||||
e.listenTo(legacycidInChangeTable);
|
e.listenTo(legacycidInChangeTable);
|
||||||
e.listenTo(reviewCategoryStrategy);
|
|
||||||
e.listenTo(commentVisibilityStrategy);
|
|
||||||
e.listenTo(changeScreen);
|
|
||||||
e.listenTo(diffView);
|
e.listenTo(diffView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +223,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
showSiteHeader.setEnabled(on);
|
showSiteHeader.setEnabled(on);
|
||||||
useFlashClipboard.setEnabled(on);
|
useFlashClipboard.setEnabled(on);
|
||||||
copySelfOnEmails.setEnabled(on);
|
copySelfOnEmails.setEnabled(on);
|
||||||
reversePatchSetOrder.setEnabled(on);
|
|
||||||
maximumPageSize.setEnabled(on);
|
maximumPageSize.setEnabled(on);
|
||||||
dateFormat.setEnabled(on);
|
dateFormat.setEnabled(on);
|
||||||
timeFormat.setEnabled(on);
|
timeFormat.setEnabled(on);
|
||||||
@ -276,8 +230,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
sizeBarInChangeTable.setEnabled(on);
|
sizeBarInChangeTable.setEnabled(on);
|
||||||
legacycidInChangeTable.setEnabled(on);
|
legacycidInChangeTable.setEnabled(on);
|
||||||
reviewCategoryStrategy.setEnabled(on);
|
reviewCategoryStrategy.setEnabled(on);
|
||||||
commentVisibilityStrategy.setEnabled(on);
|
|
||||||
changeScreen.setEnabled(on);
|
|
||||||
diffView.setEnabled(on);
|
diffView.setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +237,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
showSiteHeader.setValue(p.showSiteHeader());
|
showSiteHeader.setValue(p.showSiteHeader());
|
||||||
useFlashClipboard.setValue(p.useFlashClipboard());
|
useFlashClipboard.setValue(p.useFlashClipboard());
|
||||||
copySelfOnEmails.setValue(p.copySelfOnEmail());
|
copySelfOnEmails.setValue(p.copySelfOnEmail());
|
||||||
reversePatchSetOrder.setValue(p.reversePatchSetOrder());
|
|
||||||
setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.changesPerPage());
|
setListBox(maximumPageSize, DEFAULT_PAGESIZE, p.changesPerPage());
|
||||||
setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, //
|
setListBox(dateFormat, AccountGeneralPreferences.DateFormat.STD, //
|
||||||
p.dateFormat());
|
p.dateFormat());
|
||||||
@ -297,12 +248,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
setListBox(reviewCategoryStrategy,
|
setListBox(reviewCategoryStrategy,
|
||||||
AccountGeneralPreferences.ReviewCategoryStrategy.NONE,
|
AccountGeneralPreferences.ReviewCategoryStrategy.NONE,
|
||||||
p.reviewCategoryStrategy());
|
p.reviewCategoryStrategy());
|
||||||
setListBox(commentVisibilityStrategy,
|
|
||||||
AccountGeneralPreferences.CommentVisibilityStrategy.EXPAND_RECENT,
|
|
||||||
p.commentVisibilityStrategy());
|
|
||||||
setListBox(changeScreen,
|
|
||||||
null,
|
|
||||||
p.changeScreen());
|
|
||||||
setListBox(diffView,
|
setListBox(diffView,
|
||||||
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
p.diffView());
|
p.diffView());
|
||||||
@ -373,7 +318,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
p.setShowSiteHeader(showSiteHeader.getValue());
|
p.setShowSiteHeader(showSiteHeader.getValue());
|
||||||
p.setUseFlashClipboard(useFlashClipboard.getValue());
|
p.setUseFlashClipboard(useFlashClipboard.getValue());
|
||||||
p.setCopySelfOnEmails(copySelfOnEmails.getValue());
|
p.setCopySelfOnEmails(copySelfOnEmails.getValue());
|
||||||
p.setReversePatchSetOrder(reversePatchSetOrder.getValue());
|
|
||||||
p.setMaximumPageSize(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
|
p.setMaximumPageSize(getListBox(maximumPageSize, DEFAULT_PAGESIZE));
|
||||||
p.setDateFormat(getListBox(dateFormat,
|
p.setDateFormat(getListBox(dateFormat,
|
||||||
AccountGeneralPreferences.DateFormat.STD,
|
AccountGeneralPreferences.DateFormat.STD,
|
||||||
@ -387,15 +331,9 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
p.setReviewCategoryStrategy(getListBox(reviewCategoryStrategy,
|
p.setReviewCategoryStrategy(getListBox(reviewCategoryStrategy,
|
||||||
ReviewCategoryStrategy.NONE,
|
ReviewCategoryStrategy.NONE,
|
||||||
ReviewCategoryStrategy.values()));
|
ReviewCategoryStrategy.values()));
|
||||||
p.setCommentVisibilityStrategy(getListBox(commentVisibilityStrategy,
|
|
||||||
CommentVisibilityStrategy.EXPAND_RECENT,
|
|
||||||
CommentVisibilityStrategy.values()));
|
|
||||||
p.setDiffView(getListBox(diffView,
|
p.setDiffView(getListBox(diffView,
|
||||||
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
AccountGeneralPreferences.DiffView.values()));
|
AccountGeneralPreferences.DiffView.values()));
|
||||||
p.setChangeScreen(getListBox(changeScreen,
|
|
||||||
null,
|
|
||||||
AccountGeneralPreferences.ChangeScreen.values()));
|
|
||||||
|
|
||||||
enable(false);
|
enable(false);
|
||||||
save.setEnabled(false);
|
save.setEnabled(false);
|
||||||
@ -411,7 +349,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
public void onSuccess(Preferences prefs) {
|
public void onSuccess(Preferences prefs) {
|
||||||
Gerrit.getUserAccount().setGeneralPreferences(p);
|
Gerrit.getUserAccount().setGeneralPreferences(p);
|
||||||
Gerrit.applyUserPreferences();
|
Gerrit.applyUserPreferences();
|
||||||
Dispatcher.changeScreen2 = false;
|
|
||||||
enable(true);
|
enable(true);
|
||||||
display(prefs);
|
display(prefs);
|
||||||
Gerrit.refreshMenuBar();
|
Gerrit.refreshMenuBar();
|
||||||
@ -426,20 +363,6 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getLabel(AccountGeneralPreferences.ChangeScreen ui) {
|
|
||||||
if (ui == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
switch (ui) {
|
|
||||||
case OLD_UI:
|
|
||||||
return Util.C.changeScreenOldUi();
|
|
||||||
case CHANGE_SCREEN2:
|
|
||||||
return Util.C.changeScreenNewUi();
|
|
||||||
default:
|
|
||||||
return ui.name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MyMenuPanel extends StringListPanel {
|
private class MyMenuPanel extends StringListPanel {
|
||||||
MyMenuPanel(Button save) {
|
MyMenuPanel(Button save) {
|
||||||
super(Util.C.myMenu(), Arrays.asList(Util.C.myMenuName(),
|
super(Util.C.myMenu(), Arrays.asList(Util.C.myMenuName(),
|
||||||
|
@ -16,8 +16,6 @@ package com.google.gerrit.client.account;
|
|||||||
|
|
||||||
import com.google.gerrit.client.extensions.TopMenuItem;
|
import com.google.gerrit.client.extensions.TopMenuItem;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ChangeScreen;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
@ -43,14 +41,11 @@ public class Preferences extends JavaScriptObject {
|
|||||||
p.copySelfOnEmail(in.isCopySelfOnEmails());
|
p.copySelfOnEmail(in.isCopySelfOnEmails());
|
||||||
p.dateFormat(in.getDateFormat());
|
p.dateFormat(in.getDateFormat());
|
||||||
p.timeFormat(in.getTimeFormat());
|
p.timeFormat(in.getTimeFormat());
|
||||||
p.reversePatchSetOrder(in.isReversePatchSetOrder());
|
|
||||||
p.relativeDateInChangeTable(in.isRelativeDateInChangeTable());
|
p.relativeDateInChangeTable(in.isRelativeDateInChangeTable());
|
||||||
p.sizeBarInChangeTable(in.isSizeBarInChangeTable());
|
p.sizeBarInChangeTable(in.isSizeBarInChangeTable());
|
||||||
p.legacycidInChangeTable(in.isLegacycidInChangeTable());
|
p.legacycidInChangeTable(in.isLegacycidInChangeTable());
|
||||||
p.commentVisibilityStrategy(in.getCommentVisibilityStrategy());
|
|
||||||
p.reviewCategoryStrategy(in.getReviewCategoryStrategy());
|
p.reviewCategoryStrategy(in.getReviewCategoryStrategy());
|
||||||
p.diffView(in.getDiffView());
|
p.diffView(in.getDiffView());
|
||||||
p.changeScreen(in.getChangeScreen());
|
|
||||||
p.setMyMenus(myMenus);
|
p.setMyMenus(myMenus);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -98,9 +93,6 @@ public class Preferences extends JavaScriptObject {
|
|||||||
private final native String timeFormatRaw()
|
private final native String timeFormatRaw()
|
||||||
/*-{ return this.time_format }-*/;
|
/*-{ return this.time_format }-*/;
|
||||||
|
|
||||||
public final native boolean reversePatchSetOrder()
|
|
||||||
/*-{ return this.reverse_patch_set_order || false }-*/;
|
|
||||||
|
|
||||||
public final native boolean relativeDateInChangeTable()
|
public final native boolean relativeDateInChangeTable()
|
||||||
/*-{ return this.relative_date_in_change_table || false }-*/;
|
/*-{ return this.relative_date_in_change_table || false }-*/;
|
||||||
|
|
||||||
@ -117,13 +109,6 @@ public class Preferences extends JavaScriptObject {
|
|||||||
private final native String reviewCategeoryStrategyRaw()
|
private final native String reviewCategeoryStrategyRaw()
|
||||||
/*-{ return this.review_category_strategy }-*/;
|
/*-{ return this.review_category_strategy }-*/;
|
||||||
|
|
||||||
public final CommentVisibilityStrategy commentVisibilityStrategy() {
|
|
||||||
String s = commentVisibilityStrategyRaw();
|
|
||||||
return s != null ? CommentVisibilityStrategy.valueOf(s) : null;
|
|
||||||
}
|
|
||||||
private final native String commentVisibilityStrategyRaw()
|
|
||||||
/*-{ return this.comment_visibility_strategy }-*/;
|
|
||||||
|
|
||||||
public final DiffView diffView() {
|
public final DiffView diffView() {
|
||||||
String s = diffViewRaw();
|
String s = diffViewRaw();
|
||||||
return s != null ? DiffView.valueOf(s) : null;
|
return s != null ? DiffView.valueOf(s) : null;
|
||||||
@ -131,13 +116,6 @@ public class Preferences extends JavaScriptObject {
|
|||||||
private final native String diffViewRaw()
|
private final native String diffViewRaw()
|
||||||
/*-{ return this.diff_view }-*/;
|
/*-{ return this.diff_view }-*/;
|
||||||
|
|
||||||
public final ChangeScreen changeScreen() {
|
|
||||||
String s = changeScreenRaw();
|
|
||||||
return s != null ? ChangeScreen.valueOf(s) : null;
|
|
||||||
}
|
|
||||||
private final native String changeScreenRaw()
|
|
||||||
/*-{ return this.change_screen }-*/;
|
|
||||||
|
|
||||||
public final native JsArray<TopMenuItem> my()
|
public final native JsArray<TopMenuItem> my()
|
||||||
/*-{ return this.my; }-*/;
|
/*-{ return this.my; }-*/;
|
||||||
|
|
||||||
@ -177,9 +155,6 @@ public class Preferences extends JavaScriptObject {
|
|||||||
private final native void timeFormatRaw(String f)
|
private final native void timeFormatRaw(String f)
|
||||||
/*-{ this.time_format = f }-*/;
|
/*-{ this.time_format = f }-*/;
|
||||||
|
|
||||||
public final native void reversePatchSetOrder(boolean r)
|
|
||||||
/*-{ this.reverse_patch_set_order = r }-*/;
|
|
||||||
|
|
||||||
public final native void relativeDateInChangeTable(boolean d)
|
public final native void relativeDateInChangeTable(boolean d)
|
||||||
/*-{ this.relative_date_in_change_table = d }-*/;
|
/*-{ this.relative_date_in_change_table = d }-*/;
|
||||||
|
|
||||||
@ -195,24 +170,12 @@ public class Preferences extends JavaScriptObject {
|
|||||||
private final native void reviewCategoryStrategyRaw(String s)
|
private final native void reviewCategoryStrategyRaw(String s)
|
||||||
/*-{ this.review_category_strategy = s }-*/;
|
/*-{ this.review_category_strategy = s }-*/;
|
||||||
|
|
||||||
public final void commentVisibilityStrategy(CommentVisibilityStrategy s) {
|
|
||||||
commentVisibilityStrategyRaw(s != null ? s.toString() : null);
|
|
||||||
}
|
|
||||||
private final native void commentVisibilityStrategyRaw(String s)
|
|
||||||
/*-{ this.comment_visibility_strategy = s }-*/;
|
|
||||||
|
|
||||||
public final void diffView(DiffView d) {
|
public final void diffView(DiffView d) {
|
||||||
diffViewRaw(d != null ? d.toString() : null);
|
diffViewRaw(d != null ? d.toString() : null);
|
||||||
}
|
}
|
||||||
private final native void diffViewRaw(String d)
|
private final native void diffViewRaw(String d)
|
||||||
/*-{ this.diff_view = d }-*/;
|
/*-{ this.diff_view = d }-*/;
|
||||||
|
|
||||||
public final void changeScreen(ChangeScreen s) {
|
|
||||||
changeScreenRaw(s != null ? s.toString() : null);
|
|
||||||
}
|
|
||||||
private final native void changeScreenRaw(String s)
|
|
||||||
/*-{ this.change_screen = s }-*/;
|
|
||||||
|
|
||||||
final void setMyMenus(List<TopMenuItem> myMenus) {
|
final void setMyMenus(List<TopMenuItem> myMenus) {
|
||||||
initMy();
|
initMy();
|
||||||
for (TopMenuItem n : myMenus) {
|
for (TopMenuItem n : myMenus) {
|
||||||
|
@ -27,7 +27,7 @@ class CreateChangeAction {
|
|||||||
static void call(Button b, final String project) {
|
static void call(Button b, final String project) {
|
||||||
// TODO Replace CreateChangeDialog with a nicer looking display.
|
// TODO Replace CreateChangeDialog with a nicer looking display.
|
||||||
b.setEnabled(false);
|
b.setEnabled(false);
|
||||||
new CreateChangeDialog(b, new Project.NameKey(project)) {
|
new CreateChangeDialog(new Project.NameKey(project)) {
|
||||||
{
|
{
|
||||||
sendButton.setText(Util.C.buttonCreate());
|
sendButton.setText(Util.C.buttonCreate());
|
||||||
message.setText(Util.C.buttonCreateDescription());
|
message.setText(Util.C.buttonCreateDescription());
|
||||||
|
@ -579,9 +579,6 @@ public class ChangeScreen2 extends Screen {
|
|||||||
ChangeGlue.fireShowChange(changeInfo, changeInfo.revision(revision));
|
ChangeGlue.fireShowChange(changeInfo, changeInfo.revision(revision));
|
||||||
CodeMirror.preload();
|
CodeMirror.preload();
|
||||||
startPoller();
|
startPoller();
|
||||||
if (NewChangeScreenBar.show()) {
|
|
||||||
add(new NewChangeScreenBar(changeId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollToPath(String token) {
|
private void scrollToPath(String token) {
|
||||||
|
@ -30,7 +30,7 @@ class CherryPickAction {
|
|||||||
String project, final String commitMessage) {
|
String project, final String commitMessage) {
|
||||||
// TODO Replace CherryPickDialog with a nicer looking display.
|
// TODO Replace CherryPickDialog with a nicer looking display.
|
||||||
b.setEnabled(false);
|
b.setEnabled(false);
|
||||||
new CherryPickDialog(b, new Project.NameKey(project)) {
|
new CherryPickDialog(new Project.NameKey(project)) {
|
||||||
{
|
{
|
||||||
sendButton.setText(Util.C.buttonCherryPickChangeSend());
|
sendButton.setText(Util.C.buttonCherryPickChangeSend());
|
||||||
if (info.status() == Change.Status.MERGED) {
|
if (info.status() == Change.Status.MERGED) {
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
// Copyright (C) 2013 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.change;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.account.AccountApi;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ChangeScreen;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
|
||||||
import com.google.gwt.dom.client.Element;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
|
||||||
import com.google.gwt.user.client.Cookies;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
||||||
import com.google.gwt.user.client.ui.UIObject;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/** Displays a welcome to the new change screen bar. */
|
|
||||||
class NewChangeScreenBar extends Composite {
|
|
||||||
interface Binder extends UiBinder<HTMLPanel, NewChangeScreenBar> {}
|
|
||||||
private static final Binder uiBinder = GWT.create(Binder.class);
|
|
||||||
|
|
||||||
static boolean show() {
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
return Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences()
|
|
||||||
.getChangeScreen() == null;
|
|
||||||
}
|
|
||||||
return Cookies.getCookie(Dispatcher.COOKIE_CS2) == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Change.Id id;
|
|
||||||
|
|
||||||
@UiField Element docs;
|
|
||||||
@UiField Element settings;
|
|
||||||
@UiField Anchor keepNew;
|
|
||||||
@UiField Anchor keepOld;
|
|
||||||
|
|
||||||
NewChangeScreenBar(Change.Id id) {
|
|
||||||
this.id = id;
|
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
|
||||||
UIObject.setVisible(docs, Gerrit.getConfig().isDocumentationAvailable());
|
|
||||||
UIObject.setVisible(settings, Gerrit.isSignedIn());
|
|
||||||
}
|
|
||||||
|
|
||||||
@UiHandler("keepOld")
|
|
||||||
void onKeepOld(@SuppressWarnings("unused") ClickEvent e) {
|
|
||||||
save(ChangeScreen.OLD_UI);
|
|
||||||
Gerrit.display(PageLinks.toChange(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@UiHandler("keepNew")
|
|
||||||
void onKeepNew(@SuppressWarnings("unused") ClickEvent e) {
|
|
||||||
save(ChangeScreen.CHANGE_SCREEN2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save(ChangeScreen sel) {
|
|
||||||
removeFromParent();
|
|
||||||
Dispatcher.changeScreen2 = sel == ChangeScreen.CHANGE_SCREEN2;
|
|
||||||
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
Gerrit.getUserAccount().getGeneralPreferences().setChangeScreen(sel);
|
|
||||||
|
|
||||||
Prefs in = Prefs.createObject().cast();
|
|
||||||
in.change_screen(sel.name());
|
|
||||||
AccountApi.self().view("preferences").background().put(in,
|
|
||||||
new AsyncCallback<JavaScriptObject>() {
|
|
||||||
@Override public void onFailure(Throwable caught) {}
|
|
||||||
@Override public void onSuccess(JavaScriptObject result) {}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Cookies.setCookie(
|
|
||||||
Dispatcher.COOKIE_CS2,
|
|
||||||
Dispatcher.changeScreen2 ? "1" : "0",
|
|
||||||
new Date(System.currentTimeMillis() + 7 * 24 * 3600 * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Prefs extends JavaScriptObject {
|
|
||||||
final native void change_screen(String n) /*-{ this.change_screen=n }-*/;
|
|
||||||
protected Prefs() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2013 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.
|
|
||||||
-->
|
|
||||||
<ui:UiBinder
|
|
||||||
xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
|
||||||
xmlns:c='urn:import:com.google.gwtexpui.globalkey.client'
|
|
||||||
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
|
|
||||||
<ui:style>
|
|
||||||
.popup {
|
|
||||||
position: fixed;
|
|
||||||
top: 5px;
|
|
||||||
left: 50%;
|
|
||||||
margin-left: -200px;
|
|
||||||
z-index: 201;
|
|
||||||
padding-top: 5px;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
padding-left: 12px;
|
|
||||||
padding-right: 12px;
|
|
||||||
text-align: center;
|
|
||||||
background: #FFF1A8;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@if user.agent safari {
|
|
||||||
.popup {
|
|
||||||
\-webkit-border-radius: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@if user.agent gecko1_8 {
|
|
||||||
.popup {
|
|
||||||
\-moz-border-radius: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a.action {
|
|
||||||
color: #222;
|
|
||||||
text-decoration: underline;
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 0.5em;
|
|
||||||
}
|
|
||||||
.welcome { font-weight: bold; }
|
|
||||||
</ui:style>
|
|
||||||
<g:HTMLPanel styleName='{style.popup}'>
|
|
||||||
<div><ui:msg><span class='{style.welcome}'>Welcome to the new change screen!</span>
|
|
||||||
<a ui:field='docs'
|
|
||||||
class='{style.action}'
|
|
||||||
href='Documentation/user-review-ui.html'
|
|
||||||
target='_blank'>Learn more</a></ui:msg>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<ui:msg>You can<g:Anchor ui:field='keepOld'
|
|
||||||
styleName='{style.action}'
|
|
||||||
href='javascript:;'
|
|
||||||
title='Switch back to the old screen'><ui:attribute name='title'/>revert
|
|
||||||
to the old screen</g:Anchor><span ui:field='settings'> in Settings > Preferences</span>.
|
|
||||||
<g:Anchor ui:field='keepNew'
|
|
||||||
styleName='{style.action}'
|
|
||||||
href='javascript:;'
|
|
||||||
title='Keep the new change screen'>
|
|
||||||
<ui:attribute name='title'/>
|
|
||||||
Got it!
|
|
||||||
</g:Anchor></ui:msg>
|
|
||||||
</div>
|
|
||||||
</g:HTMLPanel>
|
|
||||||
</ui:UiBinder>
|
|
@ -19,7 +19,7 @@ import com.google.gerrit.client.changes.ChangeApi;
|
|||||||
import com.google.gerrit.client.changes.ChangeInfo;
|
import com.google.gerrit.client.changes.ChangeInfo;
|
||||||
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.ui.ActionDialog;
|
import com.google.gerrit.client.ui.CommentedActionDialog;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
@ -29,7 +29,7 @@ class RevertAction {
|
|||||||
final String commitSubject) {
|
final String commitSubject) {
|
||||||
// TODO Replace ActionDialog with a nicer looking display.
|
// TODO Replace ActionDialog with a nicer looking display.
|
||||||
b.setEnabled(false);
|
b.setEnabled(false);
|
||||||
new ActionDialog(b, false,
|
new CommentedActionDialog(
|
||||||
Util.C.revertChangeTitle(),
|
Util.C.revertChangeTitle(),
|
||||||
Util.C.headingRevertMessage()) {
|
Util.C.headingRevertMessage()) {
|
||||||
{
|
{
|
||||||
|
@ -1,395 +0,0 @@
|
|||||||
// Copyright (C) 2008 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 static com.google.gerrit.common.data.LabelValue.formatValue;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.ConfirmationCallback;
|
|
||||||
import com.google.gerrit.client.ConfirmationDialog;
|
|
||||||
import com.google.gerrit.client.ErrorDialog;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.account.AccountInfo;
|
|
||||||
import com.google.gerrit.client.change.ReviewerSuggestOracle;
|
|
||||||
import com.google.gerrit.client.change.Reviewers.PostInput;
|
|
||||||
import com.google.gerrit.client.change.Reviewers.PostResult;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.ApprovalInfo;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
|
||||||
import com.google.gerrit.client.ui.AccountLinkPanel;
|
|
||||||
import com.google.gerrit.client.ui.AddMemberBox;
|
|
||||||
import com.google.gerrit.common.data.ApprovalDetail;
|
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
|
||||||
import com.google.gwt.dom.client.Element;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.user.client.DOM;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
import com.google.gwt.user.client.ui.Image;
|
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
|
||||||
import com.google.gwt.user.client.ui.PushButton;
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/** Displays a table of {@link ApprovalDetail} objects for a change record. */
|
|
||||||
public class ApprovalTable extends Composite {
|
|
||||||
private final Grid table;
|
|
||||||
private final Widget missing;
|
|
||||||
private final Panel addReviewer;
|
|
||||||
private final ReviewerSuggestOracle reviewerSuggestOracle;
|
|
||||||
private final AddMemberBox addMemberBox;
|
|
||||||
private ChangeInfo lastChange;
|
|
||||||
private Map<Integer, Integer> rows;
|
|
||||||
|
|
||||||
public ApprovalTable() {
|
|
||||||
rows = new HashMap<>();
|
|
||||||
table = new Grid(1, 3);
|
|
||||||
table.addStyleName(Gerrit.RESOURCES.css().infoTable());
|
|
||||||
|
|
||||||
missing = new Widget() {
|
|
||||||
{
|
|
||||||
setElement((Element)(DOM.createElement("ul")));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
missing.setStyleName(Gerrit.RESOURCES.css().missingApprovalList());
|
|
||||||
|
|
||||||
addReviewer = new FlowPanel();
|
|
||||||
addReviewer.setStyleName(Gerrit.RESOURCES.css().addReviewer());
|
|
||||||
reviewerSuggestOracle = new ReviewerSuggestOracle();
|
|
||||||
addMemberBox =
|
|
||||||
new AddMemberBox(Util.C.approvalTableAddReviewer(),
|
|
||||||
Util.C.approvalTableAddReviewerHint(), reviewerSuggestOracle);
|
|
||||||
addMemberBox.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
doAddReviewer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addReviewer.add(addMemberBox);
|
|
||||||
addReviewer.setVisible(false);
|
|
||||||
|
|
||||||
final FlowPanel fp = new FlowPanel();
|
|
||||||
fp.add(table);
|
|
||||||
fp.add(missing);
|
|
||||||
fp.add(addReviewer);
|
|
||||||
initWidget(fp);
|
|
||||||
|
|
||||||
setStyleName(Gerrit.RESOURCES.css().approvalTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the header row
|
|
||||||
*
|
|
||||||
* @param labels The list of labels to display in the header. This list does
|
|
||||||
* not get resorted, so be sure that the list's elements are in the same
|
|
||||||
* order as the list of labels passed to the {@code displayRow} method.
|
|
||||||
*/
|
|
||||||
private void displayHeader(Collection<String> labels) {
|
|
||||||
table.resizeColumns(2 + labels.size());
|
|
||||||
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
int col = 0;
|
|
||||||
|
|
||||||
table.setText(0, col, Util.C.approvalTableReviewer());
|
|
||||||
fmt.setStyleName(0, col, Gerrit.RESOURCES.css().header());
|
|
||||||
col++;
|
|
||||||
|
|
||||||
table.clearCell(0, col);
|
|
||||||
fmt.setStyleName(0, col, Gerrit.RESOURCES.css().header());
|
|
||||||
col++;
|
|
||||||
|
|
||||||
for (String name : labels) {
|
|
||||||
table.setText(0, col, name);
|
|
||||||
fmt.setStyleName(0, col, Gerrit.RESOURCES.css().header());
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
fmt.addStyleName(0, col - 1, Gerrit.RESOURCES.css().rightmost());
|
|
||||||
}
|
|
||||||
|
|
||||||
void display(ChangeInfo change) {
|
|
||||||
lastChange = change;
|
|
||||||
reviewerSuggestOracle.setChange(change.legacy_id());
|
|
||||||
Map<Integer, ApprovalDetail> byUser = new LinkedHashMap<>();
|
|
||||||
Map<Integer, AccountInfo> accounts = new LinkedHashMap<>();
|
|
||||||
List<String> missingLabels = initLabels(change, accounts, byUser);
|
|
||||||
|
|
||||||
removeAllChildren(missing.getElement());
|
|
||||||
for (String label : missingLabels) {
|
|
||||||
addMissingLabel(Util.M.needApproval(label));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (byUser.isEmpty()) {
|
|
||||||
table.setVisible(false);
|
|
||||||
} else {
|
|
||||||
List<String> labels = new ArrayList<>(change.labels());
|
|
||||||
Collections.sort(labels);
|
|
||||||
displayHeader(labels);
|
|
||||||
table.resizeRows(1 + byUser.size());
|
|
||||||
int i = 1;
|
|
||||||
for (ApprovalDetail ad : ApprovalDetail.sort(
|
|
||||||
byUser.values(), change.owner()._account_id())) {
|
|
||||||
displayRow(i++, ad, labels, accounts.get(ad.getAccount().get()));
|
|
||||||
}
|
|
||||||
table.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (change.status() != Change.Status.MERGED
|
|
||||||
&& !change.mergeable()) {
|
|
||||||
addMissingLabel(Util.C.messageNeedsRebaseOrHasDependency());
|
|
||||||
}
|
|
||||||
missing.setVisible(missing.getElement().getChildCount() > 0);
|
|
||||||
addReviewer.setVisible(Gerrit.isSignedIn());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeAllChildren(Element el) {
|
|
||||||
for (int i = DOM.getChildCount(el) - 1; i >= 0; i--) {
|
|
||||||
el.removeChild(DOM.getChild(el, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMissingLabel(String text) {
|
|
||||||
Element li = DOM.createElement("li");
|
|
||||||
li.setClassName(Gerrit.RESOURCES.css().missingApproval());
|
|
||||||
li.setInnerText(text);
|
|
||||||
DOM.appendChild(missing.getElement(), li);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<Integer> removableReviewers(ChangeInfo change) {
|
|
||||||
Set<Integer> result =
|
|
||||||
new HashSet<>(change.removable_reviewers().length());
|
|
||||||
for (int i = 0; i < change.removable_reviewers().length(); i++) {
|
|
||||||
result.add(change.removable_reviewers().get(i)._account_id());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> initLabels(ChangeInfo change,
|
|
||||||
Map<Integer, AccountInfo> accounts,
|
|
||||||
Map<Integer, ApprovalDetail> byUser) {
|
|
||||||
Set<Integer> removableReviewers = removableReviewers(change);
|
|
||||||
List<String> missing = new ArrayList<>();
|
|
||||||
for (String name : change.labels()) {
|
|
||||||
LabelInfo label = change.label(name);
|
|
||||||
|
|
||||||
String min = null;
|
|
||||||
String max = null;
|
|
||||||
for (String v : label.values()) {
|
|
||||||
if (min == null) {
|
|
||||||
min = v;
|
|
||||||
}
|
|
||||||
if (v.startsWith("+")) {
|
|
||||||
max = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (label.status() == SubmitRecord.Label.Status.NEED) {
|
|
||||||
missing.add(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (label.all() != null) {
|
|
||||||
for (ApprovalInfo ai : Natives.asList(label.all())) {
|
|
||||||
if (!accounts.containsKey(ai._account_id())) {
|
|
||||||
accounts.put(ai._account_id(), ai);
|
|
||||||
}
|
|
||||||
int id = ai._account_id();
|
|
||||||
ApprovalDetail ad = byUser.get(id);
|
|
||||||
if (ad == null) {
|
|
||||||
ad = new ApprovalDetail(new Account.Id(id));
|
|
||||||
ad.setCanRemove(removableReviewers.contains(id));
|
|
||||||
byUser.put(id, ad);
|
|
||||||
}
|
|
||||||
if (ai.has_value()) {
|
|
||||||
ad.votable(name);
|
|
||||||
ad.value(name, ai.value());
|
|
||||||
String fv = formatValue(ai.value());
|
|
||||||
if (fv.equals(max)) {
|
|
||||||
ad.approved(name);
|
|
||||||
} else if (ai.value() < 0 && fv.equals(min)) {
|
|
||||||
ad.rejected(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return missing;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doAddReviewer() {
|
|
||||||
String reviewer = addMemberBox.getText();
|
|
||||||
if (!reviewer.isEmpty()) {
|
|
||||||
addMemberBox.setEnabled(false);
|
|
||||||
addReviewer(reviewer, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addReviewer(final String reviewer, boolean confirmed) {
|
|
||||||
ChangeApi.reviewers(lastChange.legacy_id().get()).post(
|
|
||||||
PostInput.create(reviewer, confirmed),
|
|
||||||
new GerritCallback<PostResult>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(PostResult result) {
|
|
||||||
addMemberBox.setEnabled(true);
|
|
||||||
addMemberBox.setText("");
|
|
||||||
if (result.error() == null) {
|
|
||||||
reload();
|
|
||||||
} else if (result.confirm()) {
|
|
||||||
askForConfirmation(result.error());
|
|
||||||
} else {
|
|
||||||
new ErrorDialog(new SafeHtmlBuilder().append(result.error()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void askForConfirmation(String text) {
|
|
||||||
String title = Util.C
|
|
||||||
.approvalTableAddManyReviewersConfirmationDialogTitle();
|
|
||||||
ConfirmationDialog confirmationDialog = new ConfirmationDialog(
|
|
||||||
title, new SafeHtmlBuilder().append(text),
|
|
||||||
new ConfirmationCallback() {
|
|
||||||
@Override
|
|
||||||
public void onOk() {
|
|
||||||
addReviewer(reviewer, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
confirmationDialog.center();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(final Throwable caught) {
|
|
||||||
addMemberBox.setEnabled(true);
|
|
||||||
if (isNoSuchEntity(caught)) {
|
|
||||||
new ErrorDialog(Util.M.reviewerNotFound(reviewer)).center();
|
|
||||||
} else {
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the reviewer data for a row.
|
|
||||||
*
|
|
||||||
* @param row The number of the row on which to set the reviewer.
|
|
||||||
* @param ad The details for this reviewer's approval.
|
|
||||||
* @param labels The list of labels to show. This list does not get resorted,
|
|
||||||
* so be sure that the list's elements are in the same order as the list
|
|
||||||
* of labels passed to the {@code displayHeader} method.
|
|
||||||
* @param account The account information for the approval.
|
|
||||||
*/
|
|
||||||
private void displayRow(int row, final ApprovalDetail ad,
|
|
||||||
List<String> labels, AccountInfo account) {
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
int col = 0;
|
|
||||||
|
|
||||||
table.setWidget(row, col++, new AccountLinkPanel(account));
|
|
||||||
rows.put(account._account_id(), row);
|
|
||||||
|
|
||||||
if (ad.canRemove()) {
|
|
||||||
final PushButton remove = new PushButton( //
|
|
||||||
new Image(Util.R.removeReviewerNormal()), //
|
|
||||||
new Image(Util.R.removeReviewerPressed()));
|
|
||||||
remove.setTitle(Util.M.removeReviewer(account.name()));
|
|
||||||
remove.setStyleName(Gerrit.RESOURCES.css().removeReviewer());
|
|
||||||
remove.addStyleName(Gerrit.RESOURCES.css().link());
|
|
||||||
remove.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
doRemove(ad, remove);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
table.setWidget(row, col, remove);
|
|
||||||
} else {
|
|
||||||
table.clearCell(row, col);
|
|
||||||
}
|
|
||||||
fmt.setStyleName(row, col++, Gerrit.RESOURCES.css().removeReviewerCell());
|
|
||||||
|
|
||||||
for (String labelName : labels) {
|
|
||||||
fmt.setStyleName(row, col, Gerrit.RESOURCES.css().approvalscore());
|
|
||||||
if (!ad.canVote(labelName)) {
|
|
||||||
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().notVotable());
|
|
||||||
fmt.getElement(row, col).setTitle(Gerrit.C.userCannotVoteToolTip());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ad.isRejected(labelName)) {
|
|
||||||
table.setWidget(row, col, new Image(Gerrit.RESOURCES.redNot()));
|
|
||||||
|
|
||||||
} else if (ad.isApproved(labelName)) {
|
|
||||||
table.setWidget(row, col, new Image(Gerrit.RESOURCES.greenCheck()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
int v = ad.getValue(labelName);
|
|
||||||
if (v == 0) {
|
|
||||||
table.clearCell(row, col);
|
|
||||||
col++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String vstr = String.valueOf(ad.getValue(labelName));
|
|
||||||
if (v > 0) {
|
|
||||||
vstr = "+" + vstr;
|
|
||||||
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().posscore());
|
|
||||||
} else {
|
|
||||||
fmt.addStyleName(row, col, Gerrit.RESOURCES.css().negscore());
|
|
||||||
}
|
|
||||||
table.setText(row, col, vstr);
|
|
||||||
}
|
|
||||||
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.addStyleName(row, col - 1, Gerrit.RESOURCES.css().rightmost());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reload() {
|
|
||||||
ChangeApi.detail(lastChange.legacy_id().get(),
|
|
||||||
new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
display(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doRemove(ApprovalDetail ad, final PushButton remove) {
|
|
||||||
remove.setEnabled(false);
|
|
||||||
ChangeApi.reviewer(lastChange.legacy_id().get(), ad.getAccount().get())
|
|
||||||
.delete(new GerritCallback<JavaScriptObject>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(JavaScriptObject result) {
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(final Throwable caught) {
|
|
||||||
remove.setEnabled(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
// Copyright (C) 2012 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.ui.ListenableValue;
|
|
||||||
import com.google.gerrit.common.data.ChangeInfo;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/** A Cache to store common client side data by change */
|
|
||||||
public class ChangeCache {
|
|
||||||
private static Map<Change.Id, ChangeCache> caches = new HashMap<>();
|
|
||||||
|
|
||||||
public static ChangeCache get(Change.Id chg) {
|
|
||||||
ChangeCache cache = caches.get(chg);
|
|
||||||
if (cache == null) {
|
|
||||||
cache = new ChangeCache(chg);
|
|
||||||
caches.put(chg, cache);
|
|
||||||
}
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Change.Id changeId;
|
|
||||||
private ChangeDetailCache detail;
|
|
||||||
private ListenableValue<ChangeInfo> info;
|
|
||||||
|
|
||||||
protected ChangeCache(Change.Id chg) {
|
|
||||||
changeId = chg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Change.Id getChangeId() {
|
|
||||||
return changeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangeDetailCache getChangeDetailCache() {
|
|
||||||
if (detail == null) {
|
|
||||||
detail = new ChangeDetailCache(changeId);
|
|
||||||
}
|
|
||||||
return detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListenableValue<ChangeInfo> getChangeInfoCache() {
|
|
||||||
if (info == null) {
|
|
||||||
info = new ListenableValue<>();
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
// Copyright (C) 2008 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.ui.CommentLinkProcessor;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
|
||||||
|
|
||||||
public class ChangeDescriptionBlock extends Composite {
|
|
||||||
private final ChangeInfoBlock infoBlock;
|
|
||||||
private final CommitMessageBlock messageBlock;
|
|
||||||
|
|
||||||
public ChangeDescriptionBlock(KeyCommandSet keysAction) {
|
|
||||||
infoBlock = new ChangeInfoBlock();
|
|
||||||
messageBlock = new CommitMessageBlock(keysAction);
|
|
||||||
|
|
||||||
final HorizontalPanel hp = new HorizontalPanel();
|
|
||||||
hp.add(infoBlock);
|
|
||||||
hp.add(messageBlock);
|
|
||||||
initWidget(hp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void display(ChangeDetail changeDetail, Boolean starred, Boolean canEditCommitMessage,
|
|
||||||
PatchSetInfo info, AccountInfoCache acc,
|
|
||||||
SubmitTypeRecord submitTypeRecord,
|
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
|
||||||
infoBlock.display(changeDetail, acc, submitTypeRecord);
|
|
||||||
messageBlock.display(changeDetail.getChange().currentPatchSetId(), info.getRevId(), starred,
|
|
||||||
canEditCommitMessage, info.getMessage(), commentLinkProcessor);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,261 +0,0 @@
|
|||||||
// Copyright (C) 2012 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.actions.ActionInfo;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.GitPerson;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.MessageInfo;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
|
||||||
import com.google.gerrit.client.rpc.NativeMap;
|
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
|
||||||
import com.google.gerrit.client.ui.ListenableValue;
|
|
||||||
import com.google.gerrit.common.data.AccountInfo;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
|
||||||
import com.google.gerrit.common.data.UiCommandDetail;
|
|
||||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo.ParentInfo;
|
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
|
||||||
import com.google.gerrit.reviewdb.client.UserIdentity;
|
|
||||||
import com.google.gwt.core.client.JsArray;
|
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChangeDetailCache extends ListenableValue<ChangeDetail> {
|
|
||||||
public static class NewGerritCallback extends
|
|
||||||
com.google.gerrit.client.rpc.GerritCallback<ChangeInfo> {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo detail) {
|
|
||||||
setChangeDetail(reverse(detail));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class IgnoreErrorCallback implements AsyncCallback<ChangeDetail> {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeDetail info) {
|
|
||||||
setChangeDetail(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChangeDetail reverse(ChangeInfo info) {
|
|
||||||
info.revisions().copyKeysIntoChildren("name");
|
|
||||||
RevisionInfo rev = current(info);
|
|
||||||
|
|
||||||
ChangeDetail r = new ChangeDetail();
|
|
||||||
r.setAllowsAnonymous(rev.has_fetch() && rev.fetch().containsKey("http"));
|
|
||||||
r.setCanAbandon(can(info.actions(), "abandon"));
|
|
||||||
r.setCanEditCommitMessage(can(rev.actions(), "message"));
|
|
||||||
r.setCanCherryPick(can(rev.actions(), "cherrypick"));
|
|
||||||
r.setCanPublish(can(rev.actions(), "publish"));
|
|
||||||
r.setCanRebase(can(rev.actions(), "rebase"));
|
|
||||||
r.setCanRestore(can(info.actions(), "restore"));
|
|
||||||
r.setCanRevert(can(info.actions(), "revert"));
|
|
||||||
r.setCanDeleteDraft(can(info.actions(), "/"));
|
|
||||||
r.setCanEditTopicName(can(info.actions(), "topic"));
|
|
||||||
r.setCanSubmit(can(rev.actions(), "submit"));
|
|
||||||
r.setCanEdit(true);
|
|
||||||
r.setChange(toChange(info));
|
|
||||||
r.setStarred(info.starred());
|
|
||||||
r.setPatchSets(toPatchSets(info));
|
|
||||||
r.setMergeable(info.mergeable());
|
|
||||||
r.setMessages(toMessages(info));
|
|
||||||
r.setAccounts(users(info));
|
|
||||||
r.setCurrentPatchSetId(new PatchSet.Id(info.legacy_id(), rev._number()));
|
|
||||||
r.setCurrentPatchSetDetail(toPatchSetDetail(info));
|
|
||||||
r.setSubmitRecords(new ArrayList<SubmitRecord>());
|
|
||||||
|
|
||||||
// Obtained later in ChangeScreen.
|
|
||||||
r.setSubmitTypeRecord(new SubmitTypeRecord());
|
|
||||||
r.getSubmitTypeRecord().status = SubmitTypeRecord.Status.RULE_ERROR;
|
|
||||||
r.setPatchSetsWithDraftComments(new HashSet<PatchSet.Id>());
|
|
||||||
r.setDependsOn(new ArrayList<com.google.gerrit.common.data.ChangeInfo>());
|
|
||||||
r.setNeededBy(new ArrayList<com.google.gerrit.common.data.ChangeInfo>());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PatchSetDetail toPatchSetDetail(ChangeInfo info) {
|
|
||||||
RevisionInfo rev = current(info);
|
|
||||||
PatchSetDetail p = new PatchSetDetail();
|
|
||||||
p.setPatchSet(toPatchSet(info, rev));
|
|
||||||
p.setProject(info.project_name_key());
|
|
||||||
p.setInfo(new PatchSetInfo(p.getPatchSet().getId()));
|
|
||||||
p.getInfo().setRevId(rev.name());
|
|
||||||
p.getInfo().setParents(new ArrayList<ParentInfo>());
|
|
||||||
p.getInfo().setAuthor(toUser(rev.commit().author()));
|
|
||||||
p.getInfo().setCommitter(toUser(rev.commit().committer()));
|
|
||||||
p.getInfo().setSubject(rev.commit().subject());
|
|
||||||
p.getInfo().setMessage(rev.commit().message());
|
|
||||||
if (rev.commit().parents() != null) {
|
|
||||||
for (CommitInfo c : Natives.asList(rev.commit().parents())) {
|
|
||||||
p.getInfo().getParents().add(new ParentInfo(
|
|
||||||
new RevId(c.commit()),
|
|
||||||
c.subject()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.setPatches(new ArrayList<Patch>());
|
|
||||||
p.setCommands(new ArrayList<UiCommandDetail>());
|
|
||||||
|
|
||||||
rev.files();
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UserIdentity toUser(GitPerson p) {
|
|
||||||
UserIdentity u = new UserIdentity();
|
|
||||||
u.setName(p.name());
|
|
||||||
u.setEmail(p.email());
|
|
||||||
u.setDate(p.date());
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AccountInfoCache users(ChangeInfo info) {
|
|
||||||
Map<Integer, AccountInfo> r = new HashMap<>();
|
|
||||||
add(r, info.owner());
|
|
||||||
if (info.messages() != null) {
|
|
||||||
for (MessageInfo m : Natives.asList(info.messages())) {
|
|
||||||
add(r, m.author());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new AccountInfoCache(r.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void add(Map<Integer, AccountInfo> r,
|
|
||||||
com.google.gerrit.client.account.AccountInfo user) {
|
|
||||||
if (user != null && !r.containsKey(user._account_id())) {
|
|
||||||
AccountInfo a = new AccountInfo(new Account.Id(user._account_id()));
|
|
||||||
a.setPreferredEmail(user.email());
|
|
||||||
a.setFullName(user.name());
|
|
||||||
r.put(user._account_id(), a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean can(NativeMap<ActionInfo> m, String n) {
|
|
||||||
return m != null && m.containsKey(n) && m.get(n).enabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<ChangeMessage> toMessages(ChangeInfo info) {
|
|
||||||
List<ChangeMessage> msgs = new ArrayList<>();
|
|
||||||
for (MessageInfo m : Natives.asList(info.messages())) {
|
|
||||||
ChangeMessage o = new ChangeMessage(
|
|
||||||
new ChangeMessage.Key(
|
|
||||||
info.legacy_id(),
|
|
||||||
m.date().toString()),
|
|
||||||
m.author() != null
|
|
||||||
? new Account.Id(m.author()._account_id())
|
|
||||||
: null,
|
|
||||||
m.date(),
|
|
||||||
m._revisionNumber() > 0
|
|
||||||
? new PatchSet.Id(info.legacy_id(), m._revisionNumber())
|
|
||||||
: null);
|
|
||||||
o.setMessage(m.message());
|
|
||||||
msgs.add(o);
|
|
||||||
}
|
|
||||||
return msgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<PatchSet> toPatchSets(ChangeInfo info) {
|
|
||||||
JsArray<RevisionInfo> all = info.revisions().values();
|
|
||||||
RevisionInfo.sortRevisionInfoByNumber(all);
|
|
||||||
|
|
||||||
List<PatchSet> r = new ArrayList<>(all.length());
|
|
||||||
for (RevisionInfo rev : Natives.asList(all)) {
|
|
||||||
r.add(toPatchSet(info, rev));
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PatchSet toPatchSet(ChangeInfo info, RevisionInfo rev) {
|
|
||||||
PatchSet p = new PatchSet(
|
|
||||||
new PatchSet.Id(info.legacy_id(), rev._number()));
|
|
||||||
p.setCreatedOn(rev.commit().committer().date());
|
|
||||||
p.setDraft(rev.draft());
|
|
||||||
p.setRevision(new RevId(rev.name()));
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Change toChange(ChangeInfo info) {
|
|
||||||
RevisionInfo rev = current(info);
|
|
||||||
PatchSetInfo p = new PatchSetInfo(
|
|
||||||
new PatchSet.Id(
|
|
||||||
info.legacy_id(),
|
|
||||||
rev._number()));
|
|
||||||
p.setSubject(info.subject());
|
|
||||||
Change c = new Change(
|
|
||||||
new Change.Key(info.change_id()),
|
|
||||||
info.legacy_id(),
|
|
||||||
new Account.Id(info.owner()._account_id()),
|
|
||||||
new Branch.NameKey(
|
|
||||||
info.project_name_key(),
|
|
||||||
info.branch()),
|
|
||||||
info.created());
|
|
||||||
c.setTopic(info.topic());
|
|
||||||
c.setStatus(info.status());
|
|
||||||
c.setCurrentPatchSet(p);
|
|
||||||
c.setLastUpdatedOn(info.updated());
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RevisionInfo current(ChangeInfo info) {
|
|
||||||
RevisionInfo rev = info.revision(info.current_revision());
|
|
||||||
if (rev == null) {
|
|
||||||
JsArray<RevisionInfo> all = info.revisions().values();
|
|
||||||
RevisionInfo.sortRevisionInfoByNumber(all);
|
|
||||||
rev = all.get(all.length() - 1);
|
|
||||||
}
|
|
||||||
return rev;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setChangeDetail(ChangeDetail detail) {
|
|
||||||
Change.Id chgId = detail.getChange().getId();
|
|
||||||
ChangeCache.get(chgId).getChangeDetailCache().set(detail);
|
|
||||||
StarredChanges.fireChangeStarEvent(chgId, detail.isStarred());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Change.Id changeId;
|
|
||||||
|
|
||||||
public ChangeDetailCache(final Change.Id chg) {
|
|
||||||
changeId = chg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
RestApi call = ChangeApi.detail(changeId.get());
|
|
||||||
ChangeList.addOptions(call, EnumSet.of(
|
|
||||||
ListChangesOption.CURRENT_ACTIONS,
|
|
||||||
ListChangesOption.ALL_REVISIONS,
|
|
||||||
ListChangesOption.ALL_COMMITS));
|
|
||||||
call.get(new NewGerritCallback());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,222 +0,0 @@
|
|||||||
// Copyright (C) 2008 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 static com.google.gerrit.client.FormatUtil.mediumFormat;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.ui.AccountLinkPanel;
|
|
||||||
import com.google.gerrit.client.ui.BranchLink;
|
|
||||||
import com.google.gerrit.client.ui.CommentedActionDialog;
|
|
||||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
|
||||||
import com.google.gerrit.client.ui.ProjectSearchLink;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.dom.client.KeyCodes;
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
import com.google.gwt.user.client.ui.Image;
|
|
||||||
import com.google.gwt.user.client.ui.InlineLabel;
|
|
||||||
import com.google.gwt.user.client.ui.TextBox;
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
import com.google.gwtexpui.clippy.client.CopyableLabel;
|
|
||||||
|
|
||||||
public class ChangeInfoBlock extends Composite {
|
|
||||||
private static final int R_CHANGE_ID = 0;
|
|
||||||
private static final int R_OWNER = 1;
|
|
||||||
private static final int R_PROJECT = 2;
|
|
||||||
private static final int R_BRANCH = 3;
|
|
||||||
private static final int R_TOPIC = 4;
|
|
||||||
private static final int R_UPLOADED = 5;
|
|
||||||
private static final int R_UPDATED = 6;
|
|
||||||
private static final int R_SUBMIT_TYPE = 7;
|
|
||||||
private static final int R_STATUS = 8;
|
|
||||||
private static final int R_MERGE_TEST = 9;
|
|
||||||
private static final int R_CNT = 10;
|
|
||||||
|
|
||||||
private final Grid table;
|
|
||||||
|
|
||||||
public ChangeInfoBlock() {
|
|
||||||
table = new Grid(R_CNT, 2);
|
|
||||||
table.setStyleName(Gerrit.RESOURCES.css().infoBlock());
|
|
||||||
table.addStyleName(Gerrit.RESOURCES.css().changeInfoBlock());
|
|
||||||
|
|
||||||
initRow(R_CHANGE_ID, "Change-Id: ");
|
|
||||||
initRow(R_OWNER, Util.C.changeInfoBlockOwner());
|
|
||||||
initRow(R_PROJECT, Util.C.changeInfoBlockProject());
|
|
||||||
initRow(R_BRANCH, Util.C.changeInfoBlockBranch());
|
|
||||||
initRow(R_TOPIC, Util.C.changeInfoBlockTopic());
|
|
||||||
initRow(R_UPLOADED, Util.C.changeInfoBlockUploaded());
|
|
||||||
initRow(R_UPDATED, Util.C.changeInfoBlockUpdated());
|
|
||||||
initRow(R_STATUS, Util.C.changeInfoBlockStatus());
|
|
||||||
initRow(R_SUBMIT_TYPE, Util.C.changeInfoBlockSubmitType());
|
|
||||||
initRow(R_MERGE_TEST, Util.C.changeInfoBlockCanMerge());
|
|
||||||
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
|
|
||||||
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
|
|
||||||
fmt.addStyleName(R_CHANGE_ID, 1, Gerrit.RESOURCES.css().changeid());
|
|
||||||
fmt.addStyleName(R_CNT - 2, 0, Gerrit.RESOURCES.css().bottomheader());
|
|
||||||
|
|
||||||
initWidget(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initRow(final int row, final String name) {
|
|
||||||
table.setText(row, 0, name);
|
|
||||||
table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void display(final ChangeDetail changeDetail,
|
|
||||||
final AccountInfoCache acc, SubmitTypeRecord submitTypeRecord) {
|
|
||||||
final Change chg = changeDetail.getChange();
|
|
||||||
final Branch.NameKey dst = chg.getDest();
|
|
||||||
|
|
||||||
CopyableLabel changeIdLabel =
|
|
||||||
new CopyableLabel("Change-Id: " + chg.getKey().get());
|
|
||||||
changeIdLabel.setPreviewText(chg.getKey().get());
|
|
||||||
table.setWidget(R_CHANGE_ID, 1, changeIdLabel);
|
|
||||||
|
|
||||||
table.setWidget(R_OWNER, 1, AccountLinkPanel.link(acc, chg.getOwner()));
|
|
||||||
|
|
||||||
final FlowPanel p = new FlowPanel();
|
|
||||||
p.add(new ProjectSearchLink(chg.getProject()));
|
|
||||||
p.add(new InlineHyperlink(chg.getProject().get(),
|
|
||||||
PageLinks.toProject(chg.getProject())));
|
|
||||||
table.setWidget(R_PROJECT, 1, p);
|
|
||||||
|
|
||||||
table.setWidget(R_BRANCH, 1, new BranchLink(dst.getShortName(), chg
|
|
||||||
.getProject(), chg.getStatus(), dst.get(), null));
|
|
||||||
table.setWidget(R_TOPIC, 1, topic(changeDetail));
|
|
||||||
table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn()));
|
|
||||||
table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn()));
|
|
||||||
table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus()));
|
|
||||||
String submitType;
|
|
||||||
if (submitTypeRecord.status == SubmitTypeRecord.Status.OK) {
|
|
||||||
submitType = com.google.gerrit.client.admin.Util
|
|
||||||
.toLongString(submitTypeRecord.type);
|
|
||||||
} else {
|
|
||||||
submitType = submitTypeRecord.status.name();
|
|
||||||
}
|
|
||||||
table.setText(R_SUBMIT_TYPE, 1, submitType);
|
|
||||||
final Change.Status status = chg.getStatus();
|
|
||||||
if (status.equals(Change.Status.NEW) || status.equals(Change.Status.DRAFT)) {
|
|
||||||
table.getRowFormatter().setVisible(R_MERGE_TEST, true);
|
|
||||||
table.setText(R_MERGE_TEST, 1, changeDetail.isMergeable() ? Util.C
|
|
||||||
.changeInfoBlockCanMergeYes() : Util.C.changeInfoBlockCanMergeNo());
|
|
||||||
} else {
|
|
||||||
table.getRowFormatter().setVisible(R_MERGE_TEST, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status.isClosed()) {
|
|
||||||
table.getCellFormatter().addStyleName(R_STATUS, 1, Gerrit.RESOURCES.css().closedstate());
|
|
||||||
table.getRowFormatter().setVisible(R_SUBMIT_TYPE, false);
|
|
||||||
} else {
|
|
||||||
table.getCellFormatter().removeStyleName(R_STATUS, 1, Gerrit.RESOURCES.css().closedstate());
|
|
||||||
table.getRowFormatter().setVisible(R_SUBMIT_TYPE, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Widget topic(final ChangeDetail changeDetail) {
|
|
||||||
final Change chg = changeDetail.getChange();
|
|
||||||
final Branch.NameKey dst = chg.getDest();
|
|
||||||
|
|
||||||
FlowPanel fp = new FlowPanel();
|
|
||||||
fp.addStyleName(Gerrit.RESOURCES.css().changeInfoTopicPanel());
|
|
||||||
fp.add(new BranchLink(chg.getTopic(), chg.getProject(), chg.getStatus(),
|
|
||||||
dst.get(), chg.getTopic()));
|
|
||||||
|
|
||||||
if (changeDetail.canEditTopicName()) {
|
|
||||||
final Image edit = new Image(Gerrit.RESOURCES.edit());
|
|
||||||
edit.addStyleName(Gerrit.RESOURCES.css().link());
|
|
||||||
edit.setTitle(Util.C.changeInfoBlockTopicAlterTopicToolTip());
|
|
||||||
edit.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
new AlterTopicDialog(chg).center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fp.add(edit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AlterTopicDialog extends CommentedActionDialog<ChangeDetail>
|
|
||||||
implements KeyPressHandler {
|
|
||||||
TextBox newTopic;
|
|
||||||
Change change;
|
|
||||||
|
|
||||||
AlterTopicDialog(Change chg) {
|
|
||||||
super(Util.C.alterTopicTitle(), Util.C.headingAlterTopicMessage(),
|
|
||||||
new ChangeDetailCache.IgnoreErrorCallback());
|
|
||||||
change = chg;
|
|
||||||
message.setVisible(false);
|
|
||||||
|
|
||||||
newTopic = new TextBox();
|
|
||||||
newTopic.addKeyPressHandler(this);
|
|
||||||
setFocusOn(newTopic);
|
|
||||||
panel.insert(newTopic, 0);
|
|
||||||
panel.insert(new InlineLabel(Util.C.alterTopicLabel()), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
newTopic.setText(change.getTopic());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doTopicEdit() {
|
|
||||||
String topic = newTopic.getText();
|
|
||||||
ChangeApi.topic(change.getId().get(), topic,
|
|
||||||
new GerritCallback<String>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String result) {
|
|
||||||
sent = true;
|
|
||||||
Gerrit.display(PageLinks.toChange(change.getId()));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(final Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
doTopicEdit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(KeyPressEvent event) {
|
|
||||||
if (event.getSource() == newTopic
|
|
||||||
&& event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
|
|
||||||
doTopicEdit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,774 +0,0 @@
|
|||||||
// Copyright (C) 2008 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.Dispatcher;
|
|
||||||
import com.google.gerrit.client.FormatUtil;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.account.AccountInfo;
|
|
||||||
import com.google.gerrit.client.change.RelatedChanges;
|
|
||||||
import com.google.gerrit.client.change.RelatedChanges.ChangeAndCommit;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
|
|
||||||
import com.google.gerrit.client.diff.DiffApi;
|
|
||||||
import com.google.gerrit.client.diff.FileInfo;
|
|
||||||
import com.google.gerrit.client.projects.ConfigInfoCache;
|
|
||||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.rpc.NativeMap;
|
|
||||||
import com.google.gerrit.client.rpc.NativeString;
|
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
|
||||||
import com.google.gerrit.client.ui.CommentPanel;
|
|
||||||
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
|
||||||
import com.google.gerrit.client.ui.ExpandAllCommand;
|
|
||||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
|
||||||
import com.google.gerrit.client.ui.NeedsSignInKeyCommand;
|
|
||||||
import com.google.gerrit.client.ui.Screen;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.ChangeInfo;
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
|
||||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
|
||||||
import com.google.gerrit.extensions.common.SubmitType;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
|
||||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch.PatchType;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gwt.core.client.JsArray;
|
|
||||||
import com.google.gwt.core.client.JsArrayString;
|
|
||||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
|
||||||
import com.google.gwt.event.shared.HandlerRegistration;
|
|
||||||
import com.google.gwt.i18n.client.LocaleInfo;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.Button;
|
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
|
||||||
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.InlineLabel;
|
|
||||||
import com.google.gwt.user.client.ui.Label;
|
|
||||||
import com.google.gwt.user.client.ui.ListBox;
|
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
public class ChangeScreen extends Screen
|
|
||||||
implements ValueChangeHandler<ChangeDetail> {
|
|
||||||
private final Change.Id changeId;
|
|
||||||
private final PatchSet.Id openPatchSetId;
|
|
||||||
private ChangeDetailCache detailCache;
|
|
||||||
private com.google.gerrit.client.changes.ChangeInfo changeInfo;
|
|
||||||
|
|
||||||
private ChangeDescriptionBlock descriptionBlock;
|
|
||||||
private ApprovalTable approvals;
|
|
||||||
|
|
||||||
private IncludedInTable includedInTable;
|
|
||||||
private DisclosurePanel includedInPanel;
|
|
||||||
private ComplexDisclosurePanel dependenciesPanel;
|
|
||||||
private ChangeTable dependencies;
|
|
||||||
private ChangeTable.Section dependsOn;
|
|
||||||
private ChangeTable.Section neededBy;
|
|
||||||
|
|
||||||
private PatchSetsBlock patchSetsBlock;
|
|
||||||
|
|
||||||
private Panel comments;
|
|
||||||
private CommentLinkProcessor commentLinkProcessor;
|
|
||||||
|
|
||||||
private KeyCommandSet keysNavigation;
|
|
||||||
private KeyCommandSet keysAction;
|
|
||||||
private HandlerRegistration regNavigation;
|
|
||||||
private HandlerRegistration regAction;
|
|
||||||
private HandlerRegistration regDetailCache;
|
|
||||||
|
|
||||||
private Grid patchesGrid;
|
|
||||||
private ListBox patchesList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The change id for which the old version history is valid.
|
|
||||||
*/
|
|
||||||
private static Change.Id currentChangeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Which patch set id is the diff base.
|
|
||||||
*/
|
|
||||||
private static PatchSet.Id diffBaseId;
|
|
||||||
|
|
||||||
public ChangeScreen(final Change.Id toShow) {
|
|
||||||
changeId = toShow;
|
|
||||||
openPatchSetId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangeScreen(final PatchSet.Id toShow) {
|
|
||||||
changeId = toShow.getParentKey();
|
|
||||||
openPatchSetId = toShow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChangeScreen(final ChangeInfo c) {
|
|
||||||
this(c.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
detailCache.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onUnload() {
|
|
||||||
if (regNavigation != null) {
|
|
||||||
regNavigation.removeHandler();
|
|
||||||
regNavigation = null;
|
|
||||||
}
|
|
||||||
if (regAction != null) {
|
|
||||||
regAction.removeHandler();
|
|
||||||
regAction = null;
|
|
||||||
}
|
|
||||||
if (regDetailCache != null) {
|
|
||||||
regDetailCache.removeHandler();
|
|
||||||
regDetailCache = null;
|
|
||||||
}
|
|
||||||
super.onUnload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerKeys() {
|
|
||||||
super.registerKeys();
|
|
||||||
regNavigation = GlobalKey.add(this, keysNavigation);
|
|
||||||
regAction = GlobalKey.add(this, keysAction);
|
|
||||||
if (openPatchSetId != null) {
|
|
||||||
patchSetsBlock.activate(openPatchSetId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onInitUI() {
|
|
||||||
super.onInitUI();
|
|
||||||
|
|
||||||
ChangeCache cache = ChangeCache.get(changeId);
|
|
||||||
|
|
||||||
detailCache = cache.getChangeDetailCache();
|
|
||||||
regDetailCache = detailCache.addValueChangeHandler(this);
|
|
||||||
|
|
||||||
addStyleName(Gerrit.RESOURCES.css().changeScreen());
|
|
||||||
addStyleName(Gerrit.RESOURCES.css().screenNoHeader());
|
|
||||||
|
|
||||||
keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
|
|
||||||
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
|
|
||||||
keysNavigation.add(new UpToListKeyCommand(0, 'u', Util.C.upToChangeList()));
|
|
||||||
keysNavigation.add(new ExpandCollapseDependencySectionKeyCommand(0, 'd', Util.C.expandCollapseDependencies()));
|
|
||||||
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
keysAction.add(new PublishCommentsKeyCommand(0, 'r', Util.C
|
|
||||||
.keyPublishComments()));
|
|
||||||
}
|
|
||||||
|
|
||||||
descriptionBlock = new ChangeDescriptionBlock(keysAction);
|
|
||||||
add(descriptionBlock);
|
|
||||||
|
|
||||||
approvals = new ApprovalTable();
|
|
||||||
add(approvals);
|
|
||||||
|
|
||||||
includedInPanel = new DisclosurePanel(Util.C.changeScreenIncludedIn());
|
|
||||||
includedInTable = new IncludedInTable(changeId);
|
|
||||||
|
|
||||||
includedInPanel.setContent(includedInTable);
|
|
||||||
add(includedInPanel);
|
|
||||||
|
|
||||||
dependencies = new ChangeTable() {
|
|
||||||
{
|
|
||||||
table.setWidth("auto");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
dependsOn = new ChangeTable.Section(Util.C.changeScreenDependsOn());
|
|
||||||
dependsOn.setChangeRowFormatter(new ChangeTable.ChangeRowFormatter() {
|
|
||||||
@Override
|
|
||||||
public String getRowStyle(ChangeInfo c) {
|
|
||||||
if (! c.isLatest() || Change.Status.ABANDONED.equals(c.getStatus())) {
|
|
||||||
return Gerrit.RESOURCES.css().outdated();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDisplayText(final ChangeInfo c, final String displayText) {
|
|
||||||
if (! c.isLatest()) {
|
|
||||||
return displayText + " [OUTDATED]";
|
|
||||||
}
|
|
||||||
return displayText;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
neededBy = new ChangeTable.Section(Util.C.changeScreenNeededBy());
|
|
||||||
dependencies.addSection(dependsOn);
|
|
||||||
dependencies.addSection(neededBy);
|
|
||||||
|
|
||||||
dependenciesPanel = new ComplexDisclosurePanel(
|
|
||||||
Util.C.changeScreenDependencies(), false);
|
|
||||||
dependenciesPanel.setContent(dependencies);
|
|
||||||
add(dependenciesPanel);
|
|
||||||
|
|
||||||
patchesList = new ListBox();
|
|
||||||
patchesList.addChangeHandler(new ChangeHandler() {
|
|
||||||
@Override
|
|
||||||
public void onChange(ChangeEvent event) {
|
|
||||||
final int index = patchesList.getSelectedIndex();
|
|
||||||
final String selectedPatchSet = patchesList.getValue(index);
|
|
||||||
if (index == 0) {
|
|
||||||
diffBaseId = null;
|
|
||||||
} else {
|
|
||||||
diffBaseId = PatchSet.Id.parse(selectedPatchSet);
|
|
||||||
}
|
|
||||||
if (patchSetsBlock != null) {
|
|
||||||
patchSetsBlock.refresh(diffBaseId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
patchesGrid = new Grid(1, 2);
|
|
||||||
patchesGrid.setStyleName(Gerrit.RESOURCES.css().selectPatchSetOldVersion());
|
|
||||||
patchesGrid.setText(0, 0, Util.C.referenceVersion());
|
|
||||||
patchesGrid.setWidget(0, 1, patchesList);
|
|
||||||
add(patchesGrid);
|
|
||||||
|
|
||||||
patchSetsBlock = new PatchSetsBlock();
|
|
||||||
add(patchSetsBlock);
|
|
||||||
|
|
||||||
comments = new FlowPanel();
|
|
||||||
comments.setStyleName(Gerrit.RESOURCES.css().changeComments());
|
|
||||||
add(comments);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayTitle(final Change.Key changeId, final String subject) {
|
|
||||||
final StringBuilder titleBuf = new StringBuilder();
|
|
||||||
if (LocaleInfo.getCurrentLocale().isRTL()) {
|
|
||||||
if (subject != null) {
|
|
||||||
titleBuf.append(subject);
|
|
||||||
titleBuf.append(" :");
|
|
||||||
}
|
|
||||||
titleBuf.append(Util.M.changeScreenTitleId(changeId.abbreviate()));
|
|
||||||
} else {
|
|
||||||
titleBuf.append(Util.M.changeScreenTitleId(changeId.abbreviate()));
|
|
||||||
if (subject != null) {
|
|
||||||
titleBuf.append(": ");
|
|
||||||
titleBuf.append(subject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setPageTitle(titleBuf.toString());
|
|
||||||
setHeaderVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onValueChange(final ValueChangeEvent<ChangeDetail> event) {
|
|
||||||
if (isAttached() && isLastValueChangeHandler()) {
|
|
||||||
// Until this screen is fully migrated to the new API, these calls must
|
|
||||||
// happen sequentially after the ChangeDetail lookup, because we can't
|
|
||||||
// start an async get at the source of every call that might trigger a
|
|
||||||
// value change.
|
|
||||||
CallbackGroup cbs1 = new CallbackGroup();
|
|
||||||
final CallbackGroup cbs2 = new CallbackGroup();
|
|
||||||
final PatchSet.Id psId = event.getValue().getCurrentPatchSet().getId();
|
|
||||||
final Map<String, Patch> patches = new HashMap<>();
|
|
||||||
String revId =
|
|
||||||
event.getValue().getCurrentPatchSetDetail().getInfo().getRevId();
|
|
||||||
|
|
||||||
if (event.getValue().getChange().getStatus().isOpen()) {
|
|
||||||
ChangeApi.revision(changeId.get(), "current")
|
|
||||||
.view("submit_type")
|
|
||||||
.get(cbs1.add(new GerritCallback<NativeString>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeString result) {
|
|
||||||
event.getValue().setSubmitTypeRecord(SubmitTypeRecord.OK(
|
|
||||||
SubmitType.valueOf(result.asString())));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
ChangeApi.revision(changeId.get(), "" + psId.get())
|
|
||||||
.view("related")
|
|
||||||
.get(cbs1.add(new AsyncCallback<RelatedChanges.RelatedInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(RelatedChanges.RelatedInfo info) {
|
|
||||||
if (info.changes() != null) {
|
|
||||||
dependsOn(info);
|
|
||||||
neededBy(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dependsOn(RelatedChanges.RelatedInfo info) {
|
|
||||||
ChangeAndCommit self = null;
|
|
||||||
Map<String, ChangeAndCommit> m = new HashMap<>();
|
|
||||||
for (int i = 0; i < info.changes().length(); i++) {
|
|
||||||
ChangeAndCommit c = info.changes().get(i);
|
|
||||||
if (changeId.equals(c.legacy_id())) {
|
|
||||||
self = c;
|
|
||||||
}
|
|
||||||
if (c.commit() != null && c.commit().commit() != null) {
|
|
||||||
m.put(c.commit().commit(), c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self != null && self.commit() != null
|
|
||||||
&& self.commit().parents() != null) {
|
|
||||||
List<ChangeInfo> d = new ArrayList<>();
|
|
||||||
for (CommitInfo p : Natives.asList(self.commit().parents())) {
|
|
||||||
ChangeAndCommit pc = m.get(p.commit());
|
|
||||||
if (pc != null && pc.has_change_number()) {
|
|
||||||
ChangeInfo i = new ChangeInfo();
|
|
||||||
load(pc, i);
|
|
||||||
d.add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
event.getValue().setDependsOn(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void neededBy(RelatedChanges.RelatedInfo info) {
|
|
||||||
Set<String> mine = new HashSet<>();
|
|
||||||
for (PatchSet ps : event.getValue().getPatchSets()) {
|
|
||||||
mine.add(ps.getRevision().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ChangeInfo> n = new ArrayList<>();
|
|
||||||
for (int i = 0; i < info.changes().length(); i++) {
|
|
||||||
ChangeAndCommit c = info.changes().get(i);
|
|
||||||
if (c.has_change_number()
|
|
||||||
&& c.commit() != null
|
|
||||||
&& c.commit().parents() != null) {
|
|
||||||
for (int j = 0; j < c.commit().parents().length(); j++) {
|
|
||||||
CommitInfo p = c.commit().parents().get(j);
|
|
||||||
if (mine.contains(p.commit())) {
|
|
||||||
ChangeInfo u = new ChangeInfo();
|
|
||||||
load(c, u);
|
|
||||||
n.add(u);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
event.getValue().setNeededBy(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void load(final ChangeAndCommit pc, final ChangeInfo i) {
|
|
||||||
RestApi call = ChangeApi.change(pc.legacy_id().get());
|
|
||||||
ChangeList.addOptions(call, EnumSet.of(
|
|
||||||
ListChangesOption.DETAILED_ACCOUNTS,
|
|
||||||
ListChangesOption.CURRENT_REVISION));
|
|
||||||
call.get(cbs2.add(new AsyncCallback<
|
|
||||||
com.google.gerrit.client.changes.ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
@Override
|
|
||||||
public void onSuccess(
|
|
||||||
com.google.gerrit.client.changes.ChangeInfo result) {
|
|
||||||
i.set(ChangeDetailCache.toChange(result),
|
|
||||||
pc.patch_set_id());
|
|
||||||
i.setStarred(result.starred());
|
|
||||||
event.getValue().getAccounts()
|
|
||||||
.merge(ChangeDetailCache.users(result));
|
|
||||||
}}));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
ChangeApi.revision(changeId.get(), revId)
|
|
||||||
.view("files")
|
|
||||||
.addParameterTrue("reviewed")
|
|
||||||
.get(cbs1.add(new AsyncCallback<JsArrayString>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(JsArrayString result) {
|
|
||||||
for(int i = 0; i < result.length(); i++) {
|
|
||||||
String path = result.get(i);
|
|
||||||
Patch p = patches.get(path);
|
|
||||||
if (p == null) {
|
|
||||||
p = new Patch(new Patch.Key(psId, path));
|
|
||||||
patches.put(path, p);
|
|
||||||
}
|
|
||||||
p.setReviewedByCurrentUser(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
final Set<PatchSet.Id> withDrafts = new HashSet<>();
|
|
||||||
event.getValue().setPatchSetsWithDraftComments(withDrafts);
|
|
||||||
for (PatchSet ps : event.getValue().getPatchSets()) {
|
|
||||||
if (!ps.getId().equals(psId)) {
|
|
||||||
final PatchSet.Id id = ps.getId();
|
|
||||||
ChangeApi.revision(changeId.get(), "" + id.get())
|
|
||||||
.view("drafts")
|
|
||||||
.get(cbs1.add(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
withDrafts.add(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChangeApi.revision(changeId.get(), "" + psId.get())
|
|
||||||
.view("drafts")
|
|
||||||
.get(cbs1.add(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
|
|
||||||
for (String path : result.keySet()) {
|
|
||||||
Patch p = patches.get(path);
|
|
||||||
if (p == null) {
|
|
||||||
p = new Patch(new Patch.Key(psId, path));
|
|
||||||
patches.put(path, p);
|
|
||||||
}
|
|
||||||
p.setDraftCount(result.get(path).length());
|
|
||||||
}
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
withDrafts.add(psId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
ChangeApi.revision(changeId.get(), revId)
|
|
||||||
.view("comments")
|
|
||||||
.get(cbs1.add(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
|
|
||||||
for (String path : result.keySet()) {
|
|
||||||
Patch p = patches.get(path);
|
|
||||||
if (p == null) {
|
|
||||||
p = new Patch(new Patch.Key(psId, path));
|
|
||||||
patches.put(path, p);
|
|
||||||
}
|
|
||||||
p.setCommentCount(result.get(path).length());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
DiffApi.list(changeId.get(), null, revId,
|
|
||||||
new AsyncCallback<NativeMap<FileInfo>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeMap<FileInfo> result) {
|
|
||||||
JsArray<FileInfo> fileInfos = result.values();
|
|
||||||
FileInfo.sortFileInfoByPath(fileInfos);
|
|
||||||
List<Patch> list = new ArrayList<>(fileInfos.length());
|
|
||||||
for (FileInfo f : Natives.asList(fileInfos)) {
|
|
||||||
Patch p = patches.get(f.path());
|
|
||||||
if (p == null) {
|
|
||||||
p = new Patch(new Patch.Key(psId, f.path()));
|
|
||||||
patches.put(f.path(), p);
|
|
||||||
}
|
|
||||||
p.setInsertions(f.lines_inserted());
|
|
||||||
p.setDeletions(f.lines_deleted());
|
|
||||||
p.setPatchType(f.binary() ? PatchType.BINARY : PatchType.UNIFIED);
|
|
||||||
if (f.status() == null) {
|
|
||||||
p.setChangeType(ChangeType.MODIFIED);
|
|
||||||
} else {
|
|
||||||
p.setChangeType(ChangeType.forCode(f.status().charAt(0)));
|
|
||||||
}
|
|
||||||
list.add(p);
|
|
||||||
}
|
|
||||||
event.getValue().getCurrentPatchSetDetail().setPatches(list);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
});
|
|
||||||
ConfigInfoCache.get(
|
|
||||||
event.getValue().getChange().getProject(),
|
|
||||||
cbs1.add(new GerritCallback<ConfigInfoCache.Entry>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ConfigInfoCache.Entry result) {
|
|
||||||
commentLinkProcessor = result.getCommentLinkProcessor();
|
|
||||||
setTheme(result.getTheme());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// Handled by last callback's onFailure.
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
ChangeApi.detail(changeId.get(), cbs1.addFinal(
|
|
||||||
new GerritCallback<com.google.gerrit.client.changes.ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(
|
|
||||||
com.google.gerrit.client.changes.ChangeInfo result) {
|
|
||||||
changeInfo = result;
|
|
||||||
cbs2.addFinal(new AsyncCallback<Void>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Void result) {
|
|
||||||
display(event.getValue());
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}).onSuccess(null);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the last attached screen.
|
|
||||||
// When DialogBox is used (i. e. CommentedActionDialog) then the original
|
|
||||||
// ChangeScreen is still in attached state.
|
|
||||||
// Use here the fact, that the handlers (ChangeScreen) are sorted.
|
|
||||||
private boolean isLastValueChangeHandler() {
|
|
||||||
int count = detailCache.getHandlerCount();
|
|
||||||
return count > 0 && detailCache.getHandler(count - 1) == this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void display(final ChangeDetail detail) {
|
|
||||||
displayTitle(detail.getChange().getKey(), detail.getChange().getSubject());
|
|
||||||
discardDiffBaseIfNotApplicable(detail.getChange().getId());
|
|
||||||
|
|
||||||
if (Status.MERGED == detail.getChange().getStatus()) {
|
|
||||||
includedInPanel.setVisible(true);
|
|
||||||
includedInPanel.addOpenHandler(includedInTable);
|
|
||||||
} else {
|
|
||||||
includedInPanel.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies.setAccountInfoCache(detail.getAccounts());
|
|
||||||
|
|
||||||
descriptionBlock.display(detail,
|
|
||||||
detail.isStarred(),
|
|
||||||
detail.canEditCommitMessage(),
|
|
||||||
detail.getCurrentPatchSetDetail().getInfo(),
|
|
||||||
detail.getAccounts(), detail.getSubmitTypeRecord(),
|
|
||||||
commentLinkProcessor);
|
|
||||||
dependsOn.display(detail.getDependsOn());
|
|
||||||
neededBy.display(detail.getNeededBy());
|
|
||||||
approvals.display(changeInfo);
|
|
||||||
|
|
||||||
patchesList.clear();
|
|
||||||
if (detail.getCurrentPatchSetDetail().getInfo().getParents().size() > 1) {
|
|
||||||
patchesList.addItem(Util.C.autoMerge());
|
|
||||||
} else {
|
|
||||||
patchesList.addItem(Util.C.baseDiffItem());
|
|
||||||
}
|
|
||||||
for (PatchSet pId : detail.getPatchSets()) {
|
|
||||||
patchesList.addItem(Util.M.patchSetHeader(pId.getPatchSetId()), pId
|
|
||||||
.getId().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diffBaseId != null) {
|
|
||||||
patchesList.setSelectedIndex(diffBaseId.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
patchSetsBlock.display(detail, diffBaseId);
|
|
||||||
addComments(detail);
|
|
||||||
|
|
||||||
// If any dependency change is still open, or is outdated,
|
|
||||||
// or the change is needed by a change that is new or submitted,
|
|
||||||
// show our dependency list.
|
|
||||||
//
|
|
||||||
boolean depsOpen = false;
|
|
||||||
int outdated = 0;
|
|
||||||
if (!detail.getChange().getStatus().isClosed()) {
|
|
||||||
final List<ChangeInfo> dependsOn = detail.getDependsOn();
|
|
||||||
if (dependsOn != null) {
|
|
||||||
for (final ChangeInfo ci : dependsOn) {
|
|
||||||
if (!ci.isLatest()) {
|
|
||||||
depsOpen = true;
|
|
||||||
outdated++;
|
|
||||||
} else if (ci.getStatus() != Change.Status.MERGED) {
|
|
||||||
depsOpen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final List<ChangeInfo> neededBy = detail.getNeededBy();
|
|
||||||
if (neededBy != null) {
|
|
||||||
for (final ChangeInfo ci : neededBy) {
|
|
||||||
if ((ci.getStatus() == Change.Status.NEW) ||
|
|
||||||
(ci.getStatus() == Change.Status.SUBMITTED) ||
|
|
||||||
(ci.getStatus() == Change.Status.DRAFT)) {
|
|
||||||
depsOpen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependenciesPanel.setOpen(depsOpen);
|
|
||||||
|
|
||||||
dependenciesPanel.getHeader().clear();
|
|
||||||
if (outdated > 0) {
|
|
||||||
dependenciesPanel.getHeader().add(new InlineLabel(
|
|
||||||
Util.M.outdatedHeader(outdated)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isCurrentView()) {
|
|
||||||
display();
|
|
||||||
}
|
|
||||||
patchSetsBlock.setRegisterKeys(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void discardDiffBaseIfNotApplicable(final Change.Id toShow) {
|
|
||||||
if (currentChangeId != null && !currentChangeId.equals(toShow)) {
|
|
||||||
diffBaseId = null;
|
|
||||||
}
|
|
||||||
currentChangeId = toShow;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addComments(final ChangeDetail detail) {
|
|
||||||
comments.clear();
|
|
||||||
|
|
||||||
final AccountInfoCache accts = detail.getAccounts();
|
|
||||||
final List<ChangeMessage> msgList = detail.getMessages();
|
|
||||||
|
|
||||||
HorizontalPanel title = new HorizontalPanel();
|
|
||||||
title.setWidth("100%");
|
|
||||||
title.add(new Label(Util.C.changeScreenComments()));
|
|
||||||
if (msgList.size() > 1) {
|
|
||||||
title.add(messagesMenuBar());
|
|
||||||
}
|
|
||||||
title.setStyleName(Gerrit.RESOURCES.css().blockHeader());
|
|
||||||
comments.add(title);
|
|
||||||
|
|
||||||
final long AGE = 7 * 24 * 60 * 60 * 1000L;
|
|
||||||
final Timestamp aged = new Timestamp(System.currentTimeMillis() - AGE);
|
|
||||||
|
|
||||||
CommentVisibilityStrategy commentVisibilityStrategy =
|
|
||||||
CommentVisibilityStrategy.EXPAND_RECENT;
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
commentVisibilityStrategy = Gerrit.getUserAccount()
|
|
||||||
.getGeneralPreferences().getCommentVisibilityStrategy();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < msgList.size(); i++) {
|
|
||||||
final ChangeMessage msg = msgList.get(i);
|
|
||||||
|
|
||||||
AccountInfo author;
|
|
||||||
if (msg.getAuthor() != null) {
|
|
||||||
author = FormatUtil.asInfo(accts.get(msg.getAuthor()));
|
|
||||||
} else {
|
|
||||||
author = AccountInfo.create(0, Util.C.messageNoAuthor(), null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isRecent;
|
|
||||||
if (i == msgList.size() - 1) {
|
|
||||||
isRecent = true;
|
|
||||||
} else {
|
|
||||||
// TODO Instead of opening messages by strict age, do it by "unread"?
|
|
||||||
isRecent = msg.getWrittenOn().after(aged);
|
|
||||||
}
|
|
||||||
|
|
||||||
final CommentPanel cp = new CommentPanel(author, msg.getWrittenOn(),
|
|
||||||
msg.getMessage(), commentLinkProcessor);
|
|
||||||
cp.setRecent(isRecent);
|
|
||||||
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelBorder());
|
|
||||||
if (i == msgList.size() - 1) {
|
|
||||||
cp.addStyleName(Gerrit.RESOURCES.css().commentPanelLast());
|
|
||||||
}
|
|
||||||
boolean isOpen = false;
|
|
||||||
switch (commentVisibilityStrategy) {
|
|
||||||
case COLLAPSE_ALL:
|
|
||||||
break;
|
|
||||||
case EXPAND_ALL:
|
|
||||||
isOpen = true;
|
|
||||||
break;
|
|
||||||
case EXPAND_MOST_RECENT:
|
|
||||||
isOpen = i == msgList.size() - 1;
|
|
||||||
break;
|
|
||||||
case EXPAND_RECENT:
|
|
||||||
default:
|
|
||||||
isOpen = isRecent;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cp.setOpen(isOpen);
|
|
||||||
comments.add(cp);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Button b = new Button(Util.C.changeScreenAddComment());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
PatchSet.Id currentPatchSetId = patchSetsBlock.getCurrentPatchSet().getId();
|
|
||||||
Gerrit.display(Dispatcher.toPublish(currentPatchSetId));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
comments.add(b);
|
|
||||||
comments.setVisible(msgList.size() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LinkMenuBar messagesMenuBar() {
|
|
||||||
final Panel c = comments;
|
|
||||||
final LinkMenuBar menuBar = new LinkMenuBar();
|
|
||||||
menuBar.addItem(Util.C.messageExpandRecent(), new ExpandAllCommand(c, true) {
|
|
||||||
@Override
|
|
||||||
protected void expand(final CommentPanel w) {
|
|
||||||
w.setOpen(w.isRecent());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menuBar.addItem(Util.C.messageExpandAll(), new ExpandAllCommand(c, true));
|
|
||||||
menuBar.addItem(Util.C.messageCollapseAll(), new ExpandAllCommand(c, false));
|
|
||||||
menuBar.addStyleName(Gerrit.RESOURCES.css().commentPanelMenuBar());
|
|
||||||
return menuBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UpToListKeyCommand extends KeyCommand {
|
|
||||||
public UpToListKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
Gerrit.displayLastChangeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ExpandCollapseDependencySectionKeyCommand extends KeyCommand {
|
|
||||||
public ExpandCollapseDependencySectionKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(KeyPressEvent event) {
|
|
||||||
dependenciesPanel.setOpen(!dependenciesPanel.isOpen());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PublishCommentsKeyCommand extends NeedsSignInKeyCommand {
|
|
||||||
public PublishCommentsKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
PatchSet.Id currentPatchSetId = patchSetsBlock.getCurrentPatchSet().getId();
|
|
||||||
Gerrit.display(Dispatcher.toPublish(currentPatchSetId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,350 +0,0 @@
|
|||||||
// Copyright (C) 2008 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 static com.google.gerrit.client.FormatUtil.shortFormat;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.ui.AccountLinkPanel;
|
|
||||||
import com.google.gerrit.client.ui.BranchLink;
|
|
||||||
import com.google.gerrit.client.ui.ChangeLink;
|
|
||||||
import com.google.gerrit.client.ui.NavigationTable;
|
|
||||||
import com.google.gerrit.client.ui.NeedsSignInKeyCommand;
|
|
||||||
import com.google.gerrit.client.ui.ProjectLink;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.AccountInfoCache;
|
|
||||||
import com.google.gerrit.common.data.ChangeInfo;
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
|
||||||
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ChangeTable extends NavigationTable<ChangeInfo> {
|
|
||||||
private static final int C_STAR = 1;
|
|
||||||
private static final int C_SUBJECT = 2;
|
|
||||||
private static final int C_OWNER = 3;
|
|
||||||
private static final int C_PROJECT = 4;
|
|
||||||
private static final int C_BRANCH = 5;
|
|
||||||
private static final int C_LAST_UPDATE = 6;
|
|
||||||
private static final int COLUMNS = 7;
|
|
||||||
|
|
||||||
private final List<Section> sections;
|
|
||||||
private AccountInfoCache accountCache = AccountInfoCache.empty();
|
|
||||||
|
|
||||||
public ChangeTable() {
|
|
||||||
super(Util.C.changeItemHelp());
|
|
||||||
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
keysAction.add(new StarKeyCommand(0, 's', Util.C.changeTableStar()));
|
|
||||||
}
|
|
||||||
|
|
||||||
sections = new ArrayList<>();
|
|
||||||
table.setText(0, C_STAR, "");
|
|
||||||
table.setText(0, C_SUBJECT, Util.C.changeTableColumnSubject());
|
|
||||||
table.setText(0, C_OWNER, Util.C.changeTableColumnOwner());
|
|
||||||
table.setText(0, C_PROJECT, Util.C.changeTableColumnProject());
|
|
||||||
table.setText(0, C_BRANCH, Util.C.changeTableColumnBranch());
|
|
||||||
table.setText(0, C_LAST_UPDATE, Util.C.changeTableColumnLastUpdate());
|
|
||||||
|
|
||||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
|
||||||
fmt.addStyleName(0, C_STAR, Gerrit.RESOURCES.css().iconHeader());
|
|
||||||
for (int i = C_SUBJECT; i < COLUMNS; i++) {
|
|
||||||
fmt.addStyleName(0, i, Gerrit.RESOURCES.css().dataHeader());
|
|
||||||
}
|
|
||||||
|
|
||||||
table.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
final Cell cell = table.getCellForEvent(event);
|
|
||||||
if (cell == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (cell.getCellIndex() == C_STAR) {
|
|
||||||
// Don't do anything (handled by star itself).
|
|
||||||
} else if (cell.getCellIndex() == C_OWNER) {
|
|
||||||
// Don't do anything.
|
|
||||||
} else if (getRowItem(cell.getRowIndex()) != null) {
|
|
||||||
movePointerTo(cell.getRowIndex());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onStarClick(final int row) {
|
|
||||||
final ChangeInfo c = getRowItem(row);
|
|
||||||
if (c != null && Gerrit.isSignedIn()) {
|
|
||||||
((StarredChanges.Icon) table.getWidget(row, C_STAR)).toggleStar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object getRowItemKey(final ChangeInfo item) {
|
|
||||||
return item.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onOpenRow(final int row) {
|
|
||||||
final ChangeInfo c = getRowItem(row);
|
|
||||||
Gerrit.display(PageLinks.toChange(c), new ChangeScreen(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertNoneRow(final int row) {
|
|
||||||
insertRow(row);
|
|
||||||
table.setText(row, 0, Util.C.changeTableNone());
|
|
||||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
|
||||||
fmt.setColSpan(row, 0, COLUMNS);
|
|
||||||
fmt.setStyleName(row, 0, Gerrit.RESOURCES.css().emptySection());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertChangeRow(final int row) {
|
|
||||||
insertRow(row);
|
|
||||||
applyDataRowStyle(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyDataRowStyle(final int row) {
|
|
||||||
super.applyDataRowStyle(row);
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
fmt.addStyleName(row, C_STAR, Gerrit.RESOURCES.css().iconCell());
|
|
||||||
for (int i = C_SUBJECT; i < COLUMNS; i++) {
|
|
||||||
fmt.addStyleName(row, i, Gerrit.RESOURCES.css().dataCell());
|
|
||||||
}
|
|
||||||
fmt.addStyleName(row, C_SUBJECT, Gerrit.RESOURCES.css().cSUBJECT());
|
|
||||||
fmt.addStyleName(row, C_OWNER, Gerrit.RESOURCES.css().cOWNER());
|
|
||||||
fmt.addStyleName(row, C_LAST_UPDATE, Gerrit.RESOURCES.css().cLastUpdate());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateChangeRow(final int row, final ChangeInfo c,
|
|
||||||
final ChangeRowFormatter changeRowFormatter) {
|
|
||||||
ChangeCache cache = ChangeCache.get(c.getId());
|
|
||||||
cache.getChangeInfoCache().set(c);
|
|
||||||
|
|
||||||
table.setWidget(row, C_ARROW, null);
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
table.setWidget(row, C_STAR, StarredChanges.createIcon(c.getId(), c.isStarred()));
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = Util.cropSubject(c.getSubject());
|
|
||||||
if (c.getStatus() != null && c.getStatus() != Change.Status.NEW) {
|
|
||||||
s += " (" + c.getStatus().name() + ")";
|
|
||||||
}
|
|
||||||
if (changeRowFormatter != null) {
|
|
||||||
removeChangeStyle(row, changeRowFormatter);
|
|
||||||
final String rowStyle = changeRowFormatter.getRowStyle(c);
|
|
||||||
if (rowStyle != null) {
|
|
||||||
table.getRowFormatter().addStyleName(row, rowStyle);
|
|
||||||
}
|
|
||||||
s = changeRowFormatter.getDisplayText(c, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
table.setWidget(row, C_SUBJECT, new TableChangeLink(s, c));
|
|
||||||
table.setWidget(row, C_OWNER, link(c.getOwner()));
|
|
||||||
table.setWidget(row, C_PROJECT, new ProjectLink(c.getProject().getKey()));
|
|
||||||
table.setWidget(row, C_BRANCH, new BranchLink(c.getProject().getKey(), c
|
|
||||||
.getStatus(), c.getBranch(), c.getTopic()));
|
|
||||||
table.setText(row, C_LAST_UPDATE, shortFormat(c.getLastUpdatedOn()));
|
|
||||||
|
|
||||||
setRowItem(row, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeChangeStyle(int row,
|
|
||||||
final ChangeRowFormatter changeRowFormatter) {
|
|
||||||
final ChangeInfo oldChange = getRowItem(row);
|
|
||||||
if (oldChange == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String oldRowStyle = changeRowFormatter.getRowStyle(oldChange);
|
|
||||||
if (oldRowStyle != null) {
|
|
||||||
table.getRowFormatter().removeStyleName(row, oldRowStyle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private AccountLinkPanel link(final Account.Id id) {
|
|
||||||
return AccountLinkPanel.link(accountCache, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSection(final Section s) {
|
|
||||||
assert s.parent == null;
|
|
||||||
|
|
||||||
if (s.titleText != null) {
|
|
||||||
s.titleRow = table.getRowCount();
|
|
||||||
table.setText(s.titleRow, 0, s.titleText);
|
|
||||||
final FlexCellFormatter fmt = table.getFlexCellFormatter();
|
|
||||||
fmt.setColSpan(s.titleRow, 0, COLUMNS);
|
|
||||||
fmt.addStyleName(s.titleRow, 0, Gerrit.RESOURCES.css().sectionHeader());
|
|
||||||
} else {
|
|
||||||
s.titleRow = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.parent = this;
|
|
||||||
s.dataBegin = table.getRowCount();
|
|
||||||
insertNoneRow(s.dataBegin);
|
|
||||||
sections.add(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccountInfoCache(final AccountInfoCache aic) {
|
|
||||||
assert aic != null;
|
|
||||||
accountCache = aic;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int insertRow(final int beforeRow) {
|
|
||||||
for (final Section s : sections) {
|
|
||||||
if (beforeRow <= s.titleRow) {
|
|
||||||
s.titleRow++;
|
|
||||||
}
|
|
||||||
if (beforeRow < s.dataBegin) {
|
|
||||||
s.dataBegin++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return table.insertRow(beforeRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeRow(final int row) {
|
|
||||||
for (final Section s : sections) {
|
|
||||||
if (row < s.titleRow) {
|
|
||||||
s.titleRow--;
|
|
||||||
}
|
|
||||||
if (row < s.dataBegin) {
|
|
||||||
s.dataBegin--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table.removeRow(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class StarKeyCommand extends NeedsSignInKeyCommand {
|
|
||||||
public StarKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
onStarClick(getCurrentRow());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class TableChangeLink extends ChangeLink {
|
|
||||||
private TableChangeLink(final String text, final ChangeInfo c) {
|
|
||||||
super(text, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void go() {
|
|
||||||
movePointerTo(cid);
|
|
||||||
super.go();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Section {
|
|
||||||
String titleText;
|
|
||||||
|
|
||||||
ChangeTable parent;
|
|
||||||
final Account.Id ownerId;
|
|
||||||
int titleRow = -1;
|
|
||||||
int dataBegin;
|
|
||||||
int rows;
|
|
||||||
|
|
||||||
private ChangeRowFormatter changeRowFormatter;
|
|
||||||
|
|
||||||
public Section() {
|
|
||||||
this(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Section(final String titleText) {
|
|
||||||
this(titleText, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Section(final String titleText, final Account.Id owner) {
|
|
||||||
setTitleText(titleText);
|
|
||||||
ownerId = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitleText(final String text) {
|
|
||||||
titleText = text;
|
|
||||||
if (titleRow >= 0) {
|
|
||||||
parent.table.setText(titleRow, 0, titleText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChangeRowFormatter(final ChangeRowFormatter changeRowFormatter) {
|
|
||||||
this.changeRowFormatter = changeRowFormatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void display(final List<ChangeInfo> changeList) {
|
|
||||||
final int sz = changeList != null ? changeList.size() : 0;
|
|
||||||
final boolean hadData = rows > 0;
|
|
||||||
|
|
||||||
if (hadData) {
|
|
||||||
while (sz < rows) {
|
|
||||||
parent.removeRow(dataBegin);
|
|
||||||
rows--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sz == 0) {
|
|
||||||
if (hadData) {
|
|
||||||
parent.insertNoneRow(dataBegin);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Set<Change.Id> cids = new HashSet<>();
|
|
||||||
|
|
||||||
if (!hadData) {
|
|
||||||
parent.removeRow(dataBegin);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (rows < sz) {
|
|
||||||
parent.insertChangeRow(dataBegin + rows);
|
|
||||||
rows++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < sz; i++) {
|
|
||||||
ChangeInfo c = changeList.get(i);
|
|
||||||
parent.populateChangeRow(dataBegin + i, c, changeRowFormatter);
|
|
||||||
cids.add(c.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface ChangeRowFormatter {
|
|
||||||
/**
|
|
||||||
* Returns the name of the CSS style that should be applied to the change
|
|
||||||
* row.
|
|
||||||
*
|
|
||||||
* @param c the change for which the styling should be returned
|
|
||||||
* @return the name of the CSS style that should be applied to the change
|
|
||||||
* row
|
|
||||||
*/
|
|
||||||
String getRowStyle(ChangeInfo c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the text that should be displayed for the change.
|
|
||||||
*
|
|
||||||
* @param c the change for which the display text should be returned
|
|
||||||
* @param displayText the current display text
|
|
||||||
* @return the new display text
|
|
||||||
*/
|
|
||||||
String getDisplayText(ChangeInfo c, String displayText);
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,32 +15,23 @@
|
|||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.client.changes;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.ui.ChangeLink;
|
import com.google.gerrit.client.ui.ChangeLink;
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||||
import com.google.gerrit.client.ui.CommentedActionDialog;
|
|
||||||
import com.google.gerrit.client.ui.TextBoxChangeListener;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
|
||||||
import com.google.gwt.dom.client.PreElement;
|
import com.google.gwt.dom.client.PreElement;
|
||||||
import com.google.gwt.dom.client.Style.Display;
|
import com.google.gwt.dom.client.Style.Display;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
import com.google.gwtexpui.clippy.client.CopyableLabel;
|
import com.google.gwtexpui.clippy.client.CopyableLabel;
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
|
||||||
|
|
||||||
public class CommitMessageBlock extends Composite {
|
public class CommitMessageBlock extends Composite {
|
||||||
interface Binder extends UiBinder<HTMLPanel, CommitMessageBlock> {
|
interface Binder extends UiBinder<HTMLPanel, CommitMessageBlock> {
|
||||||
@ -70,44 +61,11 @@ public class CommitMessageBlock extends Composite {
|
|||||||
|
|
||||||
public void display(String commitMessage,
|
public void display(String commitMessage,
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
CommentLinkProcessor commentLinkProcessor) {
|
||||||
display(null, null, null, false, commitMessage, commentLinkProcessor);
|
display(null, null, null, commitMessage, commentLinkProcessor);
|
||||||
}
|
|
||||||
|
|
||||||
private abstract class CommitMessageEditDialog
|
|
||||||
extends CommentedActionDialog<JavaScriptObject> {
|
|
||||||
private final String originalMessage;
|
|
||||||
public CommitMessageEditDialog(final String title, final String heading,
|
|
||||||
final String commitMessage, AsyncCallback<JavaScriptObject> callback) {
|
|
||||||
super(title, heading, callback);
|
|
||||||
originalMessage = commitMessage.trim();
|
|
||||||
message.setCharacterWidth(72);
|
|
||||||
message.setVisibleLines(20);
|
|
||||||
message.setText(originalMessage);
|
|
||||||
message.addStyleName(Gerrit.RESOURCES.css().changeScreenDescription());
|
|
||||||
sendButton.setEnabled(false);
|
|
||||||
|
|
||||||
new TextBoxChangeListener(message) {
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(String newText) {
|
|
||||||
// Trim the new text so we don't consider trailing
|
|
||||||
// newlines as changes
|
|
||||||
sendButton.setEnabled(!newText.trim().equals(originalMessage));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessageText() {
|
|
||||||
// As we rely on commit message lines ending in LF, we convert CRLF to
|
|
||||||
// LF. Additionally, the commit message should be trimmed to remove any
|
|
||||||
// excess newlines at the end, but we need to make sure it still has at
|
|
||||||
// least one trailing newline.
|
|
||||||
return message.getText().replaceAll("\r\n", "\n").trim() + '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(final PatchSet.Id patchSetId, final String revision,
|
public void display(final PatchSet.Id patchSetId, final String revision,
|
||||||
Boolean starred, Boolean canEditCommitMessage, final String commitMessage,
|
Boolean starred, final String commitMessage,
|
||||||
CommentLinkProcessor commentLinkProcessor) {
|
CommentLinkProcessor commentLinkProcessor) {
|
||||||
starPanel.clear();
|
starPanel.clear();
|
||||||
if (patchSetId != null && starred != null && Gerrit.isSignedIn()) {
|
if (patchSetId != null && starred != null && Gerrit.isSignedIn()) {
|
||||||
@ -127,37 +85,6 @@ public class CommitMessageBlock extends Composite {
|
|||||||
permalinkPanel.add(new ChangeLink(Util.C.changePermalink(), changeId));
|
permalinkPanel.add(new ChangeLink(Util.C.changePermalink(), changeId));
|
||||||
permalinkPanel.add(new CopyableLabel(ChangeLink.permalink(changeId),
|
permalinkPanel.add(new CopyableLabel(ChangeLink.permalink(changeId),
|
||||||
false));
|
false));
|
||||||
if (canEditCommitMessage) {
|
|
||||||
final Image edit = new Image(Gerrit.RESOURCES.edit());
|
|
||||||
edit.setTitle(Util.C.editCommitMessageToolTip());
|
|
||||||
edit.addStyleName(Gerrit.RESOURCES.css().link());
|
|
||||||
edit.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
new CommitMessageEditDialog(Util.C.titleEditCommitMessage(),
|
|
||||||
Util.C.headingEditCommitMessage(),
|
|
||||||
commitMessage,
|
|
||||||
new GerritCallback<JavaScriptObject>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(JavaScriptObject result) {}
|
|
||||||
}) {
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
ChangeApi.message(changeId.get(), revision, getMessageText(),
|
|
||||||
new GerritCallback<JavaScriptObject>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(JavaScriptObject msg) {
|
|
||||||
Gerrit.display(PageLinks.toChange(changeId));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
permalinkPanel.add(edit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] splitCommitMessage = commitMessage.split("\n", 2);
|
String[] splitCommitMessage = commitMessage.split("\n", 2);
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
// 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.changes.ChangeInfo.IncludedInInfo;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.common.data.IncludedInDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gwt.core.client.JsArrayString;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenHandler;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/** Displays a table of Branches and Tags containing the change record. */
|
|
||||||
public class IncludedInTable extends Composite implements
|
|
||||||
OpenHandler<DisclosurePanel> {
|
|
||||||
private final Grid table;
|
|
||||||
private final Change.Id changeId;
|
|
||||||
private boolean loaded = false;
|
|
||||||
|
|
||||||
public IncludedInTable(final Change.Id chId) {
|
|
||||||
changeId = chId;
|
|
||||||
table = new Grid(1, 1);
|
|
||||||
initWidget(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadTable(final IncludedInDetail detail) {
|
|
||||||
int row = 0;
|
|
||||||
table.resizeRows(detail.getBranches().size() + 1);
|
|
||||||
table.addStyleName(Gerrit.RESOURCES.css().changeTable());
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().dataHeader());
|
|
||||||
table.setText(row, 0, Util.C.includedInTableBranch());
|
|
||||||
|
|
||||||
for (final String branch : detail.getBranches()) {
|
|
||||||
fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataCell());
|
|
||||||
fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().leftMostCell());
|
|
||||||
table.setText(row, 0, branch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!detail.getTags().isEmpty()) {
|
|
||||||
table.resizeRows(table.getRowCount() + 2 + detail.getTags().size());
|
|
||||||
row++;
|
|
||||||
fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataHeader());
|
|
||||||
table.setText(row, 0, Util.C.includedInTableTag());
|
|
||||||
|
|
||||||
for (final String tag : detail.getTags()) {
|
|
||||||
fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataCell());
|
|
||||||
fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().leftMostCell());
|
|
||||||
table.setText(row, 0, tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table.setVisible(true);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(OpenEvent<DisclosurePanel> event) {
|
|
||||||
if (!loaded) {
|
|
||||||
ChangeApi.includedIn(changeId.get(),
|
|
||||||
new GerritCallback<IncludedInInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(IncludedInInfo r) {
|
|
||||||
IncludedInDetail result = new IncludedInDetail();
|
|
||||||
result.setBranches(toList(r.branches()));
|
|
||||||
result.setTags(toList(r.tags()));
|
|
||||||
loadTable(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> toList(JsArrayString in) {
|
|
||||||
List<String> r = new ArrayList<>();
|
|
||||||
if (in != null) {
|
|
||||||
for (int i = 0; i < in.length(); i++) {
|
|
||||||
r.add(in.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,736 +0,0 @@
|
|||||||
// Copyright (C) 2008 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.Dispatcher;
|
|
||||||
import com.google.gerrit.client.ErrorDialog;
|
|
||||||
import com.google.gerrit.client.FormatUtil;
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.GitwebLink;
|
|
||||||
import com.google.gerrit.client.change.DraftActions;
|
|
||||||
import com.google.gerrit.client.download.DownloadPanel;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.rpc.NativeString;
|
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
|
||||||
import com.google.gerrit.client.ui.AccountLinkPanel;
|
|
||||||
import com.google.gerrit.client.ui.ActionDialog;
|
|
||||||
import com.google.gerrit.client.ui.CherryPickDialog;
|
|
||||||
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
|
||||||
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
|
||||||
import com.google.gerrit.common.data.UiCommandDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
|
||||||
import com.google.gerrit.reviewdb.client.UserIdentity;
|
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenHandler;
|
|
||||||
import com.google.gwt.user.client.Window;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
|
||||||
import com.google.gwt.user.client.ui.Button;
|
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
import com.google.gwt.user.client.ui.Image;
|
|
||||||
import com.google.gwt.user.client.ui.InlineLabel;
|
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
|
|
||||||
implements OpenHandler<DisclosurePanel> {
|
|
||||||
private static final int R_AUTHOR = 0;
|
|
||||||
private static final int R_COMMITTER = 1;
|
|
||||||
private static final int R_PARENTS = 2;
|
|
||||||
private static final int R_DOWNLOAD = 3;
|
|
||||||
private static final int R_CNT = 4;
|
|
||||||
|
|
||||||
private final ChangeDetailCache detailCache;
|
|
||||||
private final ChangeDetail changeDetail;
|
|
||||||
private final PatchSet patchSet;
|
|
||||||
private final FlowPanel body;
|
|
||||||
|
|
||||||
private Grid infoTable;
|
|
||||||
private Panel actionsPanel;
|
|
||||||
private PatchTable patchTable;
|
|
||||||
private final Set<ClickHandler> registeredClickHandler = new HashSet<>();
|
|
||||||
|
|
||||||
private PatchSet.Id diffBaseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a closed complex disclosure panel for a patch set.
|
|
||||||
* The patch set details are loaded when the complex disclosure panel is opened.
|
|
||||||
*/
|
|
||||||
public PatchSetComplexDisclosurePanel(final PatchSet ps, boolean isOpen,
|
|
||||||
boolean hasDraftComments) {
|
|
||||||
super(Util.M.patchSetHeader(ps.getPatchSetId()), isOpen);
|
|
||||||
detailCache = ChangeCache.get(ps.getId().getParentKey()).getChangeDetailCache();
|
|
||||||
changeDetail = detailCache.get();
|
|
||||||
patchSet = ps;
|
|
||||||
|
|
||||||
body = new FlowPanel();
|
|
||||||
setContent(body);
|
|
||||||
|
|
||||||
if (hasDraftComments) {
|
|
||||||
final Image draftComments = new Image(Gerrit.RESOURCES.draftComments());
|
|
||||||
draftComments.setTitle(Util.C.patchSetWithDraftCommentsToolTip());
|
|
||||||
getHeader().add(draftComments);
|
|
||||||
}
|
|
||||||
|
|
||||||
final GitwebLink gw = Gerrit.getGitwebLink();
|
|
||||||
final InlineLabel revtxt = new InlineLabel(ps.getRevision().get() + " ");
|
|
||||||
revtxt.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
|
|
||||||
getHeader().add(revtxt);
|
|
||||||
if (gw != null && gw.canLink(ps)) {
|
|
||||||
final Anchor revlink =
|
|
||||||
new Anchor(gw.getLinkName(), false, gw.toRevision(changeDetail.getChange()
|
|
||||||
.getProject(), ps));
|
|
||||||
revlink.addStyleName(Gerrit.RESOURCES.css().patchSetLink());
|
|
||||||
getHeader().add(revlink);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ps.isDraft()) {
|
|
||||||
final InlineLabel draftLabel = new InlineLabel(Util.C.draftPatchSetLabel());
|
|
||||||
draftLabel.addStyleName(Gerrit.RESOURCES.css().patchSetRevision());
|
|
||||||
getHeader().add(draftLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isOpen) {
|
|
||||||
ensureLoaded(changeDetail.getCurrentPatchSetDetail());
|
|
||||||
} else {
|
|
||||||
addOpenHandler(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiffBaseId(PatchSet.Id diffBaseId) {
|
|
||||||
this.diffBaseId = diffBaseId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display the table showing the Author, Committer and Download links,
|
|
||||||
* followed by the action buttons.
|
|
||||||
*/
|
|
||||||
public void ensureLoaded(final PatchSetDetail detail) {
|
|
||||||
loadInfoTable(detail);
|
|
||||||
loadActionPanel(detail);
|
|
||||||
loadPatchTable(detail);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadInfoTable(final PatchSetDetail detail) {
|
|
||||||
infoTable = new Grid(R_CNT, 2);
|
|
||||||
infoTable.setStyleName(Gerrit.RESOURCES.css().infoBlock());
|
|
||||||
infoTable.addStyleName(Gerrit.RESOURCES.css().patchSetInfoBlock());
|
|
||||||
|
|
||||||
initRow(R_AUTHOR, Util.C.patchSetInfoAuthor());
|
|
||||||
initRow(R_COMMITTER, Util.C.patchSetInfoCommitter());
|
|
||||||
initRow(R_PARENTS, Util.C.patchSetInfoParents());
|
|
||||||
initRow(R_DOWNLOAD, Util.C.patchSetInfoDownload());
|
|
||||||
|
|
||||||
final CellFormatter itfmt = infoTable.getCellFormatter();
|
|
||||||
itfmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
|
|
||||||
itfmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
|
|
||||||
itfmt.addStyleName(R_CNT - 1, 0, Gerrit.RESOURCES.css().bottomheader());
|
|
||||||
itfmt.addStyleName(R_AUTHOR, 1, Gerrit.RESOURCES.css().useridentity());
|
|
||||||
itfmt.addStyleName(R_COMMITTER, 1, Gerrit.RESOURCES.css().useridentity());
|
|
||||||
itfmt.addStyleName(R_DOWNLOAD, 1, Gerrit.RESOURCES.css()
|
|
||||||
.downloadLinkListCell());
|
|
||||||
|
|
||||||
final PatchSetInfo info = detail.getInfo();
|
|
||||||
displayUserIdentity(R_AUTHOR, info.getAuthor());
|
|
||||||
displayUserIdentity(R_COMMITTER, info.getCommitter());
|
|
||||||
displayParents(info.getParents());
|
|
||||||
displayDownload();
|
|
||||||
|
|
||||||
body.add(infoTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadActionPanel(final PatchSetDetail detail) {
|
|
||||||
if (!patchSet.getId().equals(diffBaseId)) {
|
|
||||||
actionsPanel = new FlowPanel();
|
|
||||||
actionsPanel.setStyleName(Gerrit.RESOURCES.css().patchSetActions());
|
|
||||||
actionsPanel.setVisible(true);
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
if (changeDetail.canEdit()) {
|
|
||||||
populateReviewAction();
|
|
||||||
if (changeDetail.isCurrentPatchSet(detail)) {
|
|
||||||
populateActions(detail);
|
|
||||||
}
|
|
||||||
populateCommands(detail);
|
|
||||||
}
|
|
||||||
if (detail.getPatchSet().isDraft()) {
|
|
||||||
if (changeDetail.canPublish()) {
|
|
||||||
populatePublishAction();
|
|
||||||
}
|
|
||||||
if (changeDetail.canDeleteDraft()
|
|
||||||
&& changeDetail.getPatchSets().size() > 1) {
|
|
||||||
populateDeleteDraftPatchSetAction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
body.add(actionsPanel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadPatchTable(final PatchSetDetail detail) {
|
|
||||||
if (!patchSet.getId().equals(diffBaseId)) {
|
|
||||||
patchTable = new PatchTable();
|
|
||||||
patchTable.setSavePointerId("PatchTable " + patchSet.getId());
|
|
||||||
patchTable.display(diffBaseId, detail);
|
|
||||||
for (ClickHandler clickHandler : registeredClickHandler) {
|
|
||||||
patchTable.addClickHandler(clickHandler);
|
|
||||||
}
|
|
||||||
patchTable.setRegisterKeys(true);
|
|
||||||
setActive(true);
|
|
||||||
body.add(patchTable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ChangeDownloadPanel extends DownloadPanel {
|
|
||||||
public ChangeDownloadPanel(String project, String ref, boolean allowAnonymous) {
|
|
||||||
super(project, ref, allowAnonymous);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void populateDownloadCommandLinks() {
|
|
||||||
// This site prefers usage of the 'repo' tool, so suggest
|
|
||||||
// that for easy fetch.
|
|
||||||
//
|
|
||||||
if (allowedSchemes.contains(DownloadScheme.REPO_DOWNLOAD)) {
|
|
||||||
commands.add(cmdLinkfactory.new RepoCommandLink(projectName,
|
|
||||||
changeDetail.getChange().getChangeId() + "/"
|
|
||||||
+ patchSet.getPatchSetId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!urls.isEmpty()) {
|
|
||||||
if (allowedCommands.contains(DownloadCommand.CHECKOUT)
|
|
||||||
|| allowedCommands.contains(DownloadCommand.DEFAULT_DOWNLOADS)) {
|
|
||||||
commands.add(cmdLinkfactory.new CheckoutCommandLink());
|
|
||||||
}
|
|
||||||
if (allowedCommands.contains(DownloadCommand.PULL)
|
|
||||||
|| allowedCommands.contains(DownloadCommand.DEFAULT_DOWNLOADS)) {
|
|
||||||
commands.add(cmdLinkfactory.new PullCommandLink());
|
|
||||||
}
|
|
||||||
if (allowedCommands.contains(DownloadCommand.CHERRY_PICK)
|
|
||||||
|| allowedCommands.contains(DownloadCommand.DEFAULT_DOWNLOADS)) {
|
|
||||||
commands.add(cmdLinkfactory.new CherryPickCommandLink());
|
|
||||||
}
|
|
||||||
if (allowedCommands.contains(DownloadCommand.FORMAT_PATCH)
|
|
||||||
|| allowedCommands.contains(DownloadCommand.DEFAULT_DOWNLOADS)) {
|
|
||||||
commands.add(cmdLinkfactory.new FormatPatchCommandLink());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayDownload() {
|
|
||||||
ChangeDownloadPanel dp = new ChangeDownloadPanel(
|
|
||||||
changeDetail.getChange().getProject().get(),
|
|
||||||
patchSet.getRefName(),
|
|
||||||
changeDetail.isAllowsAnonymous());
|
|
||||||
|
|
||||||
infoTable.setWidget(R_DOWNLOAD, 1, dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayUserIdentity(final int row, final UserIdentity who) {
|
|
||||||
if (who == null) {
|
|
||||||
infoTable.clearCell(row, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final FlowPanel fp = new FlowPanel();
|
|
||||||
fp.setStyleName(Gerrit.RESOURCES.css().patchSetUserIdentity());
|
|
||||||
if (who.getName() != null) {
|
|
||||||
if (who.getAccount() != null) {
|
|
||||||
fp.add(new AccountLinkPanel(who));
|
|
||||||
} else {
|
|
||||||
final InlineLabel lbl = new InlineLabel(who.getName());
|
|
||||||
lbl.setStyleName(Gerrit.RESOURCES.css().accountName());
|
|
||||||
fp.add(lbl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (who.getEmail() != null) {
|
|
||||||
fp.add(new InlineLabel("<" + who.getEmail() + ">"));
|
|
||||||
}
|
|
||||||
if (who.getDate() != null) {
|
|
||||||
fp.add(new InlineLabel(FormatUtil.mediumFormat(who.getDate())));
|
|
||||||
}
|
|
||||||
infoTable.setWidget(row, 1, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayParents(final List<PatchSetInfo.ParentInfo> parents) {
|
|
||||||
if (parents.size() == 0) {
|
|
||||||
infoTable.setWidget(R_PARENTS, 1, new InlineLabel(Util.C.initialCommit()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Grid parentsTable = new Grid(parents.size(), 2);
|
|
||||||
|
|
||||||
parentsTable.setStyleName(Gerrit.RESOURCES.css().parentsTable());
|
|
||||||
parentsTable.addStyleName(Gerrit.RESOURCES.css().noborder());
|
|
||||||
final CellFormatter ptfmt = parentsTable.getCellFormatter();
|
|
||||||
int row = 0;
|
|
||||||
for (PatchSetInfo.ParentInfo parent : parents) {
|
|
||||||
parentsTable.setWidget(row, 0, new InlineLabel(parent.id.get()));
|
|
||||||
ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().noborder());
|
|
||||||
ptfmt.addStyleName(row, 0, Gerrit.RESOURCES.css().monospace());
|
|
||||||
parentsTable.setWidget(row, 1,
|
|
||||||
new InlineLabel(Util.cropSubject(parent.shortMessage)));
|
|
||||||
ptfmt.addStyleName(row, 1, Gerrit.RESOURCES.css().noborder());
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
infoTable.setWidget(R_PARENTS, 1, parentsTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateActions(final PatchSetDetail detail) {
|
|
||||||
final boolean isOpen = changeDetail.getChange().getStatus().isOpen();
|
|
||||||
|
|
||||||
if (isOpen && changeDetail.canSubmit()) {
|
|
||||||
final Button b =
|
|
||||||
new Button(Util.M
|
|
||||||
.submitPatchSet(detail.getPatchSet().getPatchSetId()));
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
ChangeApi.submit(
|
|
||||||
patchSet.getId().getParentKey().get(),
|
|
||||||
patchSet.getRevision().get(),
|
|
||||||
new GerritCallback<SubmitInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(SubmitInfo result) {
|
|
||||||
redisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable err) {
|
|
||||||
if (SubmitFailureDialog.isConflict(err)) {
|
|
||||||
new SubmitFailureDialog(err.getMessage()).center();
|
|
||||||
redisplay();
|
|
||||||
} else {
|
|
||||||
b.setEnabled(true);
|
|
||||||
super.onFailure(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void redisplay() {
|
|
||||||
Gerrit.display(
|
|
||||||
PageLinks.toChange(patchSet.getId().getParentKey()),
|
|
||||||
new ChangeScreen(patchSet.getId().getParentKey()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.canRevert()) {
|
|
||||||
final Button b = new Button(Util.C.buttonRevertChangeBegin());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
new ActionDialog(b, true, Util.C.revertChangeTitle(),
|
|
||||||
Util.C.headingRevertMessage()) {
|
|
||||||
{
|
|
||||||
sendButton.setText(Util.C.buttonRevertChangeSend());
|
|
||||||
message.setText(Util.M.revertChangeDefaultMessage(
|
|
||||||
detail.getInfo().getSubject(),
|
|
||||||
detail.getPatchSet().getRevision().get())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
ChangeApi.revert(changeDetail.getChange().getChangeId(),
|
|
||||||
getMessageText(), new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
sent = true;
|
|
||||||
Gerrit.display(PageLinks.toChange(new Change.Id(result
|
|
||||||
._number())));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.canCherryPick()) {
|
|
||||||
final Button b = new Button(Util.C.buttonCherryPickChangeBegin());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
new CherryPickDialog(b, changeDetail.getChange().getProject()) {
|
|
||||||
{
|
|
||||||
sendButton.setText(Util.C.buttonCherryPickChangeSend());
|
|
||||||
if (changeDetail.getChange().getStatus().isClosed()) {
|
|
||||||
message.setText(Util.M.cherryPickedChangeDefaultMessage(
|
|
||||||
detail.getInfo().getMessage().trim(),
|
|
||||||
detail.getPatchSet().getRevision().get()));
|
|
||||||
} else {
|
|
||||||
message.setText(detail.getInfo().getMessage().trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
ChangeApi.cherrypick(changeDetail.getChange().getChangeId(),
|
|
||||||
patchSet.getRevision().get(),
|
|
||||||
getDestinationBranch(),
|
|
||||||
getMessageText(),
|
|
||||||
new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
sent = true;
|
|
||||||
Gerrit.display(PageLinks.toChange(new Change.Id(result
|
|
||||||
._number())));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.canAbandon()) {
|
|
||||||
final Button b = new Button(Util.C.buttonAbandonChangeBegin());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
new ActionDialog(b, false, Util.C.abandonChangeTitle(),
|
|
||||||
Util.C.headingAbandonMessage()) {
|
|
||||||
{
|
|
||||||
sendButton.setText(Util.C.buttonAbandonChangeSend());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
// TODO: once the other users of ActionDialog have converted to
|
|
||||||
// REST APIs, we can use createCallback() rather than providing
|
|
||||||
// them directly.
|
|
||||||
ChangeApi.abandon(changeDetail.getChange().getChangeId(),
|
|
||||||
getMessageText(), new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
sent = true;
|
|
||||||
Gerrit.display(PageLinks.toChange(new Change.Id(result
|
|
||||||
._number())));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.getChange().getStatus() == Change.Status.DRAFT
|
|
||||||
&& changeDetail.canDeleteDraft()) {
|
|
||||||
final Button b = new Button(Util.C.buttonDeleteDraftChange());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
ChangeApi.deleteChange(patchSet.getId().getParentKey().get(),
|
|
||||||
new GerritCallback<JavaScriptObject>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(JavaScriptObject result) {
|
|
||||||
Gerrit.display(PageLinks.MINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable err) {
|
|
||||||
if (SubmitFailureDialog.isConflict(err)) {
|
|
||||||
new SubmitFailureDialog(err.getMessage()).center();
|
|
||||||
Gerrit.display(PageLinks.MINE);
|
|
||||||
} else {
|
|
||||||
b.setEnabled(true);
|
|
||||||
super.onFailure(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.canRestore()) {
|
|
||||||
final Button b = new Button(Util.C.buttonRestoreChangeBegin());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
new ActionDialog(b, false, Util.C.restoreChangeTitle(),
|
|
||||||
Util.C.headingRestoreMessage()) {
|
|
||||||
{
|
|
||||||
sendButton.setText(Util.C.buttonRestoreChangeSend());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSend() {
|
|
||||||
ChangeApi.restore(changeDetail.getChange().getChangeId(),
|
|
||||||
getMessageText(), new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
sent = true;
|
|
||||||
Gerrit.display(PageLinks.toChange(new Change.Id(result
|
|
||||||
._number())));
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}.center();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeDetail.canRebase()) {
|
|
||||||
final Button b = new Button(Util.C.buttonRebaseChange());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
final Change.Id id = patchSet.getId().getParentKey();
|
|
||||||
ChangeApi.rebase(id.get(), patchSet.getRevision().get(),
|
|
||||||
new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
Gerrit.display(PageLinks.toChange(id));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateCommands(final PatchSetDetail detail) {
|
|
||||||
for (final UiCommandDetail cmd : detail.getCommands()) {
|
|
||||||
final Button b = new Button();
|
|
||||||
b.setText(cmd.label);
|
|
||||||
b.setEnabled(cmd.enabled);
|
|
||||||
b.setTitle(cmd.title);
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
AsyncCallback<NativeString> cb =
|
|
||||||
new AsyncCallback<NativeString>() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
b.setEnabled(true);
|
|
||||||
new ErrorDialog(caught).center();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeString msg) {
|
|
||||||
b.setEnabled(true);
|
|
||||||
if (msg != null && !msg.asString().isEmpty()) {
|
|
||||||
Window.alert(msg.asString());
|
|
||||||
}
|
|
||||||
Gerrit.display(PageLinks.toChange(patchSet.getId()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
RestApi api = ChangeApi.revision(patchSet.getId()).view(cmd.id);
|
|
||||||
if ("PUT".equalsIgnoreCase(cmd.method)) {
|
|
||||||
api.put(JavaScriptObject.createObject(), cb);
|
|
||||||
} else if ("DELETE".equalsIgnoreCase(cmd.method)) {
|
|
||||||
api.delete(cb);
|
|
||||||
} else {
|
|
||||||
api.post(JavaScriptObject.createObject(), cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateReviewAction() {
|
|
||||||
final Button b = new Button(Util.C.buttonReview());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
Gerrit.display(Dispatcher.toPublish(patchSet.getId()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populatePublishAction() {
|
|
||||||
final Button b = new Button(Util.C.buttonPublishPatchSet());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
final Change.Id id = patchSet.getId().getParentKey();
|
|
||||||
ChangeApi.publish(id.get(),
|
|
||||||
patchSet.getRevision().get(),
|
|
||||||
DraftActions.cs(id));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateDeleteDraftPatchSetAction() {
|
|
||||||
final Button b = new Button(Util.C.buttonDeleteDraftPatchSet());
|
|
||||||
b.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
b.setEnabled(false);
|
|
||||||
final Change.Id id = patchSet.getId().getParentKey();
|
|
||||||
ChangeApi.deleteRevision(id.get(),
|
|
||||||
patchSet.getRevision().get(),
|
|
||||||
DraftActions.cs(id));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
actionsPanel.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
if (patchSet.getId().equals(diffBaseId)) {
|
|
||||||
if (patchTable != null) {
|
|
||||||
patchTable.setVisible(false);
|
|
||||||
}
|
|
||||||
if (actionsPanel != null) {
|
|
||||||
actionsPanel.setVisible(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (patchTable != null) {
|
|
||||||
if (patchTable.getBase() == null && diffBaseId == null
|
|
||||||
|| patchTable.getBase() != null
|
|
||||||
&& patchTable.getBase().equals(diffBaseId)) {
|
|
||||||
actionsPanel.setVisible(true);
|
|
||||||
patchTable.setVisible(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountDiffPreference diffPrefs;
|
|
||||||
if (patchTable == null) {
|
|
||||||
diffPrefs = new ListenableAccountDiffPreference().get();
|
|
||||||
} else {
|
|
||||||
diffPrefs = patchTable.getPreferences().get();
|
|
||||||
patchTable.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
|
|
||||||
new GerritCallback<PatchSetDetail>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(PatchSetDetail result) {
|
|
||||||
if (actionsPanel != null) {
|
|
||||||
actionsPanel.setVisible(true);
|
|
||||||
} else {
|
|
||||||
loadActionPanel(result);
|
|
||||||
}
|
|
||||||
loadPatchTable(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(final OpenEvent<DisclosurePanel> event) {
|
|
||||||
if (infoTable == null) {
|
|
||||||
AccountDiffPreference diffPrefs;
|
|
||||||
if (diffBaseId == null) {
|
|
||||||
diffPrefs = null;
|
|
||||||
} else {
|
|
||||||
diffPrefs = new ListenableAccountDiffPreference().get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Util.DETAIL_SVC.patchSetDetail2(diffBaseId, patchSet.getId(), diffPrefs,
|
|
||||||
new GerritCallback<PatchSetDetail>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(final PatchSetDetail result) {
|
|
||||||
loadInfoTable(result);
|
|
||||||
loadActionPanel(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initRow(final int row, final String name) {
|
|
||||||
infoTable.setText(row, 0, name);
|
|
||||||
infoTable.getCellFormatter().addStyleName(row, 0,
|
|
||||||
Gerrit.RESOURCES.css().header());
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatchSet getPatchSet() {
|
|
||||||
return patchSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a click handler to the patch table.
|
|
||||||
* If the patch table is not yet initialized it is guaranteed that the click handler
|
|
||||||
* is added to the patch table after initialization.
|
|
||||||
*/
|
|
||||||
public void addClickHandler(final ClickHandler clickHandler) {
|
|
||||||
registeredClickHandler.add(clickHandler);
|
|
||||||
if (patchTable != null) {
|
|
||||||
patchTable.addClickHandler(clickHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Activates / Deactivates the key navigation and the highlighting of the current row for the patch table */
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
if (patchTable != null) {
|
|
||||||
patchTable.setActive(active);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,272 +0,0 @@
|
|||||||
// 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.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.OpenHandler;
|
|
||||||
import com.google.gwt.event.shared.HandlerRegistration;
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommand;
|
|
||||||
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Composite that displays the patch sets of a change. This composite ensures
|
|
||||||
* that keyboard navigation to each changed file in all patch sets is possible.
|
|
||||||
*/
|
|
||||||
public class PatchSetsBlock extends Composite {
|
|
||||||
private final Map<PatchSet.Id, PatchSetComplexDisclosurePanel> patchSetPanels =
|
|
||||||
new HashMap<>();
|
|
||||||
|
|
||||||
private final FlowPanel body;
|
|
||||||
private HandlerRegistration regNavigation;
|
|
||||||
|
|
||||||
private List<PatchSetComplexDisclosurePanel> patchSetPanelsList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the patch set id of the patch set for which is the keyboard navigation is
|
|
||||||
* currently enabled
|
|
||||||
*/
|
|
||||||
private PatchSet.Id activePatchSetId;
|
|
||||||
|
|
||||||
/** the patch set id of the current (latest) patch set */
|
|
||||||
private PatchSet.Id currentPatchSetId;
|
|
||||||
|
|
||||||
/** Patch sets on this change, in order. */
|
|
||||||
private List<PatchSet> patchSets;
|
|
||||||
|
|
||||||
PatchSetsBlock() {
|
|
||||||
body = new FlowPanel();
|
|
||||||
initWidget(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Adds UI elements for each patch set of the given change to this composite. */
|
|
||||||
public void display(final ChangeDetail detail, final PatchSet.Id diffBaseId) {
|
|
||||||
clear();
|
|
||||||
|
|
||||||
final PatchSet currps = detail.getCurrentPatchSet();
|
|
||||||
currentPatchSetId = currps.getId();
|
|
||||||
patchSets = detail.getPatchSets();
|
|
||||||
|
|
||||||
if (Gerrit.isSignedIn()) {
|
|
||||||
final AccountGeneralPreferences p =
|
|
||||||
Gerrit.getUserAccount().getGeneralPreferences();
|
|
||||||
if (p.isReversePatchSetOrder()) {
|
|
||||||
Collections.reverse(patchSets);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
patchSetPanelsList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (final PatchSet ps : patchSets) {
|
|
||||||
final PatchSetComplexDisclosurePanel p =
|
|
||||||
new PatchSetComplexDisclosurePanel(ps, ps == currps,
|
|
||||||
detail.hasDraftComments(ps.getId()));
|
|
||||||
if (diffBaseId != null) {
|
|
||||||
p.setDiffBaseId(diffBaseId);
|
|
||||||
if (ps == currps) {
|
|
||||||
p.refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add(p);
|
|
||||||
patchSetPanelsList.add(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clear() {
|
|
||||||
setRegisterKeys(false);
|
|
||||||
body.clear();
|
|
||||||
patchSetPanels.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh(final PatchSet.Id diffBaseId) {
|
|
||||||
if (patchSetPanelsList != null) {
|
|
||||||
for (final PatchSetComplexDisclosurePanel p : patchSetPanelsList) {
|
|
||||||
p.setDiffBaseId(diffBaseId);
|
|
||||||
if (p.isOpen()) {
|
|
||||||
p.refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the given patch set panel to this composite and ensures that handler
|
|
||||||
* to activate / deactivate keyboard navigation for the patch set panel are
|
|
||||||
* registered.
|
|
||||||
*/
|
|
||||||
private void add(final PatchSetComplexDisclosurePanel patchSetPanel) {
|
|
||||||
body.add(patchSetPanel);
|
|
||||||
|
|
||||||
final PatchSet.Id id = patchSetPanel.getPatchSet().getId();
|
|
||||||
ActivationHandler activationHandler = new ActivationHandler(id);
|
|
||||||
patchSetPanel.addOpenHandler(activationHandler);
|
|
||||||
patchSetPanel.addClickHandler(activationHandler);
|
|
||||||
patchSetPanels.put(id, patchSetPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegisterKeys(final boolean on) {
|
|
||||||
if (on) {
|
|
||||||
KeyCommandSet keysNavigation =
|
|
||||||
new KeyCommandSet(Gerrit.C.sectionNavigation());
|
|
||||||
keysNavigation.add(new PreviousPatchSetKeyCommand(0, 'p', Util.C
|
|
||||||
.previousPatchSet()));
|
|
||||||
keysNavigation.add(new NextPatchSetKeyCommand(0, 'n', Util.C
|
|
||||||
.nextPatchSet()));
|
|
||||||
regNavigation = GlobalKey.add(this, keysNavigation);
|
|
||||||
if (activePatchSetId != null) {
|
|
||||||
activate(activePatchSetId);
|
|
||||||
} else {
|
|
||||||
activate(currentPatchSetId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (regNavigation != null) {
|
|
||||||
regNavigation.removeHandler();
|
|
||||||
regNavigation = null;
|
|
||||||
}
|
|
||||||
deactivate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onUnload() {
|
|
||||||
setRegisterKeys(false);
|
|
||||||
super.onUnload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activates keyboard navigation for the patch set panel that displays the
|
|
||||||
* patch set with the given patch set id.
|
|
||||||
* The keyboard navigation for the previously active patch set panel is
|
|
||||||
* automatically deactivated.
|
|
||||||
* This method also ensures that the current row is only highlighted in the
|
|
||||||
* table of the active patch set panel.
|
|
||||||
*/
|
|
||||||
public void activate(final PatchSet.Id patchSetId) {
|
|
||||||
if (indexOf(patchSetId) != -1) {
|
|
||||||
if (!patchSetId.equals(activePatchSetId)) {
|
|
||||||
deactivate();
|
|
||||||
PatchSetComplexDisclosurePanel patchSetPanel =
|
|
||||||
patchSetPanels.get(patchSetId);
|
|
||||||
patchSetPanel.setActive(true);
|
|
||||||
patchSetPanel.setOpen(true);
|
|
||||||
activePatchSetId = patchSetId;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Gerrit.display(PageLinks.toChange(patchSetId.getParentKey()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Deactivates the keyboard navigation for the currently active patch set panel. */
|
|
||||||
private void deactivate() {
|
|
||||||
if (activePatchSetId != null) {
|
|
||||||
PatchSetComplexDisclosurePanel patchSetPanel =
|
|
||||||
patchSetPanels.get(activePatchSetId);
|
|
||||||
patchSetPanel.setActive(false);
|
|
||||||
activePatchSetId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatchSet getCurrentPatchSet() {
|
|
||||||
PatchSetComplexDisclosurePanel patchSetPanel =
|
|
||||||
patchSetPanels.get(currentPatchSetId);
|
|
||||||
if (patchSetPanel != null) {
|
|
||||||
return patchSetPanel.getPatchSet();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int indexOf(PatchSet.Id id) {
|
|
||||||
for (int i = 0; i < patchSets.size(); i++) {
|
|
||||||
if (patchSets.get(i).getId().equals(id)) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActivationHandler implements OpenHandler<DisclosurePanel>,
|
|
||||||
ClickHandler {
|
|
||||||
|
|
||||||
private final PatchSet.Id patchSetId;
|
|
||||||
|
|
||||||
ActivationHandler(PatchSet.Id patchSetId) {
|
|
||||||
this.patchSetId = patchSetId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(OpenEvent<DisclosurePanel> event) {
|
|
||||||
// when a patch set panel is opened by the user
|
|
||||||
// it should automatically become active
|
|
||||||
PatchSetComplexDisclosurePanel patchSetPanel =
|
|
||||||
patchSetPanels.get(patchSetId);
|
|
||||||
patchSetPanel.refresh();
|
|
||||||
activate(patchSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
// when a user clicks on a patch table the corresponding
|
|
||||||
// patch set panel should automatically become active
|
|
||||||
activate(patchSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PreviousPatchSetKeyCommand extends KeyCommand {
|
|
||||||
public PreviousPatchSetKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
int index = indexOf(activePatchSetId) - 1;
|
|
||||||
if (0 <= index) {
|
|
||||||
activate(patchSets.get(index).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NextPatchSetKeyCommand extends KeyCommand {
|
|
||||||
public NextPatchSetKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
int index = indexOf(activePatchSetId) + 1;
|
|
||||||
if (index < patchSets.size()) {
|
|
||||||
activate(patchSets.get(index).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,6 @@ package com.google.gerrit.client.changes;
|
|||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
import com.google.gerrit.client.Dispatcher;
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
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.ListenableAccountDiffPreference;
|
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
|
||||||
import com.google.gerrit.client.ui.NavigationTable;
|
import com.google.gerrit.client.ui.NavigationTable;
|
||||||
@ -213,46 +212,42 @@ public class PatchTable extends Composite {
|
|||||||
/**
|
/**
|
||||||
* @return a link to the previous file in this patch set, or null.
|
* @return a link to the previous file in this patch set, or null.
|
||||||
*/
|
*/
|
||||||
public InlineHyperlink getPreviousPatchLink(int index,
|
public InlineHyperlink getPreviousPatchLink(int index) {
|
||||||
PatchScreen.Type patchType) {
|
|
||||||
int previousPatchIndex = getPreviousPatch(index, PREFERENCE_VALIDATOR);
|
int previousPatchIndex = getPreviousPatch(index, PREFERENCE_VALIDATOR);
|
||||||
if (previousPatchIndex < 0) {
|
if (previousPatchIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createLink(previousPatchIndex, patchType,
|
return createLink(previousPatchIndex,
|
||||||
SafeHtml.asis(Util.C.prevPatchLinkIcon()), null);
|
SafeHtml.asis(Util.C.prevPatchLinkIcon()), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a link to the next file in this patch set, or null.
|
* @return a link to the next file in this patch set, or null.
|
||||||
*/
|
*/
|
||||||
public InlineHyperlink getNextPatchLink(int index, PatchScreen.Type patchType) {
|
public InlineHyperlink getNextPatchLink(int index) {
|
||||||
int nextPatchIndex = getNextPatch(index, false, PREFERENCE_VALIDATOR);
|
int nextPatchIndex = getNextPatch(index, false, PREFERENCE_VALIDATOR);
|
||||||
if (nextPatchIndex < 0) {
|
if (nextPatchIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return createLink(nextPatchIndex, patchType, null,
|
return createLink(nextPatchIndex, null,
|
||||||
SafeHtml.asis(Util.C.nextPatchLinkIcon()));
|
SafeHtml.asis(Util.C.nextPatchLinkIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a link to the the given patch.
|
* @return a link to the the given patch.
|
||||||
* @param index The patch to link to
|
* @param index The patch to link to
|
||||||
* @param screenType The screen type of patch display
|
|
||||||
* @param before A string to display at the beginning of the href text
|
* @param before A string to display at the beginning of the href text
|
||||||
* @param after A string to display at the end of the href text
|
* @param after A string to display at the end of the href text
|
||||||
*/
|
*/
|
||||||
public PatchLink createLink(int index, PatchScreen.Type screenType,
|
public PatchLink createLink(int index, SafeHtml before, SafeHtml after) {
|
||||||
SafeHtml before, SafeHtml after) {
|
|
||||||
Patch patch = patchList.get(index);
|
Patch patch = patchList.get(index);
|
||||||
|
|
||||||
Patch.Key thisKey = patch.getKey();
|
Patch.Key thisKey = patch.getKey();
|
||||||
PatchLink link;
|
PatchLink link;
|
||||||
|
|
||||||
if (isUnifiedPatchLink(patch, screenType)) {
|
if (isUnifiedPatchLink(patch)) {
|
||||||
link = new PatchLink.Unified("", base, thisKey, index, detail, this);
|
link = new PatchLink.Unified("", base, thisKey);
|
||||||
} else {
|
} else {
|
||||||
link = new PatchLink.SideBySide("", base, thisKey, index, detail, this);
|
link = new PatchLink.SideBySide("", base, thisKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeHtmlBuilder text = new SafeHtmlBuilder();
|
SafeHtmlBuilder text = new SafeHtmlBuilder();
|
||||||
@ -263,15 +258,10 @@ public class PatchTable extends Composite {
|
|||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUnifiedPatchLink(final Patch patch,
|
private static boolean isUnifiedPatchLink(final Patch patch) {
|
||||||
final PatchScreen.Type screenType) {
|
return (patch.getPatchType().equals(PatchType.BINARY)
|
||||||
if (Dispatcher.isChangeScreen2()) {
|
|| Gerrit.getUserAccount().getGeneralPreferences().getDiffView()
|
||||||
return (patch.getPatchType().equals(PatchType.BINARY)
|
.equals(DiffView.UNIFIED_DIFF));
|
||||||
|| (Gerrit.isSignedIn()
|
|
||||||
&& Gerrit.getUserAccount().getGeneralPreferences().getDiffView()
|
|
||||||
.equals(DiffView.UNIFIED_DIFF)));
|
|
||||||
}
|
|
||||||
return screenType == PatchScreen.Type.UNIFIED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getFileNameOnly(Patch patch) {
|
private static String getFileNameOnly(Patch patch) {
|
||||||
@ -403,9 +393,8 @@ public class PatchTable extends Composite {
|
|||||||
Patch patch = PatchTable.this.patchList.get(row - 1);
|
Patch patch = PatchTable.this.patchList.get(row - 1);
|
||||||
setRowItem(row, patch);
|
setRowItem(row, patch);
|
||||||
|
|
||||||
Widget nameCol;
|
Widget nameCol = new PatchLink.SideBySide(getDisplayFileName(patch), base,
|
||||||
nameCol = new PatchLink.SideBySide(getDisplayFileName(patch), base,
|
patch.getKey());
|
||||||
patch.getKey(), row - 1, detail, PatchTable.this);
|
|
||||||
|
|
||||||
if (patch.getSourceFileName() != null) {
|
if (patch.getSourceFileName() != null) {
|
||||||
final String text;
|
final String text;
|
||||||
@ -427,14 +416,12 @@ public class PatchTable extends Composite {
|
|||||||
|
|
||||||
int C_UNIFIED = C_SIDEBYSIDE + 1;
|
int C_UNIFIED = C_SIDEBYSIDE + 1;
|
||||||
|
|
||||||
PatchLink sideBySide =
|
PatchLink sideBySide = new PatchLink.SideBySide(
|
||||||
new PatchLink.SideBySide(Util.C.patchTableDiffSideBySide(), base,
|
Util.C.patchTableDiffSideBySide(), base, patch.getKey());
|
||||||
patch.getKey(), row - 1, detail, PatchTable.this);
|
|
||||||
sideBySide.setStyleName("gwt-Anchor");
|
sideBySide.setStyleName("gwt-Anchor");
|
||||||
|
|
||||||
PatchLink unified =
|
PatchLink unified = new PatchLink.Unified(Util.C.patchTableDiffUnified(),
|
||||||
new PatchLink.Unified(Util.C.patchTableDiffUnified(), base,
|
base, patch.getKey());
|
||||||
patch.getKey(), row - 1, detail, PatchTable.this);
|
|
||||||
unified.setStyleName("gwt-Anchor");
|
unified.setStyleName("gwt-Anchor");
|
||||||
|
|
||||||
table.setWidget(row, C_SIDEBYSIDE, sideBySide);
|
table.setWidget(row, C_SIDEBYSIDE, sideBySide);
|
||||||
@ -447,7 +434,7 @@ public class PatchTable extends Composite {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
for (Patch p : detail.getPatches()) {
|
for (Patch p : detail.getPatches()) {
|
||||||
openWindow(Dispatcher.toPatchSideBySide(base, p.getKey()));
|
openWindow(Dispatcher.toSideBySide(base, p.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -459,7 +446,7 @@ public class PatchTable extends Composite {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
for (Patch p : detail.getPatches()) {
|
for (Patch p : detail.getPatches()) {
|
||||||
openWindow(Dispatcher.toPatchUnified(base, p.getKey()));
|
openWindow(Dispatcher.toUnified(base, p.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,526 +0,0 @@
|
|||||||
// Copyright (C) 2009 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.changes.ChangeInfo.ApprovalInfo;
|
|
||||||
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;
|
|
||||||
import com.google.gerrit.client.patches.AbstractPatchContentTable;
|
|
||||||
import com.google.gerrit.client.patches.CommentEditorContainer;
|
|
||||||
import com.google.gerrit.client.patches.CommentEditorPanel;
|
|
||||||
import com.google.gerrit.client.projects.ConfigInfoCache;
|
|
||||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gerrit.client.rpc.NativeMap;
|
|
||||||
import com.google.gerrit.client.rpc.NativeString;
|
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
|
||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
|
||||||
import com.google.gerrit.client.ui.AccountScreen;
|
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
|
||||||
import com.google.gerrit.client.ui.PatchLink;
|
|
||||||
import com.google.gerrit.client.ui.SmallHeading;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
|
||||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
|
||||||
import com.google.gerrit.extensions.common.SubmitType;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gwt.core.client.JsArray;
|
|
||||||
import com.google.gwt.core.client.JsArrayString;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.Button;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.FormPanel;
|
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
|
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
|
||||||
import com.google.gwt.user.client.ui.RadioButton;
|
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
import com.google.gwtexpui.globalkey.client.NpTextArea;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
|
||||||
import com.google.gwtjsonrpc.common.VoidResult;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class PublishCommentScreen extends AccountScreen implements
|
|
||||||
ClickHandler, CommentEditorContainer {
|
|
||||||
private static SavedState lastState;
|
|
||||||
|
|
||||||
private final PatchSet.Id patchSetId;
|
|
||||||
private Collection<ValueRadioButton> approvalButtons;
|
|
||||||
private ChangeDescriptionBlock descBlock;
|
|
||||||
private ApprovalTable approvals;
|
|
||||||
private Panel approvalPanel;
|
|
||||||
private NpTextArea message;
|
|
||||||
private FlowPanel draftsPanel;
|
|
||||||
private Button send;
|
|
||||||
private Button cancel;
|
|
||||||
private boolean saveStateOnUnload = true;
|
|
||||||
private List<CommentEditorPanel> commentEditors;
|
|
||||||
private ChangeInfo change;
|
|
||||||
private ChangeInfo detail;
|
|
||||||
private NativeMap<JsArray<CommentInfo>> drafts;
|
|
||||||
private SubmitTypeRecord submitTypeRecord;
|
|
||||||
private CommentLinkProcessor commentLinkProcessor;
|
|
||||||
|
|
||||||
public PublishCommentScreen(final PatchSet.Id psi) {
|
|
||||||
patchSetId = psi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onInitUI() {
|
|
||||||
super.onInitUI();
|
|
||||||
addStyleName(Gerrit.RESOURCES.css().publishCommentsScreen());
|
|
||||||
|
|
||||||
approvalButtons = new ArrayList<>();
|
|
||||||
descBlock = new ChangeDescriptionBlock(null);
|
|
||||||
add(descBlock);
|
|
||||||
|
|
||||||
approvals = new ApprovalTable();
|
|
||||||
add(approvals);
|
|
||||||
|
|
||||||
final FormPanel form = new FormPanel();
|
|
||||||
final FlowPanel body = new FlowPanel();
|
|
||||||
form.setWidget(body);
|
|
||||||
form.addSubmitHandler(new FormPanel.SubmitHandler() {
|
|
||||||
@Override
|
|
||||||
public void onSubmit(final SubmitEvent event) {
|
|
||||||
event.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(form);
|
|
||||||
|
|
||||||
approvalPanel = new FlowPanel();
|
|
||||||
body.add(approvalPanel);
|
|
||||||
initMessage(body);
|
|
||||||
|
|
||||||
draftsPanel = new FlowPanel();
|
|
||||||
body.add(draftsPanel);
|
|
||||||
|
|
||||||
final FlowPanel buttonRow = new FlowPanel();
|
|
||||||
buttonRow.setStyleName(Gerrit.RESOURCES.css().patchSetActions());
|
|
||||||
body.add(buttonRow);
|
|
||||||
|
|
||||||
send = new Button(Util.C.buttonPublishCommentsSend());
|
|
||||||
send.addClickHandler(this);
|
|
||||||
buttonRow.add(send);
|
|
||||||
|
|
||||||
cancel = new Button(Util.C.buttonPublishCommentsCancel());
|
|
||||||
cancel.addClickHandler(this);
|
|
||||||
buttonRow.add(cancel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableForm(final boolean enabled) {
|
|
||||||
for (final ValueRadioButton approvalButton : approvalButtons) {
|
|
||||||
approvalButton.setEnabled(enabled);
|
|
||||||
}
|
|
||||||
message.setEnabled(enabled);
|
|
||||||
for (final CommentEditorPanel commentEditor : commentEditors) {
|
|
||||||
commentEditor.enableButtons(enabled);
|
|
||||||
}
|
|
||||||
send.setEnabled(enabled);
|
|
||||||
cancel.setEnabled(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLoad() {
|
|
||||||
super.onLoad();
|
|
||||||
|
|
||||||
CallbackGroup group = new CallbackGroup();
|
|
||||||
RestApi call = ChangeApi.detail(patchSetId.getParentKey().get());
|
|
||||||
ChangeList.addOptions(call, EnumSet.of(
|
|
||||||
ListChangesOption.CURRENT_ACTIONS,
|
|
||||||
ListChangesOption.ALL_REVISIONS,
|
|
||||||
ListChangesOption.ALL_COMMITS));
|
|
||||||
call.get(group.add(new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
detail = result;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
ChangeApi.revision(patchSetId)
|
|
||||||
.view("submit_type")
|
|
||||||
.get(group.add(new GerritCallback<NativeString>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeString result) {
|
|
||||||
submitTypeRecord = SubmitTypeRecord.OK(
|
|
||||||
SubmitType.valueOf(result.asString()));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
ChangeApi.revision(patchSetId.getParentKey().get(), "" + patchSetId.get())
|
|
||||||
.view("drafts")
|
|
||||||
.get(group.add(new AsyncCallback<NativeMap<JsArray<CommentInfo>>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(NativeMap<JsArray<CommentInfo>> result) {
|
|
||||||
drafts = result;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {}
|
|
||||||
}));
|
|
||||||
ChangeApi.revision(patchSetId).view("review")
|
|
||||||
.get(group.addFinal(new GerritCallback<ChangeInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeInfo result) {
|
|
||||||
result.init();
|
|
||||||
change = result;
|
|
||||||
preDisplay(result);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void preDisplay(final ChangeInfo info) {
|
|
||||||
ConfigInfoCache.get(info.project_name_key(),
|
|
||||||
new ScreenLoadCallback<ConfigInfoCache.Entry>(this) {
|
|
||||||
@Override
|
|
||||||
protected void preDisplay(ConfigInfoCache.Entry result) {
|
|
||||||
send.setEnabled(true);
|
|
||||||
commentLinkProcessor = result.getCommentLinkProcessor();
|
|
||||||
setTheme(result.getTheme());
|
|
||||||
displayScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void postDisplay() {
|
|
||||||
message.setFocus(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onUnload() {
|
|
||||||
super.onUnload();
|
|
||||||
lastState = saveStateOnUnload ? new SavedState(this) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(final ClickEvent event) {
|
|
||||||
final Widget sender = (Widget) event.getSource();
|
|
||||||
if (send == sender) {
|
|
||||||
onSend(false);
|
|
||||||
} else if (cancel == sender) {
|
|
||||||
saveStateOnUnload = false;
|
|
||||||
goChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyDraftDelta(int delta) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(CommentEditorPanel editor) {
|
|
||||||
commentEditors.remove(editor);
|
|
||||||
|
|
||||||
// The editor should be embedded into a panel holding all
|
|
||||||
// editors for the same file.
|
|
||||||
//
|
|
||||||
FlowPanel parent = (FlowPanel) editor.getParent();
|
|
||||||
parent.remove(editor);
|
|
||||||
|
|
||||||
// If the panel now holds no editors, remove it.
|
|
||||||
//
|
|
||||||
int editorCount = 0;
|
|
||||||
for (Widget w : parent) {
|
|
||||||
if (w instanceof CommentEditorPanel) {
|
|
||||||
editorCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (editorCount == 0) {
|
|
||||||
parent.removeFromParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If that was the last file with a draft, remove the heading.
|
|
||||||
//
|
|
||||||
if (draftsPanel.getWidgetCount() == 1) {
|
|
||||||
draftsPanel.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMessage(final Panel body) {
|
|
||||||
body.add(new SmallHeading(Util.C.headingCoverMessage()));
|
|
||||||
|
|
||||||
final VerticalPanel mwrap = new VerticalPanel();
|
|
||||||
mwrap.setStyleName(Gerrit.RESOURCES.css().coverMessage());
|
|
||||||
body.add(mwrap);
|
|
||||||
|
|
||||||
message = new NpTextArea();
|
|
||||||
message.setCharacterWidth(60);
|
|
||||||
message.setVisibleLines(10);
|
|
||||||
message.setSpellCheck(true);
|
|
||||||
mwrap.add(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initApprovals(Panel body) {
|
|
||||||
for (String labelName : change.labels()) {
|
|
||||||
initLabel(labelName, body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initLabel(String labelName, Panel body) {
|
|
||||||
if (!change.has_permitted_labels()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JsArrayString nativeValues = change.permitted_values(labelName);
|
|
||||||
if (nativeValues == null || nativeValues.length() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<String> values = new ArrayList<>(nativeValues.length());
|
|
||||||
for (int i = 0; i < nativeValues.length(); i++) {
|
|
||||||
values.add(nativeValues.get(i));
|
|
||||||
}
|
|
||||||
Collections.reverse(values);
|
|
||||||
LabelInfo label = change.label(labelName);
|
|
||||||
|
|
||||||
body.add(new SmallHeading(label.name() + ":"));
|
|
||||||
|
|
||||||
VerticalPanel vp = new VerticalPanel();
|
|
||||||
vp.setStyleName(Gerrit.RESOURCES.css().labelList());
|
|
||||||
|
|
||||||
Short prior = null;
|
|
||||||
if (label.all() != null) {
|
|
||||||
for (ApprovalInfo app : Natives.asList(label.all())) {
|
|
||||||
if (app._account_id() == Gerrit.getUserAccount().getId().get()) {
|
|
||||||
prior = app.value();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String value : values) {
|
|
||||||
ValueRadioButton b = new ValueRadioButton(label, value);
|
|
||||||
SafeHtml buf = new SafeHtmlBuilder().append(b.format());
|
|
||||||
buf = commentLinkProcessor.apply(buf);
|
|
||||||
SafeHtml.set(b, buf);
|
|
||||||
|
|
||||||
if (lastState != null && patchSetId.equals(lastState.patchSetId)
|
|
||||||
&& lastState.approvals.containsKey(label.name())) {
|
|
||||||
b.setValue(lastState.approvals.get(label.name()).equals(value));
|
|
||||||
} else {
|
|
||||||
b.setValue(b.parseValue() == (prior != null ? prior : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
approvalButtons.add(b);
|
|
||||||
vp.add(b);
|
|
||||||
}
|
|
||||||
body.add(vp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayScreen() {
|
|
||||||
ChangeDetail r = ChangeDetailCache.reverse(detail);
|
|
||||||
|
|
||||||
setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(),
|
|
||||||
patchSetId.get()));
|
|
||||||
descBlock.display(r, null, false, r.getCurrentPatchSetDetail().getInfo(),
|
|
||||||
r.getAccounts(), submitTypeRecord, commentLinkProcessor);
|
|
||||||
|
|
||||||
if (r.getChange().getStatus().isOpen()) {
|
|
||||||
initApprovals(approvalPanel);
|
|
||||||
approvals.display(change);
|
|
||||||
} else {
|
|
||||||
approvals.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastState != null && patchSetId.equals(lastState.patchSetId)) {
|
|
||||||
message.setText(lastState.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
draftsPanel.clear();
|
|
||||||
commentEditors = new ArrayList<>();
|
|
||||||
|
|
||||||
if (!drafts.isEmpty()) {
|
|
||||||
draftsPanel.add(new SmallHeading(Util.C.headingPatchComments()));
|
|
||||||
|
|
||||||
Panel panel = null;
|
|
||||||
String priorFile = "";
|
|
||||||
for (final PatchLineComment c : draftList()) {
|
|
||||||
final Patch.Key patchKey = c.getKey().getParentKey();
|
|
||||||
final String fn = patchKey.get();
|
|
||||||
if (!fn.equals(priorFile)) {
|
|
||||||
panel = new FlowPanel();
|
|
||||||
panel.addStyleName(Gerrit.RESOURCES.css().patchComments());
|
|
||||||
draftsPanel.add(panel);
|
|
||||||
// Parent table can be null here since we are not showing any
|
|
||||||
// next/previous links
|
|
||||||
panel.add(new PatchLink.SideBySide(
|
|
||||||
PatchTable.getDisplayFileName(patchKey), null, patchKey, 0, null, null));
|
|
||||||
priorFile = fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
final CommentEditorPanel editor =
|
|
||||||
new CommentEditorPanel(c, commentLinkProcessor);
|
|
||||||
if (c.getLine() == AbstractPatchContentTable.R_HEAD) {
|
|
||||||
editor.setAuthorNameText(Gerrit.getUserAccountInfo(),
|
|
||||||
Util.C.fileCommentHeader());
|
|
||||||
} else {
|
|
||||||
editor.setAuthorNameText(Gerrit.getUserAccountInfo(),
|
|
||||||
Util.M.lineHeader(c.getLine()));
|
|
||||||
}
|
|
||||||
editor.setOpen(true);
|
|
||||||
commentEditors.add(editor);
|
|
||||||
panel.add(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSend(final boolean submit) {
|
|
||||||
if (commentEditors.isEmpty()) {
|
|
||||||
onSend2(submit);
|
|
||||||
} else {
|
|
||||||
final GerritCallback<VoidResult> afterSaveDraft =
|
|
||||||
new GerritCallback<VoidResult>() {
|
|
||||||
private int done;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(final VoidResult result) {
|
|
||||||
if (++done == commentEditors.size()) {
|
|
||||||
onSend2(submit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
for (final CommentEditorPanel p : commentEditors) {
|
|
||||||
p.saveDraft(afterSaveDraft);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onSend2(final boolean submit) {
|
|
||||||
ReviewInput data = ReviewInput.create();
|
|
||||||
data.message(ChangeApi.emptyToNull(message.getText().trim()));
|
|
||||||
for (final ValueRadioButton b : approvalButtons) {
|
|
||||||
if (b.getValue()) {
|
|
||||||
data.label(b.label.name(), b.parseValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enableForm(false);
|
|
||||||
new RestApi("/changes/")
|
|
||||||
.id(String.valueOf(patchSetId.getParentKey().get()))
|
|
||||||
.view("revisions").id(patchSetId.get()).view("review")
|
|
||||||
.post(data, new GerritCallback<ReviewInput>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ReviewInput result) {
|
|
||||||
if (submit) {
|
|
||||||
submit();
|
|
||||||
} else {
|
|
||||||
saveStateOnUnload = false;
|
|
||||||
goChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
super.onFailure(caught);
|
|
||||||
enableForm(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void submit() {
|
|
||||||
ChangeApi.submit(
|
|
||||||
patchSetId.getParentKey().get(),
|
|
||||||
"" + patchSetId.get(),
|
|
||||||
new GerritCallback<SubmitInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(SubmitInfo result) {
|
|
||||||
saveStateOnUnload = false;
|
|
||||||
goChange();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable err) {
|
|
||||||
if (SubmitFailureDialog.isConflict(err)) {
|
|
||||||
new SubmitFailureDialog(err.getMessage()).center();
|
|
||||||
} else {
|
|
||||||
super.onFailure(err);
|
|
||||||
}
|
|
||||||
goChange();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void goChange() {
|
|
||||||
final Change.Id ck = patchSetId.getParentKey();
|
|
||||||
Gerrit.display(PageLinks.toChange(ck), new ChangeScreen(ck));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<PatchLineComment> draftList() {
|
|
||||||
List<PatchLineComment> d = new ArrayList<>();
|
|
||||||
List<String> paths = new ArrayList<>(drafts.keySet());
|
|
||||||
Collections.sort(paths);
|
|
||||||
for (String path : paths) {
|
|
||||||
JsArray<CommentInfo> comments = drafts.get(path);
|
|
||||||
for (int i = 0; i < comments.length(); i++) {
|
|
||||||
d.add(CommentEditorPanel.toComment(patchSetId, path, comments.get(i)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ValueRadioButton extends RadioButton {
|
|
||||||
final LabelInfo label;
|
|
||||||
final String value;
|
|
||||||
|
|
||||||
ValueRadioButton(LabelInfo label, String value) {
|
|
||||||
super(label.name());
|
|
||||||
this.label = label;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
String format() {
|
|
||||||
return new StringBuilder().append(value).append(' ')
|
|
||||||
.append(label.value_text(value)).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
short parseValue() {
|
|
||||||
String value = this.value;
|
|
||||||
if (value.startsWith(" ") || value.startsWith("+")) {
|
|
||||||
value = value.substring(1);
|
|
||||||
}
|
|
||||||
return Short.parseShort(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SavedState {
|
|
||||||
final PatchSet.Id patchSetId;
|
|
||||||
final String message;
|
|
||||||
final Map<String, String> approvals;
|
|
||||||
|
|
||||||
SavedState(final PublishCommentScreen p) {
|
|
||||||
patchSetId = p.patchSetId;
|
|
||||||
message = p.message.getText();
|
|
||||||
approvals = new HashMap<>();
|
|
||||||
for (final ValueRadioButton b : p.approvalButtons) {
|
|
||||||
if (b.getValue()) {
|
|
||||||
approvals.put(b.label.name(), b.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,27 +14,17 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.client.changes;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.ChangeDetailService;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwtjsonrpc.client.JsonUtil;
|
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
public static final ChangeConstants C = GWT.create(ChangeConstants.class);
|
public static final ChangeConstants C = GWT.create(ChangeConstants.class);
|
||||||
public static final ChangeMessages M = GWT.create(ChangeMessages.class);
|
public static final ChangeMessages M = GWT.create(ChangeMessages.class);
|
||||||
public static final ChangeResources R = GWT.create(ChangeResources.class);
|
|
||||||
|
|
||||||
public static final ChangeDetailService DETAIL_SVC;
|
|
||||||
|
|
||||||
private static final int SUBJECT_MAX_LENGTH = 80;
|
private static final int SUBJECT_MAX_LENGTH = 80;
|
||||||
private static final String SUBJECT_CROP_APPENDIX = "...";
|
private static final String SUBJECT_CROP_APPENDIX = "...";
|
||||||
private static final int SUBJECT_CROP_RANGE = 10;
|
private static final int SUBJECT_CROP_RANGE = 10;
|
||||||
|
|
||||||
static {
|
|
||||||
DETAIL_SVC = GWT.create(ChangeDetailService.class);
|
|
||||||
JsonUtil.bind(DETAIL_SVC, "rpc/ChangeDetailService");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toLongString(final Change.Status status) {
|
public static String toLongString(final Change.Status status) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
return "";
|
return "";
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 313 B |
Binary file not shown.
Before Width: | Height: | Size: 430 B |
@ -979,13 +979,6 @@ a:hover {
|
|||||||
border-right: 1px solid trimColor;
|
border-right: 1px solid trimColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sideBySideTableBinaryHeader {
|
|
||||||
border-left: thin solid #b0bdcc;
|
|
||||||
width: 100%;
|
|
||||||
color: grey;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.infoTable td.approvalrole {
|
.infoTable td.approvalrole {
|
||||||
width: 5em;
|
width: 5em;
|
||||||
border-left: none;
|
border-left: none;
|
||||||
@ -1243,17 +1236,6 @@ a:hover.downloadLink {
|
|||||||
display: table;
|
display: table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** SideBySideScreen **/
|
|
||||||
.sideBySideScreenSideBySideTable {
|
|
||||||
width: 100%;
|
|
||||||
border: 1px solid #B0BDCC;
|
|
||||||
display: table;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sideBySideScreenSideBySideTable .fileLine {
|
|
||||||
width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sideBySideScreenLinkTable {
|
.sideBySideScreenLinkTable {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.patches;
|
package com.google.gerrit.client.patches;
|
||||||
|
|
||||||
import com.google.gerrit.client.Dispatcher;
|
|
||||||
import com.google.gerrit.client.FormatUtil;
|
import com.google.gerrit.client.FormatUtil;
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.account.AccountInfo;
|
import com.google.gerrit.client.account.AccountInfo;
|
||||||
import com.google.gerrit.client.changes.CommentApi;
|
import com.google.gerrit.client.changes.CommentApi;
|
||||||
import com.google.gerrit.client.changes.CommentInfo;
|
import com.google.gerrit.client.changes.CommentInfo;
|
||||||
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.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||||
import com.google.gerrit.client.ui.CommentPanel;
|
import com.google.gerrit.client.ui.CommentPanel;
|
||||||
@ -72,7 +70,7 @@ import java.sql.Timestamp;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
||||||
implements CommentEditorContainer, FocusHandler, BlurHandler {
|
implements CommentEditorContainer, FocusHandler, BlurHandler {
|
||||||
public static final int R_HEAD = 0;
|
public static final int R_HEAD = 0;
|
||||||
static final short FILE_SIDE_A = (short) 0;
|
static final short FILE_SIDE_A = (short) 0;
|
||||||
@ -110,8 +108,6 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
|||||||
if (Gerrit.isSignedIn()) {
|
if (Gerrit.isSignedIn()) {
|
||||||
keysAction.add(new InsertCommentCommand(0, 'c', PatchUtil.C
|
keysAction.add(new InsertCommentCommand(0, 'c', PatchUtil.C
|
||||||
.commentInsert()));
|
.commentInsert()));
|
||||||
keysAction.add(new PublishCommentsKeyCommand(0, 'r', Util.C
|
|
||||||
.keyPublishComments()));
|
|
||||||
|
|
||||||
// See CommentEditorPanel
|
// See CommentEditorPanel
|
||||||
//
|
//
|
||||||
@ -131,11 +127,8 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
|||||||
|
|
||||||
abstract void createFileCommentEditorOnSideB();
|
abstract void createFileCommentEditorOnSideB();
|
||||||
|
|
||||||
abstract PatchScreen.Type getPatchScreenType();
|
|
||||||
|
|
||||||
protected void initHeaders(PatchScript script, PatchSetDetail detail) {
|
protected void initHeaders(PatchScript script, PatchSetDetail detail) {
|
||||||
PatchScreen.Type type = getPatchScreenType();
|
headerSideA = new PatchSetSelectBox(PatchSetSelectBox.Side.A);
|
||||||
headerSideA = new PatchSetSelectBox(PatchSetSelectBox.Side.A, type);
|
|
||||||
headerSideA.display(detail, script, patchKey, idSideA, idSideB);
|
headerSideA.display(detail, script, patchKey, idSideA, idSideB);
|
||||||
headerSideA.addDoubleClickHandler(new DoubleClickHandler() {
|
headerSideA.addDoubleClickHandler(new DoubleClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -145,7 +138,7 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
headerSideB = new PatchSetSelectBox(PatchSetSelectBox.Side.B, type);
|
headerSideB = new PatchSetSelectBox(PatchSetSelectBox.Side.B);
|
||||||
headerSideB.display(detail, script, patchKey, idSideA, idSideB);
|
headerSideB.display(detail, script, patchKey, idSideA, idSideB);
|
||||||
headerSideB.addDoubleClickHandler(new DoubleClickHandler() {
|
headerSideB.addDoubleClickHandler(new DoubleClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -838,18 +831,6 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PublishCommentsKeyCommand extends NeedsSignInKeyCommand {
|
|
||||||
public PublishCommentsKeyCommand(int mask, char key, String help) {
|
|
||||||
super(mask, key, help);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onKeyPress(final KeyPressEvent event) {
|
|
||||||
final PatchSet.Id id = patchKey.getParentKey();
|
|
||||||
Gerrit.display(Dispatcher.toPublish(id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PrevChunkKeyCmd extends KeyCommand {
|
public class PrevChunkKeyCmd extends KeyCommand {
|
||||||
public PrevChunkKeyCmd(int mask, int key, String help) {
|
public PrevChunkKeyCmd(int mask, int key, String help) {
|
||||||
super(mask, key, help);
|
super(mask, key, help);
|
||||||
|
@ -33,10 +33,10 @@ import java.util.List;
|
|||||||
* A table used to specify which two patch sets should be diff'ed.
|
* A table used to specify which two patch sets should be diff'ed.
|
||||||
*/
|
*/
|
||||||
class HistoryTable extends FancyFlexTable<Patch> {
|
class HistoryTable extends FancyFlexTable<Patch> {
|
||||||
private final PatchScreen screen;
|
private final UnifiedPatchScreen screen;
|
||||||
final List<HistoryRadio> all = new ArrayList<>();
|
final List<HistoryRadio> all = new ArrayList<>();
|
||||||
|
|
||||||
HistoryTable(final PatchScreen parent) {
|
HistoryTable(final UnifiedPatchScreen parent) {
|
||||||
setStyleName(Gerrit.RESOURCES.css().patchHistoryTable());
|
setStyleName(Gerrit.RESOURCES.css().patchHistoryTable());
|
||||||
screen = parent;
|
screen = parent;
|
||||||
table.setWidth("auto");
|
table.setWidth("auto");
|
||||||
@ -58,14 +58,7 @@ class HistoryTable extends FancyFlexTable<Patch> {
|
|||||||
}
|
}
|
||||||
enableAll(false);
|
enableAll(false);
|
||||||
Patch.Key k = new Patch.Key(sideB, screen.getPatchKey().get());
|
Patch.Key k = new Patch.Key(sideB, screen.getPatchKey().get());
|
||||||
switch (screen.getPatchScreenType()) {
|
Gerrit.display(Dispatcher.toUnified(sideA, k));
|
||||||
case SIDE_BY_SIDE:
|
|
||||||
Gerrit.display(Dispatcher.toPatchSideBySide(sideA, k));
|
|
||||||
break;
|
|
||||||
case UNIFIED:
|
|
||||||
Gerrit.display(Dispatcher.toPatchUnified(sideA, k));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableAll(final boolean on) {
|
void enableAll(final boolean on) {
|
||||||
|
@ -75,11 +75,11 @@ class NavLinks extends Composite {
|
|||||||
table.setWidget(0, 1, up);
|
table.setWidget(0, 1, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(int patchIndex, PatchScreen.Type type, PatchTable fileList,
|
void display(int patchIndex, PatchTable fileList,
|
||||||
List<InlineHyperlink> links, List<WebLinkInfo> webLinks) {
|
List<InlineHyperlink> links, List<WebLinkInfo> webLinks) {
|
||||||
if (fileList != null) {
|
if (fileList != null) {
|
||||||
setupNav(Nav.PREV, fileList.getPreviousPatchLink(patchIndex, type));
|
setupNav(Nav.PREV, fileList.getPreviousPatchLink(patchIndex));
|
||||||
setupNav(Nav.NEXT, fileList.getNextPatchLink(patchIndex, type));
|
setupNav(Nav.NEXT, fileList.getNextPatchLink(patchIndex));
|
||||||
} else {
|
} else {
|
||||||
setupNav(Nav.PREV, null);
|
setupNav(Nav.PREV, null);
|
||||||
setupNav(Nav.NEXT, null);
|
setupNav(Nav.NEXT, null);
|
||||||
|
@ -41,18 +41,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PatchSetSelectBox extends Composite {
|
public class PatchSetSelectBox extends Composite {
|
||||||
interface Binder extends UiBinder<HTMLPanel, PatchSetSelectBox> {
|
interface Binder extends UiBinder<HTMLPanel, PatchSetSelectBox> {}
|
||||||
}
|
|
||||||
|
|
||||||
private static final Binder uiBinder = GWT.create(Binder.class);
|
private static final Binder uiBinder = GWT.create(Binder.class);
|
||||||
|
|
||||||
interface BoxStyle extends CssResource {
|
interface BoxStyle extends CssResource {
|
||||||
String selected();
|
String selected();
|
||||||
|
|
||||||
String hidden();
|
String hidden();
|
||||||
|
|
||||||
String sideMarker();
|
String sideMarker();
|
||||||
|
|
||||||
String patchSetLabel();
|
String patchSetLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +61,6 @@ public class PatchSetSelectBox extends Composite {
|
|||||||
PatchSet.Id idSideB;
|
PatchSet.Id idSideB;
|
||||||
PatchSet.Id idActive;
|
PatchSet.Id idActive;
|
||||||
Side side;
|
Side side;
|
||||||
PatchScreen.Type screenType;
|
|
||||||
Map<Integer, Anchor> links;
|
Map<Integer, Anchor> links;
|
||||||
private Label patchSet;
|
private Label patchSet;
|
||||||
|
|
||||||
@ -76,9 +70,8 @@ public class PatchSetSelectBox extends Composite {
|
|||||||
@UiField
|
@UiField
|
||||||
BoxStyle style;
|
BoxStyle style;
|
||||||
|
|
||||||
public PatchSetSelectBox(Side side, final PatchScreen.Type type) {
|
public PatchSetSelectBox(Side side) {
|
||||||
this.side = side;
|
this.side = side;
|
||||||
this.screenType = type;
|
|
||||||
|
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
}
|
}
|
||||||
@ -102,11 +95,9 @@ public class PatchSetSelectBox extends Composite {
|
|||||||
patchSet.addStyleName(style.patchSetLabel());
|
patchSet.addStyleName(style.patchSetLabel());
|
||||||
linkPanel.add(patchSet);
|
linkPanel.add(patchSet);
|
||||||
|
|
||||||
if (screenType == PatchScreen.Type.UNIFIED) {
|
Label sideMarker = new Label((side == Side.A) ? "(-)" : "(+)");
|
||||||
Label sideMarker = new Label((side == Side.A) ? "(-)" : "(+)");
|
sideMarker.addStyleName(style.sideMarker());
|
||||||
sideMarker.addStyleName(style.sideMarker());
|
linkPanel.add(sideMarker);
|
||||||
linkPanel.add(sideMarker);
|
|
||||||
}
|
|
||||||
|
|
||||||
Anchor baseLink;
|
Anchor baseLink;
|
||||||
if (detail.getInfo().getParents().size() > 1) {
|
if (detail.getInfo().getParents().size() > 1) {
|
||||||
@ -116,9 +107,7 @@ public class PatchSetSelectBox extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
links.put(0, baseLink);
|
links.put(0, baseLink);
|
||||||
if (screenType == PatchScreen.Type.UNIFIED || side == Side.A) {
|
linkPanel.add(baseLink);
|
||||||
linkPanel.add(baseLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (side == Side.B) {
|
if (side == Side.B) {
|
||||||
links.get(0).setStyleName(style.hidden());
|
links.get(0).setStyleName(style.hidden());
|
||||||
@ -161,19 +150,9 @@ public class PatchSetSelectBox extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Patch.Key keySideB = new Patch.Key(idSideB, patchKey.get());
|
Patch.Key keySideB = new Patch.Key(idSideB, patchKey.get());
|
||||||
|
Gerrit.display(Dispatcher.toUnified(idSideA, keySideB));
|
||||||
switch (screenType) {
|
|
||||||
case SIDE_BY_SIDE:
|
|
||||||
Gerrit.display(Dispatcher.toPatchSideBySide(idSideA, keySideB));
|
|
||||||
break;
|
|
||||||
case UNIFIED:
|
|
||||||
Gerrit.display(Dispatcher.toPatchUnified(idSideA, keySideB));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.patches;
|
package com.google.gerrit.client.patches;
|
||||||
|
|
||||||
|
import com.google.gerrit.common.data.ChangeDetailService;
|
||||||
import com.google.gerrit.common.data.PatchDetailService;
|
import com.google.gerrit.common.data.PatchDetailService;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwtjsonrpc.client.JsonUtil;
|
import com.google.gwtjsonrpc.client.JsonUtil;
|
||||||
@ -21,10 +22,14 @@ import com.google.gwtjsonrpc.client.JsonUtil;
|
|||||||
public class PatchUtil {
|
public class PatchUtil {
|
||||||
public static final PatchConstants C = GWT.create(PatchConstants.class);
|
public static final PatchConstants C = GWT.create(PatchConstants.class);
|
||||||
public static final PatchMessages M = GWT.create(PatchMessages.class);
|
public static final PatchMessages M = GWT.create(PatchMessages.class);
|
||||||
public static final PatchDetailService DETAIL_SVC;
|
public static final ChangeDetailService CHANGE_SVC;
|
||||||
|
public static final PatchDetailService PATCH_SVC;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DETAIL_SVC = GWT.create(PatchDetailService.class);
|
CHANGE_SVC = GWT.create(ChangeDetailService.class);
|
||||||
JsonUtil.bind(DETAIL_SVC, "rpc/PatchDetailService");
|
JsonUtil.bind(CHANGE_SVC, "rpc/ChangeDetailService");
|
||||||
|
|
||||||
|
PATCH_SVC = GWT.create(PatchDetailService.class);
|
||||||
|
JsonUtil.bind(PATCH_SVC, "rpc/PatchDetailService");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,10 @@ public class ReviewedPanels {
|
|||||||
this.bottom.setStyleName(Gerrit.RESOURCES.css().reviewedPanelBottom());
|
this.bottom.setStyleName(Gerrit.RESOURCES.css().reviewedPanelBottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populate(Patch.Key pk, PatchTable pt, int patchIndex,
|
public void populate(Patch.Key pk, PatchTable pt, int patchIndex) {
|
||||||
PatchScreen.Type patchScreenType) {
|
|
||||||
patchKey = pk;
|
patchKey = pk;
|
||||||
fileList = pt;
|
fileList = pt;
|
||||||
reviewedLink = createReviewedLink(patchIndex, patchScreenType);
|
reviewedLink = createReviewedLink(patchIndex);
|
||||||
|
|
||||||
top.clear();
|
top.clear();
|
||||||
checkBoxTop = createReviewedCheckbox();
|
checkBoxTop = createReviewedCheckbox();
|
||||||
@ -132,8 +131,7 @@ public class ReviewedPanels {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InlineHyperlink createReviewedLink(final int patchIndex,
|
private InlineHyperlink createReviewedLink(final int patchIndex) {
|
||||||
final PatchScreen.Type patchScreenType) {
|
|
||||||
final PatchValidator unreviewedValidator = new PatchValidator() {
|
final PatchValidator unreviewedValidator = new PatchValidator() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Patch patch) {
|
public boolean isValid(Patch patch) {
|
||||||
@ -150,8 +148,7 @@ public class ReviewedPanels {
|
|||||||
if (nextUnreviewedPatchIndex > -1) {
|
if (nextUnreviewedPatchIndex > -1) {
|
||||||
// Create invisible patch link to change page
|
// Create invisible patch link to change page
|
||||||
reviewedLink =
|
reviewedLink =
|
||||||
fileList.createLink(nextUnreviewedPatchIndex, patchScreenType,
|
fileList.createLink(nextUnreviewedPatchIndex, null, null);
|
||||||
null, null);
|
|
||||||
reviewedLink.setText("");
|
reviewedLink.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,684 +0,0 @@
|
|||||||
// Copyright (C) 2008 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 static com.google.gerrit.client.patches.PatchLine.Type.CONTEXT;
|
|
||||||
import static com.google.gerrit.client.patches.PatchLine.Type.DELETE;
|
|
||||||
import static com.google.gerrit.client.patches.PatchLine.Type.INSERT;
|
|
||||||
import static com.google.gerrit.client.patches.PatchLine.Type.REPLACE;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.common.data.CommentDetail;
|
|
||||||
import com.google.gerrit.common.data.PatchScript;
|
|
||||||
import com.google.gerrit.common.data.PatchScript.DisplayMethod;
|
|
||||||
import com.google.gerrit.common.data.PatchScript.FileMode;
|
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
|
||||||
import com.google.gerrit.prettify.client.SparseHtmlFile;
|
|
||||||
import com.google.gerrit.prettify.common.EditList;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
|
||||||
import com.google.gwt.dom.client.Element;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
|
||||||
import com.google.gwt.user.client.DOM;
|
|
||||||
import com.google.gwt.user.client.Event;
|
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
|
||||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
|
||||||
import com.google.gwt.user.client.ui.InlineLabel;
|
|
||||||
import com.google.gwt.user.client.ui.UIObject;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
|
||||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.diff.Edit;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class SideBySideTable extends AbstractPatchContentTable {
|
|
||||||
private static final int A = 2;
|
|
||||||
private static final int B = 3;
|
|
||||||
private static final int NUM_ROWS_TO_EXPAND = 10;
|
|
||||||
|
|
||||||
private SparseHtmlFile a;
|
|
||||||
private SparseHtmlFile b;
|
|
||||||
private boolean isHugeFile;
|
|
||||||
protected boolean isFileCommentBorderRowExist;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createFileCommentEditorOnSideA() {
|
|
||||||
createCommentEditor(R_HEAD + 1, A, R_HEAD, FILE_SIDE_A);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void createFileCommentEditorOnSideB() {
|
|
||||||
createCommentEditor(R_HEAD + 1, B, R_HEAD, FILE_SIDE_B);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCellDoubleClick(final int row, int column) {
|
|
||||||
if (column > C_ARROW && getRowItem(row) instanceof PatchLine) {
|
|
||||||
final PatchLine line = (PatchLine) getRowItem(row);
|
|
||||||
if (column == 1 || column == A) {
|
|
||||||
createCommentEditor(row + 1, A, line.getLineA(), (short) 0);
|
|
||||||
} else if (column == B || column == 4) {
|
|
||||||
createCommentEditor(row + 1, B, line.getLineB(), (short) 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCellSingleClick(Event event, int row, int column) {
|
|
||||||
super.onCellSingleClick(event, row, column);
|
|
||||||
if (column == 1 || column == 4) {
|
|
||||||
onCellDoubleClick(row, column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onInsertComment(final PatchLine line) {
|
|
||||||
final int row = getCurrentRow();
|
|
||||||
createCommentEditor(row + 1, B, line.getLineB(), (short) 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void render(final PatchScript script, final PatchSetDetail detail) {
|
|
||||||
final ArrayList<Object> lines = new ArrayList<>();
|
|
||||||
final SafeHtmlBuilder nc = new SafeHtmlBuilder();
|
|
||||||
isHugeFile = script.isHugeFile();
|
|
||||||
allocateTableHeader(nc);
|
|
||||||
lines.add(null);
|
|
||||||
if (!isDisplayBinary) {
|
|
||||||
if (script.getFileModeA() != FileMode.FILE
|
|
||||||
|| script.getFileModeB() != FileMode.FILE) {
|
|
||||||
openLine(nc);
|
|
||||||
appendModeLine(nc, script.getFileModeA());
|
|
||||||
appendModeLine(nc, script.getFileModeB());
|
|
||||||
closeLine(nc);
|
|
||||||
lines.add(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasDifferences(script)) {
|
|
||||||
int lastA = 0;
|
|
||||||
int lastB = 0;
|
|
||||||
final boolean ignoreWS = script.isIgnoreWhitespace();
|
|
||||||
a = getSparseHtmlFileA(script);
|
|
||||||
b = getSparseHtmlFileB(script);
|
|
||||||
final boolean intraline =
|
|
||||||
script.getDiffPrefs().isIntralineDifference()
|
|
||||||
&& script.hasIntralineDifference();
|
|
||||||
for (final EditList.Hunk hunk : script.getHunks()) {
|
|
||||||
if (!hunk.isStartOfFile()) {
|
|
||||||
appendSkipLine(nc);
|
|
||||||
lines.add(new SkippedLine(lastA, lastB, hunk.getCurB() - lastB));
|
|
||||||
}
|
|
||||||
|
|
||||||
while (hunk.next()) {
|
|
||||||
if (hunk.isContextLine()) {
|
|
||||||
openLine(nc);
|
|
||||||
final SafeHtml ctx = a.getSafeHtmlLine(hunk.getCurA());
|
|
||||||
appendLineNumber(nc, hunk.getCurA(), false);
|
|
||||||
appendLineText(nc, CONTEXT, ctx, false, false);
|
|
||||||
if (ignoreWS && b.contains(hunk.getCurB())) {
|
|
||||||
appendLineText(nc, CONTEXT, b, hunk.getCurB(), false);
|
|
||||||
} else {
|
|
||||||
appendLineText(nc, CONTEXT, ctx, false, false);
|
|
||||||
}
|
|
||||||
appendLineNumber(nc, hunk.getCurB(), true);
|
|
||||||
closeLine(nc);
|
|
||||||
hunk.incBoth();
|
|
||||||
lines.add(new PatchLine(CONTEXT, hunk.getCurA(), hunk.getCurB()));
|
|
||||||
|
|
||||||
} else if (hunk.isModifiedLine()) {
|
|
||||||
final boolean del = hunk.isDeletedA();
|
|
||||||
final boolean ins = hunk.isInsertedB();
|
|
||||||
final boolean full =
|
|
||||||
intraline && hunk.getCurEdit().getType() != Edit.Type.REPLACE;
|
|
||||||
openLine(nc);
|
|
||||||
|
|
||||||
if (del) {
|
|
||||||
appendLineNumber(nc, hunk.getCurA(), false);
|
|
||||||
appendLineText(nc, DELETE, a, hunk.getCurA(), full);
|
|
||||||
hunk.incA();
|
|
||||||
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
|
||||||
appendLineNumber(nc, false);
|
|
||||||
appendLineNone(nc, DELETE);
|
|
||||||
} else {
|
|
||||||
appendLineNumber(nc, false);
|
|
||||||
appendLineNone(nc, CONTEXT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ins) {
|
|
||||||
appendLineText(nc, INSERT, b, hunk.getCurB(), full);
|
|
||||||
appendLineNumber(nc, hunk.getCurB(), true);
|
|
||||||
hunk.incB();
|
|
||||||
} else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {
|
|
||||||
appendLineNone(nc, INSERT);
|
|
||||||
appendLineNumber(nc, true);
|
|
||||||
} else {
|
|
||||||
appendLineNone(nc, CONTEXT);
|
|
||||||
appendLineNumber(nc, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
closeLine(nc);
|
|
||||||
|
|
||||||
if (del && ins) {
|
|
||||||
lines.add(new PatchLine(REPLACE, hunk.getCurA(), hunk.getCurB()));
|
|
||||||
} else if (del) {
|
|
||||||
lines.add(new PatchLine(DELETE, hunk.getCurA(), -1));
|
|
||||||
} else if (ins) {
|
|
||||||
lines.add(new PatchLine(INSERT, -1, hunk.getCurB()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastA = hunk.getCurA();
|
|
||||||
lastB = hunk.getCurB();
|
|
||||||
}
|
|
||||||
if (lastB != b.size()) {
|
|
||||||
appendSkipLine(nc);
|
|
||||||
lines.add(new SkippedLine(lastA, lastB, b.size() - lastB));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Display the patch header for binary
|
|
||||||
for (final String line : script.getPatchHeader()) {
|
|
||||||
appendFileHeader(nc, line);
|
|
||||||
}
|
|
||||||
// If there is a safe picture involved, we show it
|
|
||||||
if (script.getDisplayMethodA() == DisplayMethod.IMG
|
|
||||||
|| script.getDisplayMethodB() == DisplayMethod.IMG) {
|
|
||||||
appendImageLine(script, nc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasDifferences(script)) {
|
|
||||||
appendNoDifferences(nc);
|
|
||||||
}
|
|
||||||
resetHtml(nc);
|
|
||||||
populateTableHeader(script, detail);
|
|
||||||
if (hasDifferences(script)) {
|
|
||||||
initScript(script);
|
|
||||||
if (!isDisplayBinary) {
|
|
||||||
for (int row = 0; row < lines.size(); row++) {
|
|
||||||
setRowItem(row, lines.get(row));
|
|
||||||
if (lines.get(row) instanceof SkippedLine) {
|
|
||||||
createSkipLine(row, (SkippedLine) lines.get(row), isHugeFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SafeHtml createImage(String url) {
|
|
||||||
SafeHtmlBuilder m = new SafeHtmlBuilder();
|
|
||||||
m.openElement("img");
|
|
||||||
m.setAttribute("src", url);
|
|
||||||
m.closeElement("img");
|
|
||||||
return m.toSafeHtml();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendImageLine(final PatchScript script,
|
|
||||||
final SafeHtmlBuilder m) {
|
|
||||||
m.openTr();
|
|
||||||
m.setAttribute("valign", "center");
|
|
||||||
m.setAttribute("align", "center");
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().iconCell());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
appendLineNumber(m, false);
|
|
||||||
if (script.getDisplayMethodA() == DisplayMethod.IMG) {
|
|
||||||
final String url = getUrlA();
|
|
||||||
appendLineText(m, DELETE, createImage(url), false, true);
|
|
||||||
} else {
|
|
||||||
appendLineNone(m, DELETE);
|
|
||||||
}
|
|
||||||
if (script.getDisplayMethodB() == DisplayMethod.IMG) {
|
|
||||||
final String url = getUrlB();
|
|
||||||
appendLineText(m, INSERT, createImage(url), false, true);
|
|
||||||
} else {
|
|
||||||
appendLineNone(m, INSERT);
|
|
||||||
}
|
|
||||||
|
|
||||||
appendLineNumber(m, true);
|
|
||||||
m.closeTr();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateTableHeader(final PatchScript script,
|
|
||||||
final PatchSetDetail detail) {
|
|
||||||
initHeaders(script, detail);
|
|
||||||
table.setWidget(R_HEAD, A, headerSideA);
|
|
||||||
table.setWidget(R_HEAD, B, headerSideB);
|
|
||||||
|
|
||||||
// Populate icons to lineNumber column header.
|
|
||||||
if (headerSideA.isFileOrCommitMessage()) {
|
|
||||||
table.setWidget(R_HEAD, A - 1, iconA);
|
|
||||||
}
|
|
||||||
if (headerSideB.isFileOrCommitMessage()) {
|
|
||||||
table.setWidget(R_HEAD, B + 1, iconB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendModeLine(final SafeHtmlBuilder nc, final FileMode mode) {
|
|
||||||
nc.openTd();
|
|
||||||
nc.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
nc.nbsp();
|
|
||||||
nc.closeTd();
|
|
||||||
|
|
||||||
nc.openTd();
|
|
||||||
nc.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
|
||||||
nc.addStyleName(Gerrit.RESOURCES.css().fileLineMode());
|
|
||||||
switch(mode){
|
|
||||||
case FILE:
|
|
||||||
nc.nbsp();
|
|
||||||
break;
|
|
||||||
case SYMLINK:
|
|
||||||
nc.append(PatchUtil.C.fileTypeSymlink());
|
|
||||||
break;
|
|
||||||
case GITLINK:
|
|
||||||
nc.append(PatchUtil.C.fileTypeGitlink());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nc.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PatchScreen.Type getPatchScreenType() {
|
|
||||||
return PatchScreen.Type.SIDE_BY_SIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(final CommentDetail cd, boolean expandComments) {
|
|
||||||
if (cd.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setAccountInfoCache(cd.getAccounts());
|
|
||||||
|
|
||||||
for (int row = 0; row < table.getRowCount();) {
|
|
||||||
final Iterator<PatchLineComment> ai;
|
|
||||||
final Iterator<PatchLineComment> bi;
|
|
||||||
|
|
||||||
if (row == R_HEAD) {
|
|
||||||
ai = cd.getForA(R_HEAD).iterator();
|
|
||||||
bi = cd.getForB(R_HEAD).iterator();
|
|
||||||
} else if (getRowItem(row) instanceof PatchLine) {
|
|
||||||
final PatchLine pLine = (PatchLine) getRowItem(row);
|
|
||||||
ai = cd.getForA(pLine.getLineA()).iterator();
|
|
||||||
bi = cd.getForB(pLine.getLineB()).iterator();
|
|
||||||
} else {
|
|
||||||
row++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
row++;
|
|
||||||
while (ai.hasNext() && bi.hasNext()) {
|
|
||||||
final PatchLineComment ac = ai.next();
|
|
||||||
final PatchLineComment bc = bi.next();
|
|
||||||
if (ac.getLine() == R_HEAD) {
|
|
||||||
insertFileCommentRow(row);
|
|
||||||
} else {
|
|
||||||
insertRow(row);
|
|
||||||
}
|
|
||||||
bindComment(row, A, ac, !ai.hasNext());
|
|
||||||
bindComment(row, B, bc, !bi.hasNext());
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
|
|
||||||
row = finish(ai, row, A);
|
|
||||||
row = finish(bi, row, B);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void defaultStyle(final int row, final CellFormatter fmt) {
|
|
||||||
fmt.addStyleName(row, A - 1, Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
fmt.addStyleName(row, A, Gerrit.RESOURCES.css().diffText());
|
|
||||||
if (isDisplayBinary) {
|
|
||||||
fmt.addStyleName(row, A, Gerrit.RESOURCES.css().diffTextForBinaryInSideBySide());
|
|
||||||
}
|
|
||||||
fmt.addStyleName(row, B, Gerrit.RESOURCES.css().diffText());
|
|
||||||
fmt.addStyleName(row, B + 1, Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
fmt.addStyleName(row, B + 1, Gerrit.RESOURCES.css().rightmost());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void insertRow(final int row) {
|
|
||||||
super.insertRow(row);
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
defaultStyle(row, fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void insertFileCommentRow(final int row) {
|
|
||||||
table.insertRow(row);
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
fmt.addStyleName(row, C_ARROW, Gerrit.RESOURCES.css().iconCellOfFileCommentRow());
|
|
||||||
defaultStyle(row, fmt);
|
|
||||||
|
|
||||||
fmt.addStyleName(row, C_ARROW, //
|
|
||||||
Gerrit.RESOURCES.css().cellsNextToFileComment());
|
|
||||||
fmt.addStyleName(row, A - 1, //
|
|
||||||
Gerrit.RESOURCES.css().cellsNextToFileComment());
|
|
||||||
fmt.addStyleName(row, B + 1, //
|
|
||||||
Gerrit.RESOURCES.css().cellsNextToFileComment());
|
|
||||||
createFileCommentBorderRow(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createFileCommentBorderRow(final int row) {
|
|
||||||
if (row == 1 && !isFileCommentBorderRowExist) {
|
|
||||||
isFileCommentBorderRowExist = true;
|
|
||||||
table.insertRow(R_HEAD + 2);
|
|
||||||
|
|
||||||
final CellFormatter fmt = table.getCellFormatter();
|
|
||||||
|
|
||||||
fmt.addStyleName(R_HEAD + 2, C_ARROW, //
|
|
||||||
Gerrit.RESOURCES.css().iconCellOfFileCommentRow());
|
|
||||||
defaultStyle(R_HEAD + 2, fmt);
|
|
||||||
|
|
||||||
final Element iconCell = fmt.getElement(R_HEAD + 2, C_ARROW);
|
|
||||||
UIObject.setStyleName(DOM.getParent(iconCell), Gerrit.RESOURCES.css()
|
|
||||||
.fileCommentBorder(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int finish(final Iterator<PatchLineComment> i, int row, final int col) {
|
|
||||||
while (i.hasNext()) {
|
|
||||||
final PatchLineComment c = i.next();
|
|
||||||
if (c.getLine() == R_HEAD) {
|
|
||||||
insertFileCommentRow(row);
|
|
||||||
} else {
|
|
||||||
insertRow(row);
|
|
||||||
}
|
|
||||||
bindComment(row, col, c, !i.hasNext());
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void allocateTableHeader(final SafeHtmlBuilder m) {
|
|
||||||
m.openTr();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().iconCell());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.nbsp();
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().rightmost());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.closeTr();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendFileHeader(final SafeHtmlBuilder m, final String line) {
|
|
||||||
m.openTr();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().iconCell());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
appendLineNumber(m, false);
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().sideBySideTableBinaryHeader());
|
|
||||||
m.setAttribute("colspan", 2);
|
|
||||||
m.append(line);
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
appendLineNumber(m, true);
|
|
||||||
|
|
||||||
m.closeTr();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendSkipLine(final SafeHtmlBuilder m) {
|
|
||||||
m.openTr();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().iconCell());
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().skipLine());
|
|
||||||
m.closeTd();
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
|
||||||
m.setAttribute("colspan", 4);
|
|
||||||
m.closeTd();
|
|
||||||
m.closeTr();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClickHandler expandAllListener = new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
expand(event, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private ClickHandler expandBeforeListener = new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
expand(event, NUM_ROWS_TO_EXPAND);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private ClickHandler expandAfterListener = new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
expand(event, -NUM_ROWS_TO_EXPAND);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void expand(ClickEvent event, final int numRows) {
|
|
||||||
int row = table.getCellForEvent(event).getRowIndex();
|
|
||||||
if (!(getRowItem(row) instanceof SkippedLine)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkippedLine line = (SkippedLine) getRowItem(row);
|
|
||||||
int loopTo = numRows;
|
|
||||||
if (numRows == 0) {
|
|
||||||
loopTo = line.getSize();
|
|
||||||
} else if (numRows < 0) {
|
|
||||||
loopTo = -numRows;
|
|
||||||
}
|
|
||||||
int offset = 0;
|
|
||||||
if (numRows < 0) {
|
|
||||||
offset = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CellFormatter fmt = table.getCellFormatter();
|
|
||||||
for (int i = 0 + offset; i < loopTo + offset; i++) {
|
|
||||||
insertRow(row + i);
|
|
||||||
table.getRowFormatter().setVerticalAlign(row + i,
|
|
||||||
HasVerticalAlignment.ALIGN_TOP);
|
|
||||||
int lineA = line.getStartA() + i;
|
|
||||||
int lineB = line.getStartB() + i;
|
|
||||||
if (numRows < 0) {
|
|
||||||
lineA = line.getStartA() + line.getSize() + numRows + i - offset;
|
|
||||||
lineB = line.getStartB() + line.getSize() + numRows + i - offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.setHTML(row + i, A - 1, "<a href=\"javascript:;\">" + (lineA + 1) + "</a>");
|
|
||||||
fmt.addStyleName(row + i, A - 1, Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
|
|
||||||
table.setHTML(row + i, A, a.getSafeHtmlLine(lineA).asString());
|
|
||||||
fmt.addStyleName(row + i, A, Gerrit.RESOURCES.css().fileLine());
|
|
||||||
fmt.addStyleName(row + i, A, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
|
||||||
|
|
||||||
table.setHTML(row + i, B, b.getSafeHtmlLine(lineB).asString());
|
|
||||||
fmt.addStyleName(row + i, B, Gerrit.RESOURCES.css().fileLine());
|
|
||||||
fmt.addStyleName(row + i, B, Gerrit.RESOURCES.css().fileLineCONTEXT());
|
|
||||||
|
|
||||||
table.setHTML(row + i, B + 1, "<a href=\"javascript:;\">" + (lineB + 1) + "</a>");
|
|
||||||
fmt.addStyleName(row + i, B + 1, Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
|
|
||||||
setRowItem(row + i, new PatchLine(CONTEXT, lineA, lineB));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numRows > 0) {
|
|
||||||
line.incrementStart(numRows);
|
|
||||||
createSkipLine(row + loopTo, line, isHugeFile);
|
|
||||||
} else if (numRows < 0) {
|
|
||||||
line.reduceSize(-numRows);
|
|
||||||
createSkipLine(row, line, isHugeFile);
|
|
||||||
} else {
|
|
||||||
table.removeRow(row + loopTo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSkipLine(int row, SkippedLine line, boolean isHugeFile) {
|
|
||||||
FlowPanel p = new FlowPanel();
|
|
||||||
InlineLabel l1 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionStart() + " ");
|
|
||||||
InlineLabel l2 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionEnd() + " ");
|
|
||||||
|
|
||||||
Anchor all = new Anchor(String.valueOf(line.getSize()));
|
|
||||||
all.addClickHandler(expandAllListener);
|
|
||||||
all.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
|
||||||
|
|
||||||
if (line.getSize() > 30) {
|
|
||||||
// Only show the expand before/after if skipped more than 30 lines.
|
|
||||||
Anchor b = new Anchor(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND), true);
|
|
||||||
Anchor a = new Anchor(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND), true);
|
|
||||||
|
|
||||||
b.addClickHandler(expandBeforeListener);
|
|
||||||
a.addClickHandler(expandAfterListener);
|
|
||||||
|
|
||||||
b.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
|
||||||
a.setStyleName(Gerrit.RESOURCES.css().skipLine());
|
|
||||||
|
|
||||||
p.add(b);
|
|
||||||
p.add(l1);
|
|
||||||
if (isHugeFile) {
|
|
||||||
p.add(new InlineLabel(" " + line.getSize() + " "));
|
|
||||||
} else {
|
|
||||||
p.add(all);
|
|
||||||
}
|
|
||||||
p.add(l2);
|
|
||||||
p.add(a);
|
|
||||||
} else {
|
|
||||||
p.add(l1);
|
|
||||||
p.add(all);
|
|
||||||
p.add(l2);
|
|
||||||
}
|
|
||||||
table.setWidget(row, 1, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openLine(final SafeHtmlBuilder m) {
|
|
||||||
m.openTr();
|
|
||||||
m.setAttribute("valign", "top");
|
|
||||||
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().iconCell());
|
|
||||||
m.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendLineNumber(SafeHtmlBuilder m, boolean right) {
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
if (right) {
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().rightmost());
|
|
||||||
}
|
|
||||||
m.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendLineNumber(SafeHtmlBuilder m, int lineNumberMinusOne, boolean right) {
|
|
||||||
m.openTd();
|
|
||||||
m.setStyleName(Gerrit.RESOURCES.css().lineNumber());
|
|
||||||
if (right) {
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().rightmost());
|
|
||||||
}
|
|
||||||
m.append(SafeHtml.asis("<a href=\"javascript:;\">"+ (lineNumberMinusOne + 1) + "</a>"));
|
|
||||||
m.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendLineText(final SafeHtmlBuilder m,
|
|
||||||
final PatchLine.Type type, final SparseHtmlFile src, final int i,
|
|
||||||
final boolean fullBlock) {
|
|
||||||
appendLineText(m, type, src.getSafeHtmlLine(i), src.hasTrailingEdit(i), fullBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendLineText(final SafeHtmlBuilder m,
|
|
||||||
final PatchLine.Type type, final SafeHtml lineHtml,
|
|
||||||
final boolean trailingEdit, final boolean fullBlock) {
|
|
||||||
m.openTd();
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
|
||||||
switch (type) {
|
|
||||||
case CONTEXT:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineCONTEXT());
|
|
||||||
break;
|
|
||||||
case DELETE:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineDELETE());
|
|
||||||
if (trailingEdit || fullBlock) {
|
|
||||||
m.addStyleName("wdd");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case INSERT:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineINSERT());
|
|
||||||
if (trailingEdit || fullBlock) {
|
|
||||||
m.addStyleName("wdi");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REPLACE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m.append(lineHtml);
|
|
||||||
m.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendLineNone(final SafeHtmlBuilder m, final PatchLine.Type type) {
|
|
||||||
m.openTd();
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLine());
|
|
||||||
switch (type != null ? type : PatchLine.Type.CONTEXT) {
|
|
||||||
case DELETE:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineDELETE());
|
|
||||||
break;
|
|
||||||
case INSERT:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineINSERT());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m.addStyleName(Gerrit.RESOURCES.css().fileLineNone());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
m.closeTd();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void closeLine(final SafeHtmlBuilder m) {
|
|
||||||
m.closeTr();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void destroyCommentRow(final int row) {
|
|
||||||
super.destroyCommentRow(row);
|
|
||||||
if (row == R_HEAD + 1) {
|
|
||||||
table.removeRow(row);
|
|
||||||
isFileCommentBorderRowExist = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -420,11 +420,6 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
|||||||
defaultStyle(row, fmt);
|
defaultStyle(row, fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PatchScreen.Type getPatchScreenType() {
|
|
||||||
return PatchScreen.Type.UNIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int insert(final List<PatchLineComment> in, int row) {
|
private int insert(final List<PatchLineComment> in, int row) {
|
||||||
for (Iterator<PatchLineComment> ci = in.iterator(); ci.hasNext();) {
|
for (Iterator<PatchLineComment> ci = in.iterator(); ci.hasNext();) {
|
||||||
final PatchLineComment c = ci.next();
|
final PatchLineComment c = ci.next();
|
||||||
|
@ -21,7 +21,6 @@ import com.google.gerrit.client.RpcStatus;
|
|||||||
import com.google.gerrit.client.WebLinkInfo;
|
import com.google.gerrit.client.WebLinkInfo;
|
||||||
import com.google.gerrit.client.changes.CommitMessageBlock;
|
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.diff.DiffApi;
|
import com.google.gerrit.client.diff.DiffApi;
|
||||||
import com.google.gerrit.client.diff.DiffInfo;
|
import com.google.gerrit.client.diff.DiffInfo;
|
||||||
import com.google.gerrit.client.projects.ConfigInfoCache;
|
import com.google.gerrit.client.projects.ConfigInfoCache;
|
||||||
@ -55,47 +54,11 @@ import com.google.gwtexpui.globalkey.client.KeyCommandSet;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class PatchScreen extends Screen implements
|
public class UnifiedPatchScreen extends Screen implements
|
||||||
CommentEditorContainer {
|
CommentEditorContainer {
|
||||||
static final PrettyFactory PRETTY = ClientSideFormatter.FACTORY;
|
static final PrettyFactory PRETTY = ClientSideFormatter.FACTORY;
|
||||||
static final short LARGE_FILE_CONTEXT = 100;
|
static final short LARGE_FILE_CONTEXT = 100;
|
||||||
|
|
||||||
public static class SideBySide extends PatchScreen {
|
|
||||||
public SideBySide(final Patch.Key id, final int patchIndex,
|
|
||||||
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
|
|
||||||
final TopView topView, final PatchSet.Id baseId) {
|
|
||||||
super(id, patchIndex, patchSetDetail, patchTable, topView, baseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SideBySideTable createContentTable() {
|
|
||||||
return new SideBySideTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PatchScreen.Type getPatchScreenType() {
|
|
||||||
return PatchScreen.Type.SIDE_BY_SIDE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Unified extends PatchScreen {
|
|
||||||
public Unified(final Patch.Key id, final int patchIndex,
|
|
||||||
final PatchSetDetail patchSetDetail, final PatchTable patchTable,
|
|
||||||
final TopView topView, final PatchSet.Id baseId) {
|
|
||||||
super(id, patchIndex, patchSetDetail, patchTable, topView, baseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected UnifiedDiffTable createContentTable() {
|
|
||||||
return new UnifiedDiffTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PatchScreen.Type getPatchScreenType() {
|
|
||||||
return PatchScreen.Type.UNIFIED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What should be displayed in the top of the screen
|
* What should be displayed in the top of the screen
|
||||||
*/
|
*/
|
||||||
@ -116,7 +79,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
private HistoryTable historyTable;
|
private HistoryTable historyTable;
|
||||||
private FlowPanel topPanel;
|
private FlowPanel topPanel;
|
||||||
private FlowPanel contentPanel;
|
private FlowPanel contentPanel;
|
||||||
private AbstractPatchContentTable contentTable;
|
private UnifiedDiffTable contentTable;
|
||||||
private CommitMessageBlock commitMessageBlock;
|
private CommitMessageBlock commitMessageBlock;
|
||||||
private NavLinks topNav;
|
private NavLinks topNav;
|
||||||
private NavLinks bottomNav;
|
private NavLinks bottomNav;
|
||||||
@ -137,24 +100,12 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
private boolean intralineFailure;
|
private boolean intralineFailure;
|
||||||
private boolean intralineTimeout;
|
private boolean intralineTimeout;
|
||||||
|
|
||||||
/**
|
public UnifiedPatchScreen(Patch.Key id, TopView top, PatchSet.Id baseId) {
|
||||||
* How this patch should be displayed in the patch screen.
|
|
||||||
*/
|
|
||||||
public static enum Type {
|
|
||||||
UNIFIED, SIDE_BY_SIDE
|
|
||||||
}
|
|
||||||
|
|
||||||
protected PatchScreen(final Patch.Key id, final int patchIndex,
|
|
||||||
final PatchSetDetail detail, final PatchTable patchTable,
|
|
||||||
final TopView top, final PatchSet.Id baseId) {
|
|
||||||
patchKey = id;
|
patchKey = id;
|
||||||
patchSetDetail = detail;
|
|
||||||
fileList = patchTable;
|
|
||||||
topView = top;
|
topView = top;
|
||||||
|
|
||||||
idSideA = baseId; // null here means we're diff'ing from the Base
|
idSideA = baseId; // null here means we're diff'ing from the Base
|
||||||
idSideB = id.getParentKey();
|
idSideB = id.getParentKey();
|
||||||
this.patchIndex = patchIndex;
|
|
||||||
|
|
||||||
prefs = fileList != null
|
prefs = fileList != null
|
||||||
? fileList.getPreferences()
|
? fileList.getPreferences()
|
||||||
@ -256,7 +207,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
topPanel = new FlowPanel();
|
topPanel = new FlowPanel();
|
||||||
add(topPanel);
|
add(topPanel);
|
||||||
|
|
||||||
contentTable = createContentTable();
|
contentTable = new UnifiedDiffTable();
|
||||||
contentTable.fileList = fileList;
|
contentTable.fileList = fileList;
|
||||||
|
|
||||||
topNav = new NavLinks(keysNavigation, patchKey.getParentKey());
|
topNav = new NavLinks(keysNavigation, patchKey.getParentKey());
|
||||||
@ -264,12 +215,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
|
|
||||||
add(topNav);
|
add(topNav);
|
||||||
contentPanel = new FlowPanel();
|
contentPanel = new FlowPanel();
|
||||||
if (getPatchScreenType() == PatchScreen.Type.SIDE_BY_SIDE) {
|
contentPanel.setStyleName(Gerrit.RESOURCES.css().unifiedTable());
|
||||||
contentPanel.setStyleName(//
|
|
||||||
Gerrit.RESOURCES.css().sideBySideScreenSideBySideTable());
|
|
||||||
} else {
|
|
||||||
contentPanel.setStyleName(Gerrit.RESOURCES.css().unifiedTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
contentPanel.add(contentTable);
|
contentPanel.add(contentTable);
|
||||||
add(contentPanel);
|
add(contentPanel);
|
||||||
@ -290,61 +236,29 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
.get(new GerritCallback<DiffInfo>() {
|
.get(new GerritCallback<DiffInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(DiffInfo diffInfo) {
|
public void onSuccess(DiffInfo diffInfo) {
|
||||||
topNav.display(patchIndex, getPatchScreenType(), fileList,
|
topNav.display(patchIndex, fileList,
|
||||||
getLinks(), getWebLinks(diffInfo));
|
getLinks(), getWebLinks(diffInfo));
|
||||||
bottomNav.display(patchIndex, getPatchScreenType(), fileList,
|
bottomNav.display(patchIndex, fileList,
|
||||||
getLinks(), getWebLinks(diffInfo));
|
getLinks(), getWebLinks(diffInfo));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<InlineHyperlink> getLinks() {
|
private List<InlineHyperlink> getLinks() {
|
||||||
if (contentTable instanceof SideBySideTable) {
|
InlineHyperlink toSideBySideDiffLink = new InlineHyperlink();
|
||||||
InlineHyperlink toUnifiedDiffLink = new InlineHyperlink();
|
toSideBySideDiffLink.setHTML(new ImageResourceRenderer().render(Gerrit.RESOURCES.sideBySideDiff()));
|
||||||
toUnifiedDiffLink.setHTML(new ImageResourceRenderer().render(Gerrit.RESOURCES.unifiedDiff()));
|
toSideBySideDiffLink.setTargetHistoryToken(getSideBySideDiffUrl());
|
||||||
toUnifiedDiffLink.setTargetHistoryToken(getUnifiedDiffUrl());
|
toSideBySideDiffLink.setTitle(PatchUtil.C.sideBySideDiff());
|
||||||
toUnifiedDiffLink.setTitle(PatchUtil.C.unifiedDiff());
|
return Collections.singletonList(toSideBySideDiffLink);
|
||||||
return Collections.singletonList(toUnifiedDiffLink);
|
|
||||||
} else if (contentTable instanceof UnifiedDiffTable) {
|
|
||||||
InlineHyperlink toSideBySideDiffLink = new InlineHyperlink();
|
|
||||||
toSideBySideDiffLink.setHTML(new ImageResourceRenderer().render(Gerrit.RESOURCES.sideBySideDiff()));
|
|
||||||
toSideBySideDiffLink.setTargetHistoryToken(getSideBySideDiffUrl());
|
|
||||||
toSideBySideDiffLink.setTitle(PatchUtil.C.sideBySideDiff());
|
|
||||||
return Collections.singletonList(toSideBySideDiffLink);
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("unknown table type: "
|
|
||||||
+ contentTable.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<WebLinkInfo> getWebLinks(DiffInfo diffInfo) {
|
private List<WebLinkInfo> getWebLinks(DiffInfo diffInfo) {
|
||||||
if (contentTable instanceof SideBySideTable) {
|
return diffInfo.unified_web_links();
|
||||||
return diffInfo.side_by_side_web_links();
|
|
||||||
} else if (contentTable instanceof UnifiedDiffTable) {
|
|
||||||
return diffInfo.unified_web_links();
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("unknown table type: "
|
|
||||||
+ contentTable.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSideBySideDiffUrl() {
|
private String getSideBySideDiffUrl() {
|
||||||
StringBuilder url = new StringBuilder();
|
return Dispatcher.toPatch("sidebyside", idSideA,
|
||||||
url.append("/c/");
|
new Patch.Key(idSideB, patchKey.getFileName()));
|
||||||
url.append(patchKey.getParentKey().getParentKey().get());
|
|
||||||
url.append("/");
|
|
||||||
if (idSideA != null) {
|
|
||||||
url.append(idSideA.get());
|
|
||||||
url.append("..");
|
|
||||||
}
|
|
||||||
url.append(idSideB.get());
|
|
||||||
url.append("/");
|
|
||||||
url.append(patchKey.getFileName());
|
|
||||||
return url.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getUnifiedDiffUrl() {
|
|
||||||
return getSideBySideDiffUrl() + ",unified";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -352,7 +266,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
super.onLoad();
|
super.onLoad();
|
||||||
|
|
||||||
if (patchSetDetail == null) {
|
if (patchSetDetail == null) {
|
||||||
Util.DETAIL_SVC.patchSetDetail(idSideB,
|
PatchUtil.CHANGE_SVC.patchSetDetail(idSideB,
|
||||||
new GerritCallback<PatchSetDetail>() {
|
new GerritCallback<PatchSetDetail>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(PatchSetDetail result) {
|
public void onSuccess(PatchSetDetail result) {
|
||||||
@ -405,10 +319,6 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract AbstractPatchContentTable createContentTable();
|
|
||||||
|
|
||||||
public abstract PatchScreen.Type getPatchScreenType();
|
|
||||||
|
|
||||||
public PatchSet.Id getSideA() {
|
public PatchSet.Id getSideA() {
|
||||||
return idSideA;
|
return idSideA;
|
||||||
}
|
}
|
||||||
@ -437,7 +347,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
final int rpcseq = ++rpcSequence;
|
final int rpcseq = ++rpcSequence;
|
||||||
lastScript = null;
|
lastScript = null;
|
||||||
settingsPanel.setEnabled(false);
|
settingsPanel.setEnabled(false);
|
||||||
reviewedPanels.populate(patchKey, fileList, patchIndex, getPatchScreenType());
|
reviewedPanels.populate(patchKey, fileList, patchIndex);
|
||||||
if (isFirst && fileList != null && fileList.isLoaded()) {
|
if (isFirst && fileList != null && fileList.isLoaded()) {
|
||||||
fileList.movePointerTo(patchKey);
|
fileList.movePointerTo(patchKey);
|
||||||
}
|
}
|
||||||
@ -457,7 +367,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
// Handled by ScreenLoadCallback.onFailure.
|
// Handled by ScreenLoadCallback.onFailure.
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
PatchUtil.DETAIL_SVC.patchScript(patchKey, idSideA, idSideB,
|
PatchUtil.PATCH_SVC.patchScript(patchKey, idSideA, idSideB,
|
||||||
settingsPanel.getValue(), cb.addFinal(
|
settingsPanel.getValue(), cb.addFinal(
|
||||||
new ScreenLoadCallback<PatchScript>(this) {
|
new ScreenLoadCallback<PatchScript>(this) {
|
||||||
@Override
|
@Override
|
||||||
@ -494,7 +404,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
commentLinkProcessor);
|
commentLinkProcessor);
|
||||||
} else {
|
} else {
|
||||||
commitMessageBlock.setVisible(false);
|
commitMessageBlock.setVisible(false);
|
||||||
Util.DETAIL_SVC.patchSetDetail(idSideB,
|
PatchUtil.CHANGE_SVC.patchSetDetail(idSideB,
|
||||||
new GerritCallback<PatchSetDetail>() {
|
new GerritCallback<PatchSetDetail>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(PatchSetDetail result) {
|
public void onSuccess(PatchSetDetail result) {
|
||||||
@ -516,22 +426,6 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentTable instanceof SideBySideTable
|
|
||||||
&& contentTable.isPureMetaChange(script)
|
|
||||||
&& !contentTable.isDisplayBinary) {
|
|
||||||
// User asked for SideBySide (or a link guessed, wrong) and we can't
|
|
||||||
// show a pure-rename change there accurately. Switch to
|
|
||||||
// the unified view instead. User can set file comments on binary file
|
|
||||||
// in SideBySide view.
|
|
||||||
//
|
|
||||||
contentTable.removeFromParent();
|
|
||||||
contentTable = new UnifiedDiffTable();
|
|
||||||
contentTable.fileList = fileList;
|
|
||||||
contentTable.setCommentLinkProcessor(commentLinkProcessor);
|
|
||||||
contentPanel.add(contentTable);
|
|
||||||
setToken(Dispatcher.toPatchUnified(idSideA, patchKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (script.isHugeFile()) {
|
if (script.isHugeFile()) {
|
||||||
AccountDiffPreference dp = script.getDiffPrefs();
|
AccountDiffPreference dp = script.getDiffPrefs();
|
||||||
int context = dp.getContext();
|
int context = dp.getContext();
|
||||||
@ -632,7 +526,7 @@ public abstract class PatchScreen extends Screen implements
|
|||||||
final PatchSet.Id psid = patchKey.getParentKey();
|
final PatchSet.Id psid = patchKey.getParentKey();
|
||||||
fileList = new PatchTable(prefs);
|
fileList = new PatchTable(prefs);
|
||||||
fileList.setSavePointerId("PatchTable " + psid);
|
fileList.setSavePointerId("PatchTable " + psid);
|
||||||
Util.DETAIL_SVC.patchSetDetail(psid,
|
PatchUtil.CHANGE_SVC.patchSetDetail(psid,
|
||||||
new GerritCallback<PatchSetDetail>() {
|
new GerritCallback<PatchSetDetail>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final PatchSetDetail result) {
|
public void onSuccess(final PatchSetDetail result) {
|
@ -1,42 +0,0 @@
|
|||||||
// Copyright (C) 2013 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.ui;
|
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gerrit.client.changes.ChangeDetailCache;
|
|
||||||
import com.google.gerrit.common.PageLinks;
|
|
||||||
import com.google.gerrit.common.data.ChangeDetail;
|
|
||||||
import com.google.gwt.user.client.ui.FocusWidget;
|
|
||||||
|
|
||||||
public abstract class ActionDialog extends CommentedActionDialog<ChangeDetail> {
|
|
||||||
public ActionDialog(final FocusWidget enableOnFailure, final boolean redirect,
|
|
||||||
String dialogTitle, String dialogHeading) {
|
|
||||||
super(dialogTitle, dialogHeading, new ChangeDetailCache.IgnoreErrorCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ChangeDetail result) {
|
|
||||||
if (redirect) {
|
|
||||||
Gerrit.display(PageLinks.toChange(result.getChange().getId()));
|
|
||||||
} else {
|
|
||||||
super.onSuccess(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableOnFailure.setEnabled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,6 @@ import com.google.gerrit.client.rpc.Natives;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.FocusWidget;
|
|
||||||
import com.google.gwt.user.client.ui.SuggestBox;
|
import com.google.gwt.user.client.ui.SuggestBox;
|
||||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
@ -32,12 +31,12 @@ import com.google.gwtexpui.safehtml.client.HighlightSuggestOracle;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class CherryPickDialog extends ActionDialog {
|
public abstract class CherryPickDialog extends CommentedActionDialog {
|
||||||
private SuggestBox newBranch;
|
private SuggestBox newBranch;
|
||||||
private List<BranchInfo> branches;
|
private List<BranchInfo> branches;
|
||||||
|
|
||||||
public CherryPickDialog(final FocusWidget enableOnFailure, Project.NameKey project) {
|
public CherryPickDialog(Project.NameKey project) {
|
||||||
super(enableOnFailure, true, Util.C.cherryPickTitle(), Util.C
|
super(Util.C.cherryPickTitle(), Util.C
|
||||||
.cherryPickCommitMessage());
|
.cherryPickCommitMessage());
|
||||||
ProjectApi.getBranches(project,
|
ProjectApi.getBranches(project,
|
||||||
new GerritCallback<JsArray<BranchInfo>>() {
|
new GerritCallback<JsArray<BranchInfo>>() {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.client.ui;
|
package com.google.gerrit.client.ui;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.logical.shared.CloseEvent;
|
import com.google.gwt.event.logical.shared.CloseEvent;
|
||||||
@ -27,24 +26,20 @@ import com.google.gwt.user.client.ui.PopupPanel;
|
|||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
import com.google.gwtexpui.globalkey.client.NpTextArea;
|
import com.google.gwtexpui.globalkey.client.NpTextArea;
|
||||||
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
|
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
|
||||||
|
|
||||||
public abstract class CommentedActionDialog<T> extends AutoCenterDialogBox
|
public abstract class CommentedActionDialog extends AutoCenterDialogBox
|
||||||
implements CloseHandler<PopupPanel> {
|
implements CloseHandler<PopupPanel> {
|
||||||
protected final FlowPanel panel;
|
protected final FlowPanel panel;
|
||||||
protected final NpTextArea message;
|
protected final NpTextArea message;
|
||||||
protected final Button sendButton;
|
protected final Button sendButton;
|
||||||
protected final Button cancelButton;
|
protected final Button cancelButton;
|
||||||
protected final FlowPanel buttonPanel;
|
protected final FlowPanel buttonPanel;
|
||||||
protected AsyncCallback<T> callback;
|
|
||||||
protected FocusWidget focusOn;
|
protected FocusWidget focusOn;
|
||||||
|
|
||||||
protected boolean sent = false;
|
protected boolean sent = false;
|
||||||
|
|
||||||
public CommentedActionDialog(final String title, final String heading,
|
public CommentedActionDialog(final String title, final String heading) {
|
||||||
AsyncCallback<T> callback) {
|
|
||||||
super(/* auto hide */false, /* modal */true);
|
super(/* auto hide */false, /* modal */true);
|
||||||
this.callback = callback;
|
|
||||||
setGlassEnabled(true);
|
setGlassEnabled(true);
|
||||||
setText(title);
|
setText(title);
|
||||||
|
|
||||||
@ -111,13 +106,6 @@ public abstract class CommentedActionDialog<T> extends AutoCenterDialogBox
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(CloseEvent<PopupPanel> event) {
|
public void onClose(CloseEvent<PopupPanel> event) {
|
||||||
if (!sent) {
|
|
||||||
// the dialog was closed without the send button being pressed
|
|
||||||
// e.g. the user pressed Cancel or ESC to close the dialog
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onFailure(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sent = false;
|
sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,23 +114,4 @@ public abstract class CommentedActionDialog<T> extends AutoCenterDialogBox
|
|||||||
public String getMessageText() {
|
public String getMessageText() {
|
||||||
return message.getText().trim();
|
return message.getText().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncCallback<T> createCallback() {
|
|
||||||
return new GerritCallback<T>(){
|
|
||||||
@Override
|
|
||||||
public void onSuccess(T result) {
|
|
||||||
sent = true;
|
|
||||||
if (callback != null) {
|
|
||||||
callback.onSuccess(result);
|
|
||||||
}
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
enableButtons(true);
|
|
||||||
super.onFailure(caught);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import com.google.gerrit.reviewdb.client.Branch;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gwt.core.client.JsArray;
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.FocusWidget;
|
|
||||||
import com.google.gwt.user.client.ui.SuggestBox;
|
import com.google.gwt.user.client.ui.SuggestBox;
|
||||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||||
@ -32,12 +31,12 @@ import com.google.gwtexpui.safehtml.client.HighlightSuggestOracle;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class CreateChangeDialog extends ActionDialog {
|
public abstract class CreateChangeDialog extends CommentedActionDialog {
|
||||||
private SuggestBox newChange;
|
private SuggestBox newChange;
|
||||||
private List<BranchInfo> branches;
|
private List<BranchInfo> branches;
|
||||||
|
|
||||||
public CreateChangeDialog(final FocusWidget enableOnFailure, Project.NameKey project) {
|
public CreateChangeDialog(Project.NameKey project) {
|
||||||
super(enableOnFailure, true, Util.C.dialogCreateChangeTitle(),
|
super(Util.C.dialogCreateChangeTitle(),
|
||||||
Util.C.dialogCreateChangeHeading());
|
Util.C.dialogCreateChangeHeading());
|
||||||
ProjectApi.getBranches(project,
|
ProjectApi.getBranches(project,
|
||||||
new GerritCallback<JsArray<BranchInfo>>() {
|
new GerritCallback<JsArray<BranchInfo>>() {
|
||||||
|
@ -15,90 +15,23 @@
|
|||||||
package com.google.gerrit.client.ui;
|
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.patches.PatchScreen;
|
|
||||||
import com.google.gerrit.common.data.PatchSetDetail;
|
|
||||||
import com.google.gerrit.reviewdb.client.Patch;
|
import com.google.gerrit.reviewdb.client.Patch;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
|
|
||||||
public class PatchLink extends InlineHyperlink {
|
public class PatchLink extends InlineHyperlink {
|
||||||
protected PatchSet.Id base;
|
private PatchLink(String text, String historyToken) {
|
||||||
protected Patch.Key patchKey;
|
|
||||||
protected int patchIndex;
|
|
||||||
protected PatchSetDetail patchSetDetail;
|
|
||||||
protected PatchTable parentPatchTable;
|
|
||||||
protected PatchScreen.TopView topView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param text The text of this link
|
|
||||||
* @param base optional base to compare against.
|
|
||||||
* @param patchKey The key for this patch
|
|
||||||
* @param patchIndex The index of the current patch in the patch set
|
|
||||||
* @param historyToken The history token
|
|
||||||
* @param patchSetDetail Detailed information about the patch set.
|
|
||||||
* @param parentPatchTable The table used to display this link
|
|
||||||
*/
|
|
||||||
protected PatchLink(String text, PatchSet.Id base, Patch.Key patchKey,
|
|
||||||
int patchIndex, String historyToken,
|
|
||||||
PatchSetDetail patchSetDetail, PatchTable parentPatchTable,
|
|
||||||
PatchScreen.TopView topView) {
|
|
||||||
super(text, historyToken);
|
super(text, historyToken);
|
||||||
this.base = base;
|
|
||||||
this.patchKey = patchKey;
|
|
||||||
this.patchIndex = patchIndex;
|
|
||||||
this.patchSetDetail = patchSetDetail;
|
|
||||||
this.parentPatchTable = parentPatchTable;
|
|
||||||
this.parentPatchTable = parentPatchTable;
|
|
||||||
this.topView = topView;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param text The text of this link
|
|
||||||
* @param type The type of the link to create (unified/side-by-side)
|
|
||||||
* @param patchScreen The patchScreen to grab contents to link to from
|
|
||||||
*/
|
|
||||||
public PatchLink(String text, PatchScreen.Type type, PatchScreen patchScreen) {
|
|
||||||
this(text, //
|
|
||||||
patchScreen.getSideA(), //
|
|
||||||
patchScreen.getPatchKey(), //
|
|
||||||
patchScreen.getPatchIndex(), //
|
|
||||||
Dispatcher.toPatch(type, patchScreen.getPatchKey()), //
|
|
||||||
patchScreen.getPatchSetDetail(), //
|
|
||||||
patchScreen.getFileList(), //
|
|
||||||
patchScreen.getTopView() //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void go() {
|
|
||||||
Dispatcher.patch( //
|
|
||||||
getTargetHistoryToken(), //
|
|
||||||
base, //
|
|
||||||
patchKey, //
|
|
||||||
patchIndex, //
|
|
||||||
patchSetDetail, //
|
|
||||||
parentPatchTable,
|
|
||||||
topView //
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SideBySide extends PatchLink {
|
public static class SideBySide extends PatchLink {
|
||||||
public SideBySide(String text, PatchSet.Id base, Patch.Key patchKey,
|
public SideBySide(String text, PatchSet.Id base, Patch.Key id) {
|
||||||
int patchIndex, PatchSetDetail patchSetDetail,
|
super(text, Dispatcher.toSideBySide(base, id));
|
||||||
PatchTable parentPatchTable) {
|
|
||||||
super(text, base, patchKey, patchIndex,
|
|
||||||
Dispatcher.toPatchSideBySide(base, patchKey),
|
|
||||||
patchSetDetail, parentPatchTable, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Unified extends PatchLink {
|
public static class Unified extends PatchLink {
|
||||||
public Unified(String text, PatchSet.Id base, final Patch.Key patchKey,
|
public Unified(String text, PatchSet.Id base, Patch.Key id) {
|
||||||
int patchIndex, PatchSetDetail patchSetDetail,
|
super(text, Dispatcher.toUnified(base, id));
|
||||||
PatchTable parentPatchTable) {
|
|
||||||
super(text, base, patchKey, patchIndex,
|
|
||||||
Dispatcher.toPatchUnified(base, patchKey),
|
|
||||||
patchSetDetail, parentPatchTable, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.gerrit.common.data.GerritConfig;
|
import com.google.gerrit.common.data.GerritConfig;
|
||||||
import com.google.gerrit.common.data.GitwebConfig;
|
import com.google.gerrit.common.data.GitwebConfig;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.server.account.Realm;
|
import com.google.gerrit.server.account.Realm;
|
||||||
import com.google.gerrit.server.change.ArchiveFormat;
|
import com.google.gerrit.server.change.ArchiveFormat;
|
||||||
import com.google.gerrit.server.change.GetArchive;
|
import com.google.gerrit.server.change.GetArchive;
|
||||||
@ -133,9 +132,6 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
|||||||
config.setSuggestFrom(cfg.getInt("suggest", "from", 0));
|
config.setSuggestFrom(cfg.getInt("suggest", "from", 0));
|
||||||
config.setChangeUpdateDelay((int) ConfigUtil.getTimeUnit(
|
config.setChangeUpdateDelay((int) ConfigUtil.getTimeUnit(
|
||||||
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS));
|
cfg, "change", null, "updateDelay", 30, TimeUnit.SECONDS));
|
||||||
config.setChangeScreen(cfg.getEnum(
|
|
||||||
"gerrit", null, "changeScreen",
|
|
||||||
AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2));
|
|
||||||
config.setLargeChangeSize(cfg.getInt("change", "largeChange", 500));
|
config.setLargeChangeSize(cfg.getInt("change", "largeChange", 500));
|
||||||
config.setArchiveFormats(Lists.newArrayList(Iterables.transform(
|
config.setArchiveFormats(Lists.newArrayList(Iterables.transform(
|
||||||
archiveFormats.getAllowed(),
|
archiveFormats.getAllowed(),
|
||||||
|
@ -68,13 +68,6 @@ public final class AccountGeneralPreferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum CommentVisibilityStrategy {
|
|
||||||
COLLAPSE_ALL,
|
|
||||||
EXPAND_MOST_RECENT,
|
|
||||||
EXPAND_RECENT,
|
|
||||||
EXPAND_ALL
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum ReviewCategoryStrategy {
|
public static enum ReviewCategoryStrategy {
|
||||||
NONE,
|
NONE,
|
||||||
NAME,
|
NAME,
|
||||||
@ -88,11 +81,6 @@ public final class AccountGeneralPreferences {
|
|||||||
UNIFIED_DIFF
|
UNIFIED_DIFF
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum ChangeScreen {
|
|
||||||
OLD_UI,
|
|
||||||
CHANGE_SCREEN2
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum TimeFormat {
|
public static enum TimeFormat {
|
||||||
/** 12-hour clock: 1:15 am, 2:13 pm */
|
/** 12-hour clock: 1:15 am, 2:13 pm */
|
||||||
HHMM_12("h:mm a"),
|
HHMM_12("h:mm a"),
|
||||||
@ -147,26 +135,18 @@ public final class AccountGeneralPreferences {
|
|||||||
@Column(id = 9, length = 10, notNull = false)
|
@Column(id = 9, length = 10, notNull = false)
|
||||||
protected String timeFormat;
|
protected String timeFormat;
|
||||||
|
|
||||||
/**
|
// DELETED: id = 10 (reversePatchSetOrder)
|
||||||
* If true display the patch sets in the ChangeScreen in reverse order
|
|
||||||
* (show latest patch set on top).
|
|
||||||
*/
|
|
||||||
@Column(id = 10)
|
|
||||||
protected boolean reversePatchSetOrder;
|
|
||||||
|
|
||||||
// DELETED: id = 11 (showUserInReview)
|
// DELETED: id = 11 (showUserInReview)
|
||||||
|
|
||||||
@Column(id = 12)
|
@Column(id = 12)
|
||||||
protected boolean relativeDateInChangeTable;
|
protected boolean relativeDateInChangeTable;
|
||||||
|
|
||||||
@Column(id = 13, length = 20, notNull = false)
|
// DELETED: id = 13 (commentVisibilityStrategy)
|
||||||
protected String commentVisibilityStrategy;
|
|
||||||
|
|
||||||
@Column(id = 14, length = 20, notNull = false)
|
@Column(id = 14, length = 20, notNull = false)
|
||||||
protected String diffView;
|
protected String diffView;
|
||||||
|
|
||||||
@Column(id = 15, length = 20, notNull = false)
|
// DELETED: id = 15 (changeScreen)
|
||||||
protected String changeScreen;
|
|
||||||
|
|
||||||
@Column(id = 16)
|
@Column(id = 16)
|
||||||
protected boolean sizeBarInChangeTable;
|
protected boolean sizeBarInChangeTable;
|
||||||
@ -242,14 +222,6 @@ public final class AccountGeneralPreferences {
|
|||||||
copySelfOnEmail = includeSelfOnEmail;
|
copySelfOnEmail = includeSelfOnEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReversePatchSetOrder() {
|
|
||||||
return reversePatchSetOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReversePatchSetOrder(final boolean reversePatchSetOrder) {
|
|
||||||
this.reversePatchSetOrder = reversePatchSetOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShowInfoInReviewCategory() {
|
public boolean isShowInfoInReviewCategory() {
|
||||||
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
return getReviewCategoryStrategy() != ReviewCategoryStrategy.NONE;
|
||||||
}
|
}
|
||||||
@ -296,18 +268,6 @@ public final class AccountGeneralPreferences {
|
|||||||
reviewCategoryStrategy = strategy.name();
|
reviewCategoryStrategy = strategy.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommentVisibilityStrategy getCommentVisibilityStrategy() {
|
|
||||||
if (commentVisibilityStrategy == null) {
|
|
||||||
return CommentVisibilityStrategy.EXPAND_RECENT;
|
|
||||||
}
|
|
||||||
return CommentVisibilityStrategy.valueOf(commentVisibilityStrategy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommentVisibilityStrategy(
|
|
||||||
CommentVisibilityStrategy strategy) {
|
|
||||||
commentVisibilityStrategy = strategy.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiffView getDiffView() {
|
public DiffView getDiffView() {
|
||||||
if (diffView == null) {
|
if (diffView == null) {
|
||||||
return DiffView.SIDE_BY_SIDE;
|
return DiffView.SIDE_BY_SIDE;
|
||||||
@ -319,14 +279,6 @@ public final class AccountGeneralPreferences {
|
|||||||
this.diffView = diffView.name();
|
this.diffView = diffView.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeScreen getChangeScreen() {
|
|
||||||
return changeScreen != null ? ChangeScreen.valueOf(changeScreen) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChangeScreen(ChangeScreen ui) {
|
|
||||||
changeScreen = ui != null ? ui.name() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSizeBarInChangeTable() {
|
public boolean isSizeBarInChangeTable() {
|
||||||
return sizeBarInChangeTable;
|
return sizeBarInChangeTable;
|
||||||
}
|
}
|
||||||
@ -348,16 +300,13 @@ public final class AccountGeneralPreferences {
|
|||||||
showSiteHeader = true;
|
showSiteHeader = true;
|
||||||
useFlashClipboard = true;
|
useFlashClipboard = true;
|
||||||
copySelfOnEmail = false;
|
copySelfOnEmail = false;
|
||||||
reversePatchSetOrder = false;
|
|
||||||
reviewCategoryStrategy = null;
|
reviewCategoryStrategy = null;
|
||||||
downloadUrl = null;
|
downloadUrl = null;
|
||||||
downloadCommand = null;
|
downloadCommand = null;
|
||||||
dateFormat = null;
|
dateFormat = null;
|
||||||
timeFormat = null;
|
timeFormat = null;
|
||||||
relativeDateInChangeTable = false;
|
relativeDateInChangeTable = false;
|
||||||
commentVisibilityStrategy = null;
|
|
||||||
diffView = null;
|
diffView = null;
|
||||||
changeScreen = null;
|
|
||||||
sizeBarInChangeTable = true;
|
sizeBarInChangeTable = true;
|
||||||
legacycidInChangeTable = false;
|
legacycidInChangeTable = false;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
|||||||
import com.google.gerrit.extensions.webui.TopMenu;
|
import com.google.gerrit.extensions.webui.TopMenu;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ChangeScreen;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
@ -108,14 +106,11 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
Boolean copySelfOnEmail;
|
Boolean copySelfOnEmail;
|
||||||
DateFormat dateFormat;
|
DateFormat dateFormat;
|
||||||
TimeFormat timeFormat;
|
TimeFormat timeFormat;
|
||||||
Boolean reversePatchSetOrder;
|
|
||||||
Boolean relativeDateInChangeTable;
|
Boolean relativeDateInChangeTable;
|
||||||
Boolean sizeBarInChangeTable;
|
Boolean sizeBarInChangeTable;
|
||||||
Boolean legacycidInChangeTable;
|
Boolean legacycidInChangeTable;
|
||||||
ReviewCategoryStrategy reviewCategoryStrategy;
|
ReviewCategoryStrategy reviewCategoryStrategy;
|
||||||
CommentVisibilityStrategy commentVisibilityStrategy;
|
|
||||||
DiffView diffView;
|
DiffView diffView;
|
||||||
ChangeScreen changeScreen;
|
|
||||||
List<TopMenu.MenuItem> my;
|
List<TopMenu.MenuItem> my;
|
||||||
|
|
||||||
public PreferenceInfo(AccountGeneralPreferences p,
|
public PreferenceInfo(AccountGeneralPreferences p,
|
||||||
@ -129,14 +124,11 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
copySelfOnEmail = p.isCopySelfOnEmails() ? true : null;
|
copySelfOnEmail = p.isCopySelfOnEmails() ? true : null;
|
||||||
dateFormat = p.getDateFormat();
|
dateFormat = p.getDateFormat();
|
||||||
timeFormat = p.getTimeFormat();
|
timeFormat = p.getTimeFormat();
|
||||||
reversePatchSetOrder = p.isReversePatchSetOrder() ? true : null;
|
|
||||||
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
||||||
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
|
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
|
||||||
legacycidInChangeTable = p.isLegacycidInChangeTable() ? true : null;
|
legacycidInChangeTable = p.isLegacycidInChangeTable() ? true : null;
|
||||||
reviewCategoryStrategy = p.getReviewCategoryStrategy();
|
reviewCategoryStrategy = p.getReviewCategoryStrategy();
|
||||||
commentVisibilityStrategy = p.getCommentVisibilityStrategy();
|
|
||||||
diffView = p.getDiffView();
|
diffView = p.getDiffView();
|
||||||
changeScreen = p.getChangeScreen();
|
|
||||||
}
|
}
|
||||||
my = my(v, allUsers);
|
my = my(v, allUsers);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
|||||||
import com.google.gerrit.extensions.webui.TopMenu;
|
import com.google.gerrit.extensions.webui.TopMenu;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.ChangeScreen;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DateFormat;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DiffView;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
|
||||||
@ -62,14 +60,11 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
public Boolean copySelfOnEmail;
|
public Boolean copySelfOnEmail;
|
||||||
public DateFormat dateFormat;
|
public DateFormat dateFormat;
|
||||||
public TimeFormat timeFormat;
|
public TimeFormat timeFormat;
|
||||||
public Boolean reversePatchSetOrder;
|
|
||||||
public Boolean relativeDateInChangeTable;
|
public Boolean relativeDateInChangeTable;
|
||||||
public Boolean sizeBarInChangeTable;
|
public Boolean sizeBarInChangeTable;
|
||||||
public Boolean legacycidInChangeTable;
|
public Boolean legacycidInChangeTable;
|
||||||
public CommentVisibilityStrategy commentVisibilityStrategy;
|
|
||||||
public ReviewCategoryStrategy reviewCategoryStrategy;
|
public ReviewCategoryStrategy reviewCategoryStrategy;
|
||||||
public DiffView diffView;
|
public DiffView diffView;
|
||||||
public ChangeScreen changeScreen;
|
|
||||||
public List<TopMenu.MenuItem> my;
|
public List<TopMenu.MenuItem> my;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,9 +141,6 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
if (i.timeFormat != null) {
|
if (i.timeFormat != null) {
|
||||||
p.setTimeFormat(i.timeFormat);
|
p.setTimeFormat(i.timeFormat);
|
||||||
}
|
}
|
||||||
if (i.reversePatchSetOrder != null) {
|
|
||||||
p.setReversePatchSetOrder(i.reversePatchSetOrder);
|
|
||||||
}
|
|
||||||
if (i.relativeDateInChangeTable != null) {
|
if (i.relativeDateInChangeTable != null) {
|
||||||
p.setRelativeDateInChangeTable(i.relativeDateInChangeTable);
|
p.setRelativeDateInChangeTable(i.relativeDateInChangeTable);
|
||||||
}
|
}
|
||||||
@ -161,15 +153,9 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
if (i.reviewCategoryStrategy != null) {
|
if (i.reviewCategoryStrategy != null) {
|
||||||
p.setReviewCategoryStrategy(i.reviewCategoryStrategy);
|
p.setReviewCategoryStrategy(i.reviewCategoryStrategy);
|
||||||
}
|
}
|
||||||
if (i.commentVisibilityStrategy != null) {
|
|
||||||
p.setCommentVisibilityStrategy(i.commentVisibilityStrategy);
|
|
||||||
}
|
|
||||||
if (i.diffView != null) {
|
if (i.diffView != null) {
|
||||||
p.setDiffView(i.diffView);
|
p.setDiffView(i.diffView);
|
||||||
}
|
}
|
||||||
if (i.changeScreen != null) {
|
|
||||||
p.setChangeScreen(i.changeScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.get().accounts().update(Collections.singleton(a));
|
db.get().accounts().update(Collections.singleton(a));
|
||||||
db.get().commit();
|
db.get().commit();
|
||||||
|
@ -49,13 +49,10 @@ public class SetPreferences implements RestModifyView<ConfigResource, Input> {
|
|||||||
|| i.useFlashClipboard != null || i.downloadScheme != null
|
|| i.useFlashClipboard != null || i.downloadScheme != null
|
||||||
|| i.downloadCommand != null || i.copySelfOnEmail != null
|
|| i.downloadCommand != null || i.copySelfOnEmail != null
|
||||||
|| i.dateFormat != null || i.timeFormat != null
|
|| i.dateFormat != null || i.timeFormat != null
|
||||||
|| i.reversePatchSetOrder != null
|
|
||||||
|| i.relativeDateInChangeTable != null
|
|| i.relativeDateInChangeTable != null
|
||||||
|| i.sizeBarInChangeTable != null
|
|| i.sizeBarInChangeTable != null
|
||||||
|| i.legacycidInChangeTable != null
|
|| i.legacycidInChangeTable != null
|
||||||
|| i.reviewCategoryStrategy != null
|
|| i.reviewCategoryStrategy != null) {
|
||||||
|| i.commentVisibilityStrategy != null || i.diffView != null
|
|
||||||
|| i.changeScreen != null) {
|
|
||||||
throw new BadRequestException("unsupported option");
|
throw new BadRequestException("unsupported option");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
/** A version of the database schema. */
|
/** A version of the database schema. */
|
||||||
public abstract class SchemaVersion {
|
public abstract class SchemaVersion {
|
||||||
/** The current schema version. */
|
/** The current schema version. */
|
||||||
public static final Class<Schema_103> C = Schema_103.class;
|
public static final Class<Schema_104> C = Schema_104.class;
|
||||||
|
|
||||||
public static int getBinaryVersion() {
|
public static int getBinaryVersion() {
|
||||||
return guessVersion(C);
|
return guessVersion(C);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2010 The Android Open Source Project
|
// Copyright (C) 2015 The Android Open Source Project
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -12,15 +12,16 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.gerrit.client.changes;
|
package com.google.gerrit.server.schema;
|
||||||
|
|
||||||
import com.google.gwt.resources.client.ClientBundle;
|
import com.google.inject.Inject;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
public interface ChangeResources extends ClientBundle {
|
public class Schema_104 extends SchemaVersion {
|
||||||
@Source("removeReviewerNormal.png")
|
@Inject
|
||||||
public ImageResource removeReviewerNormal();
|
Schema_104(Provider<Schema_103> prior) {
|
||||||
|
super(prior);
|
||||||
|
}
|
||||||
|
|
||||||
@Source("removeReviewerPressed.png")
|
// Remove old change screen
|
||||||
public ImageResource removeReviewerPressed();
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user