aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-07-26 14:53:59 +0300
committerLeif Åstrand <leif@vaadin.com>2012-07-26 14:53:59 +0300
commit6455d8a5f809c98d93f6bfe89fbe55a64c66a03f (patch)
tree1f431716f3d581d33983fd2b788eb91d42a8ac95
parentdf430157bf12ae88e265318c09250a3865981a0c (diff)
parentca9fab0922d9db510c51f2d363b46577f7f6c0c4 (diff)
downloadvaadin-framework-6455d8a5f809c98d93f6bfe89fbe55a64c66a03f.tar.gz
vaadin-framework-6455d8a5f809c98d93f6bfe89fbe55a64c66a03f.zip
Merge remote branch 'origin/6.8'
Conflicts: src/com/vaadin/terminal/gwt/server/CommunicationManager.java
-rw-r--r--WebContent/VAADIN/themes/base/textfield/richtext.css4
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java62
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/query/generator/MSSQLGenerator.java2
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/query/generator/OracleGenerator.java12
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java24
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java2
-rw-r--r--src/com/vaadin/terminal/gwt/server/CommunicationManager.java34
-rw-r--r--tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java57
-rw-r--r--tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.html27
-rw-r--r--tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.java57
10 files changed, 267 insertions, 14 deletions
diff --git a/WebContent/VAADIN/themes/base/textfield/richtext.css b/WebContent/VAADIN/themes/base/textfield/richtext.css
index a304fa2a57..6a236886cc 100644
--- a/WebContent/VAADIN/themes/base/textfield/richtext.css
+++ b/WebContent/VAADIN/themes/base/textfield/richtext.css
@@ -6,7 +6,9 @@
background: #fff;
border: none;
}
-
+.v-richtextarea .gwt-HTML {
+ height: 100%;
+}
.v-richtextarea .gwt-RichTextToolbar {
white-space: nowrap;
background: #959595 url(img/richtext-toolbar-bg.png) repeat-x 0 -42px;
diff --git a/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java b/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java
index a6798f972b..6485330541 100644
--- a/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java
+++ b/src/com/vaadin/data/util/sqlcontainer/query/generator/DefaultSQLGenerator.java
@@ -24,11 +24,25 @@ import com.vaadin.data.util.sqlcontainer.query.generator.filter.StringDecorator;
@SuppressWarnings("serial")
public class DefaultSQLGenerator implements SQLGenerator {
+ private Class<? extends StatementHelper> statementHelperClass = null;
+
public DefaultSQLGenerator() {
}
/**
+ * Create a new DefaultSqlGenerator instance that uses the given
+ * implementation of {@link StatementHelper}
+ *
+ * @param statementHelper
+ */
+ public DefaultSQLGenerator(
+ Class<? extends StatementHelper> statementHelperClazz) {
+ this();
+ statementHelperClass = statementHelperClazz;
+ }
+
+ /**
* Construct a DefaultSQLGenerator with the specified identifiers for start
* and end of quoted strings. The identifiers may be different depending on
* the database engine and it's settings.
@@ -44,6 +58,20 @@ public class DefaultSQLGenerator implements SQLGenerator {
quoteEnd));
}
+ /**
+ * Same as {@link #DefaultSQLGenerator(String, String)} but with support for
+ * custom {@link StatementHelper} implementation.
+ *
+ * @param quoteStart
+ * @param quoteEnd
+ * @param statementHelperClazz
+ */
+ public DefaultSQLGenerator(String quoteStart, String quoteEnd,
+ Class<? extends StatementHelper> statementHelperClazz) {
+ this(quoteStart, quoteEnd);
+ statementHelperClass = statementHelperClazz;
+ }
+
/*
* (non-Javadoc)
*
@@ -59,7 +87,7 @@ public class DefaultSQLGenerator implements SQLGenerator {
throw new IllegalArgumentException("Table name must be given.");
}
toSelect = toSelect == null ? "*" : toSelect;
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
query.append("SELECT " + toSelect + " FROM ").append(
SQLUtil.escapeSQL(tableName));
@@ -93,7 +121,7 @@ public class DefaultSQLGenerator implements SQLGenerator {
if (item == null) {
throw new IllegalArgumentException("Updated item must be given.");
}
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
query.append("UPDATE ").append(tableName).append(" SET");
@@ -147,7 +175,7 @@ public class DefaultSQLGenerator implements SQLGenerator {
throw new IllegalArgumentException(
"Cannot generate an insert query for item already in database.");
}
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
query.append("INSERT INTO ").append(tableName).append(" (");
@@ -201,7 +229,7 @@ public class DefaultSQLGenerator implements SQLGenerator {
throw new IllegalArgumentException(
"Valid keyColumnNames must be provided.");
}
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
query.append("DELETE FROM ").append(tableName).append(" WHERE ");
int count = 1;
@@ -312,4 +340,28 @@ public class DefaultSQLGenerator implements SQLGenerator {
}
return rowIdentifiers;
}
-} \ No newline at end of file
+
+ /**
+ * Returns the statement helper for the generator. Override this to handle
+ * platform specific data types.
+ *
+ * @see http://dev.vaadin.com/ticket/9148
+ * @return a new instance of the statement helper
+ */
+ protected StatementHelper getStatementHelper() {
+ if (statementHelperClass == null) {
+ return new StatementHelper();
+ }
+
+ try {
+ return statementHelperClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException(
+ "Unable to instantiate custom StatementHelper", e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(
+ "Unable to instantiate custom StatementHelper", e);
+ }
+ }
+
+}
diff --git a/src/com/vaadin/data/util/sqlcontainer/query/generator/MSSQLGenerator.java b/src/com/vaadin/data/util/sqlcontainer/query/generator/MSSQLGenerator.java
index 52c13feecb..13ef1d0090 100644
--- a/src/com/vaadin/data/util/sqlcontainer/query/generator/MSSQLGenerator.java
+++ b/src/com/vaadin/data/util/sqlcontainer/query/generator/MSSQLGenerator.java
@@ -50,7 +50,7 @@ public class MSSQLGenerator extends DefaultSQLGenerator {
offset = pagelength > 1 ? ++offset : offset;
pagelength = pagelength > 1 ? --pagelength : pagelength;
toSelect = toSelect == null ? "*" : toSelect;
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
/* Row count request is handled here */
diff --git a/src/com/vaadin/data/util/sqlcontainer/query/generator/OracleGenerator.java b/src/com/vaadin/data/util/sqlcontainer/query/generator/OracleGenerator.java
index 8e33211154..43a562d3a8 100644
--- a/src/com/vaadin/data/util/sqlcontainer/query/generator/OracleGenerator.java
+++ b/src/com/vaadin/data/util/sqlcontainer/query/generator/OracleGenerator.java
@@ -16,6 +16,10 @@ public class OracleGenerator extends DefaultSQLGenerator {
}
+ public OracleGenerator(Class<? extends StatementHelper> statementHelperClazz) {
+ super(statementHelperClazz);
+ }
+
/**
* Construct an OracleSQLGenerator with the specified identifiers for start
* and end of quoted strings. The identifiers may be different depending on
@@ -31,6 +35,11 @@ public class OracleGenerator extends DefaultSQLGenerator {
super(quoteStart, quoteEnd);
}
+ public OracleGenerator(String quoteStart, String quoteEnd,
+ Class<? extends StatementHelper> statementHelperClazz) {
+ super(quoteStart, quoteEnd, statementHelperClazz);
+ }
+
/*
* (non-Javadoc)
*
@@ -50,7 +59,7 @@ public class OracleGenerator extends DefaultSQLGenerator {
offset = pagelength > 1 ? ++offset : offset;
pagelength = pagelength > 1 ? --pagelength : pagelength;
toSelect = toSelect == null ? "*" : toSelect;
- StatementHelper sh = new StatementHelper();
+ StatementHelper sh = getStatementHelper();
StringBuffer query = new StringBuffer();
/* Row count request is handled here */
@@ -99,4 +108,5 @@ public class OracleGenerator extends DefaultSQLGenerator {
sh.setQueryString(query.toString());
return sh;
}
+
} \ No newline at end of file
diff --git a/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java b/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
index 3fd92e920d..f9458609c3 100644
--- a/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
+++ b/src/com/vaadin/data/util/sqlcontainer/query/generator/StatementHelper.java
@@ -128,8 +128,32 @@ public class StatementHelper implements Serializable {
} else if (Timestamp.class.equals(dataTypes.get(i))) {
pstmt.setTimestamp(i + 1, null);
} else {
+
+ if (handleUnrecognizedTypeNullValue(i, pstmt, dataTypes)) {
+ return;
+ }
+
throw new SQLException("Data type not supported by SQLContainer: "
+ parameters.get(i).getClass().toString());
}
}
+
+ /**
+ * Handle unrecognized null values. Override this to handle null values for
+ * platform specific data types that are not handled by the default
+ * implementation of the {@link StatementHelper}.
+ *
+ * @param i
+ * @param pstmt
+ * @param dataTypes2
+ *
+ * @return true if handled, false otherwise
+ *
+ * @see {@link http://dev.vaadin.com/ticket/9148}
+ */
+ protected boolean handleUnrecognizedTypeNullValue(int i,
+ PreparedStatement pstmt, Map<Integer, Class<?>> dataTypes)
+ throws SQLException {
+ return false;
+ }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java
index 5d5f7d7b8c..f9b399caac 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/richtextarea/VRichTextArea.java
@@ -31,6 +31,7 @@ import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
+import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate;
/**
* This class implements a basic client side rich text editor component.
@@ -85,6 +86,7 @@ public class VRichTextArea extends Composite implements Field, ChangeHandler,
initWidget(fp);
setStyleName(CLASSNAME);
+ TouchScrollDelegate.enableTouchScrolling(html, html.getElement());
}
private void createRTAComponents() {
diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
index 2cf3b23446..f083252897 100644
--- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java
@@ -94,8 +94,8 @@ public class CommunicationManager extends AbstractCommunicationManager {
Root root = application.getRootById(Integer.parseInt(rootId));
Root.setCurrent(root);
- StreamVariable streamVariable = pidToNameToStreamVariable.get(
- connectorId).get(variableName);
+ StreamVariable streamVariable = getStreamVariable(connectorId,
+ variableName);
String secKey = streamVariableToSeckey.get(streamVariable);
if (secKey.equals(parts[3])) {
@@ -119,6 +119,28 @@ public class CommunicationManager extends AbstractCommunicationManager {
}
+ /**
+ * Gets a stream variable based on paintable id and variable name. Returns
+ * <code>null</code> if no matching variable has been registered.
+ *
+ * @param paintableId
+ * id of paintable to get variable for
+ * @param variableName
+ * name of the stream variable
+ * @return the corresponding stream variable, or <code>null</code> if not
+ * found
+ */
+ public StreamVariable getStreamVariable(String paintableId,
+ String variableName) {
+ Map<String, StreamVariable> nameToStreamVariable = pidToNameToStreamVariable
+ .get(paintableId);
+ if (nameToStreamVariable == null) {
+ return null;
+ }
+ StreamVariable streamVariable = nameToStreamVariable.get(variableName);
+ return streamVariable;
+ }
+
@Override
protected void postPaint(Root root) {
super.postPaint(root);
@@ -147,8 +169,8 @@ public class CommunicationManager extends AbstractCommunicationManager {
private Map<StreamVariable, String> streamVariableToSeckey;
@Override
- String getStreamVariableTargetUrl(ClientConnector owner, String name,
- StreamVariable value) {
+ public String getStreamVariableTargetUrl(ClientConnector owner,
+ String name, StreamVariable value) {
/*
* We will use the same APP/* URI space as ApplicationResources but
* prefix url with UPLOAD
@@ -191,10 +213,10 @@ public class CommunicationManager extends AbstractCommunicationManager {
}
@Override
- protected void cleanStreamVariable(ClientConnector owner, String name) {
+ public void cleanStreamVariable(ClientConnector owner, String name) {
Map<String, StreamVariable> nameToStreamVar = pidToNameToStreamVariable
.get(owner.getConnectorId());
- nameToStreamVar.remove("name");
+ nameToStreamVar.remove(name);
if (nameToStreamVar.isEmpty()) {
pidToNameToStreamVariable.remove(owner.getConnectorId());
}
diff --git a/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java
new file mode 100644
index 0000000000..7e9aefcbd9
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.server;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+
+import com.vaadin.Application;
+import com.vaadin.terminal.StreamVariable;
+import com.vaadin.terminal.gwt.server.CommunicationManager;
+import com.vaadin.ui.Upload;
+
+public class TestStreamVariableMapping extends TestCase {
+ private static final String variableName = "myName";
+
+ private Upload owner;
+ private StreamVariable streamVariable;
+
+ private CommunicationManager cm;
+
+ @Override
+ protected void setUp() throws Exception {
+ owner = new Upload();
+ streamVariable = EasyMock.createMock(StreamVariable.class);
+ cm = createCommunicationManager();
+
+ super.setUp();
+ }
+
+ public void testAddStreamVariable() {
+ String targetUrl = cm.getStreamVariableTargetUrl(owner, variableName,
+ streamVariable);
+ assertTrue(targetUrl.startsWith("app://APP/UPLOAD/PID0/myName/"));
+
+ StreamVariable streamVariable2 = cm.getStreamVariable(
+ cm.getPaintableId(owner), variableName);
+ assertSame(streamVariable, streamVariable2);
+ }
+
+ public void testRemoverVariable() {
+ cm.getStreamVariableTargetUrl(owner, variableName, streamVariable);
+ assertNotNull(cm.getStreamVariable(cm.getPaintableId(owner),
+ variableName));
+
+ cm.cleanStreamVariable(owner, variableName);
+ assertNull(cm.getStreamVariable(cm.getPaintableId(owner), variableName));
+ }
+
+ private CommunicationManager createCommunicationManager() {
+ return new CommunicationManager(new Application() {
+ @Override
+ public void init() {
+ // TODO Auto-generated method stub
+ }
+ });
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.html b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.html
new file mode 100644
index 0000000000..be1c5a2cde
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.html
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>RichTextAreaScrolling</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">RichTextAreaScrolling</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.richtextarea.RichTextAreaScrolling?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.java b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.java
new file mode 100644
index 0000000000..f88ed0c67c
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaScrolling.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.components.richtextarea;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.VerticalLayout;
+
+public class RichTextAreaScrolling extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "A read-only RichTextArea should be (touch) scrollable";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7036;
+ }
+
+ @Override
+ protected void setup() {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 50; ++i) {
+ sb.append("A long string with several lines<br/>");
+ }
+
+ HorizontalLayout main = new HorizontalLayout();
+ main.setSpacing(true);
+ addComponent(main);
+
+ RichTextArea first = new RichTextArea("Defined height");
+ RichTextArea second = new RichTextArea("Full height");
+ RichTextArea third = new RichTextArea("Undefined height");
+
+ first.setValue(sb);
+ second.setValue(sb);
+ third.setValue(sb);
+
+ first.setReadOnly(true);
+ second.setReadOnly(true);
+ third.setReadOnly(true);
+
+ first.setWidth("200px");
+ first.setHeight("400px");
+ second.setSizeFull();
+ third.setSizeUndefined();
+
+ VerticalLayout secondLayout = new VerticalLayout();
+ secondLayout.setWidth("200px");
+ secondLayout.setHeight("200px");
+ secondLayout.addComponent(second);
+
+ main.addComponent(first);
+ main.addComponent(secondLayout);
+ main.addComponent(third);
+ }
+}