1 20 21 22 package org.ozoneDB.xml.dom.html; 23 24 25 import org.ozoneDB.xml.dom.ElementImpl; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.NodeList ; 28 import org.w3c.dom.html.HTMLCollection; 29 import org.w3c.dom.html.HTMLElement; 30 import org.w3c.dom.html.HTMLOptionElement; 31 import org.w3c.dom.html.HTMLSelectElement; 32 33 34 40 public final class HTMLSelectElementImpl extends HTMLElementImpl implements HTMLSelectElement, HTMLFormControl { 41 42 43 public String getType() { 44 return getAttribute( "type" ); 45 } 46 47 48 public String getValue() { 49 return getAttribute( "value" ); 50 } 51 52 53 public void setValue( String value ) { 54 setAttribute( "value", value ); 55 } 56 57 58 public int getSelectedIndex() { 59 NodeList options; 60 int i; 61 62 options = getElementsByTagName( "OPTION" ); 68 for (i = 0; i < options.getLength(); ++i) { 69 if (((HTMLOptionElement)options.item( i )).getSelected()) { 70 return i; 71 } 72 } 73 return -1; 74 } 75 76 77 public void setSelectedIndex( int selectedIndex ) { 78 NodeList options; 79 int i; 80 81 options = getElementsByTagName( "OPTION" ); 87 for (i = 0; i < options.getLength(); ++i) { 88 ((HTMLOptionElementImpl)options.item( i )).setSelected( i == selectedIndex ); 89 } 90 } 91 92 93 public HTMLCollection getOptions() { 94 if (_options == null) { 95 _options = new HTMLCollectionImpl( this, HTMLCollectionImpl.OPTION ); 96 } 97 return _options; 98 } 99 100 101 public int getLength() { 102 return getOptions().getLength(); 103 } 104 105 106 public boolean getDisabled() { 107 return getAttribute( "disabled" ) != null; 108 } 109 110 111 public void setDisabled( boolean disabled ) { 112 setAttribute( "disabled", disabled ? "" : null ); 113 } 114 115 116 public boolean getMultiple() { 117 return getAttribute( "multiple" ) != null; 118 } 119 120 121 public void setMultiple( boolean multiple ) { 122 setAttribute( "multiple", multiple ? "" : null ); 123 } 124 125 126 public String getName() { 127 return getAttribute( "name" ); 128 } 129 130 131 public void setName( String name ) { 132 setAttribute( "name", name ); 133 } 134 135 136 public int getSize() { 137 return toInteger( getAttribute( "size" ) ); 138 } 139 140 141 public void setSize( int size ) { 142 setAttribute( "size", String.valueOf( size ) ); 143 } 144 145 146 public int getTabIndex() { 147 return toInteger( getAttribute( "tabindex" ) ); 148 } 149 150 151 public void setTabIndex( int tabIndex ) { 152 setAttribute( "tabindex", String.valueOf( tabIndex ) ); 153 } 154 155 156 public void add( HTMLElement element, HTMLElement before ) { 157 insertBefore( element, before ); 158 } 159 160 161 public void remove( int index ) { 162 NodeList options; 163 Node removed; 164 165 options = getElementsByTagName( "OPTION" ); 171 removed = options.item( index ); 172 if (removed != null) { 173 removed.getParentNode().removeChild( removed ); 174 } 175 } 176 177 178 public void blur() { 179 } 181 182 183 public void focus() { 184 } 186 187 188 193 public HTMLSelectElementImpl( HTMLDocumentImpl owner, String name ) { 194 super( owner, "SELECT" ); 195 } 196 197 private HTMLCollection _options; 198 199 200 } 201 | Popular Tags |