// Copyright (C) 2012 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;

import com.google.gerrit.extensions.annotations.PluginName;
import com.google.inject.Inject;

/**
 * Specifies JavaScript to dynamically load into the web UI.
 *
 * @see GwtPlugin
 * @see JavaScriptPlugin
 */
public abstract class WebUiPlugin {
  public static final GwtPlugin gwt(String moduleName) {
    return new GwtPlugin(moduleName);
  }

  public static final JavaScriptPlugin js(String scriptName) {
    return new JavaScriptPlugin(scriptName);
  }

  private String pluginName;

  /** @return installed name of the plugin that provides this UI feature.  */
  public final String getPluginName() {
    return pluginName;
  }

  @Inject
  void setPluginName(@PluginName String pluginName) {
    this.pluginName = pluginName;
  }

  /** @return path to initialization script within the plugin's JAR. */
  public abstract String getJavaScriptResourcePath();

  @Override
  public String toString() {
    return getJavaScriptResourcePath();
  }
}

@@ -647,16 +647,80 @@
 webui;%0A%0A
+import com.google.gerrit.extensions.annotations.ExtensionPoint;%0A
 import c
@@ -771,16 +771,16 @@
 inName;%0A
-
 import c
@@ -870,16 +870,365 @@
 web UI.%0A
+ * %3Cp%3E%0A * To automatically register (instead of writing a Guice module), declare the%0A * intention with %7B@code @Listen%7D, extend the correct class and define a%0A * constructor to configure the correct resource:%0A *%0A * %3Cpre%3E%0A * &#064;Listen%0A * class MyJs extends JavaScriptPlugin %7B%0A *   MyJs() %7B%0A *     super(&quot;hello.js&quot;);%0A *   %7D%0A * %7D%0A * %3C/pre%3E%0A
  *%0A * @s
@@ -1265,20 +1265,36 @@
 tPlugin%0A
-
  */%0A
+@ExtensionPoint%0A
 public a

Allow web UI plugins to auto-register