org.apache.jetspeed.portal.controls
Class AbstractPortletControl

java.lang.Object
  extended byorg.apache.jetspeed.portal.portlets.AbstractPortlet
      extended byorg.apache.jetspeed.portal.controls.AbstractPortletControl
All Implemented Interfaces:
Cacheable, Portlet, PortletControl, PortletSet, PortletState, org.apache.turbine.services.cache.Refreshable, java.io.Serializable
Direct Known Subclasses:
TitleControl, VelocityPortletControl

public abstract class AbstractPortletControl
extends AbstractPortlet
implements PortletControl

The PortletControl acts both as a decoration around a Portlet or PortletSet and also as the window manager for the enclosed Portlet(Set). As such it controls the operation that may be performed on this portlet and whether the portlet content should be displayed or not. PortletControl also delegates all Portlet and PortletSet methods to its inner object and can thus be transparently cascaded or substituted to a simple portlet wherever in a PSML object tree.

Version:
$Id: AbstractPortletControl.java,v 1.23 2005/03/21 18:21:41 sgala Exp $
Author:
RaphaŽl Luta, Santiago Gala
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.apache.jetspeed.portal.PortletSet
PortletSet.Constraints
 
Field Summary
static java.lang.String BACKGROUND_COLOR
           
static java.lang.String COLOR
           
static java.lang.String TITLE_COLOR
           
static java.lang.String WIDTH
           
 
Fields inherited from class org.apache.jetspeed.portal.portlets.AbstractPortlet
content
 
Fields inherited from interface org.apache.jetspeed.portal.Portlet
PORTLET_MAXIMIZED, PORTLET_MINIMIZED, PORTLET_NORMAL
 
Constructor Summary
AbstractPortletControl()
           
 
Method Summary
 void addPortlet(Portlet portlet)
          Adds a portlet to the inner portletSet
 void addPortlet(Portlet portlet, int position)
          Adds a portlet to the inner portletSet at the explicit position
 void addPortlet(Portlet portlet, PortletSet.Constraints constraints)
          Adds a portlet to the inner portletSet within the given constraints
 void addPortlet(Portlet portlet, PortletSet.Constraints constraint, int position)
          Adds a portlet to the inner portletSet within the given constraints at the specific position
 boolean allowClose(org.apache.turbine.util.RunData rundata)
          Implements the default close behavior: any authenticated user may remove a portlet from his page
 boolean allowCustomize(org.apache.turbine.util.RunData rundata)
          Implements the default customize behavior: any authenticated user may customize a portlet
 boolean allowInfo(org.apache.turbine.util.RunData rundata)
          Implements the default info behavior: any authenticated user may get information on a portlet
 boolean allowMaximize(org.apache.turbine.util.RunData rundata)
          Implements the default maximize behavior: any authenticated user may maximize a portlet
 boolean allowMinimize(org.apache.turbine.util.RunData rundata)
          Implements the default info behavior: any authenticated user may minimize a portlet
 boolean allowPrintFriendly(org.apache.turbine.util.RunData rundata)
          Implements the default info behavior: any authenticated user may display portlet in print friendly format
 java.lang.String getBackgroundColor()
          Deprecated.  
 java.lang.String getColor()
          Deprecated.  
 PortletControlConfig getConfig()
           
 org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata)
          Returns the content of inner portlet
 PortletController getController()
          Return the current controller for this set
 java.lang.String getDescription()
           Returns a description of this portlet.
 java.lang.String getID()
          Retrieve a unique portlet id
 java.lang.String getName()
          Returns a name for this portlet.
 Portlet getPortlet()
          Retrieves the portlet managed by this control
 Portlet getPortletAt(int pos)
          Returns the Portlet at the given position if the control manages a PortletSet, else the inner portlet if the queried position is 0
 Portlet getPortletByID(java.lang.String id)
          Returns the Portlet with the given id
 Portlet getPortletByName(java.lang.String name)
          Returns the Portlet with the given name
 PortletConfig getPortletConfig()
          Get the config of this servlet.
 java.util.Enumeration getPortlets()
          Returns the elements contained within the inner PortletSet or the inner portlet
 java.lang.String getTitle()
           Allows a Portlet to define its title.
 java.lang.String getTitleColor()
          Deprecated.  
 java.lang.String getWidth()
          Deprecated.  
 void init()
          Inits the inner portlet
 void init(Portlet portlet)
          Initializes the control and associates it with a portlet
 boolean isClosed(org.apache.turbine.util.RunData rundata)
          Returns true if this portlet is currently closed
 boolean isMinimized(org.apache.turbine.util.RunData rundata)
          Returns true if this portlet is currently minimized
 void setBackgroundColor(java.lang.String backgroundColor)
          Deprecated.  
 void setClosed(boolean close, org.apache.turbine.util.RunData rundata)
          Toggles the portlet state between closed and normal
 void setColor(java.lang.String color)
          Deprecated.  
 void setConfig(PortletControlConfig conf)
          Sets the PortletControl specific configuration
 void setController(PortletController controller)
          Sets the controller for the inner PortletSet.
 void setDescription(java.lang.String description)
          Set the description for the inner portlet
 void setID(java.lang.String id)
           
 void setMinimized(boolean minimize, org.apache.turbine.util.RunData rundata)
          Change the portlet visibility state ( minimized <-> normal )
 void setName(java.lang.String name)
          Updates the managed portlet name
 void setPortlet(Portlet portlet)
          Sets the portlet to be managed by this control
 void setPortletConfig(PortletConfig portletConfig)
          Updates the managed portlet config object
 void setTitle(java.lang.String title)
          Set the title for the inner portlet
 void setTitleColor(java.lang.String titleColor)
          Deprecated.  
 void setWidth(int width)
          Deprecated.  
 void setWidth(java.lang.String width)
          Deprecated.  
 int size()
          Returns the number of portlets currently stored in this set
 boolean supportsType(MimeType mimeType)
          Returns true portlet is able to output content for given mimetype
 Portlet[] toArray()
          Returns the portlet set as an array.
 
