KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > inputHtml > InputHtmlRenderer


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.custom.inputHtml;
17
18 import java.io.IOException JavaDoc;
19 import java.util.Map JavaDoc;
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 /**
38  * @author Sylvain Vieujot (latest modification by $Author: svieujot $)
39  * @version $Revision: 1.1 $ $Date: 2005/03/26 20:31:37 $
40  * $Log: InputHtmlRenderer.java,v $
41  * Revision 1.1 2005/03/26 20:31:37 svieujot
42  * Rename x:htmlEditor to x:inputHtml.
43  *
44  * Revision 1.26 2005/03/15 21:24:41 svieujot
45  * Style handling improvements.
46  *
47  * Revision 1.25 2005/03/15 05:24:03 svieujot
48  * Add a fallback textarea mode to the htmlEditor.
49  *
50  * Revision 1.24 2005/03/09 04:13:52 svieujot
51  * htmlEditor : remove unused scripts
52  *
53  * Revision 1.23 2005/03/09 04:07:22 svieujot
54  * htmlEditor : Kupu 1.2rc2 update
55  *
56  * Revision 1.22 2005/02/08 14:24:45 svieujot
57  * Temporarily hide unimplemented functionalities (internal images library & internal links library).
58  *
59  * Revision 1.21 2005/02/07 01:40:42 svieujot
60  * style attribute fix.
61  *
62  * Revision 1.20 2005/02/06 19:45:32 svieujot
63  * Add allowExternalLinks attribute.
64  *
65  * Revision 1.19 2005/02/05 23:07:45 svieujot
66  * x:htmlEditor Add full page mode (zoom) & bugfixes
67  *
68  * Revision 1.18 2005/02/05 18:51:21 svieujot
69  * x:htmlEditor : Upgrade to Kupu 1.2rc1, remove formularMode (too experimental), bugfixes.
70  *
71  * Revision 1.17 2005/01/02 20:39:16 svieujot
72  * HtmlEditor can now process HTML documents and HTML fragments.
73  *
74  * Revision 1.16 2004/12/27 04:11:11 mmarinschek
75  * Data Table stores the state of facets of children; script tag is rendered with type attribute instead of language attribute, popup works better as a column in a data table
76  *
77  * Revision 1.15 2004/12/10 02:16:26 svieujot
78  * Start implementing UserRoleAware.
79  *
80  * Revision 1.14 2004/12/09 05:19:12 svieujot
81  * Bugfix for submitted values that were not taken care of.
82  *
83  * Revision 1.13 2004/12/08 04:36:27 svieujot
84  * Cancel last *source attributes, and make style and styleClass more modular.
85  *
86  * Revision 1.12 2004/12/08 04:13:56 svieujot
87  * Add styleSource and styleClassSource for the htmlEditor source window.
88  *
89  * Revision 1.11 2004/12/06 04:26:07 svieujot
90  * Make HtmlEditor UserRoleAware.
91  *
92  * Revision 1.10 2004/12/06 01:03:42 svieujot
93  * Bugfix : getter now use boolean instead of Boolean, and setters created.
94  *
95  * Revision 1.9 2004/12/04 03:50:44 svieujot
96  * Remove bug for IE
97  *
98  * Revision 1.8 2004/12/04 03:26:28 svieujot
99  * Various bug fixes
100  *
101  * Revision 1.7 2004/12/04 02:09:42 svieujot
102  * Several small fixes.
103  *
104  * Revision 1.6 2004/12/04 00:40:25 svieujot
105  * htmlEditor : add style and styleClass attributes.
106  *
107  * Revision 1.5 2004/12/04 00:20:00 svieujot
108  * htmlEditor : Add a formular mode, and more sensible defaults.
109  *
110  * Revision 1.4 2004/12/03 21:59:09 svieujot
111  * Initial set of htmlEditor attributes.
112  *
113  * Revision 1.3 2004/12/03 12:55:30 svieujot
114  * Get ride of the save button / process.
115  *
116  * Revision 1.2 2004/12/03 08:31:28 manolito
117  * writer.append copy'n'paste error?
118  *
119  * Revision 1.1 2004/12/02 22:28:30 svieujot
120  * Add an x:htmlEditor based on the Kupu library.
121  */

122 public class InputHtmlRenderer extends HtmlRenderer {
123     // TODO : Finish Disabled mode.
124
// TODO : Automatic Fallback for non kupu capable browsers (Safari, smartphones, non javascript, ...).
125
// TODO : Make Image & Link Library work.
126

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         // TODO : Handle fallback="auto"
136
return editor.getFallback().equals("true");
137     }
138     
139     public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException JavaDoc {
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 JavaDoc {
149         String JavaDoc clientId = editor.getClientId(context);
150         // Use only a textarea
151
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 JavaDoc text = RendererUtils.getStringValue(context, editor);
166         writer.write( htmlToPlainText( text ) );
167
168         writer.endElement(HTML.TEXTAREA_ELEM);
169     }
170     
171     private static String JavaDoc htmlToPlainText(String JavaDoc html){
172         return getHtmlBody( html ).replaceAll("<br.*>","\n");
173     }
174     
175     private static String JavaDoc getHtmlBody(String JavaDoc html){
176         String JavaDoc 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; // not found.
183

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 JavaDoc {
209         String JavaDoc clientId = editor.getClientId(context);
210         String JavaDoc 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&#x2018;");
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("&#x2019;");
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                     // TODO : Make this work (reference available images, ...).
301
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             //
315
// Toolbar
316
//
317
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("&#xA0;");
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("&#xA0;");
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); // TODO : Enable
487
writeButton(writer, "kupu-inthyperlink", "link", null, "kupu-linklibdrawer-button", false); // TODO : Enable
488
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); // kupu-tb-buttons
516

517                 writer.startElement(HTML.SELECT_ELEM,null);
518                 writer.writeAttribute(HTML.ID_ATTR, "kupu-ulstyles", null);
519                     writeOption(writer, "disc", "list-disc", "&#x25CF;");
520                     writeOption(writer, "square", "list-square", "&#x25A0;");
521                     writeOption(writer, "circle", "list-circle", "&#x25CB;");
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                 // External Link drawer
543
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                 // Table drawer
613
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); // ?
654

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); // kupu-tabledrawer-addtable
734

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                                                                     // BUG writer.writeAttribute(HTML.ID_ATTR, "kupu-tabledrawer-addrow-button", null);
804
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); // kupu-tabledrawer-edittable
812

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); // kupu-tabledrawer
831

