1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
package org.apache.tapestry.dojo.html; |
15 |
|
|
16 |
|
import org.apache.tapestry.IMarkupWriter; |
17 |
|
import org.apache.tapestry.IRequestCycle; |
18 |
|
import org.apache.tapestry.IScript; |
19 |
|
import org.apache.tapestry.TapestryUtils; |
20 |
|
import org.apache.tapestry.dojo.AbstractWidget; |
21 |
|
import org.apache.tapestry.json.JSONObject; |
22 |
|
import org.apache.tapestry.services.ResponseBuilder; |
23 |
|
|
24 |
|
import java.util.HashMap; |
25 |
|
import java.util.Map; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
0 |
public abstract class Dialog extends AbstractWidget |
33 |
|
{ |
34 |
|
public abstract boolean isHidden(); |
35 |
|
public abstract void setHidden(boolean hidden); |
36 |
|
|
37 |
|
public abstract String getBackgroundColor(); |
38 |
|
|
39 |
|
public abstract float getOpacity(); |
40 |
|
|
41 |
|
public abstract boolean getFollowScroll(); |
42 |
|
|
43 |
|
public abstract boolean getCloseOnBackgroundClick(); |
44 |
|
|
45 |
|
public abstract int getBlockDuration(); |
46 |
|
|
47 |
|
public abstract int getLifeTime(); |
48 |
|
|
49 |
|
public abstract String getToggle(); |
50 |
|
|
51 |
|
public abstract int getToggleDuration(); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
public void resize() |
59 |
|
{ |
60 |
0 |
setResizing(true); |
61 |
0 |
} |
62 |
|
|
63 |
|
public void show() |
64 |
|
{ |
65 |
0 |
setHidden(false); |
66 |
0 |
} |
67 |
|
|
68 |
|
public void hide() |
69 |
|
{ |
70 |
0 |
setHidden(true); |
71 |
0 |
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
public void renderWidget(IMarkupWriter writer, IRequestCycle cycle) |
77 |
|
{ |
78 |
0 |
if (!cycle.isRewinding()) |
79 |
|
{ |
80 |
0 |
writer.begin(getTemplateTagName()); |
81 |
0 |
renderIdAttribute(writer, cycle); |
82 |
0 |
renderInformalParameters(writer, cycle); |
83 |
|
} |
84 |
|
|
85 |
0 |
renderBody(writer, cycle); |
86 |
|
|
87 |
0 |
if (!cycle.isRewinding()) |
88 |
0 |
writer.end(); |
89 |
|
|
90 |
0 |
if (!cycle.isRewinding()) |
91 |
|
{ |
92 |
0 |
JSONObject json = new JSONObject(); |
93 |
0 |
json.put("bgColor", getBackgroundColor()); |
94 |
0 |
json.put("bgOpacity", getOpacity()); |
95 |
0 |
json.put("followScroll", getFollowScroll()); |
96 |
0 |
json.put("closeOnBackgroundClick", getCloseOnBackgroundClick()); |
97 |
0 |
json.put("blockDuration", getBlockDuration()); |
98 |
0 |
json.put("lifeTime", getLifeTime()); |
99 |
0 |
json.put("toggle", getToggle()); |
100 |
0 |
json.put("toggleDuration", getToggleDuration()); |
101 |
|
|
102 |
0 |
Map parms = new HashMap(); |
103 |
0 |
parms.put("component", this); |
104 |
0 |
parms.put("props", json.toString()); |
105 |
|
|
106 |
0 |
getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms); |
107 |
|
|
108 |
0 |
if (isResizing()) |
109 |
|
{ |
110 |
0 |
if (!getResponseBuilder().isInitializationScriptAllowed(this)) |
111 |
|
{ |
112 |
0 |
getResponseBuilder().updateComponent(getId()); |
113 |
|
} |
114 |
|
|
115 |
0 |
getResponseBuilder().addScriptAfterInitialization(this, "dojo.widget.byId('" + getClientId() + "').checkSize();"); |
116 |
|
} |
117 |
|
} |
118 |
0 |
} |
119 |
|
|
120 |
|
public abstract ResponseBuilder getResponseBuilder(); |
121 |
|
|
122 |
|
public abstract boolean isResizing(); |
123 |
|
|
124 |
|
public abstract void setResizing(boolean value); |
125 |
|
|
126 |
|
|
127 |
|
public abstract IScript getScript(); |
128 |
|
} |