From: Petter Holmström Date: Fri, 30 Oct 2009 11:04:13 +0000 (+0000) Subject: Merged with 6.2 X-Git-Tag: 6.7.0.beta1~2266^2~26 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d2f881319198940e2443fe5f0284176d77f3973b;p=vaadin-framework.git Merged with 6.2 svn changeset:9505/svn branch:portlet_2.0 --- diff --git a/WebContent/VAADIN/themes/reindeer/common/common.css b/WebContent/VAADIN/themes/reindeer/common/common.css index 09d22f35bb..731e0eaf1b 100644 --- a/WebContent/VAADIN/themes/reindeer/common/common.css +++ b/WebContent/VAADIN/themes/reindeer/common/common.css @@ -73,7 +73,6 @@ background-color: #fffcdd; border: 1px solid #b8b295; font-size: 11px; - line-height: 13px; color: #222; } .v-tooltip-text { diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css index 65e64a0724..e2f782424d 100644 --- a/WebContent/VAADIN/themes/reindeer/styles.css +++ b/WebContent/VAADIN/themes/reindeer/styles.css @@ -2304,7 +2304,6 @@ div.v-tree-node-leaf { background-color: #fffcdd; border: 1px solid #b8b295; font-size: 11px; - line-height: 13px; color: #222; } .v-tooltip-text { diff --git a/WebContent/VAADIN/themes/runo/common/common.css b/WebContent/VAADIN/themes/runo/common/common.css index 7b40130c45..7b8317c4f3 100644 --- a/WebContent/VAADIN/themes/runo/common/common.css +++ b/WebContent/VAADIN/themes/runo/common/common.css @@ -38,7 +38,6 @@ border-top-color: #d5d2c1; border-left-color: #d5d2c1; font-size: 11px; - line-height: 13px; font-family: arial, helvetica, tahoma, verdana, sans-serif; color: #5d5444; } diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index 94d2f81d33..88e08840e1 100644 --- a/WebContent/VAADIN/themes/runo/styles.css +++ b/WebContent/VAADIN/themes/runo/styles.css @@ -1847,7 +1847,6 @@ div.v-tree-node-leaf { border-top-color: #d5d2c1; border-left-color: #d5d2c1; font-size: 11px; - line-height: 13px; font-family: arial, helvetica, tahoma, verdana, sans-serif; color: #5d5444; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VForm.java b/src/com/vaadin/terminal/gwt/client/ui/VForm.java index 97fbf9b72a..7117d2cebf 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VForm.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VForm.java @@ -48,9 +48,7 @@ public class VForm extends ComplexPanel implements Container { private RenderInformation renderInformation = new RenderInformation(); - private int borderPaddingHorizontal; - - private int borderPaddingVertical; + private int borderPaddingHorizontal = -1; private boolean rendering = false; @@ -75,25 +73,13 @@ public class VForm extends ComplexPanel implements Container { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; - boolean measure = false; - if (this.client == null) { - this.client = client; - measure = true; - } + this.client = client; if (client.updateComponent(this, uidl, false)) { rendering = false; return; } - if (measure) { - // Measure the border when the style names have been set - borderPaddingVertical = getOffsetHeight(); - int ow = getOffsetWidth(); - int dow = desc.getOffsetWidth(); - borderPaddingHorizontal = ow - dow; - } - boolean legendEmpty = true; if (uidl.hasAttribute("caption")) { DOM.setInnerText(caption, uidl.getStringAttribute("caption")); @@ -138,19 +124,8 @@ public class VForm extends ComplexPanel implements Container { // TODO Check if this is needed client.runDescendentsLayout(this); - final UIDL layoutUidl = uidl.getChildUIDL(0); - Container newLo = (Container) client.getPaintable(layoutUidl); - if (lo == null) { - lo = newLo; - add((Widget) lo, fieldContainer); - } else if (lo != newLo) { - client.unregisterPaintable(lo); - remove((Widget) lo); - lo = newLo; - add((Widget) lo, fieldContainer); - } - lo.updateFromUIDL(layoutUidl, client); - + // first render footer so it will be easier to handle relative height of + // main layout if (uidl.getChildCount() > 1) { // render footer Container newFooter = (Container) client.getPaintable(uidl @@ -165,13 +140,28 @@ public class VForm extends ComplexPanel implements Container { } footer = newFooter; footer.updateFromUIDL(uidl.getChildUIDL(1), client); + updateSize(); } else { if (footer != null) { remove((Widget) footer); client.unregisterPaintable(footer); + updateSize(); } } + final UIDL layoutUidl = uidl.getChildUIDL(0); + Container newLo = (Container) client.getPaintable(layoutUidl); + if (lo == null) { + lo = newLo; + add((Widget) lo, fieldContainer); + } else if (lo != newLo) { + client.unregisterPaintable(lo); + remove((Widget) lo); + lo = newLo; + add((Widget) lo, fieldContainer); + } + lo.updateFromUIDL(layoutUidl, client); + rendering = false; } @@ -181,7 +171,7 @@ public class VForm extends ComplexPanel implements Container { renderInformation.setContentAreaHeight(renderInformation .getRenderedSize().getHeight() - - borderPaddingVertical); + - getSpaceConsumedVertically()); if (BrowserInfo.get().isIE6()) { getElement().getStyle().setProperty("overflow", "hidden"); } @@ -192,18 +182,7 @@ public class VForm extends ComplexPanel implements Container { public RenderSpace getAllocatedSpace(Widget child) { if (child == lo) { - int hPixels = 0; - if (!"".equals(height)) { - hPixels = getOffsetHeight(); - hPixels -= borderPaddingVertical; - hPixels -= footerContainer.getOffsetHeight(); - hPixels -= errorMessage.getOffsetHeight(); - hPixels -= desc.getOffsetHeight(); - - } - - return new RenderSpace(renderInformation.getContentAreaSize() - .getWidth(), hPixels); + return renderInformation.getContentAreaSize(); } else if (child == footer) { return new RenderSpace(renderInformation.getContentAreaSize() .getWidth(), 0); @@ -271,8 +250,26 @@ public class VForm extends ComplexPanel implements Container { updateSize(); } + /** + * @return pixels consumed by decoration, captions, descrioptiosn etc.. In + * other words space, not used by the actual layout in form. + */ + private int getSpaceConsumedVertically() { + int offsetHeight2 = fieldSet.getOffsetHeight(); + int offsetHeight3 = fieldContainer.getOffsetHeight(); + int borderPadding = offsetHeight2 - offsetHeight3; + return borderPadding; + } + @Override public void setWidth(String width) { + if (borderPaddingHorizontal < 0) { + // measure excess size lazyly after stylename setting, but before + // setting width + int ow = getOffsetWidth(); + int dow = desc.getOffsetWidth(); + borderPaddingHorizontal = ow - dow; + } if (Util.equals(this.width, width)) { return; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 50b34193bd..575d35e5f0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -271,6 +271,16 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { .getIntAttribute("rows")); if (headerChangedDuringUpdate) { lazyAdjustColumnWidths.schedule(1); + } else { + // webkits may still bug with their disturbing scrollbar bug, + // See #3457 + // run overflow fix for scrollable area + DeferredCommand.addCommand(new Command() { + public void execute() { + Util.runWebkitOverflowAutoFix(bodyContainer + .getElement()); + } + }); } } else { if (scrollBody != null) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java index 422583cb19..35b411ff1b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VView.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java @@ -183,8 +183,17 @@ public class VView extends SimplePanel implements Container, ResizeHandler, final String url = open.getStringAttribute("src"); final String target = open.getStringAttribute("name"); if (target == null) { - // This window is closing. Nothing was done in the close event, - // so don't need to call it before going to the new url + // source will be opened to this browser window, but we may have + // to finish rendering this window in case this is a download + // (and window stays open). + DeferredCommand.addCommand(new Command() { + public void execute() { + goTo(url); + } + }); + } else if ("_self".equals(target)) { + // This window is closing (for sure). Only other opens are + // relevant in this change. See #3558, #2144 isClosed = true; goTo(url); } else { @@ -214,7 +223,8 @@ public class VView extends SimplePanel implements Container, ResizeHandler, childIndex++; } if (isClosed) { - // don't render the content + // don't render the content, something else will be opened to this + // browser view rendering = false; return; } diff --git a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index 8e73098454..4238aab019 100644 --- a/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -62,6 +62,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; import com.vaadin.ui.Upload; import com.vaadin.ui.Window; +import com.vaadin.ui.Upload.UploadException; /** * Application manager processes changes and paints for single application @@ -203,7 +204,18 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, // file pl.setUpload(uploadComponent); - uploadComponent.receiveUpload(upstream); + try { + uploadComponent.receiveUpload(upstream); + } catch (UploadException e) { + // error happened while receiving file. Handle the + // error in the same manner as it would have happened in + // variable change. + synchronized (application) { + handleChangeVariablesError(application, + uploadComponent, e, + new HashMap()); + } + } } } } catch (final FileUploadException e) { diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index 023764ca43..9497b26b00 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -212,7 +212,7 @@ public class JsonPaintTarget implements PaintTarget { if (xml == null || xml.length() <= 0) { return ""; } - return escapeXML(new StringBuffer(xml)).toString(); + return escapeXML(new StringBuilder(xml)).toString(); } /** @@ -220,16 +220,16 @@ public class JsonPaintTarget implements PaintTarget { * * @param xml * the String to be substituted. - * @return A new StringBuffer instance where all occurrences of XML + * @return A new StringBuilder instance where all occurrences of XML * sensitive characters are substituted with entities. * */ - static public StringBuffer escapeXML(StringBuffer xml) { + static StringBuilder escapeXML(StringBuilder xml) { if (xml == null || xml.length() <= 0) { - return new StringBuffer(""); + return new StringBuilder(""); } - final StringBuffer result = new StringBuffer(xml.length() * 2); + final StringBuilder result = new StringBuilder(xml.length() * 2); for (int i = 0; i < xml.length(); i++) { final char c = xml.charAt(i); @@ -247,7 +247,7 @@ public class JsonPaintTarget implements PaintTarget { if (s == null) { return ""; } - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { final char ch = s.charAt(i); switch (ch) { @@ -531,7 +531,7 @@ public class JsonPaintTarget implements PaintTarget { throw new NullPointerException( "Parameters must be non-null strings"); } - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); buf.append("\"" + name + "\":["); for (int i = 0; i < values.length; i++) { if (i > 0) { @@ -875,7 +875,7 @@ public class JsonPaintTarget implements PaintTarget { Vector attr = new Vector(); - StringBuffer data = new StringBuffer(); + StringBuilder data = new StringBuilder(); public boolean childrenArrayOpen = false; @@ -944,7 +944,7 @@ public class JsonPaintTarget implements PaintTarget { } public String getData() { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); final Iterator it = children.iterator(); while (it.hasNext()) { buf.append(startField()); @@ -958,7 +958,7 @@ public class JsonPaintTarget implements PaintTarget { } private String attributesAsJsonObject() { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); buf.append(startField()); buf.append("{"); for (final Iterator iter = attr.iterator(); iter.hasNext();) { @@ -981,7 +981,7 @@ public class JsonPaintTarget implements PaintTarget { if (variables.size() == 0) { return ""; } - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); buf.append(startField()); buf.append("\"v\":{"); final Iterator iter = variables.iterator(); @@ -1119,16 +1119,21 @@ public class JsonPaintTarget implements PaintTarget { @Override public String getJsonPresentation() { - String pres = "\"" + name + "\":["; + StringBuilder sb = new StringBuilder(); + sb.append("\""); + sb.append(name); + sb.append("\":["); for (int i = 0; i < value.length;) { - pres += "\"" + value[i] + "\""; + sb.append("\""); + sb.append(escapeJSON(value[i])); + sb.append("\""); i++; if (i < value.length) { - pres += ","; + sb.append(","); } } - pres += "]"; - return pres; + sb.append("]"); + return sb.toString(); } } diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java index 6a45860803..269d911ad1 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java @@ -7,10 +7,14 @@ import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.jar.Attributes; @@ -50,7 +54,8 @@ public class ClassPathExplorer { } }; - private static Map classpathLocations = getClasspathLocations(); + private static List rawClasspathEntries = getRawClasspathEntries(); + private static Map classpathLocations = getClasspathLocations(rawClasspathEntries); private ClassPathExplorer() { } @@ -150,8 +155,9 @@ public class ClassPathExplorer { * Determine every URL location defined by the current classpath, and it's * associated package name. */ - private final static Map getClasspathLocations() { - Map locations = new HashMap(); + private final static List getRawClasspathEntries() { + // try to keep the order of the classpath + List locations = new ArrayList(); String pathSep = System.getProperty("path.separator"); String classpath = System.getProperty("java.class.path"); @@ -169,14 +175,28 @@ public class ClassPathExplorer { for (int i = 0; i < split.length; i++) { String classpathEntry = split[i]; if (acceptClassPathEntry(classpathEntry)) { - File file = new File(classpathEntry); - include(null, file, locations); + locations.add(classpathEntry); } } return locations; } + /** + * Determine every URL location defined by the current classpath, and it's + * associated package name. + */ + private final static Map getClasspathLocations( + List rawClasspathEntries) { + // try to keep the order of the classpath + Map locations = new LinkedHashMap(); + for (String classpathEntry : rawClasspathEntries) { + File file = new File(classpathEntry); + include(null, file, locations); + } + return locations; + } + private static boolean acceptClassPathEntry(String classpathEntry) { if (!classpathEntry.endsWith(".jar")) { // accept all non jars (practically directories) @@ -351,6 +371,41 @@ public class ClassPathExplorer { } } + /** + * Find and return the default source directory where to create new + * widgetsets. + * + * Return the first directory (not a JAR file etc.) on the classpath by + * default. + * + * TODO this could be done better... + * + * @return URL + */ + public static URL getDefaultSourceDirectory() { + System.err.println("classpathLocations keys: " + + classpathLocations.keySet()); + Iterator it = rawClasspathEntries.iterator(); + while (it.hasNext()) { + String entry = it.next(); + + File directory = new File(entry); + if (directory.exists() && !directory.isHidden() + && directory.isDirectory()) { + try { + return new URL("file://" + directory.getCanonicalPath()); + } catch (MalformedURLException e) { + e.printStackTrace(); + // ignore: continue to the next classpath entry + } catch (IOException e) { + e.printStackTrace(); + // ignore: continue to the next classpath entry + } + } + } + return null; + } + /** * Test method for helper tool */ diff --git a/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java b/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java index 6ce6097269..d849c85fc7 100644 --- a/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java +++ b/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java @@ -41,9 +41,14 @@ public class WidgetSetBuilder { .getAvailableWidgetSets(); URL sourceUrl = availableWidgetSets.get(widgetset); + if (sourceUrl == null) { + // find first/default source directory + sourceUrl = ClassPathExplorer.getDefaultSourceDirectory(); + } String widgetsetfilename = sourceUrl.getFile() + "/" + widgetset.replace(".", "/") + ".gwt.xml"; + File widgetsetFile = new File(widgetsetfilename); if (!widgetsetFile.exists()) { // create empty gwt module file @@ -83,7 +88,7 @@ public class WidgetSetBuilder { } } - changed = changed ? true : content.equals(originalContent); + changed = changed || !content.equals(originalContent); if (changed) { commitChanges(widgetsetfilename, content); } diff --git a/src/com/vaadin/ui/Upload.java b/src/com/vaadin/ui/Upload.java index 4789641193..dfbbbfc103 100644 --- a/src/com/vaadin/ui/Upload.java +++ b/src/com/vaadin/ui/Upload.java @@ -122,7 +122,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * * @param upload */ - public void receiveUpload(UploadStream upload) { + public void receiveUpload(UploadStream upload) throws UploadException { if (!isUploading) { throw new IllegalStateException("uploading not started"); } @@ -174,7 +174,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { } } if (interrupted) { - throw new Exception("Upload interrupted by other thread"); + throw new UploadInterruptedException(); } } @@ -188,17 +188,22 @@ public class Upload extends AbstractComponent implements Component.Focusable { } catch (final Exception e) { synchronized (application) { - // Download interrupted - try { - // still try to close output stream - out.close(); - } catch (IOException ignored) { + if (e instanceof UploadInterruptedException) { + // Download interrupted + try { + // still try to close output stream + out.close(); + } catch (IOException e1) { + // NOP + } } fireUploadInterrupted(filename, type, totalBytes, e); endUpload(); interrupted = false; - // throw cause ahead - throw new IllegalStateException("Uploading failed", e); + if (!(e instanceof UploadInterruptedException)) { + // throw exception for terminal to be handled + throw new UploadException(e); + } } } } @@ -296,6 +301,19 @@ public class Upload extends AbstractComponent implements Component.Focusable { } } + private class UploadInterruptedException extends Exception { + public UploadInterruptedException() { + super("Upload interrupted by other thread"); + } + + } + + public class UploadException extends Exception { + public UploadException(Exception e) { + super("Upload failed", e); + } + } + /** * Upload.Received event is sent when the upload receives a file, regardless * of whether the reception was successful or failed. If you wish to diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 828f98fc33..dc1bf7e18f 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -601,6 +601,14 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * null window name results the resource to be opened in this * window. * + *

+ * Note! When opening browser window with name "_self", client will skip + * rendering rest of the changes as it considers them irrelevant. This may + * speed up opening resource, but it may also put client side into an + * inconsistent state with server in case nothing is actually opened to + * window (like if browser decided to download the resource instead of + * displaying it). + * * @param resource * the resource. * @param windowName