]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge remote branch 'origin/databinding'
authorLeif Åstrand <leif@vaadin.com>
Thu, 8 Dec 2011 14:57:07 +0000 (16:57 +0200)
committerLeif Åstrand <leif@vaadin.com>
Thu, 8 Dec 2011 14:57:07 +0000 (16:57 +0200)
Conflicts:
src/com/vaadin/Application.java
src/com/vaadin/ui/AbstractField.java
tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
tests/testbench/com/vaadin/tests/tickets/Ticket1673.java

36 files changed:
1  2 
src/com/vaadin/Application.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/ui/AbstractComponent.java
tests/testbench/com/vaadin/tests/CustomLayoutDemo.java
tests/testbench/com/vaadin/tests/TestForStyledUpload.java
tests/testbench/com/vaadin/tests/UpgradingSample.java
tests/testbench/com/vaadin/tests/VaadinClasses.java
tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java
tests/testbench/com/vaadin/tests/components/window/LazyWindowResize.java
tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
tests/testbench/com/vaadin/tests/dd/DDTest2.java
tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java
tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java
tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java
tests/testbench/com/vaadin/tests/tickets/Ticket1245.java
tests/testbench/com/vaadin/tests/tickets/Ticket1397.java
tests/testbench/com/vaadin/tests/tickets/Ticket1673.java
tests/testbench/com/vaadin/tests/tickets/Ticket1804.java
tests/testbench/com/vaadin/tests/tickets/Ticket1819.java
tests/testbench/com/vaadin/tests/tickets/Ticket1878.java
tests/testbench/com/vaadin/tests/tickets/Ticket1900.java
tests/testbench/com/vaadin/tests/tickets/Ticket1919.java
tests/testbench/com/vaadin/tests/tickets/Ticket1921.java
tests/testbench/com/vaadin/tests/tickets/Ticket20.java
tests/testbench/com/vaadin/tests/tickets/Ticket2053.java
tests/testbench/com/vaadin/tests/tickets/Ticket2090.java
tests/testbench/com/vaadin/tests/tickets/Ticket2107.java
tests/testbench/com/vaadin/tests/tickets/Ticket2119.java
tests/testbench/com/vaadin/tests/tickets/Ticket2151.java
tests/testbench/com/vaadin/tests/tickets/Ticket2179.java
tests/testbench/com/vaadin/tests/tickets/Ticket2204.java
tests/testbench/com/vaadin/tests/tickets/Ticket2998.java
tests/testbench/com/vaadin/tests/tickets/Ticket677.java
tests/testbench/com/vaadin/tests/tickets/Ticket736.java
tests/testbench/com/vaadin/tests/tickets/Ticket846.java

index 13c8269469b9ea313bcb7e435b24111aaebe321b,c96a0adc6adbc0a36ab79ebdc033e734a996b9ea..42c4b572a15a046cb36668c12f0bf42258b08e74
@@@ -16,41 -12,31 +16,45 @@@ import java.util.Collections
  import java.util.Enumeration;
  import java.util.EventListener;
  import java.util.EventObject;
 +import java.util.HashMap;
 +import java.util.HashSet;
  import java.util.Hashtable;
 -import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.Locale;
 +import java.util.Map;
 +import java.util.Map.Entry;
  import java.util.Properties;
 +import java.util.Set;
 +import java.util.WeakHashMap;
  import java.util.logging.Level;
  import java.util.logging.Logger;
 +import java.util.regex.Matcher;
 +import java.util.regex.Pattern;
  
 +import com.vaadin.annotations.RootInitRequiresBrowserDetals;
 +import com.vaadin.annotations.RootTheme;
 +import com.vaadin.annotations.RootWidgetset;
+ import com.vaadin.data.util.converter.Converter;
+ import com.vaadin.data.util.converter.ConverterFactory;
+ import com.vaadin.data.util.converter.DefaultConverterFactory;
  import com.vaadin.service.ApplicationContext;
  import com.vaadin.terminal.ApplicationResource;
 -import com.vaadin.terminal.DownloadStream;
 +import com.vaadin.terminal.CombinedRequest;
  import com.vaadin.terminal.ErrorMessage;
 -import com.vaadin.terminal.ParameterHandler;
 +import com.vaadin.terminal.RequestHandler;
  import com.vaadin.terminal.SystemError;
  import com.vaadin.terminal.Terminal;
 -import com.vaadin.terminal.URIHandler;
  import com.vaadin.terminal.VariableOwner;
 +import com.vaadin.terminal.WrappedRequest;
 +import com.vaadin.terminal.WrappedRequest.BrowserDetails;
 +import com.vaadin.terminal.WrappedResponse;
 +import com.vaadin.terminal.gwt.client.ApplicationConnection;
 +import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
  import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent;
 -import com.vaadin.terminal.gwt.server.PortletApplicationContext;
  import com.vaadin.terminal.gwt.server.WebApplicationContext;
  import com.vaadin.ui.AbstractComponent;
