From: Jani Laakso Date: Wed, 14 Mar 2007 00:00:10 +0000 (+0000) Subject: User agent is now showed on first request. Added also system status reporting (memory... X-Git-Tag: 6.7.0.beta1~6527 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9585067b8a1bed8d6c2d98ed7c7cb37cb3529923;p=vaadin-framework.git User agent is now showed on first request. Added also system status reporting (memory resources) which is used to track demo application healthiness on production site. svn changeset:882/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/features/Feature.java b/src/com/itmill/toolkit/demo/features/Feature.java index dd4cfeae79..9c86211186 100644 --- a/src/com/itmill/toolkit/demo/features/Feature.java +++ b/src/com/itmill/toolkit/demo/features/Feature.java @@ -52,6 +52,8 @@ public abstract class Feature extends CustomComponent { protected PropertyPanel propertyPanel; private Label javadoc; + + private Label description; /** Constuctor for the feature component */ public Feature() { @@ -94,9 +96,8 @@ public abstract class Feature extends CustomComponent { 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( @@ -106,14 +107,15 @@ public abstract class Feature extends CustomComponent { 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("

" + title + "

", 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); } @@ -181,5 +183,18 @@ public abstract class Feature extends CustomComponent { 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 diff --git a/src/com/itmill/toolkit/demo/features/IntroWelcome.java b/src/com/itmill/toolkit/demo/features/IntroWelcome.java index 539b60ffe6..a970b2339e 100644 --- a/src/com/itmill/toolkit/demo/features/IntroWelcome.java +++ b/src/com/itmill/toolkit/demo/features/IntroWelcome.java @@ -28,16 +28,33 @@ 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 " @@ -60,13 +77,15 @@ public class IntroWelcome extends Feature { private static final String WELCOME_TEXT_LOWER = "" + "This area contains the selected component's description, list of properties, javadoc" - + " and optional code sample." - + "

To see how simple it is to create IT Mill Toolkit application," - + " click Code Sample tab." - + "

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 Properties panel" + " located at the top right corner area."; + private String description = WELCOME_TEXT_LOWER + + "

IT Mill Toolkit version: " + + ApplicationServlet.VERSION; + public IntroWelcome() { super(); } @@ -75,7 +94,6 @@ public class IntroWelcome extends Feature { OrderedLayout l = new OrderedLayout(); - Panel panel = new Panel(); panel.setCaption("Welcome to the IT Mill Toolkit feature tour!"); l.addComponent(panel); @@ -85,8 +103,6 @@ public class IntroWelcome extends Feature { 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" }); @@ -116,14 +132,22 @@ public class IntroWelcome extends Feature { + " }\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 + "

IT Mill Toolkit version: " - + ApplicationServlet.VERSION + - (wb != null ? "
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 + "
Browser: " + + webBrowser.getBrowserApplication()); + } + } + super.paint(target); } protected String getImage() { @@ -134,4 +158,54 @@ public class IntroWelcome extends Feature { 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); + } + } + } + }