/* *************************************************************************
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.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."
+ "
Note the Properties selection on the top "
+ "right corner. Click it open to access component properties and"
+ " feel free to edit properties at any time."
+ "
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."
+ "
You may also change application's theme from below the menu."
+ " This example application is designed to work best with"
+ " Demo theme, other themes are for demonstration purposes only."
+ "
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."
+ "
For more information, point your browser to"
+ " www.itmill.com.";
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 Properties panel"
+ " located at the top right corner area.";
// TODO Add browser agent string
private String description = WELCOME_TEXT_LOWER
+ "
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;
}
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);
}
}
}
}