protected PropertyPanel propertyPanel;
private Label javadoc;
+
+ private Label description;
/** Constuctor for the feature component */
public Feature() {
ts = new TabSheet();
// Description tab
- String desc = getDescriptionXHTML();
String title = getTitle();
- if (desc != null) {
+ if (getDescriptionXHTML() != null) {
OrderedLayout mainLayout = new OrderedLayout(
OrderedLayout.ORIENTATION_VERTICAL);
OrderedLayout layout = new OrderedLayout(
layout.addComponent(new Embedded("", new ClassResource(
getImage(), this.getApplication())));
String label = "";
- label += desc;
+ label += getDescriptionXHTML();
if (propsReminder)
label += PROP_REMINDER_TEXT;
if (title != null) {
layout.addComponent(new Label("<h3>" + title + "</h3>",
Label.CONTENT_XHTML));
}
- mainLayout.addComponent(new Label(label, Label.CONTENT_XHTML));
+ description = new Label(label, Label.CONTENT_XHTML);
+ mainLayout.addComponent(description);
ts.addTab(mainLayout, "Description", null);
}
public void setPropsReminder(boolean propsReminder) {
this.propsReminder = propsReminder;
}
+
+ public void updateDescription() {
+ String label = "";
+ label += getDescriptionXHTML();
+ if (propsReminder)
+ label += PROP_REMINDER_TEXT;
+ description.setValue(label);
+ }
+
+ // Fix for #512
+ public Label getDescription() {
+ return description;
+ }
}
\ No newline at end of file
package com.itmill.toolkit.demo.features;
+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.ExternalResource;
+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.web.ApplicationServlet;
import com.itmill.toolkit.terminal.web.WebBrowser;
import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.Form;
import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.Link;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Panel;
import com.itmill.toolkit.ui.Select;
-public class IntroWelcome extends Feature {
+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 "
private static final String WELCOME_TEXT_LOWER = ""
+ "This area contains the selected component's description, list of properties, javadoc"
- + " and optional code sample."
- + "<br /><br />To see how simple it is to create IT Mill Toolkit application,"
- + " click <em>Code Sample</em> tab."
- + "<br /><br />Start your tour now by selecting features from the list"
+ + " 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();
}
OrderedLayout l = new OrderedLayout();
- Panel panel = new Panel();
panel.setCaption("Welcome to the IT Mill Toolkit feature tour!");
l.addComponent(panel);
label.setContentMode(Label.CONTENT_XHTML);
label.setValue(WELCOME_TEXT_UPPER);
- // Propertiesversion.setValue("IT Mill Toolkit version:
- // "+ApplicationServlet.VERSION);
propertyPanel = new PropertyPanel(panel);
Form ap = propertyPanel.createBeanPropertySet(new String[] { "width",
"height" });
+ " }\n" + "}\n";
}
- /**
- * @see com.itmill.toolkit.demo.features.Feature#getDescriptionXHTML()
- */
+ // not ready yet to give description, see paint instead
protected String getDescriptionXHTML() {
- WebBrowser wb = (WebBrowser) getWindow().getTerminal();
- return WELCOME_TEXT_LOWER + "<br /><br />IT Mill Toolkit version: "
- + ApplicationServlet.VERSION +
- (wb != null ? "<br />Browser: " + wb.getBrowserApplication(): "");
+ 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());
+ }
+ }
+ super.paint(target);
}
protected String getImage() {
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);
+ }
+ }
+ }
+
}