org.sonar.plugins.api.web.gwt.client
Class ResourceWidget

java.lang.Object
  extended by org.sonar.plugins.api.web.gwt.client.ResourceWidget
All Implemented Interfaces:
com.google.gwt.core.client.EntryPoint
Direct Known Subclasses:
AbstractResourceTab

public abstract class ResourceWidget
extends java.lang.Object
implements com.google.gwt.core.client.EntryPoint


Nested Class Summary
 class ResourceWidget.StandAloneResourceHandler
           
 
Constructor Summary
ResourceWidget()
           
 
Method Summary
protected abstract  void exportJavascript()
          Export GWT javascript methods to load and control the plugin, must export currently 2 method : I.E for plugin GWT id : foo.bar.MyPlugin, class foo.bar.client.MyPlugin : $wnd.load_foo_bar_MyPlugin = function() { called to the plugin init from JS obj.@foo.bar.client.MyPlugin::loadContainer()(); } $wnd.on_resource_loaded_foo_bar_MyPlugin = function() { called when a resource JSON object has been refreshed within the page obj.@foo.bar.client.MyPlugin::onResourceLoaded()(); }
protected abstract  java.lang.String getGwtId()
          Return the GWT id of the widget
protected abstract  java.lang.String getHtmlRootId()
          Returns the root HTML ID to bind this widget with
 Resource getResource()
           
protected  com.google.gwt.core.client.JavaScriptObject getResourceJSONObject()
          Return a JavaScriptObject object containing all the measure available for the current resource key
protected abstract  boolean isDefault(WSMetrics.Metric metric, Resource resource)
          When multiple widgets are bound to the same HTML div, this method will indicate If the resource widget is the default one to show when the widget is initialized
protected abstract  boolean isForResource(Resource resource)
          When multiple widgets are in the same page, this method will indicate if the widget can be shown for the given resource
protected  boolean isMetricInList(WSMetrics.Metric metric, WSMetrics.Metric... metricsList)
          Finds if a given metric is in the provided metrics list
 void loadContainer()
          Called to render the widget for the given resource object loaded via the onResourceLoaded() method call
 void onModuleLoad()
           
 void onResourceLoaded()
          Called when a resource JSON object has been loaded within the page
protected abstract  com.google.gwt.user.client.ui.Panel render(com.google.gwt.user.client.ui.RootPanel root)
          Renders the widget for the current resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceWidget

public ResourceWidget()
Method Detail

onModuleLoad

public void onModuleLoad()
Specified by:
onModuleLoad in interface com.google.gwt.core.client.EntryPoint

getResource

public Resource getResource()

onResourceLoaded

public final void onResourceLoaded()
Called when a resource JSON object has been loaded within the page


loadContainer

public final void loadContainer()
Called to render the widget for the given resource object loaded via the onResourceLoaded() method call


getGwtId

protected abstract java.lang.String getGwtId()
Return the GWT id of the widget

Returns:
teh gwt id

render

protected abstract com.google.gwt.user.client.ui.Panel render(com.google.gwt.user.client.ui.RootPanel root)
Renders the widget for the current resource

Parameters:
root - the root html panel

getHtmlRootId

protected abstract java.lang.String getHtmlRootId()
Returns the root HTML ID to bind this widget with

Returns:
the html rood elment id

getResourceJSONObject

protected com.google.gwt.core.client.JavaScriptObject getResourceJSONObject()
Return a JavaScriptObject object containing all the measure available for the current resource key

Returns:
the JavaScriptObject instance, should never be null

exportJavascript

protected abstract void exportJavascript()
Export GWT javascript methods to load and control the plugin, must export currently 2 method : I.E for plugin GWT id : foo.bar.MyPlugin, class foo.bar.client.MyPlugin : $wnd.load_foo_bar_MyPlugin = function() { called to the plugin init from JS obj.@foo.bar.client.MyPlugin::loadContainer()(); } $wnd.on_resource_loaded_foo_bar_MyPlugin = function() { called when a resource JSON object has been refreshed within the page obj.@foo.bar.client.MyPlugin::onResourceLoaded()(); }


isDefault

protected abstract boolean isDefault(WSMetrics.Metric metric,
                                     Resource resource)
When multiple widgets are bound to the same HTML div, this method will indicate If the resource widget is the default one to show when the widget is initialized

Parameters:
metric - the metric for which the widget is shown, cannot be null
resource - the resource bound to the widget
Returns:
true or false

isMetricInList

protected boolean isMetricInList(WSMetrics.Metric metric,
                                 WSMetrics.Metric... metricsList)
Finds if a given metric is in the provided metrics list

Parameters:
metric - the metric to search
metricsList - the metric list
Returns:
true or false if not found

isForResource

protected abstract boolean isForResource(Resource resource)
When multiple widgets are in the same page, this method will indicate if the widget can be shown for the given resource

Parameters:
resource - the resource bound to the page
Returns:
true or false


Copyright © 2009 SonarSource SA. All Rights Reserved.