summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/service/FileTypeResolver.java8
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/ApplicationConnection.java48
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java4
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java36
-rw-r--r--src/com/vaadin/ui/LoginForm.java14
-rw-r--r--tests/scripts/demos-except-sampler.html2
-rw-r--r--tests/src/com/vaadin/tests/components/label/LabelModes.java109
-rw-r--r--tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java37
-rw-r--r--tests/src/com/vaadin/tests/server/TestFileTypeResolver.java52
10 files changed, 272 insertions, 43 deletions
diff --git a/src/com/vaadin/service/FileTypeResolver.java b/src/com/vaadin/service/FileTypeResolver.java
index 599cce924f..566f299376 100644
--- a/src/com/vaadin/service/FileTypeResolver.java
+++ b/src/com/vaadin/service/FileTypeResolver.java
@@ -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);
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 70cb99bc23..1c3128dbdf 100755
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -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(),
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
index 27fdf9506f..d7a11427fb 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
@@ -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;
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index e1ab149dc5..0cae63b8ca 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -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
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index 72c383b0c1..2bc10b4cc0 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -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));
}
diff --git a/src/com/vaadin/ui/LoginForm.java b/src/com/vaadin/ui/LoginForm.java
index 9d1de60505..dd6b527b4c 100644
--- a/src/com/vaadin/ui/LoginForm.java
+++ b/src/com/vaadin/ui/LoginForm.java
@@ -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;
diff --git a/tests/scripts/demos-except-sampler.html b/tests/scripts/demos-except-sampler.html
index cb51b7561c..5f59d1d602 100644
--- a/tests/scripts/demos-except-sampler.html
+++ b/tests/scripts/demos-except-sampler.html
@@ -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
index 0000000000..16568c5da5
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/label/LabelModes.java
@@ -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
index 0000000000..4a9020e2bf
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelInModalWindow.java
@@ -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
index 0000000000..dc1b292cc9
--- /dev/null
+++ b/tests/src/com/vaadin/tests/server/TestFileTypeResolver.java
@@ -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"));
+
+ }
+}