001package com.hfg.html; 002 003import com.hfg.html.attribute.Align; 004import com.hfg.xml.XMLNode; 005 006//------------------------------------------------------------------------------ 007/** 008 * Represents a paragraph (<p>) tag. 009 * 010 * @author J. Alex Taylor, hairyfatguy.com 011 */ 012//------------------------------------------------------------------------------ 013// com.hfg XML/HTML Coding Library 014// 015// This library is free software; you can redistribute it and/or 016// modify it under the terms of the GNU Lesser General Public 017// License as published by the Free Software Foundation; either 018// version 2.1 of the License, or (at your option) any later version. 019// 020// This library is distributed in the hope that it will be useful, 021// but WITHOUT ANY WARRANTY; without even the implied warranty of 022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 023// Lesser General Public License for more details. 024// 025// You should have received a copy of the GNU Lesser General Public 026// License along with this library; if not, write to the Free Software 027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 028// 029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 030// jataylor@hairyfatguy.com 031//------------------------------------------------------------------------------ 032 033public class P extends HTMLTagWithCoreEvents 034{ 035 036 //########################################################################## 037 // CONSTRUCTORS 038 //########################################################################## 039 040 //-------------------------------------------------------------------------- 041 public P() 042 { 043 super(HTML.P); 044 } 045 046 //-------------------------------------------------------------------------- 047 public P(String inContent) 048 { 049 this(); 050 addContent(inContent); 051 } 052 053 //-------------------------------------------------------------------------- 054 public P(HTMLTag inContent) 055 { 056 this(); 057 addSubtag(inContent); 058 } 059 060 //-------------------------------------------------------------------------- 061 public P(XMLNode inXMLNode) 062 { 063 this(); 064 initFromXMLNode(inXMLNode); 065 } 066 067 //########################################################################## 068 // PUBLIC METHODS 069 //########################################################################## 070 071 072 //-------------------------------------------------------------------------- 073 public Center addCenter() 074 { 075 Center center = new Center(); 076 addSubtag(center); 077 078 return center; 079 } 080 081 //-------------------------------------------------------------------------- 082 public Center addCenter(String inContent) 083 { 084 Center center = new Center(inContent); 085 addSubtag(center); 086 087 return center; 088 } 089 090 //-------------------------------------------------------------------------- 091 public Center addCenter(HTMLTag inContent) 092 { 093 Center center = new Center(inContent); 094 addSubtag(center); 095 096 return center; 097 } 098 099 //-------------------------------------------------------------------------- 100 public Div addDiv() 101 { 102 Div div = new Div(); 103 addSubtag(div); 104 105 return div; 106 } 107 108 //-------------------------------------------------------------------------- 109 public Div addDiv(HTMLTag inContent) 110 { 111 Div div = new Div(inContent); 112 addSubtag(div); 113 114 return div; 115 } 116 117 //-------------------------------------------------------------------------- 118 public Form addForm() 119 { 120 Form form = new Form(); 121 addSubtag(form); 122 123 return form; 124 } 125 126 //-------------------------------------------------------------------------- 127 public Form addForm(String inFormName) 128 { 129 Form form = new Form(inFormName); 130 addSubtag(form); 131 132 return form; 133 } 134 135 136 //-------------------------------------------------------------------------- 137 public Img addImage(String inSrc) 138 { 139 Img image = new Img(inSrc); 140 addSubtag(image); 141 142 return image; 143 } 144 145 //-------------------------------------------------------------------------- 146 public Link addLink() 147 { 148 Link link = new Link(); 149 addSubtag(link); 150 151 return link; 152 } 153 154 //-------------------------------------------------------------------------- 155 public Link addLink(CharSequence inURL) 156 { 157 Link link = new Link(inURL); 158 addSubtag(link); 159 160 return link; 161 } 162 163 //-------------------------------------------------------------------------- 164 public Link addLink(CharSequence inURL, String inContent) 165 { 166 Link link = new Link(inURL, inContent); 167 addSubtag(link); 168 169 return link; 170 } 171 172 //-------------------------------------------------------------------------- 173 public Link addLink(CharSequence inURL, HTMLTag inContent) 174 { 175 Link link = new Link(inURL, inContent); 176 addSubtag(link); 177 178 return link; 179 } 180 181 //-------------------------------------------------------------------------- 182 public Nobr addNobr() 183 { 184 Nobr nobr = new Nobr(); 185 addSubtag(nobr); 186 187 return nobr; 188 } 189 190 //-------------------------------------------------------------------------- 191 public Nobr addNobr(String inContent) 192 { 193 Nobr nobr = new Nobr(inContent); 194 addSubtag(nobr); 195 196 return nobr; 197 } 198 199 //-------------------------------------------------------------------------- 200 public Nobr addNobr(HTMLTag inContent) 201 { 202 Nobr nobr = new Nobr(inContent); 203 addSubtag(nobr); 204 205 return nobr; 206 } 207 208 209 //-------------------------------------------------------------------------- 210 public Pre addPre() 211 { 212 Pre pre = new Pre(); 213 addSubtag(pre); 214 215 return pre; 216 } 217 218 //-------------------------------------------------------------------------- 219 public Pre addPre(String inContent) 220 { 221 Pre pre = new Pre(inContent); 222 addSubtag(pre); 223 224 return pre; 225 } 226 227 //-------------------------------------------------------------------------- 228 public Pre addPre(HTMLTag inContent) 229 { 230 Pre pre = new Pre(inContent); 231 addSubtag(pre); 232 233 return pre; 234 } 235 236 //-------------------------------------------------------------------------- 237 public Span addSpan() 238 { 239 Span span = new Span(); 240 addSubtag(span); 241 242 return span; 243 } 244 245 //-------------------------------------------------------------------------- 246 public Span addSpan(String inContent) 247 { 248 Span span = new Span(inContent); 249 addSubtag(span); 250 251 return span; 252 } 253 254 //-------------------------------------------------------------------------- 255 public Span addSpan(HTMLTag inContent) 256 { 257 Span span = new Span(inContent); 258 addSubtag(span); 259 260 return span; 261 } 262 263 264 //-------------------------------------------------------------------------- 265 public Table addTable() 266 { 267 Table table = new Table(); 268 addSubtag(table); 269 270 return table; 271 } 272 273 //-------------------------------------------------------------------------- 274 public Ul addUnorderedList() 275 { 276 Ul ul = new Ul(); 277 addSubtag(ul); 278 279 return ul; 280 } 281 282 283 284 //-------------------------------------------------------------------------- 285 public InputButton addButton(String inName, String inValue) 286 { 287 InputButton button = new InputButton(inName, inValue); 288 addSubtag(button); 289 290 return button; 291 } 292 293 //-------------------------------------------------------------------------- 294 public InputCheckbox addCheckbox(String inName, String inValue) 295 { 296 InputCheckbox checkbox = new InputCheckbox(inName, inValue); 297 addSubtag(checkbox); 298 299 return checkbox; 300 } 301 302 //-------------------------------------------------------------------------- 303 public InputCheckbox addCheckbox(String inName, String inValue, boolean checked) 304 { 305 InputCheckbox checkbox = new InputCheckbox(inName, inValue, checked); 306 addSubtag(checkbox); 307 308 return checkbox; 309 } 310 311 312 //-------------------------------------------------------------------------- 313 public InputFile addFileInput() 314 { 315 InputFile subtag = new InputFile(); 316 addSubtag(subtag); 317 318 return subtag; 319 } 320 321 //-------------------------------------------------------------------------- 322 public InputFile addFileInput(String inName) 323 { 324 InputFile subtag = new InputFile(inName); 325 addSubtag(subtag); 326 327 return subtag; 328 } 329 330 //-------------------------------------------------------------------------- 331 public InputFile addFileInput(String inName, String inValue) 332 { 333 InputFile subtag = new InputFile(inName, inValue); 334 addSubtag(subtag); 335 336 return subtag; 337 } 338 339 //-------------------------------------------------------------------------- 340 public InputPassword addPasswordInput() 341 { 342 InputPassword password = new InputPassword(); 343 addSubtag(password); 344 345 return password; 346 } 347 348 //-------------------------------------------------------------------------- 349 public InputPassword addPasswordInput(String inName, String inValue) 350 { 351 InputPassword password = new InputPassword(inName, inValue); 352 addSubtag(password); 353 354 return password; 355 } 356 357 //-------------------------------------------------------------------------- 358 public InputRadio addRadio(String inName, String inValue) 359 { 360 InputRadio radio = new InputRadio(inName, inValue); 361 addSubtag(radio); 362 363 return radio; 364 } 365 366 //-------------------------------------------------------------------------- 367 public InputRadio addRadio(String inName, String inValue, boolean checked) 368 { 369 InputRadio radio = new InputRadio(inName, inValue, checked); 370 addSubtag(radio); 371 372 return radio; 373 } 374 375 //-------------------------------------------------------------------------- 376 public InputReset addReset() 377 { 378 InputReset reset = new InputReset(); 379 addSubtag(reset); 380 381 return reset; 382 } 383 384 //-------------------------------------------------------------------------- 385 public Select addSelect(String inName) 386 { 387 Select select = new Select(inName); 388 addSubtag(select); 389 390 return select; 391 } 392 393 //-------------------------------------------------------------------------- 394 public InputSubmit addSubmit(String inName, String inValue) 395 { 396 InputSubmit submit = new InputSubmit(inName, inValue); 397 addSubtag(submit); 398 399 return submit; 400 } 401 402 403 //-------------------------------------------------------------------------- 404 public Textarea addTextarea(String inName, String inValue) 405 { 406 Textarea textarea = new Textarea(inName, inValue); 407 addSubtag(textarea); 408 409 return textarea; 410 } 411 412 //-------------------------------------------------------------------------- 413 public Textarea addTextarea(String inName, String inValue, int inRows, int inCols) 414 { 415 Textarea textarea = new Textarea(inName, inValue, inRows, inCols); 416 addSubtag(textarea); 417 418 return textarea; 419 } 420 421 422 //-------------------------------------------------------------------------- 423 public InputText addTextInput() 424 { 425 InputText text = new InputText(); 426 addSubtag(text); 427 428 return text; 429 } 430 431 //-------------------------------------------------------------------------- 432 public InputText addTextInput(String inName, String inValue) 433 { 434 InputText text = new InputText(inName, inValue); 435 addSubtag(text); 436 437 return text; 438 } 439 440 441 442 443 444 //-------------------------------------------------------------------------- 445 public P setAlign(Align inValue) 446 { 447 setAttribute(inValue.getHTMLAttributeName(), inValue.toString()); 448 449 return this; 450 } 451 452 //-------------------------------------------------------------------------- 453 public P setClass(String inValue) 454 { 455 setAttribute(HTML.CLASS, inValue); 456 457 return this; 458 } 459 460 461 //-------------------------------------------------------------------------- 462 public void br() 463 { 464 HTMLUtil.br(this); 465 } 466 467 //-------------------------------------------------------------------------- 468 public void br(int inNumber) 469 { 470 HTMLUtil.br(this, inNumber); 471 } 472 473 //-------------------------------------------------------------------------- 474 public void nbsp(int inNumber) 475 { 476 HTMLUtil.nbsp(this, inNumber); 477 } 478 479 //-------------------------------------------------------------------------- 480 public void hr() 481 { 482 HTMLUtil.hr(this); 483 } 484 485 //-------------------------------------------------------------------------- 486 public void hr(String inWidth) 487 { 488 HTMLUtil.hr(this, inWidth); 489 } 490 491 492 // Overrides for HTMLTag setters to allow method chaining. 493 494 //-------------------------------------------------------------------------- 495 @Override 496 public P setId(String inValue) 497 { 498 return (P) super.setId(inValue); 499 } 500 501 //-------------------------------------------------------------------------- 502 @Override 503 public P setStyle(CharSequence inValue) 504 { 505 return (P) super.setStyle(inValue); 506 } 507 508 //-------------------------------------------------------------------------- 509 @Override 510 public P addStyle(String inValue) 511 { 512 return (P) super.addStyle(inValue); 513 } 514 515 // Overrides for HTMLTagWithCoreEvents setters to allow method chaining. 516 517 //-------------------------------------------------------------------------- 518 @Override 519 public P setOnClick(String inValue) 520 { 521 return (P) super.setOnClick(inValue); 522 } 523 524 //-------------------------------------------------------------------------- 525 @Override 526 public P setOnDblClick(String inValue) 527 { 528 return (P) super.setOnDblClick(inValue); 529 } 530 531 //-------------------------------------------------------------------------- 532 @Override 533 public P setOnMouseDown(String inValue) 534 { 535 return (P) super.setOnMouseDown(inValue); 536 } 537 538 //-------------------------------------------------------------------------- 539 @Override 540 public P setOnMouseMove(String inValue) 541 { 542 return (P) super.setOnMouseMove(inValue); 543 } 544 545 //-------------------------------------------------------------------------- 546 @Override 547 public P setOnMouseOut(String inValue) 548 { 549 return (P) super.setOnMouseOut(inValue); 550 } 551 552 //-------------------------------------------------------------------------- 553 @Override 554 public P setOnMouseOver(String inValue) 555 { 556 return (P) super.setOnMouseOver(inValue); 557 } 558 559 //-------------------------------------------------------------------------- 560 @Override 561 public P setOnMouseUp(String inValue) 562 { 563 return (P) super.setOnMouseUp(inValue); 564 } 565 566 //-------------------------------------------------------------------------- 567 @Override 568 public P setOnKeyDown(String inValue) 569 { 570 return (P) super.setOnKeyDown(inValue); 571 } 572 573 //-------------------------------------------------------------------------- 574 @Override 575 public P setOnKeyPress(String inValue) 576 { 577 return (P) super.setOnKeyPress(inValue); 578 } 579 580 //-------------------------------------------------------------------------- 581 @Override 582 public P setOnKeyUp(String inValue) 583 { 584 return (P) super.setOnKeyUp(inValue); 585 } 586}