Merge "Add top menu extension point"
This commit is contained in:
@@ -24,8 +24,13 @@ import com.google.gerrit.client.admin.ProjectScreen;
|
||||
import com.google.gerrit.client.api.ApiGlue;
|
||||
import com.google.gerrit.client.changes.ChangeConstants;
|
||||
import com.google.gerrit.client.changes.ChangeListScreen;
|
||||
import com.google.gerrit.client.config.ConfigServerApi;
|
||||
import com.google.gerrit.client.extensions.TopMenu;
|
||||
import com.google.gerrit.client.extensions.TopMenuItem;
|
||||
import com.google.gerrit.client.extensions.TopMenuList;
|
||||
import com.google.gerrit.client.patches.PatchScreen;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
||||
import com.google.gerrit.client.ui.LinkMenuItem;
|
||||
import com.google.gerrit.client.ui.MorphingTabPanel;
|
||||
@@ -87,6 +92,7 @@ import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Gerrit implements EntryPoint {
|
||||
public static final GerritConstants C = GWT.create(GerritConstants.class);
|
||||
@@ -789,6 +795,18 @@ public class Gerrit implements EntryPoint {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ConfigServerApi.topMenus(new GerritCallback<TopMenuList>() {
|
||||
public void onSuccess(TopMenuList result) {
|
||||
List<TopMenu> topMenuExtensions = Natives.asList(result);
|
||||
for (TopMenu menu : topMenuExtensions) {
|
||||
LinkMenuBar bar = new LinkMenuBar();
|
||||
for (TopMenuItem item : Natives.asList(menu.getItems())) {
|
||||
addExtensionLink(bar, item);
|
||||
}
|
||||
menuLeft.add(bar, menu.getName());
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public static void applyUserPreferences() {
|
||||
@@ -921,4 +939,10 @@ public class Gerrit implements EntryPoint {
|
||||
atag.setTarget("_blank");
|
||||
m.add(atag);
|
||||
}
|
||||
|
||||
private static void addExtensionLink(final LinkMenuBar m, final TopMenuItem item) {
|
||||
final Anchor atag = anchor(item.getName(), item.getUrl());
|
||||
atag.setTarget(item.getTarget());
|
||||
m.add(atag);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user