NextApp Echo
App Container 1.1.4

nextapp.echoservlet.ui
Class ButtonRenderer

java.lang.Object
  extended bynextapp.echoservlet.ui.ButtonRenderer
All Implemented Interfaces:
java.io.Serializable

public class ButtonRenderer
extends java.lang.Object
implements java.io.Serializable

A utility class for rendering Button, RadioButton, CheckBox, and CButton components.

See Also:
Serialized Form

Field Summary
private  java.lang.String borderTdStyleName
          Name of style applied to border TD element (used for CButton renderings).
private  nextapp.echo.AbstractButton button
          The underlying AbstractButton component being rendered.
private  AbstractButtonUI buttonUI
          The AbstractButtonUI being rendered.
private  Renderable iconRenderable
          Icon HTML code.
private  int nextRolloverSubIdValue
          Counter indicating the next 'sub id' available to identify an HTML element that will take part in the rollover effect.
private  RenderingContext rc
          The RenderingContext being used for this rendering.
private  Element rootElement
          The root of the rendered HTML Element hierarchy.
private  java.lang.String rootStyleName
          Name of style of root element.
static Service SERVICE_BUTTON_SCRIPT
           
private  Renderable stateRenderable
          State icon HTML code.
private  Renderable textRenderable
          Text HTML code.
 
Constructor Summary
private ButtonRenderer(RenderingContext rc, AbstractButtonUI buttonUI)
          Creates a ButtonRenderer for the given Button.
 
Method Summary
private static void addAlignmentSettings(Element tdElement, int horizontalAlignment, int verticalAlignment)
          Adds alignment (text-align/vertical-align) properties to a TD element.
private static void addBorderStyleSetting(ComponentStyle style, int borderStyle)
          Adds border-style property to a ComponentSyle.
private  Element createCButtonBorderElement(Renderable innerRenderable)
          Creates and returns border element for CButton.
private  Renderable createContainerRenderable()
          Creates and returns a Renderable that contains the icon, state, and text renderables of the button.
private  Renderable createIconRenderable()
          Creates and returns an Renderable representing the icon part of the button.
private  void createMainRenderables()
          Creates the main (text/icon/state) renderable components that will make up the button.
private  void createPressEvents()
          Adds mouse up/down event code to rootElement to create button-press effects when mouse is depressed on button.
private  void createRolloverEvents()
          Adds mouse over/out event code to rootElement to create button-press effects when mouse is depressed on button.
private  Renderable createStateRenderable(Element iconImgElement)
          Creates and returns an Renderable representing the state part of the button.
private  java.lang.String createTablePressedCssStyle()
          Creates CSS style for pressed state of CButton which should be applied to all rendered TABLE elements via a rollover effect when button is pressed on client.
private  java.lang.String createTableRolloverCssStyle()
          Creates CSS style for rollover state of button which should be applied to all rendered TABLE elements via a rollover effect when button is rolled over on client.
private  java.lang.String createTdPressedCssStyle()
          Creates CSS style for pressed state of CButton which should be applied to the border TD element via a rollover effect when button is pressed on client.
private  java.lang.String createTdRolloverCssStyle()
          Creates CSS style for rolled over state of CButton which should be applied to the border TD element via a rollover effect when button is rolled over on client.
private  Renderable createTextRenderable()
          Creates and returns an Renderable representing the text part of the button.
private  java.lang.String getBorderTableCellId()
          Returns the element id of the border table cell's TD.
static Element getElement(RenderingContext rc, AbstractButtonUI buttonUI)
          Returns an Element containing an HTML representation of the provided button.
private  java.lang.String getNextRolloverElementId()
          Returns the next sequential id available to assign to an elemnet participating in the rollover effect.
private  Element getRoot()
          Returns the rendered root element.
private  void modifyCButtonBorderTableStyle(ComponentStyle borderTableStyle)
          Modifies style of border table to take into account properties of CButton.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE_BUTTON_SCRIPT

public static final Service SERVICE_BUTTON_SCRIPT

rootElement

private Element rootElement
The root of the rendered HTML Element hierarchy.


rc

private RenderingContext rc
The RenderingContext being used for this rendering.


buttonUI

private AbstractButtonUI buttonUI
The AbstractButtonUI being rendered.


button

private nextapp.echo.AbstractButton button
The underlying AbstractButton component being rendered.


textRenderable

private Renderable textRenderable
Text HTML code.


iconRenderable

private Renderable iconRenderable
Icon HTML code.


stateRenderable

private Renderable stateRenderable
State icon HTML code.


nextRolloverSubIdValue

private int nextRolloverSubIdValue
Counter indicating the next 'sub id' available to identify an HTML element that will take part in the rollover effect.


rootStyleName

private java.lang.String rootStyleName
Name of style of root element.


borderTdStyleName