Methods inherited from class org.apache.jetspeed.portal.portlets.AbstractPortlet
allowView, clearContent, getAllowEdit, getAllowMaximize, getAllowView, getAttribute, getContent, getContent, getCreationTime, getDescription, getExpirationMillis, getExpire, getHandle, getHandle, getImage, getImage, getInstance, getTitle, isCacheable, isShowTitleBar, providesCustomization, refresh, setAttribute, setCacheable, setCachedObject, setContent, setContent, setContent, setCreationTime, setExpirationMillis, setHandle, setImage, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jetspeed.portal.Portlet
getAllowEdit, getAllowMaximize, getAllowView, getAttribute, getCreationTime, getDescription, getImage, getInstance, getTitle, isShowTitleBar, providesCustomization, setAttribute, setCreationTime, setImage, setTitle
 

Field Detail

COLOR

public static final java.lang.String COLOR
See Also:
Constant Field Values

BACKGROUND_COLOR

public static final java.lang.String BACKGROUND_COLOR
See Also:
Constant Field Values

TITLE_COLOR

public static final java.lang.String TITLE_COLOR
See Also:
Constant Field Values

WIDTH

public static final java.lang.String WIDTH
See Also:
Constant Field Values
Constructor Detail

AbstractPortletControl

public AbstractPortletControl()
Method Detail

getConfig

public PortletControlConfig getConfig()
Specified by:
getConfig in interface PortletControl
Returns:
the PortletControl specific configuration

setConfig

public void setConfig(PortletControlConfig conf)
Sets the PortletControl specific configuration

Specified by:
setConfig in interface PortletControl
Parameters:
conf - the new PortletControl configuration

setPortlet

public void setPortlet(Portlet portlet)
Sets the portlet to be managed by this control

Specified by:
setPortlet in interface PortletControl
Parameters:
portlet - the new portlet to be managed by the control

