com.smartgwt.client.widgets
Class BaseWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.smartgwt.client.widgets.BaseWidget
All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure
Direct Known Subclasses:
BatchUploader, Canvas, DrawnValue

public abstract class BaseWidget
extends Widget
implements HasHandlers, LogicalStructure


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
 
Field Summary
protected  JavaScriptObject config
           
protected  boolean configOnly
           
protected  String id
           
protected  boolean isElementSet
           
 NativeObject nativeObject
           
protected  String scClassName
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
  BaseWidget()
           
protected BaseWidget(JavaScriptObject jsObj)
           
  BaseWidget(String id)
           
 
Method Summary
 HandlerRegistration addDrawHandler(DrawHandler handler)
           
protected  JavaScriptObject create()
           
 void destroy()
          Permanently destroy a Canvas and all of it's children / members, recursively.
protected
<H extends EventHandler>
HandlerRegistration
doAddHandler(H handler, GwtEvent.Type<H> type)
          Adds this handler to the widget.
protected  void doInit()
           
 void doOnRender(Function function)
           
 void draw()
          Draws the widget on the page.
 boolean equals(Object obj)
           
protected  void error(String message)
           
protected  void errorIfNotCreated(String property)
           
 void fireEvent(GwtEvent<?> event)
           
protected  String getAttribute(String attribute)
           
protected  Boolean getAttributeAsBoolean(String property)
           
protected  Date getAttributeAsDate(String property)
           
protected  Date[] getAttributeAsDateArray(String property)
           
protected  Double getAttributeAsDouble(String property)
           
protected  Element getAttributeAsElement(String property)
           
protected  Float getAttributeAsFloat(String property)
           
protected  Float[] getAttributeAsFloatArray(String property)
           
protected  Integer getAttributeAsInt(String property)
           
protected  int[] getAttributeAsIntArray(String property)
           
protected  JavaScriptObject getAttributeAsJavaScriptObject(String property)
           
protected  Map getAttributeAsMap(String property)
           
protected  String getAttributeAsString(String property)
           
protected  String[] getAttributeAsStringArray(String property)
           
 JavaScriptObject getConfig()
           
 Element getDOM()
           
 Element getElement()
           
 Element getElement(boolean allowPreRender)
           
 int getHandlerCount(GwtEvent.Type<?> type)
           
 String getID()
           
 String getInnerHTML()
          Return the inner HTML for this canvas.
 JavaScriptObject getJsObj()
           
 com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
           
 JavaScriptObject getOrCreateJsObj()
           
static BaseWidget getRef(JavaScriptObject jsObj)
           
 String getScClassName()
          Get the name of the underlying SmartClient class
 String getTitle()
           
 int hashCode()
           
 void initNativeObject()
           
 boolean isConfigOnly()
           
 boolean isCreated()
           
protected  Boolean isDrawn()
           
protected  void onDestroy()
           
protected  void onDraw()
           
protected  void onInit()
           