private java.lang.String borderTdStyleName
Name of style applied to border TD element (used for CButton renderings).

Constructor Detail

ButtonRenderer

private ButtonRenderer(RenderingContext rc,
                       AbstractButtonUI buttonUI)
Creates a ButtonRenderer for the given Button.

Parameters:
rc - The RenderingContext that is rendering the button.
buttonUI - The peer of the button to be rendered.
Method Detail

addAlignmentSettings

private static void addAlignmentSettings(Element tdElement,
                                         int horizontalAlignment,
                                         int verticalAlignment)
Adds alignment (text-align/vertical-align) properties to a TD element.

Parameters:
tdElement - The TD element to which the properties are to be added.
horizontalAlignment - The horizontal alignment setting desired for the style, one of the following value:
  • EchoConstants.LEFT
  • EchoConstants.CENTER
  • EchoConstants.RIGHT
verticalAlignment - The vertical alignment setting desired for the style, one of the following value:
  • EchoConstants.TOP
  • EchoConstants.CENTER
  • EchoConstants.BOTTOM

addBorderStyleSetting

private static void addBorderStyleSetting(ComponentStyle style,
                                          int borderStyle)
Adds border-style property to a ComponentSyle.

Parameters:
style - The ComponentStyle to modify.
borderStyle - The border style constant value, one of the following values:
    CButton.BORDER_SOLID CButton.BORDER_INSET CButton.BORDER_OUTSET CButton.BORDER_NONE

getElement

public static Element getElement(RenderingContext rc,
                                 AbstractButtonUI buttonUI)
Returns an Element containing an HTML representation of the provided button.

Parameters:
rc - The RenderingContext that is rendering the button.
buttonUI - The peer of the button to be rendered.
Returns:
A hierarchy of HTML elements that visually represent the button.

createContainerRenderable

private Renderable createContainerRenderable()
Creates and returns a Renderable that contains the icon, state, and text renderables of the button.

Returns:
A Renderable that contains the icon, state, and text renderables of the button.

modifyCButtonBorderTableStyle

private void modifyCButtonBorderTableStyle(ComponentStyle borderTableStyle)
Modifies style of border table to take into account properties of CButton.

Parameters:
borderTableStyle - The ComponentStyle to modify.

createCButtonBorderElement

private Element createCButtonBorderElement(Renderable innerRenderable)
Creates and returns border element for CButton.

Parameters:
innerRenderable - button contents.
Returns:
Border Element containing contents of button.

createIconRenderable

private Renderable createIconRenderable()
Creates and returns an Renderable representing the icon part of the button.

Returns:
The created Renderable.

createMainRenderables

private void createMainRenderables()
Creates the main (text/icon/state) renderable components that will make up the button. Created elements are store in instance variables textRenderable, iconRenderable, and stateRenderable.


createStateRenderable

private Renderable createStateRenderable(Element iconImgElement)
Creates and returns an Renderable representing the state part of the button.

Returns:
The created Renderable.

createTextRenderable

private Renderable createTextRenderable()
Creates and returns an Renderable representing the text part of the button.

Returns:
The created Renderable.

createTablePressedCssStyle

private java.lang.String createTablePressedCssStyle()
Creates CSS style for pressed state of CButton which should be applied to all rendered TABLE elements via a rollover effect when button is pressed on client.

Returns:
The name of the created style name, or null if a style is not necessary.

createTdPressedCssStyle

private java.lang.String createTdPressedCssStyle()
Creates CSS style for pressed state of CButton which should be applied to the border TD element via a rollover effect when button is pressed on client.

Returns:
The name of the created style name, or null if a style is not necessary.

createPressEvents

private void createPressEvents()
Adds mouse up/down event code to rootElement to create button-press effects when mouse is depressed on button.


createTableRolloverCssStyle

private java.lang.String createTableRolloverCssStyle()
Creates CSS style for rollover state of button which should be applied to all rendered TABLE elements via a rollover effect when button is rolled over on client.

Returns:
The name of the created style name, or null if a style is not necessary.

createTdRolloverCssStyle

private java.lang.String createTdRolloverCssStyle()
Creates CSS style for rolled over state of CButton which should be applied to the border TD element via a rollover effect when button is rolled over on client.

Returns:
The name of the created style name, or null if a style is not necessary.

createRolloverEvents

private void createRolloverEvents()
Adds mouse over/out event code to rootElement to create button-press effects when mouse is depressed on button.


getBorderTableCellId

private java.lang.String getBorderTableCellId()
Returns the element id of the border table cell's TD.

Returns:
The element id.

getNextRolloverElementId

private java.lang.String getNextRolloverElementId()
Returns the next sequential id available to assign to an elemnet participating in the rollover effect.

Returns:
The next available id.

getRoot

private Element getRoot()
Returns the rendered root element.

Returns:
The rendered root element.

NextApp Echo
App Container 1.1.4