1 16 package org.apache.myfaces.custom.inputHtml; 17 18 import java.io.IOException ; 19 import java.util.Map ; 20 21 import javax.faces.component.EditableValueHolder; 22 import javax.faces.component.UIComponent; 23 import javax.faces.component.UIForm; 24 import javax.faces.context.FacesContext; 25 import javax.faces.context.ResponseWriter; 26 import javax.faces.convert.ConverterException; 27 28 import org.apache.myfaces.component.UserRoleUtils; 29 import org.apache.myfaces.component.html.util.AddResource; 30 import org.apache.myfaces.renderkit.RendererUtils; 31 import org.apache.myfaces.renderkit.html.HTML; 32 import org.apache.myfaces.renderkit.html.HtmlRenderer; 33 import org.apache.myfaces.renderkit.html.HtmlRendererUtils; 34 import org.apache.myfaces.renderkit.html.util.HTMLEncoder; 35 import org.apache.myfaces.renderkit.html.util.JavascriptUtils; 36 37 122 public class InputHtmlRenderer extends HtmlRenderer { 123 127 protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent) { 128 if( !UserRoleUtils.isEnabledOnUserRole(uiComponent) ) 129 return false; 130 131 return ((InputHtml)uiComponent).isDisabled(); 132 } 133 134 private static boolean useFallback(InputHtml editor){ 135 return editor.getFallback().equals("true"); 137 } 138 139 public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException { 140 RendererUtils.checkParamValidity(context, uiComponent, InputHtml.class); 141 InputHtml editor = (InputHtml) uiComponent; 142 if( useFallback(editor) ) 143 encodeEndFallBackMode(context, editor); 144 else 145 encodeEndNormalMode(context, editor); 146 } 147 148 private void encodeEndFallBackMode(FacesContext context, InputHtml editor) throws IOException { 149 String clientId = editor.getClientId(context); 150 ResponseWriter writer = context.getResponseWriter(); 152 writer.startElement(HTML.TEXTAREA_ELEM, editor); 153 154 writer.writeAttribute(HTML.NAME_ATTR, clientId, null); 155 HtmlRendererUtils.writeIdIfNecessary(writer, editor, context); 156 157 if( editor.getStyle()!=null ) 158 writer.writeAttribute(HTML.STYLE_ATTR, editor.getStyle(), null); 159 if( editor.getStyleClass()!=null ) 160 writer.writeAttribute(HTML.STYLE_CLASS_ATTR, editor.getStyleClass(), null); 161 162 if (isDisabled(context, editor)) 163 writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null); 164 165 String text = RendererUtils.getStringValue(context, editor); 166 writer.write( htmlToPlainText( text ) ); 167 168 writer.endElement(HTML.TEXTAREA_ELEM); 169 } 170 171 private static String htmlToPlainText(String html){ 172 return getHtmlBody( html ).replaceAll("<br.*>","\n"); 173 } 174 175 private static String getHtmlBody(String html){ 176 String lcText = html.toLowerCase(); 177 int textLength = lcText.length(); 178 int bodyStartIndex = 0; 179 while(bodyStartIndex < textLength){ 180 bodyStartIndex = lcText.indexOf("<body"); 181 if( bodyStartIndex == -1 ) 182 break; 184 bodyStartIndex += 5; 185 char c = lcText.charAt(bodyStartIndex); 186 if( c=='>' ){ 187 break; 188 } 189 190 if( c!=' ' && c!='\t' ) 191 continue; 192 193 bodyStartIndex = lcText.indexOf('>', bodyStartIndex); 194 } 195 bodyStartIndex++; 196 197 int bodyEndIndex = lcText.lastIndexOf("</body>")-1; 198 199 if( bodyStartIndex<0 || bodyEndIndex<0 200 || bodyStartIndex > bodyEndIndex 201 || bodyStartIndex>=textLength || bodyEndIndex>=textLength ){ 202 return html.trim(); 203 } 204 205 return html.substring(bodyStartIndex, bodyEndIndex+1).trim(); 206 } 207 208 private void encodeEndNormalMode(FacesContext context, InputHtml editor) throws IOException { 209 String clientId = editor.getClientId(context); 210 String formId; 211 { 212 UIComponent tmpComponent = editor.getParent(); 213 while(!(tmpComponent instanceof UIForm) ){ 214 tmpComponent = tmpComponent.getParent(); 215 } 216 formId = tmpComponent.getClientId(context); 217 } 218 219 220 AddResource.addStyleSheet(InputHtmlRenderer.class, "kupustyles.css", context); 221 AddResource.addStyleSheet(InputHtmlRenderer.class, "kupudrawerstyles.css", context); 222 223 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "sarissa.js", context); 224 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuhelpers.js", context); 225 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupueditor.js", context); 226 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupubasetools.js", context); 227 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuloggers.js", context); 228 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucontentfilters.js", context); 229 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucleanupexpressions.js", context); 230 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupucontextmenu.js", context); 231 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupuinit.js", context); 232 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupustart_form.js", context); 233 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupusourceedit.js", context); 234 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "kupudrawers.js", context); 235 236 ResponseWriter writer = context.getResponseWriter(); 237 238 writer.startElement(HTML.DIV_ELEM,null); 239 writer.writeAttribute(HTML.STYLE_ATTR, "display: none;",null); 240 241 writer.startElement("xml", null); 242 writer.writeAttribute("id", "kupuconfig", null); 243 244 writer.startElement("kupuconfig", null); 245 246 writeTag(writer, "dst", "fulldoc.html"); 247 writeTag(writer, "use_css", "0"); 248 writeTag(writer, "reload_after_save", "0"); 249 writeTag(writer, "strict_output", "1"); 250 writeTag(writer, "content_type", "application/xhtml+xml"); 251 writeTag(writer, "compatible_singletons", "1"); 252 253 writer.startElement("table_classes", null); 254 writeTag(writer, "class", "plain"); 255 writeTag(writer, "class", "listing"); 256 writeTag(writer, "class", "grid"); 257 writeTag(writer, "class", "data"); 258 writer.endElement("table_classes"); 259 260 writer.startElement("cleanup_expressions",null); 261 writer.startElement("set",null); 262 writer.startElement("name",null); 263 writer.write("Convert single quotes to curly ones"); 264 writer.endElement("name"); 265 writer.startElement("expression",null); 266 writer.startElement("reg",null); 267 writer.write("(\\W)'"); 268 writer.endElement("reg"); 269 writer.startElement("replacement",null); 270 writer.write("\\1‘"); 271 writer.endElement("replacement"); 272 writer.endElement("expression"); 273 writer.startElement("expression",null); 274 writer.startElement("reg",null); 275 writer.write("'"); 276 writer.endElement("reg"); 277 writer.startElement("replacement",null); 278 writer.write("’"); 279 writer.endElement("replacement"); 280 writer.endElement("expression"); 281 writer.endElement("set"); 282 writer.startElement("set",null); 283 writer.startElement("name",null); 284 writer.write("Reduce whitespace"); 285 writer.endElement("name"); 286 writer.startElement("expression",null); 287 writer.startElement("reg",null); 288 writer.write("[ ]{2}"); 289 writer.endElement("reg"); 290 writer.startElement("replacement",null); 291 writer.write("\\x20"); 292 writer.endElement("replacement"); 293 writer.endElement("expression"); 294 writer.endElement("set"); 295 writer.endElement("cleanup_expressions"); 296 297 writeTag(writer, "image_xsl_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/drawer.xsl", context)); 298 writeTag(writer, "link_xsl_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/drawer.xsl", context)); 299 300 writeTag(writer, "image_libraries_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/imagelibrary.xml", context)); 302 writeTag(writer, "link_libraries_uri", AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupudrawers/linklibrary.xml", context)); 303 writeTag(writer, "search_images_uri", ""); 304 writeTag(writer, "search_links_uri", ""); 305 306 writer.endElement("kupuconfig"); 307 writer.endElement("xml"); 308 writer.endElement(HTML.DIV_ELEM); 309 310 311 writer.startElement(HTML.DIV_ELEM,null); 312 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-fulleditor", null); 313 314 writer.startElement(HTML.DIV_ELEM,null); 318 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb",null); 319 writer.writeAttribute(HTML.ID_ATTR, "toolbar",null); 320 321 writer.startElement(HTML.SPAN_ELEM,null); 322 writer.writeAttribute(HTML.ID_ATTR, "kupu-tb-buttons",null); 323 324 writer.startElement(HTML.SPAN_ELEM,null); 325 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup",null); 326 writer.writeAttribute(HTML.ID_ATTR, "kupu-logo",null); 327 writer.writeAttribute(HTML.STYLE_ATTR, "float: right", null); 328 writer.startElement(HTML.BUTTON_ELEM,null); 329 writer.writeAttribute(HTML.TYPE_ATTR, "button",null); 330 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-zoom",null); 331 writer.writeAttribute(HTML.ID_ATTR, "kupu-zoom-button",null); 332 writer.writeAttribute(HTML.TITLE_ATTR, "zoom: alt-x",null); 333 writer.writeAttribute(HTML.ACCESSKEY_ATTR, "x",null); 334 writer.write(" "); 335 writer.endElement(HTML.BUTTON_ELEM); 336 if( editor.isAddKupuLogo() ){ 337 writer.startElement(HTML.BUTTON_ELEM,null); 338 writer.writeAttribute(HTML.TYPE_ATTR, "button",null); 339 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-logo",null); 340 writer.writeAttribute(HTML.TITLE_ATTR, "Kupu 1.2rc2",null); 341 writer.writeAttribute(HTML.ACCESSKEY_ATTR, "k",null); 342 writer.writeAttribute(HTML.ONCLICK_ATTR, "window.open('http://kupu.oscom.org');",null); 343 writer.write(" "); 344 writer.endElement(HTML.BUTTON_ELEM); 345 } 346 writer.endElement(HTML.SPAN_ELEM); 347 348 writer.startElement(HTML.SELECT_ELEM,null); 349 writer.writeAttribute(HTML.ID_ATTR, "kupu-tb-styles",null); 350 writer.startElement(HTML.OPTION_ELEM,null); 351 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 352 writer.writeAttribute(HTML.VALUE_ATTR, "P",null); 353 writer.writeAttribute("i18n:translate", "paragraph-normal", null); 354 writer.write("Normal"); 355 writer.endElement(HTML.OPTION_ELEM); 356 357 writer.startElement(HTML.OPTION_ELEM,null); 358 writer.writeAttribute(HTML.VALUE_ATTR, "H1",null); 359 writer.startElement(HTML.SPAN_ELEM,null); 360 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 361 writer.writeAttribute("i18n:translate", "heading", null); 362 writer.write("Heading"); 363 writer.endElement(HTML.SPAN_ELEM); 364 writer.write(" 1"); 365 writer.endElement(HTML.OPTION_ELEM); 366 367 writer.startElement(HTML.OPTION_ELEM,null); 368 writer.writeAttribute(HTML.VALUE_ATTR, "H2",null); 369 writer.startElement(HTML.SPAN_ELEM,null); 370 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 371 writer.writeAttribute("i18n:translate", "heading", null); 372 writer.write("Heading"); 373 writer.endElement(HTML.SPAN_ELEM); 374 writer.write(" 2"); 375 writer.endElement(HTML.OPTION_ELEM); 376 377 writer.startElement(HTML.OPTION_ELEM,null); 378 writer.writeAttribute(HTML.VALUE_ATTR, "H3",null); 379 writer.startElement(HTML.SPAN_ELEM,null); 380 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 381 writer.writeAttribute("i18n:translate", "heading", null); 382 writer.write("Heading"); 383 writer.endElement(HTML.SPAN_ELEM); 384 writer.write(" 3"); 385 writer.endElement(HTML.OPTION_ELEM); 386 387 writer.startElement(HTML.OPTION_ELEM,null); 388 writer.writeAttribute(HTML.VALUE_ATTR, "H4",null); 389 writer.startElement(HTML.SPAN_ELEM,null); 390 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 391 writer.writeAttribute("i18n:translate", "heading", null); 392 writer.write("Heading"); 393 writer.endElement(HTML.SPAN_ELEM); 394 writer.write(" 4"); 395 writer.endElement(HTML.OPTION_ELEM); 396 397 writer.startElement(HTML.OPTION_ELEM,null); 398 writer.writeAttribute(HTML.VALUE_ATTR, "H5",null); 399 writer.startElement(HTML.SPAN_ELEM,null); 400 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 401 writer.writeAttribute("i18n:translate", "heading", null); 402 writer.write("Heading"); 403 writer.endElement(HTML.SPAN_ELEM); 404 writer.write(" 5"); 405 writer.endElement(HTML.OPTION_ELEM); 406 407 writer.startElement(HTML.OPTION_ELEM,null); 408 writer.writeAttribute(HTML.VALUE_ATTR, "H6",null); 409 writer.startElement(HTML.SPAN_ELEM,null); 410 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 411 writer.writeAttribute("i18n:translate", "heading", null); 412 writer.write("Heading"); 413 writer.endElement(HTML.SPAN_ELEM); 414 writer.write(" 6"); 415 writer.endElement(HTML.OPTION_ELEM); 416 417 writer.startElement(HTML.OPTION_ELEM,null); 418 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 419 writer.writeAttribute(HTML.VALUE_ATTR, "PRE",null); 420 writer.writeAttribute("i18n:translate", "paragraph-formatted", null); 421 writer.write("Formatted"); 422 writer.endElement(HTML.OPTION_ELEM); 423 424 writer.endElement(HTML.SELECT_ELEM); 425 426 writer.startElement(HTML.SPAN_ELEM,null); 427 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 428 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 429 writeButton(writer, "kupu-save", "Save", "s"); 430 writer.endElement(HTML.SPAN_ELEM); 431 432 writer.startElement(HTML.SPAN_ELEM,null); 433 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 434 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-basicmarkup", null); 435 writeButton(writer, "kupu-bold", "bold: alt-b", "b"); 436 writeButton(writer, "kupu-italic", "italic: alt-i", "i"); 437 writeButton(writer, "kupu-underline", "underline: alt-u", "u"); 438 writer.endElement(HTML.SPAN_ELEM); 439 440 writer.startElement(HTML.SPAN_ELEM,null); 441 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 442 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-subsuper", null); 443 writeButton(writer, "kupu-subscript", "subscript: alt--", "-"); 444 writeButton(writer, "kupu-superscript", "superscript: alt-+", "+"); 445 writer.endElement(HTML.SPAN_ELEM); 446 447 writer.startElement(HTML.SPAN_ELEM,null); 448 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 449 writeButton(writer, "kupu-forecolor", "text color: alt-f", "f"); 450 writeButton(writer, "kupu-hilitecolor", "background color: alt-h", "h"); 451 writer.endElement(HTML.SPAN_ELEM); 452 453 writer.startElement(HTML.SPAN_ELEM,null); 454 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 455 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-justify", null); 456 writeButton(writer, "kupu-justifyleft", "left justify: alt-l", "l"); 457 writeButton(writer, "kupu-justifycenter", "center justify: alt-c", "c"); 458 writeButton(writer, "kupu-justifyright", "right justify: alt-r", "r"); 459 writer.endElement(HTML.SPAN_ELEM); 460 461 writer.startElement(HTML.SPAN_ELEM,null); 462 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 463 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-list", null); 464 writeButton(writer, "kupu-insertorderedlist", "numbered list: alt-#", "#", "kupu-list-ol-addbutton"); 465 writeButton(writer, "kupu-insertunorderedlist", "unordered list: alt-*", "*", "kupu-list-ul-addbutton"); 466 writer.endElement(HTML.SPAN_ELEM); 467 468 writer.startElement(HTML.SPAN_ELEM,null); 469 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 470 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-definitionlist", null); 471 writeButton(writer, "kupu-insertdefinitionlist", "definition list: alt-=", "=", "kupu-list-dl-addbutton"); 472 writer.endElement(HTML.SPAN_ELEM); 473 474 writer.startElement(HTML.SPAN_ELEM,null); 475 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 476 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-indent", null); 477 writeButton(writer, "kupu-outdent", "outdent: alt-<", "<"); 478 writeButton(writer, "kupu-indent", "indent: alt->", ">"); 479 writer.endElement(HTML.SPAN_ELEM); 480 481 writer.startElement(HTML.SPAN_ELEM,null); 482 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 483 if( ! editor.isAllowExternalLinks() ){ 484 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 485 } 486 writeButton(writer, "kupu-image", "image", null, "kupu-imagelibdrawer-button", false); writeButton(writer, "kupu-inthyperlink", "link", null, "kupu-linklibdrawer-button", false); writeButton(writer, "kupu-exthyperlink", "external link", null, "kupu-linkdrawer-button"); 489 writeButton(writer, "kupu-table", "table", null, "kupu-tabledrawer-button"); 490 writer.endElement(HTML.SPAN_ELEM); 491 492 writer.startElement(HTML.SPAN_ELEM,null); 493 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 494 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-remove", null); 495 writeButton(writer, "kupu-removeimage invisible", "Remove image", null, "kupu-removeimage-button"); 496 writeButton(writer, "kupu-removelink invisible", "Remove link", null, "kupu-removelink-button"); 497 writer.endElement(HTML.SPAN_ELEM); 498 499 writer.startElement(HTML.SPAN_ELEM,null); 500 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 501 writer.writeAttribute(HTML.ID_ATTR, "kupu-bg-undo", null); 502 writeButton(writer, "kupu-undo", "undo: alt-z", "z"); 503 writeButton(writer, "kupu-redo", "redo: alt-y", "y"); 504 writer.endElement(HTML.SPAN_ELEM); 505 506 writer.startElement(HTML.SPAN_ELEM,null); 507 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-tb-buttongroup", null); 508 writer.writeAttribute(HTML.ID_ATTR, "kupu-source", null); 509 if( ! editor.isAllowEditSource() ){ 510 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 511 } 512 writeButton(writer, "kupu-source", "edit HTML code", null); 513 writer.endElement(HTML.SPAN_ELEM); 514 515 writer.endElement(HTML.SPAN_ELEM); 517 writer.startElement(HTML.SELECT_ELEM,null); 518 writer.writeAttribute(HTML.ID_ATTR, "kupu-ulstyles", null); 519 writeOption(writer, "disc", "list-disc", "●"); 520 writeOption(writer, "square", "list-square", "■"); 521 writeOption(writer, "circle", "list-circle", "○"); 522 writeOption(writer, "none", "list-nobullet", "no bullet"); 523 writer.endElement(HTML.SELECT_ELEM); 524 525 writer.startElement(HTML.SELECT_ELEM,null); 526 writer.writeAttribute(HTML.ID_ATTR, "kupu-olstyles", null); 527 writeOption(writer, "decimal", "list-decimal", "1"); 528 writeOption(writer, "upper-roman", "list-upperroman", "I"); 529 writeOption(writer, "lower-roman", "list-lowerroman", "i"); 530 writeOption(writer, "upper-alpha", "list-upperalpha", "A"); 531 writeOption(writer, "lower-alpha", "list-loweralpha", "a"); 532 writer.endElement(HTML.SELECT_ELEM); 533 534 writer.startElement(HTML.DIV_ELEM,null); 535 writer.writeAttribute(HTML.STYLE_ATTR, "display:block;", null); 536 writer.startElement(HTML.DIV_ELEM,null); 537 writer.writeAttribute(HTML.ID_ATTR, "kupu-librarydrawer", null); 538 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-drawer", null); 539 writer.endElement(HTML.DIV_ELEM); 540 writer.endElement(HTML.DIV_ELEM); 541 542 writer.startElement(HTML.DIV_ELEM,null); 544 writer.writeAttribute(HTML.ID_ATTR, "kupu-linkdrawer", null); 545 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-drawer", null); 546 writer.startElement(HTML.H1_ELEM,null); 547 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 548 writer.writeAttribute("i18n:translate", "", null); 549 writer.write("External Link"); 550 writer.endElement(HTML.H1_ELEM); 551 writer.startElement(HTML.DIV_ELEM,null); 552 writer.writeAttribute(HTML.ID_ATTR, "kupu-linkdrawer-addlink", null); 553 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-panels", null); 554 writer.startElement(HTML.TABLE_ELEM,null); 555 writer.startElement(HTML.TR_ELEM,null); 556 writer.startElement(HTML.TD_ELEM,null); 557 writer.startElement(HTML.DIV_ELEM,null); 558 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-label", null); 559 writer.startElement(HTML.SPAN_ELEM,null); 560 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 561 writer.writeAttribute("i18n:translate", "items-matching-keyword", null); 562 writer.write("Link the highlighted text to this URL"); 563 writer.endElement(HTML.SPAN_ELEM); 564 writer.write(":"); 565 writer.endElement(HTML.DIV_ELEM); 566 writer.startElement(HTML.INPUT_ELEM,null); 567 writer.writeAttribute(HTML.ID_ATTR, "kupu-linkdrawer-input", null); 568 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-st", null); 569 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 570 writer.endElement(HTML.INPUT_ELEM); 571 writer.endElement(HTML.TD_ELEM); 572 writer.startElement(HTML.TD_ELEM,null); 573 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-preview-button", null); 574 writer.startElement(HTML.BUTTON_ELEM,null); 575 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 576 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.preview()", null); 577 writer.write("Preview"); 578 writer.endElement(HTML.BUTTON_ELEM); 579 writer.endElement(HTML.TD_ELEM); 580 writer.endElement(HTML.TR_ELEM); 581 writer.startElement(HTML.TR_ELEM,null); 582 writer.startElement(HTML.TD_ELEM,null); 583 writer.writeAttribute(HTML.COLSPAN_ATTR, "2", null); 584 writer.writeAttribute(HTML.ALIGN_ATTR, "center", null); 585 writer.startElement(HTML.IFRAME_ELEM,null); 586 writer.writeAttribute(HTML.FRAMEBORDER_ATTR, "1", null); 587 writer.writeAttribute(HTML.SCROLLING_ATTR, "auto", null); 588 writer.writeAttribute(HTML.WIDTH_ATTR, "440", null); 589 writer.writeAttribute(HTML.HEIGHT_ATTR, "198", null); 590 writer.writeAttribute(HTML.ID_ATTR, "kupu-linkdrawer-preview", null); 591 writer.writeAttribute(HTML.SRC_ATTR, AddResource.getResourceMappedPath(InputHtmlRenderer.class, "kupublank.html", context), null); 592 writer.endElement(HTML.IFRAME_ELEM); 593 writer.endElement(HTML.TD_ELEM); 594 writer.endElement(HTML.TR_ELEM); 595 writer.endElement(HTML.TABLE_ELEM); 596 writer.startElement(HTML.DIV_ELEM,null); 597 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-dialogbuttons", null); 598 writer.startElement(HTML.BUTTON_ELEM,null); 599 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 600 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.save()", null); 601 writer.write("Ok"); 602 writer.endElement(HTML.BUTTON_ELEM); 603 writer.startElement(HTML.BUTTON_ELEM,null); 604 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 605 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.closeDrawer()", null); 606 writer.write("Cancel"); 607 writer.endElement(HTML.BUTTON_ELEM); 608 writer.endElement(HTML.DIV_ELEM); 609 writer.endElement(HTML.DIV_ELEM); 610 writer.endElement(HTML.DIV_ELEM); 611 612 writer.startElement(HTML.DIV_ELEM,null); 614 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer",null); 615 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-drawer",null); 616 writer.startElement(HTML.H1_ELEM,null); 617 writer.write("Table"); 618 writer.endElement(HTML.H1_ELEM); 619 writer.startElement(HTML.DIV_ELEM,null); 620 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-panels", null); 621 writer.startElement(HTML.TABLE_ELEM,null); 622 writer.writeAttribute(HTML.WIDTH_ATTR, "99%",null); 623 writer.startElement(HTML.TR_ELEM,null); 624 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-panelsrow",null); 625 writer.startElement(HTML.TD_ELEM,null); 626 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-panel",null); 627 writer.startElement(HTML.TABLE_ELEM,null); 628 writer.writeAttribute(HTML.WIDTH_ATTR, "100%",null); 629 writer.startElement(HTML.TBODY_ELEM,null); 630 631 writer.startElement(HTML.TR_ELEM,null); 632 writer.startElement(HTML.TD_ELEM,null); 633 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 634 writer.write("Table Class "); 635 writer.endElement(HTML.TD_ELEM); 636 writer.startElement(HTML.TD_ELEM,null); 637 writer.writeAttribute(HTML.WIDTH_ATTR, "50%", null); 638 writer.startElement(HTML.SELECT_ELEM,null); 639 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-classchooser", null); 640 writer.writeAttribute(HTML.ONCHANGE_ATTR, "drawertool.current_drawer.tool.setTableClass(this.options[this.selectedIndex].value)", null); 641 writeOption(writer, "plain", "Plain"); 642 writeOption(writer, "listing", "Listing"); 643 writeOption(writer, "grid", "Grid"); 644 writeOption(writer, "data", "Data"); 645 writer.endElement(HTML.SELECT_ELEM); 646 writer.endElement(HTML.TD_ELEM); 647 writer.endElement(HTML.TR_ELEM); 648 649 writer.startElement(HTML.TR_ELEM, null); 650 651 writer.startElement(HTML.TD_ELEM, null); 652 writer.writeAttribute(HTML.COLSPAN_ATTR, "2", null); 653 writer.writeAttribute(HTML.CLASS_ATTR, "", null); 655 writer.startElement(HTML.DIV_ELEM, null); 656 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-addtable", null); 657 writer.startElement(HTML.TABLE_ELEM, null); 658 writer.writeAttribute(HTML.WIDTH_ATTR, "100%", null); 659 660 writer.startElement(HTML.TR_ELEM, null); 661 writer.startElement(HTML.TD_ELEM, null); 662 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 663 writer.writeAttribute(HTML.WIDTH_ATTR, "50%", null); 664 writer.write("Rows"); 665 writer.endElement(HTML.TD_ELEM); 666 writer.startElement(HTML.TD_ELEM, null); 667 writer.startElement(HTML.INPUT_ELEM, null); 668 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 669 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-newrows", null); 670 writer.writeAttribute(HTML.VALUE_ATTR, "3", null); 671 writer.endElement(HTML.INPUT_ELEM); 672 writer.endElement(HTML.TD_ELEM); 673 writer.endElement(HTML.TR_ELEM); 674 675 writer.startElement(HTML.TR_ELEM, null); 676 writer.startElement(HTML.TD_ELEM, null); 677 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 678 writer.write("Columns"); 679 writer.endElement(HTML.TD_ELEM); 680 writer.startElement(HTML.TD_ELEM, null); 681 writer.startElement(HTML.INPUT_ELEM, null); 682 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 683 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-newcols", null); 684 writer.writeAttribute(HTML.VALUE_ATTR, "3", null); 685 writer.endElement(HTML.INPUT_ELEM); 686 writer.endElement(HTML.TD_ELEM); 687 writer.endElement(HTML.TR_ELEM); 688 689 writer.startElement(HTML.TR_ELEM, null); 690 writer.startElement(HTML.TD_ELEM, null); 691 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 692 writer.write("Headings"); 693 writer.endElement(HTML.TD_ELEM); 694 writer.startElement(HTML.TD_ELEM, null); 695 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 696 writer.startElement(HTML.INPUT_ELEM, null); 697 writer.writeAttribute(HTML.NAME_ATTR, "kupu-tabledrawer-makeheader", null); 698 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-makeheader", null); 699 writer.writeAttribute(HTML.TYPE_ATTR, "checkbox", null); 700 writer.endElement(HTML.INPUT_ELEM); 701 writer.startElement(HTML.LABEL_ELEM, null); 702 writer.writeAttribute(HTML.FOR_ATTR, "kupu-tabledrawer-makeheader", null); 703 writer.write("Create"); 704 writer.endElement(HTML.LABEL_ELEM); 705 writer.endElement(HTML.TD_ELEM); 706 writer.endElement(HTML.TR_ELEM); 707 708 writer.startElement(HTML.TR_ELEM, null); 709 writer.startElement(HTML.TD_ELEM, null); 710 writer.writeAttribute(HTML.COLSPAN_ATTR, "2", null); 711 writer.writeAttribute(HTML.STYLE_ATTR, "text-align: center", null); 712 writer.startElement(HTML.BUTTON_ELEM, null); 713 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 714 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.createTable()", null); 715 writer.write("Add Table"); 716 writer.endElement(HTML.BUTTON_ELEM); 717 writer.endElement(HTML.TD_ELEM); 718 writer.endElement(HTML.TR_ELEM); 719 720 writer.startElement(HTML.TR_ELEM, null); 721 writer.startElement(HTML.TD_ELEM, null); 722 writer.writeAttribute(HTML.COLSPAN_ATTR, "2", null); 723 writer.writeAttribute(HTML.STYLE_ATTR, "text-align: center", null); 724 writer.startElement(HTML.BUTTON_ELEM, null); 725 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 726 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.tool.fixAllTables()", null); 727 writer.write("Fix All Tables"); 728 writer.endElement(HTML.BUTTON_ELEM); 729 writer.endElement(HTML.TD_ELEM); 730 writer.endElement(HTML.TR_ELEM); 731 732 writer.endElement(HTML.TABLE_ELEM); 733 writer.endElement(HTML.DIV_ELEM); 735 writer.startElement(HTML.DIV_ELEM, null); 736 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-edittable", null); 737 writer.startElement(HTML.TABLE_ELEM, null); 738 writer.writeAttribute(HTML.WIDTH_ATTR, "100%", null); 739 740 writer.startElement(HTML.TR_ELEM,null); 741 writer.startElement(HTML.TD_ELEM,null); 742 writer.writeAttribute(HTML.WIDTH_ATTR, "50%", null); 743 writer.write("Current column alignment"); 744 writer.endElement(HTML.TD_ELEM); 745 writer.startElement(HTML.TD_ELEM,null); 746 writer.startElement(HTML.SELECT_ELEM,null); 747 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-alignchooser", null); 748 writer.writeAttribute(HTML.ONCHANGE_ATTR, "drawertool.current_drawer.tool.setColumnAlign(this.options[this.selectedIndex].value)", null); 749 writeOption(writer, "left", "Left"); 750 writeOption(writer, "center", "Center"); 751 writeOption(writer, "right", "Right"); 752 writer.endElement(HTML.SELECT_ELEM); 753 writer.endElement(HTML.TD_ELEM); 754 writer.endElement(HTML.TR_ELEM); 755 756 writer.startElement(HTML.TR_ELEM,null); 757 writer.startElement(HTML.TD_ELEM,null); 758 writer.write("Column"); 759 writer.endElement(HTML.TD_ELEM); 760 writer.startElement(HTML.TD_ELEM,null); 761 writer.startElement(HTML.BUTTON_ELEM, null); 762 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 763 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-addcolumn-button", null); 764 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.tool.addTableColumn()", null); 765 writer.write("Add"); 766 writer.endElement(HTML.BUTTON_ELEM); 767 writer.startElement(HTML.BUTTON_ELEM, null); 768 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 769 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-delcolumn-button", null); 770 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.tool.delTableColumn()", null); 771 writer.write("Remove"); 772 writer.endElement(HTML.BUTTON_ELEM); 773 writer.endElement(HTML.TD_ELEM); 774 writer.endElement(HTML.TR_ELEM); 775 776 writer.startElement(HTML.TR_ELEM,null); 777 writer.startElement(HTML.TD_ELEM,null); 778 writer.write("Row"); 779 writer.endElement(HTML.TD_ELEM); 780 writer.startElement(HTML.TD_ELEM,null); 781 writer.startElement(HTML.BUTTON_ELEM, null); 782 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 783 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-addrow-button", null); 784 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.addTableRow()", null); 785 writer.write("Add"); 786 writer.endElement(HTML.BUTTON_ELEM); 787 writer.startElement(HTML.BUTTON_ELEM, null); 788 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 789 writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-delrow-button", null); 790 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.delTableRow()", null); 791 writer.write("Remove"); 792 writer.endElement(HTML.BUTTON_ELEM); 793 writer.endElement(HTML.TD_ELEM); 794 writer.endElement(HTML.TR_ELEM); 795 796 writer.startElement(HTML.TR_ELEM,null); 797 writer.startElement(HTML.TD_ELEM,null); 798 writer.write("Fix Table"); 799 writer.endElement(HTML.TD_ELEM); 800 writer.startElement(HTML.TD_ELEM,null); 801 writer.startElement(HTML.BUTTON_ELEM, null); 802 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 803 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.current_drawer.tool.fixTable()", null); 805 writer.write("Fix"); 806 writer.endElement(HTML.BUTTON_ELEM); 807 writer.endElement(HTML.TD_ELEM); 808 writer.endElement(HTML.TR_ELEM); 809 810 writer.endElement(HTML.TABLE_ELEM); 811 writer.endElement(HTML.DIV_ELEM); 813 writer.endElement(HTML.TD_ELEM); 814 writer.endElement(HTML.TR_ELEM); 815 816 writer.endElement(HTML.TBODY_ELEM); 817 writer.endElement(HTML.TABLE_ELEM); 818 writer.endElement(HTML.TD_ELEM); 819 writer.endElement(HTML.TR_ELEM); 820 writer.endElement(HTML.TABLE_ELEM); 821 writer.startElement(HTML.DIV_ELEM,null); 822 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-dialogbuttons", null); 823 writer.startElement(HTML.BUTTON_ELEM,null); 824 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 825 writer.writeAttribute(HTML.ONCLICK_ATTR, "drawertool.closeDrawer()", null); 826 writer.write("Close"); 827 writer.endElement(HTML.BUTTON_ELEM); 828 writer.endElement(HTML.DIV_ELEM); 829 writer.endElement(HTML.DIV_ELEM); 830 writer.endElement(HTML.DIV_ELEM); 832 writer.endElement(HTML.DIV_ELEM); 834 writer.startElement(HTML.DIV_ELEM, null); 838 writer.writeAttribute("xmlns", "", null); 839 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolboxes", null); 840 if( ! editor.isShowAnyToolBox() ){ 841 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 842 } 843 844 writer.startElement(HTML.DIV_ELEM, null); 846 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 847 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-properties", null); 848 if( ! editor.isShowPropertiesToolBox() ){ 849 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 850 } 851 writer.startElement(HTML.H1_ELEM, null); 852 writer.write("Properties"); 853 writer.endElement(HTML.H1_ELEM); 854 writer.startElement(HTML.DIV_ELEM, null); 855 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 856 writer.write("Title:"); 857 writer.endElement(HTML.DIV_ELEM); 858 writer.startElement(HTML.INPUT_ELEM, null); 859 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); writer.writeAttribute(HTML.ID_ATTR, "kupu-properties-title", null); 861 writer.endElement(HTML.INPUT_ELEM); 862 writer.startElement(HTML.DIV_ELEM, null); 863 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 864 writer.write("Description:"); 865 writer.endElement(HTML.DIV_ELEM); 866 writer.startElement(HTML.TEXTAREA_ELEM, null); 867 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 868 writer.writeAttribute(HTML.ID_ATTR, "kupu-properties-description", null); 869 writer.endElement(HTML.TEXTAREA_ELEM); 870 writer.endElement(HTML.DIV_ELEM); 871 872 writer.startElement(HTML.DIV_ELEM, null); 874 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 875 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-links", null); 876 if( ! editor.isShowLinksToolBox() ){ 877 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 878 } 879 writer.startElement(HTML.H1_ELEM, null); 880 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 881 writer.writeAttribute("i18n:translate", "links", null); 882 writer.write("Links"); 883 writer.endElement(HTML.H1_ELEM); 884 885 writer.startElement(HTML.DIV_ELEM, null); 886 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-addlink", null); 887 888 writer.startElement(HTML.DIV_ELEM, null); 889 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 890 writer.startElement(HTML.SPAN_ELEM, null); 891 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 892 writer.writeAttribute("i18n:translate", "items-matching-keyword", null); 893 writer.write("Link the highlighted text to this URL:"); 894 writer.endElement(HTML.SPAN_ELEM); 895 writer.endElement(HTML.DIV_ELEM); 896 897 writer.startElement(HTML.INPUT_ELEM, null); 898 writer.writeAttribute(HTML.ID_ATTR, "kupu-link-input", null); 899 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 900 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 901 writer.endElement(HTML.INPUT_ELEM); 902 903 writer.startElement(HTML.DIV_ELEM, null); 904 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-buttons", null); 905 writer.startElement(HTML.BUTTON_ELEM, null); 906 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 907 writer.writeAttribute(HTML.ID_ATTR, "kupu-link-button", null); 908 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-action", null); 909 writer.write("Make Link"); 910 writer.endElement(HTML.BUTTON_ELEM); 911 writer.endElement(HTML.DIV_ELEM); 912 913 writer.endElement(HTML.DIV_ELEM); 914 writer.endElement(HTML.DIV_ELEM); 915 916 writer.startElement(HTML.DIV_ELEM, null); 918 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 919 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-images", null); 920 if( ! editor.isShowImagesToolBox() ){ 921 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 922 } 923 writer.startElement(HTML.H1_ELEM, null); 924 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 925 writer.writeAttribute("i18n:translate", "images", null); 926 writer.write("Images"); 927 writer.endElement(HTML.H1_ELEM); 928 929 writer.startElement(HTML.DIV_ELEM, null); 930 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 931 writer.startElement(HTML.SPAN_ELEM, null); 932 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 933 writer.writeAttribute("i18n:translate", "", null); 934 writer.write("Insert image at the following URL:"); 935 writer.endElement(HTML.SPAN_ELEM); 936 writer.endElement(HTML.DIV_ELEM); 937 938 writer.startElement(HTML.INPUT_ELEM, null); 939 writer.writeAttribute(HTML.ID_ATTR, "kupu-image-input", null); 940 writer.writeAttribute(HTML.VALUE_ATTR, "kupuimages/kupu_icon.gif", null); 941 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 942 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 943 writer.endElement(HTML.INPUT_ELEM); 944 945 writer.startElement(HTML.SPAN_ELEM, null); 946 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 947 writer.writeAttribute("i18n:translate", "", null); 948 writer.write("Image float:"); 949 writer.endElement(HTML.SPAN_ELEM); 950 951 writer.startElement(HTML.SELECT_ELEM, null); 952 writer.writeAttribute(HTML.ID_ATTR, "kupu-image-float-select", null); 953 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 954 writeOption(writer, "none", "No Float"); 955 writeOption(writer, "left", "Left"); 956 writeOption(writer, "right", "Right"); 957 writer.endElement(HTML.SELECT_ELEM); 958 959 writer.startElement(HTML.DIV_ELEM, null); 960 writer.writeAttribute(HTML.CLASS_ATTR, "text-align: center", null); 961 writer.startElement(HTML.BUTTON_ELEM, null); 962 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 963 writer.writeAttribute(HTML.ID_ATTR, "kupu-image-addbutton", null); 964 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-action", null); 965 writer.write("Insert Image"); 966 writer.endElement(HTML.BUTTON_ELEM); 967 writer.endElement(HTML.DIV_ELEM); 968 969 writer.endElement(HTML.DIV_ELEM); 970 971 writer.startElement(HTML.DIV_ELEM, null); 973 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 974 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-tables", null); 975 if( ! editor.isShowTablesToolBox() ){ 976 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 977 } 978 writer.startElement(HTML.H1_ELEM, null); 979 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 980 writer.writeAttribute("i18n:translate", "table-inspector", null); 981 writer.write("Tables"); 982 writer.endElement(HTML.H1_ELEM); 983 984 writer.startElement(HTML.DIV_ELEM, null); 985 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 986 writer.write("Table Class:"); 987 writer.startElement(HTML.SELECT_ELEM, null); 988 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 989 writer.writeAttribute(HTML.ID_ATTR, "kupu-table-classchooser", null); 990 writer.endElement(HTML.SELECT_ELEM); 991 writer.endElement(HTML.DIV_ELEM); 992 993 writer.startElement(HTML.DIV_ELEM, null); 995 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-addtable", null); 996 writer.startElement(HTML.DIV_ELEM, null); 997 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 998 writer.write("Rows:"); 999 writer.endElement(HTML.DIV_ELEM); 1000 writer.startElement(HTML.INPUT_ELEM, null); 1001 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 1002 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 1003 writer.writeAttribute(HTML.ID_ATTR, "kupu-table-newrows", null); 1004 writer.endElement(HTML.INPUT_ELEM); 1005 1006 writer.startElement(HTML.DIV_ELEM, null); 1007 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 1008 writer.write("Columns:"); 1009 writer.endElement(HTML.DIV_ELEM); 1010 writer.startElement(HTML.INPUT_ELEM, null); 1011 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 1012 writer.writeAttribute(HTML.TYPE_ATTR, "text", null); 1013 writer.writeAttribute(HTML.ID_ATTR, "kupu-table-newcols", null); 1014 writer.endElement(HTML.INPUT_ELEM); 1015 1016 writer.startElement(HTML.DIV_ELEM, null); 1017 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 1018 writer.write("Headings:"); 1019 writer.startElement(HTML.INPUT_ELEM, null); 1020 writer.writeAttribute(HTML.NAME_ATTR, "kupu-table-makeheader", null); 1021 writer.writeAttribute(HTML.ID_ATTR, "kupu-table-makeheader", null); 1022 writer.writeAttribute(HTML.TYPE_ATTR, "checkbox", null); 1023 writer.endElement(HTML.INPUT_ELEM); 1024 writer.startElement(HTML.LABEL_ELEM, null); 1025 writer.writeAttribute(HTML.FOR_ATTR, "kupu-table-makeheader", null); 1026 writer.write("Create"); 1027 writer.endElement(HTML.LABEL_ELEM); 1028 writer.endElement(HTML.DIV_ELEM); 1029 1030 writer.startElement(HTML.DIV_ELEM, null); 1031 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-buttons", null); 1032 writeButton(writer, "kupu-table-fixall-button", "Fix Table"); 1033 writeButton(writer, "kupu-table-addtable-button", "Add Table"); 1034 writer.endElement(HTML.DIV_ELEM); 1035 writer.endElement(HTML.DIV_ELEM); 1037 writer.startElement(HTML.DIV_ELEM, null); 1039 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-edittable", null); 1040 1041 writer.startElement(HTML.DIV_ELEM, null); 1042 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 1043 writer.write("Col Align:"); 1044 writer.startElement(HTML.SELECT_ELEM, null); 1045 writer.writeAttribute(HTML.CLASS_ATTR, "wide", null); 1046 writer.writeAttribute(HTML.ID_ATTR, "kupu-table-alignchooser", null); 1047 writeOption(writer, "left", "Left"); 1048 writeOption(writer, "center", "Center"); 1049 writeOption(writer, "right", "Right"); 1050 writer.endElement(HTML.SELECT_ELEM); 1051 writer.endElement(HTML.DIV_ELEM); 1052 1053 writer.startElement(HTML.DIV_ELEM,null); 1054 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-buttons", null); 1055 writer.write("<br/>"); 1056 writeButton(writer, "kupu-table-addcolumn-button", "Add Column"); 1057 writeButton(writer, "kupu-table-delcolumn-button", "Remove Column"); 1058 writer.write("<br/>"); 1059 writeButton(writer, "kupu-table-addrow-button", "Add Row"); 1060 writeButton(writer, "kupu-table-delrow-button", "Remove Row"); 1061 writeButton(writer, "kupu-table-fix-button", "Fix"); 1062 writer.endElement(HTML.DIV_ELEM); 1063 1064 writer.endElement(HTML.DIV_ELEM); 1066 writer.endElement(HTML.DIV_ELEM); 1067 1068 writer.startElement(HTML.DIV_ELEM, null); 1070 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 1071 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-cleanupexpressions", null); 1072 if( ! editor.isShowCleanupExpressionsToolBox() ){ 1073 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 1074 } 1075 writer.startElement(HTML.H1_ELEM, null); 1076 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 1077 writer.writeAttribute("i18n:translate", "", null); 1078 writer.write("Cleanup expressions"); 1079 writer.endElement(HTML.H1_ELEM); 1080 writer.startElement(HTML.DIV_ELEM, null); 1081 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 1082 writer.startElement(HTML.SPAN_ELEM,null); 1083 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 1084 writer.writeAttribute("i18n:translate", "", null); 1085 writer.write("Select a cleanup action:"); 1086 writer.endElement(HTML.SPAN_ELEM); 1087 writer.endElement(HTML.DIV_ELEM); 1088 writer.startElement(HTML.SELECT_ELEM,null); 1089 writer.writeAttribute(HTML.ID_ATTR, "kupucleanupexpressionselect", null); 1090 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-st", null); 1091 writer.endElement(HTML.SELECT_ELEM); 1092 writer.startElement(HTML.DIV_ELEM,null); 1093 writer.writeAttribute(HTML.STYLE_ATTR,"text-align: center",null); 1094 writer.startElement(HTML.BUTTON_ELEM,null); 1095 writer.writeAttribute(HTML.TYPE_ATTR,"button",null); 1096 writer.writeAttribute(HTML.ID_ATTR,"kupucleanupexpressionbutton",null); 1097 writer.writeAttribute(HTML.CLASS_ATTR,"kupu-toolbox-action",null); 1098 writer.write("Perform action"); 1099 writer.endElement(HTML.BUTTON_ELEM); 1100 writer.endElement(HTML.DIV_ELEM); 1101 writer.endElement(HTML.DIV_ELEM); 1102 1103 writer.startElement(HTML.DIV_ELEM, null); 1105 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox", null); 1106 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-debug", null); 1107 if( ! editor.isShowDebugToolBox() ){ 1108 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 1109 } 1110 writer.startElement(HTML.H1_ELEM, null); 1111 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 1112 writer.writeAttribute("i18n:translate", "debug-log", null); 1113 writer.write("Debug Log"); 1114 writer.endElement(HTML.H1_ELEM); 1115 writer.startElement(HTML.DIV_ELEM, null); 1116 writer.writeAttribute(HTML.ID_ATTR, "kupu-toolbox-debuglog", null); 1117 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-toolbox-label", null); 1118 writer.endElement(HTML.DIV_ELEM); 1119 writer.endElement(HTML.DIV_ELEM); 1120 1121 writer.endElement(HTML.DIV_ELEM); 1123 writer.startElement(HTML.TABLE_ELEM, null); 1125 writer.writeAttribute(HTML.ID_ATTR, "kupu-colorchooser", null); 1126 writer.writeAttribute(HTML.CELLPADDING_ATTR, "0", null); 1127 writer.writeAttribute(HTML.CELLSPACING_ATTR, "0", null); 1128 writer.writeAttribute(HTML.STYLE_ATTR, "position: fixed; border-style: solid; border-color: black; border-width: 1px;", null); 1129 writer.endElement(HTML.TABLE_ELEM); 1130 1131 writer.startElement(HTML.DIV_ELEM, null); 1133 if( !editor.isShowAnyToolBox() ){ 1134 writer.writeAttribute(HTML.STYLE_ATTR, "margin-right: 0.3em", null); 1135 } 1136 if( editor.getStyle()!=null ){ 1137 AddResource.addInlineStyleToHeader( 1139 "#kupu-editor{height: inherit;} "+ 1140 "div.kupu-fulleditor{"+editor.getStyle()+"}", 1141 context); 1142 } 1143 writer.writeAttribute(HTML.CLASS_ATTR, 1144 "kupu-editorframe"+(editor.getStyleClass()==null ? "" : " "+editor.getStyleClass()), null); 1145 writer.startElement(HTML.IFRAME_ELEM, null); 1146 writer.writeAttribute(HTML.ID_ATTR, "kupu-editor", null); 1147 writer.writeAttribute(HTML.FRAMEBORDER_ATTR, "0", null); 1148 writer.writeAttribute(HTML.SCROLLING_ATTR, "auto", null); 1149 writer.writeAttribute(HTML.SRC_ATTR, "about:blank", null); 1151 writer.endElement(HTML.IFRAME_ELEM); 1152 writer.startElement(HTML.TEXTAREA_ELEM, null); 1153 writer.writeAttribute(HTML.CLASS_ATTR, "kupu-editor-textarea", null); 1154 writer.writeAttribute(HTML.ID_ATTR, "kupu-editor-textarea", null); 1155 writer.endElement(HTML.TEXTAREA_ELEM); 1157 writer.endElement(HTML.DIV_ELEM); 1158 1159 writer.endElement(HTML.DIV_ELEM); 1161 String text = editor.getValueAsHtmlDocument( context ); 1162 String encodedText = text == null ? "" : JavascriptUtils.encodeString( text ); 1163 1164 AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "myFacesUtils.js", context); 1165 1166 String resourceBaseURL = AddResource.getResourceMappedPath(InputHtmlRenderer.class, "", context); 1167 1168 writer.startElement(HTML.SCRIPT_ELEM, null); 1169 writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null); 1170 writer.write("myFacesKupuSet(" + 1171 "\""+encodedText+"\"," + 1172 "\""+clientId+"\"," + 1173 "\""+formId+"\"," + 1174 "\""+resourceBaseURL+"\"" + 1175 ");"); 1176 writer.endElement(HTML.SCRIPT_ELEM); 1177 } 1178 1179 static private void writeTag(ResponseWriter writer, String tagName, String tagBody) throws IOException { 1180 writer.startElement(tagName, null); 1181 writer.writeText(tagBody, null); 1182 writer.endElement(tagName); 1183 } 1184 1185 static private void writeButton(ResponseWriter writer, String classAttr, String title, String accessKey) throws IOException { 1186 writeButton(writer, classAttr, title, accessKey, classAttr+"-button"); 1187 } 1188 1189 static private void writeButton(ResponseWriter writer, String classAttr, String title, String accessKey, String id) throws IOException { 1190 writeButton(writer, classAttr, title, accessKey, id, true); 1191 } 1192 1193 static private void writeButton(ResponseWriter writer, String classAttr, String title, String accessKey, String id, boolean display) throws IOException { 1194 writer.startElement(HTML.BUTTON_ELEM,null); 1195 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 1196 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 1197 writer.writeAttribute(HTML.CLASS_ATTR, classAttr, null); 1198 writer.writeAttribute(HTML.ID_ATTR, id, null); 1199 writer.writeAttribute(HTML.TITLE_ATTR, title, null); 1200 writer.writeAttribute("i18n:attributes", "title", null); 1201 if( ! display ) 1202 writer.writeAttribute(HTML.STYLE_ATTR, "display: none", null); 1203 if( accessKey != null ){ 1204 writer.writeAttribute(HTML.ACCESSKEY_ATTR, accessKey, null); 1205 } 1206 writer.write(" "); 1207 writer.endElement(HTML.BUTTON_ELEM); 1208 } 1209 1210 static private void writeButton(ResponseWriter writer, String id, String text) throws IOException { 1211 writer.startElement(HTML.BUTTON_ELEM, null); 1212 writer.writeAttribute(HTML.TYPE_ATTR, "button", null); 1213 writer.writeAttribute(HTML.ID_ATTR, id, null); 1214 writer.write(text); 1215 writer.endElement(HTML.BUTTON_ELEM); 1216 } 1217 1218 static private void writeOption(ResponseWriter writer, String value, String body) throws IOException { 1219 writer.startElement(HTML.OPTION_ELEM,null); 1220 writer.writeAttribute(HTML.VALUE_ATTR, value, null); 1221 writer.write(body); 1222 writer.endElement(HTML.OPTION_ELEM); 1223 } 1224 1225 static private void writeOption(ResponseWriter writer, String value, String translate, String body) throws IOException { 1226 writer.startElement(HTML.OPTION_ELEM,null); 1227 writer.writeAttribute("xmlns:i18n", "http://xml.zope.org/namespaces/i18n", null); 1228 writer.writeAttribute(HTML.VALUE_ATTR, value, null); 1229 writer.writeAttribute("i18n:translate", translate, null); 1230 writer.write(body); 1231 writer.endElement(HTML.OPTION_ELEM); 1232 } 1233 1234 public void decode(FacesContext facesContext, UIComponent uiComponent) { 1235 RendererUtils.checkParamValidity(facesContext, uiComponent, InputHtml.class); 1236 InputHtml editor = (InputHtml) uiComponent; 1237 1238 Map paramMap = facesContext.getExternalContext() 1239 .getRequestParameterMap(); 1240 String clientId = uiComponent.getClientId(facesContext); 1241 if (paramMap.containsKey(clientId)) { 1242 String submitedText = (String )paramMap.get(clientId); 1244 String htmlText = ! useFallback(editor) ? 1245 submitedText : 1246 HTMLEncoder.encode(submitedText, true, true); 1247 ((EditableValueHolder) uiComponent).setSubmittedValue( htmlText ); 1248 } else { 1249 if(!HtmlRendererUtils.isDisabledOrReadOnly(editor)) { 1252 ((EditableValueHolder) uiComponent).setSubmittedValue( RendererUtils.EMPTY_STRING ); 1253 } 1254 } 1255 } 1256 1257 public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException { 1258 RendererUtils.checkParamValidity(facesContext, uiComponent, InputHtml.class); 1259 InputHtml editor = (InputHtml) uiComponent; 1260 String submittedDocument = (String ) RendererUtils.getConvertedUIOutputValue(facesContext, editor, submittedValue); 1261 return editor.getValueFromDocument( submittedDocument ); 1262 } 1263} | Popular Tags |