summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza <dariusz@luksza.org>2013-10-01 11:07:13 +0200
committerShawn Pearce <sop@google.com>2013-10-16 11:19:29 -0700
commit2d3afab63f4084874933f5b2484a754b3549f1c4 (patch)
treed0c4e99085464ee15140599b0bb43788276438c4
parenta5c3ef93ab43e29e51386e733d2b3a091767974a (diff)
Create enum containing all Gerrit top menu items
Instead of relying on string names for Gerrit's top menu items, provide an enumeration that contains definitions of all top items. It also adds GWT Extensions module to fulfill compilation dependency for gwtui. Change-Id: I7a109885b9a65b132e7119851cd76be527f75364 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
-rw-r--r--Documentation/dev-plugins.txt2
-rw-r--r--gerrit-extension-api/BUCK13
-rw-r--r--gerrit-extension-api/src/main/java/com/google/gerrit/extensions/Extensions.gwt.xml18
-rw-r--r--gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/GerritTopMenu.java25
-rw-r--r--gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/TopMenu.java5
-rw-r--r--gerrit-gwtui/BUCK2
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml1
-rw-r--r--gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java24
8 files changed, 70 insertions, 20 deletions
diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt
index 6023d05365..dcf176e34c 100644
--- a/Documentation/dev-plugins.txt
+++ b/Documentation/dev-plugins.txt
@@ -837,7 +837,7 @@ public class MyTopMenuExtension implements TopMenu {
@Override
public List<MenuEntry> getEntries() {
return Lists.newArrayList(
- new MenuEntry("Projects", Lists.newArrayList(
+ new MenuEntry(GerritTopMenu.PROJECTS, Lists.newArrayList(
new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/"))));
}
}
diff --git a/gerrit-extension-api/BUCK b/gerrit-extension-api/BUCK
index 41456364ff..5aa57dde14 100644
--- a/gerrit-extension-api/BUCK
+++ b/gerrit-extension-api/BUCK
@@ -1,14 +1,21 @@
-SRCS = glob(['src/main/java/com/google/gerrit/extensions/**/*.java'])
+SRC = 'src/main/java/com/google/gerrit/extensions/'
+
+gwt_module(
+ name = 'client',
+ srcs = glob([SRC + 'webui/GerritTopMenu.java']),
+ gwtxml = SRC + 'Extensions.gwt.xml',
+ visibility = ['PUBLIC'],
+)
java_library2(
name = 'api',
- srcs = SRCS,
+ srcs = glob([SRC + '**/*.java']),
compile_deps = ['//lib/guice:guice'],
visibility = ['PUBLIC'],
)
java_sources(
name = 'api-src',
- srcs = SRCS,
+ srcs = glob([SRC + '**/*.java']),
visibility = ['PUBLIC'],
)
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/Extensions.gwt.xml b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/Extensions.gwt.xml
new file mode 100644
index 0000000000..ef6a8271ef
--- /dev/null
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/Extensions.gwt.xml
@@ -0,0 +1,18 @@
+<!--
+ Copyright (C) 2013 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.
+-->
+<module>
+ <source path='webui' />
+</module>
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/GerritTopMenu.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/GerritTopMenu.java
new file mode 100644
index 0000000000..e3821fca74
--- /dev/null
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/GerritTopMenu.java
@@ -0,0 +1,25 @@
+// Copyright (C) 2013 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.extensions.webui;
+
+public enum GerritTopMenu {
+ ALL, MY, DIFFERENCES, PROJECTS, PEOPLE, PLUGINS, DOCUMENTATION;
+
+ public final String menuName;
+
+ private GerritTopMenu() {
+ menuName = name().substring(0, 1) + name().substring(1).toLowerCase();
+ }
+}
diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/TopMenu.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/TopMenu.java
index ecb7d42e5a..7389519fc1 100644
--- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/TopMenu.java
+++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/webui/TopMenu.java
@@ -20,11 +20,14 @@ import java.util.List;
@ExtensionPoint
public interface TopMenu {
-
public class MenuEntry {
public final String name;
public final List<MenuItem> items;
+ public MenuEntry(GerritTopMenu gerritMenu, List<MenuItem> items) {
+ this(gerritMenu.menuName, items);
+ }
+
public MenuEntry(String name, List<MenuItem> items) {
this.name = name;
this.items = items;
diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK
index 6024481f10..1ae823e24d 100644
--- a/gerrit-gwtui/BUCK
+++ b/gerrit-gwtui/BUCK
@@ -70,6 +70,7 @@ gwt_module(
'//gerrit-gwtexpui:SafeHtml',
'//gerrit-gwtexpui:UserAgent',
'//gerrit-common:client',
+ '//gerrit-extension-api:client',
'//gerrit-patch-jgit:client',
'//gerrit-prettify:client',
'//gerrit-reviewdb:client',
@@ -117,6 +118,7 @@ java_test(
deps = [
':ui_module',
'//gerrit-common:client',
+ '//gerrit-extension-api:client',
'//lib:junit',
'//lib/gwt:dev',
'//lib/gwt:user',
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml b/gerrit-gwtui/src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml
index d33a525e3e..9fe04bc8ea 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml
@@ -24,6 +24,7 @@
<inherits name='com.google.gwtexpui.linker.ServerPlannedIFrameLinker'/>
<inherits name='com.google.gwtexpui.progress.Progress'/>
<inherits name='com.google.gwtexpui.safehtml.SafeHtml'/>
+ <inherits name='com.google.gerrit.extensions.Extensions'/>
<inherits name='com.google.gerrit.prettify.PrettyFormatter'/>
<inherits name='com.google.gerrit.Common'/>
<inherits name='com.google.gerrit.UserAgent'/>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
index 2f594357e2..fc2d9f66e7 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
@@ -42,6 +42,7 @@ import com.google.gerrit.common.data.GerritConfig;
import com.google.gerrit.common.data.GitwebConfig;
import com.google.gerrit.common.data.HostPageData;
import com.google.gerrit.common.data.SystemInfoService;
+import com.google.gerrit.extensions.webui.GerritTopMenu;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
@@ -113,13 +114,6 @@ public class Gerrit implements EntryPoint {
private static AccountDiffPreference myAccountDiffPref;
private static String xGerritAuth;
- private static final String ALL_BAR = "All";
- private static final String MY_BAR = "My";
- private static final String DIFF_BAR = "Differences";
- private static final String PROJECTS_BAR = "Projects";
- private static final String PEOPLE_BAR = "People";
- private static final String PLUGINS_BAR = "Plugins";
- private static final String DOCUMENTATION_BAR = "Documentation";
private static Map<String, LinkMenuBar> menuBars;
private static MorphingTabPanel menuLeft;
@@ -210,7 +204,7 @@ public class Gerrit implements EntryPoint {
* @param view the loaded view.
*/
public static void updateMenus(Screen view) {
- LinkMenuBar diffBar = menuBars.get(DIFF_BAR);
+ LinkMenuBar diffBar = menuBars.get(GerritTopMenu.DIFFERENCES.menuName);
if (view instanceof PatchScreen) {
patchScreen = (PatchScreen) view;
menuLeft.setVisible(diffBar, true);
@@ -671,7 +665,7 @@ public class Gerrit implements EntryPoint {
LinkMenuBar m;
m = new LinkMenuBar();
- menuBars.put(ALL_BAR, m);
+ menuBars.put(GerritTopMenu.ALL.menuName, m);
addLink(m, C.menuAllOpen(), PageLinks.toChangeQuery("status:open"));
addLink(m, C.menuAllMerged(), PageLinks.toChangeQuery("status:merged"));
addLink(m, C.menuAllAbandoned(), PageLinks.toChangeQuery("status:abandoned"));
@@ -679,7 +673,7 @@ public class Gerrit implements EntryPoint {
if (signedIn) {
m = new LinkMenuBar();
- menuBars.put(MY_BAR, m);
+ menuBars.put(GerritTopMenu.MY.menuName, m);
addLink(m, C.menuMyChanges(), PageLinks.MINE);
addLink(m, C.menuMyDrafts(), PageLinks.toChangeQuery("is:draft"));
addLink(m, C.menuMyDraftComments(), PageLinks.toChangeQuery("has:draft"));
@@ -693,7 +687,7 @@ public class Gerrit implements EntryPoint {
patchScreen = null;
LinkMenuBar diffBar = new LinkMenuBar();
- menuBars.put(DIFF_BAR, diffBar);
+ menuBars.put(GerritTopMenu.DIFFERENCES.menuName, diffBar);
menuLeft.addInvisible(diffBar, C.menuDiff());
addDiffLink(diffBar, CC.patchTableDiffSideBySide(), PatchScreen.Type.SIDE_BY_SIDE);
addDiffLink(diffBar, CC.patchTableDiffUnified(), PatchScreen.Type.UNIFIED);
@@ -710,7 +704,7 @@ public class Gerrit implements EntryPoint {
}
}
};
- menuBars.put(PROJECTS_BAR, projectsBar);
+ menuBars.put(GerritTopMenu.PROJECTS.menuName, projectsBar);
addLink(projectsBar, C.menuProjectsList(), PageLinks.ADMIN_PROJECTS);
addProjectLink(projectsBar, C.menuProjectsInfo(), ProjectScreen.INFO);
addProjectLink(projectsBar, C.menuProjectsBranches(), ProjectScreen.BRANCH);
@@ -722,13 +716,13 @@ public class Gerrit implements EntryPoint {
if (signedIn) {
final LinkMenuBar peopleBar = new LinkMenuBar();
- menuBars.put(PEOPLE_BAR, peopleBar);
+ menuBars.put(GerritTopMenu.PEOPLE.menuName, peopleBar);
final LinkMenuItem groupsListMenuItem =
addLink(peopleBar, C.menuPeopleGroupsList(), PageLinks.ADMIN_GROUPS);
menuLeft.add(peopleBar, C.menuPeople());
final LinkMenuBar pluginsBar = new LinkMenuBar();
- menuBars.put(PLUGINS_BAR, pluginsBar);
+ menuBars.put(GerritTopMenu.PLUGINS.menuName, pluginsBar);
AccountCapabilities.all(new GerritCallback<AccountCapabilities>() {
@Override
public void onSuccess(AccountCapabilities result) {
@@ -754,7 +748,7 @@ public class Gerrit implements EntryPoint {
if (getConfig().isDocumentationAvailable()) {
m = new LinkMenuBar();
- menuBars.put(DOCUMENTATION_BAR, m);
+ menuBars.put(GerritTopMenu.DOCUMENTATION.menuName, m);
addDocLink(m, C.menuDocumentationIndex(), "index.html");
addDocLink(m, C.menuDocumentationSearch(), "user-search.html");
addDocLink(m, C.menuDocumentationUpload(), "user-upload.html");