My favorites
▼
|
Sign in
synthfuljava
Synthful Utilities Library for the Java Platform.
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
gwt
/
widgets
/
org
/
synthful
/
gwt
/
widgets
/
client
/
ui
/
ScrollableDialogBox.java
‹r75
r105
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package org.synthful.gwt.widgets.client.ui;
import java.util.ArrayList;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Blessed Geek
*
*/
public class ScrollableDialogBox
extends DialogBox
{
public ScrollableDialogBox() {
this(false);
}
public ScrollableDialogBox(boolean autoHide) {
this(autoHide, true);
}
public ScrollableDialogBox(boolean autoHide, boolean modal) {
super(autoHide, modal);
Element td01 = getCellElement(0, 1);
Widget caption = (Widget) this.getCaption();
DOM.removeChild(td01, caption.getElement());
DOM.appendChild(td01, this.captionPanel.getElement());
adopt(this.captionPanel);
this.captionTitle = new CaptionTitle();
captionPanel.add(this.captionTitle);
captionPanel.add(this.closer);
super.setWidget(this.contentPanel);
this.setWidthPx(200);
this.CloserEventHandlers.add(new CloserHandler());
this.captionPanel.setStyleName("Caption");
this.closer.setStyleName("Closer");
this.closer.setStyleName("Title");
DOM.setStyleAttribute(closer.getElement(), "color", "black");
}
public void setHeightPx(int hgt) {
this.contentPanel.setWidth(hgt + "px");
this.Height = hgt;
}
public void setWidthPx(int wid) {
this.contentPanel.setWidth(wid + "px");
this.initCaptionWidths(wid);
}
public void setSizePx(int wid, int hgt) {
this.contentPanel.setSize(wid + "px", hgt + "px");
this.Height = hgt;
this.initCaptionWidths(wid);
}
@Override
public void setWidget(Widget widget) {
this.contentPanel.setWidget(widget);
}
@Override
public Widget getWidget() {
return this.contentPanel.getWidget();
}
private void initCaptionWidths(int wid) {
this.Width = wid;
this.captionPanel.setWidth(this.Width + "px");
}
public final Caption getCaptionTitle() {
return this.captionTitle;
}
public String getCaptionHTML() {
return this.captionTitle.getHTML();
}
public String getCaptionText() {
return this.captionTitle.getText();
}
public void setCaptionHTML(String html) {
this.captionTitle.setHTML(html);
}
public void setCaptionText(String text) {
this.captionTitle.setText(text);
}
protected boolean isCaptionControlEvent(NativeEvent event) {
return isWidgetEvent(event, this.captionPanel.getWidget(1));
}
static protected boolean isWidgetEvent(NativeEvent event, Widget w) {
EventTarget target = event.getEventTarget();
if (Element.is(target)) {
boolean t = w.getElement().isOrHasChild(Element.as(target));
// if (t)
// System.out.println("isWidgetEvent:"+w+':'+target+':'+t);
return t;
}
return false;
}
@Override
public void onBrowserEvent(Event event) {
if (isCaptionControlEvent(event)) {
for (CloserEventHandler handler : this.CloserEventHandlers) {
switch (event.getTypeInt())
{
case Event.ONMOUSEUP:
case Event.ONCLICK:
handler.onClick(event);
break;
case Event.ONMOUSEOVER:
handler.onMouseOver(event);
break;
case Event.ONMOUSEOUT:
handler.onMouseOut(event);
break;
}
}
return;
}
super.onBrowserEvent(event);
}
// The events are not firing normally because DialogBox has over-ridden
// onBrowserEvent with some obtuse logic.
// So we have to create our own tiny system of event handling for the closer
// button
// in conjunction with List<AntiObtusedCloserHandler>
public interface CloserEventHandler
{
public void onClick(Event event);
public void onMouseOver(Event event);
public void onMouseOut(Event event);
}
/*
*
* @gwt.TypeArgs parameters
* <java.util.ArrayList<org.synthful.gwt.widgets.client
* .ui.ScrollableDialogBox.CloserEventHandler>>
*/
final public ArrayList<CloserEventHandler> CloserEventHandlers =
new ArrayList<CloserEventHandler>();
private class CloserHandler
implements CloserEventHandler
{
public void onClick(Event event) {
hide();
DOM.setStyleAttribute(closer.getElement(), "color", "black");
}
public void onMouseOver(Event event) {
DOM.setStyleAttribute(closer.getElement(), "color", "red");
}
public void onMouseOut(Event event) {
DOM.setStyleAttribute(closer.getElement(), "color", "black");
}
}
protected class CaptionTitle
extends HTML
implements Caption
{}
public FocusPanel getContentPanel() {
return contentPanel;
}
final public HorizontalPanel captionPanel = new HorizontalPanel();
final private Button closer = new Button("X");
final private FocusPanel contentPanel = new FocusPanel();
public int Width, Height;
protected CaptionTitle captionTitle;
}
Show details
Hide details
Change log
r91
by BlessedGeek on Jul 19, 2010
Diff
[No log message]
Go to:
...ient/ui/ScrollableDialogBox.java
...t/widgets/client/ui/UIPopup.java
...gwt/widgets/client/ui/UITab.java
.../client/ui/UITabLayoutPanel.java
...UnusableScrollableDialogBox.java
Project members,
sign in
to write a code review
Older revisions
r75
by BlessedGeek on Apr 8, 2010
Diff
[No log message]
r36
by BlessedGeek on Jul 18, 2009
Diff
[No log message]
r34
by BlessedGeek on Jul 10, 2009
Diff
[No log message]
All revisions of this file
File info
Size: 5182 bytes, 202 lines
View raw file
Powered by
Google Project Hosting