public static void refreshMenuBar() {
menuLeft.clear();
menuRight.clear();
final boolean signedIn = isSignedIn();
final GerritConfig cfg = getConfig();
LinkMenuBar m;
m = new LinkMenuBar();
addLink(m, C.menuAllOpen(), PageLinks.toChangeQuery("status:open"));
addLink(m, C.menuAllMerged(), PageLinks.toChangeQuery("status:merged"));
addLink(m, C.menuAllAbandoned(), PageLinks.toChangeQuery("status:abandoned"));
menuLeft.add(m, C.menuAll());
if (signedIn) {
m = new LinkMenuBar();
addLink(m, C.menuMyChanges(), PageLinks.MINE);
addLink(m, C.menuMyDrafts(), PageLinks.toChangeQuery("is:draft"));
addLink(m, C.menuMyWatchedChanges(), PageLinks.toChangeQuery("is:watched status:open"));
addLink(m, C.menuMyStarredChanges(), PageLinks.toChangeQuery("is:starred"));
addLink(m, C.menuMyDraftComments(), PageLinks.toChangeQuery("has:draft"));
menuLeft.add(m, C.menuMine());
menuLeft.selectTab(1);
} else {
menuLeft.selectTab(0);
}
patchScreen = null;
diffBar = new LinkMenuBar();
menuLeft.addInvisible(diffBar, C.menuDiff());
addDiffLink(diffBar, CC.patchTableDiffSideBySide(), PatchScreen.Type.SIDE_BY_SIDE);
addDiffLink(diffBar, CC.patchTableDiffUnified(), PatchScreen.Type.UNIFIED);
addDiffLink(diffBar, C.menuDiffCommit(), PatchScreen.TopView.COMMIT);
addDiffLink(diffBar, C.menuDiffPreferences(), PatchScreen.TopView.PREFERENCES);
addDiffLink(diffBar, C.menuDiffPatchSets(), PatchScreen.TopView.PATCH_SETS);
addDiffLink(diffBar, C.menuDiffFiles(), PatchScreen.TopView.FILES);
if (signedIn) {
final LinkMenuBar menuBar = new LinkMenuBar();
addLink(menuBar, C.menuGroups(), PageLinks.ADMIN_GROUPS);
addLink(menuBar, C.menuProjects(), PageLinks.ADMIN_PROJECTS);
AccountCapabilities.all(new GerritCallback<AccountCapabilities>() {
@Override
public void onSuccess(AccountCapabilities result) {
if (result.canPerform(ADMINISTRATE_SERVER)) {
addLink(menuBar, C.menuPlugins(), PageLinks.ADMIN_PLUGINS);
}
}
}, ADMINISTRATE_SERVER);
menuLeft.add(menuBar, C.menuAdmin());
}
if (getConfig().isDocumentationAvailable()) {
m = new LinkMenuBar();
addDocLink(m, C.menuDocumentationIndex(), "index.html");
addDocLink(m, C.menuDocumentationSearch(), "user-search.html");
addDocLink(m, C.menuDocumentationUpload(), "user-upload.html");
addDocLink(m, C.menuDocumentationAccess(), "access-control.html");
menuLeft.add(m, C.menuDocumentation());
}
if (signedIn) {
whoAmI();
addLink(menuRight, C.menuSettings(), PageLinks.SETTINGS);
if (cfg.getAuthType() != AuthType.CLIENT_SSL_CERT_LDAP) {
menuRight.add(anchor(C.menuSignOut(), selfRedirect("/logout")));
}
} else {
switch (cfg.getAuthType()) {
case HTTP:
case HTTP_LDAP:
case CLIENT_SSL_CERT_LDAP:
break;
case OPENID:
menuRight.addItem(C.menuRegister(), new Command() {
public void execute() {
final String to = History.getToken();
new OpenIdSignInDialog(SignInMode.REGISTER, to, null).center();
}
});
menuRight.addItem(C.menuSignIn(), new Command() {
public void execute() {
doSignIn(History.getToken());
}
});
break;
case LDAP:
case LDAP_BIND:
case CUSTOM_EXTENSION:
if (cfg.getRegisterUrl() != null) {
menuRight.add(anchor(C.menuRegister(), cfg.getRegisterUrl()));
}
signInAnchor = anchor(C.menuSignIn(), loginRedirect(History.getToken()));
menuRight.add(signInAnchor);
break;