com.arsdigita.bebop
Class TabbedPane

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.SimpleContainer
                      extended bycom.arsdigita.bebop.TabbedPane
All Implemented Interfaces:
Cloneable, Component, Container, Lockable

public class TabbedPane
extends SimpleContainer

A tabbed pane that lets the user switch between components by clicking on a given title in the tab strip.

Tabs (components) are added using the addTab method. Each entry consists of a label (which is a string) and the Component that is displayed if the user clicks on the label.

There is always exactly one component that is currently visible, the component that is returned by getCurrentPane(com.arsdigita.bebop.PageState). Without user interaction, this is the default pane -- that was set by setDefaultPane(com.arsdigita.bebop.Component) -- or, if none has been set, the first component that was added to the TabbedPane.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/TabbedPane.java#8 $
Author:
David Lutterkort, Stanislav Freidin, Uday Mathur

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
TabbedPane()
          Constructs an empty TabbedPane.
 
Method Summary
 void add(Component pc)
          Adds a new pane to the dialog.
 void add(Component pc, int constraints)
          Adds a new pane with layout constraints to the dialog.
 void addActionListener(ActionListener l)
          Adds an ActionListener, which is run whenever respond is called.
 void addTab(Component label, Component c)
          Adds a tab and its associated component.
 void addTab(String label, Component c)
          Adds a tab and its associated component.
protected  int findPane(Component c)
          Find the pane whose body is the specified component
protected  void fireActionEvent(PageState state)
          Fires an ActionEvent.
protected  void generateTabs(PageState data, Element parent)
          Builds a DOM representing the header for the tab strip.
 void generateXML(PageState state, Element parent)
          Services the request by building a DOM tree with the tabs themselves and then the included page.
 Component getCurrentPane(PageState data)
          Gets the currently visible pane.
 Component getDefaultPane()
          Gets the default pane.
 Component getPane(Component label)
          Gets the pane with the specified label.
 Component getPane(String label)
          Gets the pane with the specified key in its label.
 int getSelectedIndex(PageState state)
           
 boolean isTabVisible(PageState s, Component c)
          Determine if a particular tab is visible
 boolean isTabVisible(PageState s, int i)
          Determine if a particular tab is visible
 void register(Page p)
          Registers with the specified root container.
 void removeActionListener(ActionListener l)
          Removes a previously added ActionListener.
 void respond(PageState state)
          Notifies the TabbedPane that one of the tabs has been selected.
 void setDefaultPane(Component pane)
          Sets the default pane, which is visible until the user clicks on another label in the tab strip.
protected  void setDefaultPaneIndex(int i)
          Sets the index of the default pane, which is visible until the user clicks on another label in the tab strip.
 void setSelectedIndex(PageState state, int index)
           
 void setTabVisible(PageState s, Component c, boolean v)
          Show or hide a particular tab
 void setTabVisible(PageState s, int i, boolean v)
          Show or hide a particular tab
 
Methods inherited from class com.arsdigita.bebop.SimpleContainer
children, contains, generateChildrenXML, generateParent, get, getNamespace, getTag, indexOf, isEmpty, setNamespace, setTag, size
 
Methods inherited from class com.arsdigita.bebop.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.bebop.Component
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, register, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked, lock
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

TabbedPane

public TabbedPane()
Constructs an empty TabbedPane.

Method Detail

register

public void register(Page p)
Registers with the specified root container. Adds a state parameter to keep track of the visible component to the page.

Specified by:
register in interface Component
Overrides:
register in class SimpleComponent
Parameters:
p - the root container to register with

add

public void add(Component pc)
Adds a new pane to the dialog. Assigns a rather unhelpful default label (the pane number) to the component. Use addTab instead.

Specified by:
add in interface Container
Overrides:
add in class SimpleContainer
Parameters:
pc - the component to be added

add

public void add(Component pc,
                int constraints)
Adds a new pane with layout constraints to the dialog. Ignores the constraints. Assigns a rather unhelpful default label (the pane number) to the component. Use addTab instead.

Specified by:
add in interface Container
Overrides:
add in class SimpleContainer
Parameters:
constraints - this parameter is ignored. Child classes should override the add method if they wish to provide special handling of constraints.

addTab

public void addTab(Component label,
                   Component c)
Adds a tab and its associated component.

