com.google.gwt.user.client.ui.impl.RichTextAreaImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client Show documentation
Show all versions of vaadin-client Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/*
* Copyright 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.user.client.ui.impl;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.HasInitializeHandlers;
import com.google.gwt.event.logical.shared.InitializeEvent;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.RichTextArea;
/**
* Base class for RichText platform implementations. The default version simply
* creates a text area with no rich text support.
*
* This is not currently used by any user-agent, but will provide a
* <textarea> fallback in the event a future browser fails to implement
* rich text editing.
*/
public class RichTextAreaImpl {
protected Element elem;
protected HasInitializeHandlers owner;
public RichTextAreaImpl() {
elem = createElement();
}
public Element getElement() {
return elem;
}
public String getHTML() {
return elem.getPropertyString("value");
}
public String getText() {
return elem.getPropertyString("value");
}
public void initElement() {
onElementInitialized();
}
public boolean isEnabled() {
return !elem.getPropertyBoolean("disabled");
}
public void setEnabled(boolean enabled) {
elem.setPropertyBoolean("disabled", !enabled);
}
public native void setFocus(boolean focused) /*-{
if (focused) {
[email protected]::elem.focus();
} else {
[email protected]::elem.blur();
}
}-*/;
public void setHTML(String html) {
elem.setPropertyString("value", html);
}
public void setOwner(HasInitializeHandlers owner) {
this.owner = owner;
}
public void setText(String text) {
elem.setPropertyString("value", text);
}
/**
* @deprecated as of GWT 2.1, use {@link #setOwner(HasInitializeHandlers)}
* instead
*/
@Deprecated
public void setWidget(RichTextArea richTextWidget) {
setOwner(richTextWidget);
}
public void uninitElement() {
}
protected Element createElement() {
return DOM.createTextArea();
}
protected void hookEvents() {
DOM.sinkEvents(elem, Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONCHANGE
| Event.ONCLICK | Event.FOCUSEVENTS);
}
protected void onElementInitialized() {
hookEvents();
if (owner != null) {
InitializeEvent.fire(owner);
}
}
}