getPortlet

public Portlet getPortlet()
Retrieves the portlet managed by this control

Specified by:
getPortlet in interface PortletControl
Returns:
the portlet object managed or null

init

public void init(Portlet portlet)
Initializes the control and associates it with a portlet

Specified by:
init in interface PortletControl
Parameters:
portlet - the portlet to be managed by this control

getColor

public java.lang.String getColor()
Deprecated.  

Returns the color to use for displaying the portlet text This method is deprecated and is only useful for ECS based Control implementation

Specified by:
getColor in interface PortletControl
Returns:
the text color value in HTML format (#RRGGBB)

setColor

public void setColor(java.lang.String color)
Deprecated.  

Sets the color to use for displaying the portlet text This method is deprecated and is only useful for ECS based Control implementation

Specified by:
setColor in interface PortletControl
Parameters:
color - the text color value in HTML format (#RRGGBB)

getBackgroundColor

public java.lang.String getBackgroundColor()
Deprecated.  

Returns the color to use for displaying the portlet background This method is deprecated and is only useful for ECS based Control implementation

Specified by:
getBackgroundColor in interface PortletControl
Returns:
the text color value in HTML format (#RRGGBB)

setBackgroundColor

public void setBackgroundColor(java.lang.String backgroundColor)
Deprecated.  

Sets the color to use for displaying the portlet background This method is deprecated and is only useful for ECS based Control implementation

Specified by:
setBackgroundColor in interface PortletControl
Parameters:
backgroundColor - the background color value in HTML format (#RRGGBB)

getTitleColor

public java.lang.String getTitleColor()
Deprecated.  

Returns the color to use for displaying the portlet title This method is deprecated and is only useful for ECS based Control implementation

Specified by:
getTitleColor in interface PortletControl
Returns:
the text color value in HTML format (#RRGGBB)

setTitleColor

public void setTitleColor(java.lang.String titleColor)
Deprecated.  

Sets the color to use for displaying the portlet title This method is deprecated and is only useful for ECS based Control implementation

Specified by:
setTitleColor in interface PortletControl
Parameters:
titleColor - the title color value in HTML format (#RRGGBB)

getWidth

public java.lang.String getWidth()
Deprecated.  

Returns the width of the managed portlet relative to the size of portlet control. This method is deprecated and is only useful for ECS based Control implementation

Specified by:
getWidth in interface PortletControl
Returns:
the size value. May be expressed in percentages (eg, "80%")

setWidth

public void setWidth(int width)
Deprecated.  

Sets the width of the managed portlet relative to the size of portlet control. This method is deprecated and is only useful for ECS based Control implementation

Specified by:
setWidth in interface PortletControl
Parameters:
width - the width of portlet. Must be a positive, non nul integer

setWidth

public void setWidth(java.lang.String width)
Deprecated.  

Sets the width of the managed portlet relative to the size of portlet control. This method is deprecated and is only useful for ECS based Control implementation

Specified by:
setWidth in interface PortletControl
Parameters:
width - the width of portlet. Must be parseable as a positive, non nul integer or a percentage

getPortletConfig

public PortletConfig getPortletConfig()
Description copied from interface: Portlet
Get the config of this servlet.

Specified by:
getPortletConfig in interface Portlet
Overrides:
getPortletConfig in class AbstractPortlet
Returns:
the inner portlet config object

setPortletConfig

public void setPortletConfig(PortletConfig portletConfig)
Updates the managed portlet config object

Specified by:
setPortletConfig in interface Portlet
Overrides:
setPortletConfig in class AbstractPortlet
Parameters:
portletConfig - the new portet config object

getName

public java.lang.String getName()
Description copied from interface: Portlet
Returns a name for this portlet. This is used by PSML to identify a Portlet within the PortletRegistry

Specified by:
getName in interface Portlet
Overrides:
getName in class AbstractPortlet
Returns:
the inner portlet name

setName

public void setName(java.lang.String name)
Updates the managed portlet name

Specified by:
setName in interface Portlet
Overrides:
setName in class AbstractPortlet
Parameters:
name - the new portet name

getTitle

public java.lang.String getTitle()
Description copied from interface: Portlet

Allows a Portlet to define its title. This can be used by a PortletControl for rendering its content.

In order to define a default title you should not override this but should call setTitle() within your init() method

This should return null if not specified.

Specified by:
getTitle in interface Portlet
Overrides:
getTitle in class AbstractPortlet
Returns:
the inner portlet title

setTitle

public void setTitle(java.lang.String title)
Set the title for the inner portlet

Specified by:
setTitle in interface Portlet
Overrides:
setTitle in class AbstractPortlet
Parameters:
title - the new portlet title

getDescription

public java.lang.String getDescription()
Description copied from interface: Portlet

Returns a description of this portlet. This should describe what the capabilities of the portlet and how it can help the user.

In order to define a default title you should not override (in the AbstractPortlet implementation) this but should call setDescription() within your init() method

This should return null if not specified.

Specified by:
getDescription in interface Portlet
Overrides:
getDescription in class AbstractPortlet
Returns:
the inner portlet description

setDescription

public void setDescription(java.lang.String description)
Set the description for the inner portlet

Specified by:
setDescription in interface Portlet
Overrides:
setDescription in class AbstractPortlet
Parameters:
description - the new portlet description

init

public void init()
          throws PortletException
Inits the inner portlet

Specified by:
init in interface Portlet
Overrides:
init in class AbstractPortlet
Throws:
PortletException

getContent

public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata)
Returns the content of inner portlet

Specified by:
getContent in interface Portlet
Overrides:
getContent in class AbstractPortlet
Parameters:
rundata - the RunData for the request

supportsType

public boolean supportsType(MimeType mimeType)
Description copied from interface: Portlet
Returns true portlet is able to output content for given mimetype

Specified by:
supportsType in interface Portlet
Overrides:
supportsType in class AbstractPortlet
See Also:
Portlet.supportsType(org.apache.jetspeed.util.MimeType)

size

public int size()
Description copied from interface: PortletSet
Returns the number of portlets currently stored in this set

Specified by:
size in interface PortletSet
Returns:
the size of the inner portletSet, 1 if the inner portlet is not a set, or 0 if there's no inner portlet

toArray

public Portlet[] toArray()
Description copied from interface: PortletSet
Returns the portlet set as an array.

Specified by:
toArray in interface PortletSet
Returns:
an array of portlet contained within the inner PortletSet or the inner portlet

getPortletAt

public Portlet getPortletAt(int pos)
Returns the Portlet at the given position if the control manages a PortletSet, else the inner portlet if the queried position is 0

Specified by:
getPortletAt in interface PortletSet
Parameters:
pos - the queried position. Must be strictly smaller than the value of size()
Returns:
the portlet object stored at this position

getPortlets

public java.util.Enumeration getPortlets()
Returns the elements contained within the inner PortletSet or the inner portlet

Specified by:
getPortlets in interface PortletSet
Returns:
an enumeration of portlets

addPortlet

public void addPortlet(Portlet portlet)
Adds a portlet to the inner portletSet

Specified by:
addPortlet in interface PortletSet
Parameters:
portlet - the portlet to add

addPortlet

public void addPortlet(Portlet portlet,
                       int position)
Adds a portlet to the inner portletSet at the explicit position

Specified by:
addPortlet in interface PortletSet
Parameters:
portlet - the portlet to add
position - the position of the new portlet

addPortlet

public void addPortlet(Portlet portlet,
                       PortletSet.Constraints constraints)
Adds a portlet to the inner portletSet within the given constraints

Specified by:
addPortlet in interface PortletSet
Parameters:
portlet - the portlet to add
constraints - the portlet layout constraints

addPortlet

public void addPortlet(Portlet portlet,
                       PortletSet.Constraints constraint,
                       int position)
Adds a portlet to the inner portletSet within the given constraints at the specific position

Specified by:
addPortlet in interface PortletSet
Parameters:
portlet - the portlet to add
constraint - the portlet layout constraints
position - the portlet required position

getController

public PortletController getController()
Description copied from interface: PortletSet
Return the current controller for this set

Specified by:
getController in interface PortletSet
Returns:
the controller for the inner portletSet or null

setController

public void setController(PortletController controller)
Sets the controller for the inner PortletSet. Has no effect if their is no inner portletSet

Specified by:
setController in interface PortletSet

allowClose

public boolean allowClose(org.apache.turbine.util.RunData rundata)
Implements the default close behavior: any authenticated user may remove a portlet from his page

Specified by:
allowClose in interface PortletState
Overrides:
allowClose in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

isClosed

public boolean isClosed(org.apache.turbine.util.RunData rundata)
Returns true if this portlet is currently closed

Specified by:
isClosed in interface PortletState
Overrides:
isClosed in class AbstractPortlet
Parameters:
rundata - The RunData object for the current request

setClosed

public void setClosed(boolean close,
                      org.apache.turbine.util.RunData rundata)
Toggles the portlet state between closed and normal

Specified by:
setClosed in interface PortletState
Overrides:
setClosed in class AbstractPortlet
Parameters:
rundata - The RunData object for the current request

allowInfo

public boolean allowInfo(org.apache.turbine.util.RunData rundata)
Implements the default info behavior: any authenticated user may get information on a portlet

Specified by:
allowInfo in interface PortletState
Overrides:
allowInfo in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

allowCustomize

public boolean allowCustomize(org.apache.turbine.util.RunData rundata)
Implements the default customize behavior: any authenticated user may customize a portlet

Specified by:
allowCustomize in interface PortletState
Overrides:
allowCustomize in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

allowMaximize

public boolean allowMaximize(org.apache.turbine.util.RunData rundata)
Implements the default maximize behavior: any authenticated user may maximize a portlet

Specified by:
allowMaximize in interface PortletState
Overrides:
allowMaximize in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

allowMinimize

public boolean allowMinimize(org.apache.turbine.util.RunData rundata)
Implements the default info behavior: any authenticated user may minimize a portlet

Specified by:
allowMinimize in interface PortletState
Overrides:
allowMinimize in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

allowPrintFriendly

public boolean allowPrintFriendly(org.apache.turbine.util.RunData rundata)
Implements the default info behavior: any authenticated user may display portlet in print friendly format

Specified by:
allowPrintFriendly in interface PortletState
Overrides:
allowPrintFriendly in class AbstractPortlet
Parameters:
rundata - the RunData object for the current request

isMinimized

public boolean isMinimized(org.apache.turbine.util.RunData rundata)
Returns true if this portlet is currently minimized

Specified by:
isMinimized in interface PortletState
Overrides:
isMinimized in class AbstractPortlet
Parameters:
rundata - The RunData object for the current request

setMinimized

public void setMinimized(boolean minimize,
                         org.apache.turbine.util.RunData rundata)
Change the portlet visibility state ( minimized <-> normal )

Specified by:
setMinimized in interface PortletState
Overrides:
setMinimized in class AbstractPortlet
Parameters:
minimize - True if the portlet change to minimized
rundata - A RunData object

getID

public java.lang.String getID()
Description copied from interface: Portlet
Retrieve a unique portlet id

Specified by:
getID in interface Portlet
Overrides:
getID in class AbstractPortlet

setID

public void setID(java.lang.String id)
Specified by:
setID in interface Portlet
Overrides:
setID in class AbstractPortlet

getPortletByID

public Portlet getPortletByID(java.lang.String id)
Returns the Portlet with the given id

Specified by:
getPortletByID in interface PortletSet

getPortletByName

public Portlet getPortletByName(java.lang.String name)
Returns the Portlet with the given name

Specified by:
getPortletByName in interface PortletSet


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.