Clearspace API (2.5.18) Core Javadocs

com.jivesoftware.community.widget
Class BaseWidget

java.lang.Object
  extended by com.jivesoftware.community.widget.BaseWidget
All Implemented Interfaces:
Widget

public abstract class BaseWidget
extends Object
implements Widget

An abstract implementation of the Widget interface this class provides subclasses with built in support for processing a freemarker template and internationalization. It is recommended that all Widgets extend this base class, rather than implementing the Widget interface directly.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jivesoftware.community.widget.Widget
Widget.ContainerSize
 
Field Summary
static String ERROR_TEMPLATE_FILE
           
static String FEATURE_DISABLED_FILE
           
protected  JiveFreemarkerManager freemarkerManager
           
protected  ClearspaceLicenseManager licenseManager
           
 
Constructor Summary
BaseWidget()
           
 
Method Summary
protected  void addError(Map<String,Object> properties, String localizedString)
           
protected  String applyFreemarkerTemplate(WidgetContext widgetContext, Widget.ContainerSize size, String templateName)
          Processes the specified template file and returns a String containing the content of the template file.
 String getCssClass()
          Returns a custom css class for the widget, or null if a custom css class does not exist.
 String getCustomTitle()
          Returns a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.
 String getFeedURL()
          Returns the location of a feed for this widget or null if no feed exists.
 long getID()
          Gets the internal id of the widget
protected  String getLocalizedString(String key, WidgetContext widgetContext)
           
 boolean isEnabled(WidgetContext widgetContext)
          Gives widgets the ability to determine whether or not the widget should be available for end users / administrators to add in a specific widget context.
protected  boolean isModuleAvailable(String name, WidgetContext widgetContext)
           
 boolean isPropertyEnabled(WidgetContext widgetContext, String propName)
          Gives widgets the ability to determine whether or not a specific property should be available during editing of the widget by end users / administrators.
protected  Map<String,Object> loadProperties(WidgetContext widgetContext, Widget.ContainerSize size)
          Responsible for parsing the request URL and adding the necessary parameters to the freemarker context.
protected static String processFreemarkerTemplate(freemarker.template.Configuration config, freemarker.template.SimpleHash model, String templateName, Locale locale, TimeZone timeZone)
          Processes the specified template file and returns a String containing the content of the template file.
 void setCustomTitle(String customTitle)
          Sets a custom title that will override the default title when the widget is rendered.
 void setFreemarkerManager(JiveFreemarkerManager mgr)
           
 void setID(long ID)
          Sets the internal id of the widget
 void setLicenseManager(ClearspaceLicenseManager licenseManager)
           
protected  String stripHTMLTags(String html)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jivesoftware.community.widget.Widget
getDescription, getTitle, render
 

Field Detail

FEATURE_DISABLED_FILE

public static final String FEATURE_DISABLED_FILE
See Also:
Constant Field Values

ERROR_TEMPLATE_FILE

public static final String ERROR_TEMPLATE_FILE
See Also:
Constant Field Values

freemarkerManager

protected JiveFreemarkerManager freemarkerManager

licenseManager

protected ClearspaceLicenseManager licenseManager
Constructor Detail

BaseWidget

public BaseWidget()
Method Detail

setFreemarkerManager

public void setFreemarkerManager(JiveFreemarkerManager mgr)

setLicenseManager

public void setLicenseManager(ClearspaceLicenseManager licenseManager)

getID

public final long getID()
Description copied from interface: Widget
Gets the internal id of the widget

Specified by:
getID in interface Widget
Returns:
the internal id of the widget

setID

public final void setID(long ID)
Description copied from interface: Widget
Sets the internal id of the widget

Specified by:
setID in interface Widget
Parameters:
ID - the internal id of the widget

getCustomTitle

public final String getCustomTitle()
Description copied from interface: Widget
Returns a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.

Specified by:
getCustomTitle in interface Widget
Returns:
a custom title that will override the default title when the widget is rendered, or null if a custom title does not exist.

setCustomTitle

public final void setCustomTitle(String customTitle)
Description copied from interface: Widget
Sets a custom title that will override the default title when the widget is rendered.

Specified by:
setCustomTitle in interface Widget
Parameters:
customTitle - a custom title that will override the default title when the widget is rendered.

getCssClass

public String getCssClass()
Description copied from interface: Widget
Returns a custom css class for the widget, or null if a custom css class does not exist.

Specified by:
getCssClass in interface Widget
Returns:
a custom css class for the widget, or null if a custom css class does not exist.

getFeedURL

public String getFeedURL()
Description copied from interface: Widget
Returns the location of a feed for this widget or null if no feed exists.

Specified by:
getFeedURL in interface Widget
Returns:
the location of a feed for this widget or null if no feed exists.

isEnabled

public boolean isEnabled(WidgetContext widgetContext)
Description copied from interface: Widget
Gives widgets the ability to determine whether or not the widget should be available for end users / administrators to add in a specific widget context.

Specified by:
isEnabled in interface Widget
Parameters:
widgetContext - the context the widget would be rendered in
Returns:
true if the widget should be available to choose, false otherwise.

isPropertyEnabled

public boolean isPropertyEnabled(WidgetContext widgetContext,
                                 String propName)
Description copied from interface: Widget
Gives widgets the ability to determine whether or not a specific property should be available during editing of the widget by end users / administrators.

Specified by:
isPropertyEnabled in interface Widget
Parameters:
widgetContext - the context the widget would be rendered in
propName - the property to enable for editing
Returns:
true it the property should be editable, false otherwise.

applyFreemarkerTemplate

protected String applyFreemarkerTemplate(WidgetContext widgetContext,
                                         Widget.ContainerSize size,
                                         String templateName)
Processes the specified template file and returns a String containing the content of the template file.

Parameters:
widgetContext - the widget context used to render this widget
size - the ContainerSize to render
templateName - name of the template
Returns:
the content of the specified template file

processFreemarkerTemplate

protected static String processFreemarkerTemplate(freemarker.template.Configuration config,
                                                  freemarker.template.SimpleHash model,
                                                  String templateName,
                                                  Locale locale,
                                                  TimeZone timeZone)
Processes the specified template file and returns a String containing the content of the template file.

Parameters:
config - the freemarker configuration
model - used for the freemarker context
templateName - name of the template
locale - the locale of the template or null for the default locale
timeZone - the timeZone of the template or null for the default timezone
Returns:
the content of the specified template file

loadProperties

protected Map<String,Object> loadProperties(WidgetContext widgetContext,
                                            Widget.ContainerSize size)
Responsible for parsing the request URL and adding the necessary parameters to the freemarker context. The parameters will then be available for use in the freemarker template.

Parameters:
widgetContext - the widget context used to render the widget
size - the ContainerSize to render
Returns:
a map containing all the necessary parameters for the requested options

isModuleAvailable

protected boolean isModuleAvailable(String name,
                                    WidgetContext widgetContext)

getLocalizedString

protected String getLocalizedString(String key,
                                    WidgetContext widgetContext)

stripHTMLTags

protected String stripHTMLTags(String html)

addError

protected void addError(Map<String,Object> properties,
                        String localizedString)

Clearspace Project Page

Copyright © 1999-2007 Jive Software.