Initial code commit
This initial code commit adds "Dependency" info to the change screen.
Dependency refers to the change that is a depenency of this change.
In other words its the reverse lookup for zuul's 'depends-on:'
reference
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/Chound.gwt.xml b/src/main/java/com/googlesource/gerrit/plugins/chound/Chound.gwt.xml
new file mode 100644
index 0000000..9284d1e
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/Chound.gwt.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2016 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 rename-to="Chound">
+ <!-- Inherit the core Web Toolkit stuff. -->
+ <inherits name="com.google.gwt.user.User"/>
+ <!-- Other module inherits -->
+ <inherits name="com.google.gerrit.Plugin"/>
+ <inherits name="com.google.gwt.http.HTTP"/>
+ <!-- Using GWT built-in themes adds a number of static -->
+ <!-- resources to the plugin. No theme inherits lines were -->
+ <!-- added in order to make this plugin as simple as possible -->
+ <!-- Specify the app entry point class. -->
+ <entry-point class="com.googlesource.gerrit.plugins.chound.client.ChoundPlugin"/>
+ <stylesheet src="chound.css"/>
+</module>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/chound/HttpModule.java
new file mode 100644
index 0000000..2e6220b
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/HttpModule.java
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 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.googlesource.gerrit.plugins.chound;
+
+import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.extensions.webui.GwtPlugin;
+import com.google.gerrit.extensions.webui.WebUiPlugin;
+import com.google.gerrit.httpd.plugins.HttpPluginModule;
+
+public class HttpModule extends HttpPluginModule {
+
+ @Override
+ protected void configureServlets() {
+ DynamicSet.bind(binder(), WebUiPlugin.class)
+ .toInstance(new GwtPlugin("Chound"));
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/Module.java b/src/main/java/com/googlesource/gerrit/plugins/chound/Module.java
new file mode 100644
index 0000000..460d954
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/Module.java
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 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.googlesource.gerrit.plugins.chound;
+
+import com.google.gerrit.extensions.restapi.RestApiModule;
+import com.google.inject.AbstractModule;
+
+public class Module extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ install(new RestApiModule() {
+ @Override
+ protected void configure() {
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/chound.css b/src/main/java/com/googlesource/gerrit/plugins/chound/chound.css
new file mode 100644
index 0000000..bdd428e
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/chound.css
@@ -0,0 +1,6 @@
+.commitExtension {
+ padding-top: 0px;
+ padding: 0;
+ vertical-align: top;
+}
+.commitExtension { width: COMMIT_WIDTH; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/client/ChoundPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/chound/client/ChoundPlugin.java
new file mode 100644
index 0000000..b5ed208
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/client/ChoundPlugin.java
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 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.googlesource.gerrit.plugins.chound.client;
+
+import com.google.gerrit.client.GerritUiExtensionPoint;
+import com.google.gerrit.client.Resources;
+import com.google.gerrit.plugin.client.Plugin;
+import com.google.gerrit.plugin.client.PluginEntryPoint;
+import com.google.gwt.core.client.GWT;
+
+public class ChoundPlugin extends PluginEntryPoint {
+ public static final Resources RESOURCES = GWT.create(Resources.class);
+
+ @Override
+ public void onPluginLoad() {
+
+ Plugin.get().panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_COMMIT_INFO_BLOCK,
+ new LabelPanel.Factory());
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java b/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java
new file mode 100644
index 0000000..46be76e
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/chound/client/LabelPanel.java
@@ -0,0 +1,70 @@
+// Copyright (C) 2016 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.googlesource.gerrit.plugins.chound.client;
+
+import com.google.gerrit.client.GerritUiExtensionPoint;
+import com.google.gerrit.client.info.ChangeInfo;
+import com.google.gerrit.client.rpc.NativeMap;
+import com.google.gerrit.plugin.client.extension.Panel;
+import com.google.gerrit.plugin.client.rpc.RestApi;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.InlineHyperlink;
+import com.google.gwt.user.client.ui.InlineLabel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class LabelPanel extends VerticalPanel {
+ static class Factory implements Panel.EntryPoint {
+ @Override
+ public void onLoad(Panel panel) {
+ panel.setWidget(new LabelPanel(panel));
+ }
+ }
+
+ LabelPanel(final Panel panel) {
+ ChangeInfo change =
+ panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
+ RestApi r = new RestApi("changes")
+ .view("?q=message:" + change.changeId())
+ .view("+NOT+change:" + change.changeId());
+ r.get(new AsyncCallback<NativeMap<ChangeInfo>>() {
+ @Override
+ public void onSuccess(NativeMap<ChangeInfo> result) {
+ if (!result.isEmpty()) {
+ display(result);
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
+ }
+
+ private void display(NativeMap<ChangeInfo> result) {
+ if (!result.isEmpty()) {
+ HorizontalPanel p = new HorizontalPanel();
+ InlineLabel il = new InlineLabel("Dependency");
+ p.add(il);
+ for (String key : result.keySet()) {
+ InlineHyperlink ih = new InlineHyperlink(
+ result.get(key).changeId(), "/c/" + result.get(key)._number());
+ p.add(ih);
+ }
+ add(p);
+ }
+ }
+}
\ No newline at end of file