Class BaseWidget
- All Implemented Interfaces:
HasAttachHandlers
,HasHandlers
,EventListener
,HasVisibility
,IsWidget
,LogicalStructure
- Direct Known Subclasses:
Canvas
,DrawItem
,PointerSettings
,Sound
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
Field Summary
Modifier and TypeFieldDescriptionprotected JavaScriptObject
protected boolean
protected boolean
protected String
protected String
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddDrawHandler
(DrawHandler handler) void
addDynamicProperty
(String propertyName, AdvancedCriteria criteria) Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.void
addDynamicProperty
(String propertyName, UserFormula formula) Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.void
addDynamicProperty
(String propertyName, UserSummary summary) Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.void
addDynamicProperty
(String propertyName, String source) Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.void
static void
changeAutoChildDefaults
(String autoChildName, Canvas defaults) Changes the defaults for Canvas AutoChildren namedautoChildName
.static void
changeAutoChildDefaults
(String autoChildName, FormItem defaults) Changes the defaults for FormItem AutoChildren namedautoChildName
.void
clearDynamicProperty
(String propertyName) Clears a dynamic property previously established viaaddDynamicProperty(java.lang.String,java.lang.String)
.void
Commits a widget to being an actual live instance instead of being used as a configuration template with various APIs that accept a properties object.protected JavaScriptObject
create()
void
destroy()
Permanently destroy a Canvas and all of it's children / members, recursively.protected final <H extends EventHandler>
HandlerRegistrationdoAddHandler
(H handler, GwtEvent.Type<H> type) Adds this handler to the widget.protected final void
doInit()
void
doOnRender
(Function function) void
draw()
Draws the widget on the page.
boolean
protected void
protected void
errorIfNotCreated
(String property) 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 Object
getAttributeAsObject
(String property) protected Record
getAttributeAsRecord
(String property) protected String
getAttributeAsString
(String property) protected String[]
getAttributeAsStringArray
(String property) static BaseWidget
Retrieve a BaseWidget by its globalID
.static BaseWidget
getByJSObject
(JavaScriptObject jsObj) Retrieve a BaseWidget from itsJavaScriptObject
.Returns the javascript class name.getDOM()
int
getHandlerCount
(GwtEvent.Type<?> type) getID()
Return the inner HTML for this canvas.getJsObj()
Getter implementing theLogicalStructure
interface, which supports Eclipse's logical structure debugging facility.static BaseWidget
getOrCreateRef
(JavaScriptObject jsObj) static BaseWidget
getRef
(JavaScriptObject jsObj) Get the name of the underlying SmartClient classgetTitle()
static boolean
boolean
hasDynamicProperty
(String propertyName) Returns true if the property is dynamic.int
hashCode()
void
protected final void
internalSetID
(JavaScriptObject jsObj) protected final void
internalSetID
(String id, boolean autoAssigned) boolean
boolean
isDrawn()
Returns the boolean true if the widget has been completely drawn, and false otherwise.boolean
protected void
onBind()
protected void
protected void
onDraw()
protected void
onInit()
protected BaseWidget
setAttribute
(String attribute, double[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, double value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, float[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, float value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, int[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, JavaScriptObject[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, JavaScriptObject value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Element value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, BaseClass[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, DataClass[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, DataClass value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, ValueEnum value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, BaseWidget[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, BaseWidget value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Boolean value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Float[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Integer value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Object[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, String[] value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, String value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Date value, boolean allowPostCreate) protected BaseWidget
setAttribute
(String attribute, Map value, boolean allowPostCreate) void
setConfig
(JavaScriptObject config) void
setConfigOnly
(boolean configOnly) static void
setDefaultProperties
(BaseWidget baseWidgetProperties) Class level method to set the default properties of this class.protected boolean
void
setFactoryCreated
(boolean createdByBeanFactory) setHtmlElement
(Element element) void
Setter implementing theLogicalStructure
interface, which supports Eclipse's logical structure debugging facility.void
setNullProperty
(String property) void
setPosition
(String position) void
setProperty
(String property, boolean value) void
setProperty
(String property, double value) void
setProperty
(String property, float value) void
setProperty
(String property, int value) void
setProperty
(String property, JavaScriptObject value) void
setProperty
(String property, Element value) void
setProperty
(String property, String value) void
setScClassName
(String scClassName) Set the name of the underlying SmartClient class.void
toString()
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, setVisible, setWidth, sinkBitlessEvent
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
id
-
config
-
scClassName
-
configOnly
protected boolean configOnly -
factoryProperties
-
factoryCreated
protected boolean factoryCreated -
nativeObject
-
-
Constructor Details
-
BaseWidget
public BaseWidget() -
BaseWidget
-
BaseWidget
-
-
Method Details
-
getOrCreateRef
-
changeAutoChildDefaults
Changes the defaults for Canvas AutoChildren namedautoChildName
.- Parameters:
autoChildName
- name of an AutoChild to customize the defaults for.defaults
- Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, seeSGWTProperties
.- See Also:
-
changeAutoChildDefaults
Changes the defaults for FormItem AutoChildren namedautoChildName
.- Parameters:
autoChildName
- name of an AutoChild to customize the defaults for.defaults
- FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, seeSGWTProperties
.- See Also:
-
create
-
setDefaultProperties
Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
- Parameters:
baseWidgetProperties
- properties that should be used as new defaults when instances of this class are created- See Also:
-
getById
Retrieve a BaseWidget by its globalID
.- Parameters:
ID
- global ID of the BaseWidget- Returns:
- the Canvas, or null if not found
-
getByJSObject
Retrieve a BaseWidget from itsJavaScriptObject
.- Parameters:
jsObj
- SmartClient object associated with Canvas- Returns:
- the BaseWidget, or null if not found
-
setFactoryCreated
public void setFactoryCreated(boolean createdByBeanFactory) -
isFactoryCreated
public boolean isFactoryCreated() -
setJavaScriptObject
-
getRef
-
hasAutoAssignedID
-
getClassName
Returns the javascript class name.- Returns:
-
getScClassName
Get the name of the underlying SmartClient class- Returns:
- the SmartClient class name
-
setScClassName
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() -
onBind
protected void onBind() -
isConfigOnly
public boolean isConfigOnly() -
setConfigOnly
public void setConfigOnly(boolean configOnly) -
setDragTracker
protected boolean setDragTracker() -
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()
callingdestroy()
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 usingCanvas.markForDestroy()
instead of calling this method directly.Note: This is an override point
-
doOnRender
-
addDrawHandler
-
onDraw
protected void onDraw() -
onDestroy
protected void onDestroy() -
setPosition
-
setHtmlElement
-
getDOM
-
getID
-
internalSetID
-
internalSetID
-
setID
-
getConfig
-
setConfig
-
isCreated
public boolean isCreated() -
isDrawn
Returns the boolean true if the widget has been completely drawn, and false otherwise.- Returns:
- true if drawn, false if not drawn
- See Also:
-
getJsObj
-
getOrCreateJsObj
-
completeCreation
public void completeCreation()Commits a widget to being an actual live instance instead of being used as a configuration template with various APIs that accept a properties object.A widget will be automatically instantiated in some circumstances, such as:
- when it's drawn
- when it's added as a member of a
Layout
or child of a parent widget - when it's asked to perform any kind of network request (e.g.
listGrid.fetchData()
, etc.)
In general, completeCreation() will also occur automatically as a result of methods that require the object to derive or calculate any kind of value. The object will remain in the uncreated state (still usable as just a configuration object) as long as the only methods that are called either set properties or retrieve properties previously set.
Note that if the object has already been used as a configuration template, say by being passed to a method such as
Canvas.changeAutoChildDfaults()
as the properties object argument, then it is an error to call this method.For a discussion of when a widget should be treated as a properties object rather than a live instance, see
SmartGWT Properties
. -
applyFactoryProperties
public void applyFactoryProperties() -
getAttribute
-
getAttributeAsString
-
getAttributeAsStringArray
-
getAttributeAsIntArray
-
getAttributeAsFloatArray
-
getAttributeAsDate
-
getAttributeAsDateArray
-
getAttributeAsInt
-
getAttributeAsDouble
-
getAttributeAsElement
-
getAttributeAsJavaScriptObject
-
getAttributeAsObject
-
getAttributeAsFloat
-
getAttributeAsBoolean
-
getAttributeAsMap
-
getAttributeAsRecord
-
errorIfNotCreated
- Throws:
IllegalStateException
-
error
- Throws:
IllegalStateException
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
protected BaseWidget setAttribute(String attribute, JavaScriptObject[] value, boolean allowPostCreate) -
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setNullProperty
-
setProperty
-
setProperty
-
setProperty
-
setProperty
-
setProperty
-
setProperty
-
setProperty
-
setAttribute
-
setAttribute
protected BaseWidget setAttribute(String attribute, JavaScriptObject value, boolean allowPostCreate) -
setAttribute
-
setAttribute
-
setAttribute
-
setAttribute
-
setTitle
-
getTitle
-
toString
-
equals
-
hashCode
public int hashCode() -
setLogicalStructure
- Specified by:
setLogicalStructure
in interfaceLogicalStructure
-
initNativeObject
public void initNativeObject()- Specified by:
initNativeObject
in interfaceLogicalStructure
-
addDynamicProperty
Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.The dataPath, criteria, or formula is evaluated immediately when addDynamicProperty() is called, then re-evaluated every time the ruleScope changes. An
AdvancedCriteria
will always evaluate to boolean true or false, and aUserSummary
to a string.It is invalid usage to use
addDynamicProperty()
on a property that is not runtime settable. However,addDynamicProperty()
will not throw an error or log a warning if this is done.If a property is already dynamic and addDynamicProperty() is called again, the new dynamic behavior replaces the old. If a property should no longer be dynamic, call
clearDynamicProperty()
.Dynamic properties can also be declared together via
dynamicProperties
.Note that you may convert a simple criteria to an
AdvancedCriteria
by callingDataSource.convertCriteria()
.- Parameters:
propertyName
- name of a settable property on this instance. SeeIdentifier
source
- aDataPath
.- See Also:
-
Canvas.getDataPath()
com.smartgwt.client.widgets.Class#getDynamicProperties
DataPath
-
addDynamicProperty
Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.The dataPath, criteria, or formula is evaluated immediately when addDynamicProperty() is called, then re-evaluated every time the ruleScope changes. An
AdvancedCriteria
will always evaluate to boolean true or false, and aUserSummary
to a string.It is invalid usage to use
addDynamicProperty()
on a property that is not runtime settable. However,addDynamicProperty()
will not throw an error or log a warning if this is done.If a property is already dynamic and addDynamicProperty() is called again, the new dynamic behavior replaces the old. If a property should no longer be dynamic, call
clearDynamicProperty()
.Dynamic properties can also be declared together via
dynamicProperties
.Note that you may convert a simple criteria to an
AdvancedCriteria
by callingDataSource.convertCriteria()
.- Parameters:
propertyName
- name of a settable property on this instance. SeeIdentifier
formula
- aUserFormula
- See Also:
-
Canvas.getDataPath()
com.smartgwt.client.widgets.Class#getDynamicProperties
DataPath
-
addDynamicProperty
Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.The dataPath, criteria, or formula is evaluated immediately when addDynamicProperty() is called, then re-evaluated every time the ruleScope changes. An
AdvancedCriteria
will always evaluate to boolean true or false, and aUserSummary
to a string.It is invalid usage to use
addDynamicProperty()
on a property that is not runtime settable. However,addDynamicProperty()
will not throw an error or log a warning if this is done.If a property is already dynamic and addDynamicProperty() is called again, the new dynamic behavior replaces the old. If a property should no longer be dynamic, call
clearDynamicProperty()
.Dynamic properties can also be declared together via
dynamicProperties
.Note that you may convert a simple criteria to an
AdvancedCriteria
by callingDataSource.convertCriteria()
.- Parameters:
propertyName
- name of a settable property on this instance. SeeIdentifier
summary
- aUserSummary
- See Also:
-
Canvas.getDataPath()
com.smartgwt.client.widgets.Class#getDynamicProperties
DataPath
-
addDynamicProperty
Sets up the value ofpropertyName
to be dynamically derived from theruleScope
, by either a simpleDataPath
into the ruleScope, anAdvancedCriteria
built againstDataPaths
, or via a textual or numeric formula using the ruleScope as available formula inputs.The dataPath, criteria, or formula is evaluated immediately when addDynamicProperty() is called, then re-evaluated every time the ruleScope changes. An
AdvancedCriteria
will always evaluate to boolean true or false, and aUserSummary
to a string.It is invalid usage to use
addDynamicProperty()
on a property that is not runtime settable. However,addDynamicProperty()
will not throw an error or log a warning if this is done.If a property is already dynamic and addDynamicProperty() is called again, the new dynamic behavior replaces the old. If a property should no longer be dynamic, call
clearDynamicProperty()
.Dynamic properties can also be declared together via
dynamicProperties
.Note that you may convert a simple criteria to an
AdvancedCriteria
by callingDataSource.convertCriteria()
.- Parameters:
propertyName
- name of a settable property on this instance. SeeIdentifier
criteria
- anAdvancedCriteria
- See Also:
-
Canvas.getDataPath()
com.smartgwt.client.widgets.Class#getDynamicProperties
DataPath
-
clearDynamicProperty
Clears a dynamic property previously established viaaddDynamicProperty(java.lang.String,java.lang.String)
.If the property is not currently dynamic, nothing will be done (and no warning logged).
The current value of the property will not be changed by this call.
- Parameters:
propertyName
- name of the dynamic property to clear
-
hasDynamicProperty
Returns true if the property is dynamic.- Parameters:
propertyName
- name of the dynamic property to check- Returns:
- boolean true if the property is dynamic
-
setLogicalStructure
Setter implementing theLogicalStructure
interface, which supports Eclipse's logical structure debugging facility. -
getLogicalStructure
Getter implementing theLogicalStructure
interface, which supports Eclipse's logical structure debugging facility.- Specified by:
getLogicalStructure
in interfaceLogicalStructure
-