Changeset 6596
- Timestamp:
- Nov 14, 2014, 2:34:01 PM (8 years ago)
- Location:
- trunk/src/clients/web
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Body.java
r6576 r6596 25 25 26 26 import net.sf.basedb.clients.web.Base; 27 import net.sf.basedb.clients.web.extensions.DynamicActionAttributeSupport; 28 import net.sf.basedb.clients.web.extensions.skin.SkinAction; 27 29 import net.sf.basedb.clients.web.util.HTML; 28 30 import net.sf.basedb.core.Application; … … 31 33 32 34 import java.util.Date; 35 import java.util.List; 36 33 37 import javax.servlet.jsp.JspException; 34 38 import javax.servlet.jsp.JspTagException; … … 235 239 addDynamicAttributes(sb); 236 240 sb.append(">\n"); 241 242 // Output <div> tag with skin extension dynamic attributes 243 List<SkinAction> skinActions = page.getSkinActions(); 244 if (skinActions != null && skinActions.size() > 0) 245 { 246 sb.append("<div id=\"skin-data\" class=\"datacontainer\">\n"); 247 for (SkinAction skin : skinActions) 248 { 249 if (skin.getId() != null) 250 { 251 sb.append("\t<div id=\"").append(skin.getId()).append("\""); 252 sb.append(DynamicActionAttributeSupport.getAttributesString(skin)); 253 sb.append("></div>\n"); 254 } 255 } 256 sb.append("</div>"); 257 } 237 258 } 238 259 -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Head.java
r6576 r6596 24 24 25 25 import net.sf.basedb.clients.web.extensions.ExtensionsControl; 26 import net.sf.basedb.clients.web.extensions.JspContext; 26 27 import net.sf.basedb.clients.web.util.HTML; 27 28 import net.sf.basedb.core.SessionControl; … … 185 186 } 186 187 187 private void appendStyles(StringBuilder sb, String fontStyles, boolean hideLongTexts )188 private void appendStyles(StringBuilder sb, String fontStyles, boolean hideLongTexts, JspContext jspContext) 188 189 { 189 190 LinkedHashSet<String> allStyles = new LinkedHashSet<String>(); … … 198 199 allStyles.add(fontStyles); 199 200 if (hideLongTexts) allStyles.add("long_texts.css"); 201 if (jspContext != null && jspContext.getStylesheets() != null) 202 { 203 allStyles.addAll(jspContext.getStylesheets()); 204 } 205 200 206 String appRoot = page.getRoot(); 201 207 for (String style : allStyles) … … 226 232 } 227 233 228 private void appendScripts(StringBuilder sb )234 private void appendScripts(StringBuilder sb, JspContext jspContext) 229 235 { 230 236 SessionControl sc = page.getSessionControl(); … … 245 251 { 246 252 allScripts.addAll(Arrays.asList(getScripts().split(","))); 253 } 254 if (jspContext != null && jspContext.getScripts() != null) 255 { 256 allScripts.addAll(jspContext.getScripts()); 247 257 } 248 258 … … 294 304 page = (Page)getParent(); 295 305 306 SessionControl sc = page.getSessionControl(); 307 int pageType = page.getTypeCode(); 308 JspContext skinContext = page.getSkinContext(); 309 296 310 StringBuilder sb = new StringBuilder(); 297 311 int returnValue = EVAL_BODY_INCLUDE; 298 if (page .getTypeCode()== Page.PAGE_TYPE_INCLUDE)299 { 300 appendScripts(sb );312 if (pageType == Page.PAGE_TYPE_INCLUDE) 313 { 314 appendScripts(sb, skinContext); 301 315 returnValue = SKIP_BODY; 302 316 } 303 317 else 304 318 { 305 SessionControl sc = page.getSessionControl();306 319 String longTexts = Values.getString(sc != null ? sc.getUserClientSetting("text.long") : null, "display"); 307 320 String fontStyles = Values.getString(sc != null ? sc.getUserClientSetting("appearance.fontsize") : null, "size_m.css"); 308 321 309 322 String favicon = page.getFavicon(); 310 if (favicon != null && !favicon.startsWith("/")) 323 if (favicon == null) favicon = "favicon.ico"; 324 if (!favicon.startsWith("/")) 311 325 { 312 326 favicon = page.getRoot()+favicon; … … 314 328 315 329 sb.append("<head>\n"); 316 if (favicon != null) 317 { 318 sb.append("\t<link id=\"fav-icon\" rel=\"SHORTCUT ICON\" href=\"").append(favicon).append("\">\n"); 319 } 320 appendStyles(sb, fontStyles, !"display".equals(longTexts)); 321 appendScripts(sb); 330 sb.append("\t<link id=\"fav-icon\" rel=\"SHORTCUT ICON\" href=\"").append(favicon).append("\">\n"); 331 appendStyles(sb, fontStyles, !"display".equals(longTexts), skinContext); 332 appendScripts(sb, skinContext); 322 333 323 334 String title = page.getTitle(); -
trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Page.java
r6540 r6596 23 23 package net.sf.basedb.clients.web.taglib; 24 24 25 import java.util.ArrayList; 26 import java.util.List; 27 25 28 import net.sf.basedb.core.Application; 26 29 import net.sf.basedb.core.SessionControl; 27 30 import net.sf.basedb.core.Version; 28 31 import net.sf.basedb.clients.web.Base; 32 import net.sf.basedb.clients.web.extensions.ExtensionsControl; 33 import net.sf.basedb.clients.web.extensions.JspContext; 34 import net.sf.basedb.clients.web.extensions.skin.SkinAction; 29 35 import net.sf.basedb.util.Values; 36 import net.sf.basedb.util.extensions.ActionIterator; 37 import net.sf.basedb.util.extensions.ExtensionsInvoker; 30 38 31 39 import javax.servlet.jsp.PageContext; … … 176 184 The 'favicon' to use. 177 185 */ 178 private String favicon = "favicon.ico";186 private String favicon = null; 179 187 180 188 private static volatile boolean initialized = false; … … 201 209 */ 202 210 private transient SessionControl sc; 211 212 private transient JspContext skinContext; 213 214 private transient List<SkinAction> skinActions; 203 215 204 216 /** … … 314 326 } 315 327 328 /** 329 Get the JSP context used for invoking skin extensions. Needed 330 by HEAD taglib so that it can include required scripts and stylesheets. 331 @since 3.4 332 */ 333 public JspContext getSkinContext() 334 { 335 return skinContext; 336 } 337 338 /** 339 Get all skin extension actions. Needed in BODY so that 340 it can include data on the page. 341 @since 3.4 342 */ 343 public List<SkinAction> getSkinActions() 344 { 345 return skinActions; 346 } 347 316 348 @Override 317 349 public void setPageContext(PageContext pageContext) 318 350 { 319 351 super.setPageContext(pageContext); 352 favicon = null; 320 353 if (!initialized) initStaticFields(pageContext); 321 354 try … … 327 360 } 328 361 362 @SuppressWarnings("unchecked") 329 363 @Override 330 364 public int doStartTag() … … 333 367 if (type != PAGE_TYPE_INCLUDE) 334 368 { 369 // Load skin extensions: net.sf.basedb.clients.web.global-skin 370 skinContext = ExtensionsControl.createContext(sc, pageContext); 371 skinContext.setAttribute("page-type", getTypeCode()); 372 ExtensionsInvoker<SkinAction> invoker = (ExtensionsInvoker<SkinAction>)ExtensionsControl.useExtensions(skinContext, "net.sf.basedb.clients.web.global-skin"); 373 ActionIterator<SkinAction> it = invoker.iterate(); 374 skinActions = new ArrayList<SkinAction>(); 375 while (it.hasNext()) 376 { 377 SkinAction skin = it.next(); 378 if (favicon == null) 379 { 380 String skinIcon = skin.getFavicon(); 381 if (skinIcon != null) favicon = skinIcon; 382 } 383 } 384 335 385 StringBuilder sb = new StringBuilder(); 336 386 sb.append("<!doctype ").append(getDoctype()).append(">\n"); -
trunk/src/clients/web/web-extensions.xml
r6440 r6596 155 155 and/or password prompts, help texts, etc. Since there is only one login form, 156 156 only the first extension found for this extension point is used. 157 </description> 158 </extension-point> 159 160 <extension-point 161 id="global-skin"> 162 <action-class>net.sf.basedb.clients.web.extensions.skin.SkinAction</action-class> 163 <name>Skins</name> 164 <description> 165 Extension point for GUI customizations. Extensions should implement 166 the SkinAction interface, which can be used to set the favicon and 167 add custom data to a hidden div tag on the page. Most work is expected 168 to be done by stylesheets and/or scripts added to the JspContext 169 instance passed to factory via the prepareContext method. 157 170 </description> 158 171 </extension-point>
Note: See TracChangeset
for help on using the changeset viewer.