use of com.google.gerrit.client.ui.Screen in project gerrit by GerritCodeReview.
the class Dispatcher method admin.
private static void admin(String token) {
GWT.runAsync(new AsyncSplit(token) {
@Override
public void onSuccess() {
if (matchExact(ADMIN_GROUPS, token) || matchExact("/admin/groups", token)) {
Gerrit.display(token, new GroupListScreen());
} else if (matchPrefix(ADMIN_GROUPS, token)) {
String rest = skip(token);
if (rest.startsWith("?")) {
Gerrit.display(token, new GroupListScreen(rest.substring(1)));
} else {
group();
}
} else if (matchPrefix("/admin/groups", token)) {
String rest = skip(token);
if (rest.startsWith("?")) {
Gerrit.display(token, new GroupListScreen(rest.substring(1)));
}
} else if (matchExact(ADMIN_PROJECTS, token) || matchExact("/admin/projects", token)) {
Gerrit.display(token, new ProjectListScreen());
} else if (matchPrefix(ADMIN_PROJECTS, token)) {
String rest = skip(token);
if (rest.startsWith("?")) {
Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
} else {
Gerrit.display(token, selectProject());
}
} else if (matchPrefix("/admin/projects", token)) {
String rest = skip(token);
if (rest.startsWith("?")) {
Gerrit.display(token, new ProjectListScreen(rest.substring(1)));
}
} else if (matchPrefix(ADMIN_PLUGINS, token) || matchExact("/admin/plugins", token)) {
Gerrit.display(token, new PluginListScreen());
} else if (matchExact(ADMIN_CREATE_PROJECT, token) || matchExact("/admin/create-project", token)) {
Gerrit.display(token, new CreateProjectScreen());
} else if (matchExact(ADMIN_CREATE_GROUP, token) || matchExact("/admin/create-group", token)) {
Gerrit.display(token, new CreateGroupScreen());
} else {
Gerrit.display(token, new NotFoundScreen());
}
}
private void group() {
final String panel;
final String group;
if (matchPrefix("/admin/groups/uuid-", token)) {
String p = skip(token);
int c = p.indexOf(',');
if (c < 0) {
group = p;
panel = null;
} else {
group = p.substring(0, c);
panel = p.substring(c + 1);
}
} else if (matchPrefix(ADMIN_GROUPS, token)) {
String p = skip(token);
int c = p.indexOf(',');
if (c < 0) {
group = p;
panel = null;
} else {
group = p.substring(0, c);
panel = p.substring(c + 1);
}
} else {
Gerrit.display(token, new NotFoundScreen());
return;
}
GroupApi.getGroupDetail(group, new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(GroupInfo group) {
if (panel == null || panel.isEmpty()) {
//
if (AccountGroup.isInternalGroup(group.getGroupUUID())) {
String newToken = toGroup(group.getGroupId(), AccountGroupScreen.MEMBERS);
Gerrit.display(newToken, new AccountGroupMembersScreen(group, newToken));
} else {
String newToken = toGroup(group.getGroupId(), AccountGroupScreen.INFO);
Gerrit.display(newToken, new AccountGroupInfoScreen(group, newToken));
}
} else if (AccountGroupScreen.INFO.equals(panel)) {
Gerrit.display(token, new AccountGroupInfoScreen(group, token));
} else if (AccountGroupScreen.MEMBERS.equals(panel)) {
Gerrit.display(token, new AccountGroupMembersScreen(group, token));
} else if (AccountGroupScreen.AUDIT_LOG.equals(panel)) {
Gerrit.display(token, new AccountGroupAuditLogScreen(group, token));
} else {
Gerrit.display(token, new NotFoundScreen());
}
}
});
}
private Screen selectProject() {
if (matchPrefix(ADMIN_PROJECTS, token)) {
String rest = skip(token);
int c = rest.lastIndexOf(',');
if (c < 0) {
return new ProjectInfoScreen(Project.NameKey.parse(rest));
} else if (c == 0) {
return new NotFoundScreen();
}
int q = rest.lastIndexOf('?');
if (q > 0 && rest.lastIndexOf(',', q) > 0) {
c = rest.substring(0, q - 1).lastIndexOf(',');
}
Project.NameKey k = Project.NameKey.parse(rest.substring(0, c));
String panel = rest.substring(c + 1);
if (ProjectScreen.INFO.equals(panel)) {
return new ProjectInfoScreen(k);
}
if (ProjectScreen.BRANCHES.equals(panel) || matchPrefix(ProjectScreen.BRANCHES, panel)) {
return new ProjectBranchesScreen(k);
}
if (ProjectScreen.TAGS.equals(panel) || matchPrefix(ProjectScreen.TAGS, panel)) {
return new ProjectTagsScreen(k);
}
if (ProjectScreen.ACCESS.equals(panel)) {
return new ProjectAccessScreen(k);
}
if (ProjectScreen.DASHBOARDS.equals(panel)) {
return new ProjectDashboardsScreen(k);
}
}
return new NotFoundScreen();
}
});
}
use of com.google.gerrit.client.ui.Screen in project gerrit by GerritCodeReview.
the class Dispatcher method mine.
private static Screen mine() {
if (Gerrit.isSignedIn()) {
return new AccountDashboardScreen(Gerrit.getUserAccount().getId());
}
Screen r = new AccountDashboardScreen(null);
r.setRequiresSignIn(true);
return r;
}
use of com.google.gerrit.client.ui.Screen in project gerrit by GerritCodeReview.
the class Gerrit method onModuleLoad2.
private void onModuleLoad2(HostPageData hpd) {
RESOURCES.gwt_override().ensureInjected();
RESOURCES.css().ensureInjected();
topMenu = RootPanel.get("gerrit_topmenu");
final RootPanel gStarting = RootPanel.get("gerrit_startinggerrit");
final RootPanel gBody = RootPanel.get("gerrit_body");
bottomMenu = RootPanel.get("gerrit_btmmenu");
topMenu.setStyleName(RESOURCES.css().gerritTopMenu());
gBody.setStyleName(RESOURCES.css().gerritBody());
final Grid menuLine = new Grid(1, 3);
menuLeft = new MorphingTabPanel();
menuRight = new LinkMenuBar();
searchPanel = new SearchPanel();
menuLeft.setStyleName(RESOURCES.css().topmenuMenuLeft());
menuLine.setStyleName(RESOURCES.css().topmenu());
topMenu.add(menuLine);
final FlowPanel menuRightPanel = new FlowPanel();
menuRightPanel.setStyleName(RESOURCES.css().topmenuMenuRight());
menuRightPanel.add(searchPanel);
menuRightPanel.add(menuRight);
menuLine.setWidget(0, 0, menuLeft);
menuLine.setWidget(0, 1, new FlowPanel());
menuLine.setWidget(0, 2, menuRightPanel);
final CellFormatter fmt = menuLine.getCellFormatter();
fmt.setStyleName(0, 0, RESOURCES.css().topmenuTDmenu());
fmt.setStyleName(0, 1, RESOURCES.css().topmenuTDglue());
fmt.setStyleName(0, 2, RESOURCES.css().topmenuTDmenu());
siteHeader = RootPanel.get("gerrit_header");
siteFooter = RootPanel.get("gerrit_footer");
body = new ViewSite<Screen>() {
@Override
protected void onShowView(Screen view) {
String token = view.getToken();
History.newItem(token, false);
dispatchHistoryHooks(token);
if (view instanceof ChangeListScreen) {
lastChangeListToken = token;
}
super.onShowView(view);
view.onShowView();
lastViewToken = token;
}
};
gBody.add(body);
JsonUtil.addRpcStartHandler(RpcStatus.INSTANCE);
JsonUtil.addRpcCompleteHandler(RpcStatus.INSTANCE);
gStarting.getElement().getParentElement().removeChild(gStarting.getElement());
RootPanel.detachNow(gStarting);
ApiGlue.init();
applyUserPreferences();
populateBottomMenu(bottomMenu, hpd);
refreshMenuBar();
History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
display(event.getValue());
}
});
JumpKeys.register(body);
saveDefaultTheme();
if (hpd.messages != null) {
new MessageOfTheDayBar(hpd.messages).show();
}
PluginLoader.load(hpd.plugins, hpd.pluginsLoadTimeout, new GerritCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult result) {
String token = History.getToken();
if (token.isEmpty()) {
token = isSignedIn() ? PageLinks.MINE : PageLinks.toChangeQuery("status:open");
}
display(token);
}
});
}
use of com.google.gerrit.client.ui.Screen in project gerrit by GerritCodeReview.
the class Dispatcher method query.
private static void query(String token) {
String s = skip(token);
int c = s.indexOf(',');
Screen screen;
if (c >= 0) {
String prefix = s.substring(0, c);
if (s.substring(c).equals(",n,z")) {
// Respect legacy token with max sortkey.
screen = new QueryScreen(prefix, 0);
} else {
screen = new QueryScreen(prefix, Integer.parseInt(s.substring(c + 1)));
}
} else {
screen = new QueryScreen(s, 0);
}
Gerrit.display(token, screen);
}
use of com.google.gerrit.client.ui.Screen in project gerrit by GerritCodeReview.
the class Dispatcher method dashboard.
private static void dashboard(final String token) {
String rest = skip(token);
if (rest.matches("[0-9]+")) {
Gerrit.display(token, new AccountDashboardScreen(Account.Id.parse(rest)));
return;
}
if (rest.equals("self")) {
if (Gerrit.isSignedIn()) {
Gerrit.display(token, new AccountDashboardScreen(Gerrit.getUserAccount().getId()));
} else {
Screen s = new AccountDashboardScreen(null);
s.setRequiresSignIn(true);
Gerrit.display(token, s);
}
return;
}
if (rest.startsWith("?")) {
Gerrit.display(token, new CustomDashboardScreen(rest.substring(1)));
return;
}
Gerrit.display(token, new NotFoundScreen());
}
Aggregations