1 18 package org.apache.beehive.netui.compiler.model; 19 20 import org.w3c.dom.Node ; 21 import org.apache.xmlbeans.XmlObject; 22 import org.apache.xmlbeans.XmlCursor; 23 24 import java.util.HashMap ; 25 26 29 public abstract class StrutsElementSupport 30 { 31 private String _description; 32 private HashMap _properties = new HashMap (); 33 private String _displayName; 34 private Icon _icon; 35 private StrutsApp _parentApp; 36 private String _comment; 37 private String _className; 38 39 public StrutsElementSupport( StrutsApp parentApp ) 40 { 41 _parentApp = parentApp; 42 } 43 44 protected StrutsApp getParentApp() 45 { 46 return _parentApp; 47 } 48 49 public void setDescription( String description ) 50 { _description = description; } 51 52 public String getDescription() 53 { return _description; } 54 55 public void setProperty( String name, String value ) 56 { _properties.put( name, value ); } 57 58 public String getProperty( String name ) 59 { return ( String ) _properties.get( name ); } 60 61 public void setDisplayName( String displayName ) 62 { _displayName = displayName; } 63 64 public String getDisplayName() 65 { return _displayName; } 66 67 public void setIcon( Icon icon ) 68 { _icon = icon; } 69 70 public Icon getIcon() 71 { return _icon; } 72 73 public String getClassName() 74 { 75 return _className; 76 } 77 78 public void setClassName( String className ) 79 { 80 _className = className; 81 } 82 83 public void setComment( String comment ) 84 { 85 _comment = comment; 86 } 87 88 public String getComment() 89 { 90 return _comment; 91 } 92 93 class Icon 94 { 95 String smallIconLocation; 96 String largeIconLocation; 97 98 104 public Icon( String smallIconLocation ) 105 { 106 this( smallIconLocation, null ); 107 } 108 109 117 public Icon( String smallIconLocation, String largeIconLocation ) 118 { 119 this.smallIconLocation = smallIconLocation; 120 this.largeIconLocation = largeIconLocation; 121 } 122 } 123 124 public static String getAttr( Node node, String name ) 125 { 126 Node attr = node.getAttributes().getNamedItem( name ); 127 return ( attr != null ? attr.getNodeValue() : null ); 128 } 129 130 public static boolean getAttrBool( Node node, String name ) 131 { 132 String val = getAttr( node, name ); 133 return ( val != null && val.equalsIgnoreCase( "true" ) ); } 135 136 protected void addComment( XmlObject xb ) 137 { 138 if ( _comment != null ) 139 { 140 XmlCursor curs = xb.newCursor(); 141 curs.insertComment( " " + _comment + " " ); 142 } 143 } 144 145 protected void setParentApp( StrutsApp parentApp ) 146 { 147 _parentApp = parentApp; 148 } 149 } 150 | Popular Tags |