A usable, closeable and scrollable dialog box is available from
http://code.google.com/p/synthfuljava/ .
ScrolledDialogBox Patch
This class ScrolledDialogBox is found as
http://code.google.com/p/synthfuljava/source/browse/trunk/gwt/widgets/com/google/gwt/user/client/ui/ScrolledDialogBox.java .
Being a patch, it retains the com.google.gwt.user.client.ui namespace.
DialogBox over-rides the onBrowserEvent method and replaces it with a block of obtuse logic - to prevent the text in the caption bar from being selected while the mouse is grabbing the caption to move the DialogBox around the window. A prevention scheme that does not work very well on the hosted browser, evidently. This obtuse logic is the very reason why buttons placed on the caption bar will not react appropriately to mouse click events - consequently, you cannot hide/close the DialogBox through any button placed on the caption bar.
Therefore, either we delve into the convoluted GWT event firing scheme or invent our own mini event scheme and insert it into onBrowserEvent method of DialogBox. The scheme is defined by the interface CloserEventHandler, where only three mouse events are recognised
- onClick - to close the dialog by clicking on the close button
- onMouseOver - to change the colour of the close button
- onMouseOut - to change the close button back to its original colour.
And CloserHandler embedded class implements CloserEventHandler, which is added onto the CloserEventHandlers event stack, which the new onBrowserEvent paces through to execute each registered handler.
Subclassing rather than Patching
The initial tendency to solve the problem, besides waiting for Google to release a better DialogBox (waiting and looking over the wall till your neck stretches as long as a giraffe's), is to subclass DialogBox to provide the desired effect of having a closer button at the caption bar. As in
http://code.google.com/p/synthfuljava/source/browse/trunk/gwt/widgets/org/synthful/gwt/widgets/client/ui/UnusableScrollableDialogBox.java .
However, this class has a disclaimer - it is not useable, as explained within the javadoc sections, but retained as an example why over-riding this way would not work, because DialogBox's caption acknowledges DialogBox as a parent, but DialogBox does not acknowledge its caption as a child:
- In DialogBox, the caption bar comprises one widget alone - an HTML widget implementing the DialogBox.Caption interface.
- We need to replace the caption bar with a HorizontalPanel. On the HorizontalPanel, we should place the caption widget and on the right, the closer button.
- We should extract the caption widget and reuse it by pulling it out of the caption bar and reinserting it as the first widget of the HorizontalPanel.
- However DialogBox did not add caption widget as a widget but rather by adopting (using the adopt() method) it as an element. The consequence is, caption registers DialogBox as a parent but, DialogBox does not register caption widget as a child widget.
- To yank caption widget out of DialogBox, we would use caption.removeParent() method. However, Widget removeParent() method first detours to let the parent check if it has the widget as a child widget - if not, the parent's failure to relate to the widget as a child causes the remove operation to abort without the widget having a chance to nullify the dead-beat parent from its private parent variable. Since a widget's parent is stored as a private variable, we muggles would not be able to access it to nullify it.
- Well, since the caption widget still acknowledges its dead-beat parent as a parent, the add operation would not work. That is HorizontalPanel cannot add caption widget as its child widget because add() method would first check if the widget still has a parent.
- Therefore the caption widget is a victim of a widget's unrequited loyalty to its dead-beat parent.
Therefore the solution is to
- Orphan the original caption widget.
- Instantiate an HTML widget as the new caption widget.
- Over-ride the get/set Text, Caption & Html methods. Unfortunately, the getCaption() method is final and cannot be over-riden.
- Instantiate a HorizontalPanel and set it as the new caption panel.
- Add the new caption widget as first child widget of HorizontalPanel.
- Instantiate a Button and add it to HorizontalPanel as its second widget.
- Conjure the mini event scheme.
The subclassing code is found as
http://code.google.com/p/synthfuljava/source/browse/trunk/gwt/widgets/org/synthful/gwt/widgets/client/ui/ScrollableDialogBox.java .
Disclaimer: The ScrolledDialogBox and ScrollableDialogBox classes need further refinement.
- The position of the X button needs to be properly calculated
- The event scheme of the X button accounts only for onClick, onMouseOver and onMouseOut.
canada goose jackets
ReplyDeletedolce and gabbana outlet online
michael kors outlet store
ray ban sunglasses discount
adidas superstar
louis vuitton outlet online
michael kors outlet store
polo ralph lauren
michael kors outlet store
birkenstock uk
zhi20161130
michael kors outlet online
ReplyDeletepolo ralph lauren outlet
pandora outlet
coach outlet online
adidas
true religion uk
michael kors handbags clearance
nike free 4.0 flyknit
adidas trainers
longchamp bag
2017220yuanyuan
nike air max 2018
ReplyDeletetory burch outlet store
keen shoes
coach factorty outlet store
birkenstock shoes outlet
adidas outlet store
north face outlet
longchamp outlet
vans outlet store
dolce and gabbana handbags
clb20180522
roshe run
ReplyDeletenike roshe
adidas shoes
nike free
lebron 14
adidas outlet
philipp plein
nike flip-flops
fitflops
mac makeup
chenyingying20180721
links of london outlet store
ReplyDeleteysl handbags
michael kors
yeezy shoes
nike roshe
adidas outlet
golden goose
jordan retro
nike flyknit
michael kors handbags
jordans
ReplyDeletecartier love bracelet
roshe run
coach outlet online
michael kors outlet
jordan 12s
guess
kate spade outlet
abercrombie
air max 90
2018.8.8chenlixiang
supreme t shirt
ReplyDeletegoyard
supreme outlet
goyard handbags
goyard
yeezy shoes
golden goose sneakers
golden goose outlet
balenciaga shoes
golden goose