com.atlassian.plugin.web.descriptors
Class DefaultWebPanelModuleDescriptor

java.lang.Object
  extended by com.atlassian.plugin.descriptors.AbstractModuleDescriptor<T>
      extended by com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor<WebPanel>
          extended by com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor
All Implemented Interfaces:
ModuleDescriptor<WebPanel>, Resourced, StateAware, ConditionalDescriptor, ContextAware, WebFragmentModuleDescriptor<WebPanel>, WebPanelModuleDescriptor, WeightedDescriptor

public class DefaultWebPanelModuleDescriptor
extends AbstractWebFragmentModuleDescriptor<WebPanel>
implements WebPanelModuleDescriptor

The web panel module declares a single web panel in atlassian-plugin.xml. Its XML element contains a location string that should match existing locations in the host application where web panels can be embedded.

A web panel also contains a single resource child element that contains the contents of the web panel. This can be plain HTML, or a (velocity) template to provide dynamic content.

A resource element's type attribute identifies the format of the panel's content (currently "static" and "velocity" are supported) which allows the plugin framework to use the appropriate WebPanelRenderer.

A web panel's resource element can either contain its contents embedded in the resource element itself, as part of the atlassian-plugin.xml file, or it can link to a file on the classpath when the location attribute is used.

Examples

A web panel that contains static, embedded HTML:

     <web-panel key="myPanel" location="general">
         <resource name="view" type="static"><![CDATA[<b>Hello World!</b>]]></resource>
     </web-panel>
 

