KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > AbstractVTLPortletAction


1 package org.apache.jetspeed.modules.actions.portlets;
2
3 import org.apache.jetspeed.portal.portlets.AbstractVTLPortlet;
4
5 // Turbine stuff
6
import org.apache.turbine.util.RunData;
7 import org.apache.turbine.modules.Action;
8
9 // Velocity Stuff
10
import org.apache.velocity.context.Context;
11
12
13 /**
14 An abstract class to build actions supporting VTLPortlets
15
16 Don't put in URL, it's called automatically by VTLPortlet when needed
17
18 @author <a HREF="mailto:re_carrasco@bco011.sonda.cl">Roberto Carrasco</a>
19 */

20 public abstract class AbstractVTLPortletAction extends Action
21 {
22     public void doPerform( RunData rundata )
23     {
24         Context context = (Context)rundata.getTemplateInfo().getTemplateContext( "VTLPortletContext" );
25         AbstractVTLPortlet xPortlet = (AbstractVTLPortlet)context.get( "portlet" );
26         boolean loggedUser = rundata.getUser() != null && rundata.getUser().hasLoggedIn();
27
28
29         // portlet must be configured
30
if( xPortlet.isButtonConfigure( rundata ) )
31         {
32             if( loggedUser )
33             {
34                 setConfigureContent( xPortlet, context, rundata );
35             }
36             return;
37         }
38
39         // portlet must shows maximized
40
if( xPortlet.isButtonMaximize( rundata ) )
41         {
42             setMaximizedContent( xPortlet, context, rundata, loggedUser );
43             return;
44         }
45
46         // portlet is minimized - let's change at least the title bar
47
if( xPortlet.isMinimized( rundata ) )
48         {
49             if( loggedUser )
50             {
51                 setMinimizedContent( xPortlet, context, rundata );
52             }
53             return;
54         }
55
56         // show in standar way ( with portlets around it )
57
setNormalContent( xPortlet, context, rundata, loggedUser );
58     }
59
60     // only if conf button clicked
61
abstract void setConfigureContent( AbstractVTLPortlet xPortlet,
62                                        Context context, RunData rundata );
63
64     // only if max button clicked
65
abstract void setMaximizedContent( AbstractVTLPortlet xPortlet,
66                                        Context context, RunData rundata, boolean loggedUser );
67
68     // only in minimized state
69
abstract void setMinimizedContent( AbstractVTLPortlet xPortlet,
70                                        Context context, RunData rundata );
71
72     // only in normal state
73
abstract void setNormalContent( AbstractVTLPortlet xPortlet,
74                                     Context context, RunData rundata, boolean loggedUser );
75
76 }
77
Popular Tags