1
2
3
4
5
6
7
8
9
10
11
12
13
14 package net.sf.tacos.components.dojo.old;
15
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.apache.hivemind.ApplicationRuntimeException;
20 import org.apache.tapestry.AbstractComponent;
21 import org.apache.tapestry.IMarkupWriter;
22 import org.apache.tapestry.IRequestCycle;
23 import org.apache.tapestry.IScript;
24 import org.apache.tapestry.PageRenderSupport;
25 import org.apache.tapestry.TapestryUtils;
26 import org.apache.tapestry.dojo.DojoUtils;
27 import org.apache.tapestry.dojo.IWidget;
28 import org.apache.tapestry.json.JSONObject;
29
30
31
32
33
34
35
36
37 public abstract class FloatingPane extends AbstractComponent implements IWidget, IDojoFloatingPane
38 {
39
40 public abstract boolean getHasToolbar();
41
42
43 public abstract boolean isResizable();
44
45
46 public abstract boolean getPersistPosition();
47
48
49 public abstract String getIdParameter();
50
51
52 public abstract boolean getIsTaskBar();
53
54
55 public abstract String getOptions();
56
57
58 public abstract IScript getScript();
59
60
61 public String getTaskBarId()
62 {
63 Object obj = getTaskBar();
64 if (obj == null)
65 return null;
66 else if (obj instanceof String)
67 return (String)obj;
68 else if (obj instanceof FloatingPane)
69 return ((FloatingPane)obj).getIdParameter();
70 else
71 throw new ApplicationRuntimeException("Parameter taskBar should either be a String or a FloatingPane");
72 }
73
74
75
76
77 public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
78 {
79 renderComponent(writer, cycle);
80 }
81
82
83
84
85
86 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
87 {
88 writer.begin("div");
89 writer.attribute("id", getIdParameter());
90
91 renderInformalParameters(writer, cycle);
92 renderBody(writer, cycle);
93
94 writer.end();
95
96 JSONObject obj = DojoUtils.parseJSONParameter(this, "options");
97
98 obj.put("title", getTitle());
99 if (getIcon() != null)
100 obj.put("iconSrc", getIcon().buildURL());
101 if (getHref() != null)
102 obj.put("href", getHref());
103 obj.put("widgetId", getId());
104 obj.put("toggle", "fade");
105 obj.put("constrainToContainer", getConstrainToContainer());
106 obj.put("displayMaximizeAction", getDisplayMaximizeAction());
107 obj.put("displayMinimizeAction", getDisplayMinimizeAction());
108 obj.put("displayCloseAction", getDisplayCloseAction());
109 obj.put("hasShadow", getHasShadow());
110 obj.put("resizable", isResizable());
111 obj.put("taskBarId", getTaskBarId());
112
113
114
115 Map scriptParms = new HashMap();
116 scriptParms.put("id", getIdParameter());
117 scriptParms.put("props", obj.toString());
118 PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
119
120 getScript().execute(this, cycle, pageRenderSupport, scriptParms);
121 }
122 }