* the actions available for this portlet
*/
protected List buildActionList( RunData rundata, Portlet portlet )
{
List actions = new Vector();
JetspeedLink jsLink = null;
JetspeedRunData jdata = (JetspeedRunData)rundata;
// disable actions option
if (JetspeedSecurity.areActionsDisabledForAllUsers())
{
return actions;
}
JetspeedUser user = jdata.getJetspeedUser();
if (JetspeedSecurity.areActionsDisabledForAnon() && false == user.hasLoggedIn())
{
return actions;
}
// list the available actiosn for this portlet
if (portlet instanceof PortletState)
{
// the portlet is state aware
PortletState state = (PortletState)portlet;
boolean customized = (jdata.getMode()==jdata.CUSTOMIZE);
boolean maximized = customized||(jdata.getMode()==jdata.MAXIMIZE);
boolean infoAdded = false;
if ( state.allowCustomize( rundata ) )
{
if (! customized )
{
actions.add( new PortletAction("customize", "Customize") );
}
}
else
{
if ( state.allowInfo( rundata ) )
{
actions.add( new PortletAction("info", "Information") );
infoAdded = true;
}
}
if ( (!customized) && state.allowPrintFriendly( rundata ) )
{
actions.add( new PortletAction("print", "Print Friendly Format") );
}
if ( (!customized) && state.allowInfo( rundata ) && (!infoAdded) )
{
actions.add( new PortletAction("info", "Information") );
}
if ( (!customized) && (!maximized) && state.allowClose( rundata ) )
{
actions.add( new PortletAction("close", "Close") );
}
if ( state.isMinimized( rundata ) || maximized )
{
actions.add( new PortletAction("restore", "Restore") );
}
else
{
if ( state.allowMinimize( rundata ) )
{
actions.add( new PortletAction("minimize", "Minimize") );
}
if ( state.allowMaximize( rundata ) )
{
actions.add( new PortletAction("maximize", "Maximize") );
}
}
}
else
{
// the portlet only knows about edit and maximize
if ( portlet.getAllowEdit( rundata ) )
{
actions.add( new PortletAction("info", "Information") );
}
if ( portlet.getAllowMaximize( rundata ) )
{
actions.add( new PortletAction("maximize", "Maximize") );
}
}
// Now that we know which actions should be displayed,
// build the links and put it in the context
Iterator i = actions.iterator();
while( i.hasNext() )
{
PortletAction action = (PortletAction)i.next();
try
{
jsLink = JetspeedLinkFactory.getInstance(rundata);
}
catch( Exception e)
{
logger.error( "Exception in buildActionList", e );
}
// action.setLink( jsLink.setPortletById(portlet.getID())
// .addQueryData("action", getAction( action.getName()))
// .toString());
action.setLink( jsLink.setAction( getAction( action.getName()), portlet).toString());
JetspeedLinkFactory.putInstance(jsLink);
jsLink=null;
}
return actions;