public class GwtMetawidget
extends com.google.gwt.user.client.ui.FlowPanel
implements com.google.gwt.user.client.ui.HasName
GWT compiles Java to JavaScript, and JavaScript lacks Java's comprehensive reflection support.
The only viable Inspector the JavaScript could run would be XmlInspector, and even that would
have to be considerably rewritten as GWT supplies its own variant of org.w3c.dom
.
A more interesting solution is to have the JavaScript client send its objects (via AJAX) to the
Java server for inspection. The full power of Java Inspectors can then be brought to bear,
including inspecting annotations and server-side configuration files (such as
hibernate.cfg.xml
).
Modifier and Type | Class and Description |
---|---|
protected class |
GwtMetawidget.Pipeline |
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
Constructor and Description |
---|
GwtMetawidget() |
Modifier and Type | Method and Description |
---|---|
protected void |
add(com.google.gwt.user.client.ui.Widget child,
com.google.gwt.user.client.Element container) |
void |
addInspectionResultProcessor(InspectionResultProcessor<GwtMetawidget> inspectionResultProcessor) |
void |
addWidgetProcessor(WidgetProcessor<com.google.gwt.user.client.ui.Widget,GwtMetawidget> widgetProcessor) |
protected GwtMetawidget |
buildNestedMetawidget()
Hook so subclasses can change which class gets created.
|
protected void |
buildWidgets()
Builds the widgets.
|
void |
clear() |
protected void |
configure() |
protected void |
endBuild() |
Set<com.google.gwt.user.client.ui.Widget> |
fetchExistingUnusedWidgets()
Fetch a list of
Widgets that were added manually, and have so far not been used. |
<T> T |
getClientProperty(Object key)
Storage area for WidgetProcessors, Layouts, and other stateless clients.
|
Facet |
getFacet(String name) |
String |
getLabelString(Map<String,String> attributes)
Returns a label for the given set of attributes.
|
String |
getLocalizedKey(String key) |
int |
getMaximumInspectionDepth() |
String |
getName()
Implements the
com.google.gwt.user.client.ui.HasName interface. |
String |
getPath() |
<T> T |
getToInspect()
Gets the object being inspected.
|
<T> T |
getValue(String... names)
Gets the value from the Widget with the given name.
|
<T> T |
getValue(com.google.gwt.user.client.ui.Widget widget)
Gets the value from the given Widget.
|
<T extends com.google.gwt.user.client.ui.Widget> |
getWidget(String... names)
Gets the widget with the given name.
|
<T> T |
getWidgetProcessor(Class<T> widgetProcessorClass) |
protected void |
initNestedMetawidget(GwtMetawidget nestedMetawidget,
Map<String,String> attributes) |
protected void |
insert(com.google.gwt.user.client.ui.Widget child,
com.google.gwt.user.client.Element container,
int beforeIndex,
boolean domInsert) |
String |
inspect(Object toInspect,
String type,
String... names)
Useful for WidgetBuilders to perform nested inspections (eg.
|
protected void |
invalidateInspection()
Invalidates the current inspection result (if any) and invalidates the widgets.
|
protected void |
invalidateWidgets()
Invalidates the widgets.
|
boolean |
isReadOnly() |
protected void |
layoutWidget(com.google.gwt.user.client.ui.Widget widget,
String elementName,
Map<String,String> attributes) |
protected GwtMetawidget.Pipeline |
newPipeline()
Instantiate the Pipeline used by this Metawidget.
|
void |
putClientProperty(Object key,
Object value)
Storage area for WidgetProcessors, Layouts, and other stateless clients.
|
boolean |
remove(int index) |
boolean |
remove(com.google.gwt.user.client.ui.Widget widget) |
void |
setDictionaryName(String dictionaryName)
Set the Dictionary name for localization.
|
void |
setInspector(Inspector inspector) |
void |
setLayout(Layout<com.google.gwt.user.client.ui.Widget,com.google.gwt.user.client.ui.Panel,GwtMetawidget> layout) |
void |
setMaximumInspectionDepth(int maximumInspectionDepth) |
void |
setName(String name)
Implements the
com.google.gwt.user.client.ui.HasName interface. |
void |
setPath(String path)
Sets the path to be inspected.
|
void |
setReadOnly(boolean readOnly) |
void |
setToInspect(Object toInspect)
Sets the Object to inspect.
|
void |
setValue(Object value,
String... names)
Sets the Widget with the given name to the specified value.
|
void |
setValue(Object value,
com.google.gwt.user.client.ui.Widget widget)
Sets the given Widget to the specified value.
|
void |
setWidgetBuilder(WidgetBuilder<com.google.gwt.user.client.ui.Widget,GwtMetawidget> widgetBuilder) |
protected void |
startBuild() |
void |
updateToInspectWithoutInvalidate(Object toInspect)
Updates the Object to inspect, without invalidating the previous inspection results.
|
adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, iterator
add, adopt, adopt, disown, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public <T> T getToInspect()
Exposed for binding implementations.
Person p = getToInspect()
)public void setToInspect(Object toInspect)
If setPath
has not been set, or points to a previous setToInspect
,
sets it to point to the given Object.
public void updateToInspectWithoutInvalidate(Object toInspect)
This is an internal API exposed for WidgetProcessor rebinding support. Clients should not call it directly.
public void setPath(String path)
Note setPath
is quite different to
com.google.gwt.user.client.ui.HasName.setName
. setPath
is always in
relation to setToInspect
, so must include the type name and any subsequent
sub-names (eg. type/name/name). Conversely, setName
is a single name relative to
our immediate parent. setName
is only implemented so that
GwtMetawidget
s can be used directly as overridden widgets (i.e. without needing
to be wrapped in a Stub
).
public String getPath()
public void setName(String name)
com.google.gwt.user.client.ui.HasName
interface.
Useful so that GwtMetawidget
s can be used directly as overridden widgets (i.e.
without needing to be wrapped in a Stub
). Unlike setPath
, has no
effect on inspection.
setName
in interface com.google.gwt.user.client.ui.HasName
public String getName()
com.google.gwt.user.client.ui.HasName
interface.
Useful so that GwtMetawidget
s can be used directly as overridden widgets (i.e.
without needing to be wrapped in a Stub
). Unlike setPath
, has no
effect on inspection.
getName
in interface com.google.gwt.user.client.ui.HasName
public void setInspector(Inspector inspector)
public String inspect(Object toInspect, String type, String... names)
public void addInspectionResultProcessor(InspectionResultProcessor<GwtMetawidget> inspectionResultProcessor)
public void setWidgetBuilder(WidgetBuilder<com.google.gwt.user.client.ui.Widget,GwtMetawidget> widgetBuilder)
public void addWidgetProcessor(WidgetProcessor<com.google.gwt.user.client.ui.Widget,GwtMetawidget> widgetProcessor)
public <T> T getWidgetProcessor(Class<T> widgetProcessorClass)
public void setLayout(Layout<com.google.gwt.user.client.ui.Widget,com.google.gwt.user.client.ui.Panel,GwtMetawidget> layout)
public void setDictionaryName(String dictionaryName)
The Dictionary name must be a JavaScript variable declared in the host HTML page.
public String getLabelString(Map<String,String> attributes)
The label is determined using the following algorithm:
public String getLocalizedKey(String key)
public void setReadOnly(boolean readOnly)
public boolean isReadOnly()
public int getMaximumInspectionDepth()
public void setMaximumInspectionDepth(int maximumInspectionDepth)
public <T extends com.google.gwt.user.client.ui.Widget> T getWidget(String... names)
public <T> T getValue(String... names)
The value is returned as it is stored in the Widget (eg. String for TextBox) so may need some conversion before being reapplied to the object being inspected. This obviously requires knowledge of which Widget GwtMetawidget created, which is not ideal, so clients may prefer to use binding instead.
String s = getValue(names)
)public <T> T getValue(com.google.gwt.user.client.ui.Widget widget)
String s = getValue(widget)
)public void setValue(Object value, String... names)
Clients must ensure the value is of the correct type to suit the Widget (eg. String for TextBox). This obviously requires knowledge of which Widget GwtMetawidget created, which is not ideal, so clients may prefer to use binding instead.
public void setValue(Object value, com.google.gwt.user.client.ui.Widget widget)
public void putClientProperty(Object key, Object value)
public <T> T getClientProperty(Object key)
public boolean remove(int index)
remove
in interface com.google.gwt.user.client.ui.IndexedPanel
remove
in class com.google.gwt.user.client.ui.ComplexPanel
public boolean remove(com.google.gwt.user.client.ui.Widget widget)
remove
in interface com.google.gwt.user.client.ui.HasWidgets
remove
in class com.google.gwt.user.client.ui.ComplexPanel
public void clear()
clear
in interface com.google.gwt.user.client.ui.HasWidgets
clear
in class com.google.gwt.user.client.ui.FlowPanel
public Set<com.google.gwt.user.client.ui.Widget> fetchExistingUnusedWidgets()
Widgets
that were added manually, and have so far not been used.
This is an internal API exposed for OverriddenWidgetBuilder. Clients should not call it directly.
protected GwtMetawidget.Pipeline newPipeline()
Subclasses wishing to use their own Pipeline should override this method to instantiate their version.
protected void configure()
protected void add(com.google.gwt.user.client.ui.Widget child, com.google.gwt.user.client.Element container)
add
in class com.google.gwt.user.client.ui.ComplexPanel
protected void insert(com.google.gwt.user.client.ui.Widget child, com.google.gwt.user.client.Element container, int beforeIndex, boolean domInsert)
insert
in class com.google.gwt.user.client.ui.ComplexPanel
protected void invalidateInspection()
As an optimisation we only invalidate the widgets, not the entire inspection result, for some operations (such as adding/removing stubs, changing read-only etc.)
protected void invalidateWidgets()
If the widgets are already invalidated, but rebuilding is not yet in progress, cancels the pending rebuild and resets the timer. This tries to 'batch' multiple invalidate requests into one.
protected void buildWidgets()
Unlike buildWidgets
in other Metawidget implementations, this method may be
asynchronous. If the GwtMetawidget
is using an GwtInspectorAsync
Inspector (which it does by default), clients should not expect the widgets to be built by
the time this method returns.
protected void startBuild()
protected void layoutWidget(com.google.gwt.user.client.ui.Widget widget, String elementName, Map<String,String> attributes)
elementName
- XML node name of the business field. Typically 'entity', 'property' or 'action'.
Never nullprotected GwtMetawidget buildNestedMetawidget()
protected void initNestedMetawidget(GwtMetawidget nestedMetawidget, Map<String,String> attributes) throws Exception
Exception
protected void endBuild()
Copyright © 2015. All Rights Reserved.