diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-29 13:39:51 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-29 13:39:51 +0200 |
commit | 181b598714e979ad26236a3677f9e825f74ca282 (patch) | |
tree | cc178f0c3e5e971f2d7e071ea46f88d6aea0cdbe /server/src/com/vaadin | |
parent | 0d93598759d2a1a95a25cc84e75cfa03f154590e (diff) | |
parent | b89213ee880dd1197bc7696f6f5a1919c0ff02c1 (diff) | |
download | vaadin-framework-181b598714e979ad26236a3677f9e825f74ca282.tar.gz vaadin-framework-181b598714e979ad26236a3677f9e825f74ca282.zip |
Merge remote-tracking branch 'origin/master' into grid
Change-Id: Id00b3893951bc669fcc8e234f09909d480e249ab
Diffstat (limited to 'server/src/com/vaadin')
13 files changed, 117 insertions, 65 deletions
diff --git a/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java b/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java index 23a72ee1e5..0a92c00cad 100644 --- a/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/BeanFieldGroup.java @@ -155,10 +155,10 @@ public class BeanFieldGroup<T> extends FieldGroup { } @Override - public Field<?> buildAndBind(String caption, Object propertyId) - throws BindException { + public <T extends Field> T buildAndBind(String caption, Object propertyId, + Class<T> fieldType) throws BindException { ensureNestedPropertyAdded(propertyId); - return super.buildAndBind(caption, propertyId); + return super.buildAndBind(caption, propertyId, fieldType); } @Override diff --git a/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java b/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java index 98fed3ad01..8e32585a47 100644 --- a/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java +++ b/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java @@ -91,10 +91,20 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { private <T extends Field> T createEnumField(Class<?> type, Class<T> fieldType) { + // Determine first if we should (or can) create a select for the enum + Class<AbstractSelect> selectClass = null; if (AbstractSelect.class.isAssignableFrom(fieldType)) { - AbstractSelect s = createCompatibleSelect((Class<? extends AbstractSelect>) fieldType); + selectClass = (Class<AbstractSelect>) fieldType; + } else if (anySelect(fieldType)) { + selectClass = AbstractSelect.class; + } + + if (selectClass != null) { + AbstractSelect s = createCompatibleSelect(selectClass); populateWithEnumData(s, (Class<? extends Enum>) type); return (T) s; + } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { + return (T) createAbstractTextField((Class<? extends AbstractTextField>) fieldType); } return null; @@ -106,8 +116,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { if (InlineDateField.class.isAssignableFrom(fieldType)) { field = new InlineDateField(); - } else if (DateField.class.isAssignableFrom(fieldType) - || fieldType == Field.class) { + } else if (anyField(fieldType) + || DateField.class.isAssignableFrom(fieldType)) { field = new PopupDateField(); } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { field = createAbstractTextField((Class<? extends AbstractTextField>) fieldType); @@ -119,6 +129,10 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { return (T) field; } + private boolean anyField(Class<?> fieldType) { + return fieldType == Field.class || fieldType == AbstractField.class; + } + protected AbstractSelect createCompatibleSelect( Class<? extends AbstractSelect> fieldType) { AbstractSelect select; @@ -143,6 +157,10 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { return select; } + private boolean anySelect(Class<? extends Field> fieldType) { + return anyField(fieldType) || fieldType == AbstractSelect.class; + } + protected <T extends Field> T createBooleanField(Class<T> fieldType) { if (fieldType.isAssignableFrom(CheckBox.class)) { CheckBox cb = new CheckBox(null); diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index 591f73dc75..ef5c61a294 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -58,9 +58,8 @@ import com.vaadin.ui.UI; * Views can be explicitly registered or dynamically generated and listening to * view changes is possible. * <p> - * Note that {@link Navigator} is not a component itself but comes with - * {@link SimpleViewDisplay} which is a component that displays the selected - * view as its contents. + * Note that {@link Navigator} is not a component itself but uses a + * {@link ViewDisplay} to update contents based on the state. * * @author Vaadin Ltd * @since 7.0 @@ -627,11 +626,9 @@ public class Navigator implements Serializable { } /** - * Return the ViewDisplay used by the navigator. Unless another display is - * specified, a {@link SimpleViewDisplay} (which is a {@link Component}) is - * used by default. + * Return the {@link ViewDisplay} used by the navigator. * - * @return current ViewDisplay + * @return the ViewDisplay used for displaying views */ public ViewDisplay getDisplay() { return display; diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 985d7ef765..bfe195ccf9 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -39,6 +39,7 @@ import org.jsoup.parser.Tag; import com.vaadin.annotations.Viewport; import com.vaadin.annotations.ViewportGeneratorClass; +import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; import com.vaadin.shared.communication.PushMode; @@ -505,8 +506,12 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { JsonObject versionInfo = Json.createObject(); versionInfo.put("vaadinVersion", Version.getFullVersion()); - versionInfo.put("atmosphereVersion", - org.atmosphere.util.Version.getRawVersion()); + String atmosphereVersion = AtmospherePushConnection + .getAtmosphereVersion(); + if (atmosphereVersion != null) { + versionInfo.put("atmosphereVersion", atmosphereVersion); + } + appConfig.put("versionInfo", versionInfo); appConfig.put("widgetset", context.getWidgetsetName()); diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 6832da236a..22848c023c 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -27,8 +27,7 @@ import java.util.logging.Logger; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import org.atmosphere.util.Version; - +import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.server.communication.PushRequestHandler; import com.vaadin.server.communication.ServletBootstrapHandler; import com.vaadin.server.communication.ServletUIInitHandler; @@ -54,21 +53,20 @@ public class VaadinServletService extends VaadinService { } private static boolean checkAtmosphereSupport() { - try { - String rawVersion = Version.getRawVersion(); - if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION - .equals(rawVersion)) { - getLogger().log( - Level.WARNING, - Constants.INVALID_ATMOSPHERE_VERSION_WARNING, - new Object[] { - Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION, - rawVersion }); - } - return true; - } catch (NoClassDefFoundError e) { + String rawVersion = AtmospherePushConnection.getAtmosphereVersion(); + if (rawVersion == null) { return false; } + + if (!Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION.equals(rawVersion)) { + getLogger().log( + Level.WARNING, + Constants.INVALID_ATMOSPHERE_VERSION_WARNING, + new Object[] { + Constants.REQUIRED_ATMOSPHERE_RUNTIME_VERSION, + rawVersion }); + } + return true; } @Override diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index a274fbbb9b..0819a24ee9 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -31,6 +31,7 @@ import java.util.logging.Logger; import org.atmosphere.cpr.AtmosphereResource; import org.atmosphere.cpr.AtmosphereResource.TRANSPORT; +import org.atmosphere.util.Version; import com.vaadin.shared.communication.PushConstants; import com.vaadin.ui.UI; @@ -44,6 +45,16 @@ import com.vaadin.ui.UI; */ public class AtmospherePushConnection implements PushConnection { + public static String getAtmosphereVersion() { + try { + String v = Version.getRawVersion(); + assert v != null; + return v; + } catch (NoClassDefFoundError e) { + return null; + } + } + /** * Represents a message that can arrive as multiple fragments. */ diff --git a/server/src/com/vaadin/server/communication/PushRequestHandler.java b/server/src/com/vaadin/server/communication/PushRequestHandler.java index 40eb1b688e..d0367d0bed 100644 --- a/server/src/com/vaadin/server/communication/PushRequestHandler.java +++ b/server/src/com/vaadin/server/communication/PushRequestHandler.java @@ -29,6 +29,7 @@ import org.atmosphere.cpr.AtmosphereInterceptor; import org.atmosphere.cpr.AtmosphereRequest; import org.atmosphere.cpr.AtmosphereResponse; import org.atmosphere.interceptor.HeartbeatInterceptor; +import org.atmosphere.util.VoidAnnotationProcessor; import com.vaadin.server.RequestHandler; import com.vaadin.server.ServiceDestroyEvent; @@ -91,6 +92,8 @@ public class PushRequestHandler implements RequestHandler, atmosphere.addAtmosphereHandler("/*", pushHandler.handler); atmosphere.addInitParameter(ApplicationConfig.BROADCASTER_CACHE, UUIDBroadcasterCache.class.getName()); + atmosphere.addInitParameter(ApplicationConfig.ANNOTATION_PROCESSOR, + VoidAnnotationProcessor.class.getName()); atmosphere.addInitParameter(ApplicationConfig.PROPERTY_SESSION_SUPPORT, "true"); atmosphere.addInitParameter(ApplicationConfig.MESSAGE_DELIMITER, diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index d5e47b2286..423ebcb46a 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -1688,8 +1688,6 @@ public abstract class AbstractSelect extends AbstractField<Object> implements // Clears the item id mapping table itemIdMapper.removeAll(); - adjustSelection(); - // Notify all listeners fireItemSetChange(); } @@ -1728,25 +1726,6 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } /** - * Removes orphaned ids from selection. - * - * @since 7.4 - */ - protected void adjustSelection() { - Object value = getValue(); - if (isMultiSelect() && (value instanceof Collection)) { - Collection<?> collection = (Collection<?>) value; - for (Object id : collection) { - if (!containsId(id)) { - unselect(id); - } - } - } else if (!containsId(value)) { - unselect(value); - } - } - - /** * Implementation of item set change event. */ private static class ItemSetChangeEvent extends EventObject implements diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 414681f5dd..af73fca6a8 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -358,7 +358,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * by the first region, but if split position is reversed the measuring is * done by the second region instead. * - * @since 7.4 + * @since 7.3.6 * @return {@code true} if reversed, {@code false} otherwise. * @see #setSplitPosition(float, boolean) */ diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index 677f29ba13..6beb6ed686 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -365,7 +365,7 @@ public class Button extends AbstractComponent implements * No action is taken is the button is disabled. */ public void click() { - if (isConnectorEnabled() && !isReadOnly()) { + if (isEnabled() && !isReadOnly()) { fireClick(); } } diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index 266c93e81f..67dfdd4258 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -1621,4 +1621,34 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, } } + /** + * Sets whether HTML is allowed in the tab captions. + * <p> + * If set to true, the captions are rendered in the browser as HTML and the + * developer is responsible for ensuring no harmful HTML is used. If set to + * false, the content is rendered in the browser as plain text. + * <p> + * The default is false, i.e. render tab captions as plain text + * + * @param tabCaptionsAsHtml + * true if the tab captions are rendered as HTML, false if + * rendered as plain text + * @since 7.4 + */ + public void setTabCaptionsAsHtml(boolean tabCaptionsAsHtml) { + getState().tabCaptionsAsHtml = tabCaptionsAsHtml; + } + + /** + * Checks whether HTML is allowed in the tab captions. + * <p> + * The default is false, i.e. render tab captions as plain text + * + * @return true if the tab captions are rendered as HTML, false if rendered + * as plain text + * @since 7.4 + */ + public boolean isTabCaptionsAsHtml() { + return getState(false).tabCaptionsAsHtml; + } } diff --git a/server/src/com/vaadin/ui/declarative/Design.java b/server/src/com/vaadin/ui/declarative/Design.java index 59393a7815..dc96e789bf 100644 --- a/server/src/com/vaadin/ui/declarative/Design.java +++ b/server/src/com/vaadin/ui/declarative/Design.java @@ -184,13 +184,18 @@ public class Design implements Serializable { // taken care of by jsoup. Element root = doc.body(); Elements children = root.children(); - if (children.size() != 1) { + if (children.size() > 1) { throw new DesignException( - "The first level of a component hierarchy should contain exactly one root component, but found " - + children.size()); + "The first level of a component hierarchy should contain at most one root component, but found " + + children.size() + "."); } - Element element = children.first(); + Element element = children.size() == 0 ? null : children.first(); if (componentRoot != null) { + if (element == null) { + throw new DesignException( + "The root element cannot be null when the specified root Component is" + + " not null."); + } // user has specified root instance that may have member fields that // should be bound final FieldBinder binder; @@ -222,7 +227,8 @@ public class Design implements Serializable { designContext.removeComponentCreationListener(creationListener); } else { // createChild creates the entire component hierarchy - componentRoot = designContext.readDesign(element); + componentRoot = element == null ? null : designContext + .readDesign(element); } designContext.setRootComponent(componentRoot); return designContext; @@ -255,8 +261,10 @@ public class Design implements Serializable { // creates the entire component hierarchy rooted at the // given root node. Component root = designContext.getRootComponent(); - Node rootNode = designContext.createElement(root); - body.appendChild(rootNode); + if (root != null) { + Node rootNode = designContext.createElement(root); + body.appendChild(rootNode); + } designContext.writePackageMappings(doc); return doc; } @@ -424,10 +432,11 @@ public class Design implements Serializable { /** * Writes the given component tree in design format to the given output - * stream + * stream. * * @param component - * the root component of the component tree + * the root component of the component tree, null can be used for + * generating an empty design * @param outputStream * the output stream to write the design to. The design is always * written as UTF-8 @@ -446,8 +455,10 @@ public class Design implements Serializable { * and other information not available in the component tree. * * @param designContext - * the DesignContext object specifying the component hierarchy - * and the local id values of the objects + * The DesignContext object specifying the component hierarchy + * and the local id values of the objects. If + * designContext.getRootComponent() is null, an empty design will + * be generated. * @param outputStream * the output stream to write the design to. The design is always * written as UTF-8 diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java index ade2494638..fd83339b76 100644 --- a/server/src/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/com/vaadin/ui/declarative/DesignContext.java @@ -415,7 +415,7 @@ public class DesignContext implements Serializable { * * @param componentDesign * The design element containing the description of the component - * to be created + * to be created. * @return the root component of component tree */ public Component readDesign(Element componentDesign) { |