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
*
* @param invocation
* RPC method invocation
- * @param delayed
- * <code>false</code> to trigger sending within a short time
- * window (possibly combining subsequent calls to a single
- * request), <code>true</code> to let the framework delay sending
- * of RPC calls and variable changes until the next non-delayed
- * change
* @param lastOnly
* <code>true</code> to remove all previously delayed invocations
* of the same method that were also enqueued with lastonly set
/** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client;
- /** For internal use only. May be removed or replaced in the future. */
- public boolean immediate;
-
/**
* The current position of the split handle in either percentages or pixels
* <p>
int pixelPosition = DOM.getElementPropertyInt(splitter, "offsetTop");
// reposition splitter in case it is out of box
- if ((pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize)
- || (positionReversed && pixelPosition < 0)) {
+ if (pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize
+ || positionReversed && pixelPosition < 0) {
pixelPosition = wholeSize - getSplitterSize();
if (pixelPosition < 0) {
pixelPosition = 0;
}
firstContainer.getStyle().setHeight(pixelPosition, Unit.PX);
- int secondContainerHeight = (wholeSize - pixelPosition
- - getSplitterSize());
+ int secondContainerHeight = wholeSize - pixelPosition
+ - getSplitterSize();
if (secondContainerHeight < 0) {
secondContainerHeight = 0;
}
int pixelPosition = DOM.getElementPropertyInt(splitter, "offsetLeft");
// reposition splitter in case it is out of box
- if ((pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize)
- || (positionReversed && pixelPosition < 0)) {
+ if (pixelPosition > 0 && pixelPosition + getSplitterSize() > wholeSize
+ || positionReversed && pixelPosition < 0) {
pixelPosition = wholeSize - getSplitterSize();
if (pixelPosition < 0) {
pixelPosition = 0;
}
firstContainer.getStyle().setWidth(pixelPosition, Unit.PX);
- int secondContainerWidth = (wholeSize - pixelPosition
- - getSplitterSize());
+ int secondContainerWidth = wholeSize - pixelPosition
+ - getSplitterSize();
if (secondContainerWidth < 0) {
secondContainerWidth = 0;
}
} else {
// Reversed position
if (positionReversed) {
- position = (getOffsetWidth() - newX - getSplitterSize()) + "px";
+ position = getOffsetWidth() - newX - getSplitterSize() + "px";
} else {
position = newX + "px";
}
} else {
// Reversed position
if (positionReversed) {
- position = (getOffsetHeight() - newY - getSplitterSize())
- + "px";
+ position = getOffsetHeight() - newY - getSplitterSize() + "px";
} else {
position = newY + "px";
}
* @return true if the browser requires a dragging curtain
*/
private boolean isDraggingCurtainRequired() {
- return (BrowserInfo.get().isGecko() || BrowserInfo.get().isWebkit());
+ return BrowserInfo.get().isGecko() || BrowserInfo.get().isWebkit();
}
/**
/** For internal use only. May be removed or replaced in the future. */
public String id;
- /** For internal use only. May be removed or replaced in the future. */
- public boolean immediate;
-
/** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client;
Element el = DOM.getFirstChild(getElement());
while (el != null) {
- DOM.sinkEvents(el,
- (DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS));
+ DOM.sinkEvents(el, DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS);
el = DOM.getNextSibling(el);
}
@Override
public void onBrowserEvent(Event event) {
- if (icon != null && (event.getTypeInt() == Event.ONCLICK)
- && (DOM.eventGetTarget(event) == icon.getElement())) {
+ if (icon != null && event.getTypeInt() == Event.ONCLICK
+ && DOM.eventGetTarget(event) == icon.getElement()) {
// Click on icon should do nothing if widget is disabled
if (isEnabled()) {
setValue(!getValue());
/** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client;
- /** For internal use only. May be removed or replaced in the future. */
- public boolean immediate;
-
/** For internal use only. May be removed or replaced in the future. */
public static String resolutionToString(Resolution res) {
if (res == Resolution.DAY) {
this.date = date;
}
- public boolean isImmediate() {
- return immediate;
- }
-
- public void setImmediate(boolean immediate) {
- this.immediate = immediate;
- }
-
public boolean isReadonly() {
return readonly;
}
false);
}
}
- if (isImmediate()) {
- getClient().sendPendingVariableChanges();
- }
+ getClient().sendPendingVariableChanges();
}
}
protected String id;
- protected boolean immediate;
protected boolean disabled;
protected boolean readonly;
@Override
public void execute() {
final Element p = getElement();
- if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)
+ if (p.getPropertyInt(domProperty) > MIN_SIZE + 5
|| propertyNotNullOrEmpty(styleAttribute, p)) {
if (isVertical()) {
setHeight();
increaseValue(true);
} else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
processBaseEvent(event);
- } else if ((BrowserInfo.get().isGecko()
- && DOM.eventGetType(event) == Event.ONKEYPRESS)
- || (!BrowserInfo.get().isGecko()
- && DOM.eventGetType(event) == Event.ONKEYDOWN)) {
+ } else if (BrowserInfo.get().isGecko()
+ && DOM.eventGetType(event) == Event.ONKEYPRESS
+ || !BrowserInfo.get().isGecko()
+ && DOM.eventGetType(event) == Event.ONKEYDOWN) {
if (handleNavigation(event.getKeyCode(), event.getCtrlKey(),
event.getShiftKey())) {
}
if (isVertical()) {
- v = ((baseSize - (coord - baseOffset))
- / (double) (baseSize - handleSize)) * (max - min) + min;
+ v = (baseSize - (coord - baseOffset))
+ / (double) (baseSize - handleSize) * (max - min) + min;
} else {
- v = ((coord - baseOffset) / (double) (baseSize - handleSize))
+ v = (coord - baseOffset) / (double) (baseSize - handleSize)
* (max - min) + min;
}
return false;
}
- if ((keycode == getNavigationUpKey() && isVertical())
- || (keycode == getNavigationRightKey() && !isVertical())) {
+ if (keycode == getNavigationUpKey() && isVertical()
+ || keycode == getNavigationRightKey() && !isVertical()) {
if (shift) {
for (int a = 0; a < acceleration; a++) {
increaseValue(false);
}
return true;
} else if (keycode == getNavigationDownKey() && isVertical()
- || (keycode == getNavigationLeftKey() && !isVertical())) {
+ || keycode == getNavigationLeftKey() && !isVertical()) {
if (shift) {
for (int a = 0; a < acceleration; a++) {
decreaseValue(false);
this.id = id;
}
- public void setImmediate(boolean immediate) {
- this.immediate = immediate;
- }
-
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
: "offsetWidth";
final int handleSize = handle.getPropertyInt(domProperty);
final int baseSize = base.getPropertyInt(domProperty)
- - (2 * BASE_BORDER_WIDTH);
+ - 2 * BASE_BORDER_WIDTH;
final int range = baseSize - handleSize;
double v = value.doubleValue();
Date currentDate = getDate();
getClient().updateVariable(getId(), "year",
currentDate != null ? currentDate.getYear() + 1900 : -1,
- currentResolution == Resolution.YEAR && immediate);
+ currentResolution == Resolution.YEAR);
if (currentResolution.compareTo(Resolution.MONTH) <= 0) {
getClient().updateVariable(getId(), "month",
currentDate != null ? currentDate.getMonth() + 1 : -1,
- currentResolution == Resolution.MONTH && immediate);
+ currentResolution == Resolution.MONTH);
}
if (currentResolution.compareTo(Resolution.DAY) <= 0) {
getClient().updateVariable(getId(), "day",
currentDate != null ? currentDate.getDate() : -1,
- currentResolution == Resolution.DAY && immediate);
+ currentResolution == Resolution.DAY);
}
}
/** stored height of parent for embedded application auto-resize */
private int parentHeight;
- /** For internal use only. May be removed or replaced in the future. */
- public boolean immediate;
-
/** For internal use only. May be removed or replaced in the future. */
public boolean resizeLazy = false;
*/
public boolean centered = false;
- /** For internal use only. May be removed or replaced in the future. */
- public boolean immediate;
-
private Element wrapper;
/** For internal use only. May be removed or replaced in the future. */
private static void focusTopmostModalWindow() {
VWindow topmost = getTopmostWindow();
- if ((topmost != null) && (topmost.vaadinModality)) {
+ if (topmost != null && topmost.vaadinModality) {
topmost.focus();
}
}
if (updateVariables) {
// sending width back always as pixels, no need for unit
client.updateVariable(id, "width", w, false);
- client.updateVariable(id, "height", h, immediate);
+ client.updateVariable(id, "height", h, true);
}
if (updateVariables || !resizeLazy) {
VCaption.setCaptionText(getWidget(), getState());
getWidget().setValue(getState().checked);
- getWidget().immediate = getState().immediate;
}
@Override
getWidget().getElement());
getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked,
details);
- if (getState().immediate) {
- getConnection().sendPendingVariableChanges();
- }
+ getConnection().sendPendingVariableChanges();
}
}
// Save details
getWidget().client = client;
getWidget().paintableId = uidl.getId();
- getWidget().immediate = getState().immediate;
getWidget().setReadonly(isReadOnly());
getWidget().setEnabled(isEnabled());
* a day/enter/clicking outside of popup) then the new value is
* communicated to the server.
*/
- if (getWidget().isImmediate()) {
- getConnection().getServerRpcQueue().flush();
- }
+ getConnection().getServerRpcQueue().flush();
}
});
}
super.onStateChanged(stateChangeEvent);
getWidget().setId(getConnectorId());
- getWidget().setImmediate(getState().immediate);
getWidget().setDisabled(!isEnabled());
getWidget().setReadOnly(isReadOnly());
getWidget().setOrientation(getState().orientation);
public void onStateChanged(StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
- getWidget().immediate = getState().immediate;
-
getWidget().setEnabled(isEnabled());
clickEventHandler.handleEventHandlerRegistration();
getRpcProxy(UIServerRpc.class).resize(event.getHeight(),
event.getWidth(), Window.getClientWidth(),
Window.getClientHeight());
- if (getState().immediate || getPageState().hasResizeListeners) {
- getConnection().getServerRpcQueue().flush();
- }
+ getConnection().getServerRpcQueue().flush();
}
});
getWidget().addScrollHandler(new ScrollHandler() {
boolean firstPaint = getWidget().connection == null;
getWidget().connection = client;
- getWidget().immediate = getState().immediate;
getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY);
// this also implicitly removes old styles
String styles = "";
}
ComponentConnector content = getContent();
- boolean hasContent = (content != null);
+ boolean hasContent = content != null;
Element contentElement = window.contentPanel.getElement();
Style contentStyle = window.contents.getStyle();
clickEventHandler.handleEventHandlerRegistration();
- window.immediate = state.immediate;
-
window.setClosable(!isReadOnly());
// initialize position from state
updateWindowPosition();
*/
package com.vaadin.v7.client.ui;
+import com.google.gwt.user.client.ui.Focusable;
import com.vaadin.client.StyleConstants;
-import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.ui.HasErrorIndicator;
import com.vaadin.client.ui.HasRequiredIndicator;
import com.vaadin.v7.shared.AbstractFieldState;
@Deprecated
-public abstract class AbstractFieldConnector extends AbstractComponentConnector
+public abstract class AbstractFieldConnector
+ extends AbstractLegacyComponentConnector
implements HasRequiredIndicator, HasErrorIndicator {
@Override
getWidget().setStyleName(StyleConstants.REQUIRED,
isRequiredIndicatorVisible());
}
+
+ @OnStateChange("tabIndex")
+ void updateTabIndex() {
+ // AbstractFieldState is not inheriting TabIndexState because of
+ // AbstractLegacyComponentState, thus need to set tab index here
+ // (instead of AbstractComponentConnector)
+ if (getWidget() instanceof Focusable) {
+ ((Focusable) getWidget()).setTabIndex(getState().tabIndex);
+ }
+ }
}
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.AbstractConnector;
import com.vaadin.shared.communication.ServerRpc;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* Legacy connector for Vaadin 7 compatibility connectors. Needed because
*
* @author Vaadin Ltd
* @since 8.0
+ * @deprecated only used for Vaadin 7 compatiblity components
*/
+@Deprecated
public class AbstractLegacyComponentConnector
extends AbstractComponentConnector {
protected <T extends ServerRpc> T getRpcProxy(Class<T> rpcInterface) {
return super.getRpcProxy(rpcInterface);
}
+
+ @Override
+ public AbstractLegacyComponentState getState() {
+ return (AbstractLegacyComponentState) super.getState();
+ }
}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.v7.client.ui;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.vaadin.client.ApplicationConnection;
+import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.Util;
+import com.vaadin.client.VTooltip;
+import com.vaadin.client.ui.Field;
+import com.vaadin.client.ui.Icon;
+import com.vaadin.client.ui.aria.AriaHelper;
+import com.vaadin.client.ui.aria.HandlesAriaInvalid;
+import com.vaadin.client.ui.aria.HandlesAriaRequired;
+
+public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox
+ implements Field, HandlesAriaInvalid, HandlesAriaRequired {
+
+ public static final String CLASSNAME = "v-checkbox";
+
+ /** For internal use only. May be removed or replaced in the future. */
+ public String id;
+
+ /** For internal use only. May be removed or replaced in the future. */
+ public boolean immediate;
+
+ /** For internal use only. May be removed or replaced in the future. */
+ public ApplicationConnection client;
+
+ /** For internal use only. May be removed or replaced in the future. */
+ public Element errorIndicatorElement;
+
+ /** For internal use only. May be removed or replaced in the future. */
+ public Icon icon;
+
+ public VCheckBox() {
+ setStyleName(CLASSNAME);
+
+ Element el = DOM.getFirstChild(getElement());
+ while (el != null) {
+ DOM.sinkEvents(el, DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS);
+ el = DOM.getNextSibling(el);
+ }
+
+ if (BrowserInfo.get().isWebkit()) {
+ // Webkit does not focus non-text input elements on click
+ // (#11854)
+ addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ setFocus(true);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onBrowserEvent(Event event) {
+ if (icon != null && event.getTypeInt() == Event.ONCLICK
+ && DOM.eventGetTarget(event) == icon.getElement()) {
+ // Click on icon should do nothing if widget is disabled
+ if (isEnabled()) {
+ setValue(!getValue());
+ }
+ }
+ super.onBrowserEvent(event);
+ if (event.getTypeInt() == Event.ONLOAD) {
+ Util.notifyParentOfSizeChange(this, true);
+ }
+ }
+
+ /**
+ * Gives access to the input element.
+ *
+ * @return Element of the CheckBox itself
+ */
+ private Element getCheckBoxElement() {
+ // FIXME: Would love to use a better way to access the checkbox element
+ return getElement().getFirstChildElement();
+ }
+
+ @Override
+ public void setAriaRequired(boolean required) {
+ AriaHelper.handleInputRequired(getCheckBoxElement(), required);
+ }
+
+ @Override
+ public void setAriaInvalid(boolean invalid) {
+ AriaHelper.handleInputInvalid(getCheckBoxElement(), invalid);
+ }
+}
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.Action;
import com.vaadin.client.ui.ActionOwner;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.client.ui.VCalendar;
import com.vaadin.v7.client.ui.VCalendar.BackwardListener;
import com.vaadin.v7.client.ui.VCalendar.DateClickListener;
* @author Vaadin Ltd.
*/
@Connect(value = Calendar.class, loadStyle = LoadStyle.LAZY)
-public class CalendarConnector extends AbstractComponentConnector
+public class CalendarConnector extends AbstractLegacyComponentConnector
implements ActionOwner, SimpleManagedLayout, Paintable {
private CalendarServerRpc rpc = RpcProxy.create(CalendarServerRpc.class,
this);
- private final HashMap<String, String> actionMap = new HashMap<String, String>();
- private HashMap<Object, String> tooltips = new HashMap<Object, String>();
+ private final HashMap<String, String> actionMap = new HashMap<>();
+ private HashMap<Object, String> tooltips = new HashMap<>();
private static final String DROPHANDLER_ACCEPT_CRITERIA_PAINT_TAG = "-ac";
}
private Action[] getActionsBetween(Date start, Date end) {
- List<Action> actions = new ArrayList<Action>();
- List<String> ids = new ArrayList<String>();
+ List<Action> actions = new ArrayList<>();
+ List<String> ids = new ArrayList<>();
for (int i = 0; i < actionKeys.size(); i++) {
String actionKey = actionKeys.get(i);
return actions.toArray(new Action[actions.size()]);
}
- private List<String> actionKeys = new ArrayList<String>();
+ private List<String> actionKeys = new ArrayList<>();
private void updateActionMap(List<CalendarState.Action> actions) {
actionMap.clear();
*/
@Override
public Action[] getActions() {
- List<Action> actions = new ArrayList<Action>();
+ List<Action> actions = new ArrayList<>();
for (int i = 0; i < actionKeys.size(); i++) {
final String actionKey = actionKeys.get(i);
final VCalendarAction a = new VCalendarAction(this, rpc, actionKey);
private List<CalendarEvent> calendarEventListOf(
List<CalendarState.Event> events, boolean format24h) {
- List<CalendarEvent> list = new ArrayList<CalendarEvent>(events.size());
+ List<CalendarEvent> list = new ArrayList<>(events.size());
for (CalendarState.Event event : events) {
final String dateFrom = event.dateFrom;
final String dateTo = event.dateTo;
}
private List<CalendarDay> calendarDayListOf(List<CalendarState.Day> days) {
- List<CalendarDay> list = new ArrayList<CalendarDay>(days.size());
+ List<CalendarDay> list = new ArrayList<>(days.size());
for (CalendarState.Day day : days) {
CalendarDay d = new CalendarDay(day.date, day.localizedDateFormat,
day.dayOfWeek, day.week, day.yearOfWeek);
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
import com.vaadin.client.ui.Icon;
-import com.vaadin.client.ui.VCheckBox;
import com.vaadin.shared.EventId;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.Connect;
import com.vaadin.v7.client.ui.AbstractFieldConnector;
+import com.vaadin.v7.client.ui.VCheckBox;
import com.vaadin.v7.shared.ui.checkbox.CheckBoxServerRpc;
import com.vaadin.v7.shared.ui.checkbox.CheckBoxState;
import com.vaadin.v7.ui.CheckBox;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.shared.ui.colorpicker.ColorPickerState;
/**
*/
@Deprecated
public abstract class AbstractColorPickerConnector
- extends AbstractComponentConnector implements ClickHandler {
+ extends AbstractLegacyComponentConnector implements ClickHandler {
private static final String DEFAULT_WIDTH_STYLE = "v-default-caption-width";
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.colorpicker.VColorPickerGradient;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.shared.ui.colorpicker.ColorPickerGradientServerRpc;
import com.vaadin.v7.shared.ui.colorpicker.ColorPickerGradientState;
* @since 7.0.0
*/
@Connect(value = com.vaadin.v7.ui.components.colorpicker.ColorPickerGradient.class, loadStyle = LoadStyle.LAZY)
-public class ColorPickerGradientConnector extends AbstractComponentConnector
- implements MouseUpHandler {
+public class ColorPickerGradientConnector
+ extends AbstractLegacyComponentConnector implements MouseUpHandler {
private ColorPickerGradientServerRpc rpc = RpcProxy
.create(ColorPickerGradientServerRpc.class, this);
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.communication.RpcProxy;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.colorpicker.VColorPickerGrid;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.shared.ui.colorpicker.ColorPickerGridServerRpc;
import com.vaadin.v7.shared.ui.colorpicker.ColorPickerGridState;
* @since 7.0.0
*/
@Connect(value = com.vaadin.v7.ui.components.colorpicker.ColorPickerGrid.class, loadStyle = LoadStyle.LAZY)
-public class ColorPickerGridConnector extends AbstractComponentConnector
+public class ColorPickerGridConnector extends AbstractLegacyComponentConnector
implements ClickHandler {
private ColorPickerGridServerRpc rpc = RpcProxy
import com.vaadin.client.Profiler;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.Connect.LoadStyle;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.client.ui.VLabel;
import com.vaadin.v7.shared.ui.label.LabelState;
import com.vaadin.v7.ui.Label;
@Connect(value = Label.class, loadStyle = LoadStyle.EAGER)
-public class LabelConnector extends AbstractComponentConnector {
+public class LabelConnector extends AbstractLegacyComponentConnector {
@Override
public LabelState getState() {
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window.CloseEvent;
import com.vaadin.ui.Window.CloseListener;
* @since 7.0.0
*/
@Deprecated
-public abstract class AbstractColorPicker extends AbstractComponent
+public abstract class AbstractColorPicker extends AbstractLegacyComponent
implements CloseListener, ColorSelector {
private static final Method COLOR_CHANGE_METHOD;
static {
window.setHistoryVisible(historyVisible);
window.setPreviewVisible(textfieldVisible);
- window.setImmediate(true);
window.addCloseListener(this);
window.addColorChangeListener(new ColorChangeListener() {
@Override
DesignAttributeHandler.writeAttribute("color", attribute,
color.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);
import com.vaadin.server.CompositeErrorMessage;
import com.vaadin.server.ErrorMessage;
import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
*/
@SuppressWarnings("serial")
@Deprecated
-public abstract class AbstractField<T> extends AbstractComponent
+public abstract class AbstractField<T> extends AbstractLegacyComponent
implements Field<T>, Property.ReadOnlyStatusChangeListener,
Property.ReadOnlyStatusChangeNotifier, Action.ShortcutNotifier {
@Override
public boolean isReadOnly() {
return super.isReadOnly()
- || (dataSource != null && dataSource.isReadOnly());
+ || dataSource != null && dataSource.isReadOnly();
}
/**
public void commit()
throws Buffered.SourceException, InvalidValueException {
if (dataSource != null && !dataSource.isReadOnly()) {
- if ((isInvalidCommitted() || isValid())) {
+ if (isInvalidCommitted() || isValid()) {
try {
// Commits the value to datasource.
// Fires value change if the value has changed
T value = getInternalValue();
- if ((value != oldValue) && ((value != null && !value.equals(oldValue))
+ if (value != oldValue && (value != null && !value.equals(oldValue)
|| value == null)) {
fireValueChange(false);
}
@Override
public boolean isEmpty() {
- return (getFieldValue() == null);
+ return getFieldValue() == null;
}
@Override
--- /dev/null
+/*
+ * Copyright 2000-2016 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.v7.ui;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.declarative.DesignAttributeHandler;
+import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
+
+/**
+ * An abstract base class for compatibility components.
+ * <p>
+ * Used since immediate property has been removed in Vaadin 8 from
+ * {@link AbstractComponent}.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ * @deprecated only used for Vaadin 7 compatiblity components
+ */
+@Deprecated
+public class AbstractLegacyComponent extends AbstractComponent {
+
+ private Boolean explicitImmediateValue;
+
+ /**
+ * 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.
+ * <p>
+ * Since Vaadin 8, the default mode is immediate.
+ *
+ * @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;
+ }
+
+ @Override
+ public void readDesign(Element design, DesignContext designContext) {
+ super.readDesign(design, designContext);
+
+ Attributes attr = design.attributes();
+ // handle immediate
+ if (attr.hasKey("immediate")) {
+ setImmediate(DesignAttributeHandler.getFormatter()
+ .parse(attr.get("immediate"), Boolean.class));
+ }
+ }
+
+ @Override
+ public void writeDesign(Element design, DesignContext designContext) {
+ super.writeDesign(design, designContext);
+
+ AbstractLegacyComponent def = designContext.getDefaultInstance(this);
+ Attributes attr = design.attributes();
+ // handle immediate
+ if (explicitImmediateValue != null) {
+ DesignAttributeHandler.writeAttribute("immediate", attr,
+ explicitImmediateValue, def.isImmediate(), Boolean.class);
+ }
+ }
+
+ @Override
+ public void beforeClientResponse(boolean initial) {
+ super.beforeClientResponse(initial);
+ getState().immediate = isImmediate();
+ }
+
+ @Override
+ protected AbstractLegacyComponentState getState() {
+ return (AbstractLegacyComponentState) super.getState();
+ }
+
+ @Override
+ protected AbstractLegacyComponentState getState(boolean markAsDirty) {
+ return (AbstractLegacyComponentState) super.getState(markAsDirty);
+ }
+}
import com.vaadin.server.KeyMapper;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Calendar extends AbstractComponent
+public class Calendar extends AbstractLegacyComponent
implements CalendarComponentEvents.NavigationNotifier,
CalendarComponentEvents.EventMoveNotifier,
CalendarComponentEvents.RangeSelectNotifier,
}
private void setupCalendarEvents() {
- int durationInDays = (int) (((endDate.getTime()) - startDate.getTime())
+ int durationInDays = (int) ((endDate.getTime() - startDate.getTime())
/ DateConstants.DAYINMILLIS);
durationInDays++;
if (durationInDays > 60) {
endDate = getEndDate();
}
- int durationInDays = (int) (((endDate.getTime()) - startDate.getTime())
+ int durationInDays = (int) ((endDate.getTime() - startDate.getTime())
/ DateConstants.DAYINMILLIS);
durationInDays++;
if (durationInDays > 60) {
df_date.setTimeZone(currentCalendar.getTimeZone());
df_time.setTimeZone(currentCalendar.getTimeZone());
- state.now = (df_date.format(now) + " " + df_time.format(now));
+ state.now = df_date.format(now) + " " + df_time.format(now);
Date firstDateToShow = expandStartDate(startDate, durationInDays > 7);
Date lastDateToShow = expandEndDate(endDate, durationInDays > 7);
cal.add(java.util.Calendar.SECOND, -1);
Date end = cal.getTime();
- boolean monthView = (durationInDays > 7);
+ boolean monthView = durationInDays > 7;
/**
* If in day or week view add actions for each half-an-hour.
* The date caption pattern.
*/
public void setWeeklyCaptionFormat(String dateFormatPattern) {
- if ((weeklyCaptionFormat == null && dateFormatPattern != null)
- || (weeklyCaptionFormat != null
- && !weeklyCaptionFormat.equals(dateFormatPattern))) {
+ if (weeklyCaptionFormat == null && dateFormatPattern != null
+ || weeklyCaptionFormat != null
+ && !weeklyCaptionFormat.equals(dateFormatPattern)) {
weeklyCaptionFormat = dateFormatPattern;
markAsDirty();
}
// monday first
if (calendar.getFirstDayOfWeek() == java.util.Calendar.MONDAY) {
- fow = (fow == java.util.Calendar.SUNDAY) ? 7 : fow - 1;
+ fow = fow == java.util.Calendar.SUNDAY ? 7 : fow - 1;
}
return fow;
if (currentTimeFormat != null) {
design.attr("time-format",
- (currentTimeFormat == TimeFormat.Format12H ? "12h"
- : "24h"));
+ currentTimeFormat == TimeFormat.Format12H ? "12h" : "24h");
}
if (startDate != null) {
design.attr("start-date", df_date.format(getStartDate()));
/*
* Copyright 2000-2016 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
/**
* Form component provides easy way of creating and managing sets fields.
- *
+ *
* <p>
* <code>Form</code> is a container for fields implementing {@link Field}
* interface. It provides support for any layouts and provides buffering
* setting immediateness, etc. Also direct mechanism for replacing existing
* fields with selections is given.
* </p>
- *
+ *
* <p>
* <code>Form</code> provides customizable editor for classes implementing
* {@link com.vaadin.data.Item} interface. Also the form itself implements this
* properties of any class following bean pattern, can be accessed trough
* {@link com.vaadin.data.util.BeanItem}.
* </p>
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
* @deprecated As of 7.0, use {@link FieldGroup} instead of {@link Form} for
/**
* Form needs to repaint itself if child fields value changes due possible
* change in form validity.
- *
+ *
* TODO introduce ValidityChangeEvent (#6239) and start using it instead.
* See e.g. DateField#notifyFormOfValidityChange().
*/
/**
* Constructs a new form with default layout.
- *
+ *
* <p>
* By default the form uses {@link FormLayout}.
* </p>
/**
* Constructs a new form with given {@link Layout}.
- *
+ *
* @param formLayout
* the layout of the form.
*/
/**
* Constructs a new form with given {@link Layout} and
* {@link FormFieldFactory}.
- *
+ *
* @param formLayout
* the layout of the form.
* @param fieldFactory
/**
* The error message of a Form is the error of the first field with a
* non-empty error.
- *
+ *
* Empty error messages of the contained fields are skipped, because an
* empty error indicator would be confusing to the user, especially if there
* are errors that have something to display. This is also the reason why
/**
* Controls the making validation visible implicitly on commit.
- *
+ *
* Having commit() call setValidationVisible(true) implicitly is the default
* behaviour. You can disable the implicit setting by setting this property
* as false.
- *
+ *
* It is useful, because you usually want to start with the form free of
* errors and only display them after the user clicks Ok. You can disable
* the implicit setting by setting this property as false.
- *
+ *
* @param makeVisible
* If true (default), validation is made visible when commit() is
* called. If false, the visibility is left as it is.
/**
* Is validation made automatically visible on commit?
- *
+ *
* See setValidationVisibleOnCommit().
- *
+ *
* @return true if validation is made automatically visible on commit.
*/
public boolean isValidationVisibleOnCommit() {
// Try to commit all
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
try {
- final Field<?> f = (fields.get(i.next()));
+ final Field<?> f = fields.get(i.next());
// Commit only non-readonly fields.
if (!f.isReadOnly()) {
f.commit();
// Try to discard all changes
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
try {
- (fields.get(i.next())).discard();
+ fields.get(i.next()).discard();
} catch (final Buffered.SourceException e) {
if (problems == null) {
problems = new LinkedList<>();
this.buffered = buffered;
for (final Iterator<Object> i = propertyIds.iterator(); i
.hasNext();) {
- (fields.get(i.next())).setBuffered(buffered);
+ fields.get(i.next()).setBuffered(buffered);
}
}
}
/**
* Adds a new property to form and create corresponding field.
- *
+ *
* @see com.vaadin.data.Item#addItemProperty(Object, Property)
*/
@Override
/**
* Registers the field with the form and adds the field to the form layout.
- *
+ *
* <p>
* The property id must not be already used in the form.
* </p>
- *
+ *
* <p>
* This field is added to the layout using the
* {@link #attachField(Object, Field)} method.
* </p>
- *
+ *
* @param propertyId
* the Property id the the field.
* @param field
/**
* Register the field with the form. All registered fields are validated
* when the form is validated and also committed when the form is committed.
- *
+ *
* <p>
* The property id must not be already used in the form.
* </p>
- *
- *
+ *
+ *
* @param propertyId
* the Property id of the field.
* @param field
// form.
// Should this also include invalidCommitted (#3993)?
field.setBuffered(buffered);
- if (isImmediate() && field instanceof AbstractComponent) {
- ((AbstractComponent) field).setImmediate(true);
+ if (isImmediate() && field instanceof AbstractLegacyComponent) {
+ ((AbstractLegacyComponent) field).setImmediate(true);
}
}
* CustomLayout location given by the string representation of the property
* id using {@link CustomLayout#addComponent(Component, String)}.
* </p>
- *
+ *
* <p>
* Override this method to control how the fields are added to the layout.
* </p>
- *
+ *
* @param propertyId
* @param field
*/
/**
* The property identified by the property id.
- *
+ *
* <p>
* The property data source of the field specified with property id is
* returned. If there is a (with specified property id) having no data
* source, the field is returned instead of the data source.
* </p>
- *
+ *
* @see com.vaadin.data.Item#getItemProperty(Object)
*/
@Override
/**
* Gets the field identified by the propertyid.
- *
+ *
* @param propertyId
* the id of the property.
*/
/**
* Removes the property and corresponding field from the form.
- *
+ *
* @see com.vaadin.data.Item#removeItemProperty(Object)
*/
@Override
* Override this method to control how the fields are removed from the
* layout.
* </p>
- *
+ *
* @param field
* the field to be detached from the forms layout.
*/
/**
* Removes all properties and fields from the form.
- *
+ *
* @return the Success of the operation. Removal of all fields succeeded if
* (and only if) the return value is <code>true</code>.
*/
/**
* Sets the item datasource for the form.
- *
+ *
* <p>
* Setting item datasource clears any fields, the form might contain and
* adds all the properties as fields to the form.
* </p>
- *
+ *
* @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
*/
@Override
/**
* Set the item datasource for the form, but limit the form contents to
* specified properties of the item.
- *
+ *
* <p>
* Setting item datasource clears any fields, the form might contain and
* adds the specified the properties as fields to the form, in the specified
* order.
* </p>
- *
+ *
* @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
*/
public void setItemDataSource(Item newDataSource,
* property straight to Field. If Property.Viewer type property (e.g.
* PropertyFormatter) is already set for field, the property is bound to
* that Property.Viewer.
- *
+ *
* @param propertyId
* @param property
* @param field
// expect developer has e.g. PropertyFormatter that he wishes to use and
// assign the property to the Viewer instead.
boolean hasFilterProperty = field.getPropertyDataSource() != null
- && (field.getPropertyDataSource() instanceof Property.Viewer);
+ && field.getPropertyDataSource() instanceof Property.Viewer;
if (hasFilterProperty) {
((Property.Viewer) field.getPropertyDataSource())
.setPropertyDataSource(property);
/**
* Gets the layout of the form.
- *
+ *
* <p>
* By default form uses <code>OrderedLayout</code> with <code>form</code>
* -style.
* </p>
- *
+ *
* @return the Layout of the form.
*/
public Layout getLayout() {
/**
* Sets the layout of the form.
- *
+ *
* <p>
* If set to null then Form uses a FormLayout by default.
* </p>
- *
+ *
* @param layout
* the layout of the form.
*/
/**
* Sets the form field to be selectable from static list of changes.
- *
+ *
* <p>
* The list values and descriptions are given as array. The value-array must
* contain the current value of the field and the lengths of the arrays must
* match. Null values are not supported.
* </p>
- *
+ *
* Note: since Vaadin 7.0, returns an {@link AbstractSelect} instead of a
* {@link Select}.
- *
+ *
* @param propertyId
* the id of the property.
* @param values
boolean isMultiselect = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == value
- || (value != null && value.equals(values[i]))) {
+ || value != null && value.equals(values[i])) {
found = true;
}
}
found = false;
for (int i = 0; i < values.length && !found; i++) {
if (values[i] == val
- || (val != null && val.equals(values[i]))) {
+ || val != null && val.equals(values[i])) {
found = true;
}
}
/**
* Checks the validity of the Form and all of its fields.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#validate()
*/
@Override
public void validate() throws Validator.InvalidValueException {
super.validate();
for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).validate();
+ fields.get(i.next()).validate();
}
}
/**
* Checks the validabtable object accept invalid values.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#isInvalidAllowed()
*/
@Override
/**
* Should the validabtable object accept invalid values.
- *
+ *
* @see com.vaadin.legacy.data.Validatable#setInvalidAllowed(boolean)
*/
@Override
/**
* Sets the component's to read-only mode to the specified state.
- *
+ *
* @see com.vaadin.ui.Component#setReadOnly(boolean)
*/
@Override
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
for (final Iterator<?> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).setReadOnly(readOnly);
+ fields.get(i.next()).setReadOnly(readOnly);
}
}
/**
* Sets the field factory used by this Form to genarate Fields for
* properties.
- *
+ *
* {@link FormFieldFactory} is used to create fields for form properties.
* {@link DefaultFieldFactory} is used by default.
- *
+ *
* @param fieldFactory
* the new factory used to create the fields.
* @see Field
/**
* Get the field factory of the form.
- *
+ *
* @return the FormFieldFactory Factory used to create the fields.
*/
public FormFieldFactory getFormFieldFactory() {
/**
* Gets the field type.
- *
+ *
* @see com.vaadin.legacy.ui.AbstractField#getType()
*/
@Override
/**
* Sets the internal value.
- *
+ *
* This is relevant when the Form is used as Field.
- *
+ *
* @see com.vaadin.legacy.ui.AbstractField#setInternalValue(java.lang.Object)
*/
@Override
* Gets the first focusable field in form. If there are enabled,
* non-read-only fields, the first one of them is returned. Otherwise, the
* field for the first property (or null if none) is returned.
- *
+ *
* @return the Field.
*/
private Field<?> getFirstFocusableField() {
/**
* Updates the internal form datasource.
- *
+ *
* Method setFormDataSource.
- *
+ *
* @param data
* @param properties
*/
/**
* Returns the visibleProperties.
- *
+ *
* @return the Collection of visible Item properites.
*/
public Collection<?> getVisibleItemProperties() {
/**
* Sets the visibleProperties.
- *
+ *
* @param visibleProperties
* the visibleProperties to set.
*/
/**
* Sets the visibleProperties.
- *
+ *
* @param visibleProperties
* the visibleProperties to set.
*/
/**
* Focuses the first field in the form.
- *
+ *
* @see com.vaadin.ui.Component.Focusable#focus()
*/
@Override
/**
* Sets the Tabulator index of this Focusable component.
- *
+ *
* @see com.vaadin.ui.Component.Focusable#setTabIndex(int)
*/
@Override
super.setTabIndex(tabIndex);
for (final Iterator<?> i = getItemPropertyIds().iterator(); i
.hasNext();) {
- (getField(i.next())).setTabIndex(tabIndex);
+ getField(i.next()).setTabIndex(tabIndex);
}
}
super.setImmediate(immediate);
for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
Field<?> f = i.next();
- if (f instanceof AbstractComponent) {
- ((AbstractComponent) f).setImmediate(immediate);
+ if (f instanceof AbstractLegacyComponent) {
+ ((AbstractLegacyComponent) f).setImmediate(immediate);
}
}
}
* {@inheritDoc}
* <p>
* A Form is empty if all of its fields are empty.
- *
+ *
*/
@Override
public boolean isEmpty() {
/*
* (non-Javadoc)
- *
+ *
* @see com.vaadin.ui.AbstractField#clear()
*/
@Override
/**
* Adding validators directly to form is not supported.
- *
+ *
* Add the validators to form fields instead.
*/
@Override
/**
* Returns a layout that is rendered below normal form contents. This area
* can be used for example to include buttons related to form contents.
- *
+ *
* @return layout rendered below normal form contents or null if no footer
* is used
*/
/**
* Sets the layout that is rendered below normal form contents. No footer is
* rendered if this is set to null, .
- *
+ *
* @param footer
* the new footer layout
*/
* {@link AbstractField}. The ownActionManager handles Actions attached to
* this Form specifically, while the ActionManager in AbstractField
* delegates to the containing Window (i.e global Actions).
- *
+ *
* @return
*/
protected ActionManager getOwnActionManager() {
import org.jsoup.nodes.Element;
import com.vaadin.shared.util.SharedUtil;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignFormatter;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Label extends AbstractComponent implements Property<String>,
+public class Label extends AbstractLegacyComponent implements Property<String>,
Property.Viewer, Property.ValueChangeListener,
Property.ValueChangeNotifier, Comparable<Label> {
import com.vaadin.server.StreamVariable.StreamingProgressEvent;
import com.vaadin.shared.EventId;
import com.vaadin.shared.Registration;
-import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Component;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.util.ReflectTools;
*/
@SuppressWarnings("serial")
@Deprecated
-public class Upload extends AbstractComponent
+public class Upload extends AbstractLegacyComponent
implements Component.Focusable, LegacyComponent {
/**
/*
* Copyright 2000-2016 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
/**
* A component that represents color selection popup within a color picker.
- *
+ *
* @since 7.0.0
*/
@Deprecated
-public class ColorPickerPopup extends Window implements ClickListener,
- ColorChangeListener, ColorSelector {
+public class ColorPickerPopup extends Window
+ implements ClickListener, ColorChangeListener, ColorSelector {
private static final String STYLENAME = "v-colorpicker-popup";
setContent(layout);
setStyleName(STYLENAME);
setResizable(false);
- setImmediate(true);
// Create the history
history = new ColorPickerHistory();
history.addColorChangeListener(this);
/**
* Creates the RGB tab.
- *
+ *
* @return the component
*/
private Component createRGBTab(Color color) {
public void valueChange(ValueChangeEvent event) {
double red = (Double) event.getProperty().getValue();
if (!updatingColors) {
- Color newColor = new Color((int) red, selectedColor
- .getGreen(), selectedColor.getBlue());
+ Color newColor = new Color((int) red,
+ selectedColor.getGreen(), selectedColor.getBlue());
setColor(newColor);
}
}
/**
* Creates the hsv tab.
- *
+ *
* @return the component
*/
private Component createHSVTab(Color color) {
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 360f;
- float saturation = (Float.parseFloat(saturationSlider
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(valueSlider.getValue()
- .toString())) / 100f;
+ float hue = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ saturationSlider.getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ valueSlider.getValue().toString()) / 100f;
// Set the color
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
/*
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(hueSlider.getValue()
- .toString())) / 360f;
- float saturation = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(valueSlider.getValue()
- .toString())) / 100f;
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ float hue = Float
+ .parseFloat(hueSlider.getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ valueSlider.getValue().toString()) / 100f;
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
}
}
@Override
public void valueChange(ValueChangeEvent event) {
if (!updatingColors) {
- float hue = (Float.parseFloat(hueSlider.getValue()
- .toString())) / 360f;
- float saturation = (Float.parseFloat(saturationSlider
- .getValue().toString())) / 100f;
- float value = (Float.parseFloat(event.getProperty()
- .getValue().toString())) / 100f;
-
- Color color = new Color(Color.HSVtoRGB(hue, saturation,
- value));
+ float hue = Float
+ .parseFloat(hueSlider.getValue().toString()) / 360f;
+ float saturation = Float.parseFloat(
+ saturationSlider.getValue().toString()) / 100f;
+ float value = Float.parseFloat(
+ event.getProperty().getValue().toString()) / 100f;
+
+ Color color = new Color(
+ Color.HSVtoRGB(hue, saturation, value));
setColor(color);
}
}
/**
* Creates the select tab.
- *
+ *
* @return the component
*/
private Component createSelectTab() {
/**
* Gets the history.
- *
+ *
* @return the history
*/
public ColorPickerHistory getHistory() {
/**
* Gets the color history.
- *
+ *
* @return the color history
*/
public List<Color> getColorHistory() {
blueSlider.setValue(((Integer) color.getBlue()).doubleValue());
greenSlider.setValue(((Integer) color.getGreen()).doubleValue());
} catch (ValueOutOfBoundsException e) {
- getLogger().log(
- Level.WARNING,
+ getLogger().log(Level.WARNING,
"Unable to set RGB color value to " + color.getRed() + ","
- + color.getGreen() + "," + color.getBlue(), e);
+ + color.getGreen() + "," + color.getBlue(),
+ e);
}
}
saturationSlider.setValue(((Float) (hsv[1] * 100f)).doubleValue());
valueSlider.setValue(((Float) (hsv[2] * 100f)).doubleValue());
} catch (ValueOutOfBoundsException e) {
- getLogger().log(
- Level.WARNING,
- "Unable to set HSV color value to " + hsv[0] + "," + hsv[1]
- + "," + hsv[2], e);
+ getLogger().log(Level.WARNING, "Unable to set HSV color value to "
+ + hsv[0] + "," + hsv[1] + "," + hsv[2], e);
}
}
/**
* Checks the visibility of the given tab
- *
+ *
* @param tab
* The tab to check
* @return true if tab is visible, false otherwise
/**
* How many tabs are visible
- *
+ *
* @return The number of tabs visible
*/
private int tabsNumVisible() {
/**
* Set RGB tab visibility
- *
+ *
* @param visible
* The visibility of the RGB tab
*/
/**
* Set HSV tab visibility
- *
+ *
* @param visible
* The visibility of the HSV tab
*/
/**
* Set Swatches tab visibility
- *
+ *
* @param visible
* The visibility of the Swatches tab
*/
/**
* Set the History visibility
- *
+ *
* @param visible
*/
public void setHistoryVisible(boolean visible) {
/**
* Set the preview visibility
- *
+ *
* @param visible
*/
public void setPreviewVisible(boolean visible) {
@Override
public Color calculate(int x, int y) {
- float h = (x / 220f);
+ float h = x / 220f;
float s = 1f;
float v = 1f;
@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;
private ColorPickerPreview() {
setStyleName("v-colorpicker-preview");
- setImmediate(true);
field = new TextField();
field.setImmediate(true);
field.setSizeFull();
--- /dev/null
+/*
+ * Copyright 2000-2016 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.v7.ui;
+
+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;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.server.ErrorMessage.ErrorLevel;
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.FileResource;
+import com.vaadin.server.Responsive;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.server.UserError;
+import com.vaadin.tests.design.DeclarativeTestBase;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.declarative.Design;
+import com.vaadin.ui.declarative.DesignContext;
+
+/**
+ * Test cases for reading and writing the properties of AbstractComponent.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class AbstractLegacyComponentDeclarativeTest
+ extends DeclarativeTestBase<AbstractLegacyComponent> {
+
+ private AbstractLegacyComponent component;
+
+ @Before
+ public void setUp() {
+ NativeSelect ns = new NativeSelect();
+ component = ns;
+ }
+
+ @Test
+ public void testEmptyDesign() {
+ String design = "<vaadin7-native-select>";
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testProperties() {
+ String design = "<vaadin7-native-select id=\"testId\" primary-style-name=\"test-style\" "
+ + "caption=\"test-caption\" locale=\"fi_FI\" description=\"test-description\" "
+ + "error=\"<div>test-error</div>\" />";
+ component.setId("testId");
+ component.setPrimaryStyleName("test-style");
+ component.setCaption("test-caption");
+ component.setLocale(new Locale("fi", "FI"));
+ component.setDescription("test-description");
+ 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);
+ }
+
+ @Test
+ public void testReadImmediate() {
+ // Additional tests for the immediate property, including
+ // explicit immediate values
+ String[] design = { "<vaadin7-native-select/>",
+ "<vaadin7-native-select immediate=\"false\"/>",
+ "<vaadin7-native-select immediate=\"true\"/>",
+ "<vaadin7-native-select immediate />" };
+ Boolean[] explicitImmediate = { null, Boolean.FALSE, Boolean.TRUE,
+ Boolean.TRUE };
+ boolean[] immediate = { true, false, true, true };
+ for (int i = 0; i < design.length; i++) {
+ component = (AbstractLegacyComponent) Design
+ .read(new ByteArrayInputStream(
+ design[i].getBytes(Charset.forName("UTF-8"))));
+ assertEquals(immediate[i], component.isImmediate());
+ assertEquals(explicitImmediate[i], getExplicitImmediate(component));
+ }
+ }
+
+ @Test
+ public void testExternalIcon() {
+ String design = "<vaadin7-native-select icon=\"http://example.com/example.gif\"/>";
+ component.setIcon(
+ new ExternalResource("http://example.com/example.gif"));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testThemeIcon() {
+ String design = "<vaadin7-native-select icon=\"theme://example.gif\"/>";
+ component.setIcon(new ThemeResource("example.gif"));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testFileResourceIcon() {
+ String design = "<vaadin7-native-select icon=\"img/example.gif\"/>";
+ component.setIcon(new FileResource(new File("img/example.gif")));
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testWidthAndHeight() {
+ String design = "<vaadin7-native-select width=\"70%\" height=\"12px\"/>";
+ component.setWidth("70%");
+ component.setHeight("12px");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testSizeFull() {
+ String design = "<vaadin7-native-select size-full />";
+ component.setSizeFull();
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testHeightFull() {
+ String design = "<vaadin7-native-select height-full width=\"20px\"/>";
+ component.setHeight("100%");
+ component.setWidth("20px");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testWidthFull() {
+ String design = "<vaadin7-native-select caption=\"Foo\" caption-as-html width-full height=\"20px\"></vaadin7-native-select>";
+ AbstractLegacyComponent component = new NativeSelect();
+ component.setCaptionAsHtml(true);
+ component.setCaption("Foo");
+ component.setHeight("20px");
+ component.setWidth("100%");
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testResponsive() {
+ String design = "<vaadin7-native-select responsive />";
+ Responsive.makeResponsive(component);
+ testRead(design, component);
+ testWrite(design, component);
+ }
+
+ @Test
+ public void testResponsiveFalse() {
+ String design = "<vaadin7-native-select responsive =\"false\"/>";
+ // Only test read as the attribute responsive=false would not be written
+ testRead(design, component);
+ }
+
+ @Test
+ public void testReadAlreadyResponsive() {
+ AbstractComponent component = new Label();
+ Responsive.makeResponsive(component);
+ Element design = createDesign(true);
+ component.readDesign(design, new DesignContext());
+ assertEquals("Component should have only one extension", 1,
+ component.getExtensions().size());
+ }
+
+ @Test
+ public void testUnknownProperties() {
+ String design = "<vaadin7-native-select foo=\"bar\"/>";
+
+ DesignContext context = readAndReturnContext(design);
+ NativeSelect ns = (NativeSelect) context.getRootComponent();
+ assertTrue("Custom attribute was preserved in custom attributes",
+ context.getCustomAttributes(ns).containsKey("foo"));
+
+ testWrite(ns, design, context);
+ }
+
+ private Element createDesign(boolean responsive) {
+ Attributes attributes = new Attributes();
+ attributes.put("responsive", responsive);
+ Element node = new Element(Tag.valueOf("vaadin-label"), "", attributes);
+ return node;
+ }
+
+ private Boolean getExplicitImmediate(AbstractLegacyComponent component) {
+ try {
+ Field immediate = AbstractLegacyComponent.class
+ .getDeclaredField("explicitImmediateValue");
+ immediate.setAccessible(true);
+ return (Boolean) immediate.get(component);
+ } catch (Exception e) {
+ throw new RuntimeException(
+ "Getting the field explicitImmediateValue failed.");
+ }
+ }
+}
--- /dev/null
+package com.vaadin.v7.ui;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class AbstractLegacyComponentTest {
+ AbstractLegacyComponent component = new AbstractLegacyComponent() {
+ };
+
+ @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());
+ }
+}
*/
package com.vaadin.v7.shared;
-import com.vaadin.shared.ui.TabIndexState;
+import com.vaadin.shared.annotations.NoLayout;
/**
* Shared state for {@link com.vaadin.ui.AbstractField}.
* @since 7.0.0
*
*/
-public class AbstractFieldState extends TabIndexState {
+public class AbstractFieldState extends AbstractLegacyComponentState {
public boolean propertyReadOnly = false;
public boolean hideErrors = false;
public boolean required = false;
public boolean modified = false;
+ /**
+ * The <i>tabulator index</i> of the field.
+ */
+ @NoLayout
+ public int tabIndex = 0;
}
--- /dev/null
+/*
+ * Copyright 2000-2016 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.v7.shared;
+
+import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.shared.annotations.NoLayout;
+
+/**
+ * Shared state for AbstractLegacyComponent.
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ * @deprecated only used for Vaadin 7 compatiblity components
+ */
+@Deprecated
+public class AbstractLegacyComponentState extends AbstractComponentState {
+ @NoLayout
+ public boolean immediate = false;
+}
import java.util.List;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* @since 7.1.0
* @author Vaadin Ltd.
*/
-public class CalendarState extends AbstractComponentState {
+public class CalendarState extends AbstractLegacyComponentState {
public boolean format24H;
public String[] dayNames;
*/
package com.vaadin.v7.shared.ui.colorpicker;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* Default shared state implementation for ColorPickerGradient.
* @since 7.0.0
*/
@Deprecated
-public class ColorPickerGradientState extends AbstractComponentState {
+public class ColorPickerGradientState extends AbstractLegacyComponentState {
public int cursorX;
*/
package com.vaadin.v7.shared.ui.colorpicker;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* Default shared state implementation for ColorPickerGrid.
* @since 7.0.0
*/
@Deprecated
-public class ColorPickerGridState extends AbstractComponentState {
+public class ColorPickerGridState extends AbstractLegacyComponentState {
public int rowCount;
*/
package com.vaadin.v7.shared.ui.colorpicker;
-import com.vaadin.shared.AbstractComponentState;
import com.vaadin.shared.annotations.DelegateToWidget;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* Default shared state implementation for AbstractColorPicker.
* @since 7.0.0
*/
@Deprecated
-public class ColorPickerState extends AbstractComponentState {
+public class ColorPickerState extends AbstractLegacyComponentState {
{
primaryStyleName = "v-colorpicker";
}
*/
package com.vaadin.v7.shared.ui.label;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
-public class LabelState extends AbstractComponentState {
+public class LabelState extends AbstractLegacyComponentState {
{
primaryStyleName = "v-label";
}
*/
package com.vaadin.v7.shared.ui.upload;
-import com.vaadin.shared.AbstractComponentState;
+import com.vaadin.v7.shared.AbstractLegacyComponentState;
/**
* Shared state for the Upload component.
*
* @since 7.6
*/
-public class UploadState extends AbstractComponentState {
+public class UploadState extends AbstractLegacyComponentState {
{
primaryStyleName = "v-upload";
*/
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,
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()) {
*/
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();
-
}
/**
* Returns the current selected color of this color picker.
- *
+ *
* @return the selected color, not null
*/
@Override
/**
* 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
*/
/**
* 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
*/
window.setHistoryVisible(historyVisible);
window.setPreviewVisible(textfieldVisible);
- window.setImmediate(true);
window.addCloseListener(
event -> getState().popupVisible = false);
window.addValueChangeListener(
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);
private HasComponents parent;
- private Boolean explicitImmediateValue;
-
protected static final String DESIGN_ATTR_PLAIN_TEXT = "plain-text";
/* Constructor */
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 {
}
}
- /**
- * 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)
*
} else {
getState().errorMessage = null;
}
-
- getState().immediate = isImmediate();
}
/* General event framework */
}
}
- // handle immediate
- if (attr.hasKey("immediate")) {
- setImmediate(DesignAttributeHandler.getFormatter()
- .parse(attr.get("immediate"), Boolean.class));
- }
// handle locale
if (attr.hasKey("locale")) {
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()))) {
* // 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
* // 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
// expand horizontally by default
setWidth(100, UNITS_PERCENTAGE);
- setImmediate(true);
setCloseHandler(new CloseHandler() {
@Override
setContent(layout);
setStyleName(STYLENAME);
setResizable(false);
- setImmediate(true);
// Create the history
history = new ColorPickerHistory();
history.addValueChangeListener(this::colorChanged);
/**
* Instantiates a new color picker popup.
- *
+ *
* @param initialColor
* the initially selected 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);
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(
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);
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(
@Override
public Color calculate(int x, int y) {
- float h = (x / 220f);
+ float h = x / 220f;
float s = 1f;
float v = 1f;
@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;
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);
}
oldValue = value;
- fireEvent(new ValueChange<>((Component) field.getData(),
- color, event.isUserOriginated()));
+ fireEvent(new ValueChange<>((Component) field.getData(), color,
+ event.isUserOriginated()));
}
} catch (NumberFormatException nfe) {
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.Locale;
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);
}
component = (AbstractComponent) Design
.read(new ByteArrayInputStream(
design[i].getBytes(Charset.forName("UTF-8"))));
- assertEquals(immediate[i], component.isImmediate());
- assertEquals(explicitImmediate[i], getExplicitImmediate(component));
}
}
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.");
- }
- }
}
+++ /dev/null
-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());
- }
-}
public String width = "";
public boolean readOnly = false;
@NoLayout
- public boolean immediate = false;
- @NoLayout
public String description = "";
// Note: for the caption, there is a difference between null and an empty
// string!
df.setCaption("DateField caption " + df);
df.setDescription("DateField description " + df);
df.setComponentError(errorMsg);
- df.setImmediate(true);
// FIXME: bug #1138 this makes datefield to render with unknown
// component (UIDL tree debug)
df.addStyleName("thisShouldBeHarmless");
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
s.setMax(13);
s.setMin(12);
s.setResolution(2);
- s.setImmediate(true);
// s.setOrientation(Slider.ORIENTATION_VERTICAL);
// s.setArrows(false);
+++ /dev/null
-package com.vaadin.tests.application;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.util.Set;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.ConnectorTracker;
-import com.vaadin.ui.Window;
-
-public class ResynchronizeAfterAsyncRemoval extends AbstractTestUIWithLog {
-
- @Override
- public void setup(VaadinRequest vaadinRequest) {
- final Window window = new Window("Asynchronously removed window");
- // without this, the size info sent in the background removes the
- // window immediately after showing it, making the test fail
- setImmediate(false);
- window.center();
-
- // The window will enqueue a non-immediate message reporting its current
- // position.
- addWindow(window);
-
- // Remove window immediately when the current response is sent
- runAfterResponse(new Runnable() {
- @Override
- public void run() {
- removeWindow(window);
- }
- });
-
- // Clicking the button will trigger sending the window coordinates, but
- // the window is already removed at that point.
- addComponent(new Button("Am I dirty?", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log("Window removed: " + (window.getParent() == null));
-
- boolean dirty = getUI().getConnectorTracker()
- .isDirty(event.getButton());
- log("Dirty: " + dirty);
- }
- }));
- addComponent(new Button("Log unregistered connector count",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- logUnregisteredConnectorCount();
- }
- }));
- }
-
- private void logUnregisteredConnectorCount() {
- int count = 0;
-
- Map<Integer, Set<String>> unregisterIdMap = getUnregisterIdMap();
- for (Set<String> set : unregisterIdMap.values()) {
- count += set.size();
- }
- log("syncId: " + getConnectorTracker().getCurrentSyncId());
- log("Unregistered connector count: " + count);
- }
-
- @SuppressWarnings("unchecked")
- private Map<Integer, Set<String>> getUnregisterIdMap() {
- try {
- ConnectorTracker tracker = getConnectorTracker();
- Field field = tracker.getClass()
- .getDeclaredField("syncIdToUnregisteredConnectorIds");
- field.setAccessible(true);
- return (Map<Integer, Set<String>>) field.get(tracker);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
\ No newline at end of file
* when overriding.
*/
protected void createActions() {
- createBooleanAction("Immediate", CATEGORY_STATE, true,
- immediateCommand);
createBooleanAction("Enabled", CATEGORY_STATE, true, enabledCommand);
createBooleanAction("Readonly", CATEGORY_STATE, false, readonlyCommand);
createBooleanAction("Visible", CATEGORY_STATE, true, visibleCommand);
}
protected boolean isSelected(MenuItem item) {
- return (item.getIcon() != null);
+ return item.getIcon() != null;
}
private <VALUETYPE> MenuBar.Command singleSelectMenuCommand(
Registration registration;
@Override
- public void execute(T c, Boolean enabled,
- Object data) {
+ public void execute(T c, Boolean enabled, Object data) {
if (enabled) {
registration = addListener.apply(c);
} else if (registration != null) {
/* COMMANDS */
- protected Command<T, String> widthCommand = (t, value, data) -> t.setWidth(
- value);
+ protected Command<T, String> widthCommand = (t, value, data) -> t
+ .setWidth(value);
protected Command<T, String> heightCommand = (t, value, data) -> t
.setHeight(value);
protected Command<T, Boolean> enabledCommand = (c, enabled, data) -> c
.setEnabled(enabled);
- protected Command<T, Boolean> immediateCommand = (c, immediate, data) -> c
- .setImmediate(immediate);
-
protected Command<T, Boolean> errorIndicatorCommand = (c, enabled,
data) -> {
if (enabled) {
protected Command<T, Boolean> visibleCommand = (c, enabled, data) -> c
.setVisible(enabled);
- protected Command<T, Resource> iconCommand = (c, value, data) -> c.setIcon(
- value);
+ protected Command<T, Resource> iconCommand = (c, value, data) -> c
+ .setIcon(value);
protected Command<T, String> captionCommand = (c, value, data) -> c
.setCaption(value);
event -> doCommand(command, event.getValue()));
checkBox.setValue(initialState);
- checkBox.setImmediate(true);
checkBox.setId("checkboxaction-" + caption);
// Set default value for all components
});
button.setId("buttonaction-" + caption);
- button.setImmediate(true);
return button;
}
+++ /dev/null
-package com.vaadin.tests.components;
-
-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.Notification;
-
-public class OutOfSync extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- // Without this, there is an extra request from the UI that changes the
- // request sequence compared to what the test expects
- setImmediate(false);
-
- Button b = new Button("Click me after 1s to be out of sync");
- b.addClickListener(new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Notification.show("This code will never be reached");
- }
- });
- setContent(b);
- Thread t = new Thread(new Runnable() {
-
- @Override
- public void run() {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- // Remove button but prevent repaint -> causes out of sync
- // issues
- getSession().lock();
- try {
- setContent(null);
- getConnectorTracker().markClean(OutOfSync.this);
- } finally {
- getSession().unlock();
- }
- }
- });
- t.start();
- }
-
- @Override
- protected String getTestDescription() {
- return "Click the button after 1s when it has been removed server side (causing synchronization problems)";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 10780;
- }
-
-}
@Override
protected void setup(VaadinRequest request) {
mainLayout = new AbsoluteLayout();
- mainLayout.setImmediate(true);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
// btnLogin
Button btnLogin = new Button();
btnLogin.setCaption("Login");
- btnLogin.setImmediate(false);
btnLogin.setWidth("-1px");
btnLogin.setHeight("-1px");
btnLogin.addClickListener(new Button.ClickListener() {
GridLayout gridButtons = new GridLayout(2, 3);
Button btn1 = new Button("Button one");
- btn1.setImmediate(true);
btn1.addClickListener(new Button.ClickListener() {
@Override
gridButtons.addComponent(btn1, 0, 0);
Button btn2 = new Button("Button two");
- btn2.setImmediate(true);
btn2.addClickListener(new Button.ClickListener() {
@Override
gridButtons.addComponent(btn2, 0, 1);
Button btn3 = new Button("Button three");
- btn3.setImmediate(true);
btn3.addClickListener(new Button.ClickListener() {
@Override
button.setEnabled(enabled);
// button.requestRepaint();
});
- enable.setImmediate(true);
CheckBox caption = new CheckBox("Toggle button caption", true);
caption.addValueChangeListener(
event -> button.setCaption(button.getCaption() + "+"));
- caption.setImmediate(true);
CheckBox visible = new CheckBox("Toggle panel visibility", true);
visible.addValueChangeListener(
event -> panel.setVisible(event.getValue()));
- visible.setImmediate(true);
CheckBox panelEnable = new CheckBox("Toggle panel enabled", true);
panelEnable.addValueChangeListener(
event -> panel.setEnabled(event.getValue()));
- panelEnable.setImmediate(true);
mainWindow.addComponent(enable);
mainWindow.addComponent(caption);
import com.vaadin.v7.ui.Field;
import com.vaadin.v7.ui.TextField;
-public class RequiredIndicatorForFieldsWithoutCaption extends AbstractReindeerTestUI {
+public class RequiredIndicatorForFieldsWithoutCaption
+ extends AbstractReindeerTestUI {
private Set<Field> fields = new HashSet<>();
@Override
protected void setup(VaadinRequest request) {
CheckBox required = new CheckBox("Fields required", true);
- required.setImmediate(true);
required.addValueChangeListener(event -> {
boolean newRequired = event.getValue();
for (Field f : fields) {
getLayout().setSpacing(true);
Button button = new Button("CLICK ME!", clickListener);
- button.setImmediate(true);
addComponent(button);
addComponent(out);
addComponent(btn);
final CheckBox enable = new CheckBox("Enable alt text", true);
- enable.setImmediate(true);
enable.addValueChangeListener(event -> {
if (event.getValue()) {
btn.setIconAlternateText("alt text");
setLocale(defaultLocale);
}
- if (parameters.containsKey(("secondsResolution"))) {
+ if (parameters.containsKey("secondsResolution")) {
useSecondResolution = true;
}
private void initHideWeekEndButton() {
hideWeekendsButton = new CheckBox("Hide weekends");
- hideWeekendsButton.setImmediate(true);
hideWeekendsButton.addValueChangeListener(
event -> setWeekendsHidden(hideWeekendsButton.getValue()));
}
private void initReadOnlyButton() {
readOnlyButton = new CheckBox("Read-only mode");
- readOnlyButton.setImmediate(true);
readOnlyButton.addValueChangeListener(event -> calendarComponent
.setReadOnly(readOnlyButton.getValue()));
}
private void initDisabledButton() {
disabledButton = new CheckBox("Disabled");
- disabledButton.setImmediate(true);
disabledButton.addValueChangeListener(event -> calendarComponent
.setEnabled(!disabledButton.getValue()));
}
private CheckBox createCheckBox(String caption) {
CheckBox cb = new CheckBox(caption);
- cb.setImmediate(true);
return cb;
}
+++ /dev/null
-/*
- * Copyright 2000-2016 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.checkbox;
-
-import com.vaadin.data.HasValue;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-
-public class CheckBoxImmediate extends AbstractReindeerTestUI {
- private int count = 0;
-
- @Override
- protected void setup(VaadinRequest request) {
- final Label status = new Label("Events received: " + count);
- status.setId("count");
- addComponent(status);
-
- CheckBox cb = new CheckBox("Non-immediate");
- HasValue.ValueChangeListener<Boolean> listener = event -> {
- count++;
- status.setValue("Events received: " + count);
- };
- cb.addValueChangeListener(listener);
- cb.setImmediate(false);
- addComponent(cb);
-
- cb = new CheckBox("Immediate");
- cb.addValueChangeListener(listener);
- cb.setImmediate(true);
- addComponent(cb);
- }
-
- @Override
- protected String getTestDescription() {
- return "Test for verifying that a non-immediate CheckBox does not send value change to server immediately.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 18102;
- }
-
-}
rgbVisible = event.getValue();
setPopupVisibilities();
});
- rgbBox.setImmediate(true);
rgbBox.setId("rgbBox");
optLayout.addComponent(rgbBox);
hsvVisible = event.getValue();
setPopupVisibilities();
});
- hsvBox.setImmediate(true);
hsvBox.setId("hsvBox");
optLayout.addComponent(hsvBox);
swaVisible = event.getValue();
setPopupVisibilities();
});
- swaBox.setImmediate(true);
swaBox.setId("swaBox");
optLayout.addComponent(swaBox);
historyVisible = event.getValue();
setPopupVisibilities();
});
- hisBox.setImmediate(true);
hisBox.setId("hisBox");
optLayout.addComponent(hisBox);
txtfieldVisible = event.getValue();
setPopupVisibilities();
});
- txtBox.setImmediate(true);
txtBox.setId("txtBox");
optLayout.addComponent(txtBox);
setContent(root);
ComboBox<String> combo = new ComboBox<>();
- combo.setImmediate(true);
root.addComponent(combo);
combo.setItems("Hello World", "Please click on the text");
combo.setItems("Item 1", "Item 2", "Item 3", "Item 4");
combo.addValueChangeListener(
event -> log.log("you made a selection change"));
- combo.setImmediate(true);
Button btn1 = new Button("Click me");
btn1.addClickListener(event -> log.log("you clicked me"));
final ComboBox cbNullSelectionNotAllowed = getComboBoxWithNullSelectionNotAllowed();
Button b = new Button("Reset");
- b.setImmediate(true);
b.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
protected void setup() {
final ComboBox<String> box = new ComboBox(null,
DataSource.create("Value 1", "Value 2", "Value 3", "Value 4"));
- box.setImmediate(true);
box.setPrimaryStyleName("my-combobox");
addComponent(box);
addTestComponent(s8);
ComboBox<StringBean> s9 = new PageLength0ComboBox();
- s9.setImmediate(true);
s9.setCaption("Pagelength 0");
populate(s9, 15);
s9.setItemCaptionGenerator(StringBean::getValue);
addComponent(cb2);
Button btClear = new Button("Clear button");
- btClear.setImmediate(true);
btClear.addClickListener(new Button.ClickListener() {
@Override
df.setLocale(locale);
df.setWidth("300px");
df.setDateFormat(pattern);
- df.setImmediate(true);
String debugId = pattern.replace('/', 'X');
// only certain characters are allowed in debug IDs
debugId = debugId.replaceAll("[^-a-zA-Z .'_]", "X");
final AbstractDateField dateField = new DateField("Enter date");
dateField.setResolution(Resolution.YEAR);
dateField.setId(DATEFIELD_ID);
- dateField.setImmediate(true);
addComponent(dateField);
Label l = new Label("Select resolution");
@Override
protected void setup(VaadinRequest request) {
final AbstractDateField dateField = new TestDateField("Insert Date: ");
- dateField.setImmediate(true);
dateField.setDateFormat(pattern);
dateField.addValueChangeListener(event -> log("valueChange: value: "
"From inclusive", bi.getItemProperty("fromInclusive"));
CheckBox toInclusive = new CheckBoxWithPropertyDataSource(
"To inclusive", bi.getItemProperty("toInclusive"));
- fromInclusive.setImmediate(true);
fromInclusive.addValueChangeListener(refreshField);
- toInclusive.setImmediate(true);
toInclusive.addValueChangeListener(refreshField);
PopupDateField toField = createDateField();
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
private AbstractDateField fromRange = new TestDateField("Range start");
private AbstractDateField toRange = new TestDateField("Range end");
private AbstractDateField valueDF = new TestDateField("Value");
- private CheckBox immediateCB = new CheckBox("Immediate");
private Button recreate = new Button("Recreate static datefields");
private Button clearRangeButton = new Button("Clear range");
});
fromRange.setValue(null);
- fromRange.setImmediate(true);
fromRange.addValueChangeListener(event -> {
inlineDynamicDateField.setRangeStart(fromRange.getValue());
dynamicDateField.setRangeStart(fromRange.getValue());
});
toRange.setValue(null);
- toRange.setImmediate(true);
toRange.addValueChangeListener(event -> {
inlineDynamicDateField.setRangeEnd(toRange.getValue());
dynamicDateField.setRangeEnd(toRange.getValue());
});
valueDF.setValue(null);
- valueDF.setImmediate(true);
valueDF.addValueChangeListener(event -> {
inlineDynamicDateField.setValue(valueDF.getValue());
dynamicDateField.setValue(valueDF.getValue());
});
- immediateCB.setValue(true);
- immediateCB.setImmediate(true);
- immediateCB.addValueChangeListener(event -> {
- inlineDynamicDateField.setImmediate(immediateCB.getValue());
- dynamicDateField.setImmediate(immediateCB.getValue());
- });
-
recreate.addClickListener(new Button.ClickListener() {
@Override
fromRange.setId("fromRange");
toRange.setId("toRange");
valueDF.setId("valueDF");
- immediateCB.setId("immediateCB");
recreate.setId("recreate");
clearRangeButton.setId("clearRangeButton");
dynamicDateField.setId("dynamicDateField");
hl.addComponent(fromRange);
hl.addComponent(toRange);
hl.addComponent(valueDF);
- hl.addComponent(immediateCB);
hl.addComponent(recreate);
hl.addComponent(clearRangeButton);
addComponent(hl);
LocalDate toVal = toRange.getValue();
LocalDate value = valueDF.getValue();
Resolution r = (Resolution) resoSelect.getValue();
- boolean immediate = immediateCB.getValue();
df.setValue(value);
df.setResolution(r);
df.setRangeStart(fromVal);
df.setRangeEnd(toVal);
- df.setImmediate(immediate);
-
}
}
protected void setup() {
MyDateField df = new MyDateField(
"Returns the old value for invalid dates");
- df.setImmediate(true);
addComponent(df);
MyDateField2 df2 = new MyDateField2("Returns empty for invalid dates");
- df2.setImmediate(true);
addComponent(df2);
MyDateField3 df3 = new MyDateField3(
"Throws an exception for invalid dates");
- df3.setImmediate(true);
addComponent(df3);
MyDateField4 df4 = new MyDateField4("Can convert 'today'");
- df4.setImmediate(true);
addComponent(df4);
}
final VerticalLayout pane = new VerticalLayout();
AbstractDateField dateField = new TestDateField();
- // If the field is immediate, the UI behaves differently (the value is
- // updated and an error is indicated earlier instead of showing the date
- // selector on the first click as the test expects. Keeping as
- // non-immediate to test the old expected behavior.
- dateField.setImmediate(false);
pane.addComponent(dateField);
content.addComponent(pane);
});
immediateCB.setValue(true);
- immediateCB.setImmediate(true);
immediateCB.addValueChangeListener(event -> {
inlineDynamicDateField.setImmediate(immediateCB.getValue());
dynamicDateField.setImmediate(immediateCB.getValue());
df.setLocale(new Locale("fi"));
df.setResolution(Resolution.DAY);
df.setLenient(true);
- df.setImmediate(true);
df.setValue(d);
AbstractDateField df2 = new TestDateField("Normal ");
df2.setResolution(Resolution.DAY);
// df2.setLenient(false);
df2.setValue(null);
- df2.setImmediate(true);
df2.setValue(d);
addComponent(df);
df = new TestDateField("Lenient with time");
df.setLocale(new Locale("fi"));
df.setLenient(true);
- df.setImmediate(true);
df.setValue(d);
df2 = new TestDateField("Normal with time");
df2.setLocale(new Locale("fi"));
// df2.setLenient(false);
df2.setValue(null);
- df2.setImmediate(true);
df2.setValue(d);
addComponent(df);
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.InlineDateField;
dateField.setResolution(Resolution.MONTH);
dateField.addValueChangeListener(event -> getMainWindow()
.showNotification("Date now" + event.getValue()));
- dateField.setImmediate(true);
getLayout().addComponent(dateField);
final DateField dateField3 = new DateField();
dateField3.setResolution(Resolution.YEAR);
dateField3.addValueChangeListener(event -> getMainWindow()
.showNotification("Date now" + event.getValue()));
- dateField3.setImmediate(true);
getLayout().addComponent(dateField3);
final InlineDateField dateField2 = new InlineDateField();
dateField2.setResolution(Resolution.MONTH);
dateField2.addValueChangeListener(event -> getMainWindow()
.showNotification("Date now" + event.getValue()));
- dateField2.setImmediate(true);
getLayout().addComponent(dateField2);
- CheckBox immediate = new CheckBox(
- "Immediate (use sync button to change fields) ");
- immediate.setValue(true);
- immediate.addListener(event -> {
- boolean newImmediate = !dateField.isImmediate();
- dateField.setImmediate(newImmediate);
- dateField2.setImmediate(newImmediate);
- dateField3.setImmediate(newImmediate);
- });
-
- getLayout().addComponent(immediate);
getLayout().addComponent(new Button("sync"));
}
final CheckBox enabled = new CheckBox("Enabled", true);
addComponent(enabled);
- enabled.setImmediate(true);
enabled.addValueChangeListener(
event -> dnd.setEnabled(event.getValue()));
final CheckBox enabled = new CheckBox("Enabled", true);
addComponent(enabled);
- enabled.setImmediate(true);
enabled.addValueChangeListener(
event -> dnd.setEnabled(event.getValue()));
});
final CheckBox enabled = new CheckBox("Enabled", true);
addComponent(enabled);
- enabled.setImmediate(true);
enabled.addValueChangeListener(
event -> tbl.setEnabled(event.getValue()));
}
-/*
+/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.FormLayout;
import com.vaadin.ui.DateField;
+import com.vaadin.ui.FormLayout;
public class FormLayoutErrorHover extends AbstractReindeerTestUI {
protected void setup(VaadinRequest request) {
FormLayout formLayout = new FormLayout();
DateField fromDate = new DateField("Date");
- fromDate.setImmediate(true);
formLayout.addComponent(fromDate);
addComponent(formLayout);
final CheckBox spacingCheckBox = new CheckBox("Spacings", false);
spacingCheckBox.setId("spacings");
- spacingCheckBox.setImmediate(true);
spacingCheckBox.addValueChangeListener(
event -> setLayoutSpacing(spacingCheckBox.getValue()));
addComponent(spacingCheckBox);
final CheckBox marginCheckBox = new CheckBox("Margins", false);
marginCheckBox.setId("margins");
- marginCheckBox.setImmediate(true);
marginCheckBox.addValueChangeListener(
event -> setLayoutMargin(marginCheckBox.getValue()));
addComponent(marginCheckBox);
gridLayout = new GridLayout(ROWS, COLS);
gridLayout.setHideEmptyRowsAndColumns(true);
- layout.setImmediate(true);
- gridLayout.setImmediate(true);
gridLayout2 = new GridLayout(4, 4);
gridLayout2.setHideEmptyRowsAndColumns(true);
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
Label label = new Label("Slot " + i + " " + j);
- label.setImmediate(true);
labels[i][j] = label;
gridLayout.addComponent(label, j, i);
if (!(i == 2 || j == 2)) {
"Hide / Show toggleable components");
visibilityToggleCheckBox.setId("visibility-toggle");
visibilityToggleCheckBox.setHeight("2000px");
- visibilityToggleCheckBox.setImmediate(true);
visibilityToggleCheckBox.setValue(false); // Initially unchecked
gridLayout.addComponent(visibilityToggleCheckBox);
}));
addComponent(new CheckBox("Listener active") {
{
- setImmediate(true);
addValueChangeListener(event -> resizeJsComponent
.setListenerEnabled(event.getValue()));
}
checkBox.setValue(audio.isShowControls());
checkBox.addValueChangeListener(
event -> audio.setShowControls(event.getValue()));
- checkBox.setImmediate(true);
addComponent(checkBox);
checkBox = new CheckBox("HtmlContentAllowed");
checkBox.setValue(audio.isHtmlContentAllowed());
checkBox.addValueChangeListener(
event -> audio.setHtmlContentAllowed(event.getValue()));
- checkBox.setImmediate(true);
addComponent(checkBox);
checkBox = new CheckBox("muted");
checkBox.setValue(audio.isMuted());
checkBox.addValueChangeListener(
event -> audio.setMuted(event.getValue()));
- checkBox.setImmediate(true);
addComponent(checkBox);
checkBox = new CheckBox("autoplay");
checkBox.setValue(audio.isAutoplay());
checkBox.addValueChangeListener(
event -> audio.setAutoplay(event.getValue()));
- checkBox.setImmediate(true);
addComponent(checkBox);
Button b = new Button("Change", new Button.ClickListener() {
optionGroup.setNewItemsAllowed(true);
final CheckBox readOnlyCheckbox = new CheckBox("read-only");
- readOnlyCheckbox.setImmediate(true);
readOnlyCheckbox.addValueChangeListener(
event -> optionGroup.setReadOnly(readOnlyCheckbox.getValue()));
readOnlyCheckbox.setValue(Boolean.TRUE);
header.addComponent(title);
final CheckBox vertical = new CheckBox("Vertical", !horizontal);
- vertical.setImmediate(true);
vertical.addValueChangeListener(event -> {
view.removeAllComponents();
final CheckBox margin = new CheckBox("Margin", false);
margin.addValueChangeListener(event -> l.setMargin(event.getValue()));
- margin.setImmediate(true);
layout.addComponent(margin);
layout.addComponent(margin);
final CheckBox spacing = new CheckBox("Spacing", false);
spacing.addValueChangeListener(event -> l.setSpacing(event.getValue()));
- spacing.setImmediate(true);
layout.addComponent(spacing);
// Cell controls
if (target == null) {
return;
}
- l.setComponentAlignment(target, ((Alignment) align.getValue()));
+ l.setComponentAlignment(target, (Alignment) align.getValue());
}
});
cell.addComponent(align);
expand = new CheckBox("Expand");
- expand.setImmediate(true);
expand.setEnabled(false);
expand.addValueChangeListener(event -> {
if (target != null) {
component.addComponent(componentDescription);
componentError = new CheckBox("Error");
- componentError.setImmediate(true);
componentError.setEnabled(false);
componentError.addValueChangeListener(event -> {
if (target != null) {
component.addComponent(componentError);
componentRequired = new CheckBox("Required");
- componentRequired.setImmediate(true);
componentRequired.setEnabled(false);
componentRequired.addValueChangeListener(event -> {
if (target != null && target instanceof AbstractField) {
filterFoobarField.setMaxLength(16);
// this.filterFoobarField.setStyleName("pexp-fixed-width");
- // Configure incoming checkbox
- incomingOnlyField.setImmediate(true);
-
// Add filter inputs for phone # and foobar ID
tableControlsLayout.addComponent(filterPhoneField);
tableControlsLayout.addComponent(filterFoobarField);
panel.setContent(panelLayout);
final CheckBox heightSelection = new CheckBox("Undefined height");
- heightSelection.setImmediate(true);
heightSelection.addValueChangeListener(event -> {
if (heightSelection.getValue() == Boolean.TRUE) {
panel.setHeight(null);
panel.setScrollTop(50);
panel.setScrollLeft(50);
- panel.setImmediate(true);
updateLabelText();
}
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
+import com.vaadin.ui.RichTextArea;
import com.vaadin.v7.shared.ui.progressindicator.ProgressIndicatorServerRpc;
import com.vaadin.v7.ui.ProgressIndicator;
-import com.vaadin.ui.RichTextArea;
public class RichTextAreaUpdateWhileTyping extends AbstractReindeerTestUI {
rta = new RichTextArea();
rta.setId("rta");
- rta.setImmediate(true);
addComponent(rta);
}
slider.markAsDirty();
});
- slider.setImmediate(true);
slider.setWidth(200, Unit.PIXELS);
addComponent(slider);
final HorizontalSplitPanel hsplit = new HorizontalSplitPanel();
hsplit.setSizeFull();
- hsplit.setImmediate(true);
hsplit.setSplitPosition(100, Sizeable.UNITS_PIXELS, hsplitReversed);
hsplit.addSplitterClickListener(
new HorizontalSplitPanel.SplitterClickListener() {
final VerticalSplitPanel vsplit = new VerticalSplitPanel();
vsplit.setSizeFull();
- vsplit.setImmediate(true);
vsplit.setSplitPosition(10, Sizeable.UNITS_PERCENTAGE, vsplitReversed);
vsplit.addSplitterClickListener(new SplitterClickListener() {
@Override
protected void setup() {
CheckBox cb = new CheckBox("Set first column width");
cb.setValue(false);
- cb.setImmediate(true);
cb.addValueChangeListener(event -> {
if (event.getValue()) {
rightTable.setColumnWidth("name", 150);
cb = new CheckBox("Set second column width");
cb.setValue(true);
- cb.setImmediate(true);
cb.addValueChangeListener(event -> {
if (event.getValue()) {
rightTable.setColumnWidth("info", 20);
barTable.setFooterVisible(visible);
bazTable.setFooterVisible(visible);
});
- footers.setImmediate(true);
addComponent(footers);
HorizontalLayout tables = new HorizontalLayout();
fooTable = createTable(null);
@Override
protected void setup() {
editMode = new CheckBox("Edit mode");
- editMode.setImmediate(true);
editMode.addValueChangeListener(
event -> table.setEditable(editMode.getValue()));
useCustomConverters = new CheckBox("Use custom converters");
- useCustomConverters.setImmediate(true);
useCustomConverters.addValueChangeListener(event -> recreateTable());
localeSelect = createLocaleSelect();
}
private static BeanItemContainer<Person> createContainer(int nr) {
- BeanItemContainer<Person> bic = new BeanItemContainer<>(
- Person.class);
+ BeanItemContainer<Person> bic = new BeanItemContainer<>(Person.class);
for (int i = 1; i <= nr; i++) {
Person p = new Person();
p.setFirstName("First " + i);
p.setLastName("Last " + i);
p.setAge(i);
- p.setDeceased((i % 5 - 2) == 0);
+ p.setDeceased(i % 5 - 2 == 0);
p.setEmail("person" + i + "@mail.com");
p.setRent(new BigDecimal(i * 1250.25));
p.setSalary(3000 + i);
- p.setSex((i % 4) == 0 ? Sex.MALE : Sex.FEMALE);
+ p.setSex(i % 4 == 0 ? Sex.MALE : Sex.FEMALE);
p.setBirthDate(new Date(2011 - 1900 - p.getAge(), 11 - 1, 24));
if (i % 42 == 0) {
p.setSex(Sex.UNKNOWN);
}
- String city = "City " + (i / 10);
+ String city = "City " + i / 10;
Country country = Country.FINLAND;
Address address = new Address("Street " + i, 12345 + i * 2, city,
country);
@Override
protected void setup() {
addComponent(useFieldFactory);
- useFieldFactory.setImmediate(true);
useFieldFactory.addValueChangeListener(event -> {
if (useFieldFactory.getValue()) {
table.setTableFieldFactory(new CachingFieldFactory());
private AbsoluteLayout buildMainLayout() {
// common part: create layout
mainLayout = new AbsoluteLayout();
- mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
private VerticalLayout buildVerticalLayout_1() {
// common part: create layout
verticalLayout_1 = new VerticalLayout();
- verticalLayout_1.setImmediate(false);
verticalLayout_1.setWidth("100.0%");
verticalLayout_1.setHeight("100.0%");
verticalLayout_1.setMargin(false);
private HorizontalLayout buildHorizontalLayout_1() {
// common part: create layout
horizontalLayout_1 = new HorizontalLayout();
- horizontalLayout_1.setImmediate(false);
horizontalLayout_1.setWidth("100.0%");
horizontalLayout_1.setHeight("-1px");
horizontalLayout_1.setMargin(false);
// btnRefreshTable
setBtnRefreshTable(new Button());
getBtnRefreshTable().setCaption("Reload table row cache");
- getBtnRefreshTable().setImmediate(false);
getBtnRefreshTable().setWidth("-1px");
getBtnRefreshTable().setHeight("-1px");
horizontalLayout_1.addComponent(getBtnRefreshTable());
options.setSpacing(true);
final CheckBox visible = new CheckBox("Footers Visible", true);
- visible.setImmediate(true);
visible.addValueChangeListener(
event -> table.setFooterVisible(visible.getValue()));
options.addComponent(visible);
final TextField footer1Value = new TextField(null, "Footer1");
- footer1Value.setImmediate(true);
Button footer1Btn = new Button("Change", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
options.addComponent(footer1);
final TextField footer2Value = new TextField(null, "Footer2");
- footer2Value.setImmediate(true);
Button footer2Btn = new Button("Change", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
options.addComponent(footer2);
final TextField footer3Value = new TextField(null, "Footer3");
- footer3Value.setImmediate(true);
Button footer3Btn = new Button("Change", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
});
CheckBox immediateCheckbox = new CheckBox("Immediate");
- immediateCheckbox.setImmediate(true);
immediateCheckbox.setValue(table.isImmediate());
immediateCheckbox.addValueChangeListener(
event -> table.setImmediate(event.getValue()));
CheckBox columnReorderingCheckbox = new CheckBox(
"Column reordering allowed");
- columnReorderingCheckbox.setImmediate(true);
columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
columnReorderingCheckbox.addValueChangeListener(
event -> table.setColumnReorderingAllowed(event.getValue()));
});
CheckBox immediateCheckbox = new CheckBox("Immediate");
- immediateCheckbox.setImmediate(true);
immediateCheckbox.setValue(table.isImmediate());
immediateCheckbox.addValueChangeListener(
event -> table.setImmediate(event.getValue()));
CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
- sortEnabledCheckbox.setImmediate(true);
sortEnabledCheckbox.setValue(table.isSortEnabled());
sortEnabledCheckbox.addValueChangeListener(
event -> table.setSortEnabled(event.getValue()));
CheckBox columnReorderingCheckbox = new CheckBox(
"Column reordering allowed");
- columnReorderingCheckbox.setImmediate(true);
columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
columnReorderingCheckbox.addValueChangeListener(
event -> table.setColumnReorderingAllowed(event.getValue()));
table.setFooterVisible(true);
CheckBox immediateCheckbox = new CheckBox("Immediate");
- immediateCheckbox.setImmediate(true);
immediateCheckbox.setValue(table.isImmediate());
immediateCheckbox.addValueChangeListener(
event -> table.setImmediate(event.getValue()));
CheckBox headerClickListenerCheckbox = new CheckBox(
"Header click listener");
- headerClickListenerCheckbox.setImmediate(true);
headerClickListenerCheckbox.addValueChangeListener(
new HasValue.ValueChangeListener<Boolean>() {
CheckBox footerClickListenerCheckbox = new CheckBox(
"Footer click listener");
- footerClickListenerCheckbox.setImmediate(true);
footerClickListenerCheckbox.addValueChangeListener(
new HasValue.ValueChangeListener<Boolean>() {
footerClickListenerCheckbox.setValue(true);
CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
- sortEnabledCheckbox.setImmediate(true);
sortEnabledCheckbox.setValue(table.isSortEnabled());
sortEnabledCheckbox.addValueChangeListener(
event -> table.setSortEnabled(event.getValue()));
CheckBox columnReorderingCheckbox = new CheckBox(
"Column reordering allowed");
- columnReorderingCheckbox.setImmediate(true);
columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
columnReorderingCheckbox.addValueChangeListener(
event -> table.setColumnReorderingAllowed(event.getValue()));
@Override
protected void setup(VaadinRequest request) {
CheckBox cb = new CheckBox("Item click listener");
- cb.setImmediate(true);
cb.addValueChangeListener(event -> {
if (event.getValue()) {
table.addItemClickListener(HeaderPositionWhenSorting.this);
addComponent(cb);
CheckBox cbActionHandler = new CheckBox("Action handler");
- cbActionHandler.setImmediate(true);
cbActionHandler.addValueChangeListener(event -> {
if (event.getValue()) {
table.addActionHandler(HeaderPositionWhenSorting.this);
CheckBox cbActionHasActions = new CheckBox(
"Action handler has actions");
- cbActionHasActions.setImmediate(true);
cbActionHasActions.addValueChangeListener(event -> {
actionHandlerHasActions = event.getValue();
}
});
- showHeaders.setImmediate(true);
showHeaders.setValue(true);
addComponent(showHeaders);
CheckBox b = new CheckBox("immediate");
b.setValue(c.isImmediate());
b.addValueChangeListener(event -> c.setImmediate(event.getValue()));
- b.setImmediate(true);
layout.addComponent(b);
b = new CheckBox("selectable");
if (c instanceof Table) {
b.addValueChangeListener(
event -> ((Tree) c).setSelectable(event.getValue()));
}
- b.setImmediate(true);
layout.addComponent(b);
b = new CheckBox("nullsel");
b.setValue(c.isNullSelectionAllowed());
b.addValueChangeListener(
event -> c.setNullSelectionAllowed(event.getValue()));
- b.setImmediate(true);
layout.addComponent(b);
b = new CheckBox("multi");
b.setValue(c.isMultiSelect());
b.addValueChangeListener(event -> c.setMultiSelect(event.getValue()));
- b.setImmediate(true);
layout.addComponent(b);
return layout;
}
@Override
public void setup() {
CheckBox cb = new CheckBox("Item click listener");
- cb.setImmediate(true);
cb.addValueChangeListener(event -> {
if (event.getValue()) {
table.addListener(TableAndBrowserContextMenu.this);
addComponent(cb);
CheckBox cbActionHandler = new CheckBox("Action handler");
- cbActionHandler.setImmediate(true);
cbActionHandler.addValueChangeListener(event -> {
if (event.getValue()) {
table.addActionHandler(TableAndBrowserContextMenu.this);
CheckBox cbActionHasActions = new CheckBox(
"Action handler has actions");
- cbActionHasActions.setImmediate(true);
cbActionHasActions.addValueChangeListener(event -> {
actionHandlerHasActions = event.getValue();
}
});
showHeaders.setValue(true);
- showHeaders.setImmediate(true);
mainWindow.addComponent(showHeaders);
mainWindow.addComponent(table);
componentDescription
.addValueChangeListener(event -> table.setContainerDataSource(
createContainer(componentDescription.getValue())));
- componentDescription.setImmediate(true);
componentDescription.setValue(true);
tableCellItemDescription = new CheckBox("Tooltip on table cells");
tableCellItemDescription
.addValueChangeListener(event -> table.refreshRowCache());
- tableCellItemDescription.setImmediate(true);
tableCellItemDescription.setValue(true);
tableRowItemDescription = new CheckBox("Tooltip on table Rows");
tableRowItemDescription
.addValueChangeListener(event -> table.refreshRowCache());
- tableRowItemDescription.setImmediate(true);
tableRowItemDescription.setValue(true);
addComponent(componentDescription);
final Table table = new Table();
final CheckBox chkSelectable = new CheckBox("selectable");
- chkSelectable.setImmediate(true);
chkSelectable.addValueChangeListener(
event -> table.setSelectable(chkSelectable.getValue()));
log.log("Column 1 hidden");
}
});
- cb.setImmediate(true);
visibilities.addComponent(cb);
cb = new CheckBox("Column 2");
log.log("Column 2 hidden");
}
});
- cb.setImmediate(true);
visibilities.addComponent(cb);
cb = new CheckBox("Column 3");
log.log("Column 3 hidden");
}
});
- cb.setImmediate(true);
visibilities.addComponent(cb);
addComponent(log);
@Override
protected void setup() {
- brokenContainer.setImmediate(true);
- brokenGenerator.setImmediate(true);
- clearTableOnError.setImmediate(true);
clearTableOnError.addValueChangeListener(event -> {
Boolean value = clearTableOnError.getValue();
setErrorHandler(value != null ? value : false);
addComponent(table);
final CheckBox multiselect = new CheckBox("Multiselect");
- multiselect.setImmediate(true);
multiselect.setId("multiselect");
multiselect.addValueChangeListener(event -> {
Boolean value = multiselect.getValue();
area2.setCaption("Nonwrapping");
}
});
- onoff.setImmediate(true);
addComponent(onoff);
}
Panel panel = new Panel(fl);
panel.setCaption("Hackers panel");
CheckBox ml = new CheckBox("Multiline");
- ml.setImmediate(true);
// FIXME re-add this when TextArea has been replaced with vaadin8
// version
// ml.addListener(new Property.ValueChangeListener() {
addComponent(field0);
final CheckBox readonly = new CheckBox("Readonly");
- readonly.setImmediate(true);
readonly.addValueChangeListener(event -> {
boolean newReadonly = event.getValue();
field1.setReadOnly(newReadonly);
TextField tf2 = new TextField("TextField 2",
"Has focus, blur and valuechange listeners");
tf2.setWidth("300px");
- tf2.addValueChangeListener(l -> this.valueChange(tf2));
+ tf2.addValueChangeListener(l -> valueChange(tf2));
tf2.addFocusListener(this);
tf2.addBlurListener(this);
TextField tf3 = new TextField("TextField 3",
"Has non-immediate valuechange listener");
tf3.setWidth("300px");
- tf3.addValueChangeListener(l -> this.valueChange(tf3));
+ tf3.addValueChangeListener(l -> valueChange(tf3));
addComponent(tf3);
TextField tf4 = new TextField("TextField 4",
"Has immediate valuechange listener");
tf4.setWidth("300px");
- tf4.setImmediate(true);
- tf4.addValueChangeListener(l -> this.valueChange(tf4));
+ tf4.addValueChangeListener(l -> valueChange(tf4));
addComponent(tf4);
}
button.setClickShortcut(KeyCode.ESCAPE);
final CheckBox inputPromptSelection = new CheckBox("Input prompt");
- inputPromptSelection.setImmediate(true);
inputPromptSelection.addValueChangeListener(event -> {
if (event.getValue()) {
textField.setInputPrompt("Input prompt");
}
log.log("Set input prompt: " + textField.getInputPrompt());
});
- inputPromptSelection.setImmediate(true);
addComponent(textField);
addComponent(button);
protected void setup() {
CheckBox cb = new CheckBox("Connectors");
cb.setValue(false);
- cb.setImmediate(true);
cb.addValueChangeListener(event -> {
if (event.getValue()) {
tree.addStyleName(BaseTheme.TREE_CONNECTORS);
final CheckBox filterType = new CheckBox(
"Include parent when filtering", true);
- filterType.setImmediate(true);
filterType.addValueChangeListener(event -> {
cont.setIncludeParentsWhenFiltering(event.getValue());
ccTree.markAsDirty();
final IdTestLabel idTestLabelWithId = new IdTestLabel("set id");
idTestLabelWithId.setSizeUndefined();
idTestLabelWithId.setId("set10179");
- idTestLabelWithId.setImmediate(true);
addComponent(idTestLabelWithId);
final Label label = new Label("no id");
}
});
button.setId("toggle");
- button.setImmediate(true);
addComponent(button);
}
+++ /dev/null
-package com.vaadin.tests.components.window;
-
-import com.vaadin.server.Page.BrowserWindowResizeEvent;
-import com.vaadin.server.Page.BrowserWindowResizeListener;
-import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.tests.util.LoremIpsum;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.LegacyWindow;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.ResizeEvent;
-import com.vaadin.ui.Window.ResizeListener;
-
-public class LazyWindowResize extends AbstractTestCase {
-
- private LegacyWindow mainWindow;
- private Window subWindow;
- private CheckBox lazyMode;
- private Log log = new Log(5);
- private CheckBox resizeListenerCheckBox;
-
- protected ResizeListener resizeListener = new ResizeListener() {
-
- @Override
- public void windowResized(ResizeEvent e) {
- log.log("Sub window resized");
- }
- };
-
- protected BrowserWindowResizeListener browserWindowResizeListener = new BrowserWindowResizeListener() {
- @Override
- public void browserWindowResized(BrowserWindowResizeEvent event) {
- log.log("Main window resized");
- }
- };
-
- private CheckBox immediateCheckBox;
-
- @Override
- protected String getDescription() {
- return "Check or uncheck the checkbox to use lazy or eager resize events. Lazy mode uses a small delay before recalculating layout sizes and can be used to speed up resizes in slow UIs.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6715;
- }
-
- @Override
- public void init() {
- mainWindow = new LegacyWindow("Resize test");
- setMainWindow(mainWindow);
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- subWindow = new Window("Sub window", layout);
- subWindow.setHeight("50%");
- subWindow.setWidth("50%");
- subWindow.center();
- layout.addComponent(new Label(LoremIpsum.get(1000)));
- getMainWindow().addWindow(subWindow);
-
- lazyMode = new CheckBox("Lazy resize");
- lazyMode.setImmediate(true);
- lazyMode.addValueChangeListener(event -> setLazy(lazyMode.getValue()));
-
- resizeListenerCheckBox = new CheckBox("Resize listener");
- resizeListenerCheckBox.setImmediate(true);
- resizeListenerCheckBox.addValueChangeListener(event -> {
- if (resizeListenerCheckBox.getValue()) {
- subWindow.addResizeListener(resizeListener);
- mainWindow.addListener(browserWindowResizeListener);
- } else {
- subWindow.removeResizeListener(resizeListener);
- mainWindow.removeListener(browserWindowResizeListener);
- }
- });
- immediateCheckBox = new CheckBox("Windows immediate");
- immediateCheckBox.setImmediate(true);
- immediateCheckBox.addValueChangeListener(event -> {
- mainWindow.setImmediate(immediateCheckBox.getValue());
- subWindow.setImmediate(immediateCheckBox.getValue());
- });
- mainWindow.addComponent(lazyMode);
- mainWindow.addComponent(resizeListenerCheckBox);
- mainWindow.addComponent(immediateCheckBox);
- mainWindow.addComponent(log);
- mainWindow.addComponent(new Label("<br/><br/>", ContentMode.HTML));
- mainWindow.addComponent(new Label(LoremIpsum.get(10000)));
-
- setLazy(false);
- }
-
- private void setLazy(boolean b) {
- mainWindow.setResizeLazy(b);
- subWindow.setResizeLazy(b);
- }
-
-}
+++ /dev/null
-package com.vaadin.tests.components.window;
-
-import com.vaadin.server.Page;
-import com.vaadin.server.Page.BrowserWindowResizeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class WindowResizeListener extends TestBase {
-
- @Override
- protected String getDescription() {
- return "Size changes from windows (both sub "
- + "and browsers level) should get back to server."
- + " If size changes, a separate server side event should occur.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
- Window subwin = new ResizeListenerWindow();
-
- @Override
- protected void setup() {
-
- final Label l = new Label();
- getLayout().addComponent(l);
-
- getMainWindow().addListener(new Page.BrowserWindowResizeListener() {
- @Override
- public void browserWindowResized(BrowserWindowResizeEvent event) {
- l.setValue("Current browser window size: "
- + getMainWindow().getBrowserWindowWidth() + " x "
- + getMainWindow().getBrowserWindowHeight());
- }
- });
-
- CheckBox subwindow = new CheckBox("show subwindow");
- subwindow.setImmediate(true);
- subwindow.addValueChangeListener(event -> {
- if (event.getValue()) {
- getMainWindow().addWindow(subwin);
- } else {
- getMainWindow().removeWindow(subwin);
- }
- });
- getLayout().addComponent(subwindow);
-
- CheckBox immediate = new CheckBox("immediate");
- immediate.addValueChangeListener(event -> {
- boolean booleanValue = event.getValue();
- getMainWindow().setImmediate(booleanValue);
- subwin.setImmediate(booleanValue);
- });
- immediate.setImmediate(true);
- immediate.setValue(true);
- getMainWindow().setImmediate(true);
- subwin.setImmediate(true);
- getLayout().addComponent(immediate);
-
- getLayout().addComponent(new Button("Sync"));
-
- }
-}
-
-class ResizeListenerWindow extends Window {
- Label sizeLabel = new Label();
-
- public ResizeListenerWindow() {
- super("Subwindow", new VerticalLayout());
- setWidth("400px");
-
- VerticalLayout hl = (VerticalLayout) getContent();
- hl.setMargin(true);
- hl.addComponent(new Label("Current size: "));
- hl.addComponent(sizeLabel);
-
- addResizeListener(new ResizeListener() {
- @Override
- public void windowResized(ResizeEvent e) {
- updateLabel();
- }
- });
-
- updateLabel();
- }
-
- public void updateLabel() {
- sizeLabel.setValue(getWidth() + getWidthUnits().getSymbol() + " x "
- + getHeight() + getHeightUnits().getSymbol());
- }
-}
filterString.getValue().toString(), false, false);
}
});
- cb.setImmediate(true);
vl.addComponent(cb);
nextLabel = new Label();
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemButton.setImmediate(true);
vl.addComponent(addItemButton);
final Button addItemAfterButton = new Button("addItemAfter()",
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemAfterButton.setImmediate(true);
vl.addComponent(addItemAfterButton);
position = new TextField("Position:", "0");
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemAtButton.setImmediate(true);
vl.addComponent(addItemAtButton);
getLayout().addComponent(table);
filterString.getValue().toString(), false, false);
}
});
- cb.setImmediate(true);
vl.addComponent(cb);
nextLabel = new Label();
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemButton.setImmediate(true);
vl.addComponent(addItemButton);
final Button addItemAfterButton = new Button("addItemAfter()",
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemAfterButton.setImmediate(true);
vl.addComponent(addItemAfterButton);
position = new TextField("Position:", "0");
nextLabel.setCaption("Next id: " + nextToAdd);
}
});
- addItemAtButton.setImmediate(true);
vl.addComponent(addItemAtButton);
getLayout().addComponent(table);
final Tree tree = new Tree("Inventory");
CheckBox checkBox = new CheckBox("Enabled");
- checkBox.setImmediate(true);
checkBox.setValue(true);
checkBox.addValueChangeListener(
event -> tree.setEnabled(!tree.isEnabled()));
addComponent(checkBox);
checkBox = new CheckBox("Drag start");
- checkBox.setImmediate(true);
checkBox.setValue(true);
checkBox.addValueChangeListener(event -> {
if (event.getValue()) {
if (sourceItemId instanceof BeanItem<?>) {
beanItem = (BeanItem<?>) sourceItemId;
} else if (sourceItemId instanceof InventoryObject) {
- beanItem = new BeanItem<>(
- (InventoryObject) sourceItemId);
+ beanItem = new BeanItem<>((InventoryObject) sourceItemId);
}
// Remove the item from the source container and
LegacyWindow mainWindow = getMainWindow();
mainWindow.setSizeUndefined();
mainWindow.getContent().setSizeUndefined();
- mainWindow.setImmediate(true);
CheckBox lazyCheckBox = new CheckBox("Lazy resize");
lazyCheckBox.addValueChangeListener(event -> {
log.log("Resize lazy: " + resizeLazy);
});
lazyCheckBox.setValue(Boolean.FALSE);
- lazyCheckBox.setImmediate(true);
addComponent(lazyCheckBox);
addComponent(log);
private Component toggleRequired() {
CheckBox requiredToggle = new CheckBox();
- requiredToggle.setImmediate(true);
requiredToggle.setCaption("Required");
requiredToggle
.addValueChangeListener(event -> setRequired(event.getValue()));
private Component toggleIcon() {
CheckBox iconToggle = new CheckBox();
- iconToggle.setImmediate(true);
iconToggle.setCaption("Icons");
iconToggle.addValueChangeListener(event -> setIcon(event.getValue()));
return iconToggle;
private Component toggleError() {
CheckBox errorToggle = new CheckBox();
- errorToggle.setImmediate(true);
errorToggle.setCaption("Error");
errorToggle.addValueChangeListener(event -> setError(event.getValue()));
return errorToggle;
private Component toggleRequired() {
CheckBox requiredToggle = new CheckBox();
- requiredToggle.setImmediate(true);
requiredToggle.setCaption("Required");
requiredToggle
.addValueChangeListener(event -> setRequired(event.getValue()));
private Component toggleIcon() {
CheckBox iconToggle = new CheckBox();
- iconToggle.setImmediate(true);
iconToggle.setCaption("Icons");
iconToggle.addValueChangeListener(event -> setIcon(event.getValue()));
return iconToggle;
private Component toggleReadOnly() {
CheckBox readOnlyToggle = new CheckBox();
- readOnlyToggle.setImmediate(true);
readOnlyToggle.setCaption("Read only");
readOnlyToggle
.addValueChangeListener(event -> setReadOnly(event.getValue()));
private Component toggleEnabled() {
CheckBox enabledToggle = new CheckBox();
- enabledToggle.setImmediate(true);
enabledToggle.setValue(true);
enabledToggle.setCaption("Enabled");
enabledToggle
private Component toggleInvalid() {
CheckBox invalid = new CheckBox("Invalid");
- invalid.setImmediate(true);
invalid.addValueChangeListener(event -> setInvalid(event.getValue()));
return invalid;
private Component toggleError() {
CheckBox errorToggle = new CheckBox();
- errorToggle.setImmediate(true);
errorToggle.setCaption("Error");
errorToggle.addValueChangeListener(event -> setError(event.getValue()));
return errorToggle;
private Component createMarginsToggle() {
final CheckBox cb = new CheckBox("Margins");
- cb.setImmediate(true);
cb.addValueChangeListener(
event -> ((MarginHandler) layout).setMargin(cb.getValue()));
messages.setRequired(true);
messages.setCaption("Messages visible");
});
- control.setImmediate(true);
formLayout.addComponent(control);
messages = new TextArea("Messages hidden");
Styles styles = Page.getCurrent().getStyles();
// inject the new color as a style
- styles.add(".v-app .v-textarea.text-label { color:"
- + color.getCSS() + "; }");
+ styles.add(".v-app .v-textarea.text-label { color:" + color.getCSS()
+ + "; }");
});
return textColor;
* Creates a font family selection dialog
*/
private Component createFontSelect() {
- final ComboBox<String> select = new ComboBox<>(null, Arrays.asList(
- "Arial", "Helvetica", "Verdana", "Courier", "Times",
- "sans-serif"));
+ final ComboBox<String> select = new ComboBox<>(null,
+ Arrays.asList("Arial", "Helvetica", "Verdana", "Courier",
+ "Times", "sans-serif"));
select.setValue("Arial");
select.setWidth("200px");
select.setPlaceholder("Font");
select.setDescription("Font");
- select.setImmediate(true);
select.setEmptySelectionAllowed(false);
select.addValueChangeListener(event -> {
// Get the new font family
select.setValue(12);
select.setPlaceholder("Font size");
select.setDescription("Font size");
- select.setImmediate(true);
select.setEmptySelectionAllowed(false);
select.addValueChangeListener(event -> {
// Get the new font size
@Override
protected void setup(VaadinRequest request) {
PasswordField passwordField = new PasswordField("Enter password");
- passwordField.setImmediate(true);
CapsLockWarningWithRpc capsLockWarningWithRpc = new CapsLockWarningWithRpc();
capsLockWarningWithRpc.extend(passwordField);
CheckBox pushSetting = new CheckBox("Push enabled");
pushSetting.setValue(Boolean
.valueOf(getPushConfiguration().getPushMode().isEnabled()));
- pushSetting.setImmediate(true);
pushSetting.addValueChangeListener(event -> {
if (event.getValue()) {
getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
}
});
themeToggle.setStyleName("small");
- themeToggle.setImmediate(true);
styleToggle = new CheckBox("Black style");
styleToggle.addValueChangeListener(event -> {
main.getContent().setStyleName("");
}
});
- styleToggle.setImmediate(true);
styleToggle.setStyleName("small");
iconToggle = new CheckBox("64x icons");
largeIcons = !largeIcons;
recreateAll();
});
- iconToggle.setImmediate(true);
iconToggle.setStyleName("small");
nativeToggle = new CheckBox("Native buttons");
nativeButtons = !nativeButtons;
recreateAll();
});
- nativeToggle.setImmediate(true);
nativeToggle.setStyleName("small");
toggles.setSpacing(true);
private void initHideWeekEndButton() {
hideWeekendsButton = new CheckBox("Hide weekends");
- hideWeekendsButton.setImmediate(true);
hideWeekendsButton.addValueChangeListener(
event -> setWeekendsHidden(hideWeekendsButton.getValue()));
}
private void initReadOnlyButton() {
readOnlyButton = new CheckBox("Read-only mode");
- readOnlyButton.setImmediate(true);
readOnlyButton.addValueChangeListener(event -> calendarComponent
.setReadOnly(readOnlyButton.getValue()));
}
private void initDisabledButton() {
disabledButton = new CheckBox("Disabled");
- disabledButton.setImmediate(true);
disabledButton.addValueChangeListener(event -> calendarComponent
.setEnabled(!disabledButton.getValue()));
}
private CheckBox createCheckBox(String caption) {
CheckBox cb = new CheckBox(caption);
- cb.setImmediate(true);
return cb;
}
addComponent(wrap);
final CheckBox closable = new CheckBox("Closable");
- closable.setImmediate(true);
wrap.addComponent(closable);
final CheckBox overflow = new CheckBox("Overflow");
- overflow.setImmediate(true);
wrap.addComponent(overflow);
final CheckBox caption = new CheckBox("Captions", true);
- caption.setImmediate(true);
wrap.addComponent(caption);
final CheckBox icon = new CheckBox("Icons");
- icon.setImmediate(true);
wrap.addComponent(icon);
final CheckBox disable = new CheckBox("Disable tabs");
- disable.setImmediate(true);
wrap.addComponent(disable);
Label h3 = new Label("Additional Styles");
addComponent(wrap);
final CheckBox framed = new CheckBox("Framed", true);
- framed.setImmediate(true);
wrap.addComponent(framed);
final CheckBox centered = new CheckBox("Centered tabs");
- centered.setImmediate(true);
wrap.addComponent(centered);
final CheckBox rightAlign = new CheckBox("Right-aligned tabs");
- rightAlign.setImmediate(true);
wrap.addComponent(rightAlign);
final CheckBox equal = new CheckBox("Equal-width tabs");
- equal.setImmediate(true);
wrap.addComponent(equal);
final CheckBox padded = new CheckBox("Padded tabbar");
- padded.setImmediate(true);
wrap.addComponent(padded);
final CheckBox compact = new CheckBox("Compact");
- compact.setImmediate(true);
wrap.addComponent(compact);
final CheckBox iconsOnTop = new CheckBox("Icons on top");
- iconsOnTop.setImmediate(true);
wrap.addComponent(iconsOnTop);
final CheckBox selectedOnly = new CheckBox("Selected tab closable");
- selectedOnly.setImmediate(true);
wrap.addComponent(selectedOnly);
HasValue.ValueChangeListener<Boolean> update = event -> {
@Override
protected void setup(VaadinRequest request) {
requiredInput = new CheckBox("Field required");
- requiredInput.setImmediate(true);
requiredInput.addValueChangeListener(
event -> tf.setRequired(requiredInput.getValue()));
});
integerValidatorInput = new CheckBox("Integer validator");
- integerValidatorInput.setImmediate(true);
integerValidatorInput.addValueChangeListener(event -> {
if (integerValidatorInput.getValue()) {
tf.addValidator(integerValidator);
}
});
stringLengthValidatorInput = new CheckBox("String length validator");
- stringLengthValidatorInput.setImmediate(true);
stringLengthValidatorInput.addValueChangeListener(event -> {
if (stringLengthValidatorInput.getValue()) {
tf.addValidator(stringLengthValidator);
import com.google.gwt.user.client.ui.HasWidgets;
import com.vaadin.client.data.DataChangeHandler;
import com.vaadin.client.data.DataSource;
-import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.Connect;
import com.vaadin.tests.widgetset.server.v7.grid.GridClientColumnRenderers;
import com.vaadin.v7.client.renderers.Renderer;
import com.vaadin.v7.client.renderers.TextRenderer;
import com.vaadin.v7.client.renderers.WidgetRenderer;
+import com.vaadin.v7.client.ui.AbstractLegacyComponentConnector;
import com.vaadin.v7.client.widget.grid.CellReference;
import com.vaadin.v7.client.widget.grid.RendererCellReference;
import com.vaadin.v7.client.widget.grid.datasources.ListDataSource;
@Connect(GridClientColumnRenderers.GridController.class)
public class GridClientColumnRendererConnector
- extends AbstractComponentConnector {
+ extends AbstractLegacyComponentConnector {
public static enum Renderers {
TEXT_RENDERER, WIDGET_RENDERER, HTML_RENDERER, NUMBER_RENDERER, DATE_RENDERER, CPLX_RENDERER;
grid.setSelectionMode(Grid.SelectionMode.SINGLE);
grid.setEditorEnabled(true);
- grid.setImmediate(true);
getLayout().addComponent(grid);
getLayout().setExpandRatio(grid, 1);
layout.addComponent(checkbox);
numberTextField = new TextField("Row");
- numberTextField.setImmediate(true);
layout.addComponent(numberTextField);
layout.addComponent(
grid = new Grid(container);
grid.setWidth("100%");
- grid.setImmediate(true);
grid.setSelectionMode(SelectionMode.SINGLE);
grid.addSelectionListener(new SelectionListener() {
@Override
+++ /dev/null
-/*
- * Copyright 2000-2016 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.application;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-public class ResynchronizeAfterAsyncRemovalTest extends SingleBrowserTest {
- @Test
- public void noResyncAfterAsyncRemoval() {
- openTestURL();
-
- $(ButtonElement.class).first().click();
-
- Assert.assertEquals("Timing issue in the test?",
- "1. Window removed: true", getLogRow(1));
-
- Assert.assertEquals(
- "Removing window should not cause button to be marked as dirty",
- "2. Dirty: false", getLogRow(0));
-
- ButtonElement logCountButton = $(ButtonElement.class).all().get(1);
- logCountButton.click();
-
- Assert.assertEquals("Sanity check", "3. syncId: 2", getLogRow(1));
- Assert.assertEquals("Sanity check",
- "4. Unregistered connector count: 1", getLogRow(0));
-
- logCountButton.click();
-
- Assert.assertEquals("Sanity check", "5. syncId: 3", getLogRow(1));
- Assert.assertEquals(
- "Unregistered connector map should have been cleared",
- "6. Unregistered connector count: 0", getLogRow(0));
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2016 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;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class OutOfSyncTest extends MultiBrowserTest {
-
- @Test
- public void testClientResync() throws InterruptedException {
- openTestURL();
-
- // Wait for server to get rid of the Button
- sleep(1000);
-
- // On the first round-trip after the component has been removed, the
- // server assumes the client will remove the button. How ever (to force
- // it to be out of sync) the test UI calls markClean() on the Button to
- // make it not update with the response.
- $(ButtonElement.class).first().click();
- Assert.assertTrue(
- "Button should not have disappeared on the first click.",
- $(ButtonElement.class).exists());
-
- // Truly out of sync, full resync is forced.
- $(ButtonElement.class).first().click();
- Assert.assertFalse("Button should disappear with the second click.",
- $(ButtonElement.class).exists());
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2016 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.checkbox;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.elements.CheckBoxElement;
-import com.vaadin.testbench.elements.LabelElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class CheckBoxImmediateTest extends MultiBrowserTest {
-
- @Test
- public void testNonImmediateCheckBox() {
- openTestURL();
-
- CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first();
- WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
- final WebElement countElem = $(LabelElement.class).id("count");
-
- inputElem.click();
- assertEquals("Events received: 0", countElem.getText());
- }
-
- @Test
- public void testImmediateCheckBox() {
- openTestURL();
-
- CheckBoxElement checkBoxElement = $(CheckBoxElement.class).get(1);
- WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
- final WebElement countElem = $(LabelElement.class).id("count");
-
- inputElem.click();
- assertEquals("Events received: 1", countElem.getText());
- }
-}