]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed #325 (Ensure availability of Toolkit website)
authorJani Laakso <jani.laakso@itmill.com>
Wed, 14 Mar 2007 15:00:28 +0000 (15:00 +0000)
committerJani Laakso <jani.laakso@itmill.com>
Wed, 14 Mar 2007 15:00:28 +0000 (15:00 +0000)
All relevant code is under try catch block. Activated by setting "statistics" parameter on ServletContainer (web.xml).

svn changeset:903/svn branch:trunk

src/com/itmill/toolkit/demo/features/FeatureBrowser.java
src/com/itmill/toolkit/demo/features/FeatureUtil.java [new file with mode: 0644]
src/com/itmill/toolkit/demo/features/FeaturesApplication.java
src/com/itmill/toolkit/demo/features/IntroWelcome.java
src/com/itmill/toolkit/demo/features/PropertyPanel.java

index 8d63a162d0d90e4cd5625f8666196e800c6a2396..c79ca6f782af94505e58b81338ca1b77aeeff5a4 100644 (file)
@@ -188,6 +188,22 @@ public class FeatureBrowser extends CustomComponent implements
 
        public void valueChange(Property.ValueChangeEvent event) {
 
+               // FIXME: navigation statistics
+               try {
+                       if ((event.getProperty().toString() == null)
+                                       && ((AbstractComponent) event.getProperty()).getTag()
+                                                       .equals("tree")) {
+                               // ignore tree initialization
+                       } else {
+                               FeatureUtil.debug(getApplication().getUser().toString(),
+                                               "valueChange "
+                                                               + ((AbstractComponent) event.getProperty())
+                                                                               .getTag() + ", " + event.getProperty());
+                       }
+               } catch (Exception e) {
+                       // ignored, should never happen
+               }
+
                // Change feature
                if (event.getProperty() == features) {
                        Object id = features.getValue();
@@ -224,6 +240,16 @@ public class FeatureBrowser extends CustomComponent implements
        }
 
        public void buttonClick(ClickEvent event) {
+               // FIXME: navigation statistics
+               try {
+                       FeatureUtil.debug(getApplication().getUser().toString(),
+                                       "buttonClick " + event.getButton().getTag() + ", "
+                                                       + event.getButton().getCaption() + ", "
+                                                       + event.getButton().getValue());
+               } catch (Exception e) {
+                       // ignored, should never happen
+               }
+
                if (properties != null)
                        properties.setVisible(((Boolean) propertiesSelect.getValue())
                                        .booleanValue());
diff --git a/src/com/itmill/toolkit/demo/features/FeatureUtil.java b/src/com/itmill/toolkit/demo/features/FeatureUtil.java
new file mode 100644 (file)
index 0000000..91dbfbd
--- /dev/null
@@ -0,0 +1,31 @@
+package com.itmill.toolkit.demo.features;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class FeatureUtil {
+
+       private static boolean statistics = false;
+
+       public static final SimpleDateFormat format = new SimpleDateFormat(
+                       "yyyyMMdd HHmmss");
+
+       public static void debug(String userIdentity, String msg) {
+               if (statistics)
+                       System.out.println("[" + userIdentity + "] " + msg);
+       }
+
+       public static String getTimestamp() {
+               if (statistics)
+                       try {
+                               return format.format(new Date());
+                       } catch (Exception e) {
+                               // ignored, should never happen
+                       }
+               return "";
+       }
+
+       public static void setStatistics(boolean statistics) {
+               FeatureUtil.statistics = statistics;
+       }
+}
index 74c61f60d7a3d897eec90c61a96b5168d1ab9403..070cf9ef4ff871f62c4e5b68f976733726b4356d 100644 (file)
@@ -33,6 +33,9 @@ import com.itmill.toolkit.ui.*;
 public class FeaturesApplication extends com.itmill.toolkit.Application {
 
        public void init() {
+               if (getProperty("statistics") != null)
+                       FeatureUtil.setStatistics(true);
+               setUser(new Long(System.currentTimeMillis()).toString());
                Window main = new Window("IT Mill Toolkit Features Tour");
                setMainWindow(main);
                main.addComponent(new FeatureBrowser());
@@ -44,6 +47,8 @@ public class FeaturesApplication extends com.itmill.toolkit.Application {
        public void terminalError(
                        com.itmill.toolkit.terminal.Terminal.ErrorEvent event) {
                Throwable e = event.getThrowable();
+               FeatureUtil.debug(getUser().toString(), "terminalError: "
+                               + e.toString());
                e.printStackTrace();
        }
 
index 280039c6b8bec5ae2fb285785f3a2c557c50c525..75a643e1c4f99e05eb0988f83f72ac8685b44f91 100644 (file)
@@ -143,6 +143,14 @@ public class IntroWelcome extends Feature implements URIHandler,
                                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);
index 759d30de0ebf8253cf21971bf627d85977c55eb5..22ab4a5ac3966a39f69283ed77311943129af562 100644 (file)
@@ -55,7 +55,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
        private Button setButton = new Button("Set", this);
 
        private Button discardButton = new Button("Discard changes", this);
-       
+
        private Table allProperties = new Table();
 
        private Object objectToConfigure;
@@ -125,23 +125,6 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                updatePropertyList();
        }
 
-       /** Handle all button clicks for this panel */
-       public void buttonClick(Button.ClickEvent event) {
-
-               // Commit all changed on all forms
-               if (event.getButton() == setButton) {
-                       for (Iterator i = forms.iterator(); i.hasNext();)
-                               ((Form) i.next()).commit();
-               }
-
-               // Discard all changed on all forms
-               if (event.getButton() == discardButton) {
-                       for (Iterator i = forms.iterator(); i.hasNext();)
-                               ((Form) i.next()).discard();
-               }
-
-       }
-
        /** Recreate property list contents */
        public void updatePropertyList() {
 
@@ -351,6 +334,16 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
        /** Value change listener for listening selections */
        public void valueChange(Property.ValueChangeEvent event) {
 
+               // FIXME: navigation statistics
+               try {
+                       FeatureUtil.debug(getApplication().getUser().toString(),
+                                       "valueChange "
+                                                       + ((AbstractComponent) event.getProperty())
+                                                                       .getTag() + ", " + event.getProperty());
+               } catch (Exception e) {
+                       // ignored, should never happen
+               }
+
                // Adding components to component container
                if (event.getProperty() == addComponent) {
                        String value = (String) addComponent.getValue();
@@ -416,6 +409,31 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                }
        }
 
+       /** Handle all button clicks for this panel */
+       public void buttonClick(Button.ClickEvent event) {
+               // FIXME: navigation statistics
+               try {
+                       FeatureUtil.debug(getApplication().getUser().toString(),
+                                       "buttonClick " + event.getButton().getTag() + ", "
+                                                       + event.getButton().getCaption() + ", "
+                                                       + event.getButton().getValue());
+               } catch (Exception e) {
+                       // ignored, should never happen
+               }
+               // Commit all changed on all forms
+               if (event.getButton() == setButton) {
+                       for (Iterator i = forms.iterator(); i.hasNext();)
+                               ((Form) i.next()).commit();
+               }
+
+               // Discard all changed on all forms
+               if (event.getButton() == discardButton) {
+                       for (Iterator i = forms.iterator(); i.hasNext();)
+                               ((Form) i.next()).discard();
+               }
+
+       }
+
        /**
         * Helper function for creating forms from array of propety names.
         */