Move project and settings tabs to left side

Instead of using a GWT TabPanel to show the project and settings tabs,
move them onto the left as part of a vertically stacked menu.  This
just looks cleaner, and helps us to avoid ultra wide windows in the
settings area as the number of tabs keeps increasing.

While we are doing the UI refactoring, make each section proper top
level screen objects.  This makes it far easier to ensure the data is
loaded in the background before the UI gets displayed, which removes
some of the display jitter you see as you navigate to a section.

This also nicely fixes some table UI layout glitches that were caused
by the TabPanel forcing our content width to 100% even though we
didn't want that.

Change-Id: I5da0dadddc2746206852a0873d6014051bd9f6dc
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-07-14 20:22:22 -07:00
parent 14bedca306
commit 270c5941d4
28 changed files with 534 additions and 479 deletions

View File

@@ -24,6 +24,7 @@ import com.google.gwtorm.client.KeyUtil;
public class PageLinks { public class PageLinks {
public static final String SETTINGS = "settings"; public static final String SETTINGS = "settings";
public static final String SETTINGS_PREFERENCES = "settings,preferences";
public static final String SETTINGS_SSHKEYS = "settings,ssh-keys"; public static final String SETTINGS_SSHKEYS = "settings,ssh-keys";
public static final String SETTINGS_WEBIDENT = "settings,web-identities"; public static final String SETTINGS_WEBIDENT = "settings,web-identities";
public static final String SETTINGS_MYGROUPS = "settings,group-memberships"; public static final String SETTINGS_MYGROUPS = "settings,group-memberships";

View File

@@ -21,25 +21,40 @@ import static com.google.gerrit.common.PageLinks.MINE_DRAFTS;
import static com.google.gerrit.common.PageLinks.MINE_STARRED; import static com.google.gerrit.common.PageLinks.MINE_STARRED;
import static com.google.gerrit.common.PageLinks.REGISTER; import static com.google.gerrit.common.PageLinks.REGISTER;
import static com.google.gerrit.common.PageLinks.SETTINGS; import static com.google.gerrit.common.PageLinks.SETTINGS;
import static com.google.gerrit.common.PageLinks.SETTINGS_AGREEMENTS;
import static com.google.gerrit.common.PageLinks.SETTINGS_CONTACT;
import static com.google.gerrit.common.PageLinks.SETTINGS_MYGROUPS;
import static com.google.gerrit.common.PageLinks.SETTINGS_NEW_AGREEMENT; import static com.google.gerrit.common.PageLinks.SETTINGS_NEW_AGREEMENT;
import static com.google.gerrit.common.PageLinks.SETTINGS_PREFERENCES;
import static com.google.gerrit.common.PageLinks.SETTINGS_PROJECTS;
import static com.google.gerrit.common.PageLinks.SETTINGS_SSHKEYS;
import static com.google.gerrit.common.PageLinks.SETTINGS_WEBIDENT; import static com.google.gerrit.common.PageLinks.SETTINGS_WEBIDENT;
import static com.google.gerrit.common.PageLinks.TOP; import static com.google.gerrit.common.PageLinks.TOP;
import com.google.gerrit.client.account.AccountSettings; import com.google.gerrit.client.account.MyAgreementsScreen;
import com.google.gerrit.client.account.MyContactInformationScreen;
import com.google.gerrit.client.account.MyGroupsScreen;
import com.google.gerrit.client.account.MyIdentitiesScreen;
import com.google.gerrit.client.account.MyPreferencesScreen;
import com.google.gerrit.client.account.MyProfileScreen;
import com.google.gerrit.client.account.MySshKeysScreen;
import com.google.gerrit.client.account.MyWatchedProjectsScreen;
import com.google.gerrit.client.account.NewAgreementScreen; import com.google.gerrit.client.account.NewAgreementScreen;
import com.google.gerrit.client.account.RegisterScreen; import com.google.gerrit.client.account.RegisterScreen;
import com.google.gerrit.client.account.ValidateEmailScreen; import com.google.gerrit.client.account.ValidateEmailScreen;
import com.google.gerrit.client.admin.AccountGroupScreen; import com.google.gerrit.client.admin.AccountGroupScreen;
import com.google.gerrit.client.admin.GroupListScreen; import com.google.gerrit.client.admin.GroupListScreen;
import com.google.gerrit.client.admin.ProjectAdminScreen; import com.google.gerrit.client.admin.ProjectAccessScreen;
import com.google.gerrit.client.admin.ProjectBranchesScreen;
import com.google.gerrit.client.admin.ProjectInfoScreen;
import com.google.gerrit.client.admin.ProjectListScreen; import com.google.gerrit.client.admin.ProjectListScreen;
import com.google.gerrit.client.admin.ProjectScreen;
import com.google.gerrit.client.auth.openid.OpenIdSignInDialog; import com.google.gerrit.client.auth.openid.OpenIdSignInDialog;
import com.google.gerrit.client.auth.userpass.UserPassSignInDialog; import com.google.gerrit.client.auth.userpass.UserPassSignInDialog;
import com.google.gerrit.client.changes.AccountDashboardScreen; import com.google.gerrit.client.changes.AccountDashboardScreen;
import com.google.gerrit.client.changes.AllAbandonedChangesScreen; import com.google.gerrit.client.changes.AllAbandonedChangesScreen;
import com.google.gerrit.client.changes.AllMergedChangesScreen; import com.google.gerrit.client.changes.AllMergedChangesScreen;
import com.google.gerrit.client.changes.AllOpenChangesScreen; import com.google.gerrit.client.changes.AllOpenChangesScreen;
import com.google.gerrit.client.changes.MineWatchedOpenChangesScreen;
import com.google.gerrit.client.changes.ByProjectAbandonedChangesScreen; import com.google.gerrit.client.changes.ByProjectAbandonedChangesScreen;
import com.google.gerrit.client.changes.ByProjectMergedChangesScreen; import com.google.gerrit.client.changes.ByProjectMergedChangesScreen;
import com.google.gerrit.client.changes.ByProjectOpenChangesScreen; import com.google.gerrit.client.changes.ByProjectOpenChangesScreen;
@@ -47,11 +62,11 @@ import com.google.gerrit.client.changes.ChangeQueryResultsScreen;
import com.google.gerrit.client.changes.ChangeScreen; import com.google.gerrit.client.changes.ChangeScreen;
import com.google.gerrit.client.changes.MineDraftsScreen; import com.google.gerrit.client.changes.MineDraftsScreen;
import com.google.gerrit.client.changes.MineStarredScreen; import com.google.gerrit.client.changes.MineStarredScreen;
import com.google.gerrit.client.changes.MineWatchedOpenChangesScreen;
import com.google.gerrit.client.changes.PatchTable; import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.changes.PublishCommentScreen; import com.google.gerrit.client.changes.PublishCommentScreen;
import com.google.gerrit.client.patches.PatchScreen; import com.google.gerrit.client.patches.PatchScreen;
import com.google.gerrit.client.ui.Screen; import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.auth.SignInMode; import com.google.gerrit.common.auth.SignInMode;
import com.google.gerrit.reviewdb.Account; import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGroup; import com.google.gerrit.reviewdb.AccountGroup;
@@ -292,6 +307,39 @@ public class Dispatcher {
private Screen select() { private Screen select() {
String p; String p;
if (token.equals(SETTINGS)) {
return new MyProfileScreen();
}
if (token.equals(SETTINGS_PREFERENCES)) {
return new MyPreferencesScreen();
}
if (token.equals(SETTINGS_PROJECTS)) {
return new MyWatchedProjectsScreen();
}
if (token.equals(SETTINGS_CONTACT)) {
return new MyContactInformationScreen();
}
if (token.equals(SETTINGS_SSHKEYS)) {
return new MySshKeysScreen();
}
if (token.equals(SETTINGS_WEBIDENT)) {
return new MyIdentitiesScreen();
}
if (token.equals(SETTINGS_MYGROUPS)) {
return new MyGroupsScreen();
}
if (token.equals(SETTINGS_AGREEMENTS)
&& Gerrit.getConfig().isUseContributorAgreements()) {
return new MyAgreementsScreen();
}
p = "register,"; p = "register,";
if (token.startsWith(p)) { if (token.startsWith(p)) {
return new RegisterScreen(skip(p, token)); return new RegisterScreen(skip(p, token));
@@ -308,7 +356,7 @@ public class Dispatcher {
final String[] args = skip(p, token).split(","); final String[] args = skip(p, token).split(",");
final SignInMode mode = SignInMode.valueOf(args[0]); final SignInMode mode = SignInMode.valueOf(args[0]);
final String msg = KeyUtil.decode(args[1]); final String msg = KeyUtil.decode(args[1]);
final String to = PageLinks.MINE; final String to = MINE;
switch (Gerrit.getConfig().getAuthType()) { switch (Gerrit.getConfig().getAuthType()) {
case OPENID: case OPENID:
new OpenIdSignInDialog(mode, to, msg).center(); new OpenIdSignInDialog(mode, to, msg).center();
@@ -324,7 +372,7 @@ public class Dispatcher {
case SIGN_IN: case SIGN_IN:
return new AllOpenChangesScreen(TOP); return new AllOpenChangesScreen(TOP);
case LINK_IDENTIY: case LINK_IDENTIY:
return new AccountSettings(SETTINGS_WEBIDENT); return new MyIdentitiesScreen();
} }
} }
@@ -336,7 +384,7 @@ public class Dispatcher {
return new NewAgreementScreen(skip(p, token)); return new NewAgreementScreen(skip(p, token));
} }
return new AccountSettings(token); return new NotFoundScreen();
} }
}); });
} }
@@ -358,8 +406,23 @@ public class Dispatcher {
if (token.startsWith(p)) { if (token.startsWith(p)) {
p = skip(p, token); p = skip(p, token);
final int c = p.indexOf(','); final int c = p.indexOf(',');
final String idstr = p.substring(0, c); final Project.NameKey k = Project.NameKey.parse(p.substring(0, c));
return new ProjectAdminScreen(Project.NameKey.parse(idstr), token); final boolean isWild = k.equals(Gerrit.getConfig().getWildProject());
p = p.substring(c + 1);
if (ProjectScreen.INFO.equals(p)) {
return new ProjectInfoScreen(k);
}
if (!isWild && ProjectScreen.BRANCH.equals(p)) {
return new ProjectBranchesScreen(k);
}
if (ProjectScreen.ACCESS.equals(p)) {
return new ProjectAccessScreen(k);
}
return new NotFoundScreen();
} }
if (ADMIN_GROUPS.equals(token)) { if (ADMIN_GROUPS.equals(token)) {

View File

@@ -123,6 +123,7 @@ public interface GerritCss extends CssResource {
String linkMenuItemNotLast(); String linkMenuItemNotLast();
String menuBarUserName(); String menuBarUserName();
String menuItem(); String menuItem();
String menuScreenMenuBar();
String missingApproval(); String missingApproval();
String missingApprovalList(); String missingApprovalList();
String needsReview(); String needsReview();

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.account;
import com.google.gwt.i18n.client.Constants; import com.google.gwt.i18n.client.Constants;
public interface AccountConstants extends Constants { public interface AccountConstants extends Constants {
String accountSettingsHeading(); String settingsHeading();
String fullName(); String fullName();
String preferredEmail(); String preferredEmail();
@@ -31,7 +31,9 @@ public interface AccountConstants extends Constants {
String copySelfOnEmails(); String copySelfOnEmails();
String buttonSaveChanges(); String buttonSaveChanges();
String tabAccountSummary();
String tabPreferences(); String tabPreferences();
String tabWatchedProjects();
String tabContactInformation(); String tabContactInformation();
String tabSshKeys(); String tabSshKeys();
String tabWebIdentities(); String tabWebIdentities();
@@ -73,7 +75,6 @@ public interface AccountConstants extends Constants {
String buttonDeleteIdentity(); String buttonDeleteIdentity();
String buttonLinkIdentity(); String buttonLinkIdentity();
String watchedProjects();
String buttonWatchProject(); String buttonWatchProject();
String defaultProjectName(); String defaultProjectName();
String watchedProjectColumnEmailNotifications(); String watchedProjectColumnEmailNotifications();

View File

@@ -1,4 +1,4 @@
accountSettingsHeading = Account Settings settingsHeading = Settings
fullName = Full Name fullName = Full Name
preferredEmail = Email Address preferredEmail = Email Address
@@ -12,9 +12,11 @@ maximumPageSizeFieldLabel = Maximum Page Size:
contextWholeFile = Whole File contextWholeFile = Whole File
buttonSaveChanges = Save Changes buttonSaveChanges = Save Changes
tabAccountSummary = Profile
tabPreferences = Preferences tabPreferences = Preferences
tabWatchedProjects = Watched Projects
tabContactInformation = Contact Information tabContactInformation = Contact Information
tabSshKeys = SSH Keys tabSshKeys = SSH Public Keys
tabWebIdentities = Identities tabWebIdentities = Identities
tabMyGroups = Groups tabMyGroups = Groups
tabAgreements = Agreements tabAgreements = Agreements
@@ -54,7 +56,6 @@ addSshKeyHelp = (<a href="http://help.github.com/key-setup-redirect" target="_bl
invalidSshKeyError = Invalid SSH Key invalidSshKeyError = Invalid SSH Key
sshJavaAppletNotAvailable = Open Key Unavailable: Java not enabled sshJavaAppletNotAvailable = Open Key Unavailable: Java not enabled
watchedProjects = Watched Projects
buttonWatchProject = Watch buttonWatchProject = Watch
defaultProjectName = Project Name defaultProjectName = Project Name
watchedProjectColumnEmailNotifications = Email Notifications watchedProjectColumnEmailNotifications = Email Notifications

View File

@@ -1,183 +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.account;
import static com.google.gerrit.client.FormatUtil.mediumFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.ui.AccountScreen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.reviewdb.Account;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.LazyPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import java.util.ArrayList;
import java.util.List;
public class AccountSettings extends AccountScreen {
private final String initialTabToken;
private int labelIdx, fieldIdx;
private Grid info;
private List<String> tabTokens;
private TabPanel tabs;
public AccountSettings(final String tabToken) {
initialTabToken = tabToken;
}
@Override
public boolean displayToken(String token) {
final int tabIdx = tabTokens.indexOf(token);
if (0 <= tabIdx) {
tabs.selectTab(tabIdx);
setToken(token);
return true;
} else {
return false;
}
}
@Override
protected void onLoad() {
super.onLoad();
final int idx = tabTokens.indexOf(initialTabToken);
tabs.selectTab(0 <= idx ? idx : 0);
display(Gerrit.getUserAccount());
display();
}
@Override
protected void onInitUI() {
super.onInitUI();
setPageTitle(Util.C.accountSettingsHeading());
if (LocaleInfo.getCurrentLocale().isRTL()) {
labelIdx = 1;
fieldIdx = 0;
} else {
labelIdx = 0;
fieldIdx = 1;
}
info = new Grid(5, 2);
info.setStyleName(Gerrit.RESOURCES.css().infoBlock());
info.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
add(info);
infoRow(0, Util.C.userName());
infoRow(1, Util.C.fullName());
infoRow(2, Util.C.preferredEmail());
infoRow(3, Util.C.registeredOn());
infoRow(4, Util.C.accountId());
final CellFormatter fmt = info.getCellFormatter();
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(4, 0, Gerrit.RESOURCES.css().bottomheader());
tabTokens = new ArrayList<String>();
tabs = new TabPanel();
tabs.setWidth("98%");
add(tabs);
tabs.add(new LazyPanel() {
@Override
protected PreferencePanel createWidget() {
return new PreferencePanel();
}
}, Util.C.tabPreferences());
tabTokens.add(PageLinks.SETTINGS);
tabs.add(new LazyPanel() {
@Override
protected ProjectWatchPanel createWidget() {
return new ProjectWatchPanel();
}
}, Util.C.watchedProjects());
tabTokens.add(PageLinks.SETTINGS_PROJECTS);
tabs.add(new LazyPanel() {
@Override
protected ContactPanelFull createWidget() {
final ContactPanelFull p = new ContactPanelFull();
p.accountSettings = AccountSettings.this;
return p;
}
}, Util.C.tabContactInformation());
tabTokens.add(PageLinks.SETTINGS_CONTACT);
tabs.add(new LazyPanel() {
@Override
protected SshPanel createWidget() {
return new SshPanel();
}
}, Util.C.tabSshKeys());
tabTokens.add(PageLinks.SETTINGS_SSHKEYS);
tabs.add(new LazyPanel() {
@Override
protected ExternalIdPanel createWidget() {
return new ExternalIdPanel();
}
}, Util.C.tabWebIdentities());
tabTokens.add(PageLinks.SETTINGS_WEBIDENT);
tabs.add(new LazyPanel() {
@Override
protected MyGroupsPanel createWidget() {
return new MyGroupsPanel();
}
}, Util.C.tabMyGroups());
tabTokens.add(PageLinks.SETTINGS_MYGROUPS);
if (Gerrit.getConfig().isUseContributorAgreements()) {
tabs.add(new LazyPanel() {
@Override
protected AgreementPanel createWidget() {
return new AgreementPanel();
}
}, Util.C.tabAgreements());
tabTokens.add(PageLinks.SETTINGS_AGREEMENTS);
}
tabs.addSelectionHandler(new SelectionHandler<Integer>() {
@Override
public void onSelection(final SelectionEvent<Integer> event) {
setToken(tabTokens.get(event.getSelectedItem()));
}
});
}
private void infoRow(final int row, final String name) {
info.setText(row, labelIdx, name);
info.getCellFormatter().addStyleName(row, 0,
Gerrit.RESOURCES.css().header());
}
void display(final Account account) {
info.setText(0, fieldIdx, account.getUserName());
info.setText(1, fieldIdx, account.getFullName());
info.setText(2, fieldIdx, account.getPreferredEmail());
info.setText(3, fieldIdx, mediumFormat(account.getRegisteredOn()));
info.setText(4, fieldIdx, account.getId().toString());
}
}

View File

@@ -46,8 +46,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
class ContactPanelShort extends Composite { class ContactPanelShort extends Composite {
AccountSettings accountSettings;
protected final FlowPanel body; protected final FlowPanel body;
protected int labelIdx, fieldIdx; protected int labelIdx, fieldIdx;
protected Button save; protected Button save;
@@ -227,6 +225,10 @@ class ContactPanelShort extends Composite {
} }
registerNewEmail.setEnabled(true); registerNewEmail.setEnabled(true);
} }
display();
}
void display() {
} }
protected void row(final Grid info, final int row, final String name, protected void row(final Grid info, final int row, final String name,
@@ -354,9 +356,6 @@ class ContactPanelShort extends Composite {
me.setFullName(result.getFullName()); me.setFullName(result.getFullName());
me.setPreferredEmail(result.getPreferredEmail()); me.setPreferredEmail(result.getPreferredEmail());
Gerrit.refreshMenuBar(); Gerrit.refreshMenuBar();
if (accountSettings != null) {
accountSettings.display(me);
}
} }
ContactInformation toContactInformation() { ContactInformation toContactInformation() {

View File

@@ -16,7 +16,7 @@ package com.google.gerrit.client.account;
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.rpc.GerritCallback; import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.Hyperlink; import com.google.gerrit.client.ui.Hyperlink;
import com.google.gerrit.common.PageLinks; import com.google.gerrit.common.PageLinks;
@@ -26,30 +26,27 @@ import com.google.gerrit.reviewdb.AccountAgreement;
import com.google.gerrit.reviewdb.AccountGroupAgreement; import com.google.gerrit.reviewdb.AccountGroupAgreement;
import com.google.gerrit.reviewdb.ContributorAgreement; import com.google.gerrit.reviewdb.ContributorAgreement;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
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;
class AgreementPanel extends Composite { public class MyAgreementsScreen extends SettingsScreen {
private AgreementTable agreements; private AgreementTable agreements;
AgreementPanel() { @Override
final FlowPanel body = new FlowPanel(); protected void onInitUI() {
super.onInitUI();
agreements = new AgreementTable(); agreements = new AgreementTable();
body.add(agreements); add(agreements);
body.add(new Hyperlink(Util.C.newAgreement(), PageLinks.SETTINGS_NEW_AGREEMENT)); add(new Hyperlink(Util.C.newAgreement(), PageLinks.SETTINGS_NEW_AGREEMENT));
initWidget(body);
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SVC.myAgreements(new GerritCallback<AgreementInfo>() { Util.ACCOUNT_SVC.myAgreements(new ScreenLoadCallback<AgreementInfo>(this) {
public void onSuccess(final AgreementInfo result) { public void preDisplay(final AgreementInfo result) {
agreements.display(result); agreements.display(result);
} }
}); });

View File

@@ -0,0 +1,31 @@
// 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.account;
public class MyContactInformationScreen extends SettingsScreen {
private ContactPanelFull panel;
@Override
protected void onInitUI() {
super.onInitUI();
panel = new ContactPanelFull() {
@Override
void display() {
MyContactInformationScreen.this.display();
}
};
add(panel);
}
}

View File

@@ -15,34 +15,26 @@
package com.google.gerrit.client.account; package com.google.gerrit.client.account;
import com.google.gerrit.client.admin.GroupTable; import com.google.gerrit.client.admin.GroupTable;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.reviewdb.AccountGroup; import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import java.util.List; import java.util.List;
class MyGroupsPanel extends Composite { public class MyGroupsScreen extends SettingsScreen {
private GroupTable groups; private GroupTable groups;
MyGroupsPanel() { @Override
final FlowPanel body = new FlowPanel(); protected void onInitUI() {
super.onInitUI();
groups = new GroupTable(false /* do not hyperlink to admin */); groups = new GroupTable(false /* do not hyperlink to admin */);
body.add(groups); add(groups);
initWidget(body);
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
refresh(); Util.ACCOUNT_SEC.myGroups(new ScreenLoadCallback<List<AccountGroup>>(this) {
} public void preDisplay(final List<AccountGroup> result) {
private void refresh() {
Util.ACCOUNT_SEC.myGroups(new GerritCallback<List<AccountGroup>>() {
public void onSuccess(final List<AccountGroup> result) {
groups.display(result); groups.display(result);
} }
}); });

View File

@@ -18,6 +18,7 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.auth.openid.OpenIdSignInDialog; import com.google.gerrit.client.auth.openid.OpenIdSignInDialog;
import com.google.gerrit.client.auth.openid.OpenIdUtil; import com.google.gerrit.client.auth.openid.OpenIdUtil;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.common.auth.SignInMode; import com.google.gerrit.common.auth.SignInMode;
import com.google.gerrit.common.auth.openid.OpenIdUrls; import com.google.gerrit.common.auth.openid.OpenIdUrls;
@@ -29,8 +30,6 @@ import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import java.util.Collections; import java.util.Collections;
@@ -39,16 +38,18 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
class ExternalIdPanel extends Composite { public class MyIdentitiesScreen extends SettingsScreen {
private IdTable identites; private IdTable identites;
private Button deleteIdentity; private Button deleteIdentity;
ExternalIdPanel() { @Override
final FlowPanel body = new FlowPanel(); protected void onInitUI() {
body.add(new UsernamePanel()); super.onInitUI();
add(new UsernamePanel());
identites = new IdTable(); identites = new IdTable();
body.add(identites); add(identites);
deleteIdentity = new Button(Util.C.buttonDeleteIdentity()); deleteIdentity = new Button(Util.C.buttonDeleteIdentity());
deleteIdentity.setEnabled(false); deleteIdentity.setEnabled(false);
@@ -58,7 +59,7 @@ class ExternalIdPanel extends Composite {
identites.deleteChecked(); identites.deleteChecked();
} }
}); });
body.add(deleteIdentity); add(deleteIdentity);
switch (Gerrit.getConfig().getAuthType()) { switch (Gerrit.getConfig().getAuthType()) {
case OPENID: { case OPENID: {
@@ -70,21 +71,18 @@ class ExternalIdPanel extends Composite {
new OpenIdSignInDialog(SignInMode.LINK_IDENTIY, to, null).center(); new OpenIdSignInDialog(SignInMode.LINK_IDENTIY, to, null).center();
} }
}); });
body.add(linkIdentity); add(linkIdentity);
break; break;
} }
} }
initWidget(body);
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SEC Util.ACCOUNT_SEC
.myExternalIds(new GerritCallback<List<AccountExternalId>>() { .myExternalIds(new ScreenLoadCallback<List<AccountExternalId>>(this) {
public void onSuccess(final List<AccountExternalId> result) { public void preDisplay(final List<AccountExternalId> result) {
identites.display(result); identites.display(result);
} }
}); });

View File

@@ -19,6 +19,7 @@ import static com.google.gerrit.reviewdb.AccountGeneralPreferences.PAGESIZE_CHOI
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.reviewdb.Account; import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGeneralPreferences; import com.google.gerrit.reviewdb.AccountGeneralPreferences;
import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeEvent;
@@ -28,21 +29,20 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
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.Grid;
import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.ListBox;
import com.google.gwtjsonrpc.client.VoidResult; import com.google.gwtjsonrpc.client.VoidResult;
class PreferencePanel extends Composite { public class MyPreferencesScreen extends SettingsScreen {
private CheckBox showSiteHeader; private CheckBox showSiteHeader;
private CheckBox useFlashClipboard; private CheckBox useFlashClipboard;
private CheckBox copySelfOnEmails; private CheckBox copySelfOnEmails;
private ListBox maximumPageSize; private ListBox maximumPageSize;
private Button save; private Button save;
PreferencePanel() { @Override
final FlowPanel body = new FlowPanel(); protected void onInitUI() {
super.onInitUI();
final ClickHandler onClickSave = new ClickHandler() { final ClickHandler onClickSave = new ClickHandler() {
@Override @Override
@@ -99,7 +99,7 @@ class PreferencePanel extends Composite {
formGrid.setWidget(row, fieldIdx, maximumPageSize); formGrid.setWidget(row, fieldIdx, maximumPageSize);
row++; row++;
body.add(formGrid); add(formGrid);
save = new Button(Util.C.buttonSaveChanges()); save = new Button(Util.C.buttonSaveChanges());
save.setEnabled(false); save.setEnabled(false);
@@ -109,18 +109,15 @@ class PreferencePanel extends Composite {
doSave(); doSave();
} }
}); });
body.add(save); add(save);
initWidget(body);
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SVC.myAccount(new GerritCallback<Account>() { Util.ACCOUNT_SVC.myAccount(new ScreenLoadCallback<Account>(this) {
public void onSuccess(final Account result) { public void preDisplay(final Account result) {
display(result.getGeneralPreferences()); display(result.getGeneralPreferences());
enable(true);
} }
}); });
} }

View File

@@ -0,0 +1,78 @@
// 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.account;
import static com.google.gerrit.client.FormatUtil.mediumFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.reviewdb.Account;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
public class MyProfileScreen extends SettingsScreen {
private int labelIdx, fieldIdx;
private Grid info;
@Override
protected void onInitUI() {
super.onInitUI();
if (LocaleInfo.getCurrentLocale().isRTL()) {
labelIdx = 1;
fieldIdx = 0;
} else {
labelIdx = 0;
fieldIdx = 1;
}
info = new Grid(5, 2);
info.setStyleName(Gerrit.RESOURCES.css().infoBlock());
info.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());
add(info);
infoRow(0, Util.C.userName());
infoRow(1, Util.C.fullName());
infoRow(2, Util.C.preferredEmail());
infoRow(3, Util.C.registeredOn());
infoRow(4, Util.C.accountId());
final CellFormatter fmt = info.getCellFormatter();
fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
fmt.addStyleName(4, 0, Gerrit.RESOURCES.css().bottomheader());
}
@Override
protected void onLoad() {
super.onLoad();
display(Gerrit.getUserAccount());
display();
}
private void infoRow(final int row, final String name) {
info.setText(row, labelIdx, name);
info.getCellFormatter().addStyleName(row, 0,
Gerrit.RESOURCES.css().header());
}
void display(final Account account) {
info.setText(0, fieldIdx, account.getUserName());
info.setText(1, fieldIdx, account.getFullName());
info.setText(2, fieldIdx, account.getPreferredEmail());
info.setText(3, fieldIdx, mediumFormat(account.getRegisteredOn()));
info.setText(4, fieldIdx, account.getId().toString());
}
}

View File

@@ -0,0 +1,31 @@
// 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.account;
public class MySshKeysScreen extends SettingsScreen {
private SshPanel panel;
@Override
protected void onInitUI() {
super.onInitUI();
panel = new SshPanel() {
@Override
void display() {
MySshKeysScreen.this.display();
}
};
add(panel);
}
}

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.account;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.ProjectLink; import com.google.gerrit.client.ui.ProjectLink;
import com.google.gerrit.client.ui.ProjectNameSuggestOracle; import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
@@ -36,7 +37,6 @@ import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
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.SuggestBox; import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
@@ -47,7 +47,7 @@ import com.google.gwtjsonrpc.client.VoidResult;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
class ProjectWatchPanel extends Composite { public class MyWatchedProjectsScreen extends SettingsScreen {
private WatchTable watches; private WatchTable watches;
private Button addNew; private Button addNew;
@@ -55,8 +55,9 @@ class ProjectWatchPanel extends Composite {
private Button delSel; private Button delSel;
private boolean submitOnSelection; private boolean submitOnSelection;
ProjectWatchPanel() { @Override
final FlowPanel body = new FlowPanel(); protected void onInitUI() {
super.onInitUI();
{ {
final FlowPanel fp = new FlowPanel(); final FlowPanel fp = new FlowPanel();
@@ -117,11 +118,11 @@ class ProjectWatchPanel extends Composite {
} }
}); });
fp.add(addNew); fp.add(addNew);
body.add(fp); add(fp);
} }
watches = new WatchTable(); watches = new WatchTable();
body.add(watches); add(watches);
{ {
final FlowPanel fp = new FlowPanel(); final FlowPanel fp = new FlowPanel();
delSel = new Button(Util.C.buttonDeleteSshKey()); delSel = new Button(Util.C.buttonDeleteSshKey());
@@ -132,10 +133,8 @@ class ProjectWatchPanel extends Composite {
} }
}); });
fp.add(delSel); fp.add(delSel);
body.add(fp); add(fp);
} }
initWidget(body);
} }
void doAddNew() { void doAddNew() {
@@ -166,8 +165,9 @@ class ProjectWatchPanel extends Composite {
protected void onLoad() { protected void onLoad() {
super.onLoad(); super.onLoad();
Util.ACCOUNT_SVC Util.ACCOUNT_SVC
.myProjectWatch(new GerritCallback<List<AccountProjectWatchInfo>>() { .myProjectWatch(new ScreenLoadCallback<List<AccountProjectWatchInfo>>(
public void onSuccess(final List<AccountProjectWatchInfo> result) { this) {
public void preDisplay(final List<AccountProjectWatchInfo> result) {
watches.display(result); watches.display(result);
} }
}); });

View File

@@ -0,0 +1,42 @@
// 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.account;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.ui.MenuScreen;
import com.google.gerrit.common.PageLinks;
public abstract class SettingsScreen extends MenuScreen {
public SettingsScreen() {
setRequiresSignIn(true);
link(Util.C.tabAccountSummary(), PageLinks.SETTINGS);
link(Util.C.tabPreferences(), PageLinks.SETTINGS_PREFERENCES);
link(Util.C.tabWatchedProjects(), PageLinks.SETTINGS_PROJECTS);
link(Util.C.tabContactInformation(), PageLinks.SETTINGS_CONTACT);
link(Util.C.tabSshKeys(), PageLinks.SETTINGS_SSHKEYS);
link(Util.C.tabWebIdentities(), PageLinks.SETTINGS_WEBIDENT);
link(Util.C.tabMyGroups(), PageLinks.SETTINGS_MYGROUPS);
if (Gerrit.getConfig().isUseContributorAgreements()) {
link(Util.C.tabAgreements(), PageLinks.SETTINGS_AGREEMENTS);
}
}
@Override
protected void onInitUI() {
super.onInitUI();
setPageTitle(Util.C.settingsHeading());
}
}

View File

@@ -70,9 +70,10 @@ class SshPanel extends Composite {
private Panel serverKeys; private Panel serverKeys;
private int loadCount;
SshPanel() { SshPanel() {
final FlowPanel body = new FlowPanel(); final FlowPanel body = new FlowPanel();
body.add(new UsernamePanel());
showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey()); showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey());
showAddKeyBlock.addClickHandler(new ClickHandler() { showAddKeyBlock.addClickHandler(new ClickHandler() {
@@ -320,6 +321,9 @@ class SshPanel extends Composite {
if (result.isEmpty() && keys.isVisible()) { if (result.isEmpty() && keys.isVisible()) {
showAddKeyBlock(true); showAddKeyBlock(true);
} }
if (++loadCount == 2) {
display();
}
} }
}); });
@@ -329,10 +333,16 @@ class SshPanel extends Composite {
for (final SshHostKey keyInfo : result) { for (final SshHostKey keyInfo : result) {
serverKeys.add(new SshHostKeyPanel(keyInfo)); serverKeys.add(new SshHostKeyPanel(keyInfo));
} }
if (++loadCount == 2) {
display();
}
} }
}); });
} }
void display() {
}
@Override @Override
protected void onUnload() { protected void onUnload() {
if (appletLoadTimer != null) { if (appletLoadTimer != null) {

View File

@@ -30,7 +30,7 @@ public class ValidateEmailScreen extends AccountScreen {
@Override @Override
protected void onInitUI() { protected void onInitUI() {
super.onInitUI(); super.onInitUI();
setPageTitle(Util.C.accountSettingsHeading()); setPageTitle(Util.C.settingsHeading());
} }
@Override @Override

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client.admin;
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.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle; import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.Hyperlink; import com.google.gerrit.client.ui.Hyperlink;
@@ -43,7 +44,6 @@ import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
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.Grid; import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.ListBox;
@@ -59,9 +59,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ProjectRightsPanel extends Composite { public class ProjectAccessScreen extends ProjectScreen {
private Project.NameKey projectName;
private Panel parentPanel; private Panel parentPanel;
private Hyperlink parentName; private Hyperlink parentName;
@@ -74,26 +72,25 @@ public class ProjectRightsPanel extends Composite {
private NpTextBox nameTxtBox; private NpTextBox nameTxtBox;
private SuggestBox nameTxt; private SuggestBox nameTxt;
private NpTextBox referenceTxt; private NpTextBox referenceTxt;
private FlowPanel addPanel;
private final FlowPanel addPanel = new FlowPanel(); public ProjectAccessScreen(final Project.NameKey toShow) {
super(toShow);
}
public ProjectRightsPanel(final Project.NameKey toShow) { @Override
projectName = toShow; protected void onInitUI() {
super.onInitUI();
final FlowPanel body = new FlowPanel(); initParent();
initParent(body); initRights();
initRights(body);
initWidget(body);
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
enableForm(false);
super.onLoad(); super.onLoad();
Util.PROJECT_SVC.projectDetail(getProjectKey(),
Util.PROJECT_SVC.projectDetail(projectName, new ScreenLoadCallback<ProjectDetail>(this) {
new GerritCallback<ProjectDetail>() { public void preDisplay(final ProjectDetail result) {
public void onSuccess(final ProjectDetail result) {
enableForm(true); enableForm(true);
display(result); display(result);
} }
@@ -112,16 +109,17 @@ public class ProjectRightsPanel extends Composite {
rangeMaxBox.setEnabled(canAdd); rangeMaxBox.setEnabled(canAdd);
} }
private void initParent(final Panel body) { private void initParent() {
parentPanel = new VerticalPanel(); parentPanel = new VerticalPanel();
parentPanel.add(new SmallHeading(Util.C.headingParentProjectName())); parentPanel.add(new SmallHeading(Util.C.headingParentProjectName()));
parentName = new Hyperlink("", ""); parentName = new Hyperlink("", "");
parentPanel.add(parentName); parentPanel.add(parentName);
body.add(parentPanel); add(parentPanel);
} }
private void initRights(final Panel body) { private void initRights() {
addPanel = new FlowPanel();
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel()); addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
final Grid addGrid = new Grid(5, 2); final Grid addGrid = new Grid(5, 2);
@@ -144,7 +142,7 @@ public class ProjectRightsPanel extends Composite {
for (final ApprovalType at : Gerrit.getConfig().getApprovalTypes() for (final ApprovalType at : Gerrit.getConfig().getApprovalTypes()
.getActionTypes()) { .getActionTypes()) {
final ApprovalCategory c = at.getCategory(); final ApprovalCategory c = at.getCategory();
if (Gerrit.getConfig().getWildProject().equals(projectName) if (Gerrit.getConfig().getWildProject().equals(getProjectKey())
&& ApprovalCategory.OWN.equals(c.getId())) { && ApprovalCategory.OWN.equals(c.getId())) {
// Giving out control of the WILD_PROJECT to other groups beyond // Giving out control of the WILD_PROJECT to other groups beyond
// Administrators is dangerous. Having control over WILD_PROJECT // Administrators is dangerous. Having control over WILD_PROJECT
@@ -228,10 +226,10 @@ public class ProjectRightsPanel extends Composite {
} }
}); });
body.add(new SmallHeading(Util.C.headingAccessRights())); add(new SmallHeading(Util.C.headingAccessRights()));
body.add(rights); add(rights);
body.add(delRight); add(delRight);
body.add(addPanel); add(addPanel);
if (catBox.getItemCount() > 0) { if (catBox.getItemCount() > 0) {
catBox.setSelectedIndex(0); catBox.setSelectedIndex(0);
@@ -250,8 +248,7 @@ public class ProjectRightsPanel extends Composite {
} }
parentPanel.setVisible(!isWild); parentPanel.setVisible(!isWild);
parentName.setTargetHistoryToken(Dispatcher.toProjectAdmin(parent, parentName.setTargetHistoryToken(Dispatcher.toProjectAdmin(parent, ACCESS));
ProjectAdminScreen.ACCESS_TAB));
parentName.setText(parent.get()); parentName.setText(parent.get());
rights.display(result.groups, result.rights); rights.display(result.groups, result.rights);
@@ -262,7 +259,7 @@ public class ProjectRightsPanel extends Composite {
private void doDeleteRefRights(final HashSet<RefRight.Key> refRightIds) { private void doDeleteRefRights(final HashSet<RefRight.Key> refRightIds) {
if (!refRightIds.isEmpty()) { if (!refRightIds.isEmpty()) {
Util.PROJECT_SVC.deleteRight(projectName, refRightIds, Util.PROJECT_SVC.deleteRight(getProjectKey(), refRightIds,
new GerritCallback<ProjectDetail>() { new GerritCallback<ProjectDetail>() {
@Override @Override
public void onSuccess(final ProjectDetail result) { public void onSuccess(final ProjectDetail result) {
@@ -338,8 +335,8 @@ public class ProjectRightsPanel extends Composite {
} }
addRight.setEnabled(false); addRight.setEnabled(false);
Util.PROJECT_SVC.addRight(projectName, at.getCategory().getId(), groupName, Util.PROJECT_SVC.addRight(getProjectKey(), at.getCategory().getId(),
refPattern, min.getValue(), max.getValue(), groupName, refPattern, min.getValue(), max.getValue(),
new GerritCallback<ProjectDetail>() { new GerritCallback<ProjectDetail>() {
public void onSuccess(final ProjectDetail result) { public void onSuccess(final ProjectDetail result) {
addRight.setEnabled(true); addRight.setEnabled(true);

View File

@@ -1,119 +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.admin;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.data.ProjectDetail;
import com.google.gerrit.reviewdb.Project;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.ui.LazyPanel;
import com.google.gwt.user.client.ui.TabPanel;
import java.util.ArrayList;
import java.util.List;
public class ProjectAdminScreen extends Screen {
static final String INFO_TAB = "info";
static final String BRANCH_TAB = "branches";
static final String ACCESS_TAB = "access";
private final Project.NameKey projectName;
private final String initialTabToken;
private List<String> tabTokens;
private TabPanel tabs;
public ProjectAdminScreen(final Project.NameKey toShow, final String token) {
projectName = toShow;
initialTabToken = token;
}
@Override
public boolean displayToken(String token) {
final int tabIdx = tabTokens.indexOf(token);
if (0 <= tabIdx) {
tabs.selectTab(tabIdx);
setToken(token);
return true;
} else {
return false;
}
}
@Override
protected void onLoad() {
super.onLoad();
Util.PROJECT_SVC.projectDetail(projectName,
new ScreenLoadCallback<ProjectDetail>(this) {
@Override
protected void preDisplay(final ProjectDetail result) {
display(result);
tabs.selectTab(tabTokens.indexOf(initialTabToken));
}
});
}
@Override
protected void onInitUI() {
super.onInitUI();
tabTokens = new ArrayList<String>();
tabs = new TabPanel();
tabs.setWidth("98%");
add(tabs);
tabs.add(new LazyPanel() {
@Override
protected ProjectInfoPanel createWidget() {
return new ProjectInfoPanel(projectName);
}
}, Util.C.projectAdminTabGeneral());
tabTokens.add(Dispatcher.toProjectAdmin(projectName, INFO_TAB));
if (!Gerrit.getConfig().getWildProject().equals(projectName)) {
tabs.add(new LazyPanel() {
@Override
protected ProjectBranchesPanel createWidget() {
return new ProjectBranchesPanel(projectName);
}
}, Util.C.projectAdminTabBranches());
tabTokens.add(Dispatcher.toProjectAdmin(projectName, BRANCH_TAB));
}
tabs.add(new LazyPanel() {
@Override
protected ProjectRightsPanel createWidget() {
return new ProjectRightsPanel(projectName);
}
}, Util.C.projectAdminTabAccess());
tabTokens.add(Dispatcher.toProjectAdmin(projectName, ACCESS_TAB));
tabs.addSelectionHandler(new SelectionHandler<Integer>() {
@Override
public void onSelection(final SelectionEvent<Integer> event) {
setToken(tabTokens.get(event.getSelectedItem()));
}
});
}
private void display(final ProjectDetail result) {
final Project project = result.project;
setPageTitle(Util.M.project(project.getName()));
}
}

View File

@@ -18,9 +18,10 @@ import com.google.gerrit.client.ConfirmationCallback;
import com.google.gerrit.client.ConfirmationDialog; import com.google.gerrit.client.ConfirmationDialog;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.common.data.ListBranchesResult;
import com.google.gerrit.common.data.GitwebLink; import com.google.gerrit.common.data.GitwebLink;
import com.google.gerrit.common.data.ListBranchesResult;
import com.google.gerrit.common.errors.InvalidNameException; import com.google.gerrit.common.errors.InvalidNameException;
import com.google.gerrit.common.errors.InvalidRevisionException; import com.google.gerrit.common.errors.InvalidRevisionException;
import com.google.gerrit.reviewdb.Branch; import com.google.gerrit.reviewdb.Branch;
@@ -39,11 +40,9 @@ import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
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.Grid; import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter; import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import com.google.gwtexpui.globalkey.client.NpTextBox; import com.google.gwtexpui.globalkey.client.NpTextBox;
import com.google.gwtjsonrpc.client.RemoteJsonException; import com.google.gwtjsonrpc.client.RemoteJsonException;
@@ -52,33 +51,24 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class ProjectBranchesPanel extends Composite { public class ProjectBranchesScreen extends ProjectScreen {
private Project.NameKey projectName;
private BranchesTable branches; private BranchesTable branches;
private Button delBranch; private Button delBranch;
private Button addBranch; private Button addBranch;
private NpTextBox nameTxtBox; private NpTextBox nameTxtBox;
private NpTextBox irevTxtBox; private NpTextBox irevTxtBox;
private FlowPanel addPanel;
private final FlowPanel addPanel = new FlowPanel(); public ProjectBranchesScreen(final Project.NameKey toShow) {
super(toShow);
public ProjectBranchesPanel(final Project.NameKey toShow) {
final FlowPanel body = new FlowPanel();
initBranches(body);
initWidget(body);
projectName = toShow;
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
enableForm(false);
super.onLoad(); super.onLoad();
Util.PROJECT_SVC.listBranches(getProjectKey(),
Util.PROJECT_SVC.listBranches(projectName, new ScreenLoadCallback<ListBranchesResult>(this) {
new GerritCallback<ListBranchesResult>() { public void preDisplay(final ListBranchesResult result) {
public void onSuccess(final ListBranchesResult result) {
enableForm(true); enableForm(true);
display(result.getBranches()); display(result.getBranches());
addPanel.setVisible(result.getCanAdd()); addPanel.setVisible(result.getCanAdd());
@@ -98,7 +88,11 @@ public class ProjectBranchesPanel extends Composite {
irevTxtBox.setEnabled(on); irevTxtBox.setEnabled(on);
} }
private void initBranches(final Panel body) { @Override
protected void onInitUI() {
super.onInitUI();
addPanel = new FlowPanel();
addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel()); addPanel.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
final Grid addGrid = new Grid(2, 2); final Grid addGrid = new Grid(2, 2);
@@ -189,9 +183,9 @@ public class ProjectBranchesPanel extends Composite {
} }
}); });
body.add(branches); add(branches);
body.add(delBranch); add(delBranch);
body.add(addPanel); add(addPanel);
} }
private void doAddNewBranch() { private void doAddNewBranch() {
@@ -219,7 +213,7 @@ public class ProjectBranchesPanel extends Composite {
} }
addBranch.setEnabled(false); addBranch.setEnabled(false);
Util.PROJECT_SVC.addBranch(projectName, branchName, rev, Util.PROJECT_SVC.addBranch(getProjectKey(), branchName, rev,
new GerritCallback<ListBranchesResult>() { new GerritCallback<ListBranchesResult>() {
public void onSuccess(final ListBranchesResult result) { public void onSuccess(final ListBranchesResult result) {
addBranch.setEnabled(true); addBranch.setEnabled(true);
@@ -292,7 +286,7 @@ public class ProjectBranchesPanel extends Composite {
new HTML(message.toString()), new ConfirmationCallback() { new HTML(message.toString()), new ConfirmationCallback() {
@Override @Override
public void onOk() { public void onOk() {
Util.PROJECT_SVC.deleteBranch(projectName, ids, Util.PROJECT_SVC.deleteBranch(getProjectKey(), ids,
new GerritCallback<Set<Branch.NameKey>>() { new GerritCallback<Set<Branch.NameKey>>() {
public void onSuccess(final Set<Branch.NameKey> deleted) { public void onSuccess(final Set<Branch.NameKey> deleted) {
for (int row = 1; row < table.getRowCount();) { for (int row = 1; row < table.getRowCount();) {

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.client.admin;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.SmallHeading; import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.client.ui.TextSaveButtonListener; import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gerrit.common.data.ProjectDetail; import com.google.gerrit.common.data.ProjectDetail;
@@ -28,15 +29,12 @@ import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwtexpui.globalkey.client.NpTextArea; import com.google.gwtexpui.globalkey.client.NpTextArea;
public class ProjectInfoPanel extends Composite { public class ProjectInfoScreen extends ProjectScreen {
private Project.NameKey projectName;
private Project project; private Project project;
private Panel submitTypePanel; private Panel submitTypePanel;
@@ -49,7 +47,14 @@ public class ProjectInfoPanel extends Composite {
private NpTextArea descTxt; private NpTextArea descTxt;
private Button saveProject; private Button saveProject;
public ProjectInfoPanel(final Project.NameKey toShow) { public ProjectInfoScreen(final Project.NameKey toShow) {
super(toShow);
}
@Override
protected void onInitUI() {
super.onInitUI();
saveProject = new Button(Util.C.buttonSaveChanges()); saveProject = new Button(Util.C.buttonSaveChanges());
saveProject.addClickHandler(new ClickHandler() { saveProject.addClickHandler(new ClickHandler() {
@Override @Override
@@ -58,28 +63,18 @@ public class ProjectInfoPanel extends Composite {
} }
}); });
final FlowPanel body = new FlowPanel(); initDescription();
initDescription(body); initSubmitType();
initSubmitType(body); initAgreements();
initAgreements(body); add(saveProject);
body.add(saveProject);
initWidget(body);
projectName = toShow;
} }
@Override @Override
protected void onLoad() { protected void onLoad() {
enableForm(false, false, false);
saveProject.setEnabled(false);
super.onLoad(); super.onLoad();
refresh(); Util.PROJECT_SVC.projectDetail(getProjectKey(),
} new ScreenLoadCallback<ProjectDetail>(this) {
public void preDisplay(final ProjectDetail result) {
private void refresh() {
Util.PROJECT_SVC.projectDetail(projectName,
new GerritCallback<ProjectDetail>() {
public void onSuccess(final ProjectDetail result) {
enableForm(result.canModifyAgreements, enableForm(result.canModifyAgreements,
result.canModifyDescription, result.canModifyMergeType); result.canModifyDescription, result.canModifyMergeType);
saveProject.setVisible( saveProject.setVisible(
@@ -102,7 +97,7 @@ public class ProjectInfoPanel extends Composite {
canModifyAgreements || canModifyDescription || canModifyMergeType); canModifyAgreements || canModifyDescription || canModifyMergeType);
} }
private void initDescription(final Panel body) { private void initDescription() {
final VerticalPanel vp = new VerticalPanel(); final VerticalPanel vp = new VerticalPanel();
vp.add(new SmallHeading(Util.C.headingDescription())); vp.add(new SmallHeading(Util.C.headingDescription()));
@@ -111,11 +106,11 @@ public class ProjectInfoPanel extends Composite {
descTxt.setCharacterWidth(60); descTxt.setCharacterWidth(60);
vp.add(descTxt); vp.add(descTxt);
body.add(vp); add(vp);
new TextSaveButtonListener(descTxt, saveProject); new TextSaveButtonListener(descTxt, saveProject);
} }
private void initSubmitType(final Panel body) { private void initSubmitType() {
submitTypePanel = new VerticalPanel(); submitTypePanel = new VerticalPanel();
submitTypePanel.add(new SmallHeading(Util.C.headingSubmitType())); submitTypePanel.add(new SmallHeading(Util.C.headingSubmitType()));
@@ -130,10 +125,10 @@ public class ProjectInfoPanel extends Composite {
} }
}); });
submitTypePanel.add(submitType); submitTypePanel.add(submitType);
body.add(submitTypePanel); add(submitTypePanel);
} }
private void initAgreements(final Panel body) { private void initAgreements() {
final ValueChangeHandler<Boolean> onChangeSave = final ValueChangeHandler<Boolean> onChangeSave =
new ValueChangeHandler<Boolean>() { new ValueChangeHandler<Boolean>() {
@Override @Override
@@ -153,7 +148,7 @@ public class ProjectInfoPanel extends Composite {
useSignedOffBy.addValueChangeHandler(onChangeSave); useSignedOffBy.addValueChangeHandler(onChangeSave);
agreementsPanel.add(useSignedOffBy); agreementsPanel.add(useSignedOffBy);
body.add(agreementsPanel); add(agreementsPanel);
} }
private void setSubmitType(final Project.SubmitType newSubmitType) { private void setSubmitType(final Project.SubmitType newSubmitType) {
@@ -203,12 +198,6 @@ public class ProjectInfoPanel extends Composite {
result.canModifyDescription, result.canModifyMergeType); result.canModifyDescription, result.canModifyMergeType);
display(result); display(result);
} }
@Override
public void onFailure(final Throwable caught) {
refresh();
super.onFailure(caught);
}
}); });
} }
} }

View File

@@ -105,7 +105,7 @@ public class ProjectListScreen extends Screen {
} }
private String link(final Project item) { private String link(final Project item) {
return Dispatcher.toProjectAdmin(item.getNameKey(), ProjectAdminScreen.INFO_TAB); return Dispatcher.toProjectAdmin(item.getNameKey(), ProjectScreen.INFO);
} }
void display(final List<Project> result) { void display(final List<Project> result) {

View File

@@ -0,0 +1,39 @@
// Copyright 2010 Google Inc. All Rights Reserved.
package com.google.gerrit.client.admin;
import static com.google.gerrit.client.Dispatcher.toProjectAdmin;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.ui.MenuScreen;
import com.google.gerrit.reviewdb.Project;
public abstract class ProjectScreen extends MenuScreen {
public static final String INFO = "info";
public static final String BRANCH = "branches";
public static final String ACCESS = "access";
private final Project.NameKey name;
public ProjectScreen(final Project.NameKey toShow) {
name = toShow;
final boolean isWild = toShow.equals(Gerrit.getConfig().getWildProject());
link(Util.C.projectAdminTabGeneral(), toProjectAdmin(name, INFO));
if (!isWild) {
link(Util.C.projectAdminTabBranches(), toProjectAdmin(name, BRANCH));
}
link(Util.C.projectAdminTabAccess(), toProjectAdmin(name, ACCESS));
}
protected Project.NameKey getProjectKey() {
return name;
}
@Override
protected void onInitUI() {
super.onInitUI();
setPageTitle(Util.M.project(name.get()));
}
}

View File

@@ -113,6 +113,29 @@
} }
/** MenuScreen **/
.menuScreenMenuBar {
background: topMenuColor;
padding-top: 0.5em;
padding-bottom: 10em;
padding-left: 0.5em;
padding-right: 0.5em;
border-right: 1px solid black;
margin-right: 0.5em;
}
.menuScreenMenuBar .menuItem {
white-space: nowrap;
display: block;
border-right: none;
padding: 0.2em;
}
.menuScreenMenuBar .menuItem.activeRow {
background: selectionColor;
}
/** CommentPanel **/ /** CommentPanel **/
.commentPanelBorder { .commentPanelBorder {
border-top: 1px solid lightgray; border-top: 1px solid lightgray;

View File

@@ -47,6 +47,18 @@ public class LinkMenuBar extends Composite {
body.clear(); body.clear();
} }
public LinkMenuItem find(String targetToken) {
for (Widget w : body) {
if (w instanceof LinkMenuItem) {
LinkMenuItem m = (LinkMenuItem) w;
if (targetToken.equals(m.getTargetHistoryToken())) {
return m;
}
}
}
return null;
}
public void add(final Widget i) { public void add(final Widget i) {
if (body.getWidgetCount() > 0) { if (body.getWidgetCount() > 0) {
final Widget p = body.getWidget(body.getWidgetCount() - 1); final Widget p = body.getWidget(body.getWidgetCount() - 1);

View File

@@ -0,0 +1,61 @@
// 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.ui;
import com.google.gerrit.client.Gerrit;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
public abstract class MenuScreen extends Screen {
private final LinkMenuBar menu;
private final FlowPanel body;
public MenuScreen() {
menu = new LinkMenuBar();
menu.setStyleName(Gerrit.RESOURCES.css().menuScreenMenuBar());
body = new FlowPanel();
}
@Override
protected void onInitUI() {
super.onInitUI();
HorizontalPanel hp = new HorizontalPanel();
hp.add(menu);
hp.add(body);
super.add(hp);
}
@Override
public void setToken(String token) {
LinkMenuItem self = menu.find(token);
if (self != null) {
self.addStyleName(Gerrit.RESOURCES.css().activeRow());
}
super.setToken(token);
}
@Override
protected void add(final Widget w) {
body.add(w);
}
protected void link(String text, String target) {
final LinkMenuItem item = new LinkMenuItem(text, target);
item.setStyleName(Gerrit.RESOURCES.css().menuItem());
menu.add(item);
}
}

View File

@@ -72,7 +72,7 @@ public abstract class Screen extends View {
header.insert(w, 0); header.insert(w, 0);
} }
protected final void add(final Widget w) { protected void add(final Widget w) {
body.add(w); body.add(w);
} }