raphael 01/05/29 15:54:38
Modified: src/java/org/apache/jetspeed/portal/controls
VelocityPortletControl.java
Added: src/java/org/apache/jetspeed/portal/controls
VelocityPortletSetControl.java
Log:
extend VelocityPortletControl to replace all existing HTML ECS controls
(including PanedPortletControl)
Revision Changes Path
1.2 +16 -4
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java
Index: VelocityPortletControl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VelocityPortletControl.java 2001/05/28 15:16:10 1.1
+++ VelocityPortletControl.java 2001/05/29 22:54:35 1.2
@@ -64,8 +64,8 @@
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.portal.PortletState;
+import org.apache.jetspeed.portal.PortalState;
import org.apache.jetspeed.util.MimeType;
-import org.apache.jetspeed.util.template.ContentTemplateLink;
// Ecs stuff
import org.apache.ecs.ConcreteElement;
@@ -102,6 +102,12 @@
public class VelocityPortletControl extends AbstractPortletControl
{
+ /** Disable content caching */
+ public boolean isCacheable()
+ {
+ return false;
+ }
+
/**
* Handles the content generation for this control using Velocity
*/
@@ -109,7 +115,8 @@
{
Portlet portlet = getPortlet();
- // Create a new Velocity context
+ // Create a new Velocity context and load default
+ // application pull tools
Context context = TurbineVelocity.getContext(rundata);
context.put("actions", buildActionList( rundata, portlet ) );
@@ -147,7 +154,7 @@
*/
public void buildContext( RunData rundata, Context context )
{
- // empty, should be used by subclasses to populate the context
+ // empty, used by subclasses to populate the context
}
/** Builds a list of possible window actions for this portlet
@@ -181,8 +188,13 @@
}
}
+ if ( state.allowClose( rundata ) )
+ {
+ actions.add( new PortletAction("close") );
+ }
+
if ( ( state.isMinimized( rundata ) )
- ||
(portlet.getName().equals(rundata.getSession().getAttribute("maximize"))) )
+ || (portlet.getName().equals(PortalState.getMaximized(rundata))) )
{
actions.add( new PortletAction("restore") );
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletSetControl.java
Index: VelocityPortletSetControl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.portal.controls;
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletState;
import org.apache.jetspeed.portal.controllers.CardPortletController;
// Velocity Stuff
import org.apache.velocity.context.Context;
import java.util.List;
import java.util.Vector;
import java.util.Enumeration;
/**
* A Velocity based portlet control designed for handling a PortletSet
* child
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class VelocityPortletSetControl extends VelocityPortletControl
{
/**
* This method adds the control specific objects to the context
*
* @param rundata the RunData object for this request
* @param context the Context used by the template
*/
public void buildContext( RunData rundata, Context context )
{
if (getPortlet() instanceof PortletSet)
{
context.put("tabs", getTabs((PortletSet)getPortlet(), rundata) );
}
}
/**
* Populate a list of tabs that should be displayed by this control.
* Each tab represents a child portlet.
*
* This method works best if the child of this control is a PortletSet
* whose controller implements the SelectableController interface.
*
* @param portlet the base portlet to explore for children
* @
*/
private List getTabs( PortletSet portlets, RunData rundata )
{
Vector tabs = new Vector();
CardPortletController controller = null;
// if portlet is a PortletSet, try to retrieve the Controller
// we need a SelectableController to work properly.
if ( portlets.getController() instanceof CardPortletController )
{
controller = (CardPortletController) portlets.getController();
}
for ( Enumeration en = portlets.getPortlets(); en.hasMoreElements(); )
{
Portlet p = (Portlet)en.nextElement();
// skip any closed portlet
if ((p instanceof PortletState) && (((PortletState)p).isClosed(rundata)))
{
continue;
}
PortletTab tab = new PortletTab();
tab.setTitle( (p.getTitle()!=null)?p.getTitle():p.getName() );
if ( controller != null )
{
tab.setSelected(controller.isSelected(p, rundata));
tab.setLink(controller.getPortletURI( p, rundata ).toString());
}
tab.setActions(buildActionList(rundata, p));
tabs.addElement(tab);
}
return tabs;
}
/** Utilty class describing a Tab elemnt in the template Velocity Context
*/
public class PortletTab
{
private String title = null;
private boolean selected = false;
private String link = null;
private List actions = null;
public String getTitle()
{
return this.title;
}
public void setTitle(String title)
{
this.title = title;
}
public boolean isSelected()
{
return this.selected;
}
public void setSelected(boolean selected)
{
this.selected = selected;
}
public String getLink()
{
return this.link;
}
public void setLink(String link)
{
this.link = link;
}
public List getActions()
{
return (this.actions==null)?new Vector():this.actions;
}
public void setActions(List actions)
{
this.actions = actions;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]