+ import com.vaadin.ui.AbstractField;
 +import com.vaadin.ui.Root;
  import com.vaadin.ui.Window;
  
  /**
@@@ -512,33 -192,245 +516,40 @@@ public class Application implements Ter
       */
      private Terminal.ErrorListener errorHandler = this;
  
 -    /**
 -     * <p>
 -     * Gets a window by name. Returns <code>null</code> if the application is
 -     * not running or it does not contain a window corresponding to the name.
 -     * </p>
 -     * 
 -     * <p>
 -     * All windows can be referenced by their names in url
 -     * <code>http://host:port/foo/bar/</code> where
 -     * <code>http://host:port/foo/</code> is the application url as returned by
 -     * getURL() and <code>bar</code> is the name of the window.
 -     * </p>
 -     * 
 -     * <p>
 -     * One should note that this method can, as a side effect create new windows
 -     * if needed by the application. This can be achieved by overriding the
 -     * default implementation.
 -     * </p>
 -     * 
 -     * <p>
 -     * If for some reason user opens another window with same url that is
 -     * already open, name is modified by adding "_12345678" postfix to the name,
 -     * where 12345678 is a random number. One can decide to create another
 -     * window-object for those windows (recommended) or to discard the postfix.
 -     * If the user has two browser windows pointing to the same window-object on
 -     * server, synchronization errors are likely to occur.
 -     * </p>
 -     * 
 -     * <p>
 -     * If no browser-level windowing is used, all defaults are fine and this
 -     * method can be left as is. In case browser-level windows are needed, it is
 -     * recommended to create new window-objects on this method from their names
 -     * if the super.getWindow() does not find existing windows. See below for
 -     * implementation example: <code><pre>
 -        // If we already have the requested window, use it
 -        Window w = super.getWindow(name);
 -        if (w == null) {
 -            // If no window found, create it
 -            w = new Window(name);
 -            // set windows name to the one requested
 -            w.setName(name);
 -            // add it to this application
 -            addWindow(w);
 -            // ensure use of window specific url
 -            w.open(new ExternalResource(w.getURL().toString()));
 -            // add some content
 -            w.addComponent(new Label("Test window"));
 -        }
 -        return w;</pre></code>
 -     * </p>
 -     * 
 -     * <p>
 -     * <strong>Note</strong> that all returned Window objects must be added to
 -     * this application instance.
 -     * 
 -     * <p>
 -     * The method should return null if the window does not exists (and is not
 -     * created as a side-effect) or if the application is not running anymore.
 -     * </p>
 -     * 
 -     * @param name
 -     *            the name of the window.
 -     * @return the window associated with the given URI or <code>null</code>
 -     */
 -    public Window getWindow(String name) {
 -
 -        // For closed app, do not give any windows
 -        if (!isRunning()) {
 -            return null;
 -        }
+     /**
+      * The converter factory that is used for all fields in the application.
+      */
+     // private ConverterFactory converterFactory = new
+     // DefaultConverterFactory();
+     private static ConverterFactory converterFactory = new DefaultConverterFactory();
 +    private LinkedList<RequestHandler> requestHandlers = new LinkedList<RequestHandler>();
  
 -        // Gets the window by name
 -        final Window window = windows.get(name);
 +    private int nextRootId = 0;
 +    private Map<Integer, Root> roots = new HashMap<Integer, Root>();
  
 -        return window;
 -    }
 +    private boolean productionMode = true;
  
      /**
 -     * Adds a new window to the application.
 -     * 
 -     * <p>
 -     * This implicitly invokes the
 -     * {@link com.vaadin.ui.Window#setApplication(Application)} method.
 -     * </p>
 -     * 
 -     * <p>
 -     * Note that all application-level windows can be accessed by their names in
 -     * url <code>http://host:port/foo/bar/</code> where
 -     * <code>http://host:port/foo/</code> is the application url as returned by
 -     * getURL() and <code>bar</code> is the name of the window. Also note that
 -     * not all windows should be added to application - one can also add windows
 -     * inside other windows - these windows show as smaller windows inside those
 -     * windows.
 -     * </p>
 -     * 
 -     * @param window
 -     *            the new <code>Window</code> to add. If the name of the window
 -     *            is <code>null</code>, an unique name is automatically given
 -     *            for the window.
 -     * @throws IllegalArgumentException
 -     *             if a window with the same name as the new window already
 -     *             exists in the application.
 -     * @throws NullPointerException
 -     *             if the given <code>Window</code> is <code>null</code>.
 -     */
 -    public void addWindow(Window window) throws IllegalArgumentException,
 -            NullPointerException {
 -
 -        // Nulls can not be added to application
 -        if (window == null) {
 -            return;
 -        }
 -
 -        // Check that one is not adding a sub-window to application
 -        if (window.getParent() != null) {
 -            throw new IllegalArgumentException(
 -                    "Window was already added inside another window"
 -                            + " - it can not be added to application also.");
 -        }
 -
 -        // Gets the naming proposal from window
 -        String name = window.getName();
 -
 -        // Checks that the application does not already contain
 -        // window having the same name
 -        if (name != null && windows.containsKey(name)) {
 -
 -            // If the window is already added
 -            if (window == windows.get(name)) {
 -                return;
 -            }
 -
 -            // Otherwise complain
 -            throw new IllegalArgumentException("Window with name '"
 -                    + window.getName()
 -                    + "' is already present in the application");
 -        }
 -
 -        // If the name of the window is null, the window is automatically named
 -        if (name == null) {
 -            boolean accepted = false;
 -            while (!accepted) {
 -
 -                // Try another name
 -                synchronized (this) {
 -                    name = String.valueOf(nextWindowId);
 -                    nextWindowId++;
 -                }
 -
 -                if (!windows.containsKey(name)) {
 -                    accepted = true;
 -                }
 -            }
 -            window.setName(name);
 -        }
 -
 -        // Adds the window to application
 -        windows.put(name, window);
 -        window.setApplication(this);
 -
 -        fireWindowAttachEvent(window);
 -
 -        // If no main window is set, declare the window to be main window
 -        if (getMainWindow() == null) {
 -            mainWindow = window;
 -        }
 -    }
 +     * Keeps track of requests for which a root should be created once more
 +     * information is available.
 +     */
 +    private Map<Integer, PendingRootRequest> pendingRoots = new HashMap<Integer, PendingRootRequest>();
  
      /**
 -     * Send information to all listeners about new Windows associated with this
 -     * application.
 -     * 
 -     * @param window
 +     * Keeps track of the roots that should be remembered when the browser is
 +     * refreshed.
       */
 -    private void fireWindowAttachEvent(Window window) {
 -        // Fires the window attach event
 -        if (windowAttachListeners != null) {
 -            final Object[] listeners = windowAttachListeners.toArray();
 -            final WindowAttachEvent event = new WindowAttachEvent(window);
 -            for (int i = 0; i < listeners.length; i++) {
 -                ((WindowAttachListener) listeners[i]).windowAttached(event);
 -            }
 -        }
 -    }
 +    private Map<String, Integer> retainOnRefreshRoots = new WeakHashMap<String, Integer>();
  
      /**
 -     * Removes the specified window from the application.
 -     * 
 -     * <p>
 -     * Removing the main window of the Application also sets the main window to
 -     * null. One must another window to be the main window after this with
 -     * {@link #setMainWindow(Window)}.
 -     * </p>
 -     * 
 +     * Keeps track of which roots have been inited.
       * <p>
 -     * Note that removing window from the application does not close the browser
 -     * window - the window is only removed from the server-side.
 +     * TODO Investigate whether this might be derived from the different states
 +     * in getRootForRrequest.
       * </p>
 -     * 
 -     * @param window
 -     *            the window to be removed.
       */
 -    public void removeWindow(Window window) {
 -        if (window != null && windows.contains(window)) {
 -
 -            // Removes the window from application
 -            windows.remove(window.getName());
 -
 -            // If the window was main window, clear it
 -            if (getMainWindow() == window) {
 -                setMainWindow(null);
 -            }
 -
 -            // Removes the application from window
 -            if (window.getApplication() == this) {
 -                window.setApplication(null);
 -            }
 -
 -            fireWindowDetachEvent(window);
 -        }
 -    }
 -
 -    private void fireWindowDetachEvent(Window window) {
 -        // Fires the window detach event
 -        if (windowDetachListeners != null) {
 -            final Object[] listeners = windowDetachListeners.toArray();
 -            final WindowDetachEvent event = new WindowDetachEvent(window);
 -            for (int i = 0; i < listeners.length; i++) {
 -                ((WindowDetachListener) listeners[i]).windowDetached(event);
 -            }
 -        }
 -    }
 +    private Set<Integer> initedRoots = new HashSet<Integer>();
  
      /**
       * Gets the user of the application.
index 0f482b3ed1e074928100d29b2150dd7c6c0ecda1,7fac9e442e5a218b60190f1dc7f2e07ea26c0e1e..c1cbcf0e85ca2dbb049624be15a1f135e16de832
@@@ -17,14 -17,13 +17,13 @@@ import com.vaadin.data.util.sqlcontaine
  import com.vaadin.data.util.sqlcontainer.query.TableQuery;
  import com.vaadin.ui.Button;
  import com.vaadin.ui.Button.ClickEvent;
- import com.vaadin.ui.Button.ClickListener;
  import com.vaadin.ui.Form;
  import com.vaadin.ui.HorizontalSplitPanel;
 +import com.vaadin.ui.Root;
  import com.vaadin.ui.Table;
 -import com.vaadin.ui.Window;
  
 -public class CheckboxUpdateProblem extends Application implements
 -        Property.ValueChangeListener {
 +public class CheckboxUpdateProblem extends Application.LegacyApplication
 +        implements Property.ValueChangeListener {
      private final DatabaseHelper databaseHelper = new DatabaseHelper();
      private Table testList;
      private final HorizontalSplitPanel horizontalSplit = new HorizontalSplitPanel();
          }
      }
  
--}
++}
index de255e0b5435ba75040f95868a57eaae6c79b73b,59673671c77092bd864f980921670fc9f7decd0f..61f05cea63fc755fda12b55f264332a9f8773d76
@@@ -594,9 -593,9 +594,9 @@@ public class LiferayThemeDemo extends A
                  new Button.ClickListener() {
                      public void buttonClick(ClickEvent event) {
                          event.getButton()
 -                                .getWindow()
 +                                .getRoot()
-                                 .showNotification((String) title.getValue(),
-                                         (String) message.getValue());
+                                 .showNotification(title.getValue(),
+                                         message.getValue());
  
                      }
                  });
          show = new Button("Warning Notification", new Button.ClickListener() {
              public void buttonClick(ClickEvent event) {
                  event.getButton()
 -                        .getWindow()
 +                        .getRoot()
-                         .showNotification((String) title.getValue(),
-                                 (String) message.getValue(),
+                         .showNotification(title.getValue(), message.getValue(),
                                  Notification.TYPE_WARNING_MESSAGE);
  
              }
          show = new Button("Error Notification", new Button.ClickListener() {
              public void buttonClick(ClickEvent event) {
                  event.getButton()
 -                        .getWindow()
 +                        .getRoot()
-                         .showNotification((String) title.getValue(),
-                                 (String) message.getValue(),
+                         .showNotification(title.getValue(), message.getValue(),
                                  Notification.TYPE_ERROR_MESSAGE);
  
              }
          show = new Button("Tray Notification", new Button.ClickListener() {
              public void buttonClick(ClickEvent event) {
                  event.getButton()
 -                        .getWindow()
 +                        .getRoot()
-                         .showNotification((String) title.getValue(),
-                                 (String) message.getValue(),
+                         .showNotification(title.getValue(), message.getValue(),
                                  Notification.TYPE_TRAY_NOTIFICATION);
  
              }
index 22f78d18b1a1835be68de3d02694038415d2df6d,a0dc53cd88c8806a0ee4ac61af5f8b2aa4a40179..6f86fc223eab48a4a5258d37e7c3cd06d8900eca
@@@ -90,4 -92,4 +92,4 @@@ class TreeExample extends CustomCompone
          return id;\r
      }\r
  \r
--}
++}
index aa173ea684c047255dc07ea18e8285ca693ce032,6843359d8f7cba91af0b1ebe9a7935f4718db2a0..96cfd7cfdc81b414fcbcc3294e4eebda024c6c35
@@@ -2,17 -2,22 +2,22 @@@ package com.vaadin.tests.tickets
  \r
  import com.vaadin.Application;\r
  import com.vaadin.ui.Button;\r
 -import com.vaadin.ui.Window;\r
+ import com.vaadin.ui.Button.ClickEvent;\r
 +import com.vaadin.ui.Root;\r
  \r
 -public class Ticket1673 extends com.vaadin.Application {\r
 +public class Ticket1673 extends com.vaadin.Application.LegacyApplication {\r
  \r
      @Override\r
      public void init() {\r
  \r
 -        final Window main = new Window("#1673");\r
 +        final Root main = new Root("#1673");\r
          setMainWindow(main);\r
  \r
-         main.addComponent(new Button("close", this, "close"));\r
+         main.addComponent(new Button("close", new Button.ClickListener() {\r
+             public void buttonClick(ClickEvent event) {\r
+                 close();\r
+             }\r
+         }));\r
  \r
      }\r
  \r
index e7789840f2b55802b6a06d4d785d3ebf5bc307e4,cb6a14d61577962da4156d54447debc836b298c4..fcda39c9421a8783b7ac835c6361cca8ae7a41a8
@@@ -50,4 -55,4 +55,4 @@@ public class Ticket1919 extends com.vaa
          p.addComponent(b);\r
          return p;\r
      }\r
--}
++}
index bc57c6573ab0b87d2050b0970625573513a5f264,7bf12b8c505764b6c36d1e8acad116c0758ab93b..b4cec881337359fea16310e4ea03a37ae785057c
@@@ -4,16 -3,14 +4,17 @@@ import java.io.IOException
  import java.util.Map;
  
  import com.vaadin.Application;
 -import com.vaadin.terminal.ParameterHandler;
 +import com.vaadin.terminal.RequestHandler;
 +import com.vaadin.terminal.WrappedRequest;
 +import com.vaadin.terminal.WrappedResponse;
  import com.vaadin.ui.Button;
+ import com.vaadin.ui.Button.ClickEvent;
  import com.vaadin.ui.Label;
 +import com.vaadin.ui.Root;
  import com.vaadin.ui.VerticalLayout;
 -import com.vaadin.ui.Window;
  
 -public class Ticket1921 extends Application implements ParameterHandler {
 +public class Ticket1921 extends Application.LegacyApplication implements
 +        RequestHandler {
  
      int state = -1;
      int round = 1;
index f6d153ccaa483f81fea6929aa743978e3a7e5416,903c9874a46dc024e49158160cc3256f9d7d72e2..0cc27b11f52f856d171b6738c1df0da7fae9c21a
@@@ -5,12 -5,13 +5,13 @@@ import com.vaadin.data.Validator
  import com.vaadin.data.util.MethodProperty;
  import com.vaadin.data.validator.CompositeValidator;
  import com.vaadin.data.validator.CompositeValidator.CombinationMode;
+ import com.vaadin.data.validator.IntegerValidator;
  import com.vaadin.ui.Button;
  import com.vaadin.ui.CheckBox;
 +import com.vaadin.ui.Root;
  import com.vaadin.ui.TextField;
 -import com.vaadin.ui.Window;
  
 -public class Ticket20 extends Application {
 +public class Ticket20 extends Application.LegacyApplication {
  
      @Override
      public void init() {
index b49f9cd2a842d0465a5d086e0b158b8d3c78496b,220fd168dac5c29979965e498a83f5b74a48f3a1..89dbcef69abcd8301a9d101229fd1d73bcc32578
@@@ -89,4 -91,4 +91,4 @@@ public class Ticket2119 extends Applica
  
          return layout;
      }
--}
++}
index 7e714141d0874ca27ab31a2a8f1b5e68438dc092,06912d61d0eef8246e377143aae07893fcc6ecb3..57343e13c1e96e0a35d53610911126b1186c025d
@@@ -177,20 -179,12 +180,12 @@@ public class Ticket2998 extends Applica
                              try {\r
                                  @SuppressWarnings("unused")\r
                                  float f = Float.parseFloat((String) value);\r
-                                 return true;\r
                              } catch (Exception e) {\r
 -                                f.getWindow().showNotification(\r
 -                                        "Bad number value");\r
 +                                f.getRoot()\r
 +                                        .showNotification("Bad number value");\r
                                  f.setValue(0);\r
-                                 return false;\r
                              }\r
                          }\r
\r
-                         public void validate(Object value)\r
-                                 throws InvalidValueException {\r
-                             // TODO Auto-generated method stub\r
\r
-                         }\r
                      });\r
                  }\r
                  if (propertyId.equals("date")) {\r
index 48dcfd1c579618f1b1d39d38ea37332e66dd6f7f,9f8184cac9e4472af4356eb40a0517e0e9016560..44b2a364c5ed9656ce3c49ed9ddc3da2995a6f28
@@@ -1,14 -1,14 +1,14 @@@
  package com.vaadin.tests.tickets;
  
  import com.vaadin.Application;
- import com.vaadin.data.Validator;
  import com.vaadin.data.util.MethodProperty;
+ import com.vaadin.data.validator.IntegerValidator;
  import com.vaadin.ui.Button;
  import com.vaadin.ui.CheckBox;
 +import com.vaadin.ui.Root;
  import com.vaadin.ui.TextField;
 -import com.vaadin.ui.Window;
  
 -public class Ticket846 extends Application {
 +public class Ticket846 extends Application.LegacyApplication {
  
      @Override
      public void init() {