Merge "Link to owner query from user name"

This commit is contained in:
Edwin Kempin
2012-05-10 16:46:58 -07:00
committed by gerrit code review
6 changed files with 26 additions and 27 deletions

View File

@@ -17,8 +17,8 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AddMemberBox;
import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.Hyperlink;
@@ -286,7 +286,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
CheckBox checkBox = new CheckBox();
table.setWidget(row, 1, checkBox);
checkBox.setEnabled(enabled);
table.setWidget(row, 2, AccountDashboardLink.link(accounts, accountId));
table.setWidget(row, 2, AccountLink.link(accounts, accountId));
table.setText(row, 3, accounts.get(accountId).getPreferredEmail());
final FlexCellFormatter fmt = table.getFlexCellFormatter();

View File

@@ -21,7 +21,7 @@ import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AddMemberBox;
import com.google.gerrit.client.ui.ReviewerSuggestOracle;
import com.google.gerrit.common.data.AccountInfoCache;
@@ -129,8 +129,8 @@ public class ApprovalTable extends Composite {
accountCache = aic;
}
private AccountDashboardLink link(final Account.Id id) {
return AccountDashboardLink.link(accountCache, id);
private AccountLink link(final Account.Id id) {
return AccountLink.link(accountCache, id);
}
void display(ChangeDetail detail) {

View File

@@ -17,7 +17,7 @@ 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.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.ProjectLink;
@@ -92,7 +92,7 @@ public class ChangeInfoBlock extends Composite {
changeIdLabel.setPreviewText(chg.getKey().get());
table.setWidget(R_CHANGE_ID, 1, changeIdLabel);
table.setWidget(R_OWNER, 1, AccountDashboardLink.link(acc, chg.getOwner()));
table.setWidget(R_OWNER, 1, AccountLink.link(acc, chg.getOwner()));
table.setWidget(R_PROJECT, 1, new ProjectLink(chg.getProject(), chg.getStatus()));
table.setWidget(R_BRANCH, 1, new BranchLink(dst.getShortName(), chg
.getProject(), chg.getStatus(), dst.get(), null));

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.NavigationTable;
@@ -226,8 +226,8 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
setRowItem(row, c);
}
private AccountDashboardLink link(final Account.Id id) {
return AccountDashboardLink.link(accountCache, id);
private AccountLink link(final Account.Id id) {
return AccountLink.link(accountCache, id);
}
public void addSection(final Section s) {

View File

@@ -20,9 +20,9 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.CommentedActionDialog;
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
import com.google.gerrit.client.ui.InlineHyperlink;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ChangeDetail;
@@ -383,7 +383,8 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
if (who.getName() != null) {
final Account.Id aId = who.getAccount();
if (aId != null) {
fp.add(new AccountDashboardLink(who.getName(), aId));
fp.add(new InlineHyperlink(who.getName(), PageLinks.toAccountQuery(who
.getName())));
} else {
final InlineLabel lbl = new InlineLabel(who.getName());
lbl.setStyleName(Gerrit.RESOURCES.css().accountName());

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2008 The Android Open Source Project
// 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.
@@ -16,41 +16,39 @@ package com.google.gerrit.client.ui;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.AccountDashboardScreen;
import com.google.gerrit.client.changes.QueryScreen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.reviewdb.client.Account;
/** Link to any user's account dashboard. */
public class AccountDashboardLink extends InlineHyperlink {
public class AccountLink extends InlineHyperlink {
/** Create a link after locating account details from an active cache. */
public static AccountDashboardLink link(final AccountInfoCache cache,
public static AccountLink link(final AccountInfoCache cache,
final Account.Id id) {
final AccountInfo ai = cache.get(id);
return ai != null ? new AccountDashboardLink(ai) : null;
return ai != null ? new AccountLink(ai) : null;
}
private Account.Id accountId;
private final String query;
public AccountDashboardLink(final AccountInfo ai) {
public AccountLink(final AccountInfo ai) {
this(FormatUtil.name(ai), ai);
}
public AccountDashboardLink(final String text, final AccountInfo ai) {
this(text, ai.getId());
public AccountLink(final String text, final AccountInfo ai) {
super(text, PageLinks.toAccountQuery(FormatUtil.name(ai)));
setTitle(FormatUtil.nameEmail(ai));
this.query = "owner:\"" + FormatUtil.name(ai) + "\"";
}
public AccountDashboardLink(final String text, final Account.Id ai) {
super(text, PageLinks.toAccountDashboard(ai));
addStyleName(Gerrit.RESOURCES.css().accountName());
accountId = ai;
private Screen createScreen() {
return QueryScreen.forQuery(query);
}
@Override
public void go() {
Gerrit.display(getTargetHistoryToken(), //
new AccountDashboardScreen(accountId));
Gerrit.display(getTargetHistoryToken(), createScreen());
}
}