832             writer.endElement(HTML.DIV_ELEM); // toolbar
833

834             //
835
// Tool Boxes
836
//
837
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                 // Properties tool box
845
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); // TODO : Check class name. Should be something like kupu-wide in next version.
860
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                 // Links tool box
873
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                 // Images tool box
917
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                 // Tables tool box
972
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                     // Add table
994
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); // Add table
1036

1037                    // Edit table
1038
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); // Edit table
1065

1066                writer.endElement(HTML.DIV_ELEM);
1067                
1068                // Cleanup expressions tool box
1069
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                // Debug tool box
1104
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); // kupu-toolboxes
1122

1123            // Color Chooser
1124
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            // Edit space
1132
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                // Convert the style into an style declaration so that it doesn't preempt the Zoom works as it's relying on changing the class
1138
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); // Text loaded afterward by javascript
1150

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.writeAttribute(HTML.STYLE_ATTR, "display: none", null);
1156
writer.endElement(HTML.TEXTAREA_ELEM);
1157            writer.endElement(HTML.DIV_ELEM);
1158            
1159        writer.endElement(HTML.DIV_ELEM); // kupu-fulleditor
1160

1161        String JavaDoc text = editor.getValueAsHtmlDocument( context );
1162        String JavaDoc encodedText = text == null ? "" : JavascriptUtils.encodeString( text );
1163        
1164        AddResource.addJavaScriptToHeader(InputHtmlRenderer.class, "myFacesUtils.js", context);
1165        
1166        String JavaDoc 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 JavaDoc tagName, String JavaDoc tagBody) throws IOException JavaDoc{
1180        writer.startElement(tagName, null);
1181        writer.writeText(tagBody, null);
1182        writer.endElement(tagName);
1183    }
1184    
1185    static private void writeButton(ResponseWriter writer, String JavaDoc classAttr, String JavaDoc title, String JavaDoc accessKey) throws IOException JavaDoc{
1186        writeButton(writer, classAttr, title, accessKey, classAttr+"-button");
1187    }
1188    
1189    static private void writeButton(ResponseWriter writer, String JavaDoc classAttr, String JavaDoc title, String JavaDoc accessKey, String JavaDoc id) throws IOException JavaDoc{
1190        writeButton(writer, classAttr, title, accessKey, id, true);
1191    }
1192
1193    static private void writeButton(ResponseWriter writer, String JavaDoc classAttr, String JavaDoc title, String JavaDoc accessKey, String JavaDoc id, boolean display) throws IOException JavaDoc{
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("&#xA0;");
1207        writer.endElement(HTML.BUTTON_ELEM);
1208    }
1209    
1210    static private void writeButton(ResponseWriter writer, String JavaDoc id, String JavaDoc text) throws IOException JavaDoc{
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 JavaDoc value, String JavaDoc body) throws IOException JavaDoc{
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 JavaDoc value, String JavaDoc translate, String JavaDoc body) throws IOException JavaDoc{
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 JavaDoc paramMap = facesContext.getExternalContext()
1239                .getRequestParameterMap();
1240        String JavaDoc clientId = uiComponent.getClientId(facesContext);
1241        if (paramMap.containsKey(clientId)) {
1242            //request parameter found, set submittedValue
1243
String JavaDoc submitedText = (String JavaDoc)paramMap.get(clientId);
1244            String JavaDoc htmlText = ! useFallback(editor) ?
1245                            submitedText :
1246                            HTMLEncoder.encode(submitedText, true, true);
1247            ((EditableValueHolder) uiComponent).setSubmittedValue( htmlText );
1248        } else {
1249            //request parameter not found, nothing to decode - set submitted value to empty
1250
//if the component has not been disabled
1251
if(!HtmlRendererUtils.isDisabledOrReadOnly(editor)) {
1252                ((EditableValueHolder) uiComponent).setSubmittedValue( RendererUtils.EMPTY_STRING );
1253            }
1254        }
1255    }
1256    
1257    public Object JavaDoc getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object JavaDoc submittedValue) throws ConverterException {
1258        RendererUtils.checkParamValidity(facesContext, uiComponent, InputHtml.class);
1259        InputHtml editor = (InputHtml) uiComponent;
1260        String JavaDoc submittedDocument = (String JavaDoc) RendererUtils.getConvertedUIOutputValue(facesContext, editor, submittedValue);
1261        return editor.getValueFromDocument( submittedDocument );
1262    }
1263}
Popular Tags