protected  void setAttribute(String attribute, BaseClass[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, BaseWidget[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, BaseWidget value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Boolean value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, DataClass[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, DataClass value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Date value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, double value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Element value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Float[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, float value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, int[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Integer value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, JavaScriptObject[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, JavaScriptObject value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Map value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, Object[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, String[] value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, String value, boolean allowPostCreate)
           
protected  void setAttribute(String attribute, ValueEnum value, boolean allowPostCreate)
           
 void setConfig(JavaScriptObject config)
           
 void setConfigOnly(boolean configOnly)
           
protected  boolean setDragTracker()
           
protected  void setElement(Element elem)
           
 void setHtmlElement(Element element)
           
 void setID(String id)
           
 com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.core.LogicalStructureObject s)
           
 void setNullProperty(String property)
           
 void setPosition(String position)
           
 void setProperty(String property, boolean value)
           
 void setProperty(String property, double value)
           
 void setProperty(String property, Element value)
           
 void setProperty(String property, float value)
           
 void setProperty(String property, int value)
           
 void setProperty(String property, JavaScriptObject value)
           
 void setProperty(String property, String value)
           
 void setScClassName(String scClassName)
          Set the name of the underlying SmartClient class.
 void setTitle(String title)
           
 String toString()
           
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, setVisible, setWidth, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected String id

config

protected JavaScriptObject config

isElementSet

protected boolean isElementSet

scClassName

protected String scClassName

configOnly

protected boolean configOnly

nativeObject

public NativeObject nativeObject
Constructor Detail

BaseWidget

public BaseWidget()

BaseWidget

protected BaseWidget(JavaScriptObject jsObj)

BaseWidget

public BaseWidget(String id)
Method Detail

fireEvent

public void fireEvent(GwtEvent<?> event)
Specified by:
fireEvent in interface HasHandlers
Overrides:
fireEvent in class Widget

doAddHandler

protected final <H extends EventHandler> HandlerRegistration doAddHandler(H handler,
                                                                          GwtEvent.Type<H> type)
Adds this handler to the widget.

Type Parameters:
H - the type of handler to add
Parameters:
type - the event type
handler - the handler
Returns:
HandlerRegistration used to remove the handler

getHandlerCount

public int getHandlerCount(GwtEvent.Type<?> type)
Overrides:
getHandlerCount in class Widget

getRef

public static BaseWidget getRef(JavaScriptObject jsObj)

setElement

protected void setElement(Element elem)
Overrides:
setElement in class UIObject

getScClassName

public String getScClassName()
Get the name of the underlying SmartClient class

Returns:
the SmartClient class name

setScClassName

public void setScClassName(String scClassName)
Set the name of the underlying SmartClient class. This is an advanced setting.

Parameters:
scClassName - the SmartClient class

doInit

protected final void doInit()

onInit

protected void onInit()

isConfigOnly

public boolean isConfigOnly()

setConfigOnly

public void setConfigOnly(boolean configOnly)

setDragTracker

protected boolean setDragTracker()

getInnerHTML

public String getInnerHTML()
Return the inner HTML for this canvas. Called when the canvas is drawn or redrawn; override to customize.

Note : Canvas.setRedrawOnResize(java.lang.Boolean) should be set to true for components whose inner HTML will not automatically reflow to fit the component's new size.

Returns:
HTML contents of this canvas

draw

public void draw()
Draws the widget on the page.


destroy

public void destroy()
Permanently destroy a Canvas and all of it's children / members, recursively.

Like Canvas.clear() calling destroy() removes all HTML for the component; unlike clear(), a destroyed Canvas is permanently unusable: it cannot be draw()'n again and cannot be referenced by its global ID. This method also removes all JavaScript references to the Canvas outside of application code, making it eligible for garbage collection (though developers will need to release any references to the canvas held in application code themselves).

Any attempt to call a method on a destroyed Canvas will generally result in an error. If your application is forced to hold onto Canvas's that might be destroy()d without warning, you can avoid errors by checking for the Canvas.getDestroyed() property. If you override certain Canvas methods, your code may be called while a Canvas is being destroy()d; in this case you can avoid extra work (and possibly errors) by checking for the +Canvas.getDestroying() property.

Note that destroy() should not be called directly in event handling code for this canvas. For this reason, wherever possible we recommend using Canvas.markForDestroy() instead of calling this method directly.

Note: This is an override point


doOnRender

public void doOnRender(Function function)

addDrawHandler

public HandlerRegistration addDrawHandler(DrawHandler handler)

onDraw

protected void onDraw()

onDestroy

protected void onDestroy()

getElement

public Element getElement()
Overrides:
getElement in class UIObject

getElement

public Element getElement(boolean allowPreRender)

setPosition

public void setPosition(String position)

setHtmlElement

public void setHtmlElement(Element element)

getDOM

public Element getDOM()

getID

public String getID()

setID

public void setID(String id)

getConfig

public JavaScriptObject getConfig()

setConfig

public void setConfig(JavaScriptObject config)

isCreated

public boolean isCreated()

isDrawn

protected Boolean isDrawn()

getJsObj

public JavaScriptObject getJsObj()

getOrCreateJsObj

public JavaScriptObject getOrCreateJsObj()

create

protected JavaScriptObject create()

getAttribute

protected String getAttribute(String attribute)

getAttributeAsString

protected String getAttributeAsString(String property)

getAttributeAsStringArray

protected String[] getAttributeAsStringArray(String property)

getAttributeAsIntArray

protected int[] getAttributeAsIntArray(String property)

getAttributeAsFloatArray

protected Float[] getAttributeAsFloatArray(String property)

getAttributeAsDate

protected Date getAttributeAsDate(String property)

getAttributeAsDateArray

protected Date[] getAttributeAsDateArray(String property)

getAttributeAsInt

protected Integer getAttributeAsInt(String property)

getAttributeAsDouble

protected Double getAttributeAsDouble(String property)

getAttributeAsElement

protected Element getAttributeAsElement(String property)

getAttributeAsJavaScriptObject

protected JavaScriptObject getAttributeAsJavaScriptObject(String property)

getAttributeAsFloat

protected Float getAttributeAsFloat(String property)

getAttributeAsBoolean

protected Boolean getAttributeAsBoolean(String property)

getAttributeAsMap

protected Map getAttributeAsMap(String property)

errorIfNotCreated

protected void errorIfNotCreated(String property)
                          throws IllegalStateException
Throws:
IllegalStateException

error

protected void error(String message)
              throws IllegalStateException
Throws:
IllegalStateException

setAttribute

protected void setAttribute(String attribute,
                            String value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            ValueEnum value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            BaseWidget value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Map value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            int[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Float[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            DataClass value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            DataClass[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            JavaScriptObject[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            BaseClass[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            BaseWidget[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            float value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            double value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Integer value,
                            boolean allowPostCreate)

setNullProperty

public void setNullProperty(String property)

setProperty

public void setProperty(String property,
                        String value)

setProperty

public void setProperty(String property,
                        boolean value)

setProperty

public void setProperty(String property,
                        int value)

setProperty

public void setProperty(String property,
                        float value)

setProperty

public void setProperty(String property,
                        double value)

setProperty

public void setProperty(String property,
                        Element value)

setProperty

public void setProperty(String property,
                        JavaScriptObject value)

setAttribute

protected void setAttribute(String attribute,
                            Date value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            JavaScriptObject value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            String[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Object[] value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Boolean value,
                            boolean allowPostCreate)

setAttribute

protected void setAttribute(String attribute,
                            Element value,
                            boolean allowPostCreate)

setTitle

public void setTitle(String title)
Overrides:
setTitle in class UIObject

getTitle

public String getTitle()
Overrides:
getTitle in class UIObject

toString

public String toString()
Overrides:
toString in class UIObject

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setLogicalStructure

public com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.core.LogicalStructureObject s)
Specified by:
setLogicalStructure in interface LogicalStructure

getLogicalStructure

public com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
Specified by:
getLogicalStructure in interface LogicalStructure

initNativeObject

public void initNativeObject()
Specified by:
initNativeObject in interface LogicalStructure