A web panel that contains an embedded velocity template:

     <web-panel key="myPanel" location="general">
         <resource name="view" type="velocity"><![CDATA[#set($name = 'foo')My name is $name]]></resource>
     </web-panel>
 

A web panel that contains uses a velocity template that is on the classpath (part of the plugin's jar file):

     <web-panel key="myPanel" location="general">
         <resource name="view" type="velocity" location="templates/pie.vm"/>
     </web-panel>
 

Finally it is also possible to provide your own custom class that is responsible for producing the panel's HTML, by using the descriptor's class attribute:

     <web-panel key="myPanel" location="general" class="com.example.FooWebPanel"/>
 
Note that FooWebPanel must implement WebPanel.

Since:
2.5.0

Field Summary
static String XML_ELEMENT_NAME
          Host applications should use this string when registering the web panel module descriptor.
 
Fields inherited from class com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor
condition, contextProvider, element, label, params, tooltip, webInterfaceManager
 
Fields inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
moduleClass, moduleClassName, moduleFactory, plugin, resources, singleton
 
Fields inherited from interface com.atlassian.plugin.web.descriptors.WebFragmentModuleDescriptor
COMPOSITE_TYPE_AND, COMPOSITE_TYPE_OR
 
Constructor Summary
DefaultWebPanelModuleDescriptor(HostContainer hostContainer, ModuleFactory moduleClassFactory, WebInterfaceManager webInterfaceManager)
           
 
Method Summary
 void disabled()
          Disables the module descriptor.
 void enabled()
          Enables the descriptor by loading the module class.
 String getLocation()
          Returns the location in the host application where the web panel should be embedded.
 WebPanel getModule()
          The particular module object created by this plugin.
 int getWeight()
           
 void init(Plugin plugin, org.dom4j.Element element)
          Initialise a module given it's parent plugin and the XML element representing the module.
protected  void provideValidationRules(ValidationPattern pattern)
          Provides validation rules for the pattern
 
Methods inherited from class com.atlassian.plugin.web.descriptors.AbstractWebFragmentModuleDescriptor
equals, getCondition, getContextProvider, getTooltip, getWebLabel, getWebParams, hashCode, makeCondition, makeConditions, makeConditions, makeContextProvider, setWebInterfaceManager
 
Methods inherited from class com.atlassian.plugin.descriptors.AbstractModuleDescriptor
assertModuleClassImplements, destroy, getCompleteKey, getDescription, getDescriptionKey, getI18nNameKey, getKey, getMinJavaVersion, getModuleClass, getName, getParams, getPlugin, getPluginKey, getResourceDescriptor, getResourceDescriptors, getResourceDescriptors, getResourceLocation, isEnabledByDefault, isSingleton, isSingletonByDefault, isSystemModule, loadClass, loadClass, satisfiesMinJavaVersion, setPlugin, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.atlassian.plugin.web.descriptors.WebFragmentModuleDescriptor
getCondition, getTooltip, getWebLabel, getWebParams
 
Methods inherited from interface com.atlassian.plugin.ModuleDescriptor
destroy, equals, getCompleteKey, getDescription, getDescriptionKey, getI18nNameKey, getKey, getMinJavaVersion, getModuleClass, getName, getParams, getPlugin, getPluginKey, hashCode, isEnabledByDefault, isSystemModule, satisfiesMinJavaVersion
 
Methods inherited from interface com.atlassian.plugin.Resourced
getResourceDescriptor, getResourceDescriptors, getResourceDescriptors, getResourceLocation
 
Methods inherited from interface com.atlassian.plugin.web.descriptors.ContextAware
getContextProvider
 

Field Detail

XML_ELEMENT_NAME

public static final String XML_ELEMENT_NAME
Host applications should use this string when registering the web panel module descriptor.

See Also:
Constant Field Values
Constructor Detail

DefaultWebPanelModuleDescriptor

public DefaultWebPanelModuleDescriptor(HostContainer hostContainer,
                                       ModuleFactory moduleClassFactory,
                                       WebInterfaceManager webInterfaceManager)
Method Detail

init

public void init(Plugin plugin,
                 org.dom4j.Element element)
          throws PluginParseException
Description copied from interface: ModuleDescriptor
Initialise a module given it's parent plugin and the XML element representing the module.

Since atlassian-plugins v2.2, you can no longer load classes from the plugin in this method, because the OSGi bundle that they will live in is not built yet. Load classes in the AbstractModuleDescriptor.enabled() method instead.

Specified by:
init in interface ModuleDescriptor<WebPanel>
Overrides:
init in class AbstractWebFragmentModuleDescriptor<WebPanel>
Parameters:
plugin - The plugin that the module belongs to. Must not be null.
element - XML element representing the module. Must not be null.
Throws:
PluginParseException - Can be thrown if an error occurs while parsing the XML element.

provideValidationRules

protected void provideValidationRules(ValidationPattern pattern)
Description copied from class: AbstractModuleDescriptor
Provides validation rules for the pattern

Overrides:
provideValidationRules in class AbstractModuleDescriptor<WebPanel>
Parameters:
pattern - The validation pattern

getLocation

public String getLocation()
Description copied from interface: WebPanelModuleDescriptor
Returns the location in the host application where the web panel should be embedded.

Specified by:
getLocation in interface WebPanelModuleDescriptor

getWeight

public int getWeight()
Specified by:
getWeight in interface WebFragmentModuleDescriptor<WebPanel>
Specified by:
getWeight in interface WeightedDescriptor
Overrides:
getWeight in class AbstractWebFragmentModuleDescriptor<WebPanel>

getModule

public WebPanel getModule()
Description copied from interface: ModuleDescriptor
The particular module object created by this plugin.

Specified by:
getModule in interface ModuleDescriptor<WebPanel>
Specified by:
getModule in class AbstractModuleDescriptor<WebPanel>
Returns:
The module object created by this plugin.
See Also:
ModuleDescriptor.getModuleClass()

enabled

public void enabled()
Description copied from class: AbstractModuleDescriptor
Enables the descriptor by loading the module class. Classes overriding this method MUST call super.enabled() before their own enabling code.

Specified by:
enabled in interface StateAware
Overrides:
enabled in class AbstractWebFragmentModuleDescriptor<WebPanel>

disabled

public void disabled()
Description copied from class: AbstractModuleDescriptor
Disables the module descriptor. Classes overriding this method MUST call super.disabled() after their own disabling code.

Specified by:
disabled in interface StateAware
Overrides:
disabled in class AbstractWebFragmentModuleDescriptor<WebPanel>


Copyright © 2011 Atlassian. All Rights Reserved.