aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin')
-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
6 files changed, 123 insertions, 13 deletions
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());
}