1 28 29 30 package com.caucho.portal.alpharenderer; 31 32 import com.caucho.util.L10N; 33 34 import java.util.logging.Logger ; 35 36 37 public class HtmlMenu 38 extends Menu 39 { 40 private static L10N L = new L10N( HtmlMenu.class ); 41 42 static protected final Logger log = 43 Logger.getLogger( HtmlMenu.class.getName() ); 44 45 46 private String _cssClass; 47 private boolean _showSeparators = true; 48 49 public HtmlMenu() 50 { 51 } 52 53 public void setCssClass( String cssClass ) 54 { 55 _cssClass = cssClass; 56 } 57 58 62 public void setShowSeparators( boolean showSeparators ) 63 { 64 _showSeparators = showSeparators; 65 } 66 67 protected void menuStart( StringBuffer buf ) 68 { 69 if ( _cssClass != null ) { 70 buf.append( "<div class='" ); 71 buf.append( _cssClass ); 72 buf.append( "'>" ); 73 } 74 else { 75 buf.append( "<div>"); 76 } 77 } 78 79 protected void menuItem( StringBuffer buf, 80 int count, 81 String name, 82 String shortDescription, 83 String url, 84 boolean isSelected ) 85 86 { 87 if ( _showSeparators ) { 88 if ( count == 1 ) 89 buf.append("[ "); 90 else 91 buf.append(" | "); 92 } 93 94 if ( isSelected ) 95 buf.append("<span class='sel'"); 96 else { 97 if ( url == null) 98 buf.append("<span class='nosel'"); 99 else 100 buf.append("<span class='unsel'"); 101 } 102 103 if ( url == null && shortDescription != null ) { 104 buf.append(" title='"); 105 appendEscaped( buf, shortDescription ); 106 buf.append("'"); 107 } 108 109 buf.append('>'); 110 111 if ( url != null ) { 112 buf.append( "<a HREF='" ); 113 buf.append( url ); 114 buf.append( "'"); 115 116 if ( shortDescription != null ) { 117 buf.append(" title='"); 118 appendEscaped( buf,shortDescription ); 119 buf.append("'"); 120 } 121 buf.append( ">"); 122 } 123 124 appendEscaped( buf, name ); 125 126 if ( url != null ) 127 buf.append( "</a>" ); 128 129 buf.append( "</span>" ); 130 } 131 132 protected void menuEnd( StringBuffer buf, int count ) 133 { 134 if ( _showSeparators && count > 0 ) 135 buf.append("]"); 136 137 buf.append( "</div>"); 138 } 139 } 140 | Popular Tags |