diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2016-10-07 16:06:01 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-10-13 06:41:15 +0000 |
commit | fb4248119d77a6865a42ffdf0d80f10d683769a5 (patch) | |
tree | 60692a31b04a85958fefb6959e06e7039a3ea879 /server | |
parent | b66631c3dc5d79caa6a78274d2ea4107ccae7973 (diff) | |
download | vaadin-framework-fb4248119d77a6865a42ffdf0d80f10d683769a5.tar.gz vaadin-framework-fb4248119d77a6865a42ffdf0d80f10d683769a5.zip |
Remove AbstractComponent.immediate
All components are now in immediate mode by default.
V7 compatibility components will use AbstractLegacyComponent that has immediate.
V7 ColorPickerPopup will not have setImmediate, since it extends V8 Window,
which is not in V7 compatibility packages.
Removed OutOfSync and ResynchronizeAfterAsyncRemoval Tests,
since those tested UI in not immediate mode, which is invalid now.
Removed WindowResizeListener, LazyWindowResize, test UIs,
since both used immediate and there were no test run for either.
Change-Id: Ie1c8cfa4c48461db944ff9b13efe8473c5a3298f
Diffstat (limited to 'server')
10 files changed, 37 insertions, 154 deletions
diff --git a/server/src/main/java/com/vaadin/server/DragAndDropService.java b/server/src/main/java/com/vaadin/server/DragAndDropService.java index d23c87e468..f43c68fd6f 100644 --- a/server/src/main/java/com/vaadin/server/DragAndDropService.java +++ b/server/src/main/java/com/vaadin/server/DragAndDropService.java @@ -110,7 +110,7 @@ public class DragAndDropService implements VariableOwner, ClientConnector { */ private void handleDropRequest(DropTarget dropTarget, Map<String, Object> variables) { - DropHandler dropHandler = (dropTarget).getDropHandler(); + DropHandler dropHandler = dropTarget.getDropHandler(); if (dropHandler == null) { // No dropHandler returned so no drop can be performed. getLogger().log(Level.FINE, @@ -217,16 +217,22 @@ public class DragAndDropService implements VariableOwner, ClientConnector { return transferable; } + /** + * <p> + * Tests if the variable owner is enabled or not. The terminal should not + * send any variable changes to disabled variable owners. + * </p> + * Implementation detail: this method is originally from the VariableOwner + * class, which has been removed in Vaadin 8. + * + * @return <code>true</code> if the variable owner is enabled, + * <code>false</code> if not + */ @Override public boolean isEnabled() { return isConnectorEnabled(); } - @Override - public boolean isImmediate() { - return true; - } - public void printJSONResponse(Writer outWriter) throws IOException { if (isDirty()) { diff --git a/server/src/main/java/com/vaadin/server/VariableOwner.java b/server/src/main/java/com/vaadin/server/VariableOwner.java index c431d37b96..d92b353cd4 100644 --- a/server/src/main/java/com/vaadin/server/VariableOwner.java +++ b/server/src/main/java/com/vaadin/server/VariableOwner.java @@ -62,24 +62,4 @@ public interface VariableOwner extends Serializable { */ public boolean isEnabled(); - /** - * <p> - * Tests if the variable owner is in immediate mode or not. Being in - * immediate mode means that all variable changes are required to be sent - * back from the terminal immediately when they occur. - * </p> - * - * <p> - * <strong>Note:</strong> <code>VariableOwner</code> does not include a set- - * method for the immediateness property. This is because not all - * VariableOwners wish to offer the functionality. Such VariableOwners are - * never in the immediate mode, thus they always return <code>false</code> - * in {@link #isImmediate()}. - * </p> - * - * @return <code>true</code> if the component is in immediate mode, - * <code>false</code> if not. - */ - public boolean isImmediate(); - } diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java index 6814a96796..dd482a5bd0 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java +++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java @@ -154,7 +154,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> { /** * Returns the current selected color of this color picker. - * + * * @return the selected color, not null */ @Override @@ -165,7 +165,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> { /** * Sets the selected color of this color picker. If the new color is not * equal to getValue(), fires a value change event. - * + * * @param color * the new selected color, not null */ @@ -191,7 +191,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> { /** * Returns true if the component shows the default caption (css-code for the * currently selected color, e.g. #ffffff) if no other caption is available. - * + * * @return {@code true} if the default caption is enabled, {@code false} * otherwise */ @@ -447,7 +447,6 @@ public abstract class AbstractColorPicker extends AbstractField<Color> { window.setHistoryVisible(historyVisible); window.setPreviewVisible(textfieldVisible); - window.setImmediate(true); window.addCloseListener( event -> getState().popupVisible = false); window.addValueChangeListener( @@ -515,7 +514,7 @@ public abstract class AbstractColorPicker extends AbstractField<Color> { DesignAttributeHandler.writeAttribute("color", attribute, getValue().getCSS(), Color.WHITE.getCSS(), String.class); DesignAttributeHandler.writeAttribute("popup-style", attribute, - (popupStyle == PopupStyle.POPUP_NORMAL ? "normal" : "simple"), + popupStyle == PopupStyle.POPUP_NORMAL ? "normal" : "simple", "normal", String.class); DesignAttributeHandler.writeAttribute("position", attribute, positionX + "," + positionY, "0,0", String.class); diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index f794cab51b..0681612996 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -118,8 +118,6 @@ public abstract class AbstractComponent extends AbstractClientConnector private HasComponents parent; - private Boolean explicitImmediateValue; - protected static final String DESIGN_ATTR_PLAIN_TEXT = "plain-text"; /* Constructor */ @@ -434,7 +432,7 @@ public abstract class AbstractComponent extends AbstractClientConnector return false; } else if (!super.isConnectorEnabled()) { return false; - } else if ((getParent() instanceof SelectiveRenderer) + } else if (getParent() instanceof SelectiveRenderer && !((SelectiveRenderer) getParent()).isRendered(this)) { return false; } else { @@ -442,44 +440,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - /** - * Returns the explicitly set immediate value. - * - * @return the explicitly set immediate value or null if - * {@link #setImmediate(boolean)} has not been explicitly invoked - */ - protected Boolean getExplicitImmediateValue() { - return explicitImmediateValue; - } - - /** - * Returns the immediate mode of the component. - * <p> - * Since Vaadin 8, the default mode is immediate. - * - * @return true if the component is in immediate mode (explicitly or - * implicitly set), false if the component if not in immediate mode - */ - public boolean isImmediate() { - if (explicitImmediateValue != null) { - return explicitImmediateValue; - } else { - return true; - } - } - - /** - * Sets the component's immediate mode to the specified status. - * - * @param immediate - * the boolean value specifying if the component should be in the - * immediate mode after the call. - */ - public void setImmediate(boolean immediate) { - explicitImmediateValue = immediate; - getState().immediate = immediate; - } - /* * (non-Javadoc) * @@ -771,8 +731,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } else { getState().errorMessage = null; } - - getState().immediate = isImmediate(); } /* General event framework */ @@ -1002,11 +960,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - // handle immediate - if (attr.hasKey("immediate")) { - setImmediate(DesignAttributeHandler.getFormatter() - .parse(attr.get("immediate"), Boolean.class)); - } // handle locale if (attr.hasKey("locale")) { @@ -1289,11 +1242,6 @@ public abstract class AbstractComponent extends AbstractClientConnector for (String attribute : getDefaultAttributes()) { DesignAttributeHandler.writeAttribute(this, attribute, attr, def); } - // handle immediate - if (explicitImmediateValue != null) { - DesignAttributeHandler.writeAttribute("immediate", attr, - explicitImmediateValue, def.isImmediate(), Boolean.class); - } // handle locale if (getLocale() != null && (getParent() == null || !getLocale().equals(getParent().getLocale()))) { diff --git a/server/src/main/java/com/vaadin/ui/Component.java b/server/src/main/java/com/vaadin/ui/Component.java index ffca8b808c..5822a7b078 100644 --- a/server/src/main/java/com/vaadin/ui/Component.java +++ b/server/src/main/java/com/vaadin/ui/Component.java @@ -858,7 +858,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * // Some miscellaneous component * TextField name = new TextField("Say it all here"); * name.addListener(this); - * name.setImmediate(true); * layout.addComponent(name); * * // Handle button clicks as generic events instead @@ -940,7 +939,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * // Some miscellaneous component * TextField name = new TextField("Say it all here"); * name.addListener(this); - * name.setImmediate(true); * layout.addComponent(name); * * // Handle button clicks as generic events instead diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java index 79fe6227a1..747f294666 100644 --- a/server/src/main/java/com/vaadin/ui/TabSheet.java +++ b/server/src/main/java/com/vaadin/ui/TabSheet.java @@ -142,7 +142,6 @@ public class TabSheet extends AbstractComponentContainer // expand horizontally by default setWidth(100, UNITS_PERCENTAGE); - setImmediate(true); setCloseHandler(new CloseHandler() { @Override diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java index 4460b21d33..4cb79b9249 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java @@ -139,7 +139,6 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { setContent(layout); setStyleName(STYLENAME); setResizable(false); - setImmediate(true); // Create the history history = new ColorPickerHistory(); history.addValueChangeListener(this::colorChanged); @@ -147,7 +146,7 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { /** * Instantiates a new color picker popup. - * + * * @param initialColor * the initially selected color */ @@ -307,7 +306,6 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { private Slider createRGBSlider(String caption, String styleName) { Slider redSlider = new Slider(caption, 0, 255); - redSlider.setImmediate(true); redSlider.setStyleName("rgb-slider"); redSlider.setWidth("220px"); redSlider.addStyleName(styleName); @@ -345,16 +343,14 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { hueSlider.setStyleName("hsv-slider"); hueSlider.addStyleName("hue-slider"); hueSlider.setWidth("220px"); - hueSlider.setImmediate(true); hueSlider.addValueChangeListener(event -> { if (!updatingColors) { - float hue = (Float.parseFloat(event.getValue().toString())) + float hue = Float.parseFloat(event.getValue().toString()) / 360f; - float saturation = (Float - .parseFloat(saturationSlider.getValue().toString())) - / 100f; - float value = (Float - .parseFloat(valueSlider.getValue().toString())) / 100f; + float saturation = Float.parseFloat( + saturationSlider.getValue().toString()) / 100f; + float value = Float + .parseFloat(valueSlider.getValue().toString()) / 100f; // Set the color Color newColor = new Color( @@ -374,15 +370,14 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { saturationSlider.setStyleName("hsv-slider"); saturationSlider.setWidth("220px"); - saturationSlider.setImmediate(true); saturationSlider.addValueChangeListener(event -> { if (!updatingColors) { - float hue = (Float.parseFloat(hueSlider.getValue().toString())) + float hue = Float.parseFloat(hueSlider.getValue().toString()) / 360f; - float saturation = (Float - .parseFloat(event.getValue().toString())) / 100f; - float value = (Float - .parseFloat(valueSlider.getValue().toString())) / 100f; + float saturation = Float.parseFloat(event.getValue().toString()) + / 100f; + float value = Float + .parseFloat(valueSlider.getValue().toString()) / 100f; Color newColor = new Color( Color.HSVtoRGB(hue, saturation, value)); setValue(newColor); @@ -392,15 +387,13 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { valueSlider.setStyleName("hsv-slider"); valueSlider.setWidth("220px"); - valueSlider.setImmediate(true); valueSlider.addValueChangeListener(event -> { if (!updatingColors) { - float hue = (Float.parseFloat(hueSlider.getValue().toString())) + float hue = Float.parseFloat(hueSlider.getValue().toString()) / 360f; - float saturation = (Float - .parseFloat(saturationSlider.getValue().toString())) - / 100f; - float value = (Float.parseFloat(event.getValue().toString())) + float saturation = Float.parseFloat( + saturationSlider.getValue().toString()) / 100f; + float value = Float.parseFloat(event.getValue().toString()) / 100f; Color newColor = new Color( @@ -647,7 +640,7 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { @Override public Color calculate(int x, int y) { - float h = (x / 220f); + float h = x / 220f; float s = 1f; float v = 1f; @@ -699,8 +692,8 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { @Override public Color calculate(int x, int y) { - float saturation = 1f - (y / 220.0f); - float value = (x / 220.0f); + float saturation = 1f - y / 220.0f; + float value = x / 220.0f; float hue = Float.parseFloat(hueSlider.getValue().toString()) / 360f; diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java index 3d743f7365..a76f19e0e2 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java @@ -46,9 +46,7 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> { private ColorPickerPreview() { setStyleName("v-colorpicker-preview"); - setImmediate(true); field = new TextField(); - field.setImmediate(true); field.setSizeFull(); field.setStyleName("v-colorpicker-preview-textfield"); field.setData(this); @@ -162,8 +160,8 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> { } oldValue = value; - fireEvent(new ValueChange<>((Component) field.getData(), - color, event.isUserOriginated())); + fireEvent(new ValueChange<>((Component) field.getData(), color, + event.isUserOriginated())); } } catch (NumberFormatException nfe) { diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java index 3822251de3..b13499983e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java @@ -19,7 +19,6 @@ import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.File; -import java.lang.reflect.Field; import java.nio.charset.Charset; import java.util.Locale; @@ -83,7 +82,6 @@ public class AbstractComponentDeclarativeTest component.setComponentError(new UserError("<div>test-error</div>", com.vaadin.server.AbstractErrorMessage.ContentMode.HTML, ErrorLevel.ERROR)); - component.setImmediate(true); testRead(design, component); testWrite(design, component); } @@ -103,8 +101,6 @@ public class AbstractComponentDeclarativeTest component = (AbstractComponent) Design .read(new ByteArrayInputStream( design[i].getBytes(Charset.forName("UTF-8")))); - assertEquals(immediate[i], component.isImmediate()); - assertEquals(explicitImmediate[i], getExplicitImmediate(component)); } } @@ -246,15 +242,4 @@ public class AbstractComponentDeclarativeTest return node; } - private Boolean getExplicitImmediate(AbstractComponent component) { - try { - Field immediate = AbstractComponent.class - .getDeclaredField("explicitImmediateValue"); - immediate.setAccessible(true); - return (Boolean) immediate.get(component); - } catch (Exception e) { - throw new RuntimeException( - "Getting the field explicitImmediateValue failed."); - } - } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java deleted file mode 100644 index 1cc48ee3e2..0000000000 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.vaadin.tests.server.component.abstractcomponent; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.vaadin.ui.AbstractComponent; - -public class AbstractComponentTest { - AbstractComponent component = new AbstractComponent() { - }; - - @Test - public void testImmediate() { - assertTrue("Component should be immediate by default", - component.isImmediate()); - component.setImmediate(false); - assertFalse( - "Explicitly non-immediate component should not be immediate", - component.isImmediate()); - } -} |