summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-10 12:39:39 +0300
committerLeif Åstrand <leif@vaadin.com>2012-04-10 12:39:39 +0300
commit22998065ade29c7d093513010cae817a87efd5a3 (patch)
treef9c72ac71348e1dc25d772a215637358e59fe6b4 /src
parentc5ab6b8c898357ce73918da852307ad2c9840290 (diff)
parent105d563f6622256d00d580dc52cc302e7c810e56 (diff)
downloadvaadin-framework-22998065ade29c7d093513010cae817a87efd5a3.tar.gz
vaadin-framework-22998065ade29c7d093513010cae817a87efd5a3.zip
Merge remote branch 'origin/master' into layoutgraph
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/VDebugConsole.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/AbsoluteLayoutConnector.java19
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java63
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java16
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java29
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java22
-rw-r--r--src/com/vaadin/ui/TreeTable.java4
8 files changed, 110 insertions, 51 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
index f28af4040d..fea777ff72 100644
--- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
@@ -634,6 +634,10 @@ public class VDebugConsole extends VOverlay implements Console {
}
error(Util.getSimpleName(e) + ": " + e.getMessage());
GWT.log(e.getMessage(), e);
+ if (!GWT.isProdMode()) {
+ e.printStackTrace();
+ }
+
}
public void init() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbsoluteLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbsoluteLayoutConnector.java
index 5761bd4eae..1ee68fa49f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/AbsoluteLayoutConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/AbsoluteLayoutConnector.java
@@ -15,6 +15,7 @@ import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.Connector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
+import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VCaption;
import com.vaadin.terminal.gwt.client.communication.RpcProxy;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
@@ -55,7 +56,7 @@ public class AbsoluteLayoutConnector extends
@Override
protected ComponentConnector getChildComponent(Element element) {
- return getWidget().getComponent(element);
+ return getConnectorForElement(element);
}
@Override
@@ -75,6 +76,21 @@ public class AbsoluteLayoutConnector extends
rpc = RpcProxy.create(AbsoluteLayoutServerRPC.class, this);
}
+ /**
+ * Returns the deepest nested child component which contains "element". The
+ * child component is also returned if "element" is part of its caption.
+ *
+ * @param element
+ * An element that is a nested sub element of the root element in
+ * this layout
+ * @return The Paintable which the element is a part of. Null if the element
+ * belongs to the layout and not to a child.
+ */
+ protected ComponentConnector getConnectorForElement(Element element) {
+ return Util.getConnectorForElement(getConnection(), getWidget(),
+ element);
+ }
+
public void updateCaption(ComponentConnector component) {
VAbsoluteLayout absoluteLayoutWidget = getWidget();
AbsoluteWrapper componentWrapper = getWrapper(component);
@@ -87,6 +103,7 @@ public class AbsoluteLayoutConnector extends
if (caption == null) {
caption = new VCaption(component, getConnection());
absoluteLayoutWidget.add(caption);
+ componentWrapper.setCaption(caption);
}
caption.updateCaption();
componentWrapper.updateCaptionPosition();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java
index 29cce052f0..938b0a2e34 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java
@@ -11,6 +11,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
import com.vaadin.terminal.gwt.client.LayoutManager;
import com.vaadin.terminal.gwt.client.Paintable;
@@ -296,8 +297,7 @@ public abstract class AbstractOrderedLayoutConnector extends
}
@Override
- public void onConnectorHierarchyChange(
- com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent event) {
+ public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
super.onConnectorHierarchyChange(event);
List<ComponentConnector> previousChildren = event.getOldChildren();
int currentIndex = 0;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java
index de0f6d9368..06d9669d7c 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/GridLayoutConnector.java
@@ -3,7 +3,6 @@
*/
package com.vaadin.terminal.gwt.client.ui;
-import java.util.HashSet;
import java.util.Iterator;
import com.google.gwt.core.client.GWT;
@@ -12,6 +11,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
+import com.vaadin.terminal.gwt.client.ConnectorMap;
import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.UIDL;
@@ -128,27 +128,11 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
layout.columnWidths = new int[cols];
layout.rowHeights = new int[rows];
- if (layout.cells == null) {
- layout.cells = new Cell[cols][rows];
- } else if (layout.cells.length != cols
- || layout.cells[0].length != rows) {
- Cell[][] newCells = new Cell[cols][rows];
- for (int i = 0; i < layout.cells.length; i++) {
- for (int j = 0; j < layout.cells[i].length; j++) {
- if (i < cols && j < rows) {
- newCells[i][j] = layout.cells[i][j];
- }
- }
- }
- layout.cells = newCells;
- }
+ layout.setSize(rows, cols);
final int[] alignments = uidl.getIntArrayAttribute("alignments");
int alignmentIndex = 0;
- HashSet<Widget> nonRenderedWidgets = new HashSet<Widget>(
- layout.widgetToCell.keySet());
-
for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
final UIDL r = (UIDL) i.next();
if ("gr".equals(r.getTag())) {
@@ -158,11 +142,34 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
int row = cellUidl.getIntAttribute("y");
int col = cellUidl.getIntAttribute("x");
- Cell cell = layout.getCell(row, col, cellUidl);
+ Widget previousWidget = null;
+
+ Cell cell = layout.getCell(row, col);
+ if (cell != null && cell.slot != null) {
+ // This is an update. Track if the widget changes
+ // and update the caption if that happens. This
+ // workaround can be removed once the DOM update is
+ // done in onContainerHierarchyChange
+ previousWidget = cell.slot.getWidget();
+ }
+
+ cell = layout.createCell(row, col);
+
+ cell.updateFromUidl(cellUidl);
+
if (cell.hasContent()) {
cell.setAlignment(new AlignmentInfo(
alignments[alignmentIndex++]));
- nonRenderedWidgets.remove(cell.slot.getWidget());
+ if (cell.slot.getWidget() != previousWidget) {
+ // Widget changed or widget moved from another
+ // slot. Update its caption as the widget might
+ // have called updateCaption when the widget was
+ // still in its old slot. This workaround can be
+ // removed once the DOM update
+ // is done in onContainerHierarchyChange
+ updateCaption(ConnectorMap.get(getConnection())
+ .getConnector(cell.slot.getWidget()));
+ }
}
}
}
@@ -181,9 +188,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
needCaptionUpdate = false;
for (ComponentConnector child : getChildren()) {
- if (child.delegateCaptionHandling()) {
- updateCaption(child);
- }
+ updateCaption(child);
}
}
getLayoutManager().setNeedsUpdate(this);
@@ -213,11 +218,19 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
}
public void updateCaption(ComponentConnector childConnector) {
+ if (!childConnector.delegateCaptionHandling()) {
+ // Check not required by interface but by workarounds in this class
+ // when updateCaption is explicitly called for all children.
+ return;
+ }
+
VGridLayout layout = getWidget();
Cell cell = layout.widgetToCell.get(childConnector.getWidget());
if (cell == null) {
- // workaround before updateFromUidl is removed. Update the
- // captions at the end of updateFromUidl instead of immediately
+ // workaround before updateFromUidl is removed. We currently update
+ // the captions at the end of updateFromUidl instead of immediately
+ // because the DOM has not been set up at this point (as it is done
+ // in updateFromUidl)
needCaptionUpdate = true;
return;
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java
index c5c3834d4b..4b411e910c 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java
@@ -12,8 +12,6 @@ import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.ComponentConnector;
-import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VCaption;
public class VAbsoluteLayout extends ComplexPanel {
@@ -133,18 +131,4 @@ public class VAbsoluteLayout extends ComplexPanel {
}
}
- /**
- * Returns the deepest nested child component which contains "element". The
- * child component is also returned if "element" is part of its caption.
- *
- * @param element
- * An element that is a nested sub element of the root element in
- * this layout
- * @return The Paintable which the element is a part of. Null if the element
- * belongs to the layout and not to a child.
- */
- ComponentConnector getComponent(Element element) {
- return Util.getConnectorForElement(client, this, element);
- }
-
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
index ef2469312b..6e58a821d1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VGridLayout.java
@@ -585,21 +585,24 @@ public class VGridLayout extends ComplexPanel {
}
}
+ Cell getCell(int row, int col) {
+ return cells[col][row];
+ }
+
/**
- * Returns the Cell with the given coordinates. Creates a new Cell if an
- * existing was not found and also updates the Cell based on the given UIDL.
+ * Creates a new Cell with the given coordinates. If an existing cell was
+ * found, returns that one.
*
* @param row
* @param col
* @return
*/
- Cell getCell(int row, int col, UIDL c) {
- Cell cell = cells[col][row];
+ Cell createCell(int row, int col) {
+ Cell cell = getCell(row, col);
if (cell == null) {
cell = new Cell(row, col);
cells[col][row] = cell;
}
- cell.updateFromUidl(c);
return cell;
}
@@ -660,4 +663,20 @@ public class VGridLayout extends ComplexPanel {
}
}
+ public void setSize(int rows, int cols) {
+ if (cells == null) {
+ cells = new Cell[cols][rows];
+ } else if (cells.length != cols || cells[0].length != rows) {
+ Cell[][] newCells = new Cell[cols][rows];
+ for (int i = 0; i < cells.length; i++) {
+ for (int j = 0; j < cells[i].length; j++) {
+ if (i < cols && j < rows) {
+ newCells[i][j] = cells[i][j];
+ }
+ }
+ }
+ cells = newCells;
+ }
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
index 90efdf2296..9f1691112b 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
@@ -15,6 +15,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Collection;
@@ -34,6 +35,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import sun.net.www.protocol.file.FileURLConnection;
+
import com.vaadin.Application;
import com.vaadin.Application.ApplicationStartEvent;
import com.vaadin.Application.SystemMessages;
@@ -1123,8 +1126,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
// Find the modification timestamp
long lastModifiedTime = 0;
+ URLConnection connection = null;
try {
- lastModifiedTime = resourceUrl.openConnection().getLastModified();
+ connection = resourceUrl.openConnection();
+ lastModifiedTime = connection.getLastModified();
// Remove milliseconds to avoid comparison problems (milliseconds
// are not returned by the browser in the "If-Modified-Since"
// header).
@@ -1140,6 +1145,21 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
Level.FINEST,
"Failed to find out last modified timestamp. Continuing without it.",
e);
+ } finally {
+ if (connection instanceof FileURLConnection) {
+ try {
+ // Explicitly close the input stream to prevent it
+ // from remaining hanging
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700
+ InputStream is = connection.getInputStream();
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ logger.log(Level.INFO,
+ "Error closing FileURLConnection input stream", e);
+ }
+ }
}
// Set type mime type if we can determine it based on the filename
diff --git a/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java
index f920810edf..80e721aaea 100644
--- a/src/com/vaadin/ui/TreeTable.java
+++ b/src/com/vaadin/ui/TreeTable.java
@@ -551,7 +551,9 @@ public class TreeTable extends Table implements Hierarchical {
public void setContainerDataSource(Container newDataSource) {
cStrategy = null;
- containerSupportsPartialUpdates = (newDataSource instanceof ItemSetChangeNotifier);
+ // FIXME: This disables partial updates until TreeTable is fixed so it
+ // does not change component hierarchy during paint
+ containerSupportsPartialUpdates = (newDataSource instanceof ItemSetChangeNotifier) && false;
if (!(newDataSource instanceof Hierarchical)) {
newDataSource = new ContainerHierarchicalWrapper(newDataSource);