Bladeren bron

Merge changes from origin/7.1

badf9f2 Do not prevent deployment if Atmosphere init fails (#13199)
be827f8 Enable on-the-fly SASS compilation in OSGi (#10307)
61a1899 Fix SQLContainer paging and caching issue (#11199)
19dde49 Remove applet test which does not work reliably
a73c9ef Fix broken TableScrollingWithSQLContainer test UI
fbce127 Use Chrome 33 for testing

Change-Id: I4a09cdfcc8187604a24391a73ea6c04c6d50bb5f
tags/7.2.0.beta1
Build Agent 10 jaren geleden
bovenliggende
commit
45bae7affe

+ 1
- 1
server/build.xml Bestand weergeven



<target name="jar"> <target name="jar">
<property name="server.osgi.import" value="javax.servlet;version=&quot;2.4.0&quot;,javax.servlet.http;version=&quot;2.4.0&quot;,javax.validation;version=&quot;1.0.0.GA&quot;;resolution:=optional,org.jsoup;version=&quot;1.6.3&quot;,org.jsoup.parser;version=&quot;1.6.3&quot;,org.jsoup.nodes;version=&quot;1.6.3&quot;,org.jsoup.helper;version=&quot;1.6.3&quot;,org.jsoup.safety;version=&quot;1.6.3&quot;,org.json;version=&quot;0.0.20080701&quot;" /> <property name="server.osgi.import" value="javax.servlet;version=&quot;2.4.0&quot;,javax.servlet.http;version=&quot;2.4.0&quot;,javax.validation;version=&quot;1.0.0.GA&quot;;resolution:=optional,org.jsoup;version=&quot;1.6.3&quot;,org.jsoup.parser;version=&quot;1.6.3&quot;,org.jsoup.nodes;version=&quot;1.6.3&quot;,org.jsoup.helper;version=&quot;1.6.3&quot;,org.jsoup.safety;version=&quot;1.6.3&quot;,org.json;version=&quot;0.0.20080701&quot;" />
<property name="server.osgi.require" value="com.vaadin.shared;bundle-version=&quot;${vaadin.version}&quot;,com.vaadin.push;bundle-version=&quot;${vaadin.version}&quot;;resolution:=optional" />
<property name="server.osgi.require" value="com.vaadin.shared;bundle-version=&quot;${vaadin.version}&quot;,com.vaadin.push;bundle-version=&quot;${vaadin.version}&quot;;resolution:=optional,com.vaadin.theme-compiler;bundle-version=&quot;${vaadin.version}&quot;;resolution:=optional" />
<antcall target="common.jar"> <antcall target="common.jar">
<param name="require-bundle" value="${server.osgi.require}" /> <param name="require-bundle" value="${server.osgi.require}" />
<param name="import-package" value="${server.osgi.import}" /> <param name="import-package" value="${server.osgi.import}" />

+ 101
- 79
server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java Bestand weergeven

Container.Indexed, Container.Sortable, Container.ItemSetChangeNotifier { Container.Indexed, Container.Sortable, Container.ItemSetChangeNotifier {


/** Query delegate */ /** Query delegate */
private QueryDelegate delegate;
private QueryDelegate queryDelegate;
/** Auto commit mode, default = false */ /** Auto commit mode, default = false */
private boolean autoCommit = false; private boolean autoCommit = false;


/** Number of items to cache = CACHE_RATIO x pageLength */ /** Number of items to cache = CACHE_RATIO x pageLength */
public static final int CACHE_RATIO = 2; public static final int CACHE_RATIO = 2;


/** Amount of cache to overlap with previous page */
private int cacheOverlap = pageLength;

/** Item and index caches */ /** Item and index caches */
private final Map<Integer, RowId> itemIndexes = new HashMap<Integer, RowId>(); private final Map<Integer, RowId> itemIndexes = new HashMap<Integer, RowId>();
private final CacheMap<RowId, RowItem> cachedItems = new CacheMap<RowId, RowItem>(); private final CacheMap<RowId, RowItem> cachedItems = new CacheMap<RowId, RowItem>();
throw new IllegalArgumentException( throw new IllegalArgumentException(
"QueryDelegate must not be null."); "QueryDelegate must not be null.");
} }
this.delegate = delegate;
queryDelegate = delegate;
getPropertyIds(); getPropertyIds();
cachedItems.setCacheLimit(CACHE_RATIO * getPageLength());
cachedItems.setCacheLimit(CACHE_RATIO * getPageLength() + cacheOverlap);
} }


/**************************************/ /**************************************/


@Override @Override
public Object addItem() throws UnsupportedOperationException { public Object addItem() throws UnsupportedOperationException {
Object emptyKey[] = new Object[delegate.getPrimaryKeyColumns().size()];
Object emptyKey[] = new Object[queryDelegate.getPrimaryKeyColumns()
.size()];
RowId itemId = new TemporaryRowId(emptyKey); RowId itemId = new TemporaryRowId(emptyKey);
// Create new empty column properties for the row item. // Create new empty column properties for the row item.
List<ColumnProperty> itemProperties = new ArrayList<ColumnProperty>(); List<ColumnProperty> itemProperties = new ArrayList<ColumnProperty>();
if (autoCommit) { if (autoCommit) {
/* Add and commit instantly */ /* Add and commit instantly */
try { try {
if (delegate instanceof TableQuery) {
itemId = ((TableQuery) delegate)
if (queryDelegate instanceof TableQuery) {
itemId = ((TableQuery) queryDelegate)
.storeRowImmediately(newRowItem); .storeRowImmediately(newRowItem);
} else { } else {
delegate.beginTransaction();
delegate.storeRow(newRowItem);
delegate.commit();
queryDelegate.beginTransaction();
queryDelegate.storeRow(newRowItem);
queryDelegate.commit();
} }
refresh(); refresh();
if (notificationsEnabled) { if (notificationsEnabled) {
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"Failed to add row to DB. Rolling back.", e); "Failed to add row to DB. Rolling back.", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
getLogger().log(Level.SEVERE, getLogger().log(Level.SEVERE,
"Failed to roll back row addition", e); "Failed to roll back row addition", e);


if (itemId instanceof RowId && !(itemId instanceof TemporaryRowId)) { if (itemId instanceof RowId && !(itemId instanceof TemporaryRowId)) {
try { try {
return delegate.containsRowWithKey(((RowId) itemId).getId());
return queryDelegate.containsRowWithKey(((RowId) itemId)
.getId());
} catch (Exception e) { } catch (Exception e) {
/* Query failed, just return false. */ /* Query failed, just return false. */
getLogger().log(Level.WARNING, "containsId query failed", e); getLogger().log(Level.WARNING, "containsId query failed", e);
ResultSet rs = null; ResultSet rs = null;
try { try {
// Load ALL rows :( // Load ALL rows :(
delegate.beginTransaction();
rs = delegate.getResults(0, 0);
List<String> pKeys = delegate.getPrimaryKeyColumns();
queryDelegate.beginTransaction();
rs = queryDelegate.getResults(0, 0);
List<String> pKeys = queryDelegate.getPrimaryKeyColumns();
while (rs.next()) { while (rs.next()) {
RowId id = null; RowId id = null;
if (pKeys.isEmpty()) { if (pKeys.isEmpty()) {
} }
rs.getStatement().close(); rs.getStatement().close();
rs.close(); rs.close();
delegate.commit();
queryDelegate.commit();
} catch (SQLException e) { } catch (SQLException e) {
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"getItemIds() failed, rolling back.", e); "getItemIds() failed, rolling back.", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException e1) { } catch (SQLException e1) {
getLogger().log(Level.SEVERE, "Failed to roll back state", e1); getLogger().log(Level.SEVERE, "Failed to roll back state", e1);
} }
return false; return false;
} }
try { try {
delegate.beginTransaction();
boolean success = delegate.removeRow((RowItem) i);
delegate.commit();
queryDelegate.beginTransaction();
boolean success = queryDelegate.removeRow((RowItem) i);
queryDelegate.commit();
refresh(); refresh();
if (notificationsEnabled) { if (notificationsEnabled) {
CacheFlushNotifier.notifyOfCacheFlush(this); CacheFlushNotifier.notifyOfCacheFlush(this);
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"Failed to remove row, rolling back", e); "Failed to remove row, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
/* Nothing can be done here */ /* Nothing can be done here */
getLogger().log(Level.SEVERE, getLogger().log(Level.SEVERE,
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"Failed to remove row, rolling back", e); "Failed to remove row, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
/* Nothing can be done here */ /* Nothing can be done here */
getLogger().log(Level.SEVERE, getLogger().log(Level.SEVERE,
if (autoCommit) { if (autoCommit) {
/* Remove and commit instantly. */ /* Remove and commit instantly. */
try { try {
delegate.beginTransaction();
queryDelegate.beginTransaction();
boolean success = true; boolean success = true;
for (Object id : getItemIds()) { for (Object id : getItemIds()) {
if (!delegate.removeRow((RowItem) getItem(id))) {
if (!queryDelegate.removeRow((RowItem) getItem(id))) {
success = false; success = false;
} }
} }
if (success) { if (success) {
delegate.commit();
queryDelegate.commit();
getLogger().log(Level.FINER, "All rows removed from DB..."); getLogger().log(Level.FINER, "All rows removed from DB...");
refresh(); refresh();
if (notificationsEnabled) { if (notificationsEnabled) {
CacheFlushNotifier.notifyOfCacheFlush(this); CacheFlushNotifier.notifyOfCacheFlush(this);
} }
} else { } else {
delegate.rollback();
queryDelegate.rollback();
} }
return success; return success;
} catch (SQLException e) { } catch (SQLException e) {
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"removeAllItems() failed, rolling back", e); "removeAllItems() failed, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
/* Nothing can be done here */ /* Nothing can be done here */
getLogger().log(Level.SEVERE, "Failed to roll back", ee); getLogger().log(Level.SEVERE, "Failed to roll back", ee);
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"removeAllItems() failed, rolling back", e); "removeAllItems() failed, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
/* Nothing can be done here */ /* Nothing can be done here */
getLogger().log(Level.SEVERE, "Failed to roll back", ee); getLogger().log(Level.SEVERE, "Failed to roll back", ee);
int size = size(); int size = size();
// this protects against infinite looping // this protects against infinite looping
int counter = 0; int counter = 0;
int oldIndex;
while (counter < size) { while (counter < size) {
for (Integer i : itemIndexes.keySet()) {
if (itemIndexes.get(i).equals(itemId)) {
return i;
if (itemIndexes.containsValue(itemId)) {
for (Integer idx : itemIndexes.keySet()) {
if (itemIndexes.get(idx).equals(itemId)) {
return idx;
}
} }
counter++;
} }
oldIndex = currentOffset;
// load in the next page. // load in the next page.
int nextIndex = (currentOffset / (pageLength * CACHE_RATIO) + 1)
* (pageLength * CACHE_RATIO);
int nextIndex = currentOffset + pageLength * CACHE_RATIO
+ cacheOverlap;
if (nextIndex >= size) { if (nextIndex >= size) {
// Container wrapped around, start from index 0. // Container wrapped around, start from index 0.
nextIndex = 0; nextIndex = 0;
} }
updateOffsetAndCache(nextIndex); updateOffsetAndCache(nextIndex);

// Update counter
if (currentOffset > oldIndex) {
counter += currentOffset - oldIndex;
} else {
counter += size - oldIndex;
}
} }
// safeguard in case item not found // safeguard in case item not found
return -1; return -1;
*/ */
private void setPageLengthInternal(int pageLength) { private void setPageLengthInternal(int pageLength) {
this.pageLength = pageLength > 0 ? pageLength : DEFAULT_PAGE_LENGTH; this.pageLength = pageLength > 0 ? pageLength : DEFAULT_PAGE_LENGTH;
cachedItems.setCacheLimit(CACHE_RATIO * getPageLength());
cacheOverlap = getPageLength();
cachedItems.setCacheLimit(CACHE_RATIO * getPageLength() + cacheOverlap);
} }


/** /**
try { try {
getLogger().log(Level.FINER, getLogger().log(Level.FINER,
"Commiting changes through delegate..."); "Commiting changes through delegate...");
delegate.beginTransaction();
queryDelegate.beginTransaction();
/* Perform buffered deletions */ /* Perform buffered deletions */
for (RowItem item : removedItems.values()) { for (RowItem item : removedItems.values()) {
if (!delegate.removeRow(item)) {
if (!queryDelegate.removeRow(item)) {
throw new SQLException("Removal failed for row with ID: " throw new SQLException("Removal failed for row with ID: "
+ item.getId()); + item.getId());
} }
} }
/* Perform buffered modifications */ /* Perform buffered modifications */
for (RowItem item : modifiedItems) { for (RowItem item : modifiedItems) {
if (delegate.storeRow(item) > 0) {
if (queryDelegate.storeRow(item) > 0) {
/* /*
* Also reset the modified state in the item in case it is * Also reset the modified state in the item in case it is
* reused e.g. in a form. * reused e.g. in a form.
*/ */
item.commit(); item.commit();
} else { } else {
delegate.rollback();
queryDelegate.rollback();
refresh(); refresh();
throw new ConcurrentModificationException( throw new ConcurrentModificationException(
"Item with the ID '" + item.getId() "Item with the ID '" + item.getId()
} }
/* Perform buffered additions */ /* Perform buffered additions */
for (RowItem item : addedItems) { for (RowItem item : addedItems) {
delegate.storeRow(item);
queryDelegate.storeRow(item);
} }
delegate.commit();
queryDelegate.commit();
removedItems.clear(); removedItems.clear();
addedItems.clear(); addedItems.clear();
modifiedItems.clear(); modifiedItems.clear();
CacheFlushNotifier.notifyOfCacheFlush(this); CacheFlushNotifier.notifyOfCacheFlush(this);
} }
} catch (SQLException e) { } catch (SQLException e) {
delegate.rollback();
queryDelegate.rollback();
throw e; throw e;
} catch (OptimisticLockException e) { } catch (OptimisticLockException e) {
delegate.rollback();
queryDelegate.rollback();
throw e; throw e;
} }
} }
void itemChangeNotification(RowItem changedItem) { void itemChangeNotification(RowItem changedItem) {
if (autoCommit) { if (autoCommit) {
try { try {
delegate.beginTransaction();
if (delegate.storeRow(changedItem) == 0) {
delegate.rollback();
queryDelegate.beginTransaction();
if (queryDelegate.storeRow(changedItem) == 0) {
queryDelegate.rollback();
refresh(); refresh();
throw new ConcurrentModificationException( throw new ConcurrentModificationException(
"Item with the ID '" + changedItem.getId() "Item with the ID '" + changedItem.getId()
+ "' has been externally modified."); + "' has been externally modified.");
} }
delegate.commit();
queryDelegate.commit();
if (notificationsEnabled) { if (notificationsEnabled) {
CacheFlushNotifier.notifyOfCacheFlush(this); CacheFlushNotifier.notifyOfCacheFlush(this);
} }
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"itemChangeNotification failed, rolling back...", e); "itemChangeNotification failed, rolling back...", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException ee) { } catch (SQLException ee) {
/* Nothing can be done here */ /* Nothing can be done here */
getLogger().log(Level.SEVERE, "Rollback failed", e); getLogger().log(Level.SEVERE, "Rollback failed", e);
* Index of the item that was requested, but not found in cache * Index of the item that was requested, but not found in cache
*/ */
private void updateOffsetAndCache(int index) { private void updateOffsetAndCache(int index) {
if (itemIndexes.containsKey(index)) {
return;
}
currentOffset = (index / (pageLength * CACHE_RATIO))
* (pageLength * CACHE_RATIO);
int oldOffset = currentOffset;
currentOffset = (index / pageLength) * pageLength - cacheOverlap;
if (currentOffset < 0) { if (currentOffset < 0) {
currentOffset = 0; currentOffset = 0;
} }

if (oldOffset == currentOffset && !cachedItems.isEmpty()) {
return;
}

getPage(); getPage();
} }


} }
try { try {
try { try {
delegate.setFilters(filters);
queryDelegate.setFilters(filters);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
getLogger().log(Level.FINE, getLogger().log(Level.FINE,
"The query delegate doesn't support filtering", e); "The query delegate doesn't support filtering", e);
} }
try { try {
delegate.setOrderBy(sorters);
queryDelegate.setOrderBy(sorters);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
getLogger().log(Level.FINE, getLogger().log(Level.FINE,
"The query delegate doesn't support sorting", e); "The query delegate doesn't support sorting", e);
} }
int newSize = delegate.getCount();
int newSize = queryDelegate.getCount();
sizeUpdated = new Date(); sizeUpdated = new Date();
sizeDirty = false; sizeDirty = false;
if (newSize != size) { if (newSize != size) {
private void getPropertyIds() throws SQLException { private void getPropertyIds() throws SQLException {
propertyIds.clear(); propertyIds.clear();
propertyTypes.clear(); propertyTypes.clear();
delegate.setFilters(null);
delegate.setOrderBy(null);
queryDelegate.setFilters(null);
queryDelegate.setOrderBy(null);
ResultSet rs = null; ResultSet rs = null;
ResultSetMetaData rsmd = null; ResultSetMetaData rsmd = null;
try { try {
delegate.beginTransaction();
rs = delegate.getResults(0, 1);
queryDelegate.beginTransaction();
rs = queryDelegate.getResults(0, 1);
rsmd = rs.getMetaData(); rsmd = rs.getMetaData();
boolean resultExists = rs.next(); boolean resultExists = rs.next();
Class<?> type = null; Class<?> type = null;


boolean persistable = !rsmd.isReadOnly(i); boolean persistable = !rsmd.isReadOnly(i);


if (delegate instanceof TableQuery) {
if (queryDelegate instanceof TableQuery) {
if (rsmd.getColumnLabel(i).equals( if (rsmd.getColumnLabel(i).equals(
((TableQuery) delegate).getVersionColumn())) {
((TableQuery) queryDelegate).getVersionColumn())) {
readOnly = true; readOnly = true;
} }
} }
propertyPersistable.put(colName, persistable); propertyPersistable.put(colName, persistable);
propertyNullable.put(colName, propertyNullable.put(colName,
rsmd.isNullable(i) == ResultSetMetaData.columnNullable); rsmd.isNullable(i) == ResultSetMetaData.columnNullable);
propertyPrimaryKey.put(colName, delegate.getPrimaryKeyColumns()
propertyPrimaryKey.put(colName, queryDelegate
.getPrimaryKeyColumns()
.contains(rsmd.getColumnLabel(i))); .contains(rsmd.getColumnLabel(i)));
propertyTypes.put(colName, type); propertyTypes.put(colName, type);
} }
rs.getStatement().close(); rs.getStatement().close();
rs.close(); rs.close();
delegate.commit();
queryDelegate.commit();
getLogger().log(Level.FINER, "Property IDs fetched."); getLogger().log(Level.FINER, "Property IDs fetched.");
} catch (SQLException e) { } catch (SQLException e) {
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"Failed to fetch property ids, rolling back", e); "Failed to fetch property ids, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException e1) { } catch (SQLException e1) {
getLogger().log(Level.SEVERE, "Failed to roll back", e1); getLogger().log(Level.SEVERE, "Failed to roll back", e1);
} }
itemIndexes.clear(); itemIndexes.clear();
try { try {
try { try {
delegate.setOrderBy(sorters);
queryDelegate.setOrderBy(sorters);
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
/* The query delegate doesn't support sorting. */ /* The query delegate doesn't support sorting. */
/* No need to do anything. */ /* No need to do anything. */
getLogger().log(Level.FINE, getLogger().log(Level.FINE,
"The query delegate doesn't support sorting", e); "The query delegate doesn't support sorting", e);
} }
delegate.beginTransaction();
int fetchedRows = pageLength * CACHE_RATIO;
rs = delegate.getResults(currentOffset, fetchedRows);
queryDelegate.beginTransaction();
int fetchedRows = pageLength * CACHE_RATIO + cacheOverlap;
rs = queryDelegate.getResults(currentOffset, fetchedRows);
rsmd = rs.getMetaData(); rsmd = rs.getMetaData();
List<String> pKeys = delegate.getPrimaryKeyColumns();
List<String> pKeys = queryDelegate.getPrimaryKeyColumns();
// } // }
/* Create new items and column properties */ /* Create new items and column properties */
ColumnProperty cp = null; ColumnProperty cp = null;
int rowCount = currentOffset; int rowCount = currentOffset;
if (!delegate.implementationRespectsPagingLimits()) {
if (!queryDelegate.implementationRespectsPagingLimits()) {
rowCount = currentOffset = 0; rowCount = currentOffset = 0;
setPageLengthInternal(size); setPageLengthInternal(size);
} }
} }
rs.getStatement().close(); rs.getStatement().close();
rs.close(); rs.close();
delegate.commit();
queryDelegate.commit();
getLogger().log(Level.FINER, "Fetched {0} rows starting from {1}", getLogger().log(Level.FINER, "Fetched {0} rows starting from {1}",
new Object[] { fetchedRows, currentOffset }); new Object[] { fetchedRows, currentOffset });
} catch (SQLException e) { } catch (SQLException e) {
getLogger().log(Level.WARNING, getLogger().log(Level.WARNING,
"Failed to fetch rows, rolling back", e); "Failed to fetch rows, rolling back", e);
try { try {
delegate.rollback();
queryDelegate.rollback();
} catch (SQLException e1) { } catch (SQLException e1) {
getLogger().log(Level.SEVERE, "Failed to roll back", e1); getLogger().log(Level.SEVERE, "Failed to roll back", e1);
} }
*/ */
private boolean isColumnIdentifierValid(String identifier) { private boolean isColumnIdentifierValid(String identifier) {
if (identifier.equalsIgnoreCase("rownum") if (identifier.equalsIgnoreCase("rownum")
&& delegate instanceof TableQuery) {
TableQuery tq = (TableQuery) delegate;
&& queryDelegate instanceof TableQuery) {
TableQuery tq = (TableQuery) queryDelegate;
if (tq.getSqlGenerator() instanceof MSSQLGenerator if (tq.getSqlGenerator() instanceof MSSQLGenerator
|| tq.getSqlGenerator() instanceof OracleGenerator) { || tq.getSqlGenerator() instanceof OracleGenerator) {
return false; return false;
* @return current querydelegate * @return current querydelegate
*/ */
protected QueryDelegate getQueryDelegate() { protected QueryDelegate getQueryDelegate() {
return delegate;
return queryDelegate;
} }


/************************************/ /************************************/
* @param listener * @param listener
*/ */
public void addRowIdChangeListener(RowIdChangeListener listener) { public void addRowIdChangeListener(RowIdChangeListener listener) {
if (delegate instanceof QueryDelegate.RowIdChangeNotifier) {
((QueryDelegate.RowIdChangeNotifier) delegate)
if (queryDelegate instanceof QueryDelegate.RowIdChangeNotifier) {
((QueryDelegate.RowIdChangeNotifier) queryDelegate)
.addListener(listener); .addListener(listener);
} }
} }
* @param listener * @param listener
*/ */
public void removeRowIdChangeListener(RowIdChangeListener listener) { public void removeRowIdChangeListener(RowIdChangeListener listener) {
if (delegate instanceof QueryDelegate.RowIdChangeNotifier) {
((QueryDelegate.RowIdChangeNotifier) delegate)
if (queryDelegate instanceof QueryDelegate.RowIdChangeNotifier) {
((QueryDelegate.RowIdChangeNotifier) queryDelegate)
.removeListener(listener); .removeListener(listener);
} }
} }

+ 17
- 4
server/src/com/vaadin/server/VaadinServletService.java Bestand weergeven

public class VaadinServletService extends VaadinService { public class VaadinServletService extends VaadinService {
private final VaadinServlet servlet; private final VaadinServlet servlet;


private final static boolean atmosphereAvailable = checkAtmosphereSupport();
private boolean atmosphereAvailable = checkAtmosphereSupport();


/** /**
* Keeps track of whether a warning about missing push support has already * Keeps track of whether a warning about missing push support has already
private static boolean checkAtmosphereSupport() { private static boolean checkAtmosphereSupport() {
try { try {
String rawVersion = Version.getRawVersion(); String rawVersion = Version.getRawVersion();
if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION.equals(rawVersion)) {
if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION
.equals(rawVersion)) {
getLogger().log( getLogger().log(
Level.WARNING, Level.WARNING,
Constants.INVALID_ATMOSPHERE_VERSION_WARNING, Constants.INVALID_ATMOSPHERE_VERSION_WARNING,
new Object[] { Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION,
new Object[] {
Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION,
rawVersion }); rawVersion });
} }
return true; return true;
handlers.add(0, new ServletBootstrapHandler()); handlers.add(0, new ServletBootstrapHandler());
handlers.add(new ServletUIInitHandler()); handlers.add(new ServletUIInitHandler());
if (atmosphereAvailable) { if (atmosphereAvailable) {
handlers.add(new PushRequestHandler(this));
try {
handlers.add(new PushRequestHandler(this));
} catch (ServiceException e) {
// Atmosphere init failed. Push won't work but we don't throw a
// service exception as we don't want to prevent non-push
// applications from working
getLogger()
.log(Level.WARNING,
"Error initializing Atmosphere. Push will not work.",
e);
atmosphereAvailable = false;
}
} }
return handlers; return handlers;
} }

+ 1
- 1
server/src/com/vaadin/server/communication/PushRequestHandler.java Bestand weergeven

trackMessageSize.configure(atmosphere.getAtmosphereConfig()); trackMessageSize.configure(atmosphere.getAtmosphereConfig());
atmosphere.interceptor(trackMessageSize); atmosphere.interceptor(trackMessageSize);
} catch (ServletException e) { } catch (ServletException e) {
throw new ServiceException("Could not read atmosphere settings", e);
throw new ServiceException("Atmosphere init failed", e);
} }
} }



+ 1
- 0
theme-compiler/build.xml Bestand weergeven



<target name="jar" depends="parser"> <target name="jar" depends="parser">
<antcall target="common.jar"> <antcall target="common.jar">
<param name="import-package" value="org.apache.commons.jexl2;version=&quot;2.1.1&quot;,org.w3c.css.sac;version=&quot;1.3&quot;,org.w3c.flute.parser;version=&quot;1.3.0.gg2&quot;,org.w3c.flute.parser.selectors;version=&quot;1.3.0.gg2&quot;,org.w3c.flute.util;version=&quot;1.3.0.gg2&quot;" />
<reference torefid="extra.jar.includes" refid="empty.reference" /> <reference torefid="extra.jar.includes" refid="empty.reference" />
</antcall> </antcall>
</target> </target>

+ 1
- 1
uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java Bestand weergeven

"Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"); "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko");
expectedUserAgent expectedUserAgent
.put(Browser.CHROME.getDesiredCapabilities(), .put(Browser.CHROME.getDesiredCapabilities(),
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36");
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36");


} }



+ 0
- 36
uitest/src/com/vaadin/tests/components/embedded/EmbeddedApplet.html Bestand weergeven

<?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>EmbeddedClickListenerRelativeCoordinates</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">EmbeddedClickListenerRelativeCoordinates</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.components.embedded.EmbeddedApplet?restartApplication</td>
<td></td>
</tr>
<tr>
<td>screenCapture</td>
<td></td>
<td>with-applet</td>
</tr>
<tr>
<td>click</td>
<td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedApplet::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
<td>screenCapture</td>
<td></td>
<td>without-applet</td>
</tr>
</tbody></table>
</body>
</html>

+ 99
- 0
uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainer.java Bestand weergeven

package com.vaadin.tests.components.table;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import com.vaadin.data.util.sqlcontainer.SQLContainer;
import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.query.QueryDelegate;
import com.vaadin.data.util.sqlcontainer.query.TableQuery;
import com.vaadin.data.util.sqlcontainer.query.generator.DefaultSQLGenerator;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
public class TableScrollingWithSQLContainer extends UI {

/** Table should never end up calling indexOfId in this case */
private class LimitedSQLContainer extends SQLContainer {

public LimitedSQLContainer(QueryDelegate delegate) throws SQLException {
super(delegate);
}

@Override
public int indexOfId(Object itemId) {
throw new RuntimeException("This function should not be called");
}
}

private void generateTestData(JDBCConnectionPool connectionPool)
throws SQLException {
Connection conn = connectionPool.reserveConnection();
Statement statement = conn.createStatement();
try {
statement.execute("drop table PEOPLE");
} catch (SQLException e) {
// Will fail if table doesn't exist, which is OK.
conn.rollback();
}
statement
.execute("create table people (id integer generated always as identity,"
+ " name varchar(32), AGE INTEGER)");
statement.execute("alter table people add primary key (id)");
for (int i = 0; i < 5000; i++) {
statement
.executeUpdate("insert into people values(default, 'Person "
+ i + "', '" + i % 99 + "')");
}
statement.close();
conn.commit();
connectionPool.releaseConnection(conn);
}

static final String TABLE = "table";

@Override
public void init(VaadinRequest request) {
try {
SimpleJDBCConnectionPool connectionPool = new SimpleJDBCConnectionPool(
"org.hsqldb.jdbc.JDBCDriver",
"jdbc:hsqldb:mem:sqlcontainer", "SA", "", 2, 20);
generateTestData(connectionPool);

TableQuery query = new TableQuery("people", connectionPool,
new DefaultSQLGenerator());

SQLContainer container = new LimitedSQLContainer(query);

final VerticalLayout rootLayout = new VerticalLayout();

final Table table = new Table();
table.setContainerDataSource(container);
table.setCurrentPageFirstItemIndex(300);
rootLayout.addComponent(table);

table.setImmediate(true);

rootLayout.addComponent(new Button("GOTO 200", new ClickListener() {

@Override
public void buttonClick(ClickEvent event) {
table.setCurrentPageFirstItemIndex(200);
}
}));

setContent(rootLayout);

} catch (Exception e) {
e.printStackTrace();
}
}
}

+ 35
- 0
uitest/src/com/vaadin/tests/components/table/TableScrollingWithSQLContainerTest.java Bestand weergeven

/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components.table;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;

import com.vaadin.tests.tb3.MultiBrowserTest;

public class TableScrollingWithSQLContainerTest extends MultiBrowserTest {

@Test
public void verifySQLContainerIndexOfIDNotCalled() {
openTestURL();

vaadinElement("/VVerticalLayout[0]/VButton[0]").click();

Assert.assertTrue("SQLContainer indexOfId was called", driver
.findElements(By.className("v-errorindicator")).isEmpty());
}
}

+ 1
- 1
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java Bestand weergeven

public abstract class MultiBrowserTest extends PrivateTB3Configuration { public abstract class MultiBrowserTest extends PrivateTB3Configuration {


public enum Browser { public enum Browser {
FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(29)), SAFARI(
FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI(
BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil
.ie(9)), IE10(BrowserUtil.ie(10)), IE11(BrowserUtil.ie(11)), OPERA( .ie(9)), IE10(BrowserUtil.ie(10)), IE11(BrowserUtil.ie(11)), OPERA(
BrowserUtil.opera(17)); BrowserUtil.opera(17));

Laden…
Annuleren
Opslaan