KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > ui > impl > RichTextAreaImpl


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.user.client.ui.impl;
17
18 import com.google.gwt.user.client.DOM;
19 import com.google.gwt.user.client.Element;
20 import com.google.gwt.user.client.Event;
21 import com.google.gwt.user.client.ui.RichTextArea;
22
23 /**
24  * Base class for RichText platform implementations. The default version
25  * simply creates a text area with no rich text support.
26  */

27 public class RichTextAreaImpl {
28
29   protected Element elem;
30
31   public RichTextAreaImpl() {
32     elem = createElement();
33   }
34
35   public Element getElement() {
36     return elem;
37   }
38
39   public String JavaDoc getHTML() {
40     return DOM.getElementProperty(elem, "value");
41   }
42
43   public String JavaDoc getText() {
44     return DOM.getElementProperty(elem, "value");
45   }
46
47   public void hookEvents(RichTextArea owner) {
48     DOM.setEventListener(elem, owner);
49   }
50
51   public void initElement() {
52     DOM.sinkEvents(elem, Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONCHANGE
53         | Event.ONCLICK);
54   }
55
56   public boolean isBasicEditingSupported() {
57     return false;
58   }
59
60   public boolean isExtendedEditingSupported() {
61     return false;
62   }
63
64   public native void setFocus(boolean focused) /*-{
65     if (focused) {
66       this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.focus();
67     } else {
68       this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.blur();
69     }
70   }-*/
;
71
72   public void setHTML(String JavaDoc html) {
73     DOM.setElementProperty(elem, "value", html);
74   }
75
76   public void setText(String JavaDoc text) {
77     DOM.setElementProperty(elem, "value", text);
78   }
79
80   public void unhookEvents() {
81     DOM.setEventListener(elem, null);
82   }
83
84   protected Element createElement() {
85     return DOM.createTextArea();
86   }
87 }
88
Popular Tags