Parameters:
label - the text to display in the tab strip
c - the component to display when the user clicks on the label in the tab strip

addTab

public void addTab(String label,
                   Component c)
Adds a tab and its associated component.

Parameters:
label - the text to display in the tab strip
c - the component to display when the user clicks on the label in the tab strip

addActionListener

public void addActionListener(ActionListener l)
Adds an ActionListener, which is run whenever respond is called.

See Also:
respond

removeActionListener

public void removeActionListener(ActionListener l)
Removes a previously added ActionListener.

See Also:
addActionListener

fireActionEvent

protected void fireActionEvent(PageState state)
Fires an ActionEvent. All registered ActionListeners are run. The source of the event is the TabbedPane.

Parameters:
state - the current page state
See Also:
respond

setDefaultPaneIndex

protected void setDefaultPaneIndex(int i)
Sets the index of the default pane, which is visible until the user clicks on another label in the tab strip.

Parameters:
i - the index of the default pane

setDefaultPane

public void setDefaultPane(Component pane)
                    throws IllegalArgumentException
Sets the default pane, which is visible until the user clicks on another label in the tab strip.

Parameters:
pane - the component to display as the default pane
Throws:
IllegalArgumentException

setTabVisible

public void setTabVisible(PageState s,
                          int i,
                          boolean v)
Show or hide a particular tab

Parameters:
s - the page state
i - the index of the tab
v - if true, shows the tab. Otherwise, hides the tab

setTabVisible

public void setTabVisible(PageState s,
                          Component c,
                          boolean v)
Show or hide a particular tab

Parameters:
s - the page state
c - the body of the tab
v - if true, shows the tab. Otherwise, hides the tab

isTabVisible

public boolean isTabVisible(PageState s,
                            int i)
Determine if a particular tab is visible

Parameters:
s - the page state
i - the index of the tab

isTabVisible

public boolean isTabVisible(PageState s,
                            Component c)
Determine if a particular tab is visible

Parameters:
s - the page state
c - the body of the tab

findPane

protected int findPane(Component c)
Find the pane whose body is the specified component

Parameters:
c - the component
Returns:
the pane index on success, -1 if no such pane exists

getDefaultPane

public Component getDefaultPane()
Gets the default pane. If no default pane has been set explicitly, the first pane is returned.

Returns:
the default pane, or null if there are no panes.

getPane

public Component getPane(Component label)
Gets the pane with the specified label.

Returns:
the pane with the specified label, or null if a pane with that label does not exist.

getPane

public Component getPane(String label)
Gets the pane with the specified key in its label. Returns null if a pane with that label does not exist. This function exists for backward compatibility.

Returns:
the pane with the specified label, or null if a pane with that label does not exist.

getCurrentPane

public Component getCurrentPane(PageState data)
Gets the currently visible pane.


setSelectedIndex

public void setSelectedIndex(PageState state,
                             int index)

getSelectedIndex

public int getSelectedIndex(PageState state)

generateTabs

protected void generateTabs(PageState data,
                            Element parent)
Builds a DOM representing the header for the tab strip. Marks the current pane.


generateXML

public void generateXML(PageState state,
                        Element parent)
Services the request by building a DOM tree with the tabs themselves and then the included page.

Generates a DOM fragment:

 <bebop:tabbedPane>
  <bebop:tabStrip>
   <bebop:tab [href="..."] [current="t|f"]> .. label .. </bebop:tab>
   <bebop:tab [href="..."] [current="t|f"]> .. label .. </bebop:tab>
   <bebop:tab [href="..."] [current="t|f"]> .. label .. </bebop:tab>
  </bebop:tabStrip>
  <bebop:currentPane>
    ... contentes ..
  </bebop:currentPane>
 </bebop:tabbedPane>
 

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleContainer
Parameters:
state - represents the current request
parent - the parent XML element
See Also:
SimpleContainer.setTag(String), SimpleContainer.setNamespace(String)

respond

public void respond(PageState state)
             throws javax.servlet.ServletException
Notifies the TabbedPane that one of the tabs has been selected. Changes the currently visible pane and runs all the ActionListeners.

The respond method on the now-visible component is not called.

Specified by:
respond in interface Component
Overrides:
respond in class SimpleComponent
Parameters:
state - the current page state
Throws:
javax.servlet.ServletException


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC