Add example extension that shows a status in the change header bar

Change-Id: I32972f1c6e29719bd3b0950cb483282e3b27aa0a
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java
new file mode 100644
index 0000000..e0ceeed
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/ChangeScreenStatusExtension.java
@@ -0,0 +1,39 @@
+// Copyright (C) 2015 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.cookbook.client;
+
+import com.google.gerrit.plugin.client.extension.Panel;
+import com.google.gwt.dom.client.Style.Unit;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Image;
+import com.google.gwt.user.client.ui.InlineLabel;
+
+/**
+ * Extension for change screen that displays a status in the header bar.
+ */
+public class ChangeScreenStatusExtension extends FlowPanel {
+  static class Factory implements Panel.EntryPoint {
+    @Override
+    public void onLoad(Panel panel) {
+      panel.setWidget(new ChangeScreenStatusExtension());
+    }
+  }
+
+  ChangeScreenStatusExtension() {
+    getElement().getStyle().setPadding(5, Unit.PX);
+    add(new Image(CookBookPlugin.RESOURCES.greenCheck()));
+    add(new InlineLabel("OK"));
+  }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
index 9743fdd..36fe6a7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/CookBookPlugin.java
@@ -15,10 +15,14 @@
 package com.googlesource.gerrit.plugins.cookbook.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 CookBookPlugin extends PluginEntryPoint {
+  public static final Resources RESOURCES = GWT.create(Resources.class);
+
   @Override
   public void onPluginLoad() {
     Plugin.get().screen("", new IndexScreen.Factory());
@@ -27,5 +31,7 @@
     Plugin.get().panel(
         GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
         new CookBookChangeScreenExtension.Factory());
+    Plugin.get().panel(GerritUiExtensionPoint.CHANGE_SCREEN_HEADER,
+        new ChangeScreenStatusExtension.Factory());
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
index 0edf949..774ec3d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/client/IndexScreen.java
@@ -14,9 +14,7 @@
 
 package com.googlesource.gerrit.plugins.cookbook.client;
 
-import com.google.gerrit.client.Resources;
 import com.google.gerrit.plugin.client.screen.Screen;
-import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.core.client.Scheduler.ScheduledCommand;
 import com.google.gwt.event.dom.client.ClickEvent;
@@ -45,14 +43,13 @@
 
   private TextBox usernameTxt;
   private TextArea greetingTxt;
-  private Resources RESOURCES = GWT.create(Resources.class);
 
   IndexScreen() {
     setStyleName("cookbook-panel");
 
     Panel labelImagePanel = new HorizontalPanel();
     Panel usernamePanel = new VerticalPanel();
-    Image img = new Image(RESOURCES.info());
+    Image img = new Image(CookBookPlugin.RESOURCES.info());
     img.setTitle("User to send greetings to");
     labelImagePanel.add(new Label("Username"));
     labelImagePanel.add(img);