]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged [10797]-[10991] from 6.2
authorArtur Signell <artur.signell@itmill.com>
Mon, 25 Jan 2010 15:45:08 +0000 (15:45 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 25 Jan 2010 15:45:08 +0000 (15:45 +0000)
svn changeset:10996/svn branch:6.3

src/com/vaadin/service/FileTypeResolver.java
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
src/com/vaadin/terminal/gwt/client/ui/VWindow.java
src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
src/com/vaadin/ui/LoginForm.java
tests/scripts/demos-except-sampler.html
tests/src/com/vaadin/tests/components/label/LabelModes.java [new file with mode: 0644]
tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java [new file with mode: 0644]
tests/src/com/vaadin/tests/server/TestFileTypeResolver.java [new file with mode: 0644]

index 599cce924f09c59590e872c903b45c9f8451938e..566f29937663eb6fe3fd82bfcea994defa198b85 100644 (file)
@@ -245,7 +245,13 @@ public class FileTypeResolver implements Serializable {
         dotIndex++;
 
         if (fileName.length() > dotIndex) {
-            final String ext = fileName.substring(dotIndex);
+            String ext = fileName.substring(dotIndex);
+
+            // Ignore any query parameters
+            int queryStringStart = ext.indexOf('?');
+            if (queryStringStart > 0) {
+                ext = ext.substring(0, queryStringStart);
+            }
 
             // Return type from extension map, if found
             final String type = (String) extToMIMEMap.get(ext);
index 70cb99bc233617e69ea7ec8a3fbac6ca6c9c83a2..1c3128dbdfe5bea69c9a80c312eceb8094b79fb8 100755 (executable)
@@ -1324,11 +1324,12 @@ public class ApplicationConnection {
 
     /**
      * Sends a new value for the given paintables given variable to the server.
-     * <p>
+     * 
      * The update is actually queued to be sent at a suitable time. If immediate
      * is true, the update is sent as soon as possible. If immediate is false,
      * the update will be sent along with the next immediate update.
-     * </p>
+     * 
+     * A null array is sent as an empty array.
      * 
      * @param paintableId
      *            the id of the paintable that owns the variable
@@ -1342,11 +1343,14 @@ public class ApplicationConnection {
     public void updateVariable(String paintableId, String variableName,
             String[] values, boolean immediate) {
         final StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
+        if (values != null) {
+            for (int i = 0; i < values.length; i++) {
+                buf.append(values[i]);
+                // there will be an extra separator at the end to differentiate
+                // between an empty array and one containing an empty string
+                // only
                 buf.append(VAR_ARRAYITEM_SEPARATOR);
             }
-            buf.append(values[i]);
         }
         addVariableToQueue(paintableId, variableName, buf.toString(),
                 immediate, 'c');
@@ -1354,11 +1358,13 @@ public class ApplicationConnection {
 
     /**
      * Sends a new value for the given paintables given variable to the server.
-     * <p>
+     * 
      * The update is actually queued to be sent at a suitable time. If immediate
      * is true, the update is sent as soon as possible. If immediate is false,
-     * the update will be sent along with the next immediate update.
-     * </p>
+     * the update will be sent along with the next immediate update. </p>
+     * 
+     * A null array is sent as an empty array.
+     * 
      * 
      * @param paintableId
      *            the id of the paintable that owns the variable
@@ -1372,18 +1378,20 @@ public class ApplicationConnection {
     public void updateVariable(String paintableId, String variableName,
             Object[] values, boolean immediate) {
         final StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < values.length; i++) {
-            if (i > 0) {
-                buf.append(VAR_ARRAYITEM_SEPARATOR);
-            }
-            Object value = values[i];
-            char transportType = getTransportType(value);
-            // first char tells the type in array
-            buf.append(transportType);
-            if (transportType == 'p') {
-                buf.append(getPid((Paintable) value));
-            } else {
-                buf.append(value);
+        if (values != null) {
+            for (int i = 0; i < values.length; i++) {
+                if (i > 0) {
+                    buf.append(VAR_ARRAYITEM_SEPARATOR);
+                }
+                Object value = values[i];
+                char transportType = getTransportType(value);
+                // first char tells the type in array
+                buf.append(transportType);
+                if (transportType == 'p') {
+                    buf.append(getPid((Paintable) value));
+                } else {
+                    buf.append(value);
+                }
             }
         }
         addVariableToQueue(paintableId, variableName, buf.toString(),
index 27fdf9506fa4511a7b181c0f80034fb30b6927d4..d7a11427fb92e957bfba2f0a80a2a8332c7f6c69 100644 (file)
@@ -16,7 +16,6 @@ import com.google.gwt.user.client.DeferredCommand;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.ComplexPanel;
-import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
@@ -503,7 +502,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
             DOM.setStyleAttribute(draggingCurtain, "zIndex", ""
                     + VOverlay.Z_INDEX);
 
-            DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain);
+            DOM.appendChild(wrapper, draggingCurtain);
         }
     }
 
@@ -521,7 +520,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
      */
     private void hideDraggingCurtain() {
         if (draggingCurtain != null) {
-            DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain);
+            DOM.removeChild(wrapper, draggingCurtain);
             draggingCurtain = null;
         }
     }
index e1ab149dc539211687775e0c0340885f5fbde5a6..0cae63b8ca63c4221605160562bc29b8eea9659b 100644 (file)
@@ -1065,6 +1065,10 @@ public class VWindow extends VOverlay implements Container, ScrollListener {
         } else if (vaadinModality) {
             // return false when modal and outside window
             final Element target = event.getTarget().cast();
+            if (DOM.getCaptureElement() != null) {
+                // Allow events when capture is set
+                return true;
+            }
 
             if (!DOM.isOrHasChild(getElement(), target)) {
                 // not within the modal window, but let's see if it's in the
index 72c383b0c117fc491ac7ba21345aa7dc7d810e9a..2bc10b4cc09a9914ba5397d18df2449be9a8bb86 100644 (file)
@@ -59,6 +59,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringTokenizer;
 
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
@@ -1211,7 +1212,7 @@ public abstract class AbstractCommunicationManager implements
             val = convertMap(strValue);
             break;
         case VTYPE_STRINGARRAY:
-            val = strValue.split(VAR_ARRAYITEM_SEPARATOR);
+            val = convertStringArray(strValue);
             break;
         case VTYPE_STRING:
             val = strValue;
@@ -1244,19 +1245,44 @@ public abstract class AbstractCommunicationManager implements
         HashMap<String, Object> map = new HashMap<String, Object>();
         for (int i = 0; i < parts.length; i += 2) {
             String key = parts[i];
-            char variabletype = key.charAt(0);
-            Object value = convertVariableValue(variabletype, parts[i + 1]);
-            map.put(key.substring(1), value);
+            if (key.length() > 0) {
+                char variabletype = key.charAt(0);
+                Object value = convertVariableValue(variabletype, parts[i + 1]);
+                map.put(key.substring(1), value);
+            }
         }
         return map;
     }
 
+    private String[] convertStringArray(String strValue) {
+        // need to return delimiters and filter them out; otherwise empty
+        // strings are lost
+        // an extra empty delimiter at the end is automatically eliminated
+        StringTokenizer tokenizer = new StringTokenizer(strValue,
+                VAR_ARRAYITEM_SEPARATOR, true);
+        List<String> tokens = new ArrayList<String>();
+        String prevToken = VAR_ARRAYITEM_SEPARATOR;
+        while (tokenizer.hasMoreTokens()) {
+            String token = tokenizer.nextToken();
+            if (!VAR_ARRAYITEM_SEPARATOR.equals(token)) {
+                tokens.add(token);
+            } else if (VAR_ARRAYITEM_SEPARATOR.equals(prevToken)) {
+                tokens.add("");
+            }
+            prevToken = token;
+        }
+        return tokens.toArray(new String[tokens.size()]);
+    }
+
     private Object convertArray(String strValue) {
         String[] val = strValue.split(VAR_ARRAYITEM_SEPARATOR);
+        if (val.length == 0 || (val.length == 1 && val[0].length() == 0)) {
+            return new Object[0];
+        }
         Object[] values = new Object[val.length];
         for (int i = 0; i < values.length; i++) {
             String string = val[i];
-            // first char of string is typ
+            // first char of string is type
             char variableType = string.charAt(0);
             values[i] = convertVariableValue(variableType, string.substring(1));
         }
index 9d1de60505e9d49e35bef63e7b1c01afc1dc6a19..dd6b527b4c4f0e8b3f112ef867c68f5ce857fba5 100644 (file)
@@ -43,9 +43,6 @@ public class LoginForm extends CustomComponent {
 
     private ApplicationResource loginPage = new ApplicationResource() {
 
-        /**
-         * 
-         */
         private static final long serialVersionUID = 1L;
 
         public Application getApplication() {
@@ -76,9 +73,6 @@ public class LoginForm extends CustomComponent {
 
     private ParameterHandler paramHandler = new ParameterHandler() {
 
-        /**
-         * 
-         */
         private static final long serialVersionUID = 1L;
 
         public void handleParameters(Map<String, String[]> parameters) {
@@ -100,9 +94,6 @@ public class LoginForm extends CustomComponent {
     };
 
     private URIHandler uriHandler = new URIHandler() {
-        /**
-         * 
-         */
         private static final long serialVersionUID = 1L;
         private final String responce = "<html><body>Login form handeled."
                 + "<script type='text/javascript'>top.vaadin.forceSync();"
@@ -175,7 +166,7 @@ public class LoginForm extends CustomComponent {
                 + "<div class='v-app v-app-loginpage' style=\"background:transparent;\">"
                 + "<iframe name='logintarget' style='width:0;height:0;"
                 + "border:0;margin:0;padding:0;'></iframe>"
-                + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\">"
+                + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">"
                 + "<div>Username</div><div >"
                 + "<input class='v-textfield' style='display:block;' type='text' name='username'></div>"
                 + "<div>Password</div>"
@@ -211,9 +202,6 @@ public class LoginForm extends CustomComponent {
      */
     public class LoginEvent extends Event {
 
-        /**
-         * 
-         */
         private static final long serialVersionUID = 1L;
         private Map<String, String> params;
 
index cb51b7561ceecbc964243e6f1dee2e3b37c54d1d..5f59d1d602dee28a43aef692fb36a79724df675c 100644 (file)
@@ -58,7 +58,7 @@
 </tr>
 <tr>
        <td>pause</td>
-       <td>1000</td>
+       <td>5000</td>
        <td></td>
 </tr>
 <tr>
diff --git a/tests/src/com/vaadin/tests/components/label/LabelModes.java b/tests/src/com/vaadin/tests/components/label/LabelModes.java
new file mode 100644 (file)
index 0000000..16568c5
--- /dev/null
@@ -0,0 +1,109 @@
+package com.vaadin.tests.components.label;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class LabelModes extends ComponentTestCase {
+
+    Label label[] = new Label[20];
+
+    @Override
+    protected void setup() {
+        super.setup();
+
+        Label l;
+        l = createLabel("This is an undefined wide label with default content mode");
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nbut is in\ndefault content mode");
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\npreformatted mode");
+        l.setContentMode(Label.CONTENT_PREFORMATTED);
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\nhtml mode");
+        l.setContentMode(Label.CONTENT_XHTML);
+        l.setWidth(null);
+        addTestComponent(l);
+
+        l = createLabel("This label                       contains\nnewlines and spaces\nand is in\nraw mode");
+        l.setContentMode(Label.CONTENT_RAW);
+        l.setWidth(null);
+        addTestComponent(l);
+
+    }
+
+    private Label createLabel(String text, String caption) {
+        Label l = new Label(text);
+        l.setCaption(caption);
+
+        return l;
+    }
+
+    private Label createLabel(String text) {
+        return createLabel(text, null);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "A generic test for Labels in different configurations";
+    }
+
+    @Override
+    protected List<Component> createActions() {
+        ArrayList<Component> actions = new ArrayList<Component>();
+
+        CheckBox errorIndicators = new CheckBox("Error indicators",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Button b = event.getButton();
+                        boolean enabled = (Boolean) b.getValue();
+                        setErrorIndicators(enabled);
+
+                    }
+                });
+
+        CheckBox enabled = new CheckBox("Enabled", new Button.ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                Button b = event.getButton();
+                boolean enabled = (Boolean) b.getValue();
+                setEnabled(enabled);
+            }
+        });
+
+        CheckBox readonly = new CheckBox("Readonly",
+                new Button.ClickListener() {
+                    public void buttonClick(ClickEvent event) {
+                        Button b = event.getButton();
+                        boolean enabled = (Boolean) b.getValue();
+                        setReadOnly(enabled);
+                    }
+                });
+
+        errorIndicators.setValue(new Boolean(false));
+        readonly.setValue(new Boolean(false));
+        enabled.setValue(new Boolean(true));
+
+        errorIndicators.setImmediate(true);
+        readonly.setImmediate(true);
+        enabled.setImmediate(true);
+
+        actions.add(errorIndicators);
+        actions.add(readonly);
+        actions.add(enabled);
+
+        return actions;
+    }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java
new file mode 100644 (file)
index 0000000..4a9020e
--- /dev/null
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.SplitPanel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SplitPanelInModalWindow extends TestBase {
+
+    @Override
+    public void setup() {
+
+        VerticalLayout vl = new VerticalLayout();
+        final Window modalWindow = new Window("Modeless Window", vl);
+        vl.setWidth(200, Sizeable.UNITS_PIXELS);
+        vl.setHeight(200, Sizeable.UNITS_PIXELS);
+        modalWindow.setModal(true); // This line causes the problem
+        getMainWindow().addWindow(modalWindow);
+
+        SplitPanel splitPanel = new SplitPanel(
+                SplitPanel.ORIENTATION_HORIZONTAL);
+        splitPanel.setSplitPosition(20);
+        vl.addComponent(splitPanel);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Moving the splitter in the modal window should work as expected and not cause the application to freeze.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 4067;
+    }
+
+}
\ No newline at end of file
diff --git a/tests/src/com/vaadin/tests/server/TestFileTypeResolver.java b/tests/src/com/vaadin/tests/server/TestFileTypeResolver.java
new file mode 100644 (file)
index 0000000..dc1b292
--- /dev/null
@@ -0,0 +1,52 @@
+package com.vaadin.tests.server;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import com.vaadin.service.FileTypeResolver;
+
+public class TestFileTypeResolver extends TestCase {
+
+    private static final String FLASH_MIME_TYPE = "application/x-shockwave-flash";
+    private static final String TEXT_MIME_TYPE = "text/plain";
+    private static final String HTML_MIME_TYPE = "text/html";
+
+    public void testMimeTypes() {
+        File plainFlash = new File("MyFlash.swf");
+        File plainText = new File("/a/b/MyFlash.txt");
+        File plainHtml = new File("c:\\MyFlash.html");
+
+        // Flash
+        assertEquals(
+                FileTypeResolver.getMIMEType(plainFlash.getAbsolutePath()),
+                FLASH_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainFlash.getAbsolutePath()
+                + "?param1=value1"), FLASH_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainFlash.getAbsolutePath()
+                + "?param1=value1&param2=value2"), FLASH_MIME_TYPE);
+
+        // Plain text
+        assertEquals(FileTypeResolver.getMIMEType(plainText.getAbsolutePath()),
+                TEXT_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainText.getAbsolutePath()
+                + "?param1=value1"), TEXT_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainText.getAbsolutePath()
+                + "?param1=value1&param2=value2"), TEXT_MIME_TYPE);
+
+        // Plain text
+        assertEquals(FileTypeResolver.getMIMEType(plainHtml.getAbsolutePath()),
+                HTML_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainHtml.getAbsolutePath()
+                + "?param1=value1"), HTML_MIME_TYPE);
+        assertEquals(FileTypeResolver.getMIMEType(plainHtml.getAbsolutePath()
+                + "?param1=value1&param2=value2"), HTML_MIME_TYPE);
+
+        // Filename missing
+        assertEquals(FileTypeResolver.DEFAULT_MIME_TYPE, FileTypeResolver
+                .getMIMEType(""));
+        assertEquals(FileTypeResolver.DEFAULT_MIME_TYPE, FileTypeResolver
+                .getMIMEType("?param1"));
+
+    }
+}