1 package org.apache.jetspeed.portal.controls; 2 3 import org.apache.jetspeed.portal.portlets.AbstractVTLPortlet; 4 5 import org.apache.turbine.services.velocity.TurbineVelocity; 7 import org.apache.turbine.util.RunData; 8 import org.apache.turbine.util.DynamicURI; 9 10 import org.apache.jetspeed.portal.Portlet; 12 import org.apache.jetspeed.portal.PortletControl; 13 import org.apache.jetspeed.util.MimeType; 14 import org.apache.jetspeed.util.URILookup; 15 import org.apache.jetspeed.util.JetspeedException; 16 17 import org.apache.ecs.ConcreteElement; 19 import org.apache.ecs.StringElement; 20 21 import org.apache.velocity.context.Context; 23 24 49 public class VTLTitlePortletControl extends PortletControl 50 { 51 54 public boolean supportsType( MimeType mimeType ) 55 { 56 return mimeType == MimeType.HTML; 57 } 58 59 60 62 public ConcreteElement getContent( RunData rundata ) 63 { 64 Portlet portlet = getPortlet(); 66 String portletName = portlet.getName(); 67 ConcreteElement portletContent = portlet.getContent( rundata ); 68 69 String hrefConfigure = ""; 71 String hrefMinimize = ""; 72 String hrefRestore = ""; 73 String hrefMaximize = ""; 74 String hrefClose = ""; 75 76 if( portlet instanceof AbstractVTLPortlet) 78 { 79 AbstractVTLPortlet xPortlet = (AbstractVTLPortlet)portlet; 81 82 if( xPortlet.getAllowEdit( rundata ) ) 84 { 85 hrefConfigure=new DynamicURI( rundata ) 86 .addPathInfo("portlet", portletName) 87 .addPathInfo("button","configure") 88 .toString(); 89 } 90 91 if( xPortlet.getAllowMinimize( rundata ) ) 93 { 94 if( xPortlet.isMinimized( rundata ) ) 95 { 96 hrefRestore=new DynamicURI( rundata ) 97 .addPathInfo("action", "portlets.RestorePortlet") 98 .addPathInfo("portletName", portletName) 99 .toString(); 100 } 101 else 102 { 103 hrefMinimize=new DynamicURI( rundata ) 104 .addPathInfo("action", "portlets.MinimizePortlet") 105 .addPathInfo("portletName", portletName) 106 .toString(); 107 } 108 } 109 110 if( xPortlet.getAllowMaximize( rundata ) ) 112 { 113 hrefMaximize=new DynamicURI( rundata ) 114 .addPathInfo("portlet", portletName) 115 .addPathInfo("button","maximize") 116 .toString(); 117 } 118 119 if( xPortlet.getAllowClose( rundata ) ) 121 { 122 hrefClose=new DynamicURI( rundata ) 123 .addPathInfo("action", "portlets.ClosePortlet") 124 .addPathInfo("portletName", portletName) 125 .toString(); 126 } 127 } 128 129 else 131 { 132 if ( portlet.getAllowEdit( rundata ) ) 133 { 134 try 135 { 136 hrefConfigure = URILookup.getURI( URILookup.TYPE_INFO, 137 URILookup.SUBTYPE_MARK, 138 portlet, rundata ); 139 } 140 catch (JetspeedException e) {} 141 } 142 143 if ( portlet.getAllowMaximize( rundata ) ) 144 { 145 try 146 { 147 hrefMaximize = URILookup.getURI( URILookup.TYPE_HOME, 148 URILookup.SUBTYPE_MAXIMIZE, 149 portlet, rundata ); 150 } 151 catch (JetspeedException je) {} 152 } 153 } 154 155 Context context = TurbineVelocity.getContext(); 157 158 context.put( "hrefConfigure", hrefConfigure ); 160 context.put( "hrefMinimize", hrefMinimize ); 161 context.put( "hrefRestore", hrefRestore ); 162 context.put( "hrefMaximize", hrefMaximize ); 163 context.put( "hrefClose", hrefClose ); 164 165 context.put( "panelColor", this.getColor() ); 167 context.put( "panelWidth", this.getWidth() ); 168 169 context.put( "titleText", getPortlet().getTitle() ); 171 context.put( "titleBgColor", this.getTitleColor() ); 172 173 context.put( "portletBgColor", this.getBackgroundColor() ); 175 176 context.put( "portletContent", portletContent ); 178 179 String theme = "VTLDefaultTheme.vm"; 182 String s = null; 183 try 184 { 185 s = TurbineVelocity.handleRequest(context, "controls/" + theme); 186 } 187 catch( Exception e ) 188 { 189 s = e.toString(); 190 } 191 192 return new StringElement( s ); 193 } 194 195 } 196 197 | Popular Tags |