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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
/* *************************************************************************
IT Mill Toolkit
Development of Browser User Interfaces Made Easy
Copyright (C) 2000-2006 IT Mill Ltd
*************************************************************************
This product is distributed under commercial license that can be found
from the product package on license.pdf. Use of this product might
require purchasing a commercial license from IT Mill Ltd. For guidelines
on usage, see licensing-guidelines.html
*************************************************************************
For more information, contact:
IT Mill Ltd phone: +358 2 4802 7180
Ruukinkatu 2-4 fax: +358 2 4802 7181
20540, Turku email: info@itmill.com
Finland company www: www.itmill.com
Primary source for information and releases: www.itmill.com
********************************************************************** */
package com.itmill.toolkit.tests.featurebrowser;
import java.net.URL;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import com.itmill.toolkit.terminal.DownloadStream;
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
import com.itmill.toolkit.terminal.ParameterHandler;
import com.itmill.toolkit.terminal.URIHandler;
import com.itmill.toolkit.terminal.gwt.server.ApplicationServlet;
import com.itmill.toolkit.terminal.gwt.server.WebBrowser;
import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.Form;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Panel;
import com.itmill.toolkit.ui.Select;
public class IntroWelcome extends Feature implements URIHandler,
ParameterHandler {
private WebBrowser webBrowser = null;
Panel panel = new Panel();
private static final String WELCOME_TEXT_UPPER = ""
+ "This application lets you view and play with some features of "
+ "IT Mill Toolkit. Use menu on the left to select component."
+ "<br /><br />Note the <b>Properties selection</b> on the top "
+ "right corner. Click it open to access component properties and"
+ " feel free to edit properties at any time."
+ "<br /><br />The area that you are now reading is the component"
+ " demo area. Lower area from here contains component description, API"
+ " documentation and optional code sample. Note that not all selections"
+ " contain demo, only description and API documentation is shown."
+ "<br /><br />You may also change application's theme from below the menu."
+ " This example application is designed to work best with"
+ " <em>Demo</em> theme, other themes are for demonstration purposes only."
+ "<br /><br />IT Mill Toolkit enables you to construct complex Web"
+ " applications using plain Java, no knowledge of other Web technologies"
+ " such as XML, HTML, DOM, JavaScript or browser differences is required."
+ "<br /><br />For more information, point your browser to"
+ " <a href=\"http://www.itmill.com\" target=\"_new\">www.itmill.com</a>.";
private static final String WELCOME_TEXT_LOWER = ""
+ "This area contains the selected component's description, list of properties, javadoc"
+ " and optional code sample. "
+ "Start your tour now by selecting features from the list"
+ " on the left and remember to experiment with the <b>Properties panel</b>"
+ " located at the top right corner area.";
private String description = WELCOME_TEXT_LOWER
+ "<br /><br />IT Mill Toolkit version: "
+ ApplicationServlet.VERSION;
public IntroWelcome() {
super();
}
protected Component getDemoComponent() {
OrderedLayout l = new OrderedLayout();
panel.setCaption("Welcome to the IT Mill Toolkit feature tour!");
l.addComponent(panel);
Label label = new Label();
panel.addComponent(label);
label.setContentMode(Label.CONTENT_XHTML);
label.setValue(WELCOME_TEXT_UPPER);
propertyPanel = new PropertyPanel(panel);
Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
"height" });
Select themes = (Select) propertyPanel.getField("style");
themes.addItem("light").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("light");
themes.addItem("strong").getItemProperty(
themes.getItemCaptionPropertyId()).setValue("strong");
propertyPanel.addProperties("Panel Properties", ap);
setJavadocURL("package-summary.html");
setPropsReminder(false);
return l;
}
protected String getExampleSrc() {
return ""
+ "package com.itmill.toolkit.demo;\n"
+ "import com.itmill.toolkit.ui.*;\n\n"
+ "public class HelloWorld extends com.itmill.toolkit.Application {\n"
+ " public void init() {\n"
+ " Window main = new Window(\"Hello window\");\n"
+ " setMainWindow(main);\n"
+ " main.addComponent(new Label(\"Hello World!\"));\n"
+ " }\n" + "}\n";
}
// not ready yet to give description, see paint instead
protected String getDescriptionXHTML() {
return description;
}
// Hack for #512: set description right (WebBrowser now exists)
public void paint(PaintTarget target) throws PaintException {
if (webBrowser == null) {
webBrowser = (WebBrowser) getWindow().getTerminal();
if (webBrowser != null) {
super.getDescription().setValue(
description + "<br />Browser: "
+ webBrowser.getBrowserApplication());
try {
FeatureUtil.debug(getApplication().getUser().toString(),
"timestamp=[" + FeatureUtil.getTimestamp()
+ "] userAgent=["
+ webBrowser.getBrowserApplication() + "]");
} catch (Exception e) {
// ignored, should never happen
}
}
}
super.paint(target);
}
protected String getImage() {
return "icon_intro.png";
}
protected String getTitle() {
return "Welcome";
}
/**
* Add URI and parametes handlers to window.
*
* @see com.itmill.toolkit.ui.Component#attach()
*/
public void attach() {
super.attach();
getWindow().addURIHandler(this);
getWindow().addParameterHandler(this);
}
/**
* Remove all handlers from window
*
* @see com.itmill.toolkit.ui.Component#detach()
*/
public void detach() {
super.detach();
getWindow().removeURIHandler(this);
getWindow().removeParameterHandler(this);
}
/**
* Update URI
*
* @see com.itmill.toolkit.terminal.URIHandler#handleURI(URL, String)
*/
public DownloadStream handleURI(URL context, String relativeUri) {
return null;
}
/**
* Show system status if systemStatus is given on URL
*
* @see com.itmill.toolkit.terminal.ParameterHandler#handleParameters(Map)
*/
public void handleParameters(Map parameters) {
for (Iterator i = parameters.keySet().iterator(); i.hasNext();) {
String name = (String) i.next();
if (name.equals("systemStatus")) {
String status = "";
status += "timestamp=" + new Date() + " ";
status += "free=" + Runtime.getRuntime().freeMemory() + ", ";
status += "total=" + Runtime.getRuntime().totalMemory() + ", ";
status += "max=" + Runtime.getRuntime().maxMemory() + "\n";
System.out.println(status);
}
}
}
}
|