From 6624c7fedf44b1097eb09f78d016ba471aa3dc12 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 12 Feb 2013 09:15:21 +0200 Subject: Added support for Dates to DefaultFieldGroupFieldFactory (#8539) Change-Id: I61b45b4bb988878d86a913d383764ce7c17c3bf9 --- .../src/com/vaadin/tests/fieldgroup/DateForm.html | 42 ++++++ .../src/com/vaadin/tests/fieldgroup/DateForm.java | 150 +++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/fieldgroup/DateForm.html create mode 100644 uitest/src/com/vaadin/tests/fieldgroup/DateForm.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/fieldgroup/DateForm.html b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.html new file mode 100644 index 0000000000..f141091805 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.html @@ -0,0 +1,42 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.fieldgroup.DateForm?restartApplication
assertValuevaadin=runcomvaadintestsfieldgroupDateForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VPopupCalendar[0]#field1/20/84
assertValuevaadin=runcomvaadintestsfieldgroupDateForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VPopupCalendar[0]#field1/20/84
assertCSSClassvaadin=runcomvaadintestsfieldgroupDateForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day20v-inline-datefield-calendarpanel-day-selected
assertValuevaadin=runcomvaadintestsfieldgroupDateForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VTextField[0]Jan 20, 1984 4:34:49 PM
+ + diff --git a/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java new file mode 100644 index 0000000000..0d906a086b --- /dev/null +++ b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java @@ -0,0 +1,150 @@ +package com.vaadin.tests.fieldgroup; + +import java.util.Date; + +import com.vaadin.data.fieldgroup.BeanFieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +import com.vaadin.data.fieldgroup.PropertyId; +import com.vaadin.data.util.BeanItem; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.DateField; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.Notification; +import com.vaadin.ui.PopupDateField; +import com.vaadin.ui.TextField; + +public class DateForm extends TestBase { + + private Log log = new Log(5); + @PropertyId("date1") + private DateField dateField; + @PropertyId("date2") + private PopupDateField popupDateField; + @PropertyId("date3") + private InlineDateField inlineDateField; + @PropertyId("date4") + private TextField textField; + + public static class DateObject { + private Date date1, date2, date3, date4; + + public DateObject(Date date1, Date date2, Date date3, Date date4) { + super(); + this.date1 = date1; + this.date2 = date2; + this.date3 = date3; + this.date4 = date4; + } + + public Date getDate1() { + return date1; + } + + public void setDate1(Date date1) { + this.date1 = date1; + } + + public Date getDate2() { + return date2; + } + + public void setDate2(Date date2) { + this.date2 = date2; + } + + public Date getDate3() { + return date3; + } + + public void setDate3(Date date3) { + this.date3 = date3; + } + + public Date getDate4() { + return date4; + } + + public void setDate4(Date date4) { + this.date4 = date4; + } + + } + + @Override + protected void setup() { + addComponent(log); + final FieldGroup fieldGroup = new BeanFieldGroup( + DateObject.class); + fieldGroup.setBuffered(true); + + fieldGroup.buildAndBindMemberFields(this); + textField.setWidth("20em"); + addComponent(dateField); + addComponent(popupDateField); + addComponent(inlineDateField); + addComponent(textField); + + Button commitButton = new Button("Commit", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + String msg = "Commit succesful"; + try { + fieldGroup.commit(); + } catch (CommitException e) { + msg = "Commit failed: " + e.getMessage(); + } + Notification.show(msg); + log.log(msg); + + } + }); + Button discardButton = new Button("Discard", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + fieldGroup.discard(); + log.log("Discarded changes"); + + } + }); + Button showBean = new Button("Show bean values", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log(getPerson(fieldGroup).toString()); + + } + }); + addComponent(commitButton); + addComponent(discardButton); + addComponent(showBean); + + DateObject d = new DateObject(new Date(443457289789L), new Date( + 443457289789L), new Date(443457289789L), + new Date(443457289789L)); + fieldGroup.setItemDataSource(new BeanItem(d)); + } + + public static Person getPerson(FieldGroup binder) { + return ((BeanItem) binder.getItemDataSource()).getBean(); + } + + @Override + protected String getDescription() { + return "Ensure FieldGroupFieldFactory supports Dates"; + } + + @Override + protected Integer getTicketNumber() { + return 8539; + } + +} -- cgit v1.2.3 From 7df9f960992cc9acfd4bbb1aa9a84af1205cd6ec Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 18 Jan 2013 10:45:01 +0200 Subject: Added tutorial examples for creating a simple login view #10076 Change-Id: I4cce618a6937cd1c0f3fc57e742666fb4749fa5a --- .../minitutorials/v70/SimpleLoginMainView.java | 42 +++++++ .../tests/minitutorials/v70/SimpleLoginUI.java | 64 ++++++++++ .../tests/minitutorials/v70/SimpleLoginView.java | 137 +++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginMainView.java create mode 100644 uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java create mode 100644 uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginMainView.java b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginMainView.java new file mode 100644 index 0000000000..cb59aa1608 --- /dev/null +++ b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginMainView.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.minitutorials.v70; + +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.Label; + +public class SimpleLoginMainView extends CustomComponent implements View { + + public static final String NAME = ""; + + Label text = new Label(); + + Button logout = new Button("Logout", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + + // "Logout" the user + getSession().setAttribute("user", null); + + // Refresh this view, should redirect to login view + getUI().getNavigator().navigateTo(NAME); + } + }); + + public SimpleLoginMainView() { + setCompositionRoot(new CssLayout(text, logout)); + } + + @Override + public void enter(ViewChangeEvent event) { + // Get the user name from the session + String username = String.valueOf(getSession().getAttribute("user")); + + // And show the username + text.setValue("Hello " + username); + } +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java new file mode 100644 index 0000000000..2fbbff10a8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java @@ -0,0 +1,64 @@ +package com.vaadin.tests.minitutorials.v70; + +import com.vaadin.navigator.Navigator; +import com.vaadin.navigator.ViewChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.UI; + +public class SimpleLoginUI extends UI { + + @Override + protected void init(VaadinRequest request) { + + /* + * Create a new instance of the navigator. The navigator will attach + * itself automatically to this view. + */ + new Navigator(this, this); + + /* + * The initial log view where the user can login to the application + */ + getNavigator().addView(SimpleLoginView.NAME, SimpleLoginView.class); + + /* + * Add the main view of the application + */ + getNavigator().addView(SimpleLoginMainView.NAME, + SimpleLoginMainView.class); + + /* + * We use a view change handler to ensure the user is always redirected + * to the login view if the user is not logged in. + */ + getNavigator().addViewChangeListener(new ViewChangeListener() { + + @Override + public boolean beforeViewChange(ViewChangeEvent event) { + + // Check if a user has logged in + boolean isLoggedIn = getSession().getAttribute("user") != null; + boolean isLoginView = event.getNewView() instanceof SimpleLoginView; + + if (!isLoggedIn && !isLoginView) { + // Redirect to login view always if a user has not yet + // logged in + getNavigator().navigateTo(SimpleLoginView.NAME); + return false; + + } else if (isLoggedIn && isLoginView) { + // If someone tries to access to login view while logged in, + // then cancel + return false; + } + + return true; + } + + @Override + public void afterViewChange(ViewChangeEvent event) { + + } + }); + } +} diff --git a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java new file mode 100644 index 0000000000..88a2a8f678 --- /dev/null +++ b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java @@ -0,0 +1,137 @@ +package com.vaadin.tests.minitutorials.v70; + +import com.vaadin.data.validator.AbstractValidator; +import com.vaadin.data.validator.EmailValidator; +import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.themes.Reindeer; + +public class SimpleLoginView extends CustomComponent implements View, + Button.ClickListener { + + public static final String NAME = "login"; + + private final TextField user; + + private final PasswordField password; + + private final Button loginButton; + + public SimpleLoginView() { + setSizeFull(); + + // Create the user input field + user = new TextField("User:"); + user.setWidth("300px"); + user.setRequired(true); + user.setInputPrompt("Your username (eg. joe@email.com)"); + user.addValidator(new EmailValidator("Username must be an email address")); + user.setInvalidAllowed(false); + + // Create the password input field + password = new PasswordField("Password:"); + password.setWidth("300px"); + password.addValidator(new PasswordValidator()); + password.setRequired(true); + password.setValue(""); + password.setNullRepresentation(""); + + // Create login button + loginButton = new Button("Login", this); + + // Add both to a panel + VerticalLayout fields = new VerticalLayout(user, password, loginButton); + fields.setCaption("Please login to access the application. (test@test.com/passw0rd)"); + fields.setSpacing(true); + fields.setMargin(new MarginInfo(true, true, true, false)); + fields.setSizeUndefined(); + + // The view root layout + VerticalLayout viewLayout = new VerticalLayout(fields); + viewLayout.setSizeFull(); + viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); + viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); + setCompositionRoot(viewLayout); + } + + @Override + public void enter(ViewChangeEvent event) { + // focus the username field when user arrives to the login view + user.focus(); + } + + /* + * Validator for validating the passwords + */ + private static final class PasswordValidator extends + AbstractValidator { + + public PasswordValidator() { + super("The password provided is not valid"); + } + + @Override + protected boolean isValidValue(String value) { + /* + * Password must be at least 8 characters long and contain at least + * one number + */ + if (value != null + && (value.length() < 8 || !value.matches(".*\\d.*"))) { + return false; + } + return true; + } + + @Override + public Class getType() { + return String.class; + } + } + + @Override + public void buttonClick(ClickEvent event) { + + /* + * Validate the fields using the navigator. By using validors for the + * fields we reduce the amount of queries we have to use to the database + * for wrongly entered passwords + */ + if (!user.isValid() || !password.isValid()) { + return; + } + + String username = user.getValue(); + String password = this.password.getValue(); + + /* + * Validate username and password with database here. For examples sake + * I use a dummy username and password. + */ + boolean isValid = username.equals("test@test.com") + && password.equals("passw0rd"); + + if(isValid){ + // Store the current user in the service session + getSession().setAttribute("user", username); + + // Navigate to main view + getUI().getNavigator().navigateTo(SimpleLoginMainView.NAME); + + } else { + + // Wrong password clear the password field and refocuses it + this.password.setValue(null); + this.password.focus(); + } + } +} + -- cgit v1.2.3 From c5af559686ab3984d43c59a8d6289b99229961e1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sun, 24 Feb 2013 18:20:37 +0200 Subject: Automatically listen to shutdown port and not not enforce -ea (#9998) Relaxed requirement to enable assertions with DevelopmentServerLauncher to make it easier to get started. Changed default to automatically listen to shutdown port 8889. Can be turned of by specifying port -1. Change-Id: Id088b97fb9e8b5e7d9aa3cef874a8d2c02a6ca58 --- uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java index 381091206a..444a70348c 100644 --- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -58,9 +58,11 @@ public class DevelopmentServerLauncher { // Pass-through of arguments for Jetty final Map serverArgs = parseArguments(args); + if (!serverArgs.containsKey("shutdownPort")) + serverArgs.put("shutdownPort", "8889"); - if (serverArgs.containsKey("shutdownPort")) { - int port = Integer.parseInt(serverArgs.get("shutdownPort")); + int port = Integer.parseInt(serverArgs.get("shutdownPort")); + if (port > 0) { try { // Try to notify another instance that it's time to close Socket socket = new Socket((String) null, port); @@ -94,7 +96,7 @@ public class DevelopmentServerLauncher { try { assert false; - throw new RuntimeException("You should run " + System.err.println("You should run " + DevelopmentServerLauncher.class.getSimpleName() + " with assertions enabled. Add -ea as a VM argument."); } catch (AssertionError e) { -- cgit v1.2.3 From b5c6f6cc0c75fa2849ad14dd395af69698440257 Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Tue, 5 Mar 2013 10:48:11 +0200 Subject: WAI-ARIA for form fields (#11180) Changes in the base classes of the form fields for WAI-ARIA integration Change-Id: I770082c353b1b0004875675e28f03d6a3e69f03f --- client/src/com/vaadin/client/ui/AriaHelper.java | 95 ++++++ .../com/vaadin/client/ui/HandlesAriaCaption.java | 20 ++ .../AbstractOrderedLayoutConnector.java | 7 + .../com/vaadin/client/ui/orderedlayout/Slot.java | 7 +- .../tests/layouts/CaptionsInLayoutsWaiAria.java | 354 +++++++++++++++++++++ 5 files changed, 482 insertions(+), 1 deletion(-) create mode 100644 client/src/com/vaadin/client/ui/AriaHelper.java create mode 100644 client/src/com/vaadin/client/ui/HandlesAriaCaption.java create mode 100644 uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/AriaHelper.java b/client/src/com/vaadin/client/ui/AriaHelper.java new file mode 100644 index 0000000000..e762ba57ce --- /dev/null +++ b/client/src/com/vaadin/client/ui/AriaHelper.java @@ -0,0 +1,95 @@ +package com.vaadin.client.ui; + +import com.google.gwt.aria.client.Id; +import com.google.gwt.aria.client.InvalidValue; +import com.google.gwt.aria.client.Roles; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.Widget; + +/** + * Helper class that helps to implement the WAI-ARIA functionality. + */ +public class AriaHelper { + + /** + * Binds a caption (label in HTML speak) to the form element as required by + * WAI-ARIA specification. + * + * @param widget + * Element, that should be bound to the caption + * @param captionElement + * Element of the caption + */ + public static void bindCaption(Widget widget, Element captionElement) { + assert widget != null : "Valid Widget required"; + + ensureUniqueId(captionElement); + + if (widget instanceof HandlesAriaCaption) { + ((HandlesAriaCaption) widget).handleAriaCaption(captionElement); + } else if (captionElement != null) { + String ownerId = ensureUniqueId(widget.getElement()); + captionElement.setAttribute("for", ownerId); + + Roles.getTextboxRole().setAriaLabelledbyProperty( + widget.getElement(), Id.of(captionElement)); + } else { + Roles.getTextboxRole().removeAriaLabelledbyProperty( + widget.getElement()); + } + } + + /** + * Handles the required actions depending of the input element being + * required or not. + * + * @param inputElement + * Element, typically an input element + * @param required + * boolean, true when the element is required + */ + public static void handleInputRequired(Element inputElement, + boolean required) { + if (required) { + Roles.getTextboxRole().setAriaRequiredProperty(inputElement, true); + } else { + Roles.getTextboxRole().removeAriaRequiredProperty(inputElement); + } + } + + /** + * Handles the required actions depending of the input element contains + * unaccepted input + * + * @param inputElement + * Element, typically an input element + * @param showError + * boolean, true when the element input has an error + */ + public static void handleInputError(Element inputElement, boolean showError) { + if (showError) { + Roles.getTextboxRole().setAriaInvalidState(inputElement, + InvalidValue.TRUE); + } else { + Roles.getTextboxRole().removeAriaInvalidState(inputElement); + } + } + + /** + * Makes sure that the provided element has an id attribute. Adds a new + * unique id if not. + * + * @param element + * Element to check + * @return String with the id of the element + */ + private static String ensureUniqueId(Element element) { + String id = element.getId(); + if (null == id || id.isEmpty()) { + id = DOM.createUniqueId(); + element.setId(id); + } + return id; + } +} diff --git a/client/src/com/vaadin/client/ui/HandlesAriaCaption.java b/client/src/com/vaadin/client/ui/HandlesAriaCaption.java new file mode 100644 index 0000000000..4eef0c5c25 --- /dev/null +++ b/client/src/com/vaadin/client/ui/HandlesAriaCaption.java @@ -0,0 +1,20 @@ +package com.vaadin.client.ui; + +import com.google.gwt.user.client.Element; + +/** + * Some Widgets need to handle the caption handling for WAI-ARIA themselfs, as + * for example the required ids need to be set in a specific way. In such a + * case, the Widget needs to implement this interface. + */ +public interface HandlesAriaCaption { + + /** + * Called to bind the provided caption (label in HTML speak) element to the + * main input element of the Widget. + * + * @param captionElement + * Element of the caption + */ + void handleAriaCaption(Element captionElement); +} diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 50de8e0936..ac5a08475e 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -31,6 +31,7 @@ import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.AbstractLayoutConnector; import com.vaadin.client.ui.LayoutClickEventHandler; +import com.vaadin.client.ui.AriaHelper; import com.vaadin.client.ui.layout.ElementResizeEvent; import com.vaadin.client.ui.layout.ElementResizeListener; import com.vaadin.shared.AbstractFieldState; @@ -258,6 +259,12 @@ public abstract class AbstractOrderedLayoutConnector extends slot.setCaption(caption, iconUrlString, styles, error, showError, required, enabled); + AriaHelper.handleInputRequired(child.getWidget().getElement(), + required); + AriaHelper.handleInputError(child.getWidget().getElement(), + showError); + AriaHelper.bindCaption(child.getWidget(), slot.getCaptionElement()); + if (slot.hasCaption()) { CaptionPosition pos = slot.getCaptionPosition(); getLayoutManager().addElementResizeListener( diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index 795b724292..cf19da3496 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -18,6 +18,7 @@ package com.vaadin.client.ui.orderedlayout; import java.util.List; +import com.google.gwt.aria.client.Roles; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -92,7 +93,6 @@ public final class Slot extends SimplePanel { private ElementResizeListener spacingResizeListener; - // Caption is placed after component unless there is some part which // moves it above. private CaptionPosition captionPosition = CaptionPosition.RIGHT; @@ -479,6 +479,11 @@ public final class Slot extends SimplePanel { // character) requiredIcon.setInnerHTML("*"); requiredIcon.setClassName("v-required-field-indicator"); + + // The star should not be read by the screen reader, as it is + // purely visual. Required state is set at the element level for + // the screen reader. + Roles.getTextboxRole().setAriaHiddenState(requiredIcon, true); } caption.appendChild(requiredIcon); } else if (requiredIcon != null) { diff --git a/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java new file mode 100644 index 0000000000..126caa5985 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -0,0 +1,354 @@ +package com.vaadin.tests.layouts; + + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.data.Item; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.UserError; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DateField; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Layout; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class CaptionsInLayoutsWaiAria extends TestBase { + + private static final Object CAPTION = "CAPTION"; + private static final Object CLASS = "C"; + private static final Object WIDTH = "W"; + + private NativeSelect layoutSelect; + private Layout layout; + private VerticalLayout verticalLayout; + private HorizontalLayout horizontalLayout; + private GridLayout gridLayout; + private FormLayout formLayout; + private List> components = new ArrayList>(); + private CssLayout cssLayout; + private HorizontalLayout layoutParent = new HorizontalLayout(); + + @Override + protected void setup() { + // setTheme("tests-tickets"); + addComponent(createLayoutSelect()); + addComponent(toggleRequired()); + // addComponent(toggleCaptions()); + // addComponent(toggleError()); + addComponent(toggleIcon()); + addComponent(toggleReadOnly()); + addComponent(toggleInvalid()); + addComponent(addCaptionText()); + // layoutParent.addComponent(new + // NativeButton("Button right of layout")); + addComponent(layoutParent); + // addComponent(new NativeButton("Button below layout")); + createComponents(); + layoutSelect.setValue(layoutSelect.getItemIds().iterator().next()); + } + + private Component addCaptionText() { + Button b = new Button("Add caption text"); + b.addListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + prependCaptions("a"); + } + }); + return b; + } + + protected void prependCaptions(String prepend) { + for (AbstractField c : components) { + c.setCaption(prepend + c.getCaption()); + } + + } + + private Component toggleRequired() { + CheckBox requiredToggle = new CheckBox(); + requiredToggle.setImmediate(true); + requiredToggle.setCaption("Required"); + requiredToggle.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + setRequired((Boolean) event.getProperty().getValue()); + } + }); + return requiredToggle; + } + + private Component toggleIcon() { + CheckBox iconToggle = new CheckBox(); + iconToggle.setImmediate(true); + iconToggle.setCaption("Icons"); + iconToggle.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + setIcon((Boolean) event.getProperty().getValue()); + } + }); + return iconToggle; + } + + private Component toggleReadOnly() { + CheckBox readOnlyToggle = new CheckBox(); + readOnlyToggle.setImmediate(true); + readOnlyToggle.setCaption("Read only"); + readOnlyToggle.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + setReadOnly((Boolean) event.getProperty().getValue()); + } + }); + + return readOnlyToggle; + } + + private Component toggleInvalid() { + CheckBox invalid = new CheckBox("Invalid"); + invalid.setImmediate(true); + invalid.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + setInvalid((Boolean) event.getProperty().getValue()); + } + }); + + return invalid; + } + + protected void setInvalid(boolean value) { + UserError userError = null; + if (value) { + userError = new UserError( + "Der eingegebene Wert ist nicht zulässig!"); + } + + for (AbstractField c : components) { + c.setComponentError(userError); + } + } + + protected void setRequired(boolean value) { + for (AbstractField c : components) { + c.setRequired(value); + } + + } + + protected void setIcon(boolean value) { + for (AbstractField c : components) { + if (!value) { + c.setIcon(null); + } else { + c.setIcon(new ThemeResource("../runo/icons/16/ok.png")); + } + } + + } + + protected void setReadOnly(boolean value) { + for (AbstractField c : components) { + c.setReadOnly(value); + } + } + + private Component toggleError() { + CheckBox errorToggle = new CheckBox(); + errorToggle.setImmediate(true); + errorToggle.setCaption("Error"); + errorToggle.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + setError((Boolean) event.getProperty().getValue()); + } + }); + return errorToggle; + } + + protected void setError(boolean value) { + for (AbstractField c : components) { + if (value) { + c.setComponentError(new UserError("error")); + } else { + c.setComponentError(null); + + } + } + + } + + private void createComponents() { + components.add(new TextField("Default TextBox")); + components.add(new TextArea("Default TextArea.")); + // components.add(new RichTextArea("Default RichtTextArea")); + components.add(new PasswordField("Default Password")); + components.add(new DateField("Default DateField")); + + // PopupDateField popupDateField = new + // PopupDateField("Default DateField"); + // popupDateField.setTextFieldEnabled(false); + // components.add(popupDateField); + + components.add(new CheckBox("Default CheckBox")); + + ComboBox comboBox = new ComboBox("Default ComboBox"); + comboBox.addItem("Item1"); + components.add(comboBox); + + OptionGroup radioGroup = new OptionGroup("Single Items"); + radioGroup.addItem("Single Item 1"); + radioGroup.addItem("Single Item 2"); + radioGroup.setMultiSelect(false); + components.add(radioGroup); + + OptionGroup checkGroup = new OptionGroup("Multi Items"); + checkGroup.addItem("Multi Item 1"); + checkGroup.addItem("Multi Item 2"); + checkGroup.setMultiSelect(true); + components.add(checkGroup); + + // Tree tree = new Tree(); + // tree.setCaption("tree"); + // tree.addItem("single item"); + // components.add(tree); + } + + private void setLayout(Layout newLayout) { + if (layout == null) { + layoutParent.addComponent(newLayout, 0); + } else { + layoutParent.replaceComponent(layout, newLayout); + } + layout = newLayout; + + for (Component c : components) { + if (c.getParent() != layout) { + layout.addComponent(c); + } + } + + } + + private Layout getLayout(String caption, + Class layoutClass, String width) { + Layout l; + if (layoutClass == VerticalLayout.class) { + if (verticalLayout == null) { + verticalLayout = new VerticalLayout(); + verticalLayout.setStyleName("borders"); + } + l = verticalLayout; + } else if (layoutClass == HorizontalLayout.class) { + if (horizontalLayout == null) { + horizontalLayout = new HorizontalLayout(); + horizontalLayout.setStyleName("borders"); + } + l = horizontalLayout; + } else if (layoutClass == GridLayout.class) { + if (gridLayout == null) { + gridLayout = new GridLayout(); + gridLayout.setStyleName("borders"); + } + l = gridLayout; + } else if (layoutClass == CssLayout.class) { + if (cssLayout == null) { + cssLayout = new CssLayout(); + cssLayout.setStyleName("borders"); + } + l = cssLayout; + } else if (layoutClass == FormLayout.class) { + if (formLayout == null) { + formLayout = new FormLayout(); + formLayout.setStyleName("borders"); + } + l = formLayout; + } else { + return null; + } + + l.setCaption(caption); + if (width.equals("auto")) { + width = null; + } + + l.setWidth(width); + + // addComponent(l); + + return l; + } + + private Component createLayoutSelect() { + layoutSelect = new NativeSelect("Layout"); + layoutSelect.addContainerProperty(CAPTION, String.class, ""); + layoutSelect.addContainerProperty(CLASS, Class.class, ""); + layoutSelect.addContainerProperty(WIDTH, String.class, ""); + layoutSelect.setItemCaptionPropertyId(CAPTION); + layoutSelect.setNullSelectionAllowed(false); + + for (Class cls : new Class[] { HorizontalLayout.class, + VerticalLayout.class, GridLayout.class, CssLayout.class, + FormLayout.class }) { + for (String width : new String[] { "auto" }) { + Object id = layoutSelect.addItem(); + Item i = layoutSelect.getItem(id); + i.getItemProperty(CAPTION).setValue( + cls.getSimpleName() + ", " + width); + i.getItemProperty(CLASS).setValue(cls); + i.getItemProperty(WIDTH).setValue(width); + } + + } + layoutSelect.setImmediate(true); + layoutSelect.addListener(new ValueChangeListener() { + + @Override + @SuppressWarnings("unchecked") + public void valueChange(ValueChangeEvent event) { + Item i = layoutSelect.getItem(event.getProperty().getValue()); + + setLayout(getLayout((String) i.getItemProperty(CAPTION) + .getValue(), (Class) i + .getItemProperty(CLASS).getValue(), (String) i + .getItemProperty(WIDTH).getValue())); + } + }); + + return layoutSelect; + } + + @Override + protected String getDescription() { + return "Tests what happens when the caption changes in various layouts. Behavior should be consistent."; + } + + @Override + protected Integer getTicketNumber() { + return 5424; + } + +} -- cgit v1.2.3 From 67d05facb86aa01578906a9a34a67f0ca833bb85 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Mar 2013 23:29:37 +0200 Subject: Updated test as Property.toString no longer returns the property value Change-Id: Ic5da1d536ab633b60bc61e1b525fe8f2a8470a73 --- .../vaadin/tests/components/tree/TreeItemClickAndValueChange.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html b/uitest/src/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html index bf83a1acdb..83508c9478 100644 --- a/uitest/src/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html +++ b/uitest/src/com/vaadin/tests/components/tree/TreeItemClickAndValueChange.html @@ -64,7 +64,7 @@ assertText vaadin=runTrees::PID_SLog_row_1 - 4. left click on source: [Item 1], client: [*];, relative: [-1,-1], itemId: Item 2, propertyId: null + 4. left click on source: com.vaadin.ui.Tree@*, client: [*];, relative: [-1,-1], itemId: Item 2, propertyId: null assertText @@ -74,9 +74,8 @@ assertText vaadin=runTrees::PID_SLog_row_3 - 2. left click on source: [], client: [*];, relative: [-1,-1], itemId: Item 1, propertyId: null + 2. left click on source: com.vaadin.ui.Tree@*, client: [*];, relative: [-1,-1], itemId: Item 1, propertyId: null - -- cgit v1.2.3 From 45f97119c7a99a31c1223a814c23ea2c3a08459b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 11 Mar 2013 23:36:42 +0200 Subject: Fixed locator string Change-Id: Iaa5bda79704153e5a10fc6aa3b2244a06a89cf0a --- .../table/ColumnCollapsingAndColumnExpansion.html | 65 +--------------------- 1 file changed, 2 insertions(+), 63 deletions(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html b/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html index 9e529836b6..69b436a41b 100644 --- a/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html +++ b/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html @@ -13,12 +13,7 @@ open - /run/com.vaadin.tests.components.table.ColumnCollapsingAndColumnExpansion - - - - waitForVaadin - + /run/com.vaadin.tests.components.table.ColumnCollapsingAndColumnExpansion?restartApplication @@ -32,20 +27,10 @@ vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[1] - - waitForVaadin - - - click - //td[@id='gwt-uid-2']/span/div - - - - waitForVaadin - + //td[@id='gwt-uid-4']/span/div @@ -53,73 +38,38 @@ col2-hidden - - waitForVaadin - - - enterCharacter vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTextField[0] Col1 - - waitForVaadin - - - click vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] - - waitForVaadin - - - screenCapture col1-col2-hidden - - waitForVaadin - - - contextmenu vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0] - - waitForVaadin - - - mouseClick vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VContextMenu[0]#option0 11,6 - - waitForVaadin - - - enterCharacter vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTextField[0] Col2 - - waitForVaadin - - - screenCapture @@ -131,28 +81,17 @@ vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VTextField[0] Col1 - - waitForVaadin - - - click vaadin=runcomvaadintestscomponentstableColumnCollapsingAndColumnExpansion::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0] - - waitForVaadin - - - screenCapture col1-col2-col3-visible-again - -- cgit v1.2.3 From d0b5b614e9e4dfb53dfcdcc53096b2f26ed12327 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 12 Mar 2013 00:52:23 +0200 Subject: Fixed locale to ensure the same results in all browsers Change-Id: I0a4f9f69f5b5339def23e940ef9cb42163c42638 --- uitest/src/com/vaadin/tests/fieldgroup/DateForm.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java index 0d906a086b..3064856db9 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java +++ b/uitest/src/com/vaadin/tests/fieldgroup/DateForm.java @@ -1,6 +1,7 @@ package com.vaadin.tests.fieldgroup; import java.util.Date; +import java.util.Locale; import com.vaadin.data.fieldgroup.BeanFieldGroup; import com.vaadin.data.fieldgroup.FieldGroup; @@ -77,6 +78,7 @@ public class DateForm extends TestBase { @Override protected void setup() { + getMainWindow().setLocale(Locale.US); addComponent(log); final FieldGroup fieldGroup = new BeanFieldGroup( DateObject.class); -- cgit v1.2.3 From 41798f820c60c43c89d8fb480821d8bda4c42bfb Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Wed, 6 Mar 2013 11:23:48 +0200 Subject: Implemented injection of css styles #5500 Change-Id: Iaccffb4a3e137968d5f51672cdd56f803a9e9d2e --- .../src/com/vaadin/client/ui/ui/UIConnector.java | 92 +++++++++++++++ server/src/com/vaadin/server/Page.java | 128 ++++++++++++++++++++- .../src/com/vaadin/tests/themes/CSSInjectTest.html | 57 +++++++++ .../src/com/vaadin/tests/themes/CSSInjectTest.java | 87 ++++++++++++++ 4 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/themes/CSSInjectTest.html create mode 100644 uitest/src/com/vaadin/tests/themes/CSSInjectTest.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 0fb7439587..7f3c7010dd 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -17,13 +17,19 @@ package com.vaadin.client.ui.ui; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.HeadElement; +import com.google.gwt.dom.client.LinkElement; import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.dom.client.StyleInjector; import com.google.gwt.event.dom.client.ScrollEvent; import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.logical.shared.ResizeEvent; @@ -56,6 +62,7 @@ import com.vaadin.client.ui.VNotification; import com.vaadin.client.ui.VUI; import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.client.ui.window.WindowConnector; +import com.vaadin.server.Page.StyleSheet; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; @@ -256,6 +263,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector final UIDL notification = (UIDL) it.next(); VNotification.showNotification(client, notification); } + } else if (tag == "css-injections") { + injectCSS(childUidl); } } @@ -324,6 +333,89 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getWidget().rendering = false; } + /** + * Reads CSS strings and resources injected by {@link StyleSheet#inject} + * from the UIDL stream. + * + * @param uidl + * The uidl which contains "css-resource" and "css-string" tags + */ + private void injectCSS(UIDL uidl) { + + final HeadElement head = HeadElement.as(Document.get() + .getElementsByTagName(HeadElement.TAG).getItem(0)); + + /* + * Search the UIDL stream for CSS resources and strings to be injected. + */ + final List resourcesToInject = new LinkedList(); + final StringBuilder cssToInject = new StringBuilder(); + for (Iterator it = uidl.getChildIterator(); it.hasNext();) { + UIDL cssInjectionsUidl = (UIDL) it.next(); + + // Check if we have resources to inject + if (cssInjectionsUidl.getTag().equals("css-resource")) { + String url = getWidget().connection + .translateVaadinUri(cssInjectionsUidl + .getStringAttribute("url")); + + // Check if url already has been injected + boolean injected = false; + NodeList links = head + .getElementsByTagName(LinkElement.TAG); + for (int i = 0; i < links.getLength(); i++) { + LinkElement link = LinkElement.as(links.getItem(i)); + if (link.getHref().equals(url)) { + injected = true; + break; + } + } + + if (!injected) { + // Ensure duplicates do not get injected + resourcesToInject.add(url); + } + + // Check if we have CSS string to inject + } else if (cssInjectionsUidl.getTag().equals("css-string")) { + for (Iterator it2 = cssInjectionsUidl.getChildIterator(); it2 + .hasNext();) { + cssToInject.append((String) it2.next()); + } + } + } + + /* + * Inject resources as deferred to ensure other Vaadin resources that + * are located before in the DOM get applied first so the injected ones + * can override them. + */ + if (!resourcesToInject.isEmpty()) { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + for (String url : resourcesToInject) { + LinkElement link = LinkElement.as(DOM + .createElement(LinkElement.TAG)); + link.setRel("stylesheet"); + link.setHref(url); + link.setType("text/css"); + head.appendChild(link); + } + } + }); + } + + /* + * Inject the string CSS injections as a combined style tag. Not + * injected as deferred since StyleInjector will do it for us. + */ + if (cssToInject.length() > 0) { + StyleInjector.injectAtEnd(cssToInject.toString()); + } + } + public void init(String rootPanelId, ApplicationConnection applicationConnection) { DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index 8737b478c3..f7b65a8e9b 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -303,6 +303,115 @@ public class Page implements Serializable { } } + /** + * Contains dynamically injected styles injected in the HTML document at + * runtime. + * + * @since 7.1 + */ + public static class StyleSheet implements Serializable { + + /* + * Points to last injected string injection + */ + private int injectedStringPointer; + + private final List stringInjections = new LinkedList(); + + /* + * Points to last injected resource injection + */ + private int injectedResourcesPointer; + + private final List resourceInjections = new LinkedList(); + + private final UI ui; + + private StyleSheet(UI ui) { + this.ui = ui; + } + + /** + * Injects a raw CSS string into the page. + * + * @param css + * The CSS to inject + */ + public void inject(String css) { + if (css == null) { + throw new IllegalArgumentException( + "Cannot inject null CSS string"); + } + + /* + * Check if last injection was the same, in that case ignore it. + */ + if (!stringInjections.isEmpty() && injectedStringPointer > 0) { + String lastInjection = stringInjections + .get(injectedStringPointer - 1); + if (lastInjection.equals(css.trim())) { + return; + } + } + + stringInjections.add(css.trim()); + ui.markAsDirty(); + } + + /** + * Injects a CSS resource into the page + * + * @param resource + * The resource to inject. + */ + public void inject(Resource resource) { + if (resource == null) { + throw new IllegalArgumentException( + "Cannot inject null resource"); + } + + resourceInjections.add(resource); + ui.markAsDirty(); + } + + private void paint(PaintTarget target) throws PaintException { + + // If full repaint repaint all injections + if (target.isFullRepaint()) { + injectedStringPointer = 0; + injectedResourcesPointer = 0; + } + + target.startTag("css-injections"); + + // Paint pending string injections + List injections = stringInjections.subList( + injectedStringPointer, stringInjections.size()); + + for (String css : injections) { + target.startTag("css-string"); + target.addText(css); + target.endTag("css-string"); + } + + injectedStringPointer = stringInjections.size(); + + // Paint pending resource injections + List resInjections = resourceInjections.subList( + injectedResourcesPointer, resourceInjections.size()); + + for (Resource res : resInjections) { + target.startTag("css-resource"); + target.addAttribute("url", res); + target.endTag("css-resource"); + } + + target.endTag("css-injections"); + + injectedResourcesPointer = resourceInjections.size(); + } + } + private EventRouter eventRouter; private final UI uI; @@ -312,6 +421,8 @@ public class Page implements Serializable { private JavaScript javaScript; + private StyleSheet styleSheet; + /** * The current browser location. */ @@ -576,10 +687,22 @@ public class Page implements Serializable { javaScript = new JavaScript(); javaScript.extend(uI); } - return javaScript; } + /** + * Returns that stylesheet associated with this Page. The stylesheet + * contains additional styles injected at runtime into the HTML document. + * + * @since 7.1 + */ + public StyleSheet getStyleSheet() { + if (styleSheet == null) { + styleSheet = new StyleSheet(uI); + } + return styleSheet; + } + public void paintContent(PaintTarget target) throws PaintException { if (!openList.isEmpty()) { for (final Iterator i = openList.iterator(); i @@ -637,6 +760,9 @@ public class Page implements Serializable { location.toString()); } + if (styleSheet != null) { + styleSheet.paint(target); + } } /** diff --git a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html new file mode 100644 index 0000000000..05a0f256c2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.html @@ -0,0 +1,57 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.themes.CSSInjectTest?restartApplication
screenCapturehello-world-gray
typevaadin=runcomvaadinteststhemesCSSInjectTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextArea[0].hello{color:blue;}
clickvaadin=runcomvaadinteststhemesCSSInjectTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturehello-blue
typevaadin=runcomvaadinteststhemesCSSInjectTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextArea[0].world{color:red;}
clickvaadin=runcomvaadinteststhemesCSSInjectTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
screenCaptureworld-red
+ + diff --git a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java new file mode 100644 index 0000000000..bedbf47fe2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java @@ -0,0 +1,87 @@ +package com.vaadin.tests.themes; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.UUID; + +import com.vaadin.server.Page; +import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.StreamResource; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextArea; + +public class CSSInjectTest extends TestBase { + + @Override + protected void setup() { + + final StyleSheet stylesheet = Page.getCurrent().getStyleSheet(); + + // Inject some resources initially + stylesheet.inject(new StreamResource(new StreamResource.StreamSource() { + + @Override + public InputStream getStream() { + return new ByteArrayInputStream( + ".hello, .world { color:silver; }".getBytes()); + } + }, "mystyles-" + System.currentTimeMillis() + ".css")); + + Label hello = new Label( + "Hello world", + ContentMode.HTML); + addComponent(hello); + + final TextArea cssToInject = new TextArea(); + cssToInject.setImmediate(true); + addComponent(cssToInject); + + Button inject = new Button("Inject!", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + stylesheet.inject(cssToInject.getValue()); + cssToInject.setValue(""); + } + }); + addComponent(inject); + + Button injectRandom = new Button("Inject as resource!", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + + final String css = cssToInject.getValue(); + + stylesheet.inject(new StreamResource( + new StreamResource.StreamSource() { + + @Override + public InputStream getStream() { + return new ByteArrayInputStream(css + .getBytes()); + } + }, UUID.randomUUID().toString() + ".css")); + + cssToInject.setValue(""); + } + }); + addComponent(injectRandom); + } + + @Override + protected String getDescription() { + return "Demonstrates how CSS injections can be used to theme the \"Hello world\" label below"; + } + + @Override + protected Integer getTicketNumber() { + return 5500; + } + +} -- cgit v1.2.3 From 9764317f6be8091cfda37faac9294f5e58ecfeef Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Mon, 18 Mar 2013 15:41:46 +0200 Subject: Added CSS Inject / ColorPicker tutorial #11360 Change-Id: Iacafb3c4e26c4ff1a258eff466cfd18508d8ff0c --- .../v71beta/CSSInjectWithColorpicker.java | 234 +++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java new file mode 100644 index 0000000000..4ac85ab231 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java @@ -0,0 +1,234 @@ +package com.vaadin.tests.widgetset.client.minitutorials.v71beta; + +import java.util.Arrays; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.Page; +import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.shared.ui.colorpicker.Color; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ColorPicker; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.components.colorpicker.ColorChangeEvent; +import com.vaadin.ui.components.colorpicker.ColorChangeListener; + +public class CSSInjectWithColorpicker extends UI { + + @Override + protected void init(VaadinRequest request) { + + // Create a text editor + Component editor = createEditor("Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + +"Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec."); + + + VerticalLayout content = new VerticalLayout(editor); + content.setMargin(true); + setContent(content); + } + + /** + * Creates a text editor for visually editing text + * + * @param text + * The text editor + * @return + */ + private Component createEditor(String text) { + + Panel editor = new Panel("Text Editor"); + editor.setWidth("580px"); + + VerticalLayout panelContent = new VerticalLayout(); + panelContent.setSpacing(true); + panelContent.setMargin(new MarginInfo(true, false, false, false)); + editor.setContent(panelContent); + + // Create the toolbar + HorizontalLayout toolbar = new HorizontalLayout(); + toolbar.setSpacing(true); + toolbar.setMargin(new MarginInfo(false, false, false, true)); + + // Create the font family selector + toolbar.addComponent(createFontSelect()); + + // Create the font size selector + toolbar.addComponent(createFontSizeSelect()); + + // Create the text color selector + toolbar.addComponent(createTextColorSelect()); + + // Create the background color selector + toolbar.addComponent(createBackgroundColorSelect()); + + panelContent.addComponent(toolbar); + panelContent.setComponentAlignment(toolbar, Alignment.MIDDLE_LEFT); + + // Spacer between toolbar and text + panelContent.addComponent(new Label("
", ContentMode.HTML)); + + // The text to edit + TextArea textLabel = new TextArea(null, text); + textLabel.setWidth("100%"); + textLabel.setHeight("200px"); + + // IMPORTANT: We are here setting the style name of the label, we are going to use this in our injected styles to target the label + textLabel.setStyleName("text-label"); + + panelContent.addComponent(textLabel); + + return editor; + } + + /** + * Creates a background color select dialog + */ + private Component createBackgroundColorSelect() { + ColorPicker bgColor = new ColorPicker("Background", Color.WHITE); + bgColor.setWidth("110px"); + bgColor.setCaption("Background"); + bgColor.addColorChangeListener(new ColorChangeListener() { + + @Override + public void colorChanged(ColorChangeEvent event) { + + // Get the new background color + Color color = event.getColor(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new background color + styles.inject(".v-app .v-textarea.text-label { background-color:" + + color.getCSS() + "; }"); + } + }); + return bgColor; + } + + /** + * Create a text color selction dialog + */ + private Component createTextColorSelect() { + + // Colorpicker for changing text color + ColorPicker textColor = new ColorPicker("Color", Color.BLACK); + textColor.setWidth("110px"); + textColor.setCaption("Color"); + textColor.addColorChangeListener(new ColorChangeListener() { + + @Override + public void colorChanged(ColorChangeEvent event) { + + // Get the new text color + Color color = event.getColor(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new color as a style + styles.inject(".v-app .v-textarea.text-label { color:" + + color.getCSS() + "; }"); + } + }); + + return textColor; + } + + /** + * Creates a font family selection dialog + */ + private Component createFontSelect() { + final ComboBox select = new ComboBox(null, Arrays.asList("Arial", + "Helvetica", "Verdana", "Courier", "Times", "sans-serif")); + select.setValue("Arial"); + select.setWidth("200px"); + select.setInputPrompt("Font"); + select.setDescription("Font"); + select.setImmediate(true); + select.setNullSelectionAllowed(false); + select.setNewItemsAllowed(false); + + select.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + // Get the new font family + String fontFamily = select.getValue().toString(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new font size as a style. We need .v-app to + // override Vaadin's default styles here + styles.inject(".v-app .v-textarea.text-label { font-family:" + + fontFamily + "; }"); + } + }); + + return select; + } + + /** + * Creates a font size selection control + */ + private Component createFontSizeSelect() { + + final ComboBox select = new ComboBox(null, Arrays.asList(8, 9, 10, + 12, 14, 16, 20, 25, 30, 40, 50)); + select.setWidth("100px"); + select.setValue(12); + select.setInputPrompt("Font size"); + select.setDescription("Font size"); + select.setImmediate(true); + select.setNullSelectionAllowed(false); + select.setNewItemsAllowed(false); + select.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + // Get the new font size + Integer fontSize = (Integer) select.getValue(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new font size as a style. We need .v-app to + // override Vaadin's default styles here + styles.inject(".v-app .v-textarea.text-label { font-size:" + + String.valueOf(fontSize) + "px; }"); + } + }); + + return select; + } +} -- cgit v1.2.3 From 320b4e3776976e5dad822f01542f338cf76140bb Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Wed, 20 Mar 2013 10:37:11 +0200 Subject: WAI-ARIA fields (#11180) Field implementations of the WAI-ARIA changes in the base classes Change-Id: Ie51e76130f3f9976a32c373334b709f0f5b68f1a --- WebContent/VAADIN/themes/base/common/common.scss | 6 + client/src/com/vaadin/client/VCaption.java | 15 +++ client/src/com/vaadin/client/VErrorMessage.java | 3 + client/src/com/vaadin/client/VTooltip.java | 130 ++++++++++++++++++--- client/src/com/vaadin/client/ui/AriaHelper.java | 58 ++++++--- .../com/vaadin/client/ui/HandlesAriaCaption.java | 8 +- .../src/com/vaadin/client/ui/VCalendarPanel.java | 85 ++++++++++++-- client/src/com/vaadin/client/ui/VCheckBox.java | 25 ++++ client/src/com/vaadin/client/ui/VFilterSelect.java | 13 +++ client/src/com/vaadin/client/ui/VFormLayout.java | 15 +++ client/src/com/vaadin/client/ui/VOptionGroup.java | 61 +++++++++- .../src/com/vaadin/client/ui/VPopupCalendar.java | 113 +++++++++++++++++- client/src/com/vaadin/client/ui/VTextField.java | 4 + client/src/com/vaadin/client/ui/VTextualDate.java | 21 +++- .../com/vaadin/client/ui/tree/TreeConnector.java | 35 +++++- .../tests/layouts/CaptionsInLayoutsWaiAria.java | 1 - 16 files changed, 541 insertions(+), 52 deletions(-) (limited to 'uitest/src') diff --git a/WebContent/VAADIN/themes/base/common/common.scss b/WebContent/VAADIN/themes/base/common/common.scss index e801ec2821..27c6dc949c 100644 --- a/WebContent/VAADIN/themes/base/common/common.scss +++ b/WebContent/VAADIN/themes/base/common/common.scss @@ -238,4 +238,10 @@ input::-ms-clear { height: 0; } +.v-assistive-device-only { + position: absolute; + left: -2000px; + width: 10px; + overflow: hidden; +} } \ No newline at end of file diff --git a/client/src/com/vaadin/client/VCaption.java b/client/src/com/vaadin/client/VCaption.java index 47287636c4..607a0f0b0a 100644 --- a/client/src/com/vaadin/client/VCaption.java +++ b/client/src/com/vaadin/client/VCaption.java @@ -16,12 +16,15 @@ package com.vaadin.client; +import com.google.gwt.aria.client.Roles; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractFieldConnector; +import com.vaadin.client.ui.AriaHelper; import com.vaadin.client.ui.Icon; import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.AbstractFieldState; @@ -88,6 +91,8 @@ public class VCaption extends HTML { this.client = client; owner = component; + AriaHelper.bindCaption(component.getWidget(), getElement()); + if (client != null && owner != null) { setOwnerPid(getElement(), owner.getConnectorId()); } @@ -209,11 +214,21 @@ public class VCaption extends HTML { DOM.insertChild(getElement(), requiredFieldIndicator, getInsertPosition(InsertPosition.REQUIRED)); + + Roles.getTextboxRole().setAriaRequiredProperty( + owner.getWidget().getElement(), true); + + // Hide the required indicator from assistive device + Roles.getTextboxRole().setAriaHiddenState( + requiredFieldIndicator, true); } } else if (requiredFieldIndicator != null) { // Remove existing DOM.removeChild(getElement(), requiredFieldIndicator); requiredFieldIndicator = null; + + Roles.getTextboxRole().removeAriaRequiredProperty( + owner.getWidget().getElement()); } if (showError) { diff --git a/client/src/com/vaadin/client/VErrorMessage.java b/client/src/com/vaadin/client/VErrorMessage.java index a384b451dd..2e42b98a05 100644 --- a/client/src/com/vaadin/client/VErrorMessage.java +++ b/client/src/com/vaadin/client/VErrorMessage.java @@ -31,6 +31,9 @@ public class VErrorMessage extends FlowPanel { public VErrorMessage() { super(); setStyleName(CLASSNAME); + + // Needed for binding with WAI-ARIA attributes + getElement().setId(DOM.createUniqueId()); } /** diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 759b90a8cd..e6d9a79a5b 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -15,8 +15,16 @@ */ package com.vaadin.client; +import com.google.gwt.aria.client.Id; +import com.google.gwt.aria.client.LiveValue; +import com.google.gwt.aria.client.Roles; +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.dom.client.MouseMoveEvent; @@ -54,6 +62,9 @@ public class VTooltip extends VOverlay { // Open next tooltip faster. Disabled after 2 sec of showTooltip-silence. private boolean justClosed = false; + private String uniqueId = DOM.createUniqueId(); + private Element layoutElement; + /** * Used to show tooltips; usually used via the singleton in * {@link ApplicationConnection}. NOTE that #setOwner(Widget)} should be @@ -68,8 +79,19 @@ public class VTooltip extends VOverlay { setWidget(layout); layout.add(em); DOM.setElementProperty(description, "className", CLASSNAME + "-text"); - DOM.appendChild(layout.getElement(), description); + + layoutElement = layout.getElement(); + DOM.appendChild(layoutElement, description); setSinkShadowEvents(true); + + // WAI-ARIA additions + layoutElement.setId(uniqueId); + Roles.getTooltipRole().setAriaLiveProperty(getElement(), + LiveValue.POLITE); + + description.setId(DOM.createUniqueId()); + Roles.getTooltipRole().set(layoutElement); + Roles.getTooltipRole().setAriaHiddenState(layoutElement, true); } /** @@ -204,15 +226,27 @@ public class VTooltip extends VOverlay { closing = true; justClosed = true; justClosedTimer.schedule(QUICK_OPEN_TIMEOUT); + } + @Override + public void hide() { + super.hide(); + Roles.getTooltipRole().setAriaHiddenState(layoutElement, true); + Roles.getTooltipRole().removeAriaDescribedbyProperty( + tooltipEventHandler.currentElement); } private int tooltipEventMouseX; private int tooltipEventMouseY; - public void updatePosition(Event event) { - tooltipEventMouseX = DOM.eventGetClientX(event); - tooltipEventMouseY = DOM.eventGetClientY(event); + public void updatePosition(Event event, boolean isFocused) { + if (isFocused) { + tooltipEventMouseX = -1000; + tooltipEventMouseY = -1000; + } else { + tooltipEventMouseX = DOM.eventGetClientX(event); + tooltipEventMouseY = DOM.eventGetClientY(event); + } } @Override @@ -246,13 +280,18 @@ public class VTooltip extends VOverlay { } private class TooltipEventHandler implements MouseMoveHandler, - ClickHandler, KeyDownHandler { + ClickHandler, KeyDownHandler, FocusHandler, BlurHandler { /** * Current element hovered */ private com.google.gwt.dom.client.Element currentElement = null; + /** + * Current element focused + */ + private boolean currentIsFocused; + /** * Current tooltip active */ @@ -319,41 +358,77 @@ public class VTooltip extends VOverlay { @Override public void onMouseMove(MouseMoveEvent mme) { - Event event = Event.as(mme.getNativeEvent()); + handleShowHide(mme, false); + } + + @Override + public void onClick(ClickEvent event) { + handleHideEvent(); + } + + @Override + public void onKeyDown(KeyDownEvent event) { + handleHideEvent(); + } + + /** + * Displays Tooltip when page is navigated with the keyboard. + * + * Tooltip is not visible. This makes it possible for assistive devices + * to recognize the tooltip. + */ + @Override + public void onFocus(FocusEvent fe) { + handleShowHide(fe, true); + } + + /** + * Hides Tooltip when the page is navigated with the keyboard. + * + * Removes the Tooltip from page to make sure assistive devices don't + * recognize it by accident. + */ + @Override + public void onBlur(BlurEvent be) { + handleHideEvent(); + } + + private void handleShowHide(DomEvent domEvent, boolean isFocused) { + Event event = Event.as(domEvent.getNativeEvent()); com.google.gwt.dom.client.Element element = Element.as(event .getEventTarget()); // We can ignore move event if it's handled by move or over already - if (currentElement == element) { + if (currentElement == element && currentIsFocused == isFocused) { return; } - currentElement = element; boolean connectorAndTooltipFound = resolveConnector((com.google.gwt.user.client.Element) element); if (!connectorAndTooltipFound) { if (isShowing()) { handleHideEvent(); + Roles.getButtonRole() + .removeAriaDescribedbyProperty(element); } else { currentTooltipInfo = null; } } else { - updatePosition(event); + updatePosition(event, isFocused); + if (isShowing()) { replaceCurrentTooltip(); + Roles.getTooltipRole().removeAriaDescribedbyProperty( + currentElement); } else { showTooltip(); } - } - } - @Override - public void onClick(ClickEvent event) { - handleHideEvent(); - } + Roles.getTooltipRole().setAriaDescribedbyProperty(element, + Id.of(uniqueId)); + } - @Override - public void onKeyDown(KeyDownEvent event) { - handleHideEvent(); + currentIsFocused = isFocused; + currentElement = element; } } @@ -370,6 +445,25 @@ public class VTooltip extends VOverlay { widget.addDomHandler(tooltipEventHandler, MouseMoveEvent.getType()); widget.addDomHandler(tooltipEventHandler, ClickEvent.getType()); widget.addDomHandler(tooltipEventHandler, KeyDownEvent.getType()); + widget.addDomHandler(tooltipEventHandler, FocusEvent.getType()); + widget.addDomHandler(tooltipEventHandler, BlurEvent.getType()); Profiler.leave("VTooltip.connectHandlersToWidget"); } + + /** + * Returns the unique id of the tooltip element. + * + * @return String containing the unique id of the tooltip, which always has + * a value + */ + public String getUniqueId() { + return uniqueId; + } + + @Override + public void setPopupPositionAndShow(PositionCallback callback) { + super.setPopupPositionAndShow(callback); + + Roles.getTooltipRole().setAriaHiddenState(layoutElement, false); + } } diff --git a/client/src/com/vaadin/client/ui/AriaHelper.java b/client/src/com/vaadin/client/ui/AriaHelper.java index 189149f8b5..56f358f294 100644 --- a/client/src/com/vaadin/client/ui/AriaHelper.java +++ b/client/src/com/vaadin/client/ui/AriaHelper.java @@ -27,6 +27,7 @@ import com.google.gwt.user.client.ui.Widget; * Helper class that helps to implement the WAI-ARIA functionality. */ public class AriaHelper { + public static final String ASSISTIVE_DEVICE_ONLY_STYLE = "v-assistive-device-only"; /** * Binds a caption (label in HTML speak) to the form element as required by @@ -40,24 +41,32 @@ public class AriaHelper { public static void bindCaption(Widget widget, Element captionElement) { assert widget != null : "Valid Widget required"; - if (null != captionElement) { - ensureUniqueId(captionElement); - - if (widget instanceof HandlesAriaCaption) { - ((HandlesAriaCaption) widget).handleAriaCaption(captionElement); + if (widget instanceof HandlesAriaCaption) { + // Let the widget handle special cases itself + if (captionElement == null) { + ((HandlesAriaCaption) widget).clearAriaCaption(); } else { - String ownerId = ensureUniqueId(widget.getElement()); - captionElement.setAttribute("for", ownerId); - - Roles.getTextboxRole().setAriaLabelledbyProperty( - widget.getElement(), Id.of(captionElement)); + ensureUniqueId(captionElement); + ((HandlesAriaCaption) widget).bindAriaCaption(captionElement); } + } else if (captionElement != null) { + // Handle the default case + ensureUniqueId(captionElement); + String ownerId = ensureUniqueId(widget.getElement()); + captionElement.setAttribute("for", ownerId); + + Roles.getTextboxRole().setAriaLabelledbyProperty( + widget.getElement(), Id.of(captionElement)); } else { - Roles.getTextboxRole().removeAriaLabelledbyProperty( - widget.getElement()); + clearCaption(widget); } } + public static void clearCaption(Widget widget) { + Roles.getTextboxRole() + .removeAriaLabelledbyProperty(widget.getElement()); + } + /** * Handles the required actions depending of the input element being * required or not. @@ -102,7 +111,7 @@ public class AriaHelper { * Element to check * @return String with the id of the element */ - private static String ensureUniqueId(Element element) { + public static String ensureUniqueId(Element element) { String id = element.getId(); if (null == id || id.isEmpty()) { id = DOM.createUniqueId(); @@ -110,4 +119,27 @@ public class AriaHelper { } return id; } + + /** + * Moves an element out of sight. That way it is possible to have additional + * information for an assistive device, that is not in the way for visual + * users. + * + * @param element + * Element to move out of sight + */ + public static void visibleForAssistiveDevicesOnly(Element element) { + element.addClassName(ASSISTIVE_DEVICE_ONLY_STYLE); + } + + /** + * Clears the settings that moved the element out of sight, so it is visible + * on the page again. + * + * @param element + * Element to clear the specific styles from + */ + public static void visibleForAll(Element element) { + element.removeClassName(ASSISTIVE_DEVICE_ONLY_STYLE); + } } diff --git a/client/src/com/vaadin/client/ui/HandlesAriaCaption.java b/client/src/com/vaadin/client/ui/HandlesAriaCaption.java index 045bec1d4b..fbbbbff462 100644 --- a/client/src/com/vaadin/client/ui/HandlesAriaCaption.java +++ b/client/src/com/vaadin/client/ui/HandlesAriaCaption.java @@ -32,5 +32,11 @@ public interface HandlesAriaCaption { * @param captionElement * Element of the caption */ - void handleAriaCaption(Element captionElement); + void bindAriaCaption(Element captionElement); + + /** + * Called to clear the binding to a caption from the main input element of + * the widget. + */ + void clearAriaCaption(); } diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java index e234cc911c..3e81ec734b 100644 --- a/client/src/com/vaadin/client/ui/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java @@ -19,6 +19,8 @@ package com.vaadin.client.ui; import java.util.Date; import java.util.Iterator; +import com.google.gwt.aria.client.Roles; +import com.google.gwt.aria.client.SelectedValue; import com.google.gwt.dom.client.Node; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -40,6 +42,7 @@ import com.google.gwt.event.dom.client.MouseOutEvent; import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Button; @@ -175,9 +178,9 @@ public class VCalendarPanel extends FocusableFlexTable implements private boolean showISOWeekNumbers; - private Date displayedMonth; + private FocusedDate displayedMonth; - private Date focusedDate; + private FocusedDate focusedDate; private Day selectedDay; @@ -198,8 +201,9 @@ public class VCalendarPanel extends FocusableFlexTable implements private boolean initialRenderDone = false; public VCalendarPanel() { - + getElement().setId(DOM.createUniqueId()); setStyleName(VDateField.CLASSNAME + "-calendarpanel"); + Roles.getGridRole().set(getElement()); /* * Firefox auto-repeat works correctly only if we use a key press @@ -267,6 +271,8 @@ public class VCalendarPanel extends FocusableFlexTable implements private void selectDate(Date date) { if (selectedDay != null) { selectedDay.removeStyleDependentName(CN_SELECTED); + Roles.getGridcellRole().removeAriaSelectedState( + selectedDay.getElement()); } int rowCount = days.getRowCount(); @@ -279,6 +285,8 @@ public class VCalendarPanel extends FocusableFlexTable implements if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_SELECTED); selectedDay = curday; + Roles.getGridcellRole().setAriaSelectedState( + selectedDay.getElement(), SelectedValue.TRUE); return; } } @@ -528,6 +536,10 @@ public class VCalendarPanel extends FocusableFlexTable implements } else { days.setHTML(headerRow, firstWeekdayColumn + i, ""); } + + Roles.getColumnheaderRole().set( + days.getCellFormatter().getElement(headerRow, + firstWeekdayColumn + i)); } // Zero out hours, minutes, seconds, and milliseconds to compare dates @@ -557,6 +569,8 @@ public class VCalendarPanel extends FocusableFlexTable implements if (curr.equals(selectedDate)) { day.addStyleDependentName(CN_SELECTED); + Roles.getGridcellRole().setAriaSelectedState( + day.getElement(), SelectedValue.TRUE); selectedDay = day; } if (curr.equals(today)) { @@ -574,10 +588,14 @@ public class VCalendarPanel extends FocusableFlexTable implements } days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek, day); + Roles.getGridcellRole().set( + days.getCellFormatter().getElement(weekOfMonth, + firstWeekdayColumn + dayOfWeek)); // ISO week numbers if requested days.getCellFormatter().setVisible(weekOfMonth, weekColumn, isShowISOWeekNumbers()); + if (isShowISOWeekNumbers()) { final String baseCssClass = parent.getStylePrimaryName() + "-calendarpanel-weeknumber"; @@ -615,8 +633,9 @@ public class VCalendarPanel extends FocusableFlexTable implements if (focusedDate == null) { Date now = new Date(); // focusedDate must have zero hours, mins, secs, millisecs - focusedDate = new Date(now.getYear(), now.getMonth(), now.getDate()); - displayedMonth = new Date(now.getYear(), now.getMonth(), 1); + focusedDate = new FocusedDate(now.getYear(), now.getMonth(), + now.getDate()); + displayedMonth = new FocusedDate(now.getYear(), now.getMonth(), 1); } if (getResolution().getCalendarField() <= Resolution.MONTH @@ -1062,9 +1081,10 @@ public class VCalendarPanel extends FocusableFlexTable implements */ } else if (keycode == getResetKey() && !shift) { // Restore showing value the selected value - focusedDate = new Date(value.getYear(), value.getMonth(), + focusedDate = new FocusedDate(value.getYear(), value.getMonth(), value.getDate()); - displayedMonth = new Date(value.getYear(), value.getMonth(), 1); + displayedMonth = new FocusedDate(value.getYear(), value.getMonth(), + 1); renderCalendar(); return true; } @@ -1264,9 +1284,10 @@ public class VCalendarPanel extends FocusableFlexTable implements if (value == null) { focusedDate = displayedMonth = null; } else { - focusedDate = new Date(value.getYear(), value.getMonth(), + focusedDate = new FocusedDate(value.getYear(), value.getMonth(), value.getDate()); - displayedMonth = new Date(value.getYear(), value.getMonth(), 1); + displayedMonth = new FocusedDate(value.getYear(), value.getMonth(), + 1); } // Re-render calendar if the displayed month is changed, @@ -1821,4 +1842,50 @@ public class VCalendarPanel extends FocusableFlexTable implements mouseTimer.cancel(); } } + + /** + * Helper class to inform the screen reader that the user changed the + * selected date. It sets the value of a field that is outside the view, and + * is defined as a live area. That way the screen reader recognizes the + * change and reads it to the user. + */ + public class FocusedDate extends Date { + + public FocusedDate(int year, int month, int date) { + super(year, month, date); + } + + @Override + public void setTime(long time) { + super.setTime(time); + setLabel(); + } + + @Override + @Deprecated + public void setDate(int date) { + super.setDate(date); + setLabel(); + } + + @Override + @Deprecated + public void setMonth(int month) { + super.setMonth(month); + setLabel(); + } + + @Override + @Deprecated + public void setYear(int year) { + super.setYear(year); + setLabel(); + } + + private void setLabel() { + if (parent instanceof VPopupCalendar) { + ((VPopupCalendar) parent).setFocusedDate(this); + } + } + } } diff --git a/client/src/com/vaadin/client/ui/VCheckBox.java b/client/src/com/vaadin/client/ui/VCheckBox.java index ca1e3ebcdb..a94c2fcfee 100644 --- a/client/src/com/vaadin/client/ui/VCheckBox.java +++ b/client/src/com/vaadin/client/ui/VCheckBox.java @@ -16,6 +16,8 @@ package com.vaadin.client.ui; +import com.google.gwt.aria.client.CheckedValue; +import com.google.gwt.aria.client.Roles; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -46,6 +48,11 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements public VCheckBox() { setStyleName(CLASSNAME); + // Add a11y role "checkbox" + Roles.getCheckboxRole().set(getElement()); + Roles.getCheckboxRole().setAriaCheckedState(getElement(), + CheckedValue.FALSE); + Element el = DOM.getFirstChild(getElement()); while (el != null) { DOM.sinkEvents(el, @@ -69,4 +76,22 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements } } + @Override + public void setValue(Boolean value, boolean fireEvents) { + setCheckedValue(value); + super.setValue(value, fireEvents); + } + + private void setCheckedValue(Boolean value) { + CheckedValue checkedValue = value ? CheckedValue.TRUE + : CheckedValue.FALSE; + Roles.getCheckboxRole().setAriaCheckedState(getElement(), checkedValue); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + Roles.getCheckboxRole().setAriaDisabledState(getElement(), true); + } } diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index cea3489b42..5025f27248 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style; @@ -219,6 +220,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL); addCloseHandler(this); + + Roles.getListRole().set(getElement()); } /** @@ -684,6 +687,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, while (it.hasNext()) { final FilterSelectSuggestion s = it.next(); final MenuItem mi = new MenuItem(s.getDisplayString(), true, s); + Roles.getListitemRole().set(mi.getElement()); Util.sinkOnloadForImages(mi.getElement()); @@ -1049,9 +1053,13 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, }); popupOpener.sinkEvents(Event.ONMOUSEDOWN); + Roles.getButtonRole().set(popupOpener.getElement()); + panel.add(tb); panel.add(popupOpener); initWidget(panel); + Roles.getComboboxRole().set(panel.getElement()); + tb.addKeyDownHandler(this); tb.addKeyUpHandler(this); @@ -1059,6 +1067,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, tb.addBlurHandler(this); tb.addClickHandler(this); + Roles.getTextboxRole().set(tb.getElement()); + popupOpener.addClickHandler(this); setStyleName(CLASSNAME); @@ -1163,8 +1173,11 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, // Always update styles as they might have been overwritten if (textInputEnabled) { removeStyleDependentName(STYLE_NO_INPUT); + Roles.getTextboxRole().removeAriaReadonlyProperty(tb.getElement()); } else { addStyleDependentName(STYLE_NO_INPUT); + Roles.getTextboxRole().setAriaReadonlyProperty(tb.getElement(), + true); } if (this.textInputEnabled == textInputEnabled) { diff --git a/client/src/com/vaadin/client/ui/VFormLayout.java b/client/src/com/vaadin/client/ui/VFormLayout.java index 495e842bfd..4c7190340f 100644 --- a/client/src/com/vaadin/client/ui/VFormLayout.java +++ b/client/src/com/vaadin/client/ui/VFormLayout.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import com.google.gwt.aria.client.Roles; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; @@ -276,6 +277,9 @@ public class VFormLayout extends SimplePanel { if (state.caption != null) { if (captionText == null) { captionText = DOM.createSpan(); + + AriaHelper.bindCaption(owner.getWidget(), captionText); + DOM.insertChild(getElement(), captionText, icon == null ? 0 : 1); } @@ -305,11 +309,22 @@ public class VFormLayout extends SimplePanel { DOM.setElementProperty(requiredFieldIndicator, "className", "v-required-field-indicator"); DOM.appendChild(getElement(), requiredFieldIndicator); + + Roles.getTextboxRole().setAriaRequiredProperty( + owner.getWidget().getElement(), true); + + // Hide the required indicator from screen reader, as this + // information is set directly at the input field + Roles.getTextboxRole().setAriaHiddenState( + requiredFieldIndicator, true); } } else { if (requiredFieldIndicator != null) { DOM.removeChild(getElement(), requiredFieldIndicator); requiredFieldIndicator = null; + + Roles.getTextboxRole().removeAriaRequiredProperty( + owner.getWidget().getElement()); } } diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java index 2ba8a9e729..f0c7b7f83d 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroup.java +++ b/client/src/com/vaadin/client/ui/VOptionGroup.java @@ -22,6 +22,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import com.google.gwt.aria.client.CheckedValue; +import com.google.gwt.aria.client.Id; +import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; @@ -32,6 +35,7 @@ import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FocusWidget; import com.google.gwt.user.client.ui.Focusable; @@ -46,7 +50,7 @@ import com.vaadin.shared.EventId; import com.vaadin.shared.ui.optiongroup.OptionGroupConstants; public class VOptionGroup extends VOptionGroupBase implements FocusHandler, - BlurHandler { + BlurHandler, HandlesAriaCaption { public static final String CLASSNAME = "v-select-optiongroup"; @@ -85,6 +89,8 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, /** For internal use only. May be removed or replaced in the future. */ public boolean htmlContentAllowed = false; + private String labelId; + public VOptionGroup() { super(CLASSNAME); panel = (Panel) optionsContainer; @@ -99,6 +105,13 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, public void buildOptions(UIDL uidl) { panel.clear(); optionsEnabled.clear(); + + if (isMultiselect()) { + Roles.getGroupRole().set(getElement()); + } else { + Roles.getRadiogroupRole().set(getElement()); + } + for (final Iterator it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); CheckBox op; @@ -118,9 +131,30 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, if (isMultiselect()) { op = new VCheckBox(); op.setHTML(itemHtml); + + // Add a11y role "checkbox" - FIXME - did not find a good + // solution to prevent getFirstChild() + com.google.gwt.dom.client.Element checkBoxElement = op + .getElement().getFirstChildElement(); + Roles.getCheckboxRole().set(checkBoxElement); + Roles.getCheckboxRole().setAriaCheckedState(checkBoxElement, + CheckedValue.FALSE); } else { op = new RadioButton(paintableId, itemHtml, true); op.setStyleName("v-radiobutton"); + + // Add a11y role "radio" - FIXME - did not find a good solution + // to prevent getFirstChild() + com.google.gwt.dom.client.Element radioElement = op + .getElement().getFirstChildElement(); + Roles.getRadioRole().set(radioElement); + Roles.getRadioRole().setAriaCheckedState(radioElement, + CheckedValue.FALSE); + } + + if (labelId != null && !labelId.isEmpty()) { + Roles.getFormRole().setAriaDescribedbyProperty( + op.getElement().getFirstChildElement(), Id.of(labelId)); } if (icon != null && icon.length() != 0) { @@ -165,6 +199,13 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, } client.updateVariable(paintableId, "selected", getSelectedItems(), isImmediate()); + + for (CheckBox item : optionsToKeys.keySet()) { + CheckedValue value = item.getValue() ? CheckedValue.TRUE + : CheckedValue.FALSE; + Roles.getCheckboxRole().setAriaCheckedState(item.getElement(), + value); + } } } @@ -238,4 +279,22 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, }); } } + + @Override + public void bindAriaCaption(Element captionElement) { + labelId = captionElement.getId(); + for (CheckBox item : optionsToKeys.keySet()) { + Roles.getCheckboxRole().setAriaLabelledbyProperty( + item.getElement(), Id.of(labelId)); + } + } + + @Override + public void clearAriaCaption() { + labelId = null; + for (CheckBox item : optionsToKeys.keySet()) { + Roles.getCheckboxRole().removeAriaLabelledbyProperty( + item.getElement()); + } + } } diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java index 2a2578aa16..dfa5625341 100644 --- a/client/src/com/vaadin/client/ui/VPopupCalendar.java +++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java @@ -18,6 +18,9 @@ package com.vaadin.client.ui; import java.util.Date; +import com.google.gwt.aria.client.Id; +import com.google.gwt.aria.client.LiveValue; +import com.google.gwt.aria.client.Roles; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -25,14 +28,18 @@ import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; +import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.PopupPanel.PositionCallback; +import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; import com.vaadin.client.VConsole; import com.vaadin.client.ui.VCalendarPanel.FocusOutListener; @@ -68,6 +75,10 @@ public class VPopupCalendar extends VTextualDate implements Field, private boolean textFieldEnabled = true; + private String captionId; + + private Label selectedDate; + public VPopupCalendar() { super(); @@ -75,6 +86,11 @@ public class VPopupCalendar extends VTextualDate implements Field, calendarToggle.addClickHandler(this); // -2 instead of -1 to avoid FocusWidget.onAttach to reset it calendarToggle.getElement().setTabIndex(-2); + + Roles.getButtonRole().set(calendarToggle.getElement()); + Roles.getButtonRole().setAriaHiddenState(calendarToggle.getElement(), + true); + add(calendarToggle); calendar = GWT.create(VCalendarPanel.class); @@ -88,6 +104,9 @@ public class VPopupCalendar extends VTextualDate implements Field, } }); + Roles.getButtonRole().setAriaControlsProperty( + calendarToggle.getElement(), Id.of(calendar.getElement())); + calendar.setSubmitListener(new SubmitListener() { @Override public void onSubmit() { @@ -109,7 +128,19 @@ public class VPopupCalendar extends VTextualDate implements Field, popup = new VOverlay(true, true, true); popup.setOwner(this); - popup.setWidget(calendar); + FlowPanel wrapper = new FlowPanel(); + selectedDate = new Label(); + selectedDate.setStyleName(getStylePrimaryName() + "-selecteddate"); + AriaHelper.visibleForAssistiveDevicesOnly(selectedDate.getElement()); + + Roles.getTextboxRole().setAriaLiveProperty(selectedDate.getElement(), + LiveValue.ASSERTIVE); + Roles.getTextboxRole().setAriaAtomicProperty(selectedDate.getElement(), + true); + wrapper.add(selectedDate); + wrapper.add(calendar); + + popup.setWidget(wrapper); popup.addCloseHandler(this); DOM.setElementProperty(calendar.getElement(), "id", @@ -181,9 +212,63 @@ public class VPopupCalendar extends VTextualDate implements Field, text.setEnabled(textFieldEnabled); if (textFieldEnabled) { calendarToggle.setTabIndex(-1); + Roles.getButtonRole().setAriaHiddenState( + calendarToggle.getElement(), true); } else { calendarToggle.setTabIndex(0); + Roles.getButtonRole().setAriaHiddenState( + calendarToggle.getElement(), false); + } + + handleAriaAttributes(); + } + + @Override + public void bindAriaCaption(Element captionElement) { + captionId = captionElement.getId(); + + if (isTextFieldEnabled()) { + super.bindAriaCaption(captionElement); + } else { + AriaHelper.bindCaption(calendarToggle, captionElement); + } + + handleAriaAttributes(); + } + + private void handleAriaAttributes() { + Widget removeFromWidget; + Widget setForWidget; + + if (isTextFieldEnabled()) { + setForWidget = text; + removeFromWidget = calendarToggle; + } else { + setForWidget = calendarToggle; + removeFromWidget = text; } + + Roles.getFormRole().removeAriaLabelledbyProperty( + removeFromWidget.getElement()); + if (captionId == null) { + Roles.getFormRole().removeAriaLabelledbyProperty( + setForWidget.getElement()); + } else { + Roles.getFormRole().setAriaLabelledbyProperty( + setForWidget.getElement(), Id.of(captionId)); + } + } + + @Override + public void clearAriaCaption() { + captionId = null; + if (isTextFieldEnabled()) { + super.clearAriaCaption(); + } else { + AriaHelper.clearCaption(calendarToggle); + } + + handleAriaAttributes(); } /* @@ -350,6 +435,32 @@ public class VPopupCalendar extends VTextualDate implements Field, calendar.setFocus(focus); } + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + if (enabled) { + Roles.getButtonRole().setAriaDisabledState( + calendarToggle.getElement(), true); + } else { + Roles.getButtonRole().setAriaDisabledState( + calendarToggle.getElement(), false); + } + } + + /** + * Sets the content of a special field for assistive devices, so that they + * can recognize the change and inform the user (reading out in case of + * screen reader) + * + * @param selectedDate + * Date that is currently selected + */ + public void setFocusedDate(Date selectedDate) { + this.selectedDate.setText(DateTimeFormat.getFormat("dd, MMMM, yyyy") + .format(selectedDate)); + } + /** * For internal use only. May be removed or replaced in the future. * diff --git a/client/src/com/vaadin/client/ui/VTextField.java b/client/src/com/vaadin/client/ui/VTextField.java index 0fbed0dd90..9b85dd22da 100644 --- a/client/src/com/vaadin/client/ui/VTextField.java +++ b/client/src/com/vaadin/client/ui/VTextField.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui; +import com.google.gwt.aria.client.Roles; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ChangeEvent; @@ -95,6 +96,9 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, } addFocusHandler(this); addBlurHandler(this); + + // Add a11y role "textbox" + Roles.getTextboxRole().set(node); } /** diff --git a/client/src/com/vaadin/client/ui/VTextualDate.java b/client/src/com/vaadin/client/ui/VTextualDate.java index 2f444a8587..97a868b69d 100644 --- a/client/src/com/vaadin/client/ui/VTextualDate.java +++ b/client/src/com/vaadin/client/ui/VTextualDate.java @@ -18,6 +18,7 @@ package com.vaadin.client.ui; import java.util.Date; +import com.google.gwt.aria.client.Roles; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ChangeEvent; @@ -34,7 +35,7 @@ import com.vaadin.shared.EventId; import com.vaadin.shared.ui.datefield.Resolution; public class VTextualDate extends VDateField implements Field, ChangeHandler, - Focusable, SubPartAware { + Focusable, SubPartAware, HandlesAriaCaption { private static final String PARSE_ERROR_CLASSNAME = "-parseerror"; @@ -96,6 +97,9 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler, } } }); + + Roles.getTextboxRole().set(text.getElement()); + add(text); } @@ -150,6 +154,16 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler, return formatStr; } + @Override + public void bindAriaCaption(Element captionElement) { + AriaHelper.bindCaption(text, captionElement); + } + + @Override + public void clearAriaCaption() { + AriaHelper.clearCaption(text); + } + /** * Updates the text field according to the current date (provided by * {@link #getDate()}). Takes care of updating text, enabling and disabling @@ -178,8 +192,12 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler, if (readonly) { text.addStyleName("v-readonly"); + Roles.getTextboxRole().setAriaReadonlyProperty(text.getElement(), + true); } else { text.removeStyleName("v-readonly"); + Roles.getTextboxRole() + .removeAriaReadonlyProperty(text.getElement()); } } @@ -348,5 +366,4 @@ public class VTextualDate extends VDateField implements Field, ChangeHandler, return null; } - } diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index d6d1cef8cc..6e3fffb47c 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import com.google.gwt.aria.client.Roles; import com.google.gwt.dom.client.Element; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; @@ -26,6 +27,7 @@ import com.vaadin.client.Paintable; import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; +import com.vaadin.client.VConsole; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.VTree; @@ -93,7 +95,7 @@ public class TreeConnector extends AbstractComponentConnector implements } childTree = getWidget().new TreeNode(); getConnection().getVTooltip().connectHandlersToWidget(childTree); - updateNodeFromUIDL(childTree, childUidl); + updateNodeFromUIDL(childTree, childUidl, 1); getWidget().body.add(childTree); childTree.addStyleDependentName("root"); childTree.childNodeContainer.addStyleDependentName("root"); @@ -108,6 +110,9 @@ public class TreeConnector extends AbstractComponentConnector implements getWidget().isMultiselect = "multi".equals(selectMode); if (getWidget().isMultiselect) { + Roles.getTreeRole().setAriaMultiselectableProperty( + getWidget().getElement(), true); + if (BrowserInfo.get().isTouchDevice()) { // Always use the simple mode for touch devices that do not have // shift/ctrl keys (#8595) @@ -116,6 +121,9 @@ public class TreeConnector extends AbstractComponentConnector implements getWidget().multiSelectMode = MultiSelectMode.valueOf(uidl .getStringAttribute("multiselectmode")); } + } else { + Roles.getTreeRole().setAriaMultiselectableProperty( + getWidget().getElement(), false); } getWidget().selectedIds = uidl.getStringArrayVariableAsSet("selected"); @@ -169,7 +177,18 @@ public class TreeConnector extends AbstractComponentConnector implements // expanding node happened server side rootNode.setState(true, false); } - renderChildNodes(rootNode, (Iterator) uidl.getChildIterator()); + String levelPropertyString = Roles.getTreeitemRole() + .getAriaLevelProperty(rootNode.getElement()); + int levelProperty; + try { + levelProperty = Integer.valueOf(levelPropertyString); + } catch (NumberFormatException e) { + levelProperty = 1; + VConsole.error(e); + } + + renderChildNodes(rootNode, (Iterator) uidl.getChildIterator(), + levelProperty + 1); } } @@ -196,7 +215,10 @@ public class TreeConnector extends AbstractComponentConnector implements } - public void updateNodeFromUIDL(TreeNode treeNode, UIDL uidl) { + public void updateNodeFromUIDL(TreeNode treeNode, UIDL uidl, int level) { + Roles.getTreeitemRole().setAriaLevelProperty(treeNode.getElement(), + level); + String nodeKey = uidl.getStringAttribute("key"); treeNode.setText(uidl .getStringAttribute(TreeConstants.ATTRIBUTE_NODE_CAPTION)); @@ -212,7 +234,8 @@ public class TreeConnector extends AbstractComponentConnector implements if (uidl.getChildCount() == 0) { treeNode.childNodeContainer.setVisible(false); } else { - renderChildNodes(treeNode, (Iterator) uidl.getChildIterator()); + renderChildNodes(treeNode, (Iterator) uidl.getChildIterator(), + level + 1); treeNode.childrenLoaded = true; } } else { @@ -243,7 +266,7 @@ public class TreeConnector extends AbstractComponentConnector implements .getStringAttribute(TreeConstants.ATTRIBUTE_NODE_ICON)); } - void renderChildNodes(TreeNode containerNode, Iterator i) { + void renderChildNodes(TreeNode containerNode, Iterator i, int level) { containerNode.childNodeContainer.clear(); containerNode.childNodeContainer.setVisible(true); while (i.hasNext()) { @@ -256,7 +279,7 @@ public class TreeConnector extends AbstractComponentConnector implements } final TreeNode childTree = getWidget().new TreeNode(); getConnection().getVTooltip().connectHandlersToWidget(childTree); - updateNodeFromUIDL(childTree, childUidl); + updateNodeFromUIDL(childTree, childUidl, level); containerNode.childNodeContainer.add(childTree); if (!i.hasNext()) { childTree diff --git a/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java index 126caa5985..4ffe7f806e 100644 --- a/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java +++ b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -1,6 +1,5 @@ package com.vaadin.tests.layouts; - import java.util.ArrayList; import java.util.List; -- cgit v1.2.3 From de0761b03d7f1acf2aad8ac824d5cb49b75f9391 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 21 Mar 2013 10:52:41 +0200 Subject: Moved CSSInjectWithColorpicker to correct package Change-Id: I8b7d283b68da60d236748364cac4c5ac3310f836 --- .../v71beta/CSSInjectWithColorpicker.java | 234 +++++++++++++++++++++ .../v71beta/CSSInjectWithColorpicker.java | 234 --------------------- 2 files changed, 234 insertions(+), 234 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java delete mode 100644 uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java new file mode 100644 index 0000000000..09c5f91293 --- /dev/null +++ b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java @@ -0,0 +1,234 @@ +package com.vaadin.tests.minitutorials.v71beta; + +import java.util.Arrays; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.Page; +import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.shared.ui.colorpicker.Color; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ColorPicker; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.components.colorpicker.ColorChangeEvent; +import com.vaadin.ui.components.colorpicker.ColorChangeListener; + +public class CSSInjectWithColorpicker extends UI { + + @Override + protected void init(VaadinRequest request) { + + // Create a text editor + Component editor = createEditor("Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + +"Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec."); + + + VerticalLayout content = new VerticalLayout(editor); + content.setMargin(true); + setContent(content); + } + + /** + * Creates a text editor for visually editing text + * + * @param text + * The text editor + * @return + */ + private Component createEditor(String text) { + + Panel editor = new Panel("Text Editor"); + editor.setWidth("580px"); + + VerticalLayout panelContent = new VerticalLayout(); + panelContent.setSpacing(true); + panelContent.setMargin(new MarginInfo(true, false, false, false)); + editor.setContent(panelContent); + + // Create the toolbar + HorizontalLayout toolbar = new HorizontalLayout(); + toolbar.setSpacing(true); + toolbar.setMargin(new MarginInfo(false, false, false, true)); + + // Create the font family selector + toolbar.addComponent(createFontSelect()); + + // Create the font size selector + toolbar.addComponent(createFontSizeSelect()); + + // Create the text color selector + toolbar.addComponent(createTextColorSelect()); + + // Create the background color selector + toolbar.addComponent(createBackgroundColorSelect()); + + panelContent.addComponent(toolbar); + panelContent.setComponentAlignment(toolbar, Alignment.MIDDLE_LEFT); + + // Spacer between toolbar and text + panelContent.addComponent(new Label("
", ContentMode.HTML)); + + // The text to edit + TextArea textLabel = new TextArea(null, text); + textLabel.setWidth("100%"); + textLabel.setHeight("200px"); + + // IMPORTANT: We are here setting the style name of the label, we are going to use this in our injected styles to target the label + textLabel.setStyleName("text-label"); + + panelContent.addComponent(textLabel); + + return editor; + } + + /** + * Creates a background color select dialog + */ + private Component createBackgroundColorSelect() { + ColorPicker bgColor = new ColorPicker("Background", Color.WHITE); + bgColor.setWidth("110px"); + bgColor.setCaption("Background"); + bgColor.addColorChangeListener(new ColorChangeListener() { + + @Override + public void colorChanged(ColorChangeEvent event) { + + // Get the new background color + Color color = event.getColor(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new background color + styles.inject(".v-app .v-textarea.text-label { background-color:" + + color.getCSS() + "; }"); + } + }); + return bgColor; + } + + /** + * Create a text color selction dialog + */ + private Component createTextColorSelect() { + + // Colorpicker for changing text color + ColorPicker textColor = new ColorPicker("Color", Color.BLACK); + textColor.setWidth("110px"); + textColor.setCaption("Color"); + textColor.addColorChangeListener(new ColorChangeListener() { + + @Override + public void colorChanged(ColorChangeEvent event) { + + // Get the new text color + Color color = event.getColor(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new color as a style + styles.inject(".v-app .v-textarea.text-label { color:" + + color.getCSS() + "; }"); + } + }); + + return textColor; + } + + /** + * Creates a font family selection dialog + */ + private Component createFontSelect() { + final ComboBox select = new ComboBox(null, Arrays.asList("Arial", + "Helvetica", "Verdana", "Courier", "Times", "sans-serif")); + select.setValue("Arial"); + select.setWidth("200px"); + select.setInputPrompt("Font"); + select.setDescription("Font"); + select.setImmediate(true); + select.setNullSelectionAllowed(false); + select.setNewItemsAllowed(false); + + select.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + // Get the new font family + String fontFamily = select.getValue().toString(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new font size as a style. We need .v-app to + // override Vaadin's default styles here + styles.inject(".v-app .v-textarea.text-label { font-family:" + + fontFamily + "; }"); + } + }); + + return select; + } + + /** + * Creates a font size selection control + */ + private Component createFontSizeSelect() { + + final ComboBox select = new ComboBox(null, Arrays.asList(8, 9, 10, + 12, 14, 16, 20, 25, 30, 40, 50)); + select.setWidth("100px"); + select.setValue(12); + select.setInputPrompt("Font size"); + select.setDescription("Font size"); + select.setImmediate(true); + select.setNullSelectionAllowed(false); + select.setNewItemsAllowed(false); + select.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + // Get the new font size + Integer fontSize = (Integer) select.getValue(); + + // Get the stylesheet of the page + StyleSheet styles = Page.getCurrent().getStyleSheet(); + + // inject the new font size as a style. We need .v-app to + // override Vaadin's default styles here + styles.inject(".v-app .v-textarea.text-label { font-size:" + + String.valueOf(fontSize) + "px; }"); + } + }); + + return select; + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java deleted file mode 100644 index 4ac85ab231..0000000000 --- a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v71beta/CSSInjectWithColorpicker.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.vaadin.tests.widgetset.client.minitutorials.v71beta; - -import java.util.Arrays; - -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.server.Page; -import com.vaadin.server.Page.StyleSheet; -import com.vaadin.server.VaadinRequest; -import com.vaadin.shared.ui.MarginInfo; -import com.vaadin.shared.ui.colorpicker.Color; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.ColorPicker; -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Component; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextArea; -import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.components.colorpicker.ColorChangeEvent; -import com.vaadin.ui.components.colorpicker.ColorChangeListener; - -public class CSSInjectWithColorpicker extends UI { - - @Override - protected void init(VaadinRequest request) { - - // Create a text editor - Component editor = createEditor("Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - +"Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec."); - - - VerticalLayout content = new VerticalLayout(editor); - content.setMargin(true); - setContent(content); - } - - /** - * Creates a text editor for visually editing text - * - * @param text - * The text editor - * @return - */ - private Component createEditor(String text) { - - Panel editor = new Panel("Text Editor"); - editor.setWidth("580px"); - - VerticalLayout panelContent = new VerticalLayout(); - panelContent.setSpacing(true); - panelContent.setMargin(new MarginInfo(true, false, false, false)); - editor.setContent(panelContent); - - // Create the toolbar - HorizontalLayout toolbar = new HorizontalLayout(); - toolbar.setSpacing(true); - toolbar.setMargin(new MarginInfo(false, false, false, true)); - - // Create the font family selector - toolbar.addComponent(createFontSelect()); - - // Create the font size selector - toolbar.addComponent(createFontSizeSelect()); - - // Create the text color selector - toolbar.addComponent(createTextColorSelect()); - - // Create the background color selector - toolbar.addComponent(createBackgroundColorSelect()); - - panelContent.addComponent(toolbar); - panelContent.setComponentAlignment(toolbar, Alignment.MIDDLE_LEFT); - - // Spacer between toolbar and text - panelContent.addComponent(new Label("
", ContentMode.HTML)); - - // The text to edit - TextArea textLabel = new TextArea(null, text); - textLabel.setWidth("100%"); - textLabel.setHeight("200px"); - - // IMPORTANT: We are here setting the style name of the label, we are going to use this in our injected styles to target the label - textLabel.setStyleName("text-label"); - - panelContent.addComponent(textLabel); - - return editor; - } - - /** - * Creates a background color select dialog - */ - private Component createBackgroundColorSelect() { - ColorPicker bgColor = new ColorPicker("Background", Color.WHITE); - bgColor.setWidth("110px"); - bgColor.setCaption("Background"); - bgColor.addColorChangeListener(new ColorChangeListener() { - - @Override - public void colorChanged(ColorChangeEvent event) { - - // Get the new background color - Color color = event.getColor(); - - // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); - - // inject the new background color - styles.inject(".v-app .v-textarea.text-label { background-color:" - + color.getCSS() + "; }"); - } - }); - return bgColor; - } - - /** - * Create a text color selction dialog - */ - private Component createTextColorSelect() { - - // Colorpicker for changing text color - ColorPicker textColor = new ColorPicker("Color", Color.BLACK); - textColor.setWidth("110px"); - textColor.setCaption("Color"); - textColor.addColorChangeListener(new ColorChangeListener() { - - @Override - public void colorChanged(ColorChangeEvent event) { - - // Get the new text color - Color color = event.getColor(); - - // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); - - // inject the new color as a style - styles.inject(".v-app .v-textarea.text-label { color:" - + color.getCSS() + "; }"); - } - }); - - return textColor; - } - - /** - * Creates a font family selection dialog - */ - private Component createFontSelect() { - final ComboBox select = new ComboBox(null, Arrays.asList("Arial", - "Helvetica", "Verdana", "Courier", "Times", "sans-serif")); - select.setValue("Arial"); - select.setWidth("200px"); - select.setInputPrompt("Font"); - select.setDescription("Font"); - select.setImmediate(true); - select.setNullSelectionAllowed(false); - select.setNewItemsAllowed(false); - - select.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - // Get the new font family - String fontFamily = select.getValue().toString(); - - // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); - - // inject the new font size as a style. We need .v-app to - // override Vaadin's default styles here - styles.inject(".v-app .v-textarea.text-label { font-family:" - + fontFamily + "; }"); - } - }); - - return select; - } - - /** - * Creates a font size selection control - */ - private Component createFontSizeSelect() { - - final ComboBox select = new ComboBox(null, Arrays.asList(8, 9, 10, - 12, 14, 16, 20, 25, 30, 40, 50)); - select.setWidth("100px"); - select.setValue(12); - select.setInputPrompt("Font size"); - select.setDescription("Font size"); - select.setImmediate(true); - select.setNullSelectionAllowed(false); - select.setNewItemsAllowed(false); - select.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - // Get the new font size - Integer fontSize = (Integer) select.getValue(); - - // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); - - // inject the new font size as a style. We need .v-app to - // override Vaadin's default styles here - styles.inject(".v-app .v-textarea.text-label { font-size:" - + String.valueOf(fontSize) + "px; }"); - } - }); - - return select; - } -} -- cgit v1.2.3 From 4570ac9d812bfe80cf6c44c6f9b2a0eeb5101d4f Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 26 Mar 2013 00:44:59 +0200 Subject: Id changed because of id generation for wai-aria Change-Id: Ib216994e540d34179fc0e5498e0461bdf82f8794 --- .../tests/components/table/ColumnCollapsingAndColumnExpansion.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html b/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html index 69b436a41b..261d1939cd 100644 --- a/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html +++ b/uitest/src/com/vaadin/tests/components/table/ColumnCollapsingAndColumnExpansion.html @@ -30,7 +30,7 @@ click - //td[@id='gwt-uid-4']/span/div + //td[@id='gwt-uid-7']/span/div -- cgit v1.2.3 From a2a8666118de8b8f746e631a3aab4c58d2d4a6af Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Sun, 24 Mar 2013 16:38:45 +0200 Subject: Added Page.reload (#10250) Change-Id: I8ec7edbc370388d8b36a474a8845e846395f26ed --- .../src/com/vaadin/client/ui/ui/UIConnector.java | 6 +++ server/src/com/vaadin/server/Page.java | 7 ++++ .../src/com/vaadin/shared/ui/ui/PageClientRpc.java | 2 + .../vaadin/tests/components/page/PageReload.html | 46 ++++++++++++++++++++++ .../vaadin/tests/components/page/PageReload.java | 34 ++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/page/PageReload.html create mode 100644 uitest/src/com/vaadin/tests/components/page/PageReload.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 4f0ea2de37..1df74afd2e 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -97,6 +97,12 @@ public class UIConnector extends AbstractSingleComponentContainerConnector public void setTitle(String title) { com.google.gwt.user.client.Window.setTitle(title); } + + @Override + public void reload() { + Window.Location.reload(); + + } }); registerRpc(ScrollClientRpc.class, new ScrollClientRpc() { @Override diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index f7b65a8e9b..e84271e883 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -1041,4 +1041,11 @@ public class Page implements Serializable { uI.getRpcProxy(PageClientRpc.class).setTitle(title); } + /** + * Reloads the page in the browser. + */ + public void reload() { + uI.getRpcProxy(PageClientRpc.class).reload(); + } + } diff --git a/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java b/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java index 3d8f607cb8..eb847bacd0 100644 --- a/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java +++ b/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java @@ -22,4 +22,6 @@ public interface PageClientRpc extends ClientRpc { public void setTitle(String title); + public void reload(); + } diff --git a/uitest/src/com/vaadin/tests/components/page/PageReload.html b/uitest/src/com/vaadin/tests/components/page/PageReload.html new file mode 100644 index 0000000000..20d61a48f1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/page/PageReload.html @@ -0,0 +1,46 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.page.PageReload?restartApplication
assertTextvaadin=runcomvaadintestscomponentspagePageReload::PID_SLog_row_01. UI id: 0
open/run/com.vaadin.tests.components.page.PageReload
assertTextvaadin=runcomvaadintestscomponentspagePageReload::PID_SLog_row_01. UI id: 1
clickAndWaitvaadin=runcomvaadintestscomponentspagePageReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runcomvaadintestscomponentspagePageReload::PID_SLog_row_01. UI id: 2
+ + diff --git a/uitest/src/com/vaadin/tests/components/page/PageReload.java b/uitest/src/com/vaadin/tests/components/page/PageReload.java new file mode 100644 index 0000000000..c1799b29e3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/page/PageReload.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.components.page; + +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.Button.ClickListener; + +public class PageReload extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + Button b = new Button("Press to reload"); + b.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + getPage().reload(); + } + }); + addComponent(b); + log("UI id: " + getUIId()); + } + + @Override + protected String getTestDescription() { + return "Tests Page.reload(). Click button to refresh the page."; + } + + @Override + protected Integer getTicketNumber() { + return 10250; + } + +} -- cgit v1.2.3 From d4fcfdf7aa21899e8a621d48b8c1bb75fbd46c62 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 22 Mar 2013 17:45:26 +0200 Subject: Ensure session is locked during cleanup (#10569) * At the same time ensures request timer handling is done while session is locked (#10108) Change-Id: Ifc36e1ac66d02e25fe98616319c014137bd94c10 --- server/src/com/vaadin/server/VaadinService.java | 39 +++++++++++---- .../src/com/vaadin/server/VaadinSessionTest.java | 57 +++++++++++++++++----- .../tests/applicationcontext/CloseSession.java | 16 +++++- 3 files changed, 89 insertions(+), 23 deletions(-) (limited to 'uitest/src') diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 20d87d6554..e4970d4104 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -1024,13 +1024,19 @@ public abstract class VaadinService implements Serializable { * * @param session */ - private void removeClosedUIs(VaadinSession session) { - for (UI ui : new ArrayList(session.getUIs())) { - if (ui.isClosing()) { - getLogger().log(Level.FINER, "Removing closed UI {0}", - ui.getUIId()); - session.removeUI(ui); - } + private void removeClosedUIs(final VaadinSession session) { + ArrayList uis = new ArrayList(session.getUIs()); + for (final UI ui : uis) { + ui.runSafely(new Runnable() { + @Override + public void run() { + if (ui.isClosing()) { + getLogger().log(Level.FINER, "Removing closed UI {0}", + ui.getUIId()); + session.removeUI(ui); + } + } + }); } } @@ -1177,10 +1183,23 @@ public abstract class VaadinService implements Serializable { public void requestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) { if (session != null) { - cleanupSession(session); - long duration = (System.nanoTime() - (Long) request + final VaadinSession finalSession = session; + + session.runSafely(new Runnable() { + @Override + public void run() { + cleanupSession(finalSession); + } + }); + + final long duration = (System.nanoTime() - (Long) request .getAttribute(REQUEST_START_TIME_ATTRIBUTE)) / 1000000; - session.setLastRequestDuration(duration); + session.runSafely(new Runnable() { + @Override + public void run() { + finalSession.setLastRequestDuration(duration); + } + }); } CurrentInstance.clearAll(); } diff --git a/server/tests/src/com/vaadin/server/VaadinSessionTest.java b/server/tests/src/com/vaadin/server/VaadinSessionTest.java index 6cad3307bf..e433e6fd05 100644 --- a/server/tests/src/com/vaadin/server/VaadinSessionTest.java +++ b/server/tests/src/com/vaadin/server/VaadinSessionTest.java @@ -25,30 +25,38 @@ import javax.servlet.http.HttpSessionBindingEvent; import junit.framework.Assert; import org.easymock.EasyMock; +import org.junit.Before; import org.junit.Test; import com.vaadin.server.ClientConnector.DetachEvent; import com.vaadin.server.ClientConnector.DetachListener; import com.vaadin.ui.UI; +import com.vaadin.util.CurrentInstance; public class VaadinSessionTest { - @Test - public void threadLocalsAfterUnderlyingSessionTimeout() { - - final VaadinServlet mockServlet = new VaadinServlet() { + private VaadinSession session; + private VaadinServlet mockServlet; + private VaadinServletService mockService; + private HttpSession mockHttpSession; + private WrappedSession mockWrappedSession; + private VaadinServletRequest vaadinRequest; + private UI ui; + + @Before + public void setup() { + mockServlet = new VaadinServlet() { @Override public String getServletName() { return "mockServlet"; }; }; - final VaadinServletService mockService = new VaadinServletService( - mockServlet, EasyMock.createMock(DeploymentConfiguration.class)); + mockService = new VaadinServletService(mockServlet, + EasyMock.createMock(DeploymentConfiguration.class)); - HttpSession mockHttpSession = EasyMock.createMock(HttpSession.class); - WrappedSession mockWrappedSession = new WrappedHttpSession( - mockHttpSession) { + mockHttpSession = EasyMock.createMock(HttpSession.class); + mockWrappedSession = new WrappedHttpSession(mockHttpSession) { final ReentrantLock lock = new ReentrantLock(); @Override @@ -60,10 +68,10 @@ public class VaadinSessionTest { } }; - final VaadinSession session = new VaadinSession(mockService); + session = new VaadinSession(mockService); session.storeInSession(mockService, mockWrappedSession); - final UI ui = new UI() { + ui = new UI() { Page page = new Page(this) { @Override public void init(VaadinRequest request) { @@ -79,7 +87,7 @@ public class VaadinSessionTest { return page; } }; - VaadinServletRequest vaadinRequest = new VaadinServletRequest( + vaadinRequest = new VaadinServletRequest( EasyMock.createMock(HttpServletRequest.class), mockService) { @Override public String getParameter(String name) { @@ -96,6 +104,11 @@ public class VaadinSessionTest { ui.setSession(session); session.addUI(ui); + } + + @Test + public void threadLocalsAfterUnderlyingSessionTimeout() { + final AtomicBoolean detachCalled = new AtomicBoolean(false); ui.addDetachListener(new DetachListener() { @Override @@ -112,4 +125,24 @@ public class VaadinSessionTest { session.valueUnbound(EasyMock.createMock(HttpSessionBindingEvent.class)); Assert.assertTrue(detachCalled.get()); } + + @Test + public void threadLocalsAfterSessionDestroy() { + final AtomicBoolean detachCalled = new AtomicBoolean(false); + ui.addDetachListener(new DetachListener() { + @Override + public void detach(DetachEvent event) { + detachCalled.set(true); + Assert.assertEquals(ui, UI.getCurrent()); + Assert.assertEquals(ui.getPage(), Page.getCurrent()); + Assert.assertEquals(session, VaadinSession.getCurrent()); + Assert.assertEquals(mockService, VaadinService.getCurrent()); + Assert.assertEquals(mockServlet, VaadinServlet.getCurrent()); + } + }); + CurrentInstance.clearAll(); + session.close(); + mockService.cleanupSession(session); + Assert.assertTrue(detachCalled.get()); + } } diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java index 446638f8a2..cca76cc9e3 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java @@ -18,13 +18,16 @@ package com.vaadin.tests.applicationcontext; import javax.servlet.http.HttpSession; +import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinSession; import com.vaadin.server.WrappedHttpSession; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.UI; public class CloseSession extends AbstractTestUI { private static final String OLD_HASH_PARAM = "oldHash"; @@ -158,6 +161,17 @@ public class CloseSession extends AbstractTestUI { @Override public void detach() { super.detach(); - System.out.println("UI " + getUIId() + " detached"); + log.log("Detach of " + this + " (" + getUIId() + ")"); + boolean correctUI = (UI.getCurrent() == this); + boolean correctPage = (Page.getCurrent() == getPage()); + boolean correctVaadinSession = (VaadinSession.getCurrent() == getSession()); + boolean correctVaadinService = (VaadinService.getCurrent() == getSession() + .getService()); + log.log("UI.current correct in detach: " + correctUI); + log.log("Page.current correct in detach: " + correctPage); + log.log("VaadinSession.current correct in detach: " + + correctVaadinSession); + log.log("VaadinService.current correct in detach: " + + correctVaadinService); } } -- cgit v1.2.3 From cbd3badb929e0253a44ae19464b6dd0caebca968 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 26 Mar 2013 10:51:50 +0200 Subject: Fixed locking issue in tests Change-Id: I3706cfa46f82615b8cc677bcaaa207d5ab05bf40 --- .../tests/data/converter/ConverterFactory.java | 9 +++++---- .../tests/server/AlwaysLockedVaadinSession.java | 23 ++++++++++++++++++++++ .../tests/server/TestStreamVariableMapping.java | 11 +++++++++-- .../clientconnector/AttachDetachListeners.java | 4 +++- .../AbstractFieldValueConversions.java | 9 +++++---- .../abstractfield/DefaultConverterFactory.java | 5 +++-- .../abstractfield/RemoveListenersOnDetach.java | 3 ++- .../component/fieldgroup/BeanFieldGroupTest.java | 1 + .../server/component/label/LabelConverters.java | 3 ++- .../server/component/ui/CustomUIClassLoader.java | 3 ++- .../component/window/AddRemoveSubWindow.java | 3 ++- .../component/window/AttachDetachWindow.java | 3 ++- .../tests/src/com/vaadin/ui/LabelDataSource.java | 3 ++- .../util/ReflectToolsGetFieldValueByType.java | 2 -- .../tests/application/ThreadLocalInstances.java | 7 ++++++- 15 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java (limited to 'uitest/src') diff --git a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java index 5067da8861..bf4412fbce 100644 --- a/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java @@ -22,6 +22,7 @@ import junit.framework.TestCase; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.DefaultConverterFactory; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; public class ConverterFactory extends TestCase { @@ -66,7 +67,7 @@ public class ConverterFactory extends TestCase { public void testApplicationConverterFactoryInBackgroundThread() { VaadinSession.setCurrent(null); - final VaadinSession appWithCustomIntegerConverter = new VaadinSession( + final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession( null); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); @@ -84,7 +85,7 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryForDetachedComponent() { - final VaadinSession appWithCustomIntegerConverter = new VaadinSession( + final VaadinSession appWithCustomIntegerConverter = new AlwaysLockedVaadinSession( null); appWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); @@ -98,11 +99,11 @@ public class ConverterFactory extends TestCase { } public void testApplicationConverterFactoryForDifferentThanCurrentApplication() { - final VaadinSession fieldAppWithCustomIntegerConverter = new VaadinSession( + final VaadinSession fieldAppWithCustomIntegerConverter = new AlwaysLockedVaadinSession( null); fieldAppWithCustomIntegerConverter .setConverterFactory(new ConverterFactory42()); - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("", "123") { @Override diff --git a/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java b/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java new file mode 100644 index 0000000000..49e761f8b1 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/AlwaysLockedVaadinSession.java @@ -0,0 +1,23 @@ +package com.vaadin.tests.server; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinSession; + +public class AlwaysLockedVaadinSession extends VaadinSession { + + private ReentrantLock lock; + + public AlwaysLockedVaadinSession(VaadinService service) { + super(service); + lock = new ReentrantLock(); + lock.lock(); + } + + @Override + public Lock getLockInstance() { + return lock; + } +} diff --git a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java index 68fbdb8d0d..da0bf9ebc8 100644 --- a/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java +++ b/server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java @@ -4,9 +4,12 @@ import junit.framework.TestCase; import org.easymock.EasyMock; +import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.StreamVariable; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinServlet; +import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.UI; @@ -22,7 +25,7 @@ public class TestStreamVariableMapping extends TestCase { @Override protected void setUp() throws Exception { - final VaadinSession application = new VaadinSession(null); + final VaadinSession application = new AlwaysLockedVaadinSession(null); final UI uI = new UI() { @Override protected void init(VaadinRequest request) { @@ -73,7 +76,11 @@ public class TestStreamVariableMapping extends TestCase { } private LegacyCommunicationManager createCommunicationManager() { - return new LegacyCommunicationManager(new VaadinSession(null)); + VaadinServletService vss = new VaadinServletService( + EasyMock.createMock(VaadinServlet.class), + EasyMock.createMock(DeploymentConfiguration.class)); + return new LegacyCommunicationManager( + new AlwaysLockedVaadinSession(vss)); } } diff --git a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java index 8a61ec6352..f8dbaccdad 100644 --- a/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java +++ b/server/tests/src/com/vaadin/tests/server/clientconnector/AttachDetachListeners.java @@ -18,6 +18,7 @@ import com.vaadin.server.ClientConnector.DetachListener; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.Component; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; @@ -40,7 +41,8 @@ public class AttachDetachListeners { public void setUp() { control = EasyMock.createStrictControl(); - session = new VaadinSession(control.createMock(VaadinService.class)); + session = new AlwaysLockedVaadinSession( + control.createMock(VaadinService.class)); ui = new UI() { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java index cd77101ac3..144ca0fe24 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java @@ -17,6 +17,7 @@ import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.CheckBox; import com.vaadin.ui.TextField; @@ -45,7 +46,7 @@ public class AbstractFieldValueConversions extends TestCase { } public void testNonmodifiedBufferedFieldConversion() { - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("salary"); tf.setBuffered(true); tf.setLocale(new Locale("en", "US")); @@ -61,7 +62,7 @@ public class AbstractFieldValueConversions extends TestCase { } public void testModifiedBufferedFieldConversion() { - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("salary"); tf.setBuffered(true); tf.setLocale(new Locale("en", "US")); @@ -129,7 +130,7 @@ public class AbstractFieldValueConversions extends TestCase { } public void testChangeReadOnlyFieldLocale() { - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TextField tf = new TextField("salary"); tf.setLocale(new Locale("en", "US")); @@ -214,7 +215,7 @@ public class AbstractFieldValueConversions extends TestCase { } public void testNumberDoubleConverterChange() { - final VaadinSession a = new VaadinSession(null); + final VaadinSession a = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(a); TextField tf = new TextField() { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java index 698e9bcee4..5455da18f8 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/DefaultConverterFactory.java @@ -11,6 +11,7 @@ import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.Sex; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.TextField; public class DefaultConverterFactory extends TestCase { @@ -53,7 +54,7 @@ public class DefaultConverterFactory extends TestCase { } public void testFloatConversion() { - VaadinSession sess = new VaadinSession(null); + VaadinSession sess = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(sess); TextField tf = new TextField(); @@ -68,7 +69,7 @@ public class DefaultConverterFactory extends TestCase { } public void testDefaultNumberConversion() { - VaadinSession app = new VaadinSession(null); + VaadinSession app = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(app); TextField tf = new TextField(); tf.setLocale(new Locale("en", "US")); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index cd9b6c6631..6dfd50c44c 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -9,6 +9,7 @@ import com.vaadin.data.util.AbstractProperty; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.AbstractField; import com.vaadin.ui.UI; @@ -18,7 +19,7 @@ public class RemoveListenersOnDetach { int numReadOnlyChanges = 0; AbstractField field = new AbstractField() { - final private VaadinSession application = new VaadinSession(null); + final private VaadinSession application = new AlwaysLockedVaadinSession(null); private UI uI = new UI() { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java index 68c1133dc0..44b77e88e2 100644 --- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/BeanFieldGroupTest.java @@ -3,6 +3,7 @@ package com.vaadin.tests.server.component.fieldgroup; import static org.junit.Assert.assertEquals; import org.junit.Test; + import com.vaadin.data.fieldgroup.BeanFieldGroup; public class BeanFieldGroupTest { diff --git a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java index 7fd2930865..13da46cd60 100644 --- a/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java +++ b/server/tests/src/com/vaadin/tests/server/component/label/LabelConverters.java @@ -21,6 +21,7 @@ import com.vaadin.data.Property; import com.vaadin.data.util.MethodProperty; import com.vaadin.server.VaadinSession; import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.Label; public class LabelConverters extends TestCase { @@ -37,7 +38,7 @@ public class LabelConverters extends TestCase { } public void testIntegerDataSource() { - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); Label l = new Label("Foo"); Property ds = new MethodProperty(Person.createTestPerson1(), "age"); diff --git a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java index 8884c0c27c..186f563569 100644 --- a/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java +++ b/server/tests/src/com/vaadin/tests/server/component/ui/CustomUIClassLoader.java @@ -15,6 +15,7 @@ import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.UI; public class CustomUIClassLoader extends TestCase { @@ -113,7 +114,7 @@ public class CustomUIClassLoader extends TestCase { } private VaadinSession createStubApplication() { - return new VaadinSession(null) { + return new AlwaysLockedVaadinSession(null) { @Override public DeploymentConfiguration getConfiguration() { return createConfigurationMock(); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java index bf6d127a83..15d3707f28 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java @@ -8,6 +8,7 @@ import org.junit.Test; import com.vaadin.server.LegacyApplication; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.LegacyWindow; import com.vaadin.ui.UI; import com.vaadin.ui.Window; @@ -25,7 +26,7 @@ public class AddRemoveSubWindow { @Test public void addSubWindow() { - VaadinSession.setCurrent(new VaadinSession(null)); + VaadinSession.setCurrent(new AlwaysLockedVaadinSession(null)); TestApp app = new TestApp(); app.init(); Window subWindow = new Window("Sub window"); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java index 63a58bcab3..4dfadc23a1 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java @@ -8,6 +8,7 @@ import org.junit.Test; import com.vaadin.server.ClientConnector; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; import com.vaadin.ui.Label; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; @@ -15,7 +16,7 @@ import com.vaadin.ui.Window; public class AttachDetachWindow { - private VaadinSession testApp = new VaadinSession(null); + private VaadinSession testApp = new AlwaysLockedVaadinSession(null); private interface TestContainer { public boolean attachCalled(); diff --git a/server/tests/src/com/vaadin/ui/LabelDataSource.java b/server/tests/src/com/vaadin/ui/LabelDataSource.java index 7dcb382124..87ca4e372c 100644 --- a/server/tests/src/com/vaadin/ui/LabelDataSource.java +++ b/server/tests/src/com/vaadin/ui/LabelDataSource.java @@ -24,6 +24,7 @@ import org.junit.Test; import com.vaadin.data.util.ObjectProperty; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinSession; +import com.vaadin.tests.server.AlwaysLockedVaadinSession; public class LabelDataSource { @@ -39,7 +40,7 @@ public class LabelDataSource { @Before public void setup() { - vaadinSession = new VaadinSession(null); + vaadinSession = new AlwaysLockedVaadinSession(null); VaadinSession.setCurrent(vaadinSession); label = new Label(); diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java index 78be9b04fb..718a76804f 100644 --- a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java +++ b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java @@ -3,8 +3,6 @@ package com.vaadin.util; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.lang.reflect.InvocationTargetException; - import org.junit.Test; public class ReflectToolsGetFieldValueByType { diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java index b6774ae56a..ed611117d0 100644 --- a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java @@ -52,7 +52,12 @@ public class ThreadLocalInstances extends AbstractTestCase { private final FlagSeResource resource = new FlagSeResource() { @Override public DownloadStream getStream() { - reportCurrentStatus("resource handler"); + ThreadLocalInstances.this.getContext().lock(); + try { + reportCurrentStatus("resource handler"); + } finally { + ThreadLocalInstances.this.getContext().unlock(); + } return super.getStream(); } }; -- cgit v1.2.3 From 9586a30b64bfd1e8645574d9d7b6568d52dc9e25 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 25 Mar 2013 21:54:36 +0200 Subject: Made is possible to configure tooltip on the server (#8065) Change-Id: I35af6df1dfa75ef1de1268eb630fc0f4b9306170 --- client/src/com/vaadin/client/VTooltip.java | 138 +++++++++++- .../src/com/vaadin/client/ui/ui/UIConnector.java | 17 ++ server/src/com/vaadin/ui/Tooltip.java | 240 +++++++++++++++++++++ server/src/com/vaadin/ui/UI.java | 11 + shared/src/com/vaadin/shared/ui/ui/UIState.java | 12 ++ .../tests/components/ui/TooltipConfiguration.html | 135 ++++++++++++ .../tests/components/ui/TooltipConfiguration.java | 107 +++++++++ 7 files changed, 650 insertions(+), 10 deletions(-) create mode 100644 server/src/com/vaadin/ui/Tooltip.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html create mode 100644 uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index e6d9a79a5b..53770f4201 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -48,11 +48,6 @@ public class VTooltip extends VOverlay { public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE | Event.ONCLICK; - protected static final int MAX_WIDTH = 500; - private static final int QUICK_OPEN_TIMEOUT = 1000; - private static final int CLOSE_TIMEOUT = 300; - private static final int OPEN_DELAY = 750; - private static final int QUICK_OPEN_DELAY = 100; VErrorMessage em = new VErrorMessage(); Element description = DOM.createDiv(); @@ -64,6 +59,13 @@ public class VTooltip extends VOverlay { private String uniqueId = DOM.createUniqueId(); private Element layoutElement; + private int maxWidth; + + // Delays for the tooltip, configurable on the server side + private int openDelay; + private int quickOpenDelay; + private int quickOpenTimeout; + private int closeTimeout; /** * Used to show tooltips; usually used via the singleton in @@ -126,8 +128,8 @@ public class VTooltip extends VOverlay { @Override public void setPosition(int offsetWidth, int offsetHeight) { - if (offsetWidth > MAX_WIDTH) { - setWidth(MAX_WIDTH + "px"); + if (offsetWidth > getMaxWidth()) { + setWidth(getMaxWidth() + "px"); // Check new height and width with reflowed content offsetWidth = getOffsetWidth(); @@ -172,7 +174,7 @@ public class VTooltip extends VOverlay { // Schedule timer for showing the tooltip according to if it was // recently closed or not. - int timeout = justClosed ? QUICK_OPEN_DELAY : OPEN_DELAY; + int timeout = justClosed ? getQuickOpenDelay() : getOpenDelay(); showTimer.schedule(timeout); opening = true; } @@ -222,10 +224,10 @@ public class VTooltip extends VOverlay { // already about to close return; } - closeTimer.schedule(CLOSE_TIMEOUT); + closeTimer.schedule(getCloseTimeout()); closing = true; justClosed = true; - justClosedTimer.schedule(QUICK_OPEN_TIMEOUT); + justClosedTimer.schedule(getQuickOpenTimeout()); } @Override @@ -466,4 +468,120 @@ public class VTooltip extends VOverlay { Roles.getTooltipRole().setAriaHiddenState(layoutElement, false); } + + /** + * Returns the time (in ms) the tooltip should be displayed after an event + * that will cause it to be closed (e.g. mouse click outside the component, + * key down). + * + * @return The close timeout (in ms) + */ + public int getCloseTimeout() { + return closeTimeout; + } + + /** + * Sets the time (in ms) the tooltip should be displayed after an event that + * will cause it to be closed (e.g. mouse click outside the component, key + * down). + * + * @param closeTimeout + * The close timeout (in ms) + */ + public void setCloseTimeout(int closeTimeout) { + this.closeTimeout = closeTimeout; + } + + /** + * Returns the time (in ms) during which {@link #getQuickOpenDelay()} should + * be used instead of {@link #getOpenDelay()}. The quick open delay is used + * when the tooltip has very recently been shown, is currently hidden but + * about to be shown again. + * + * @return The quick open timeout (in ms) + */ + public int getQuickOpenTimeout() { + return quickOpenTimeout; + } + + /** + * Sets the time (in ms) that determines when {@link #getQuickOpenDelay()} + * should be used instead of {@link #getOpenDelay()}. The quick open delay + * is used when the tooltip has very recently been shown, is currently + * hidden but about to be shown again. + * + * @param quickOpenTimeout + * The quick open timeout (in ms) + */ + public void setQuickOpenTimeout(int quickOpenTimeout) { + this.quickOpenTimeout = quickOpenTimeout; + } + + /** + * Returns the time (in ms) that should elapse before a tooltip will be + * shown, in the situation when a tooltip has very recently been shown + * (within {@link #getQuickOpenDelay()} ms). + * + * @return The quick open delay (in ms) + */ + public int getQuickOpenDelay() { + return quickOpenDelay; + } + + /** + * Sets the time (in ms) that should elapse before a tooltip will be shown, + * in the situation when a tooltip has very recently been shown (within + * {@link #getQuickOpenDelay()} ms). + * + * @param quickOpenDelay + * The quick open delay (in ms) + */ + public void setQuickOpenDelay(int quickOpenDelay) { + this.quickOpenDelay = quickOpenDelay; + } + + /** + * Returns the time (in ms) that should elapse after an event triggering + * tooltip showing has occurred (e.g. mouse over) before the tooltip is + * shown. If a tooltip has recently been shown, then + * {@link #getQuickOpenDelay()} is used instead of this. + * + * @return The open delay (in ms) + */ + public int getOpenDelay() { + return openDelay; + } + + /** + * Sets the time (in ms) that should elapse after an event triggering + * tooltip showing has occurred (e.g. mouse over) before the tooltip is + * shown. If a tooltip has recently been shown, then + * {@link #getQuickOpenDelay()} is used instead of this. + * + * @param openDelay + * The open delay (in ms) + */ + public void setOpenDelay(int openDelay) { + this.openDelay = openDelay; + } + + /** + * Sets the maximum width of the tooltip popup. + * + * @param maxWidth + * The maximum width the tooltip popup (in pixels) + */ + public void setMaxWidth(int maxWidth) { + this.maxWidth = maxWidth; + } + + /** + * Returns the maximum width of the tooltip popup. + * + * @return The maximum width the tooltip popup (in pixels) + */ + public int getMaxWidth() { + return maxWidth; + } + } diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 1df74afd2e..b8b7786d21 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -599,4 +599,21 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } }); } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + if (stateChangeEvent.hasPropertyChanged("tooltipConfiguration")) { + getConnection().getVTooltip().setCloseTimeout( + getState().tooltipConfiguration.closeTimeout); + getConnection().getVTooltip().setOpenDelay( + getState().tooltipConfiguration.openDelay); + getConnection().getVTooltip().setQuickOpenDelay( + getState().tooltipConfiguration.quickOpenDelay); + getConnection().getVTooltip().setQuickOpenTimeout( + getState().tooltipConfiguration.quickOpenTimeout); + getConnection().getVTooltip().setMaxWidth( + getState().tooltipConfiguration.maxWidth); + } + } } diff --git a/server/src/com/vaadin/ui/Tooltip.java b/server/src/com/vaadin/ui/Tooltip.java new file mode 100644 index 0000000000..093bb33b51 --- /dev/null +++ b/server/src/com/vaadin/ui/Tooltip.java @@ -0,0 +1,240 @@ +/* + * Copyright 2000-2013 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.ui; + +import java.io.Serializable; + +import com.vaadin.shared.ui.ui.UIState.TooltipConfiguration; + +/** + * Provides method for configuring the tooltip. + * + * @author Vaadin Ltd + * @since 7.1 + */ +public interface Tooltip extends Serializable { + /** + * Returns the time (in ms) the tooltip should be displayed after an event + * that will cause it to be closed (e.g. mouse click outside the component, + * key down). + * + * @return The close timeout + */ + public int getCloseTimeout(); + + /** + * Sets the time (in ms) the tooltip should be displayed after an event that + * will cause it to be closed (e.g. mouse click outside the component, key + * down). + * + * @param closeTimeout + * The close timeout + */ + public void setCloseTimeout(int closeTimeout); + + /** + * Returns the time (in ms) during which {@link #getQuickOpenDelay()} should + * be used instead of {@link #getOpenDelay()}. The quick open delay is used + * when the tooltip has very recently been shown, is currently hidden but + * about to be shown again. + * + * @return The quick open timeout + */ + public int getQuickOpenTimeout(); + + /** + * Sets the time (in ms) that determines when {@link #getQuickOpenDelay()} + * should be used instead of {@link #getOpenDelay()}. The quick open delay + * is used when the tooltip has very recently been shown, is currently + * hidden but about to be shown again. + * + * @param quickOpenTimeout + * The quick open timeout + */ + public void setQuickOpenTimeout(int quickOpenTimeout); + + /** + * Returns the time (in ms) that should elapse before a tooltip will be + * shown, in the situation when a tooltip has very recently been shown + * (within {@link #getQuickOpenDelay()} ms). + * + * @return The quick open delay + */ + public int getQuickOpenDelay(); + + /** + * Sets the time (in ms) that should elapse before a tooltip will be shown, + * in the situation when a tooltip has very recently been shown (within + * {@link #getQuickOpenDelay()} ms). + * + * @param quickOpenDelay + * The quick open delay + */ + public void setQuickOpenDelay(int quickOpenDelay); + + /** + * Returns the time (in ms) that should elapse after an event triggering + * tooltip showing has occurred (e.g. mouse over) before the tooltip is + * shown. If a tooltip has recently been shown, then + * {@link #getQuickOpenDelay()} is used instead of this. + * + * @return The open delay + */ + public int getOpenDelay(); + + /** + * Sets the time (in ms) that should elapse after an event triggering + * tooltip showing has occurred (e.g. mouse over) before the tooltip is + * shown. If a tooltip has recently been shown, then + * {@link #getQuickOpenDelay()} is used instead of this. + * + * @param openDelay + * The open delay + */ + public void setOpenDelay(int openDelay); + + /** + * Returns the maximum width of the tooltip popup. + * + * @return The maximum width the tooltip popup + */ + public int getMaxWidth(); + + /** + * Sets the maximum width of the tooltip popup. + * + * @param maxWidth + * The maximum width the tooltip popup + */ + public void setMaxWidth(int maxWidth); +} + +class TooltipImpl implements Tooltip { + private UI ui; + + public TooltipImpl(UI ui) { + this.ui = ui; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.UI.Tooltip#getCloseTimeout() + */ + @Override + public int getCloseTimeout() { + return getState(false).closeTimeout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#setCloseTimeout(int) + */ + @Override + public void setCloseTimeout(int closeTimeout) { + getState().closeTimeout = closeTimeout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#getQuickOpenTimeout() + */ + @Override + public int getQuickOpenTimeout() { + return getState(false).quickOpenTimeout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#setQuickOpenTimeout(int) + */ + @Override + public void setQuickOpenTimeout(int quickOpenTimeout) { + getState().quickOpenTimeout = quickOpenTimeout; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#getQuickOpenDelay() + */ + @Override + public int getQuickOpenDelay() { + return getState(false).quickOpenDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#setQuickOpenDelay(int) + */ + @Override + public void setQuickOpenDelay(int quickOpenDelay) { + getState().quickOpenDelay = quickOpenDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#getOpenDelay() + */ + @Override + public int getOpenDelay() { + return getState(false).openDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#setOpenDelay(int) + */ + @Override + public void setOpenDelay(int openDelay) { + getState().openDelay = openDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#getMaxWidth() + */ + @Override + public int getMaxWidth() { + return getState(false).maxWidth; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Tooltip#setMaxWidth(int) + */ + @Override + public void setMaxWidth(int maxWidth) { + getState().maxWidth = maxWidth; + } + + private TooltipConfiguration getState() { + return ui.getState().tooltipConfiguration; + } + + private TooltipConfiguration getState(boolean markAsDirty) { + return ui.getState(markAsDirty).tooltipConfiguration; + } + +} diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 47cfd471cd..e9499da7f3 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -155,6 +155,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements private boolean closing = false; + private Tooltip tooltip = new TooltipImpl(this); + /** * Creates a new empty UI without a caption. The content of the UI must be * set by calling {@link #setContent(Component)} before using the UI. @@ -1095,4 +1097,13 @@ public abstract class UI extends AbstractSingleComponentContainer implements } } + + /** + * Retrieves the object used for configuring tooltips. + * + * @return The instance used for tooltip configuration + */ + public Tooltip getTooltip() { + return tooltip; + } } diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index 9abaf47f4b..cc6897dd0d 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -15,9 +15,21 @@ */ package com.vaadin.shared.ui.ui; +import java.io.Serializable; + import com.vaadin.shared.ui.TabIndexState; public class UIState extends TabIndexState { + public TooltipConfiguration tooltipConfiguration = new TooltipConfiguration(); + + public static class TooltipConfiguration implements Serializable { + public int openDelay = 750; + public int quickOpenDelay = 100; + public int quickOpenTimeout = 1000; + public int closeTimeout = 300; + public int maxWidth = 500; + } + { primaryStyleName = "v-ui"; // Default is 1 for legacy reasons diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html new file mode 100644 index 0000000000..5170d4408f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html @@ -0,0 +1,135 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.ui.TooltipConfiguration?restartApplication
typevaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout0
mouseMoveAtvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip0,0
waitForElementPresentid=gwt-uid-3
assertTextid=gwt-uid-3This is a short tooltip
mouseClickvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::
assertElementNotPresentid=gwt-uid-3
typevaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout3000
mouseMoveAtvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip0,0
waitForElementPresentid=gwt-uid-3
assertTextid=gwt-uid-3This is a short tooltip
mouseClickvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::
assertElementPresentid=gwt-uid-3
mouseClickvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout60,9
typevaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout0
mouseMoveAtvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip0,0
waitForElementPresentid=gwt-uid-3
assertElementWidthid=gwt-uid-3500
mouseClickvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::
typevaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SMax width100
mouseMoveAtvaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip0,0
waitForElementPresentid=gwt-uid-3
assertElementWidthid=gwt-uid-3100
+ + diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java new file mode 100644 index 0000000000..b8998ff32e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java @@ -0,0 +1,107 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.TextField; + +public class TooltipConfiguration extends AbstractTestUIWithLog { + + private TextField closeTimeout; + private TextField quickOpenTimeout; + private TextField maxWidth; + private TextField openDelay; + private TextField quickOpenDelay; + + @Override + protected void setup(VaadinRequest request) { + NativeButton componentWithShortTooltip = new NativeButton( + "Short tooltip"); + componentWithShortTooltip.setDescription("This is a short tooltip"); + componentWithShortTooltip.setId("shortTooltip"); + + NativeButton componentWithLongTooltip = new NativeButton("Long tooltip"); + componentWithLongTooltip.setId("longTooltip"); + componentWithLongTooltip.setDescription(LoremIpsum.get(5000)); + + closeTimeout = createIntegerTextField("Close timeout", + getState().tooltipConfiguration.closeTimeout); + closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getTooltip().setCloseTimeout( + (Integer) closeTimeout.getConvertedValue()); + } + }); + maxWidth = createIntegerTextField("Max width", + getState().tooltipConfiguration.maxWidth); + maxWidth.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getTooltip() + .setMaxWidth((Integer) maxWidth.getConvertedValue()); + } + }); + openDelay = createIntegerTextField("Open delay", + getState().tooltipConfiguration.openDelay); + openDelay.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getTooltip().setOpenDelay( + (Integer) openDelay.getConvertedValue()); + } + }); + + quickOpenDelay = createIntegerTextField("Quick open delay", + getState().tooltipConfiguration.quickOpenDelay); + quickOpenDelay + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getTooltip().setQuickOpenDelay( + (Integer) quickOpenDelay.getConvertedValue()); + } + }); + + quickOpenTimeout = createIntegerTextField("Quick open timeout", + getState().tooltipConfiguration.quickOpenTimeout); + quickOpenTimeout + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getTooltip().setQuickOpenTimeout( + (Integer) quickOpenTimeout.getConvertedValue()); + } + }); + + getLayout().addComponents(closeTimeout, openDelay, quickOpenDelay, + quickOpenTimeout, maxWidth); + + getLayout().addComponents(componentWithShortTooltip, + componentWithLongTooltip); + + } + + private TextField createIntegerTextField(String caption, int initialValue) { + TextField tf = new TextField(caption); + tf.setId(caption); + tf.setConverter(Integer.class); + tf.setImmediate(true); + tf.setConvertedValue(initialValue); + return tf; + } + + @Override + protected String getTestDescription() { + return "Tests that tooltip delays can be configured"; + } + + @Override + protected Integer getTicketNumber() { + return 8065; + } + +} -- cgit v1.2.3 From ce2df6d10370c669a512e96f0693fc37cf02aca1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 25 Mar 2013 23:37:45 +0200 Subject: Enable setting loading indicator delays from the server (#7448) * Refactored LoadingIndicator to a separate class on client side to enable customization and to remove clutter from ApplicationConnection Change-Id: I12e94294beed9c65a5710bdfe2486bc0f1b92bd9 --- .../com/vaadin/client/ApplicationConnection.java | 104 ++-------- .../src/com/vaadin/client/VLoadingIndicator.java | 218 +++++++++++++++++++++ .../src/com/vaadin/client/ui/ui/UIConnector.java | 10 + server/src/com/vaadin/ui/LoadingIndicator.java | 159 +++++++++++++++ server/src/com/vaadin/ui/UI.java | 12 ++ shared/src/com/vaadin/shared/ui/ui/UIState.java | 7 + .../ui/LoadingIndicatorConfigurationTest.java | 99 ++++++++++ 7 files changed, 526 insertions(+), 83 deletions(-) create mode 100644 client/src/com/vaadin/client/VLoadingIndicator.java create mode 100644 server/src/com/vaadin/ui/LoadingIndicator.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index a043ec6c0b..d59abc892a 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -177,11 +177,6 @@ public class ApplicationConnection { private VContextMenu contextMenu = null; - private Timer loadTimer; - private Timer loadTimer2; - private Timer loadTimer3; - private Element loadElement; - private final UIConnector uIConnector; protected boolean applicationRunning = false; @@ -378,6 +373,8 @@ public class ApplicationConnection { private CommunicationErrorHandler communicationErrorDelegate = null; + private VLoadingIndicator loadingIndicator; + public static class MultiStepDuration extends Duration { private int previousStep = elapsedMillis(); @@ -404,6 +401,8 @@ public class ApplicationConnection { layoutManager = GWT.create(LayoutManager.class); layoutManager.setConnection(this); tooltip = GWT.create(VTooltip.class); + loadingIndicator = GWT.create(VLoadingIndicator.class); + loadingIndicator.setConnection(this); } public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) { @@ -436,7 +435,7 @@ public class ApplicationConnection { tooltip.setOwner(uIConnector.getWidget()); - showLoadingIndicator(); + getLoadingIndicator().trigger(); scheduleHeartbeat(); @@ -987,7 +986,7 @@ public class ApplicationConnection { */ protected boolean isCSSLoaded() { return cssLoaded - || DOM.getElementPropertyInt(loadElement, "offsetHeight") != 0; + || getLoadingIndicator().getElement().getOffsetHeight() != 0; } /** @@ -1085,25 +1084,7 @@ public class ApplicationConnection { } hasActiveRequest = true; requestStartTime = new Date(); - // show initial throbber - if (loadTimer == null) { - loadTimer = new Timer() { - @Override - public void run() { - /* - * IE7 does not properly cancel the event with - * loadTimer.cancel() so we have to check that we really - * should make it visible - */ - if (loadTimer != null) { - showLoadingIndicator(); - } - - } - }; - // First one kicks in at 300ms - } - loadTimer.schedule(300); + loadingIndicator.trigger(); eventBus.fireEvent(new RequestStartingEvent(this)); } @@ -1129,7 +1110,7 @@ public class ApplicationConnection { @Override public void execute() { if (!hasActiveRequest()) { - hideLoadingIndicator(); + getLoadingIndicator().hide(); // If on Liferay and session expiration management is in // use, extend session duration on each request. @@ -1182,54 +1163,6 @@ public class ApplicationConnection { } } - private void showLoadingIndicator() { - // show initial throbber - if (loadElement == null) { - loadElement = DOM.createDiv(); - DOM.setStyleAttribute(loadElement, "position", "absolute"); - DOM.appendChild(uIConnector.getWidget().getElement(), loadElement); - VConsole.log("inserting load indicator"); - } - DOM.setElementProperty(loadElement, "className", "v-loading-indicator"); - DOM.setStyleAttribute(loadElement, "display", "block"); - // Initialize other timers - loadTimer2 = new Timer() { - @Override - public void run() { - DOM.setElementProperty(loadElement, "className", - "v-loading-indicator-delay"); - } - }; - // Second one kicks in at 1500ms from request start - loadTimer2.schedule(1200); - - loadTimer3 = new Timer() { - @Override - public void run() { - DOM.setElementProperty(loadElement, "className", - "v-loading-indicator-wait"); - } - }; - // Third one kicks in at 5000ms from request start - loadTimer3.schedule(4700); - } - - private void hideLoadingIndicator() { - if (loadTimer != null) { - loadTimer.cancel(); - loadTimer = null; - } - if (loadTimer2 != null) { - loadTimer2.cancel(); - loadTimer3.cancel(); - loadTimer2 = null; - loadTimer3 = null; - } - if (loadElement != null) { - DOM.setStyleAttribute(loadElement, "display", "none"); - } - } - /** * Checks if deferred commands are (potentially) still being executed as a * result of an update from the server. Returns true if a deferred command @@ -1251,20 +1184,25 @@ public class ApplicationConnection { } } + /** + * Returns the loading indicator used by this ApplicationConnection + * + * @return The loading indicator for this ApplicationConnection + */ + public VLoadingIndicator getLoadingIndicator() { + return loadingIndicator; + } + /** * Determines whether or not the loading indicator is showing. * * @return true if the loading indicator is visible + * @deprecated As of 7.1. Use {@link #getLoadingIndicator()} and + * {@link VLoadingIndicator#isVisible()}.isVisible() instead. */ + @Deprecated public boolean isLoadingIndicatorVisible() { - if (loadElement == null) { - return false; - } - if (loadElement.getStyle().getProperty("display").equals("none")) { - return false; - } - - return true; + return getLoadingIndicator().isVisible(); } private static native ValueMap parseJSONResponse(String jsonText) diff --git a/client/src/com/vaadin/client/VLoadingIndicator.java b/client/src/com/vaadin/client/VLoadingIndicator.java new file mode 100644 index 0000000000..ca29d6a042 --- /dev/null +++ b/client/src/com/vaadin/client/VLoadingIndicator.java @@ -0,0 +1,218 @@ +package com.vaadin.client; + +import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Timer; + +/** + * Class representing the loading indicator for Vaadin applications. The loading + * indicator has four states: "triggered", "initial", "delay" and "wait". When + * {@link #trigger()} is called the indicator moves to its "triggered" state and + * then transitions from one state to the next when the timeouts specified using + * the set*StateDelay methods occur. + * + * @author Vaadin Ltd + * @since 7.1 + */ +public class VLoadingIndicator { + + private static final String PRIMARY_STYLE_NAME = "v-loading-indicator"; + + private ApplicationConnection connection; + + private int initialStateDelay = 300; + private int delayStateDelay = 1500; + private int waitStateDelay = 5000; + + private Timer initialTimer = new Timer() { + @Override + public void run() { + show(); + } + }; + private Timer delayStateTimer = new Timer() { + @Override + public void run() { + getElement().setClassName(PRIMARY_STYLE_NAME + "-delay"); + } + }; + private Timer waitStateTimer = new Timer() { + @Override + public void run() { + getElement().setClassName(PRIMARY_STYLE_NAME + "-wait"); + } + }; + + private Element element; + + /** + * Returns the delay (in ms) which must pass before the loading indicator + * moves into the "initial" state and is shown to the user + * + * @return The delay (in ms) until moving into the "initial" state. Counted + * from when {@link #trigger()} is called. + */ + public int getInitialStateDelay() { + return initialStateDelay; + } + + /** + * Sets the delay (in ms) which must pass before the loading indicator moves + * into the "initial" state and is shown to the user + * + * @param initialStateDelay + * The delay (in ms) until moving into the "initial" state. + * Counted from when {@link #trigger()} is called. + */ + public void setInitialStateDelay(int initialStateDelay) { + this.initialStateDelay = initialStateDelay; + } + + /** + * Returns the delay (in ms) which must pass before the loading indicator + * moves to its "delay" state. + * + * @return The delay (in ms) until the loading indicator moves into its + * "delay" state. Counted from when {@link #trigger()} is called. + */ + public int getDelayStateDelay() { + return delayStateDelay; + } + + /** + * Sets the delay (in ms) which must pass before the loading indicator moves + * to its "delay" state. + * + * @param delayStateDelay + * The delay (in ms) until the loading indicator moves into its + * "delay" state. Counted from when {@link #trigger()} is called. + */ + public void setDelayStateDelay(int delayStateDelay) { + this.delayStateDelay = delayStateDelay; + } + + /** + * Returns the delay (in ms) which must pass before the loading indicator + * moves to its "wait" state. + * + * @return The delay (in ms) until the loading indicator moves into its + * "wait" state. Counted from when {@link #trigger()} is called. + */ + public int getWaitStateDelay() { + return waitStateDelay; + } + + /** + * Sets the delay (in ms) which must pass before the loading indicator moves + * to its "wait" state. + * + * @param loadingIndicatorThirdDelay + * The delay (in ms) from the event until changing the loading + * indicator into its "wait" state. Counted from when + * {@link #trigger()} is called. + */ + public void setWaitStateDelay(int loadingIndicatorThirdDelay) { + waitStateDelay = loadingIndicatorThirdDelay; + } + + /** + * Triggers displaying of this loading indicator. The loading indicator will + * actually be shown by {@link #show()} when the initial delay (as specified + * by {@link #getInitialStateDelay()}) has passed. + *

+ * The loading indicator will be hidden if shown when calling this method. + *

+ */ + public void trigger() { + hide(); + initialTimer.schedule(getInitialStateDelay()); + } + + /** + * Shows the loading indicator in its standard state and triggers timers for + * transitioning into the "delay" and "wait" states. + */ + public void show() { + // Reset possible style name and display mode + getElement().setClassName(PRIMARY_STYLE_NAME); + getElement().getStyle().setDisplay(Display.BLOCK); + + // Schedule the "delay" loading indicator + int delayStateTimerDelay = getDelayStateDelay() + - getInitialStateDelay(); + if (delayStateTimerDelay >= 0) { + delayStateTimer.schedule(delayStateTimerDelay); + } + + // Schedule the "wait" loading indicator + int waitStateTimerDelay = getWaitStateDelay() - getInitialStateDelay(); + if (waitStateTimerDelay >= 0) { + waitStateTimer.schedule(waitStateTimerDelay); + } + } + + /** + * Returns the {@link ApplicationConnection} which uses this loading + * indicator + * + * @return The ApplicationConnection for this loading indicator + */ + public ApplicationConnection getConnection() { + return connection; + } + + /** + * Sets the {@link ApplicationConnection} which uses this loading indicator. + * Only used internally. + * + * @param connection + * The ApplicationConnection for this loading indicator + */ + void setConnection(ApplicationConnection connection) { + this.connection = connection; + } + + /** + * Hides the loading indicator (if visible). Cancels any possibly running + * timers. + */ + public void hide() { + initialTimer.cancel(); + delayStateTimer.cancel(); + waitStateTimer.cancel(); + + getElement().getStyle().setDisplay(Display.NONE); + } + + /** + * Returns whether or not the loading indicator is showing. + * + * @return true if the loading indicator is visible, false otherwise + */ + public boolean isVisible() { + if (getElement().getStyle().getDisplay() + .equals(Display.NONE.getCssName())) { + return false; + } + + return true; + } + + /** + * Returns the root element of the loading indicator + * + * @return The loading indicator DOM element + */ + public Element getElement() { + if (element == null) { + element = DOM.createDiv(); + element.getStyle().setPosition(Position.ABSOLUTE); + getConnection().getUIConnector().getWidget().getElement() + .appendChild(element); + } + return element; + } + +} diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index b8b7786d21..f4524882fa 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -615,5 +615,15 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getConnection().getVTooltip().setMaxWidth( getState().tooltipConfiguration.maxWidth); } + + if (stateChangeEvent + .hasPropertyChanged("loadingIndicatorConfiguration")) { + getConnection().getLoadingIndicator().setInitialStateDelay( + getState().loadingIndicatorConfiguration.initialDelay); + getConnection().getLoadingIndicator().setWaitStateDelay( + getState().loadingIndicatorConfiguration.waitStateDelay); + getConnection().getLoadingIndicator().setDelayStateDelay( + getState().loadingIndicatorConfiguration.delayStateDelay); + } } } diff --git a/server/src/com/vaadin/ui/LoadingIndicator.java b/server/src/com/vaadin/ui/LoadingIndicator.java new file mode 100644 index 0000000000..5740ee772d --- /dev/null +++ b/server/src/com/vaadin/ui/LoadingIndicator.java @@ -0,0 +1,159 @@ +/* + * Copyright 2000-2013 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.ui; + +import java.io.Serializable; + +import com.vaadin.shared.ui.ui.UIState.LoadingIndicatorConfiguration; + +/** + * Provides method for configuring the loading indicator. + * + * @author Vaadin Ltd + * @since 7.1 + */ +public interface LoadingIndicator extends Serializable { + /** + * Sets the delay before the loading indicator is shown. The default is + * 300ms. + * + * @param initialDelay + * The initial delay (in ms) + */ + public void setInitialDelay(int initialDelay); + + /** + * Returns the delay before the loading indicator is shown. + * + * @return The initial delay (in ms) + */ + public int getInitialDelay(); + + /** + * Sets the delay before the loading indicator goes into the "delay" state. + * The delay is calculated from the time when the loading indicator was + * triggered. The default is 1500ms. + * + * @param delayStateDelay + * The delay before going into the "delay" state (in ms) + */ + public void setDelayStateDelay(int delayStateDelay); + + /** + * Returns the delay before the loading indicator goes into the "delay" + * state. The delay is calculated from the time when the loading indicator + * was triggered. + * + * @return The delay before going into the "delay" state (in ms) + */ + public int getDelayStateDelay(); + + /** + * Sets the delay before the loading indicator goes into the "wait" state. + * The delay is calculated from the time when the loading indicator was + * triggered. The default is 5000ms. + * + * @param waitStateDelay + * The delay before going into the "wait" state (in ms) + */ + public void setWaitStateDelay(int waitStateDelay); + + /** + * Returns the delay before the loading indicator goes into the "wait" + * state. The delay is calculated from the time when the loading indicator + * was triggered. + * + * @return The delay before going into the "wait" state (in ms) + */ + public int getWaitStateDelay(); +} + +class LoadingIndicatorImpl implements LoadingIndicator { + private UI ui; + + public LoadingIndicatorImpl(UI ui) { + this.ui = ui; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#setInitialDelay(int) + */ + @Override + public void setInitialDelay(int initialDelay) { + getState().initialDelay = initialDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#getInitialDelay() + */ + @Override + public int getInitialDelay() { + return getState(false).initialDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#setDelayStateDelay(int) + */ + @Override + public void setDelayStateDelay(int delayStateDelay) { + getState().delayStateDelay = delayStateDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#getDelayStateDelay() + */ + @Override + public int getDelayStateDelay() { + return getState(false).delayStateDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#setWaitStateDelay(int) + */ + @Override + public void setWaitStateDelay(int waitStateDelay) { + getState().waitStateDelay = waitStateDelay; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.LoadingIndicator#getWaitStateDelay() + */ + @Override + public int getWaitStateDelay() { + return getState(false).waitStateDelay; + } + + private LoadingIndicatorConfiguration getState() { + return ui.getState().loadingIndicatorConfiguration; + } + + private LoadingIndicatorConfiguration getState(boolean markAsDirty) { + return ui.getState(markAsDirty).loadingIndicatorConfiguration; + } + +} diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index e9499da7f3..a20c2b2087 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -116,6 +116,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements private Page page = new Page(this); + private LoadingIndicator loadingIndicator = new LoadingIndicatorImpl(this); + /** * Scroll Y position. */ @@ -1106,4 +1108,14 @@ public abstract class UI extends AbstractSingleComponentContainer implements public Tooltip getTooltip() { return tooltip; } + + /** + * Retrieves the object used for configuring the loading indicator. + * + * @return The instance used for configuring the loading indicator + */ + public LoadingIndicator getLoadingIndicator() { + return loadingIndicator; + } + } diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index cc6897dd0d..d5ee4c30e6 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -21,6 +21,13 @@ import com.vaadin.shared.ui.TabIndexState; public class UIState extends TabIndexState { public TooltipConfiguration tooltipConfiguration = new TooltipConfiguration(); + public LoadingIndicatorConfiguration loadingIndicatorConfiguration = new LoadingIndicatorConfiguration(); + + public static class LoadingIndicatorConfiguration implements Serializable { + public int initialDelay = 300; + public int delayStateDelay = 1500; + public int waitStateDelay = 5000; + } public static class TooltipConfiguration implements Serializable { public int openDelay = 750; diff --git a/uitest/src/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java new file mode 100644 index 0000000000..0f15ff2fe0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/LoadingIndicatorConfigurationTest.java @@ -0,0 +1,99 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.TextField; + +public class LoadingIndicatorConfigurationTest extends AbstractTestUIWithLog { + + private TextField initialDelay; + private TextField delayStateDelay; + private TextField waitStateDelay; + + @Override + protected void setup(VaadinRequest request) { + final TextField delayField = new TextField("Delay (ms)"); + delayField.setConverter(Integer.class); + delayField.setConvertedValue(1000); + + NativeButton delayButton = new NativeButton("Wait"); + delayButton.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + try { + Thread.sleep((Integer) delayField.getConvertedValue()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }); + + initialDelay = createIntegerTextField("Initial delay (ms)", + getState().loadingIndicatorConfiguration.initialDelay); + initialDelay.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getLoadingIndicator().setInitialDelay( + (Integer) initialDelay.getConvertedValue()); + } + }); + delayStateDelay = createIntegerTextField("Delay state delay (ms)", + getState().loadingIndicatorConfiguration.delayStateDelay); + delayStateDelay + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getLoadingIndicator().setDelayStateDelay( + (Integer) delayStateDelay.getConvertedValue()); + } + }); + waitStateDelay = createIntegerTextField("Wait state delay (ms)", + getState().loadingIndicatorConfiguration.waitStateDelay); + waitStateDelay + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + getLoadingIndicator().setWaitStateDelay( + (Integer) waitStateDelay.getConvertedValue()); + } + }); + + getLayout() + .addComponents(initialDelay, delayStateDelay, waitStateDelay); + + HorizontalLayout hl = new HorizontalLayout(); + hl.setMargin(true); + hl.setDefaultComponentAlignment(Alignment.BOTTOM_RIGHT); + hl.addComponents(delayField, delayButton); + addComponent(hl); + + } + + private TextField createIntegerTextField(String caption, int initialValue) { + TextField tf = new TextField(caption); + tf.setId(caption); + tf.setConverter(Integer.class); + tf.setImmediate(true); + tf.setConvertedValue(initialValue); + return tf; + } + + @Override + protected String getTestDescription() { + return "Tests that loading indicator delay can be configured"; + } + + @Override + protected Integer getTicketNumber() { + return 7448; + } + +} -- cgit v1.2.3 From bde44c29bdec4647dbec94b1ed2482baaf00cddf Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Wed, 27 Mar 2013 09:57:40 +0200 Subject: Implemented changes to CSS injection based on API review #5500 Change-Id: I2bed5f5a5c3cfc6b97e94cbd218bb06f446c7325 --- .../src/com/vaadin/client/ui/ui/UIConnector.java | 64 ++----------- server/src/com/vaadin/server/Page.java | 104 ++++++++++----------- .../v71beta/CSSInjectWithColorpicker.java | 18 ++-- .../src/com/vaadin/tests/themes/CSSInjectTest.java | 10 +- 4 files changed, 71 insertions(+), 125 deletions(-) (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index f4524882fa..69296b537c 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -17,7 +17,6 @@ package com.vaadin.client.ui.ui; import java.util.ArrayList; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import com.google.gwt.core.client.Scheduler; @@ -26,7 +25,6 @@ import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.HeadElement; import com.google.gwt.dom.client.LinkElement; import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.StyleInjector; @@ -62,7 +60,7 @@ import com.vaadin.client.ui.VNotification; import com.vaadin.client.ui.VUI; import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.client.ui.window.WindowConnector; -import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.Page.Styles; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; @@ -340,7 +338,7 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } /** - * Reads CSS strings and resources injected by {@link StyleSheet#inject} + * Reads CSS strings and resources injected by {@link Styles#inject} * from the UIDL stream. * * @param uidl @@ -354,8 +352,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector /* * Search the UIDL stream for CSS resources and strings to be injected. */ - final List resourcesToInject = new LinkedList(); - final StringBuilder cssToInject = new StringBuilder(); for (Iterator it = uidl.getChildIterator(); it.hasNext();) { UIDL cssInjectionsUidl = (UIDL) it.next(); @@ -364,62 +360,22 @@ public class UIConnector extends AbstractSingleComponentContainerConnector String url = getWidget().connection .translateVaadinUri(cssInjectionsUidl .getStringAttribute("url")); - - // Check if url already has been injected - boolean injected = false; - NodeList links = head - .getElementsByTagName(LinkElement.TAG); - for (int i = 0; i < links.getLength(); i++) { - LinkElement link = LinkElement.as(links.getItem(i)); - if (link.getHref().equals(url)) { - injected = true; - break; - } - } - - if (!injected) { - // Ensure duplicates do not get injected - resourcesToInject.add(url); - } + LinkElement link = LinkElement.as(DOM + .createElement(LinkElement.TAG)); + link.setRel("stylesheet"); + link.setHref(url); + link.setType("text/css"); + head.appendChild(link); // Check if we have CSS string to inject } else if (cssInjectionsUidl.getTag().equals("css-string")) { for (Iterator it2 = cssInjectionsUidl.getChildIterator(); it2 .hasNext();) { - cssToInject.append((String) it2.next()); + StyleInjector.injectAtEnd((String) it2.next()); + StyleInjector.flush(); } } } - - /* - * Inject resources as deferred to ensure other Vaadin resources that - * are located before in the DOM get applied first so the injected ones - * can override them. - */ - if (!resourcesToInject.isEmpty()) { - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - - @Override - public void execute() { - for (String url : resourcesToInject) { - LinkElement link = LinkElement.as(DOM - .createElement(LinkElement.TAG)); - link.setRel("stylesheet"); - link.setHref(url); - link.setType("text/css"); - head.appendChild(link); - } - } - }); - } - - /* - * Inject the string CSS injections as a combined style tag. Not - * injected as deferred since StyleInjector will do it for us. - */ - if (cssToInject.length() > 0) { - StyleInjector.injectAtEnd(cssToInject.toString()); - } } public void init(String rootPanelId, diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index e84271e883..a7e0f7dcb3 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -21,9 +21,11 @@ import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; import java.util.EventObject; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; import com.vaadin.event.EventRouter; import com.vaadin.shared.ui.BorderStyle; @@ -309,25 +311,22 @@ public class Page implements Serializable { * * @since 7.1 */ - public static class StyleSheet implements Serializable { + public static class Styles implements Serializable { - /* - * Points to last injected string injection - */ - private int injectedStringPointer; + private final Map stringInjections = new HashMap(); - private final List stringInjections = new LinkedList(); + private final Map resourceInjections = new HashMap(); - /* - * Points to last injected resource injection - */ - private int injectedResourcesPointer; + // The combined injection counter between both string and resource + // injections. Used as the key for the injection maps + private int injectionCounter = 0; - private final List resourceInjections = new LinkedList(); + // Points to the next injection that has not yet been made into the Page + private int nextInjectionPosition = 0; private final UI ui; - private StyleSheet(UI ui) { + private Styles(UI ui) { this.ui = ui; } @@ -337,24 +336,13 @@ public class Page implements Serializable { * @param css * The CSS to inject */ - public void inject(String css) { + public void add(String css) { if (css == null) { throw new IllegalArgumentException( "Cannot inject null CSS string"); } - /* - * Check if last injection was the same, in that case ignore it. - */ - if (!stringInjections.isEmpty() && injectedStringPointer > 0) { - String lastInjection = stringInjections - .get(injectedStringPointer - 1); - if (lastInjection.equals(css.trim())) { - return; - } - } - - stringInjections.add(css.trim()); + stringInjections.put(injectionCounter++, css); ui.markAsDirty(); } @@ -364,13 +352,13 @@ public class Page implements Serializable { * @param resource * The resource to inject. */ - public void inject(Resource resource) { + public void add(Resource resource) { if (resource == null) { throw new IllegalArgumentException( "Cannot inject null resource"); } - resourceInjections.add(resource); + resourceInjections.put(injectionCounter++, resource); ui.markAsDirty(); } @@ -378,37 +366,38 @@ public class Page implements Serializable { // If full repaint repaint all injections if (target.isFullRepaint()) { - injectedStringPointer = 0; - injectedResourcesPointer = 0; + nextInjectionPosition = 0; } - target.startTag("css-injections"); + if (injectionCounter > nextInjectionPosition) { - // Paint pending string injections - List injections = stringInjections.subList( - injectedStringPointer, stringInjections.size()); + target.startTag("css-injections"); - for (String css : injections) { - target.startTag("css-string"); - target.addText(css); - target.endTag("css-string"); - } + while (injectionCounter > nextInjectionPosition) { - injectedStringPointer = stringInjections.size(); + String stringInjection = stringInjections + .get(nextInjectionPosition); + if (stringInjection != null) { + target.startTag("css-string"); + target.addAttribute("id", nextInjectionPosition); + target.addText(stringInjection); + target.endTag("css-string"); + } - // Paint pending resource injections - List resInjections = resourceInjections.subList( - injectedResourcesPointer, resourceInjections.size()); + Resource resourceInjection = resourceInjections + .get(nextInjectionPosition); + if (resourceInjection != null) { + target.startTag("css-resource"); + target.addAttribute("id", nextInjectionPosition); + target.addAttribute("url", resourceInjection); + target.endTag("css-resource"); + } - for (Resource res : resInjections) { - target.startTag("css-resource"); - target.addAttribute("url", res); - target.endTag("css-resource"); - } - - target.endTag("css-injections"); + nextInjectionPosition++; + } - injectedResourcesPointer = resourceInjections.size(); + target.endTag("css-injections"); + } } } @@ -421,7 +410,7 @@ public class Page implements Serializable { private JavaScript javaScript; - private StyleSheet styleSheet; + private Styles styles; /** * The current browser location. @@ -696,11 +685,12 @@ public class Page implements Serializable { * * @since 7.1 */ - public StyleSheet getStyleSheet() { - if (styleSheet == null) { - styleSheet = new StyleSheet(uI); + public Styles getStyles() { + + if (styles == null) { + styles = new Styles(uI); } - return styleSheet; + return styles; } public void paintContent(PaintTarget target) throws PaintException { @@ -760,8 +750,8 @@ public class Page implements Serializable { location.toString()); } - if (styleSheet != null) { - styleSheet.paint(target); + if (styles != null) { + styles.paint(target); } } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java index 09c5f91293..e3b8f997e0 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java @@ -5,7 +5,7 @@ import java.util.Arrays; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.server.Page; -import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.Page.Styles; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.colorpicker.Color; @@ -125,10 +125,10 @@ public class CSSInjectWithColorpicker extends UI { Color color = event.getColor(); // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); + Styles styles = Page.getCurrent().getStyles(); // inject the new background color - styles.inject(".v-app .v-textarea.text-label { background-color:" + styles.add(".v-app .v-textarea.text-label { background-color:" + color.getCSS() + "; }"); } }); @@ -153,10 +153,10 @@ public class CSSInjectWithColorpicker extends UI { Color color = event.getColor(); // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); + Styles styles = Page.getCurrent().getStyles(); // inject the new color as a style - styles.inject(".v-app .v-textarea.text-label { color:" + styles.add(".v-app .v-textarea.text-label { color:" + color.getCSS() + "; }"); } }); @@ -186,11 +186,11 @@ public class CSSInjectWithColorpicker extends UI { String fontFamily = select.getValue().toString(); // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); + Styles styles = Page.getCurrent().getStyles(); // inject the new font size as a style. We need .v-app to // override Vaadin's default styles here - styles.inject(".v-app .v-textarea.text-label { font-family:" + styles.add(".v-app .v-textarea.text-label { font-family:" + fontFamily + "; }"); } }); @@ -220,11 +220,11 @@ public class CSSInjectWithColorpicker extends UI { Integer fontSize = (Integer) select.getValue(); // Get the stylesheet of the page - StyleSheet styles = Page.getCurrent().getStyleSheet(); + Styles styles = Page.getCurrent().getStyles(); // inject the new font size as a style. We need .v-app to // override Vaadin's default styles here - styles.inject(".v-app .v-textarea.text-label { font-size:" + styles.add(".v-app .v-textarea.text-label { font-size:" + String.valueOf(fontSize) + "px; }"); } }); diff --git a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java index bedbf47fe2..f4448bf326 100644 --- a/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java +++ b/uitest/src/com/vaadin/tests/themes/CSSInjectTest.java @@ -5,7 +5,7 @@ import java.io.InputStream; import java.util.UUID; import com.vaadin.server.Page; -import com.vaadin.server.Page.StyleSheet; +import com.vaadin.server.Page.Styles; import com.vaadin.server.StreamResource; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.TestBase; @@ -19,10 +19,10 @@ public class CSSInjectTest extends TestBase { @Override protected void setup() { - final StyleSheet stylesheet = Page.getCurrent().getStyleSheet(); + final Styles stylesheet = Page.getCurrent().getStyles(); // Inject some resources initially - stylesheet.inject(new StreamResource(new StreamResource.StreamSource() { + stylesheet.add(new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { @@ -44,7 +44,7 @@ public class CSSInjectTest extends TestBase { @Override public void buttonClick(ClickEvent event) { - stylesheet.inject(cssToInject.getValue()); + stylesheet.add(cssToInject.getValue()); cssToInject.setValue(""); } }); @@ -58,7 +58,7 @@ public class CSSInjectTest extends TestBase { final String css = cssToInject.getValue(); - stylesheet.inject(new StreamResource( + stylesheet.add(new StreamResource( new StreamResource.StreamSource() { @Override -- cgit v1.2.3 From 217ba18e53a8607a9e2480574ec1c3da11f4037f Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Wed, 27 Mar 2013 16:33:28 +0200 Subject: Integrate Calendar into core #11079 Everything else integrated, except TB3 tests (ticket #11090, old TB2 tests used instead) Change-Id: If1700d7680a6c0a45f84d6e3c7b80e6536da78c8 --- WebContent/VAADIN/themes/base/base.scss | 2 + .../VAADIN/themes/base/calendar/calendar.scss | 378 ++++ .../VAADIN/themes/base/calendar/img/arrows.png | Bin 0 -> 248 bytes WebContent/VAADIN/themes/tests-calendar/styles.css | 96 ++ client/src/com/vaadin/client/ui/VCalendar.java | 1444 ++++++++++++++++ .../client/ui/calendar/CalendarConnector.java | 637 +++++++ .../vaadin/client/ui/calendar/VCalendarAction.java | 138 ++ .../client/ui/calendar/schedule/CalendarDay.java | 55 + .../client/ui/calendar/schedule/CalendarEvent.java | 313 ++++ .../client/ui/calendar/schedule/DateCell.java | 808 +++++++++ .../ui/calendar/schedule/DateCellContainer.java | 114 ++ .../ui/calendar/schedule/DateCellDayEvent.java | 659 +++++++ .../client/ui/calendar/schedule/DateCellGroup.java | 60 + .../client/ui/calendar/schedule/DateUtil.java | 70 + .../client/ui/calendar/schedule/DayToolbar.java | 179 ++ .../calendar/schedule/FocusableComplexPanel.java | 117 ++ .../client/ui/calendar/schedule/FocusableGrid.java | 129 ++ .../client/ui/calendar/schedule/FocusableHTML.java | 119 ++ .../client/ui/calendar/schedule/HasTooltipKey.java | 33 + .../ui/calendar/schedule/MonthEventLabel.java | 142 ++ .../client/ui/calendar/schedule/MonthGrid.java | 215 +++ .../client/ui/calendar/schedule/SimpleDayCell.java | 696 ++++++++ .../ui/calendar/schedule/SimpleDayToolbar.java | 97 ++ .../ui/calendar/schedule/SimpleWeekToolbar.java | 108 ++ .../client/ui/calendar/schedule/WeekGrid.java | 677 ++++++++ .../calendar/schedule/WeekGridMinuteTimeRange.java | 61 + .../client/ui/calendar/schedule/WeekLabel.java | 51 + .../ui/calendar/schedule/WeeklyLongEvents.java | 184 ++ .../schedule/WeeklyLongEventsDateCell.java | 67 + .../calendar/schedule/dd/CalendarDropHandler.java | 64 + .../schedule/dd/CalendarMonthDropHandler.java | 166 ++ .../schedule/dd/CalendarWeekDropHandler.java | 181 ++ server/src/com/vaadin/ui/Calendar.java | 1822 ++++++++++++++++++++ .../calendar/CalendarComponentEvent.java | 51 + .../calendar/CalendarComponentEvents.java | 603 +++++++ .../ui/components/calendar/CalendarDateRange.java | 86 + .../components/calendar/CalendarTargetDetails.java | 80 + .../calendar/ContainerEventProvider.java | 566 ++++++ .../ui/components/calendar/event/BasicEvent.java | 251 +++ .../calendar/event/BasicEventProvider.java | 173 ++ .../event/CalendarEditableEventProvider.java | 40 + .../components/calendar/event/CalendarEvent.java | 146 ++ .../calendar/event/CalendarEventProvider.java | 112 ++ .../calendar/event/EditableCalendarEvent.java | 91 + .../calendar/handler/BasicBackwardHandler.java | 78 + .../calendar/handler/BasicDateClickHandler.java | 69 + .../calendar/handler/BasicEventMoveHandler.java | 73 + .../calendar/handler/BasicEventResizeHandler.java | 69 + .../calendar/handler/BasicForwardHandler.java | 76 + .../calendar/handler/BasicWeekClickHandler.java | 81 + .../server/component/calendar/CalendarBasics.java | 210 +++ .../component/calendar/ContainerDataSource.java | 362 ++++ .../shared/ui/calendar/CalendarClientRpc.java | 28 + .../vaadin/shared/ui/calendar/CalendarEventId.java | 36 + .../shared/ui/calendar/CalendarServerRpc.java | 49 + .../vaadin/shared/ui/calendar/CalendarState.java | 69 + .../vaadin/shared/ui/calendar/DateConstants.java | 33 + .../calendar/BeanItemContainerTestUI.java | 181 ++ .../components/calendar/CalendarActionsUI.java | 107 ++ .../tests/components/calendar/CalendarTest.java | 1227 +++++++++++++ .../components/calendar/CalendarTestEvent.java | 48 + .../components/calendar/HiddenFwdBackButtons.java | 61 + .../components/calendar/NotificationTestUI.java | 101 ++ .../vaadin/tests/components/calendar/actions.html | 51 + .../tests/components/calendar/basicNavigation.html | 236 +++ .../components/calendar/eventSizingNoOverlap.html | 110 ++ .../components/calendar/midnightEventsTest.html | 116 ++ .../components/calendar/monthlyViewNewEvent.html | 170 ++ .../components/calendar/monthlyViewNewEvents.html | 410 +++++ .../tests/components/calendar/notifications.html | 41 + .../components/calendar/sizeTest1000x600px.html | 41 + .../calendar/sizeTest100percentXundefined.html | 41 + .../calendar/sizeTest100x100percent.html | 41 + .../calendar/sizeTest300pxXundefined.html | 41 + .../components/calendar/sizeTestSizeFull.html | 41 + .../calendar/sizeTestUndefinedX100percent.html | 41 + .../calendar/sizeTestUndefinedX300px.html | 41 + .../calendar/sizeTestUndefinedXUndefined.html | 41 + .../tests/components/calendar/visibleHours24H.html | 46 + .../components/calendar/weeklyViewNewEvents.html | 657 +++++++ 80 files changed, 17204 insertions(+) create mode 100644 WebContent/VAADIN/themes/base/calendar/calendar.scss create mode 100644 WebContent/VAADIN/themes/base/calendar/img/arrows.png create mode 100644 WebContent/VAADIN/themes/tests-calendar/styles.css create mode 100644 client/src/com/vaadin/client/ui/VCalendar.java create mode 100644 client/src/com/vaadin/client/ui/calendar/CalendarConnector.java create mode 100644 client/src/com/vaadin/client/ui/calendar/VCalendarAction.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/CalendarDay.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/CalendarEvent.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DateUtil.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/HasTooltipKey.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/MonthEventLabel.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayToolbar.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/WeekLabel.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEventsDateCell.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java create mode 100644 client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java create mode 100644 server/src/com/vaadin/ui/Calendar.java create mode 100644 server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java create mode 100644 server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java create mode 100644 server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java create mode 100644 server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java create mode 100644 server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java create mode 100644 server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java create mode 100644 server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java create mode 100644 server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java create mode 100644 server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java create mode 100644 shared/src/com/vaadin/shared/ui/calendar/CalendarClientRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/calendar/CalendarEventId.java create mode 100644 shared/src/com/vaadin/shared/ui/calendar/CalendarServerRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/calendar/CalendarState.java create mode 100644 shared/src/com/vaadin/shared/ui/calendar/DateConstants.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarTestEvent.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/actions.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/notifications.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html (limited to 'uitest/src') diff --git a/WebContent/VAADIN/themes/base/base.scss b/WebContent/VAADIN/themes/base/base.scss index 87754b6777..83e463fa00 100644 --- a/WebContent/VAADIN/themes/base/base.scss +++ b/WebContent/VAADIN/themes/base/base.scss @@ -4,6 +4,7 @@ @import "button/nativebutton.scss"; @import "button/checkbox.scss"; @import "layout/layout.scss"; +@import "calendar/calendar.scss"; @import "caption/caption.scss"; @import "colorpicker/colorpicker.scss"; @import "common/common.scss"; @@ -64,6 +65,7 @@ $line-height: normal; @include base-checkbox; @include base-caption; @include base-colorpicker; + @include base-calendar; // here for now to preserve old semantics @include base-common; diff --git a/WebContent/VAADIN/themes/base/calendar/calendar.scss b/WebContent/VAADIN/themes/base/calendar/calendar.scss new file mode 100644 index 0000000000..8ff97df0f9 --- /dev/null +++ b/WebContent/VAADIN/themes/base/calendar/calendar.scss @@ -0,0 +1,378 @@ +@mixin base-calendar($primaryStyleName : v-calendar) { + +/* Global resize style */ +.#{$primaryStyleName}-nresize DIV DIV { + cursor: n-resize !important; +} + +.#{$primaryStyleName}-sresize DIV DIV { + cursor: s-resize !important; +} + +/* Header bar */ +.#{$primaryStyleName} { + background-color: #fff; +} + +.#{$primaryStyleName}-header-month,.#{$primaryStyleName}-header-week { + border-bottom: 1px solid #c1c1c1; +} + +.#{$primaryStyleName}-header-day { + text-align: center; + color: #666; + font-size: 12px; + line-height: normal; +} + +.#{$primaryStyleName}-header-week .#{$primaryStyleName}-header-day:hover { + cursor: pointer; + color: #222 +} + +.#{$primaryStyleName}-header-day-today { + font-weight: bold; + color: #444; +} + +.#{$primaryStyleName}-header-month td:first-child { + padding-left: 19px; + /* Same as VCalendar.MONTHLY_WEEKTOOLBARWIDTH - .#{$primaryStyleName}-week-numbers border */ +} + +.#{$primaryStyleName}-header-week .#{$primaryStyleName}-back,.#{$primaryStyleName}-header-week .#{$primaryStyleName}-next + { + border: none; + padding: 0; + margin: 0; + height: 12px; + width: 12px; + overflow: hidden; + background: transparent url(img/arrows.png) no-repeat 50% 0; + opacity: .3; + filter: alpha(opacity = 30); + cursor: default; +} + +.#{$primaryStyleName}-header-week .#{$primaryStyleName}-back:hover,.#{$primaryStyleName}-header-week .#{$primaryStyleName}-next:hover + { + opacity: .6; + filter: alpha(opacity = 60); +} + +.#{$primaryStyleName}-header-week .#{$primaryStyleName}-back:active,.#{$primaryStyleName}-header-week .#{$primaryStyleName}-next:active + { + opacity: 1; + filter: alpha(opacity = 100); +} + +.#{$primaryStyleName}-header-week .#{$primaryStyleName}-next { + background-position: 50% -12px; +} + +/* Month grid */ +.#{$primaryStyleName}-month { + outline: none; +} + +.#{$primaryStyleName}-week-numbers { + width: 20px; + border-right: 1px solid #ccc; +} + +.#{$primaryStyleName}-week-number { + border: none; + background: transparent; + padding: 0; + margin: 0; + cursor: pointer; + opacity: .5; + width: 20px; + text-align: center; + border-bottom: 1px solid #ddd; +} + +.#{$primaryStyleName}-week-number:hover { + opacity: 1; +} + +.#{$primaryStyleName}-month-day { + border-bottom: 1px solid #ccc; + border-right: 1px solid #ccc; + outline: none; +} + +.#{$primaryStyleName}-month-day-today { + background-color: #e7f0f5; +} + +.#{$primaryStyleName}-month-day-selected { + background-color: #fffee7; +} + +.#{$primaryStyleName}-month-day-dragemphasis { + background-color: #a8a8a8; +} + +.#{$primaryStyleName}-month-day-scrollable { + overflow-y: scroll; +} + +.#{$primaryStyleName}-day-number { + height: 18px; + line-height: 18px; + font-size: 12px; + text-align: right; + padding-right: 3px; + white-space: nowrap; +} + +.#{$primaryStyleName}-day-number:hover { + cursor: pointer; + opacity: .6; + filter: alpha(opacity = 60); +} + +.#{$primaryStyleName}-month .#{$primaryStyleName}-spacer,.#{$primaryStyleName}-month .#{$primaryStyleName}-bottom-spacer,.#{$primaryStyleName}-month .#{$primaryStyleName}-bottom-spacer-empty + { + /* Bottom spacer is used in GWT to measure the event height (offsetHeight) */ + height: 15px; + font-size: 11px; +} + +.#{$primaryStyleName}-month .#{$primaryStyleName}-bottom-spacer:hover { + cursor: pointer; + opacity: .6; + filter: alpha(opacity = 60); +} + +.#{$primaryStyleName}-event { + line-height: 14px; + font-size: 11px; + padding: 0 0 0 4px; + cursor: pointer; + overflow: hidden; + text-overflow: ellipsis; + + outline: none; +} + +.#{$primaryStyleName}-event-month { + margin-bottom: 1px; + white-space: nowrap; +} + +.#{$primaryStyleName}-event-month:hover { + text-decoration: underline; +} + +.#{$primaryStyleName}-event-all-day { + background: #999; + display: block; + margin-left: -2px; +} + +div.#{$primaryStyleName}-event-all-day { + color: #fff; + height: 14px; +} + +.#{$primaryStyleName}-event-continued-from { + margin-left: 0; +} + +.#{$primaryStyleName}-event-start { + -webkit-border-top-left-radius: 6px; + -webkit-border-bottom-left-radius: 6px; + -moz-border-radius-topleft: 6px; + -moz-border-radius-bottomleft: 6px; + border-top-left-radius: 6px; + border-bottom-left-radius: 6px; + margin-left: 0; +} + +.#{$primaryStyleName}-event-end { + -webkit-border-top-right-radius: 6px; + -webkit-border-bottom-right-radius: 6px; + -moz-border-radius-topright: 6px; + -moz-border-radius-bottomright: 6px; + border-top-right-radius: 6px; + border-bottom-right-radius: 6px; +} + +/* Week/day view */ +.#{$primaryStyleName}-week-wrapper { + position: relative; +} + +/*.v-ie7 .#{$primaryStyleName}-week-wrapper TABLE{ + table-layout: fixed; +}*/ +.#{$primaryStyleName}-times { + width: 51px; +} + +.#{$primaryStyleName}-time { + padding: 0 8px 7px 0; + margin-top: -7px; + text-align: right; + font-size: 11px; + color: #666; + border-right: 1px solid #ccc; +} + +.#{$primaryStyleName}-weekly-longevents { + border-left: 1px solid #ccc; + border-bottom: 2px solid #bbb; + margin-left: 50px; +} + +.#{$primaryStyleName}-weekly-longevents .#{$primaryStyleName}-datecell { + border-right: 1px solid #ccc; + padding: 1px 0 0; +} + +.#{$primaryStyleName}-weekly-longevents .#{$primaryStyleName}-event { + height: 14px; + margin-bottom: 1px; +} + +.#{$primaryStyleName}-weekly-longevents .#{$primaryStyleName}-event:hover { + text-decoration: underline; +} + +.#{$primaryStyleName}-day-times { + border-right: 1px solid #ccc; + outline: none; +} + +.#{$primaryStyleName}-day-times .v-datecellslot,.#{$primaryStyleName}-day-times .v-datecellslot-even { + border-bottom: 1px solid #ccc; +} + +.#{$primaryStyleName}-day-times .v-datecellslot-even { + border-bottom-color: #eee; +} + +.#{$primaryStyleName}-day-times .v-daterange { + background-color: #a8a8a8; +} + +.#{$primaryStyleName}-day-times .v-reserved { + background-color: #FF3333; +} + +.#{$primaryStyleName}-day-times .dragemphasis { + background-color: #a8a8a8; +} + +.#{$primaryStyleName}-week-wrapper .#{$primaryStyleName}-event { + padding: 0; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + margin-top: -1px; +} + +.#{$primaryStyleName}-event-caption { + position: absolute; + z-index: 1; + top: 2px; + left: 4px; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + line-height: normal; +} + +.#{$primaryStyleName}-event-content { + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + border: 1px solid #777; + background: #eee; + opacity: .8; + filter: alpha(opacity = 80); + height: 14px; /* "min-height" */ +} + +.#{$primaryStyleName}-current-time { + position: absolute; + left: 0; + width: 100%; + height: 1px; + overflow: hidden; + background: #5a6c86; + opacity: .6; + filter: alpha(opacity = 60); + z-index: 2; +} + +.#{$primaryStyleName}-event-resizetop { + position: absolute; + cursor: n-resize; + height: 5%; + min-height: 3px; + top: 0; + width: 100%; + z-index: 1; +} + +.#{$primaryStyleName}-event-resizebottom { + position: absolute; + cursor: s-resize; + height: 5%; + min-height: 3px; + bottom: 0; + width: 100%; + z-index: 1; +} + +.#{$primaryStyleName}-month-sizedheight .#{$primaryStyleName}-month-day { + height: 100px; +} + +.#{$primaryStyleName}-month-sizedwidth .#{$primaryStyleName}-month-day { + width: 100px; +} + +.#{$primaryStyleName}-header-month-Hsized .#{$primaryStyleName}-header-day { + width: 101px; +} + +/* for others */ +.#{$primaryStyleName}-header-month-Hsized td:first-child { + padding-left: 21px; +} + +.#{$primaryStyleName}-header-day-Hsized { + width: 200px; +} + +.#{$primaryStyleName}-week-numbers-Vsized .#{$primaryStyleName}-week-number { + height: 100px; + line-height: 100px; +} + +.#{$primaryStyleName}-week-wrapper-Vsized { + height: 400px; + overflow-x: hidden !important; +} + +.#{$primaryStyleName}-times-Vsized .#{$primaryStyleName}-time { + height: 38px; +} + +.#{$primaryStyleName}-times-Hsized .#{$primaryStyleName}-time { + width: 42px; +} + +.#{$primaryStyleName}-day-times-Vsized .v-datecellslot,.#{$primaryStyleName}-day-times-Vsized .v-datecellslot-even { + height: 18px; +} + +.#{$primaryStyleName}-day-times-Hsized, .#{$primaryStyleName}-day-times-Hsized .v-datecellslot,.#{$primaryStyleName}-day-times-Hsized .v-datecellslot-even { + width: 200px; +} + +} \ No newline at end of file diff --git a/WebContent/VAADIN/themes/base/calendar/img/arrows.png b/WebContent/VAADIN/themes/base/calendar/img/arrows.png new file mode 100644 index 0000000000..9905c0b065 Binary files /dev/null and b/WebContent/VAADIN/themes/base/calendar/img/arrows.png differ diff --git a/WebContent/VAADIN/themes/tests-calendar/styles.css b/WebContent/VAADIN/themes/tests-calendar/styles.css new file mode 100644 index 0000000000..7a37fcfdaf --- /dev/null +++ b/WebContent/VAADIN/themes/tests-calendar/styles.css @@ -0,0 +1,96 @@ +@import url(../reindeer/legacy-styles.css); + +.v-app { + background: #fff; + } + + +/** Customized phase colors*/ + + +/** + * Green + */ + +/* For month view */ +.v-calendar .v-calendar-event-color1 { + color: #4f8324; + } +.v-calendar .v-calendar-event-color1-all-day { + background-color: #61c114; + } + +/* For week/day view */ +.v-calendar .v-calendar-event-color1 .v-calendar-event-caption { + color: #4f8324; + } +.v-calendar .v-calendar-event-color1 .v-calendar-event-content { + border-color: #61c114; + background-color: #daff70; + } + + +/** + * Blue + */ + +/* For month view */ +.v-calendar .v-calendar-event-color2 { + color: #1c4b8b; + } +.v-calendar .v-calendar-event-color2-all-day { + background-color: #0a56bc; + } + +/* For week/day view */ +.v-calendar .v-calendar-event-color2 .v-calendar-event-caption { + color: #1c4b8b; + } +.v-calendar .v-calendar-event-color2 .v-calendar-event-content { + border-color: #0a56bc; + background-color: #529bff; + } + + +/** + * Red + */ + +/* For month view */ +.v-calendar .v-calendar-event-color3 { + color: #831d1d; + } +.v-calendar .v-calendar-event-color3-all-day { + background-color: #bd1a1a; + } + +/* For week/day view */ +.v-calendar .v-calendar-event-color3 .v-calendar-event-caption { + color: #831d1d; + } +.v-calendar .v-calendar-event-color3 .v-calendar-event-content { + border-color: #bd1a1a; + background-color: #ff9d9d; + } + + +/** + * Orange + */ + +/* For month view */ +.v-calendar .v-calendar-event-color4 { + color: #8b5923; + } +.v-calendar .v-calendar-event-color4-all-day { + background-color: #cd6a00; + } + +/* For week/day view */ +.v-calendar .v-calendar-event-color4 .v-calendar-event-caption { + color: #8b5923; + } +.v-calendar .v-calendar-event-color4 .v-calendar-event-content { + border-color: #cd6a00; + background-color: #faa345; + } \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/VCalendar.java b/client/src/com/vaadin/client/ui/VCalendar.java new file mode 100644 index 0000000000..e66a2d7552 --- /dev/null +++ b/client/src/com/vaadin/client/ui/VCalendar.java @@ -0,0 +1,1444 @@ +/* + * Copyright 2000-2013 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.client.ui; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.event.dom.client.ContextMenuHandler; +import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.DockPanel; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ui.calendar.schedule.CalendarDay; +import com.vaadin.client.ui.calendar.schedule.CalendarEvent; +import com.vaadin.client.ui.calendar.schedule.DayToolbar; +import com.vaadin.client.ui.calendar.schedule.MonthGrid; +import com.vaadin.client.ui.calendar.schedule.SimpleDayCell; +import com.vaadin.client.ui.calendar.schedule.SimpleDayToolbar; +import com.vaadin.client.ui.calendar.schedule.SimpleWeekToolbar; +import com.vaadin.client.ui.calendar.schedule.WeekGrid; +import com.vaadin.client.ui.calendar.schedule.WeeklyLongEvents; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * Client side implementation for Calendar + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class VCalendar extends Composite { + + public static final String ATTR_FIRSTDAYOFWEEK = "firstDay"; + public static final String ATTR_LASTDAYOFWEEK = "lastDay"; + public static final String ATTR_FIRSTHOUROFDAY = "firstHour"; + public static final String ATTR_LASTHOUROFDAY = "lastHour"; + + // private boolean hideWeekends; + private String[] monthNames; + private String[] dayNames; + private boolean format; + private final DockPanel outer = new DockPanel(); + private int rows; + + private boolean rangeSelectAllowed = true; + private boolean rangeMoveAllowed = true; + private boolean eventResizeAllowed = true; + private boolean eventMoveAllowed = true; + + private final SimpleDayToolbar nameToolbar = new SimpleDayToolbar(); + + private final DayToolbar dayToolbar = new DayToolbar(this); + private final SimpleWeekToolbar weekToolbar; + private WeeklyLongEvents weeklyLongEvents; + private MonthGrid monthGrid; + private WeekGrid weekGrid; + private int intWidth = 0; + private int intHeight = 0; + + protected final DateTimeFormat dateformat_datetime = DateTimeFormat + .getFormat("yyyy-MM-dd HH:mm:ss"); + protected final DateTimeFormat dateformat_date = DateTimeFormat + .getFormat("yyyy-MM-dd"); + protected final DateTimeFormat time12format_date = DateTimeFormat + .getFormat("h:mm a"); + protected final DateTimeFormat time24format_date = DateTimeFormat + .getFormat("HH:mm"); + + private boolean readOnly = false; + private boolean disabled = false; + + private boolean isHeightUndefined = false; + + private boolean isWidthUndefined = false; + private int firstDay; + private int lastDay; + private int firstHour; + private int lastHour; + + /** + * Listener interface for listening to event click events + */ + public interface DateClickListener { + /** + * Triggered when a date was clicked + * + * @param date + * The date and time that was clicked + */ + void dateClick(String date); + } + + /** + * Listener interface for listening to week number click events + */ + public interface WeekClickListener { + /** + * Called when a week number was selected. + * + * @param event + * The format of the vent string is "w" + */ + void weekClick(String event); + } + + /** + * Listener interface for listening to forward events + */ + public interface ForwardListener { + + /** + * Called when the calendar should move one view forward + */ + void forward(); + } + + /** + * Listener interface for listening to backward events + */ + public interface BackwardListener { + + /** + * Called when the calendar should move one view backward + */ + void backward(); + } + + /** + * Listener interface for listening to selection events + */ + public interface RangeSelectListener { + + /** + * Called when a user selected a new event by highlighting an area of + * the calendar. + * + * FIXME Fix the value nonsense. + * + * @param value + * The format of the value string is + * "::" if called from the + * {@link SimpleWeekToolbar} and "TO" + * if called from {@link MonthGrid} + */ + void rangeSelected(String value); + } + + /** + * Listener interface for listening to click events + */ + public interface EventClickListener { + /** + * Called when an event was clicked + * + * @param event + * The event that was clicked + */ + void eventClick(CalendarEvent event); + } + + /** + * Listener interface for listening to event moved events. Occurs when a + * user drags an event to a new position + */ + public interface EventMovedListener { + /** + * Triggered when an event was dragged to a new position and the start + * and end dates was changed + * + * @param event + * The event that was moved + */ + void eventMoved(CalendarEvent event); + } + + /** + * Listener interface for when an event gets resized (its start or end date + * changes) + */ + public interface EventResizeListener { + /** + * Triggers when the time limits for the event was changed. + * + * @param event + * The event that was changed. The new time limits have been + * updated in the event before calling this method + */ + void eventResized(CalendarEvent event); + } + + /** + * Listener interface for listening to scroll events. + */ + public interface ScrollListener { + /** + * Triggered when the calendar is scrolled + * + * @param scrollPosition + * The scroll position in pixels as returned by + * {@link ScrollPanel#getScrollPosition()} + */ + void scroll(int scrollPosition); + } + + /** + * Listener interface for listening to mouse events. + */ + public interface MouseEventListener { + /** + * Triggered when a user wants an context menu + * + * @param event + * The context menu event + * + * @param widget + * The widget that the context menu should be added to + */ + void contextMenu(ContextMenuEvent event, Widget widget); + } + + /** + * Default constructor + */ + public VCalendar() { + weekToolbar = new SimpleWeekToolbar(this); + initWidget(outer); + setStylePrimaryName("v-calendar"); + blockSelect(getElement()); + } + + /** + * Hack for IE to not select text when dragging. + * + * @param e + * The element to apply the hack on + */ + private native void blockSelect(Element e) + /*-{ + e.onselectstart = function() { + return false; + } + + e.ondragstart = function() { + return false; + } + }-*/; + + private void updateEventsToWeekGrid(CalendarEvent[] events) { + List allDayLong = new ArrayList(); + List belowDayLong = new ArrayList(); + + for (CalendarEvent e : events) { + if (e.isAllDay()) { + // Event is set on one "allDay" event or more than one. + allDayLong.add(e); + + } else { + // Event is set only on one day. + belowDayLong.add(e); + } + } + + weeklyLongEvents.addEvents(allDayLong); + + for (CalendarEvent e : belowDayLong) { + weekGrid.addEvent(e); + } + } + + /** + * Adds events to the month grid + * + * @param events + * The events to add + * @param drawImmediately + * Should the grid be rendered immediately. (currently not in + * use) + * + */ + public void updateEventsToMonthGrid(Collection events, + boolean drawImmediately) { + for (CalendarEvent e : sortEventsByDuration(events)) { + // FIXME Why is drawImmediately not used ????? + addEventToMonthGrid(e, false); + } + } + + private void addEventToMonthGrid(CalendarEvent e, boolean renderImmediately) { + Date when = e.getStart(); + Date to = e.getEnd(); + boolean eventAdded = false; + boolean inProgress = false; // Event adding has started + boolean eventMoving = false; + List dayCells = new ArrayList(); + List timeCells = new ArrayList(); + for (int row = 0; row < monthGrid.getRowCount(); row++) { + if (eventAdded) { + break; + } + for (int cell = 0; cell < monthGrid.getCellCount(row); cell++) { + SimpleDayCell sdc = (SimpleDayCell) monthGrid.getWidget(row, + cell); + if (isEventInDay(when, to, sdc.getDate()) + && isEventInDayWithTime(when, to, sdc.getDate(), + e.getEndTime(), e.isAllDay())) { + if (!eventMoving) { + eventMoving = sdc.getMoveEvent() != null; + } + long d = e.getRangeInMilliseconds(); + if ((d > 0 && d <= DateConstants.DAYINMILLIS) + && !e.isAllDay()) { + timeCells.add(sdc); + } else { + dayCells.add(sdc); + } + inProgress = true; + continue; + } else if (inProgress) { + eventAdded = true; + inProgress = false; + break; + } + } + } + + updateEventSlotIndex(e, dayCells); + updateEventSlotIndex(e, timeCells); + + for (SimpleDayCell sdc : dayCells) { + sdc.addCalendarEvent(e); + } + for (SimpleDayCell sdc : timeCells) { + sdc.addCalendarEvent(e); + } + + if (renderImmediately) { + reDrawAllMonthEvents(!eventMoving); + } + } + + /* + * We must also handle the special case when the event lasts exactly for 24 + * hours, thus spanning two days e.g. from 1.1.2001 00:00 to 2.1.2001 00:00. + * That special case still should span one day when rendered. + */ + @SuppressWarnings("deprecation") + // Date methods are not deprecated in GWT + private boolean isEventInDayWithTime(Date from, Date to, Date date, + Date endTime, boolean isAllDay) { + return (isAllDay || !(to.getDay() == date.getDay() + && from.getDay() != to.getDay() && isMidnight(endTime))); + } + + private void updateEventSlotIndex(CalendarEvent e, List cells) { + if (cells.isEmpty()) { + return; + } + + if (e.getSlotIndex() == -1) { + // Update slot index + int newSlot = -1; + for (SimpleDayCell sdc : cells) { + int slot = sdc.getEventCount(); + if (slot > newSlot) { + newSlot = slot; + } + } + newSlot++; + + for (int i = 0; i < newSlot; i++) { + // check for empty slot + if (isSlotEmpty(e, i, cells)) { + newSlot = i; + break; + } + } + e.setSlotIndex(newSlot); + } + } + + private void reDrawAllMonthEvents(boolean clearCells) { + for (int row = 0; row < monthGrid.getRowCount(); row++) { + for (int cell = 0; cell < monthGrid.getCellCount(row); cell++) { + SimpleDayCell sdc = (SimpleDayCell) monthGrid.getWidget(row, + cell); + sdc.reDraw(clearCells); + } + } + } + + private boolean isSlotEmpty(CalendarEvent addedEvent, int slotIndex, + List cells) { + for (SimpleDayCell sdc : cells) { + CalendarEvent e = sdc.getCalendarEvent(slotIndex); + if (e != null && !e.equals(addedEvent)) { + return false; + } + } + return true; + } + + /** + * Remove a month event from the view + * + * @param target + * The event to remove + * + * @param repaintImmediately + * Should we repaint after the event was removed? + */ + public void removeMonthEvent(CalendarEvent target, + boolean repaintImmediately) { + if (target != null && target.getSlotIndex() >= 0) { + // Remove event + for (int row = 0; row < monthGrid.getRowCount(); row++) { + for (int cell = 0; cell < monthGrid.getCellCount(row); cell++) { + SimpleDayCell sdc = (SimpleDayCell) monthGrid.getWidget( + row, cell); + if (sdc == null) { + return; + } + sdc.removeEvent(target, repaintImmediately); + } + } + } + } + + /** + * Updates an event in the month grid + * + * @param changedEvent + * The event that has changed + */ + public void updateEventToMonthGrid(CalendarEvent changedEvent) { + removeMonthEvent(changedEvent, true); + changedEvent.setSlotIndex(-1); + addEventToMonthGrid(changedEvent, true); + } + + /** + * Sort the event by how long they are + * + * @param events + * The events to sort + * @return An array where the events has been sorted + */ + public CalendarEvent[] sortEventsByDuration(Collection events) { + CalendarEvent[] sorted = events + .toArray(new CalendarEvent[events.size()]); + Arrays.sort(sorted, getEventComparator()); + return sorted; + } + + /* + * Check if the given event occurs at the given date. + */ + private boolean isEventInDay(Date eventWhen, Date eventTo, Date gridDate) { + if (eventWhen.compareTo(gridDate) <= 0 + && eventTo.compareTo(gridDate) >= 0) { + + return true; + } + + return false; + } + + /** + * Re-render the week grid + * + * @param daysCount + * The amount of days to include in the week + * @param days + * The days + * @param today + * Todays date + * @param realDayNames + * The names of the dates + */ + @SuppressWarnings("deprecation") + public void updateWeekGrid(int daysCount, List days, + Date today, String[] realDayNames) { + weekGrid.setFirstHour(getFirstHourOfTheDay()); + weekGrid.setLastHour(getLastHourOfTheDay()); + weekGrid.getTimeBar().updateTimeBar(is24HFormat()); + + dayToolbar.clear(); + dayToolbar.addBackButton(); + dayToolbar.setVerticalSized(isHeightUndefined); + dayToolbar.setHorizontalSized(isWidthUndefined); + weekGrid.clearDates(); + weekGrid.setDisabled(isDisabledOrReadOnly()); + + for (CalendarDay day : days) { + String date = day.getDate(); + String localized_date_format = day.getLocalizedDateFormat(); + Date d = dateformat_date.parse(date); + int dayOfWeek = day.getDayOfWeek(); + if (dayOfWeek < getFirstDayNumber() + || dayOfWeek > getLastDayNumber()) { + continue; + } + boolean isToday = false; + int dayOfMonth = d.getDate(); + if (today.getDate() == dayOfMonth && today.getYear() == d.getYear() + && today.getMonth() == d.getMonth()) { + isToday = true; + } + dayToolbar.add(realDayNames[dayOfWeek - 1], date, + localized_date_format, isToday ? "today" : null); + weeklyLongEvents.addDate(d); + weekGrid.addDate(d); + if (isToday) { + weekGrid.setToday(d, today); + } + } + dayToolbar.addNextButton(); + } + + /** + * Updates the events in the Month view + * + * @param daysCount + * How many days there are + * @param daysUidl + * + * @param today + * Todays date + */ + @SuppressWarnings("deprecation") + public void updateMonthGrid(int daysCount, List days, + Date today) { + int columns = getLastDayNumber() - getFirstDayNumber() + 1; + rows = (int) Math.ceil(daysCount / (double) 7); + + monthGrid = new MonthGrid(this, rows, columns); + monthGrid.setEnabled(!isDisabledOrReadOnly()); + weekToolbar.removeAllRows(); + int pos = 0; + boolean monthNameDrawn = true; + boolean firstDayFound = false; + boolean lastDayFound = false; + + for (CalendarDay day : days) { + String date = day.getDate(); + Date d = dateformat_date.parse(date); + int dayOfWeek = day.getDayOfWeek(); + int week = day.getWeek(); + + int dayOfMonth = d.getDate(); + + // reset at start of each month + if (dayOfMonth == 1) { + monthNameDrawn = false; + if (firstDayFound) { + lastDayFound = true; + } + firstDayFound = true; + } + + if (dayOfWeek < getFirstDayNumber() + || dayOfWeek > getLastDayNumber()) { + continue; + } + int y = (pos / columns); + int x = pos - (y * columns); + if (x == 0 && daysCount > 7) { + // Add week to weekToolbar for navigation + weekToolbar.addWeek(week, d.getYear()); + } + final SimpleDayCell cell = new SimpleDayCell(this, y, x); + cell.setMonthGrid(monthGrid); + cell.setDate(d); + cell.addDomHandler(new ContextMenuHandler() { + public void onContextMenu(ContextMenuEvent event) { + if (mouseEventListener != null) { + event.preventDefault(); + event.stopPropagation(); + mouseEventListener.contextMenu(event, cell); + } + } + }, ContextMenuEvent.getType()); + + if (!firstDayFound) { + cell.addStyleDependentName("prev-month"); + } else if (lastDayFound) { + cell.addStyleDependentName("next-month"); + } + + if (dayOfMonth >= 1 && !monthNameDrawn) { + cell.setMonthNameVisible(true); + monthNameDrawn = true; + } + + if (today.getDate() == dayOfMonth && today.getYear() == d.getYear() + && today.getMonth() == d.getMonth()) { + cell.setToday(true); + + } + monthGrid.setWidget(y, x, cell); + pos++; + } + } + + public void setSizeForChildren(int newWidth, int newHeight) { + intWidth = newWidth; + intHeight = newHeight; + isWidthUndefined = intWidth == -1; + dayToolbar.setVerticalSized(isHeightUndefined); + dayToolbar.setHorizontalSized(isWidthUndefined); + recalculateWidths(); + recalculateHeights(); + } + + /** + * Recalculates the heights of the sub-components in the calendar + */ + protected void recalculateHeights() { + if (monthGrid != null) { + + if (intHeight == -1) { + monthGrid.addStyleDependentName("sizedheight"); + } else { + monthGrid.removeStyleDependentName("sizedheight"); + } + + monthGrid.updateCellSizes(intWidth - weekToolbar.getOffsetWidth(), + intHeight - nameToolbar.getOffsetHeight()); + weekToolbar.setHeightPX((intHeight == -1) ? intHeight : intHeight + - nameToolbar.getOffsetHeight()); + + } else if (weekGrid != null) { + weekGrid.setHeightPX((intHeight == -1) ? intHeight : intHeight + - weeklyLongEvents.getOffsetHeight() + - dayToolbar.getOffsetHeight()); + } + } + + /** + * Recalculates the widths of the sub-components in the calendar + */ + protected void recalculateWidths() { + if (!isWidthUndefined) { + nameToolbar.setWidthPX(intWidth); + dayToolbar.setWidthPX(intWidth); + + if (monthGrid != null) { + monthGrid.updateCellSizes( + intWidth - weekToolbar.getOffsetWidth(), intHeight + - nameToolbar.getOffsetHeight()); + } else if (weekGrid != null) { + weekGrid.setWidthPX(intWidth); + weeklyLongEvents.setWidthPX(weekGrid.getInternalWidth()); + } + } else { + dayToolbar.setWidthPX(intWidth); + nameToolbar.setWidthPX(intWidth); + + if (monthGrid != null) { + if (intWidth == -1) { + monthGrid.addStyleDependentName("sizedwidth"); + + } else { + monthGrid.removeStyleDependentName("sizedwidth"); + } + } else if (weekGrid != null) { + weekGrid.setWidthPX(intWidth); + weeklyLongEvents.setWidthPX(weekGrid.getInternalWidth()); + } + } + } + + /** + * Get the date format used to format dates only (excludes time) + * + * @return + */ + public DateTimeFormat getDateFormat() { + return dateformat_date; + } + + /** + * Get the time format used to format time only (excludes date) + * + * @return + */ + public DateTimeFormat getTimeFormat() { + if (is24HFormat()) { + return time24format_date; + } + return time12format_date; + } + + /** + * Get the date and time format to format the dates (includes both date and + * time) + * + * @return + */ + public DateTimeFormat getDateTimeFormat() { + return dateformat_datetime; + } + + /** + * Is the calendar either disabled or readonly + * + * @return + */ + public boolean isDisabledOrReadOnly() { + return disabled || readOnly; + } + + /** + * Is the component disabled + */ + public boolean isDisabled() { + return disabled; + } + + /** + * Is the component disabled + * + * @param disabled + * True if disabled + */ + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + /** + * Is the component read-only + */ + public boolean isReadOnly() { + return readOnly; + } + + /** + * Is the component read-only + * + * @param readOnly + * True if component is readonly + */ + public void setReadOnly(boolean readOnly) { + this.readOnly = readOnly; + } + + /** + * Get the month grid component + * + * @return + */ + public MonthGrid getMonthGrid() { + return monthGrid; + } + + /** + * Get he week grid component + * + * @return + */ + public WeekGrid getWeekGrid() { + return weekGrid; + } + + /** + * Calculates correct size for all cells (size / amount of cells ) and + * distributes any overflow over all the cells. + * + * @param totalSize + * the total amount of size reserved for all cells + * @param numberOfCells + * the number of cells + * @param sizeModifier + * a modifier which is applied to all cells before distributing + * the overflow + * @return an integer array that contains the correct size for each cell + */ + public static int[] distributeSize(int totalSize, int numberOfCells, + int sizeModifier) { + int[] cellSizes = new int[numberOfCells]; + int startingSize = totalSize / numberOfCells; + int cellSizeOverFlow = totalSize % numberOfCells; + + for (int i = 0; i < numberOfCells; i++) { + cellSizes[i] = startingSize + sizeModifier; + } + + // distribute size overflow amongst all slots + int j = 0; + while (cellSizeOverFlow > 0) { + cellSizes[j]++; + cellSizeOverFlow--; + j++; + if (j >= numberOfCells) { + j = 0; + } + } + + // cellSizes[numberOfCells - 1] += cellSizeOverFlow; + + return cellSizes; + } + + /** + * Returns a comparator which can compare calendar events. + * + * @return + */ + public static Comparator getEventComparator() { + return new Comparator() { + + public int compare(CalendarEvent o1, CalendarEvent o2) { + if (o1.isAllDay() != o2.isAllDay()) { + if (o2.isAllDay()) { + return 1; + } + return -1; + } + + Long d1 = o1.getRangeInMilliseconds(); + Long d2 = o2.getRangeInMilliseconds(); + int r = 0; + if (!d1.equals(0L) && !d2.equals(0L)) { + r = d2.compareTo(d1); + return (r == 0) ? ((Integer) o2.getIndex()).compareTo(o1 + .getIndex()) : r; + } + + if (d2.equals(0L) && d1.equals(0L)) { + return ((Integer) o2.getIndex()).compareTo(o1.getIndex()); + } else if (d2.equals(0L) && d1 >= DateConstants.DAYINMILLIS) { + return -1; + } else if (d2.equals(0L) && d1 < DateConstants.DAYINMILLIS) { + return 1; + } else if (d1.equals(0L) && d2 >= DateConstants.DAYINMILLIS) { + return 1; + } else if (d1.equals(0L) && d2 < DateConstants.DAYINMILLIS) { + return -1; + } + r = d2.compareTo(d1); + return (r == 0) ? ((Integer) o2.getIndex()).compareTo(o1 + .getIndex()) : r; + } + }; + } + + /** + * Is the date at midnight + * + * @param date + * The date to check + * + * @return + */ + @SuppressWarnings("deprecation") + public static boolean isMidnight(Date date) { + return (date.getHours() == 0 && date.getMinutes() == 0 && date + .getSeconds() == 0); + } + + /** + * Are the dates equal (uses second resolution) + * + * @param date1 + * The first the to compare + * @param date2 + * The second date to compare + * @return + */ + @SuppressWarnings("deprecation") + public static boolean areDatesEqualToSecond(Date date1, Date date2) { + return date1.getYear() == date2.getYear() + && date1.getMonth() == date2.getMonth() + && date1.getDay() == date2.getDay() + && date1.getHours() == date2.getHours() + && date1.getSeconds() == date2.getSeconds(); + } + + /** + * Is the calendar event zero seconds long and is occurring at midnight + * + * @param event + * The event to check + * @return + */ + public static boolean isZeroLengthMidnightEvent(CalendarEvent event) { + return areDatesEqualToSecond(event.getStartTime(), event.getEndTime()) + && isMidnight(event.getEndTime()); + } + + /** + * Should the 24h time format be used + * + * @param format + * True if the 24h format should be used else the 12h format is + * used + */ + public void set24HFormat(boolean format) { + this.format = format; + } + + /** + * Is the 24h time format used + */ + public boolean is24HFormat() { + return format; + } + + /** + * Set the names of the week days + * + * @param names + * The names of the days (Monday, Thursday,...) + */ + public void setDayNames(String[] names) { + assert (names.length == 7); + dayNames = names; + } + + /** + * Get the names of the week days + */ + public String[] getDayNames() { + return dayNames; + } + + /** + * Set the names of the months + * + * @param names + * The names of the months (January, February,...) + */ + public void setMonthNames(String[] names) { + assert (names.length == 12); + monthNames = names; + } + + /** + * Get the month names + */ + public String[] getMonthNames() { + return monthNames; + } + + /** + * Set the number when a week starts + * + * @param dayNumber + * The number of the day + */ + public void setFirstDayNumber(int dayNumber) { + assert (dayNumber >= 1 && dayNumber <= 7); + firstDay = dayNumber; + } + + /** + * Get the number when a week starts + */ + public int getFirstDayNumber() { + return firstDay; + } + + /** + * Set the number when a week ends + * + * @param dayNumber + * The number of the day + */ + public void setLastDayNumber(int dayNumber) { + assert (dayNumber >= 1 && dayNumber <= 7); + lastDay = dayNumber; + } + + /** + * Get the number when a week ends + */ + public int getLastDayNumber() { + return lastDay; + } + + /** + * Set the number when a week starts + * + * @param dayNumber + * The number of the day + */ + public void setFirstHourOfTheDay(int hour) { + assert (hour >= 0 && hour <= 23); + firstHour = hour; + } + + /** + * Get the number when a week starts + */ + public int getFirstHourOfTheDay() { + return firstHour; + } + + /** + * Set the number when a week ends + * + * @param dayNumber + * The number of the day + */ + public void setLastHourOfTheDay(int hour) { + assert (hour >= 0 && hour <= 23); + lastHour = hour; + } + + /** + * Get the number when a week ends + */ + public int getLastHourOfTheDay() { + return lastHour; + } + + /** + * Re-renders the whole week view + * + * @param scroll + * The amount of pixels to scroll the week view + * @param today + * Todays date + * @param daysInMonth + * How many days are there in the month + * @param firstDayOfWeek + * The first day of the week + * @param events + * The events to render + */ + public void updateWeekView(int scroll, Date today, int daysInMonth, + int firstDayOfWeek, Collection events, + List days) { + + while (outer.getWidgetCount() > 0) { + outer.remove(0); + } + + monthGrid = null; + String[] realDayNames = new String[getDayNames().length]; + int j = 0; + + if (firstDayOfWeek == 2) { + for (int i = 1; i < getDayNames().length; i++) { + realDayNames[j++] = getDayNames()[i]; + } + realDayNames[j] = getDayNames()[0]; + } else { + for (int i = 0; i < getDayNames().length; i++) { + realDayNames[j++] = getDayNames()[i]; + } + + } + + weeklyLongEvents = new WeeklyLongEvents(this); + if (weekGrid == null) { + weekGrid = new WeekGrid(this, is24HFormat()); + } + updateWeekGrid(daysInMonth, days, today, realDayNames); + updateEventsToWeekGrid(sortEventsByDuration(events)); + outer.add(dayToolbar, DockPanel.NORTH); + outer.add(weeklyLongEvents, DockPanel.NORTH); + outer.add(weekGrid, DockPanel.SOUTH); + weekGrid.setVerticalScrollPosition(scroll); + } + + /** + * Re-renders the whole month view + * + * @param firstDayOfWeek + * The first day of the week + * @param today + * Todays date + * @param daysInMonth + * Amount of days in the month + * @param events + * The events to render + * @param days + * The day information + */ + public void updateMonthView(int firstDayOfWeek, Date today, + int daysInMonth, Collection events, + List days) { + + // Remove all week numbers from bar + while (outer.getWidgetCount() > 0) { + outer.remove(0); + } + + int firstDay = getFirstDayNumber(); + int lastDay = getLastDayNumber(); + int daysPerWeek = lastDay - firstDay + 1; + int j = 0; + + String[] dayNames = getDayNames(); + String[] realDayNames = new String[daysPerWeek]; + + if (firstDayOfWeek == 2) { + for (int i = firstDay; i < lastDay + 1; i++) { + if (i == 7) { + realDayNames[j++] = dayNames[0]; + } else { + realDayNames[j++] = dayNames[i]; + } + } + } else { + for (int i = firstDay - 1; i < lastDay; i++) { + realDayNames[j++] = dayNames[i]; + } + } + + nameToolbar.setDayNames(realDayNames); + + weeklyLongEvents = null; + weekGrid = null; + + updateMonthGrid(daysInMonth, days, today); + + outer.add(nameToolbar, DockPanel.NORTH); + outer.add(weekToolbar, DockPanel.WEST); + weekToolbar.updateCellHeights(); + outer.add(monthGrid, DockPanel.CENTER); + + updateEventsToMonthGrid(events, false); + } + + private DateClickListener dateClickListener; + + /** + * Sets the listener for listening to event clicks + * + * @param listener + * The listener to use + */ + public void setListener(DateClickListener listener) { + dateClickListener = listener; + } + + /** + * Gets the listener for listening to event clicks + * + * @return + */ + public DateClickListener getDateClickListener() { + return dateClickListener; + } + + private ForwardListener forwardListener; + + /** + * Set the listener which listens to forward events from the calendar + * + * @param listener + * The listener to use + */ + public void setListener(ForwardListener listener) { + forwardListener = listener; + } + + /** + * Get the listener which listens to forward events from the calendar + * + * @return + */ + public ForwardListener getForwardListener() { + return forwardListener; + } + + private BackwardListener backwardListener; + + /** + * Set the listener which listens to backward events from the calendar + * + * @param listener + * The listener to use + */ + public void setListener(BackwardListener listener) { + backwardListener = listener; + } + + /** + * Set the listener which listens to backward events from the calendar + * + * @return + */ + public BackwardListener getBackwardListener() { + return backwardListener; + } + + private WeekClickListener weekClickListener; + + /** + * Set the listener that listens to user clicking on the week numbers + * + * @param listener + * The listener to use + */ + public void setListener(WeekClickListener listener) { + weekClickListener = listener; + } + + /** + * Get the listener that listens to user clicking on the week numbers + * + * @return + */ + public WeekClickListener getWeekClickListener() { + return weekClickListener; + } + + private RangeSelectListener rangeSelectListener; + + /** + * Set the listener that listens to the user highlighting a region in the + * calendar + * + * @param listener + * The listener to use + */ + public void setListener(RangeSelectListener listener) { + rangeSelectListener = listener; + } + + /** + * Get the listener that listens to the user highlighting a region in the + * calendar + * + * @return + */ + public RangeSelectListener getRangeSelectListener() { + return rangeSelectListener; + } + + private EventClickListener eventClickListener; + + /** + * Get the listener that listens to the user clicking on the events + */ + public EventClickListener getEventClickListener() { + return eventClickListener; + } + + /** + * Set the listener that listens to the user clicking on the events + * + * @param listener + * The listener to use + */ + public void setListener(EventClickListener listener) { + eventClickListener = listener; + } + + private EventMovedListener eventMovedListener; + + /** + * Get the listener that listens to when event is dragged to a new location + * + * @return + */ + public EventMovedListener getEventMovedListener() { + return eventMovedListener; + } + + /** + * Set the listener that listens to when event is dragged to a new location + * + * @param eventMovedListener + * The listener to use + */ + public void setListener(EventMovedListener eventMovedListener) { + this.eventMovedListener = eventMovedListener; + } + + private ScrollListener scrollListener; + + /** + * Get the listener that listens to when the calendar widget is scrolled + * + * @return + */ + public ScrollListener getScrollListener() { + return scrollListener; + } + + /** + * Set the listener that listens to when the calendar widget is scrolled + * + * @param scrollListener + * The listener to use + */ + public void setListener(ScrollListener scrollListener) { + this.scrollListener = scrollListener; + } + + private EventResizeListener eventResizeListener; + + /** + * Get the listener that listens to when an events time limits are being + * adjusted + * + * @return + */ + public EventResizeListener getEventResizeListener() { + return eventResizeListener; + } + + /** + * Set the listener that listens to when an events time limits are being + * adjusted + * + * @param eventResizeListener + * The listener to use + */ + public void setListener(EventResizeListener eventResizeListener) { + this.eventResizeListener = eventResizeListener; + } + + private MouseEventListener mouseEventListener; + private boolean forwardNavigationEnabled = true; + private boolean backwardNavigationEnabled = true; + + /** + * Get the listener that listen to mouse events + * + * @return + */ + public MouseEventListener getMouseEventListener() { + return mouseEventListener; + } + + /** + * Set the listener that listen to mouse events + * + * @param mouseEventListener + * The listener to use + */ + public void setListener(MouseEventListener mouseEventListener) { + this.mouseEventListener = mouseEventListener; + } + + /** + * Is selecting a range allowed? + */ + public boolean isRangeSelectAllowed() { + return rangeSelectAllowed; + } + + /** + * Set selecting a range allowed + * + * @param rangeSelectAllowed + * Should selecting a range be allowed + */ + public void setRangeSelectAllowed(boolean rangeSelectAllowed) { + this.rangeSelectAllowed = rangeSelectAllowed; + } + + /** + * Is moving a range allowed + * + * @return + */ + public boolean isRangeMoveAllowed() { + return rangeMoveAllowed; + } + + /** + * Is moving a range allowed + * + * @param rangeMoveAllowed + * Is it allowed + */ + public void setRangeMoveAllowed(boolean rangeMoveAllowed) { + this.rangeMoveAllowed = rangeMoveAllowed; + } + + /** + * Is resizing an event allowed + */ + public boolean isEventResizeAllowed() { + return eventResizeAllowed; + } + + /** + * Is resizing an event allowed + * + * @param eventResizeAllowed + * True if allowed false if not + */ + public void setEventResizeAllowed(boolean eventResizeAllowed) { + this.eventResizeAllowed = eventResizeAllowed; + } + + /** + * Is moving an event allowed + */ + public boolean isEventMoveAllowed() { + return eventMoveAllowed; + } + + /** + * Is moving an event allowed + * + * @param eventMoveAllowed + * True if moving is allowed, false if not + */ + public void setEventMoveAllowed(boolean eventMoveAllowed) { + this.eventMoveAllowed = eventMoveAllowed; + } + + public boolean isBackwardNavigationEnabled() { + return backwardNavigationEnabled; + } + + public void setBackwardNavigationEnabled(boolean enabled) { + backwardNavigationEnabled = enabled; + } + + public boolean isForwardNavigationEnabled() { + return forwardNavigationEnabled; + } + + public void setForwardNavigationEnabled(boolean enabled) { + forwardNavigationEnabled = enabled; + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java new file mode 100644 index 0000000000..120a65d842 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java @@ -0,0 +1,637 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import com.google.gwt.core.shared.GWT; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.TooltipInfo; +import com.vaadin.client.UIDL; +import com.vaadin.client.Util; +import com.vaadin.client.VConsole; +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.client.ui.VCalendar; +import com.vaadin.client.ui.VCalendar.BackwardListener; +import com.vaadin.client.ui.VCalendar.DateClickListener; +import com.vaadin.client.ui.VCalendar.EventClickListener; +import com.vaadin.client.ui.VCalendar.EventMovedListener; +import com.vaadin.client.ui.VCalendar.EventResizeListener; +import com.vaadin.client.ui.VCalendar.ForwardListener; +import com.vaadin.client.ui.VCalendar.MouseEventListener; +import com.vaadin.client.ui.VCalendar.RangeSelectListener; +import com.vaadin.client.ui.VCalendar.WeekClickListener; +import com.vaadin.client.ui.calendar.schedule.CalendarDay; +import com.vaadin.client.ui.calendar.schedule.CalendarEvent; +import com.vaadin.client.ui.calendar.schedule.DateCell; +import com.vaadin.client.ui.calendar.schedule.DateCell.DateCellSlot; +import com.vaadin.client.ui.calendar.schedule.DateUtil; +import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent; +import com.vaadin.client.ui.calendar.schedule.HasTooltipKey; +import com.vaadin.client.ui.calendar.schedule.SimpleDayCell; +import com.vaadin.client.ui.calendar.schedule.dd.CalendarDropHandler; +import com.vaadin.client.ui.dd.VHasDropHandler; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.Connect.LoadStyle; +import com.vaadin.shared.ui.calendar.CalendarClientRpc; +import com.vaadin.shared.ui.calendar.CalendarEventId; +import com.vaadin.shared.ui.calendar.CalendarServerRpc; +import com.vaadin.shared.ui.calendar.CalendarState; +import com.vaadin.shared.ui.calendar.DateConstants; +import com.vaadin.ui.Calendar; + +/** + * Handles communication between Calendar on the server side and + * {@link VCalendar} on the client side. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@Connect(value = Calendar.class, loadStyle = LoadStyle.LAZY) +public class CalendarConnector extends AbstractComponentConnector implements + VHasDropHandler, ActionOwner, SimpleManagedLayout { + + private CalendarServerRpc rpc = RpcProxy.create(CalendarServerRpc.class, + this); + + private CalendarDropHandler dropHandler; + + private final HashMap actionMap = new HashMap(); + private HashMap tooltips = new HashMap(); + + /** + * + */ + public CalendarConnector() { + + // Listen to events + registerListeners(); + } + + @Override + protected void init() { + super.init(); + registerRpc(CalendarClientRpc.class, new CalendarClientRpc() { + @Override + public void scroll(int scrollPosition) { + // TODO widget scroll + } + }); + getLayoutManager().registerDependency(this, getWidget().getElement()); + } + + @Override + public void onUnregister() { + super.onUnregister(); + getLayoutManager().unregisterDependency(this, getWidget().getElement()); + } + + @Override + public VCalendar getWidget() { + return (VCalendar) super.getWidget(); + } + + @Override + public CalendarState getState() { + return (CalendarState) super.getState(); + } + + /** + * Registers listeners on the calendar so server can be notified of the + * events + */ + protected void registerListeners() { + getWidget().setListener(new DateClickListener() { + public void dateClick(String date) { + if (!getWidget().isDisabledOrReadOnly() + && hasEventListener(CalendarEventId.DATECLICK)) { + rpc.dateClick(date); + } + } + }); + getWidget().setListener(new ForwardListener() { + public void forward() { + if (hasEventListener(CalendarEventId.FORWARD)) { + rpc.forward(); + } + } + }); + getWidget().setListener(new BackwardListener() { + public void backward() { + if (hasEventListener(CalendarEventId.BACKWARD)) { + rpc.backward(); + } + } + }); + getWidget().setListener(new RangeSelectListener() { + public void rangeSelected(String value) { + if (hasEventListener(CalendarEventId.RANGESELECT)) { + rpc.rangeSelect(value); + } + } + }); + getWidget().setListener(new WeekClickListener() { + public void weekClick(String event) { + if (!getWidget().isDisabledOrReadOnly() + && hasEventListener(CalendarEventId.WEEKCLICK)) { + rpc.weekClick(event); + } + } + }); + getWidget().setListener(new EventMovedListener() { + public void eventMoved(CalendarEvent event) { + if (hasEventListener(CalendarEventId.EVENTMOVE)) { + StringBuilder sb = new StringBuilder(); + sb.append(DateUtil.formatClientSideDate(event.getStart())); + sb.append("-"); + sb.append(DateUtil.formatClientSideTime(event + .getStartTime())); + rpc.eventMove(event.getIndex(), sb.toString()); + } + } + }); + getWidget().setListener(new EventResizeListener() { + public void eventResized(CalendarEvent event) { + if (hasEventListener(CalendarEventId.EVENTRESIZE)) { + StringBuilder buffer = new StringBuilder(); + + buffer.append(DateUtil.formatClientSideDate(event + .getStart())); + buffer.append("-"); + buffer.append(DateUtil.formatClientSideTime(event + .getStartTime())); + + String newStartDate = buffer.toString(); + + buffer = new StringBuilder(); + buffer.append(DateUtil.formatClientSideDate(event.getEnd())); + buffer.append("-"); + buffer.append(DateUtil.formatClientSideTime(event + .getEndTime())); + + String newEndDate = buffer.toString(); + + rpc.eventResize(event.getIndex(), newStartDate, newEndDate); + } + } + }); + getWidget().setListener(new VCalendar.ScrollListener() { + public void scroll(int scrollPosition) { + // This call is @Delayed (== non-immediate) + rpc.scroll(scrollPosition); + } + }); + getWidget().setListener(new EventClickListener() { + public void eventClick(CalendarEvent event) { + if (hasEventListener(CalendarEventId.EVENTCLICK)) { + rpc.eventClick(event.getIndex()); + } + } + }); + getWidget().setListener(new MouseEventListener() { + public void contextMenu(ContextMenuEvent event, final Widget widget) { + final NativeEvent ne = event.getNativeEvent(); + int left = ne.getClientX(); + int top = ne.getClientY(); + top += Window.getScrollTop(); + left += Window.getScrollLeft(); + getClient().getContextMenu().showAt(new ActionOwner() { + public String getPaintableId() { + return CalendarConnector.this.getPaintableId(); + } + + public ApplicationConnection getClient() { + return CalendarConnector.this.getClient(); + } + + @SuppressWarnings("deprecation") + public Action[] getActions() { + if (widget instanceof SimpleDayCell) { + /* + * Month view + */ + SimpleDayCell cell = (SimpleDayCell) widget; + Date start = new Date(cell.getDate().getYear(), + cell.getDate().getMonth(), cell.getDate() + .getDate(), 0, 0, 0); + + Date end = new Date(cell.getDate().getYear(), cell + .getDate().getMonth(), cell.getDate() + .getDate(), 23, 59, 59); + + return CalendarConnector.this.getActionsBetween( + start, end); + } else if (widget instanceof DateCell) { + /* + * Week and Day view + */ + DateCell cell = (DateCell) widget; + int slotIndex = DOM.getChildIndex( + cell.getElement(), (Element) ne + .getEventTarget().cast()); + DateCellSlot slot = cell.getSlot(slotIndex); + return CalendarConnector.this.getActionsBetween( + slot.getFrom(), slot.getTo()); + } else if (widget instanceof DateCellDayEvent) { + /* + * Context menu on event + */ + DateCellDayEvent dayEvent = (DateCellDayEvent) widget; + CalendarEvent event = dayEvent.getCalendarEvent(); + Action[] actions = CalendarConnector.this + .getActionsBetween(event.getStartTime(), + event.getEndTime()); + for (Action action : actions) { + ((VCalendarAction) action).setEvent(event); + } + return actions; + + } + return null; + } + }, left, top); + } + }); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + CalendarState state = getState(); + VCalendar widget = getWidget(); + boolean monthView = state.days.size() > 7; + + // Enable or disable the forward and backward navigation buttons + widget.setForwardNavigationEnabled(hasEventListener(CalendarEventId.FORWARD)); + widget.setBackwardNavigationEnabled(hasEventListener(CalendarEventId.BACKWARD)); + + widget.set24HFormat(state.format24H); + widget.setDayNames(state.dayNames); + widget.setMonthNames(state.monthNames); + widget.setFirstDayNumber(state.firstVisibleDayOfWeek); + widget.setLastDayNumber(state.lastVisibleDayOfWeek); + widget.setFirstHourOfTheDay(state.firstHourOfDay); + widget.setLastHourOfTheDay(state.lastHourOfDay); + widget.setReadOnly(state.readOnly); + widget.setDisabled(!state.enabled); + + widget.setRangeSelectAllowed(hasEventListener(CalendarEventId.RANGESELECT)); + widget.setRangeMoveAllowed(hasEventListener(CalendarEventId.EVENTMOVE)); + widget.setEventMoveAllowed(hasEventListener(CalendarEventId.EVENTMOVE)); + widget.setEventResizeAllowed(hasEventListener(CalendarEventId.EVENTRESIZE)); + + List days = state.days; + List events = state.events; + + if (monthView) { + updateMonthView(days, events); + } else { + updateWeekView(days, events); + } + + updateSizes(); + + registerEventToolTips(state.events); + updateActionMap(state.actions); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal + * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection) + */ + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + + // check for DD -related access criteria + // Iterator childIterator = uidl.getChildIterator(); + // while (childIterator.hasNext()) { + // UIDL child = (UIDL) childIterator.next(); + // + // // Drag&drop + // if (ACCESSCRITERIA.equals(child.getTag())) { + // if (monthView + // && !(getDropHandler() instanceof CalendarMonthDropHandler)) { + // setDropHandler(new CalendarMonthDropHandler()); + // + // } else if (!monthView + // && !(getDropHandler() instanceof CalendarWeekDropHandler)) { + // setDropHandler(new CalendarWeekDropHandler()); + // } + // + // getDropHandler().setCalendarPaintable(this); + // getDropHandler().updateAcceptRules(child); + // + // } else { + // setDropHandler(null); + // } + // + // } + } + + /** + * Returns the ApplicationConnection used to connect to the server side + */ + @Override + public ApplicationConnection getClient() { + return getConnection(); + } + + /** + * Register the description of the events as tooltips. This way, any event + * displaying widget can use the event index as a key to display the + * tooltip. + */ + private void registerEventToolTips(List events) { + for (CalendarState.Event e : events) { + if (e.description != null && !"".equals(e.description)) { + tooltips.put(e.index, e.description); + } else { + tooltips.remove(e.index); + } + } + } + + @Override + public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { + TooltipInfo tooltipInfo = null; + Widget w = Util.findWidget((Element) element, null); + if (w instanceof HasTooltipKey) { + tooltipInfo = GWT.create(TooltipInfo.class); + String title = tooltips.get(((HasTooltipKey) w).getTooltipKey()); + tooltipInfo.setTitle(title != null ? title : ""); + } + if (tooltipInfo == null) { + tooltipInfo = super.getTooltipInfo(element); + } + return tooltipInfo; + } + + private void updateMonthView(List days, + List events) { + CalendarState state = getState(); + getWidget().updateMonthView(state.firstDayOfWeek, + getWidget().getDateTimeFormat().parse(state.now), days.size(), + calendarEventListOf(events, state.format24H), + calendarDayListOf(days)); + } + + private void updateWeekView(List days, + List events) { + CalendarState state = getState(); + getWidget().updateWeekView(state.scroll, + getWidget().getDateTimeFormat().parse(state.now), days.size(), + state.firstDayOfWeek, + calendarEventListOf(events, state.format24H), + calendarDayListOf(days)); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler#getDropHandler() + */ + public CalendarDropHandler getDropHandler() { + return dropHandler; + } + + /** + * Set the drop handler + * + * @param dropHandler + * The drophandler to use + */ + public void setDropHandler(CalendarDropHandler dropHandler) { + this.dropHandler = dropHandler; + } + + private Action[] getActionsBetween(Date start, Date end) { + List actions = new ArrayList(); + for (int i = 0; i < actionKeys.size(); i++) { + final String actionKey = actionKeys.get(i); + Date actionStartDate; + Date actionEndDate; + try { + actionStartDate = getActionStartDate(actionKey); + actionEndDate = getActionEndDate(actionKey); + } catch (ParseException pe) { + VConsole.error("Failed to parse action date"); + continue; + } + + boolean startIsValid = start.compareTo(actionStartDate) >= 0; + boolean endIsValid = end.compareTo(actionEndDate) <= 0; + if (startIsValid && endIsValid) { + VCalendarAction a = new VCalendarAction(this, rpc, actionKey); + a.setCaption(getActionCaption(actionKey)); + a.setIconUrl(getActionIcon(actionKey)); + a.setActionStartDate(start); + a.setActionEndDate(end); + actions.add(a); + } + } + + return actions.toArray(new Action[actions.size()]); + } + + private List actionKeys = new ArrayList(); + + private void updateActionMap(List actions) { + actionMap.clear(); + actionKeys.clear(); + + if (actions == null) { + return; + } + + for (CalendarState.Action action : actions) { + String id = action.actionKey + "-" + action.startDate + "-" + + action.endDate; + actionMap.put(id + "_c", action.caption); + actionMap.put(id + "_s", action.startDate); + actionMap.put(id + "_e", action.endDate); + actionKeys.add(id); + if (action.iconKey != null) { + actionMap.put(id + "_i", getResourceUrl(action.iconKey)); + + } else { + actionMap.remove(id + "_i"); + } + } + } + + /** + * Get the text that is displayed for a context menu item + * + * @param actionKey + * The unique action key + * @return + */ + public String getActionCaption(String actionKey) { + return actionMap.get(actionKey + "_c"); + } + + /** + * Get the icon url for a context menu item + * + * @param actionKey + * The unique action key + * @return + */ + public String getActionIcon(String actionKey) { + return actionMap.get(actionKey + "_i"); + } + + /** + * Get the start date for an action item + * + * @param actionKey + * The unique action key + * @return + * @throws ParseException + */ + public Date getActionStartDate(String actionKey) throws ParseException { + String dateStr = actionMap.get(actionKey + "_s"); + DateTimeFormat formatter = DateTimeFormat + .getFormat(DateConstants.ACTION_DATE_FORMAT_PATTERN); + return formatter.parse(dateStr); + } + + /** + * Get the end date for an action item + * + * @param actionKey + * The unique action key + * @return + * @throws ParseException + */ + public Date getActionEndDate(String actionKey) throws ParseException { + String dateStr = actionMap.get(actionKey + "_e"); + DateTimeFormat formatter = DateTimeFormat + .getFormat(DateConstants.ACTION_DATE_FORMAT_PATTERN); + return formatter.parse(dateStr); + } + + /** + * Returns ALL currently registered events. Use {@link #getActions(Date)} to + * get the actions for a specific date + */ + public Action[] getActions() { + List 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); + a.setCaption(getActionCaption(actionKey)); + a.setIconUrl(getActionIcon(actionKey)); + + try { + a.setActionStartDate(getActionStartDate(actionKey)); + a.setActionEndDate(getActionEndDate(actionKey)); + } catch (ParseException pe) { + VConsole.error(pe); + } + + actions.add(a); + } + return actions.toArray(new Action[actions.size()]); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ui.ActionOwner#getPaintableId() + */ + public String getPaintableId() { + return getConnectorId(); + } + + private List calendarEventListOf( + List events, boolean format24h) { + List list = new ArrayList(events.size()); + for (CalendarState.Event event : events) { + final String dateFrom = event.dateFrom; + final String dateTo = event.dateTo; + final String timeFrom = event.timeFrom; + final String timeTo = event.timeTo; + CalendarEvent calendarEvent = new CalendarEvent(); + calendarEvent.setAllDay(event.allDay); + calendarEvent.setCaption(event.caption); + calendarEvent.setDescription(event.description); + calendarEvent.setStart(getWidget().getDateFormat().parse(dateFrom)); + calendarEvent.setEnd(getWidget().getDateFormat().parse(dateTo)); + calendarEvent.setFormat24h(format24h); + calendarEvent.setStartTime(getWidget().getDateTimeFormat().parse( + dateFrom + " " + timeFrom)); + calendarEvent.setEndTime(getWidget().getDateTimeFormat().parse( + dateTo + " " + timeTo)); + calendarEvent.setStyleName(event.styleName); + calendarEvent.setIndex(event.index); + list.add(calendarEvent); + } + return list; + } + + private List calendarDayListOf(List days) { + List list = new ArrayList(days.size()); + for (CalendarState.Day day : days) { + CalendarDay d = new CalendarDay(day.date, day.localizedDateFormat, + day.dayOfWeek, day.week); + + list.add(d); + } + return list; + } + + @Override + public void layout() { + updateSizes(); + } + + private void updateSizes() { + int height = getLayoutManager() + .getOuterHeight(getWidget().getElement()); + int width = getLayoutManager().getOuterWidth(getWidget().getElement()); + + if (isUndefinedWidth()) { + width = -1; + } + if (isUndefinedHeight()) { + height = -1; + } + + getWidget().setSizeForChildren(width, height); + + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/VCalendarAction.java b/client/src/com/vaadin/client/ui/calendar/VCalendarAction.java new file mode 100644 index 0000000000..2a529354e5 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/VCalendarAction.java @@ -0,0 +1,138 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar; + +import java.util.Date; + +import com.google.gwt.i18n.client.DateTimeFormat; +import com.vaadin.client.ui.Action; +import com.vaadin.client.ui.calendar.schedule.CalendarEvent; +import com.vaadin.shared.ui.calendar.CalendarServerRpc; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * Action performed by the calendar + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class VCalendarAction extends Action { + + private CalendarServerRpc rpc; + + private String actionKey = ""; + + private Date actionStartDate; + + private Date actionEndDate; + + private CalendarEvent event; + + private final DateTimeFormat dateformat_datetime = DateTimeFormat + .getFormat(DateConstants.ACTION_DATE_FORMAT_PATTERN); + + /** + * + * @param owner + */ + public VCalendarAction(CalendarConnector owner) { + super(owner); + } + + /** + * Constructor + * + * @param owner + * The owner who trigger this kinds of events + * @param rpc + * The CalendarRpc which is used for executing actions + * @param key + * The unique action key which identifies this particular action + */ + public VCalendarAction(CalendarConnector owner, CalendarServerRpc rpc, + String key) { + this(owner); + this.rpc = rpc; + actionKey = key; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ui.Action#execute() + */ + @Override + public void execute() { + String startDate = dateformat_datetime.format(actionStartDate); + String endDate = dateformat_datetime.format(actionEndDate); + + if (event == null) { + rpc.actionOnEmptyCell(actionKey.split("-")[0], startDate, endDate); + } else { + rpc.actionOnEvent(actionKey.split("-")[0], startDate, endDate, + event.getIndex()); + } + + owner.getClient().getContextMenu().hide(); + } + + /** + * Get the date and time when the action starts + * + * @return + */ + public Date getActionStartDate() { + return actionStartDate; + } + + /** + * Set the date when the actions start + * + * @param actionStartDate + * The date and time when the action starts + */ + public void setActionStartDate(Date actionStartDate) { + this.actionStartDate = actionStartDate; + } + + /** + * Get the date and time when the action ends + * + * @return + */ + public Date getActionEndDate() { + return actionEndDate; + } + + /** + * Set the date and time when the action ends + * + * @param actionEndDate + * The date and time when the action ends + */ + public void setActionEndDate(Date actionEndDate) { + this.actionEndDate = actionEndDate; + } + + public CalendarEvent getEvent() { + return event; + } + + public void setEvent(CalendarEvent event) { + this.event = event; + } + +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/CalendarDay.java b/client/src/com/vaadin/client/ui/calendar/schedule/CalendarDay.java new file mode 100644 index 0000000000..ca176c08c1 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/CalendarDay.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +/** + * Utility class used to represent a day when updating views. Only used + * internally. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class CalendarDay { + private String date; + private String localizedDateFormat; + private int dayOfWeek; + private int week; + + public CalendarDay(String date, String localizedDateFormat, int dayOfWeek, + int week) { + super(); + this.date = date; + this.localizedDateFormat = localizedDateFormat; + this.dayOfWeek = dayOfWeek; + this.week = week; + } + + public String getDate() { + return date; + } + + public String getLocalizedDateFormat() { + return localizedDateFormat; + } + + public int getDayOfWeek() { + return dayOfWeek; + } + + public int getWeek() { + return week; + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/CalendarEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/CalendarEvent.java new file mode 100644 index 0000000000..e2c06d41ea --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/CalendarEvent.java @@ -0,0 +1,313 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.i18n.client.DateTimeFormat; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * A client side implementation of a calendar event + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class CalendarEvent { + private int index; + private String caption; + private Date start, end; + private String styleName; + private Date startTime, endTime; + private String description; + private int slotIndex = -1; + private boolean format24h; + + DateTimeFormat dateformat_date = DateTimeFormat.getFormat("h:mm a"); + DateTimeFormat dateformat_date24 = DateTimeFormat.getFormat("H:mm"); + private boolean allDay; + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStyleName() + */ + public String getStyleName() { + return styleName; + } + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStart() + */ + public Date getStart() { + return start; + } + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStyleName() + * @param style + */ + public void setStyleName(String style) { + styleName = style; + } + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStart() + * @param start + */ + public void setStart(Date start) { + this.start = start; + } + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getEnd() + * @return + */ + public Date getEnd() { + return end; + } + + /** + * @see com.vaadin.addon.calendar.event.CalendarEvent#getEnd() + * @param end + */ + public void setEnd(Date end) { + this.end = end; + } + + /** + * Returns the start time of the event + * + * @return Time embedded in the {@link Date} object + */ + public Date getStartTime() { + return startTime; + } + + /** + * Set the start time of the event + * + * @param startTime + * The time of the event. Use the time fields in the {@link Date} + * object + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * Get the end time of the event + * + * @return Time embedded in the {@link Date} object + */ + public Date getEndTime() { + return endTime; + } + + /** + * Set the end time of the event + * + * @param endTime + * Time embedded in the {@link Date} object + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * Get the (server side) index of the event + * + * @return + */ + public int getIndex() { + return index; + } + + /** + * Get the index of the slot where the event in rendered + * + * @return + */ + public int getSlotIndex() { + return slotIndex; + } + + /** + * Set the index of the slot where the event in rendered + * + * @param index + * The index of the slot + */ + public void setSlotIndex(int index) { + slotIndex = index; + } + + /** + * Set the (server side) index of the event + * + * @param index + * The index + */ + public void setIndex(int index) { + this.index = index; + } + + /** + * Get the caption of the event. The caption is the text displayed in the + * calendar on the event. + * + * @return + */ + public String getCaption() { + return caption; + } + + /** + * Set the caption of the event. The caption is the text displayed in the + * calendar on the event. + * + * @param caption + * The visible caption of the event + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Get the description of the event. The description is the text displayed + * when hoovering over the event with the mouse + * + * @return + */ + public String getDescription() { + return description; + } + + /** + * Set the description of the event. The description is the text displayed + * when hoovering over the event with the mouse + * + * @param description + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Does the event use the 24h time format + * + * @param format24h + * True if it uses the 24h format, false if it uses the 12h time + * format + */ + public void setFormat24h(boolean format24h) { + this.format24h = format24h; + } + + /** + * Is the event an all day event. + * + * @param allDay + * True if the event should be rendered all day + */ + public void setAllDay(boolean allDay) { + this.allDay = allDay; + } + + /** + * Is the event an all day event. + * + * @return + */ + public boolean isAllDay() { + return allDay; + } + + /** + * Get the time as a formatted string + * + * @return + */ + public String getTimeAsText() { + if (format24h) { + return dateformat_date24.format(startTime); + } else { + return dateformat_date.format(startTime); + } + } + + /** + * Get the amount of milliseconds between the start and end of the event + * + * @return + */ + public long getRangeInMilliseconds() { + return getEndTime().getTime() - getStartTime().getTime(); + } + + /** + * Get the amount of minutes between the start and end of the event + * + * @return + */ + public long getRangeInMinutes() { + return (getRangeInMilliseconds() / DateConstants.MINUTEINMILLIS); + } + + /** + * Get the amount of minutes for the event on a specific day. This is useful + * if the event spans several days. + * + * @param targetDay + * The date to check + * @return + */ + public long getRangeInMinutesForDay(Date targetDay) { + if (isTimeOnDifferentDays()) { + // Time range is on different days. Calculate the second day's + // range. + long range = (getEndTime().getTime() - getEnd().getTime()) + / DateConstants.MINUTEINMILLIS; + + if (getEnd().compareTo(targetDay) != 0) { + // Calculate first day's range. + return getRangeInMinutes() - range; + } + + return range; + } else { + return getRangeInMinutes(); + } + } + + /** + * Does the event span several days + * + * @return + */ + @SuppressWarnings("deprecation") + public boolean isTimeOnDifferentDays() { + if (getEndTime().getTime() - getStart().getTime() > DateConstants.DAYINMILLIS) { + return true; + } + + if (getStart().compareTo(getEnd()) != 0) { + if (getEndTime().getHours() == 0 && getEndTime().getMinutes() == 0) { + return false; + } + return true; + } + return false; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java new file mode 100644 index 0000000000..05e2a808fe --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java @@ -0,0 +1,808 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.Node; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.event.dom.client.ContextMenuHandler; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseMoveHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.Util; + +public class DateCell extends FocusableComplexPanel implements + MouseDownHandler, MouseMoveHandler, MouseUpHandler, KeyDownHandler, + ContextMenuHandler { + private static final String DRAGEMPHASISSTYLE = " dragemphasis"; + private Date date; + private int width; + private int eventRangeStart = -1; + private int eventRangeStop = -1; + final WeekGrid weekgrid; + private boolean disabled = false; + private int height; + private final Element[] slotElements; + private final List slots = new ArrayList(); + private int[] slotElementHeights; + private int startingSlotHeight; + private Date today; + private Element todaybar; + private final List handlers; + private final int numberOfSlots; + private final int firstHour; + private final int lastHour; + + public class DateCellSlot extends Widget { + + private final DateCell cell; + + private final Date from; + + private final Date to; + + public DateCellSlot(DateCell cell, Date from, Date to) { + setElement(DOM.createDiv()); + getElement().setInnerHTML(" "); + this.cell = cell; + this.from = from; + this.to = to; + } + + public Date getFrom() { + return from; + } + + public Date getTo() { + return to; + } + + public DateCell getParentCell() { + return cell; + } + } + + public DateCell(WeekGrid parent, Date date) { + weekgrid = parent; + Element mainElement = DOM.createDiv(); + setElement(mainElement); + makeFocusable(); + setDate(date); + + addStyleName("v-calendar-day-times"); + + handlers = new LinkedList(); + + // 2 slots / hour + firstHour = weekgrid.getFirstHour(); + lastHour = weekgrid.getLastHour(); + numberOfSlots = (lastHour - firstHour + 1) * 2; + long slotTime = Math.round(((lastHour - firstHour + 1) * 3600000.0) + / numberOfSlots); + + slotElements = new Element[numberOfSlots]; + slotElementHeights = new int[numberOfSlots]; + + slots.clear(); + long start = getDate().getTime() + firstHour * 3600000; + long end = start + slotTime; + for (int i = 0; i < numberOfSlots; i++) { + DateCellSlot slot = new DateCellSlot(this, new Date( + start), new Date(end)); + if (i % 2 == 0) { + slot.setStyleName("v-datecellslot-even"); + } else { + slot.setStyleName("v-datecellslot"); + } + Event.sinkEvents(slot.getElement(), Event.MOUSEEVENTS); + mainElement.appendChild(slot.getElement()); + slotElements[i] = slot.getElement(); + slots.add(slot); + start = end; + end = start + slotTime; + } + + // Sink events for tooltip handling + Event.sinkEvents(mainElement, Event.MOUSEEVENTS); + } + + public int getFirstHour() { + return firstHour; + } + + public int getLastHour() { + return lastHour; + } + + @Override + protected void onAttach() { + super.onAttach(); + + handlers.add(addHandler(this, MouseDownEvent.getType())); + handlers.add(addHandler(this, MouseUpEvent.getType())); + handlers.add(addHandler(this, MouseMoveEvent.getType())); + handlers.add(addDomHandler(this, ContextMenuEvent.getType())); + handlers.add(addKeyDownHandler(this)); + } + + @Override + protected void onDetach() { + for (HandlerRegistration handler : handlers) { + handler.removeHandler(); + } + handlers.clear(); + + super.onDetach(); + } + + public int getSlotIndex(Element slotElement) { + for (int i = 0; i < slotElements.length; i++) { + if (slotElement == slotElements[i]) { + return i; + } + } + + throw new IllegalArgumentException( + "Element not found in this DateCell"); + } + + public DateCellSlot getSlot(int index) { + return slots.get(index); + } + + public int getNumberOfSlots() { + return numberOfSlots; + } + + public void setTimeBarWidth(int timebarWidth) { + todaybar.getStyle().setWidth(timebarWidth, Unit.PX); + } + + /** + * @param isHorizontalSized + * if true, this DateCell is sized with CSS and not via + * {@link #setWidthPX(int)} + */ + public void setHorizontalSized(boolean isHorizontalSized) { + if (isHorizontalSized) { + addStyleDependentName("Hsized"); + + width = getOffsetWidth() + - Util.measureHorizontalBorder(getElement()); + recalculateEventWidths(); + } else { + removeStyleDependentName("Hsized"); + } + } + + /** + * @param isVerticalSized + * if true, this DateCell is sized with CSS and not via + * {@link #setHeightPX(int)} + */ + public void setVerticalSized(boolean isVerticalSized) { + if (isVerticalSized) { + addStyleDependentName("Vsized"); + + // recalc heights&size for events. all other height sizes come + // from css + startingSlotHeight = slotElements[0].getOffsetHeight(); + recalculateEventPositions(); + + if (isToday()) { + recalculateTimeBarPosition(); + } + + } else { + removeStyleDependentName("Vsized"); + } + } + + public void setDate(Date date) { + this.date = date; + } + + public void setWidthPX(int cellWidth) { + width = cellWidth; + setWidth(cellWidth + "px"); + recalculateEventWidths(); + } + + public void setHeightPX(int height, int[] cellHeights) { + this.height = height; + slotElementHeights = cellHeights; + setHeight(height + "px"); + recalculateCellHeights(); + recalculateEventPositions(); + if (today != null) { + recalculateTimeBarPosition(); + } + } + + // date methods are not deprecated in GWT + @SuppressWarnings("deprecation") + private void recalculateTimeBarPosition() { + int h = today.getHours(); + int m = today.getMinutes(); + if (h >= firstHour && h <= lastHour) { + int pixelTop = weekgrid.getPixelTopFor(m + 60 * h); + todaybar.getStyle().clearDisplay(); + todaybar.getStyle().setTop(pixelTop, Unit.PX); + } else { + todaybar.getStyle().setDisplay(Display.NONE); + } + } + + private void recalculateEventPositions() { + for (int i = 0; i < getWidgetCount(); i++) { + DateCellDayEvent dayEvent = (DateCellDayEvent) getWidget(i); + updatePositionFor(dayEvent, getDate(), + dayEvent.getCalendarEvent()); + } + } + + public void recalculateEventWidths() { + List groups = new ArrayList(); + + int count = getWidgetCount(); + + List handled = new ArrayList(); + + // Iterate through all events and group them. Events that overlaps + // with each other, are added to the same group. + for (int i = 0; i < count; i++) { + if (handled.contains(i)) { + continue; + } + + DateCellGroup curGroup = getOverlappingEvents(i); + handled.addAll(curGroup.getItems()); + + boolean newGroup = true; + // No need to check other groups, if size equals the count + if (curGroup.getItems().size() != count) { + // Check other groups. When the whole group overlaps with + // other group, the group is merged to the other. + for (DateCellGroup g : groups) { + + if (WeekGridMinuteTimeRange.doesOverlap( + curGroup.getDateRange(), g.getDateRange())) { + newGroup = false; + updateGroup(g, curGroup); + } + } + } else { + if (newGroup) { + groups.add(curGroup); + } + break; + } + + if (newGroup) { + groups.add(curGroup); + } + } + + drawDayEvents(groups); + } + + private void recalculateCellHeights() { + startingSlotHeight = height / numberOfSlots; + + for (int i = 0; i < slotElements.length; i++) { + slotElements[i].getStyle().setHeight(slotElementHeights[i], + Unit.PX); + } + + Iterator it = iterator(); + while (it.hasNext()) { + Widget child = it.next(); + if (child instanceof DateCellDayEvent) { + ((DateCellDayEvent) child).setSlotHeightInPX(getSlotHeight()); + } + + } + } + + public int getSlotHeight() { + return startingSlotHeight; + } + + public int getSlotBorder() { + return Util + .measureVerticalBorder((com.google.gwt.user.client.Element) slotElements[0]); + } + + private void drawDayEvents(List groups) { + for (DateCellGroup g : groups) { + int col = 0; + int colCount = 0; + List order = new ArrayList(); + Map columns = new HashMap(); + for (Integer eventIndex : g.getItems()) { + DateCellDayEvent d = (DateCellDayEvent) getWidget(eventIndex); + d.setMoveWidth(width); + + int freeSpaceCol = findFreeColumnSpaceOnLeft( + new WeekGridMinuteTimeRange(d.getCalendarEvent() + .getStartTime(), d.getCalendarEvent() + .getEndTime()), order, columns); + if (freeSpaceCol >= 0) { + col = freeSpaceCol; + columns.put(eventIndex, col); + int newOrderindex = 0; + for (Integer i : order) { + if (columns.get(i) >= col) { + newOrderindex = order.indexOf(i); + break; + } + } + order.add(newOrderindex, eventIndex); + } else { + // New column + col = colCount++; + columns.put(eventIndex, col); + order.add(eventIndex); + } + } + + // Update widths and left position + int eventWidth = (width / colCount); + for (Integer index : g.getItems()) { + DateCellDayEvent d = (DateCellDayEvent) getWidget(index); + d.getElement() + .getStyle() + .setMarginLeft((eventWidth * columns.get(index)), + Unit.PX); + d.setWidth(eventWidth + "px"); + d.setSlotHeightInPX(getSlotHeight()); + } + } + } + + private int findFreeColumnSpaceOnLeft(WeekGridMinuteTimeRange dateRange, + List order, Map columns) { + int freeSpot = -1; + int skipIndex = -1; + for (Integer eventIndex : order) { + int col = columns.get(eventIndex); + if (col == skipIndex) { + continue; + } + + if (freeSpot != -1 && freeSpot != col) { + // Free spot found + return freeSpot; + } + + DateCellDayEvent d = (DateCellDayEvent) getWidget(eventIndex); + WeekGridMinuteTimeRange nextRange = new WeekGridMinuteTimeRange(d + .getCalendarEvent().getStartTime(), d + .getCalendarEvent().getEndTime()); + + if (WeekGridMinuteTimeRange.doesOverlap(dateRange, nextRange)) { + skipIndex = col; + freeSpot = -1; + } else { + freeSpot = col; + } + } + + return freeSpot; + } + + /* Update top and bottom date range values. Add new index to the group. */ + private void updateGroup(DateCellGroup targetGroup, DateCellGroup byGroup) { + Date newStart = targetGroup.getStart(); + Date newEnd = targetGroup.getEnd(); + if (byGroup.getStart().before(targetGroup.getStart())) { + newStart = byGroup.getEnd(); + } + if (byGroup.getStart().after(targetGroup.getEnd())) { + newStart = byGroup.getStart(); + } + + targetGroup.setDateRange(new WeekGridMinuteTimeRange(newStart, newEnd)); + + for (Integer index : byGroup.getItems()) { + if (!targetGroup.getItems().contains(index)) { + targetGroup.add(index); + } + } + } + + /** + * Returns all overlapping DayEvent indexes in the Group. Including the + * target. + * + * @param targetIndex + * Index of DayEvent in the current DateCell widget. + * @return Group that contains all Overlapping DayEvent indexes + */ + public DateCellGroup getOverlappingEvents(int targetIndex) { + DateCellGroup g = new DateCellGroup(targetIndex); + + int count = getWidgetCount(); + DateCellDayEvent target = (DateCellDayEvent) getWidget(targetIndex); + WeekGridMinuteTimeRange targetRange = new WeekGridMinuteTimeRange(target + .getCalendarEvent().getStartTime(), target + .getCalendarEvent().getEndTime()); + Date groupStart = targetRange.getStart(); + Date groupEnd = targetRange.getEnd(); + + for (int i = 0; i < count; i++) { + if (targetIndex == i) { + continue; + } + + DateCellDayEvent d = (DateCellDayEvent) getWidget(i); + WeekGridMinuteTimeRange nextRange = new WeekGridMinuteTimeRange(d + .getCalendarEvent().getStartTime(), d + .getCalendarEvent().getEndTime()); + if (WeekGridMinuteTimeRange.doesOverlap(targetRange, nextRange)) { + g.add(i); + + // Update top & bottom values to the greatest + if (nextRange.getStart().before(targetRange.getStart())) { + groupStart = targetRange.getStart(); + } + if (nextRange.getEnd().after(targetRange.getEnd())) { + groupEnd = targetRange.getEnd(); + } + } + } + + g.setDateRange(new WeekGridMinuteTimeRange(groupStart, groupEnd)); + return g; + } + + public Date getDate() { + return date; + } + + public void addEvent(Date targetDay, CalendarEvent calendarEvent) { + Element main = getElement(); + DateCellDayEvent dayEvent = new DateCellDayEvent(this, weekgrid, calendarEvent); + dayEvent.setSlotHeightInPX(getSlotHeight()); + dayEvent.setDisabled(isDisabled()); + + if (startingSlotHeight > 0) { + updatePositionFor(dayEvent, targetDay, calendarEvent); + } + + add(dayEvent, (com.google.gwt.user.client.Element) main); + } + + // date methods are not deprecated in GWT + @SuppressWarnings("deprecation") + private void updatePositionFor(DateCellDayEvent dayEvent, Date targetDay, + CalendarEvent calendarEvent) { + if (canDisplay(calendarEvent)) { + + dayEvent.getElement().getStyle().clearDisplay(); + + Date fromDt = calendarEvent.getStartTime(); + int h = fromDt.getHours(); + int m = fromDt.getMinutes(); + long range = calendarEvent.getRangeInMinutesForDay(targetDay); + + boolean onDifferentDays = calendarEvent.isTimeOnDifferentDays(); + if (onDifferentDays) { + if (calendarEvent.getStart().compareTo(targetDay) != 0) { + // Current day slot is for the end date. Lets fix also + // the + // start & end times. + h = 0; + m = 0; + } + } + + int startFromMinutes = (h * 60) + m; + dayEvent.updatePosition(startFromMinutes, range); + + } else { + dayEvent.getElement().getStyle().setDisplay(Display.NONE); + } + } + + public void addEvent(DateCellDayEvent dayEvent) { + Element main = getElement(); + int index = 0; + List events = new ArrayList(); + + // events are the only widgets in this panel + // slots are just elements + for (; index < getWidgetCount(); index++) { + DateCellDayEvent dc = (DateCellDayEvent) getWidget(index); + dc.setDisabled(isDisabled()); + events.add(dc.getCalendarEvent()); + } + events.add(dayEvent.getCalendarEvent()); + + index = 0; + for (CalendarEvent e : weekgrid.getCalendar().sortEventsByDuration( + events)) { + if (e.equals(dayEvent.getCalendarEvent())) { + break; + } + index++; + } + this.insert(dayEvent, (com.google.gwt.user.client.Element) main, + index, true); + } + + public void removeEvent(DateCellDayEvent dayEvent) { + remove(dayEvent); + } + + /** + * + * @param event + * @return + */ + // Date methods not deprecated in GWT + @SuppressWarnings("deprecation") + private boolean canDisplay(CalendarEvent event) { + Date eventStart = event.getStartTime(); + Date eventEnd = event.getEndTime(); + + int eventStartHours = eventStart.getHours(); + int eventEndHours = eventEnd.getHours(); + + return (eventStartHours <= lastHour) + && (eventEndHours >= firstHour); + } + + public void onKeyDown(KeyDownEvent event) { + int keycode = event.getNativeEvent().getKeyCode(); + if (keycode == KeyCodes.KEY_ESCAPE && eventRangeStart > -1) { + cancelRangeSelect(); + } + } + + public void onMouseDown(MouseDownEvent event) { + if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { + Element e = Element.as(event.getNativeEvent().getEventTarget()); + if (e.getClassName().contains("reserved") || isDisabled() + || !weekgrid.getParentCalendar().isRangeSelectAllowed()) { + eventRangeStart = -1; + } else { + eventRangeStart = event.getY(); + eventRangeStop = eventRangeStart; + Event.setCapture(getElement()); + setFocus(true); + } + } + } + + @SuppressWarnings("deprecation") + public void onMouseUp(MouseUpEvent event) { + if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + return; + } + Event.releaseCapture(getElement()); + setFocus(false); + int dragDistance = Math.abs(eventRangeStart - event.getY()); + if (dragDistance > 0 && eventRangeStart >= 0) { + Element main = getElement(); + if (eventRangeStart > eventRangeStop) { + if (eventRangeStop <= -1) { + eventRangeStop = 0; + } + int temp = eventRangeStart; + eventRangeStart = eventRangeStop; + eventRangeStop = temp; + } + + NodeList nodes = main.getChildNodes(); + + int slotStart = -1; + int slotEnd = -1; + + // iterate over all child nodes, until we find first the start, + // and then the end + for (int i = 0; i < nodes.getLength(); i++) { + Element element = (Element) nodes.getItem(i); + boolean isRangeElement = element.getClassName().contains( + "v-daterange"); + + if (isRangeElement && slotStart == -1) { + slotStart = i; + slotEnd = i; // to catch one-slot selections + + } else if (isRangeElement) { + slotEnd = i; + + } else if (slotStart != -1 && slotEnd != -1) { + break; + } + } + + clearSelectionRange(); + + int startMinutes = firstHour * 60 + slotStart * 30; + int endMinutes = (firstHour * 60) + (slotEnd + 1) * 30; + Date currentDate = getDate(); + String yr = (currentDate.getYear() + 1900) + "-" + + (currentDate.getMonth() + 1) + "-" + + currentDate.getDate(); + if (weekgrid.getCalendar().getRangeSelectListener() != null) { + weekgrid.getCalendar() + .getRangeSelectListener() + .rangeSelected( + yr + ":" + startMinutes + ":" + endMinutes); + } + eventRangeStart = -1; + } else { + // Click event + eventRangeStart = -1; + cancelRangeSelect(); + + } + } + + public void onMouseMove(MouseMoveEvent event) { + if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + return; + } + + if (eventRangeStart >= 0) { + int newY = event.getY(); + int fromY = 0; + int toY = 0; + if (newY < eventRangeStart) { + fromY = newY; + toY = eventRangeStart; + } else { + fromY = eventRangeStart; + toY = newY; + } + Element main = getElement(); + eventRangeStop = newY; + NodeList nodes = main.getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Element c = (Element) nodes.getItem(i); + + if (todaybar != c) { + + int elemStart = c.getOffsetTop(); + int elemStop = elemStart + getSlotHeight(); + if (elemStart >= fromY && elemStart <= toY) { + c.addClassName("v-daterange"); + } else if (elemStop >= fromY && elemStop <= toY) { + c.addClassName("v-daterange"); + } else if (elemStop >= fromY && elemStart <= toY) { + c.addClassName("v-daterange"); + } else { + c.removeClassName("v-daterange"); + } + } + } + } + + event.preventDefault(); + } + + public void cancelRangeSelect() { + Event.releaseCapture(getElement()); + setFocus(false); + + clearSelectionRange(); + } + + private void clearSelectionRange() { + if (eventRangeStart > -1) { + // clear all "selected" class names + Element main = getElement(); + NodeList nodes = main.getChildNodes(); + + for (int i = 0; i <= 47; i++) { + Element c = (Element) nodes.getItem(i); + if (c == null) { + continue; + } + c.removeClassName("v-daterange"); + } + + eventRangeStart = -1; + } + } + + public void setToday(Date today, int width) { + this.today = today; + addStyleDependentName("today"); + Element lastChild = (Element) getElement().getLastChild(); + if (lastChild.getClassName().equals("v-calendar-current-time")) { + todaybar = lastChild; + } else { + todaybar = DOM.createDiv(); + todaybar.setClassName("v-calendar-current-time"); + getElement().appendChild(todaybar); + } + + if (width != -1) { + todaybar.getStyle().setWidth(width, Unit.PX); + } + + // position is calculated later, when we know the cell heights + } + + public Element getTodaybarElement() { + return todaybar; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean isDisabled() { + return disabled; + } + + public void setDateColor(String styleName) { + this.setStyleName("v-calendar-datecell " + styleName); + } + + public boolean isToday() { + return today != null; + } + + public void addEmphasisStyle( + com.google.gwt.user.client.Element elementOver) { + String originalStylename = getStyleName(elementOver); + setStyleName(elementOver, originalStylename + DRAGEMPHASISSTYLE); + } + + public void removeEmphasisStyle( + com.google.gwt.user.client.Element elementOver) { + String originalStylename = getStyleName(elementOver); + setStyleName( + elementOver, + originalStylename.substring(0, originalStylename.length() + - DRAGEMPHASISSTYLE.length())); + } + + public void onContextMenu(ContextMenuEvent event) { + if (weekgrid.getCalendar().getMouseEventListener() != null) { + event.preventDefault(); + event.stopPropagation(); + weekgrid.getCalendar().getMouseEventListener() + .contextMenu(event, DateCell.this); + } + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java new file mode 100644 index 0000000000..f1b45c83c5 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java @@ -0,0 +1,114 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.Util; +import com.vaadin.client.ui.VCalendar; + +/** + * Internally used class by the Calendar + * + * since 7.1 + */ +public class DateCellContainer extends FlowPanel implements + MouseDownHandler, MouseUpHandler { + + private Date date; + + private Widget clickTargetWidget; + + private VCalendar calendar; + + private static int borderWidth = -1; + + public DateCellContainer() { + setStylePrimaryName("v-calendar-datecell"); + } + + public static int measureBorderWidth(DateCellContainer dc) { + if (borderWidth == -1) { + borderWidth = Util.measureHorizontalBorder(dc.getElement()); + } + return borderWidth; + } + + public void setCalendar(VCalendar calendar) { + this.calendar = calendar; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public boolean hasEvent(int slotIndex) { + return hasDateCell(slotIndex) + && ((WeeklyLongEventsDateCell) getChildren().get(slotIndex)).getEvent() != null; + } + + public boolean hasDateCell(int slotIndex) { + return (getChildren().size() - 1) >= slotIndex; + } + + public WeeklyLongEventsDateCell getDateCell(int slotIndex) { + if (!hasDateCell(slotIndex)) { + addEmptyEventCells(slotIndex - (getChildren().size() - 1)); + } + return (WeeklyLongEventsDateCell) getChildren().get(slotIndex); + } + + public void addEmptyEventCells(int eventCount) { + for (int i = 0; i < eventCount; i++) { + addEmptyEventCell(); + } + } + + public void addEmptyEventCell() { + WeeklyLongEventsDateCell dateCell = new WeeklyLongEventsDateCell(); + dateCell.addMouseDownHandler(this); + dateCell.addMouseUpHandler(this); + add(dateCell); + } + + public void onMouseDown(MouseDownEvent event) { + clickTargetWidget = (Widget) event.getSource(); + + event.stopPropagation(); + } + + public void onMouseUp(MouseUpEvent event) { + if (event.getSource() == clickTargetWidget + && clickTargetWidget instanceof WeeklyLongEventsDateCell + && !calendar.isDisabledOrReadOnly()) { + CalendarEvent calendarEvent = ((WeeklyLongEventsDateCell) clickTargetWidget) + .getEvent(); + if (calendar.getEventClickListener() != null) { + calendar.getEventClickListener().eventClick(calendarEvent); + } + } + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java new file mode 100644 index 0000000000..039a00e25a --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java @@ -0,0 +1,659 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.EventTarget; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ContextMenuEvent; +import com.google.gwt.event.dom.client.ContextMenuHandler; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseMoveHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.vaadin.client.Util; +import com.vaadin.client.ui.VCalendar; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * Internally used by the calendar + * + * @since 7.1 + */ +public class DateCellDayEvent extends FocusableHTML implements + MouseDownHandler, MouseUpHandler, MouseMoveHandler, + KeyDownHandler, ContextMenuHandler, HasTooltipKey { + + private final DateCell dateCell; + private Element caption = null; + private final Element eventContent; + private CalendarEvent calendarEvent = null; + private HandlerRegistration moveRegistration; + private int startY = -1; + private int startX = -1; + private String moveWidth; + public static final int halfHourInMilliSeconds = 1800 * 1000; + private Date startDatetimeFrom; + private Date startDatetimeTo; + private boolean mouseMoveStarted; + private int top; + private int startYrelative; + private int startXrelative; + private boolean disabled; + private final WeekGrid weekGrid; + private com.google.gwt.user.client.Element topResizeBar; + private com.google.gwt.user.client.Element bottomResizeBar; + private Element clickTarget; + private final Integer eventIndex; + private int slotHeight; + private final List handlers; + private boolean mouseMoveCanceled; + + public DateCellDayEvent(DateCell dateCell, WeekGrid parent, CalendarEvent event) { + super(); + this.dateCell = dateCell; + + handlers = new LinkedList(); + + setStylePrimaryName("v-calendar-event"); + setCalendarEvent(event); + + weekGrid = parent; + + Style s = getElement().getStyle(); + if (event.getStyleName().length() > 0) { + addStyleDependentName(event.getStyleName()); + } + s.setPosition(Position.ABSOLUTE); + + caption = DOM.createDiv(); + caption.addClassName("v-calendar-event-caption"); + getElement().appendChild(caption); + + eventContent = DOM.createDiv(); + eventContent.addClassName("v-calendar-event-content"); + getElement().appendChild(eventContent); + + VCalendar calendar = weekGrid.getCalendar(); + if (weekGrid.getCalendar().isEventResizeAllowed()) { + topResizeBar = DOM.createDiv(); + bottomResizeBar = DOM.createDiv(); + + topResizeBar.addClassName("v-calendar-event-resizetop"); + bottomResizeBar + .addClassName("v-calendar-event-resizebottom"); + + getElement().appendChild(topResizeBar); + getElement().appendChild(bottomResizeBar); + } + + eventIndex = event.getIndex(); + } + + @Override + protected void onAttach() { + super.onAttach(); + handlers.add(addMouseDownHandler(this)); + handlers.add(addMouseUpHandler(this)); + handlers.add(addKeyDownHandler(this)); + handlers.add(addDomHandler(this, ContextMenuEvent.getType())); + } + + @Override + protected void onDetach() { + for (HandlerRegistration handler : handlers) { + handler.removeHandler(); + } + handlers.clear(); + super.onDetach(); + } + + public void setSlotHeightInPX(int slotHeight) { + this.slotHeight = slotHeight; + } + + public void updatePosition(long startFromMinutes, + long durationInMinutes) { + if (startFromMinutes < 0) { + startFromMinutes = 0; + } + top = weekGrid.getPixelTopFor((int) startFromMinutes); + + getElement().getStyle().setTop(top, Unit.PX); + if (durationInMinutes > 0) { + int heightMinutes = weekGrid.getPixelLengthFor( + (int) startFromMinutes, (int) durationInMinutes); + setHeight(heightMinutes); + } else { + setHeight(-1); + } + + boolean multiRowCaption = (durationInMinutes > 30); + updateCaptions(multiRowCaption); + } + + public int getTop() { + return top; + } + + public void setMoveWidth(int width) { + moveWidth = width + "px"; + } + + public void setHeight(int h) { + if (h == -1) { + getElement().getStyle().setProperty("height", ""); + eventContent.getStyle().setProperty("height", ""); + } else { + getElement().getStyle().setHeight(h, Unit.PX); + // FIXME measure the border height (2px) from the DOM + eventContent.getStyle().setHeight(h - 2, Unit.PX); + } + } + + /** + * @param bigMode + * If false, event is so small that caption must be in + * time-row + */ + private void updateCaptions(boolean bigMode) { + String separator = bigMode ? "
" : ": "; + caption.setInnerHTML("" + calendarEvent.getTimeAsText() + + "" + separator + + Util.escapeHTML(calendarEvent.getCaption())); + eventContent.setInnerHTML(""); + } + + public void onKeyDown(KeyDownEvent event) { + int keycode = event.getNativeEvent().getKeyCode(); + if (keycode == KeyCodes.KEY_ESCAPE && mouseMoveStarted) { + cancelMouseMove(); + } + } + + public void onMouseDown(MouseDownEvent event) { + startX = event.getClientX(); + startY = event.getClientY(); + if (isDisabled() + || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + return; + } + + clickTarget = Element.as(event.getNativeEvent() + .getEventTarget()); + mouseMoveCanceled = false; + + if (weekGrid.getCalendar().isEventMoveAllowed() + || clickTargetsResize()) { + moveRegistration = addMouseMoveHandler(this); + setFocus(true); + try { + startYrelative = (int) ((double) event + .getRelativeY(caption) % slotHeight); + startXrelative = (event.getRelativeX(weekGrid + .getElement()) - weekGrid.timebar + .getOffsetWidth()) + % getDateCellWidth(); + } catch (Exception e) { + GWT.log("Exception calculating relative start position", + e); + } + mouseMoveStarted = false; + Style s = getElement().getStyle(); + s.setZIndex(1000); + startDatetimeFrom = (Date) calendarEvent.getStartTime() + .clone(); + startDatetimeTo = (Date) calendarEvent.getEndTime().clone(); + Event.setCapture(getElement()); + } + + // make sure the right cursor is always displayed + if (clickTargetsResize()) { + addGlobalResizeStyle(); + } + + /* + * We need to stop the event propagation or else the WeekGrid + * range select will kick in + */ + event.stopPropagation(); + event.preventDefault(); + } + + public void onMouseUp(MouseUpEvent event) { + if (mouseMoveCanceled) { + return; + } + + Event.releaseCapture(getElement()); + setFocus(false); + if (moveRegistration != null) { + moveRegistration.removeHandler(); + moveRegistration = null; + } + int endX = event.getClientX(); + int endY = event.getClientY(); + int xDiff = startX - endX; + int yDiff = startY - endY; + startX = -1; + startY = -1; + mouseMoveStarted = false; + Style s = getElement().getStyle(); + s.setZIndex(1); + if (!clickTargetsResize()) { + // check if mouse has moved over threshold of 3 pixels + boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3); + + if (!weekGrid.getCalendar().isDisabledOrReadOnly() + && mouseMoved) { + // Event Move: + // - calendar must be enabled + // - calendar must not be in read-only mode + weekGrid.eventMoved(this); + } else if (!weekGrid.getCalendar().isDisabled()) { + // Event Click: + // - calendar must be enabled (read-only is allowed) + EventTarget et = event.getNativeEvent() + .getEventTarget(); + Element e = Element.as(et); + if (e == caption || e == eventContent + || e.getParentElement() == caption) { + if (weekGrid.getCalendar().getEventClickListener() != null) { + weekGrid.getCalendar().getEventClickListener() + .eventClick(calendarEvent); + } + } + } + + } else { // click targeted resize bar + removeGlobalResizeStyle(); + if (weekGrid.getCalendar().getEventResizeListener() != null) { + weekGrid.getCalendar().getEventResizeListener() + .eventResized(calendarEvent); + } + } + } + + @SuppressWarnings("deprecation") + public void onMouseMove(MouseMoveEvent event) { + if (startY < 0 && startX < 0) { + return; + } + if (isDisabled()) { + Event.releaseCapture(getElement()); + mouseMoveStarted = false; + startY = -1; + startX = -1; + removeGlobalResizeStyle(); + return; + } + int currentY = event.getClientY(); + int currentX = event.getClientX(); + int moveY = (currentY - startY); + int moveX = (currentX - startX); + if ((moveY < 5 && moveY > -6) && (moveX < 5 && moveX > -6)) { + return; + } + if (!mouseMoveStarted) { + setWidth(moveWidth); + getElement().getStyle().setMarginLeft(0, Unit.PX); + mouseMoveStarted = true; + } + + HorizontalPanel parent = (HorizontalPanel) getParent() + .getParent(); + int relativeX = event.getRelativeX(parent.getElement()) + - weekGrid.timebar.getOffsetWidth(); + int halfHourDiff = 0; + if (moveY > 0) { + halfHourDiff = (startYrelative + moveY) / slotHeight; + } else { + halfHourDiff = (moveY - startYrelative) / slotHeight; + } + + int dateCellWidth = getDateCellWidth(); + long dayDiff = 0; + if (moveX >= 0) { + dayDiff = (startXrelative + moveX) / dateCellWidth; + } else { + dayDiff = (moveX - (dateCellWidth - startXrelative)) + / dateCellWidth; + } + + int dayOffset = relativeX / dateCellWidth; + + // sanity check for right side overflow + int dateCellCount = weekGrid.getDateCellCount(); + if (dayOffset >= dateCellCount) { + dayOffset--; + dayDiff--; + } + + int dayOffsetPx = calculateDateCellOffsetPx(dayOffset) + + weekGrid.timebar.getOffsetWidth(); + + GWT.log("DateCellWidth: " + dateCellWidth + " dayDiff: " + + dayDiff + " dayOffset: " + dayOffset + + " dayOffsetPx: " + dayOffsetPx + " startXrelative: " + + startXrelative + " moveX: " + moveX); + + if (relativeX < 0 || relativeX >= getDatesWidth()) { + return; + } + + Style s = getElement().getStyle(); + + Date from = calendarEvent.getStartTime(); + Date to = calendarEvent.getEndTime(); + long duration = to.getTime() - from.getTime(); + + if (!clickTargetsResize() + && weekGrid.getCalendar().isEventMoveAllowed()) { + long daysMs = dayDiff * DateConstants.DAYINMILLIS; + from.setTime(startDatetimeFrom.getTime() + daysMs); + from.setTime(from.getTime() + + ((long) halfHourInMilliSeconds * halfHourDiff)); + to.setTime((from.getTime() + duration)); + + calendarEvent.setStartTime(from); + calendarEvent.setEndTime(to); + calendarEvent.setStart(new Date(from.getTime())); + calendarEvent.setEnd(new Date(to.getTime())); + + // Set new position for the event + long startFromMinutes = (from.getHours() * 60) + + from.getMinutes(); + long range = calendarEvent.getRangeInMinutes(); + startFromMinutes = calculateStartFromMinute( + startFromMinutes, from, to, dayOffsetPx); + if (startFromMinutes < 0) { + range += startFromMinutes; + } + updatePosition(startFromMinutes, range); + + s.setLeft(dayOffsetPx, Unit.PX); + + if (weekGrid.getDateCellWidths() != null) { + s.setWidth(weekGrid.getDateCellWidths()[dayOffset], + Unit.PX); + } else { + setWidth(moveWidth); + } + + } else if (clickTarget == topResizeBar) { + long oldStartTime = startDatetimeFrom.getTime(); + long newStartTime = oldStartTime + + ((long) halfHourInMilliSeconds * halfHourDiff); + + if (!isTimeRangeTooSmall(newStartTime, + startDatetimeTo.getTime())) { + newStartTime = startDatetimeTo.getTime() + - getMinTimeRange(); + } + + from.setTime(newStartTime); + + calendarEvent.setStartTime(from); + calendarEvent.setStart(new Date(from.getTime())); + + // Set new position for the event + long startFromMinutes = (from.getHours() * 60) + + from.getMinutes(); + long range = calendarEvent.getRangeInMinutes(); + + updatePosition(startFromMinutes, range); + + } else if (clickTarget == bottomResizeBar) { + long oldEndTime = startDatetimeTo.getTime(); + long newEndTime = oldEndTime + + ((long) halfHourInMilliSeconds * halfHourDiff); + + if (!isTimeRangeTooSmall(startDatetimeFrom.getTime(), + newEndTime)) { + newEndTime = startDatetimeFrom.getTime() + + getMinTimeRange(); + } + + to.setTime(newEndTime); + + calendarEvent.setEndTime(to); + calendarEvent.setEnd(new Date(to.getTime())); + + // Set new position for the event + long startFromMinutes = (startDatetimeFrom.getHours() * 60) + + startDatetimeFrom.getMinutes(); + long range = calendarEvent.getRangeInMinutes(); + startFromMinutes = calculateStartFromMinute( + startFromMinutes, from, to, dayOffsetPx); + if (startFromMinutes < 0) { + range += startFromMinutes; + } + updatePosition(startFromMinutes, range); + } + } + + private void cancelMouseMove() { + mouseMoveCanceled = true; + + // reset and remove everything related to the event handling + Event.releaseCapture(getElement()); + setFocus(false); + + if (moveRegistration != null) { + moveRegistration.removeHandler(); + moveRegistration = null; + } + + mouseMoveStarted = false; + removeGlobalResizeStyle(); + + Style s = getElement().getStyle(); + s.setZIndex(1); + + // reset the position of the event + int dateCellWidth = getDateCellWidth(); + int dayOffset = startXrelative / dateCellWidth; + s.clearLeft(); + + calendarEvent.setStartTime(startDatetimeFrom); + calendarEvent.setEndTime(startDatetimeTo); + + long startFromMinutes = (startDatetimeFrom.getHours() * 60) + + startDatetimeFrom.getMinutes(); + long range = calendarEvent.getRangeInMinutes(); + + startFromMinutes = calculateStartFromMinute(startFromMinutes, + startDatetimeFrom, startDatetimeTo, dayOffset); + if (startFromMinutes < 0) { + range += startFromMinutes; + } + + updatePosition(startFromMinutes, range); + + startY = -1; + startX = -1; + + // to reset the event width + ((DateCell) getParent()).recalculateEventWidths(); + } + + // date methods are not deprecated in GWT + @SuppressWarnings("deprecation") + private long calculateStartFromMinute(long startFromMinutes, + Date from, Date to, int dayOffset) { + boolean eventStartAtDifferentDay = from.getDate() != to + .getDate(); + if (eventStartAtDifferentDay) { + long minutesOnPrevDay = (getTargetDateByCurrentPosition( + dayOffset).getTime() - from.getTime()) + / DateConstants.MINUTEINMILLIS; + startFromMinutes = -1 * minutesOnPrevDay; + } + + return startFromMinutes; + } + + /** + * @param dateOffset + * @return the amount of pixels the given date is from the left side + */ + private int calculateDateCellOffsetPx(int dateOffset) { + int dateCellOffset = 0; + int[] dateWidths = weekGrid.getDateCellWidths(); + + if (dateWidths != null) { + for (int i = 0; i < dateOffset; i++) { + dateCellOffset += dateWidths[i] + 1; + } + } else { + dateCellOffset = dateOffset * weekGrid.getDateCellWidth(); + } + + return dateCellOffset; + } + + /** + * Check if the given time range is too small for events + * + * @param start + * @param end + * @return + */ + private boolean isTimeRangeTooSmall(long start, long end) { + return (end - start) >= getMinTimeRange(); + } + + /** + * @return the minimum amount of ms that an event must last when + * resized + */ + private long getMinTimeRange() { + return DateConstants.MINUTEINMILLIS * 30; + } + + /** + * Build the string for sending resize events to server + * + * @param event + * @return + */ + private String buildResizeString(CalendarEvent event) { + StringBuilder buffer = new StringBuilder(); + buffer.append(event.getIndex()); + buffer.append(","); + buffer.append(DateUtil.formatClientSideDate(event.getStart())); + buffer.append("-"); + buffer.append(DateUtil.formatClientSideTime(event + .getStartTime())); + buffer.append(","); + buffer.append(DateUtil.formatClientSideDate(event.getEnd())); + buffer.append("-"); + buffer.append(DateUtil.formatClientSideTime(event.getEndTime())); + + return buffer.toString(); + } + + private Date getTargetDateByCurrentPosition(int left) { + DateCell newParent = (DateCell) weekGrid.content + .getWidget((left / getDateCellWidth()) + 1); + Date targetDate = newParent.getDate(); + return targetDate; + } + + private int getDateCellWidth() { + return weekGrid.getDateCellWidth(); + } + + /* Returns total width of all date cells. */ + private int getDatesWidth() { + if (weekGrid.width == -1) { + // Undefined width. Needs to be calculated by the known cell + // widths. + int count = weekGrid.content.getWidgetCount() - 1; + return count * getDateCellWidth(); + } + + return weekGrid.getInternalWidth(); + } + + /** + * @return true if the current mouse movement is resizing + */ + private boolean clickTargetsResize() { + return weekGrid.getCalendar().isEventResizeAllowed() + && (clickTarget == topResizeBar || clickTarget == bottomResizeBar); + } + + private void addGlobalResizeStyle() { + if (clickTarget == topResizeBar) { + weekGrid.getCalendar().addStyleDependentName("nresize"); + } else if (clickTarget == bottomResizeBar) { + weekGrid.getCalendar().addStyleDependentName("sresize"); + } + } + + private void removeGlobalResizeStyle() { + weekGrid.getCalendar().removeStyleDependentName("nresize"); + weekGrid.getCalendar().removeStyleDependentName("sresize"); + } + + public void setCalendarEvent(CalendarEvent calendarEvent) { + this.calendarEvent = calendarEvent; + } + + public CalendarEvent getCalendarEvent() { + return calendarEvent; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean isDisabled() { + return disabled; + } + + public void onContextMenu(ContextMenuEvent event) { + if (this.dateCell.weekgrid.getCalendar().getMouseEventListener() != null) { + event.preventDefault(); + event.stopPropagation(); + this.dateCell.weekgrid.getCalendar().getMouseEventListener() + .contextMenu(event, this); + } + } + + @Override + public Object getTooltipKey() { + return eventIndex; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java new file mode 100644 index 0000000000..d2add53389 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + + +/** + * Internally used by the calendar + * + * @since 7.1 + */ +public class DateCellGroup { + private WeekGridMinuteTimeRange range; + private final List items; + + public DateCellGroup(Integer index) { + items = new ArrayList(); + items.add(index); + } + + public WeekGridMinuteTimeRange getDateRange() { + return range; + } + + public Date getStart() { + return range.getStart(); + } + + public Date getEnd() { + return range.getEnd(); + } + + public void setDateRange(WeekGridMinuteTimeRange range) { + this.range = range; + } + + public List getItems() { + return items; + } + + public void add(Integer index) { + items.add(index); + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateUtil.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateUtil.java new file mode 100644 index 0000000000..84726327e2 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateUtil.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.i18n.client.DateTimeFormat; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * Utility class for {@link Date} operations + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class DateUtil { + + /** + * Checks if dates are same day without checking datetimes. + * + * @param date1 + * @param date2 + * @return + */ + @SuppressWarnings("deprecation") + public static boolean compareDate(Date date1, Date date2) { + if (date1.getDate() == date2.getDate() + && date1.getYear() == date2.getYear() + && date1.getMonth() == date2.getMonth()) { + return true; + } + return false; + } + + /** + * @param date + * the date to format + * + * @return given Date as String, for communicating to server-side + */ + public static String formatClientSideDate(Date date) { + DateTimeFormat dateformat_date = DateTimeFormat + .getFormat(DateConstants.CLIENT_DATE_FORMAT); + return dateformat_date.format(date); + } + + /** + * @param date + * the date to format + * @return given Date as String, for communicating to server-side + */ + public static String formatClientSideTime(Date date) { + DateTimeFormat dateformat_date = DateTimeFormat + .getFormat(DateConstants.CLIENT_TIME_FORMAT); + return dateformat_date.format(date); + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java new file mode 100644 index 0000000000..bb0155d892 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java @@ -0,0 +1,179 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Iterator; + +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ui.VCalendar; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class DayToolbar extends HorizontalPanel implements ClickHandler { + private int width = 0; + protected static final int MARGINLEFT = 50; + protected static final int MARGINRIGHT = 20; + protected Button backLabel; + protected Button nextLabel; + private boolean verticalSized; + private boolean horizontalSized; + private VCalendar calendar; + + public DayToolbar(VCalendar vcalendar) { + calendar = vcalendar; + + setStylePrimaryName("v-calendar-header-week"); + backLabel = new Button(); + backLabel.setStylePrimaryName("v-calendar-back"); + nextLabel = new Button(); + nextLabel.addClickHandler(this); + nextLabel.setStylePrimaryName("v-calendar-next"); + backLabel.addClickHandler(this); + setBorderWidth(0); + setSpacing(0); + } + + public void setWidthPX(int width) { + this.width = (width - MARGINLEFT) - MARGINRIGHT; + // super.setWidth(this.width + "px"); + if (getWidgetCount() == 0) { + return; + } + updateCellWidths(); + } + + public void updateCellWidths() { + int count = getWidgetCount(); + if (count > 0) { + setCellWidth(backLabel, MARGINLEFT + "px"); + setCellWidth(nextLabel, MARGINRIGHT + "px"); + setCellHorizontalAlignment(nextLabel, ALIGN_RIGHT); + int cellw = width / (count - 2); + int remain = width % (count - 2); + int cellw2 = cellw + 1; + if (cellw > 0) { + int[] cellWidths = VCalendar + .distributeSize(width, count - 2, 0); + for (int i = 1; i < count - 1; i++) { + Widget widget = getWidget(i); + // if (remain > 0) { + // setCellWidth(widget, cellw2 + "px"); + // remain--; + // } else { + // setCellWidth(widget, cellw + "px"); + // } + setCellWidth(widget, cellWidths[i - 1] + "px"); + widget.setWidth(cellWidths[i - 1] + "px"); + } + } + } + } + + public void add(String dayName, final String date, + String localized_date_format, String extraClass) { + Label l = new Label(dayName + " " + localized_date_format); + l.setStylePrimaryName("v-calendar-header-day"); + + if (extraClass != null) { + l.addStyleDependentName(extraClass); + } + + if (verticalSized) { + l.addStyleDependentName("Vsized"); + } + if (horizontalSized) { + l.addStyleDependentName("Hsized"); + } + + l.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + if (calendar.getDateClickListener() != null) { + calendar.getDateClickListener().dateClick(date); + } + } + }); + + add(l); + } + + public void addBackButton() { + if (!calendar.isBackwardNavigationEnabled()) { + nextLabel.getElement().getStyle().setHeight(0, Unit.PX); + } + add(backLabel); + } + + public void addNextButton() { + if (!calendar.isForwardNavigationEnabled()) { + backLabel.getElement().getStyle().setHeight(0, Unit.PX); + } + add(nextLabel); + } + + public void onClick(ClickEvent event) { + if (!calendar.isDisabledOrReadOnly()) { + if (event.getSource() == nextLabel) { + if (calendar.getForwardListener() != null) { + calendar.getForwardListener().forward(); + } + } else if (event.getSource() == backLabel) { + if (calendar.getBackwardListener() != null) { + calendar.getBackwardListener().backward(); + } + } + } + } + + public void setVerticalSized(boolean sized) { + verticalSized = sized; + updateDayLabelSizedStyleNames(); + } + + public void setHorizontalSized(boolean sized) { + horizontalSized = sized; + updateDayLabelSizedStyleNames(); + } + + private void updateDayLabelSizedStyleNames() { + Iterator it = iterator(); + while (it.hasNext()) { + updateWidgetSizedStyleName(it.next()); + } + } + + private void updateWidgetSizedStyleName(Widget w) { + if (verticalSized) { + w.addStyleDependentName("Vsized"); + } else { + w.removeStyleDependentName("VSized"); + } + if (horizontalSized) { + w.addStyleDependentName("Hsized"); + } else { + w.removeStyleDependentName("HSized"); + } + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java new file mode 100644 index 0000000000..62332385d2 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java @@ -0,0 +1,117 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; +import com.google.gwt.event.dom.client.HasBlurHandlers; +import com.google.gwt.event.dom.client.HasFocusHandlers; +import com.google.gwt.event.dom.client.HasKeyDownHandlers; +import com.google.gwt.event.dom.client.HasKeyPressHandlers; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.impl.FocusImpl; +import com.vaadin.client.Focusable; + +/** + * A ComplexPanel that can be focused + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class FocusableComplexPanel extends ComplexPanel implements + HasFocusHandlers, HasBlurHandlers, HasKeyDownHandlers, + HasKeyPressHandlers, Focusable { + + protected void makeFocusable() { + // make focusable, as we don't need access key magic we don't need to + // use FocusImpl.createFocusable + getElement().setTabIndex(0); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. + * google.gwt.event.dom.client.FocusHandler) + */ + public HandlerRegistration addFocusHandler(FocusHandler handler) { + return addDomHandler(handler, FocusEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google + * .gwt.event.dom.client.BlurHandler) + */ + public HandlerRegistration addBlurHandler(BlurHandler handler) { + return addDomHandler(handler, BlurEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( + * com.google.gwt.event.dom.client.KeyDownHandler) + */ + public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { + return addDomHandler(handler, KeyDownEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler + * (com.google.gwt.event.dom.client.KeyPressHandler) + */ + public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { + return addDomHandler(handler, KeyPressEvent.getType()); + } + + /** + * Sets/Removes the keyboard focus to the panel. + * + * @param focus + * If set to true then the focus is moved to the panel, if set to + * false the focus is removed + */ + public void setFocus(boolean focus) { + if (focus) { + FocusImpl.getFocusImplForPanel().focus(getElement()); + } else { + FocusImpl.getFocusImplForPanel().blur(getElement()); + } + } + + /** + * Focus the panel + */ + public void focus() { + setFocus(true); + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java new file mode 100644 index 0000000000..d3177362bf --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java @@ -0,0 +1,129 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; +import com.google.gwt.event.dom.client.HasBlurHandlers; +import com.google.gwt.event.dom.client.HasFocusHandlers; +import com.google.gwt.event.dom.client.HasKeyDownHandlers; +import com.google.gwt.event.dom.client.HasKeyPressHandlers; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Grid; +import com.google.gwt.user.client.ui.impl.FocusImpl; +import com.vaadin.client.Focusable; + +/** + * A Grid that can be focused + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class FocusableGrid extends Grid implements HasFocusHandlers, + HasBlurHandlers, HasKeyDownHandlers, HasKeyPressHandlers, Focusable { + + /** + * Constructor + */ + public FocusableGrid() { + super(); + makeFocusable(); + } + + public FocusableGrid(int rows, int columns) { + super(rows, columns); + makeFocusable(); + } + + protected void makeFocusable() { + // make focusable, as we don't need access key magic we don't need to + // use FocusImpl.createFocusable + getElement().setTabIndex(0); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. + * google.gwt.event.dom.client.FocusHandler) + */ + public HandlerRegistration addFocusHandler(FocusHandler handler) { + return addDomHandler(handler, FocusEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google + * .gwt.event.dom.client.BlurHandler) + */ + public HandlerRegistration addBlurHandler(BlurHandler handler) { + return addDomHandler(handler, BlurEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( + * com.google.gwt.event.dom.client.KeyDownHandler) + */ + public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { + return addDomHandler(handler, KeyDownEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler + * (com.google.gwt.event.dom.client.KeyPressHandler) + */ + public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { + return addDomHandler(handler, KeyPressEvent.getType()); + } + + /** + * Sets/Removes the keyboard focus to the panel. + * + * @param focus + * If set to true then the focus is moved to the panel, if set to + * false the focus is removed + */ + public void setFocus(boolean focus) { + if (focus) { + FocusImpl.getFocusImplForPanel().focus(getElement()); + } else { + FocusImpl.getFocusImplForPanel().blur(getElement()); + } + } + + /** + * Focus the panel + */ + public void focus() { + setFocus(true); + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java new file mode 100644 index 0000000000..c3fe1958f0 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java @@ -0,0 +1,119 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; +import com.google.gwt.event.dom.client.HasBlurHandlers; +import com.google.gwt.event.dom.client.HasFocusHandlers; +import com.google.gwt.event.dom.client.HasKeyDownHandlers; +import com.google.gwt.event.dom.client.HasKeyPressHandlers; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.impl.FocusImpl; +import com.vaadin.client.Focusable; + +/** + * A HTML widget that can be focused + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class FocusableHTML extends HTML implements HasFocusHandlers, + HasBlurHandlers, HasKeyDownHandlers, HasKeyPressHandlers, Focusable { + + /** + * Constructor + */ + public FocusableHTML() { + // make focusable, as we don't need access key magic we don't need to + // use FocusImpl.createFocusable + getElement().setTabIndex(0); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. + * google.gwt.event.dom.client.FocusHandler) + */ + public HandlerRegistration addFocusHandler(FocusHandler handler) { + return addDomHandler(handler, FocusEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google + * .gwt.event.dom.client.BlurHandler) + */ + public HandlerRegistration addBlurHandler(BlurHandler handler) { + return addDomHandler(handler, BlurEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( + * com.google.gwt.event.dom.client.KeyDownHandler) + */ + public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { + return addDomHandler(handler, KeyDownEvent.getType()); + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler + * (com.google.gwt.event.dom.client.KeyPressHandler) + */ + public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { + return addDomHandler(handler, KeyPressEvent.getType()); + } + + /** + * Sets/Removes the keyboard focus to the panel. + * + * @param focus + * If set to true then the focus is moved to the panel, if set to + * false the focus is removed + */ + public void setFocus(boolean focus) { + if (focus) { + FocusImpl.getFocusImplForPanel().focus(getElement()); + } else { + FocusImpl.getFocusImplForPanel().blur(getElement()); + } + } + + /** + * Focus the panel + */ + public void focus() { + setFocus(true); + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/HasTooltipKey.java b/client/src/com/vaadin/client/ui/calendar/schedule/HasTooltipKey.java new file mode 100644 index 0000000000..5827068840 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/HasTooltipKey.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +/** + * For Calendar client-side internal use only. + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public interface HasTooltipKey { + /** + * Gets the key associated for the Widget implementing this interface. This + * key is used for getting a tooltip title identified by the key + * + * @return the tooltip key + */ + Object getTooltipKey(); +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/MonthEventLabel.java b/client/src/com/vaadin/client/ui/calendar/schedule/MonthEventLabel.java new file mode 100644 index 0000000000..b7f6ee7a3c --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/MonthEventLabel.java @@ -0,0 +1,142 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.user.client.ui.HTML; +import com.vaadin.client.ui.VCalendar; + +/** + * The label in a month cell + * + * @since 7.1 + */ +public class MonthEventLabel extends HTML implements HasTooltipKey { + + private static final String STYLENAME = "v-calendar-event"; + + private boolean timeSpecificEvent = false; + private Integer eventIndex; + private VCalendar calendar; + private String caption; + private Date time; + + /** + * Default constructor + */ + public MonthEventLabel() { + setStylePrimaryName(STYLENAME); + } + + /** + * Set the time of the event label + * + * @param date + * The date object that specifies the time + */ + public void setTime(Date date) { + time = date; + renderCaption(); + } + + /** + * Set the caption of the event label + * + * @param caption + * The caption string, can be HTML + */ + public void setCaption(String caption) { + this.caption = caption; + renderCaption(); + } + + /** + * Renders the caption in the DIV element + */ + private void renderCaption() { + StringBuilder html = new StringBuilder(); + if (caption != null && time != null) { + html.append(""); + html.append(calendar.getTimeFormat().format(time)); + html.append(" "); + html.append(caption); + } else if (caption != null) { + html.append(caption); + } else if (time != null) { + html.append(""); + html.append(calendar.getTimeFormat().format(time)); + html.append(""); + } + super.setHTML(html.toString()); + } + + /** + * Set the (server side) index of the event + * + * @param index + * The integer index + */ + public void setEventIndex(int index) { + eventIndex = index; + } + + /** + * Set the Calendar instance this label belongs to + * + * @param calendar + * The calendar instance + */ + public void setCalendar(VCalendar calendar) { + this.calendar = calendar; + } + + /** + * Is the event bound to a specific time + * + * @return + */ + public boolean isTimeSpecificEvent() { + return timeSpecificEvent; + } + + /** + * Is the event bound to a specific time + * + * @param timeSpecificEvent + * True if the event is bound to a time, false if it is only + * bound to the day + */ + public void setTimeSpecificEvent(boolean timeSpecificEvent) { + this.timeSpecificEvent = timeSpecificEvent; + } + + /* + * (non-Javadoc) + * + * @see com.google.gwt.user.client.ui.HTML#setHTML(java.lang.String) + */ + @Override + public void setHTML(String html) { + throw new UnsupportedOperationException( + "Use setCaption() and setTime() instead"); + } + + @Override + public Object getTooltipKey() { + return eventIndex; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java new file mode 100644 index 0000000000..f5afd12e42 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java @@ -0,0 +1,215 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.vaadin.client.ui.VCalendar; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class MonthGrid extends FocusableGrid implements KeyDownHandler { + + private SimpleDayCell selectionStart; + private SimpleDayCell selectionEnd; + private final VCalendar calendar; + private boolean rangeSelectDisabled; + private boolean disabled; + private boolean enabled = true; + private final HandlerRegistration keyDownHandler; + + public MonthGrid(VCalendar parent, int rows, int columns) { + super(rows, columns); + calendar = parent; + setCellSpacing(0); + setCellPadding(0); + setStylePrimaryName("v-calendar-month"); + + keyDownHandler = addKeyDownHandler(this); + } + + @Override + protected void onUnload() { + keyDownHandler.removeHandler(); + super.onUnload(); + } + + public void setSelectionEnd(SimpleDayCell simpleDayCell) { + selectionEnd = simpleDayCell; + updateSelection(); + } + + public void setSelectionStart(SimpleDayCell simpleDayCell) { + if (!rangeSelectDisabled && isEnabled()) { + selectionStart = simpleDayCell; + setFocus(true); + } + + } + + private void updateSelection() { + if (selectionStart == null) { + return; + } + if (selectionStart != null && selectionEnd != null) { + Date startDate = selectionStart.getDate(); + Date endDate = selectionEnd.getDate(); + for (int row = 0; row < getRowCount(); row++) { + for (int cell = 0; cell < getCellCount(row); cell++) { + SimpleDayCell sdc = (SimpleDayCell) getWidget(row, cell); + if (sdc == null) { + return; + } + Date d = sdc.getDate(); + if (startDate.compareTo(d) <= 0 + && endDate.compareTo(d) >= 0) { + sdc.addStyleDependentName("selected"); + } else if (startDate.compareTo(d) >= 0 + && endDate.compareTo(d) <= 0) { + sdc.addStyleDependentName("selected"); + } else { + sdc.removeStyleDependentName("selected"); + } + } + } + } + } + + public void setSelectionReady() { + if (selectionStart != null && selectionEnd != null) { + String value = ""; + Date startDate = selectionStart.getDate(); + Date endDate = selectionEnd.getDate(); + if (startDate.compareTo(endDate) > 0) { + Date temp = startDate; + startDate = endDate; + endDate = temp; + } + + if (calendar.getRangeSelectListener() != null) { + value = calendar.getDateFormat().format(startDate) + "TO" + + calendar.getDateFormat().format(endDate); + calendar.getRangeSelectListener().rangeSelected(value); + } + selectionStart = null; + selectionEnd = null; + setFocus(false); + } + } + + public void cancelRangeSelection() { + if (selectionStart != null && selectionEnd != null) { + for (int row = 0; row < getRowCount(); row++) { + for (int cell = 0; cell < getCellCount(row); cell++) { + SimpleDayCell sdc = (SimpleDayCell) getWidget(row, cell); + if (sdc == null) { + return; + } + sdc.removeStyleDependentName("selected"); + } + } + } + setFocus(false); + selectionStart = null; + } + + public void updateCellSizes(int totalWidthPX, int totalHeightPX) { + boolean setHeight = totalHeightPX > 0; + boolean setWidth = totalWidthPX > 0; + int rows = getRowCount(); + int cells = getCellCount(0); + int cellWidth = (totalWidthPX / cells) - 1; + int widthRemainder = totalWidthPX % cells; + // Division for cells might not be even. Distribute it evenly to + // will whole space. + int heightPX = totalHeightPX; + int cellHeight = heightPX / rows; + int heightRemainder = heightPX % rows; + + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cells; j++) { + SimpleDayCell sdc = (SimpleDayCell) getWidget(i, j); + + if (setWidth) { + if (widthRemainder > 0) { + sdc.setWidth(cellWidth + 1 + "px"); + widthRemainder--; + + } else { + sdc.setWidth(cellWidth + "px"); + } + } + + if (setHeight) { + if (heightRemainder > 0) { + sdc.setHeightPX(cellHeight + 1, true); + + } else { + sdc.setHeightPX(cellHeight, true); + } + } else { + sdc.setHeightPX(-1, true); + } + } + heightRemainder--; + } + } + + /** + * Disable or enable possibility to select ranges + */ + public void setRangeSelect(boolean b) { + rangeSelectDisabled = !b; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public boolean isEnabled() { + return enabled; + } + + public void onKeyDown(KeyDownEvent event) { + int keycode = event.getNativeKeyCode(); + if (KeyCodes.KEY_ESCAPE == keycode && selectionStart != null) { + cancelRangeSelection(); + } + } + + public int getDayCellIndex(SimpleDayCell dayCell) { + int rows = getRowCount(); + int cells = getCellCount(0); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cells; j++) { + SimpleDayCell sdc = (SimpleDayCell) getWidget(i, j); + if (dayCell == sdc) { + return i * cells + j; + } + } + } + + return -1; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java new file mode 100644 index 0000000000..8d1ca0fcda --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java @@ -0,0 +1,696 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseMoveHandler; +import com.google.gwt.event.dom.client.MouseOverEvent; +import com.google.gwt.event.dom.client.MouseOverHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ui.FocusableFlowPanel; +import com.vaadin.client.ui.VCalendar; +import com.vaadin.shared.ui.calendar.DateConstants; + +/** + * A class representing a single cell within the calendar in month-view + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class SimpleDayCell extends FocusableFlowPanel implements + MouseUpHandler, MouseDownHandler, MouseOverHandler, MouseMoveHandler { + + private static int BOTTOMSPACERHEIGHT = -1; + private static int EVENTHEIGHT = -1; + private static final int BORDERPADDINGSIZE = 1; + + private final VCalendar calendar; + private Date date; + private int intHeight; + private final HTML bottomspacer; + private final Label caption; + private final CalendarEvent[] events = new CalendarEvent[10]; + private final int cell; + private final int row; + private boolean monthNameVisible; + private HandlerRegistration mouseUpRegistration; + private HandlerRegistration mouseDownRegistration; + private HandlerRegistration mouseOverRegistration; + private boolean monthEventMouseDown; + private boolean labelMouseDown; + private int eventCount = 0; + + private int startX = -1; + private int startY = -1; + private int startYrelative; + private int startXrelative; + private Date startDateFrom; + private Date startDateTo; + private int prevDayDiff = 0; + private int prevWeekDiff = 0; + private HandlerRegistration moveRegistration; + private CalendarEvent moveEvent; + private Widget clickedWidget; + private HandlerRegistration bottomSpacerMouseDownHandler; + private boolean scrollable = false; + private boolean eventCanceled; + private MonthGrid monthGrid; + private HandlerRegistration keyDownHandler; + + public SimpleDayCell(VCalendar calendar, int row, int cell) { + this.calendar = calendar; + this.row = row; + this.cell = cell; + setStylePrimaryName("v-calendar-month-day"); + caption = new Label(); + bottomspacer = new HTML(); + bottomspacer.setStyleName("v-calendar-bottom-spacer-empty"); + bottomspacer.setWidth(3 + "em"); + caption.setStyleName("v-calendar-day-number"); + add(caption); + add(bottomspacer); + caption.addMouseDownHandler(this); + caption.addMouseUpHandler(this); + } + + @Override + public void onLoad() { + BOTTOMSPACERHEIGHT = bottomspacer.getOffsetHeight(); + EVENTHEIGHT = BOTTOMSPACERHEIGHT; + } + + public void setMonthGrid(MonthGrid monthGrid) { + this.monthGrid = monthGrid; + } + + public MonthGrid getMonthGrid() { + return monthGrid; + } + + @SuppressWarnings("deprecation") + public void setDate(Date date) { + int dateOfMonth = date.getDate(); + if (monthNameVisible) { + caption.setText(dateOfMonth + " " + + calendar.getMonthNames()[date.getMonth()]); + } else { + caption.setText("" + dateOfMonth); + } + this.date = date; + } + + public Date getDate() { + return date; + } + + public void reDraw(boolean clear) { + setHeightPX(intHeight + BORDERPADDINGSIZE, clear); + } + + /* + * Events and whole cell content are drawn by this method. By the + * clear-argument, you can choose to clear all old content. Notice that + * clearing will also remove all element's event handlers. + */ + public void setHeightPX(int px, boolean clear) { + // measure from DOM if needed + if (px < 0) { + intHeight = getOffsetHeight() - BORDERPADDINGSIZE; + } else { + intHeight = px - BORDERPADDINGSIZE; + } + + // Couldn't measure height or it ended up negative. Don't bother + // continuing + if (intHeight == -1) { + return; + } + + if (clear) { + while (getWidgetCount() > 1) { + remove(1); + } + } + + // How many events can be shown in UI + int slots = 0; + if (scrollable) { + for (int i = 0; i < events.length; i++) { + if (events[i] != null) { + slots = i + 1; + } + } + setHeight(intHeight + "px"); // Fixed height + } else { + // Dynamic height by the content + DOM.removeElementAttribute(getElement(), "height"); + slots = (intHeight - caption.getOffsetHeight() - BOTTOMSPACERHEIGHT) + / EVENTHEIGHT; + if (slots > 10) { + slots = 10; + } + } + + updateEvents(slots, clear); + + } + + public void updateEvents(int slots, boolean clear) { + int eventsAdded = 0; + + for (int i = 0; i < slots; i++) { + CalendarEvent e = events[i]; + if (e == null) { + // Empty slot + HTML slot = new HTML(); + slot.setStyleName("v-calendar-spacer"); + if (!clear) { + remove(i + 1); + insert(slot, i + 1); + } else { + add(slot); + } + } else { + // Event slot + eventsAdded++; + if (!clear) { + Widget w = getWidget(i + 1); + if (!(w instanceof MonthEventLabel)) { + remove(i + 1); + insert(createMonthEventLabel(e), i + 1); + } + } else { + add(createMonthEventLabel(e)); + } + } + } + + int remainingSpace = intHeight + - ((slots * EVENTHEIGHT) + BOTTOMSPACERHEIGHT + caption + .getOffsetHeight()); + int newHeight = remainingSpace + BOTTOMSPACERHEIGHT; + if (newHeight < 0) { + newHeight = EVENTHEIGHT; + } + bottomspacer.setHeight(newHeight + "px"); + + if (clear) { + add(bottomspacer); + } + + int more = eventCount - eventsAdded; + if (more > 0) { + if (bottomSpacerMouseDownHandler == null) { + bottomSpacerMouseDownHandler = bottomspacer + .addMouseDownHandler(this); + } + bottomspacer.setStyleName("v-calendar-bottom-spacer"); + bottomspacer.setText("+ " + more); + } else { + if (!scrollable && bottomSpacerMouseDownHandler != null) { + bottomSpacerMouseDownHandler.removeHandler(); + bottomSpacerMouseDownHandler = null; + } + + if (scrollable) { + bottomspacer.setText("[ - ]"); + } else { + bottomspacer.setStyleName("v-calendar-bottom-spacer-empty"); + bottomspacer.setText(""); + } + } + } + + private MonthEventLabel createMonthEventLabel(CalendarEvent e) { + long rangeInMillis = e.getRangeInMilliseconds(); + boolean timeEvent = rangeInMillis <= DateConstants.DAYINMILLIS + && !e.isAllDay(); + Date fromDatetime = e.getStartTime(); + + // Create a new MonthEventLabel + MonthEventLabel eventDiv = new MonthEventLabel(); + eventDiv.addStyleDependentName("month"); + eventDiv.addMouseDownHandler(this); + eventDiv.addMouseUpHandler(this); + eventDiv.setCalendar(calendar); + eventDiv.setEventIndex(e.getIndex()); + + if (timeEvent) { + eventDiv.setTimeSpecificEvent(true); + if (e.getStyleName() != null) { + eventDiv.addStyleDependentName(e.getStyleName()); + } + eventDiv.setCaption(e.getCaption()); + eventDiv.setTime(fromDatetime); + + } else { + eventDiv.setTimeSpecificEvent(false); + Date from = e.getStart(); + Date to = e.getEnd(); + if (e.getStyleName().length() > 0) { + eventDiv.addStyleName("month-event " + e.getStyleName()); + } else { + eventDiv.addStyleName("month-event"); + } + int fromCompareToDate = from.compareTo(date); + int toCompareToDate = to.compareTo(date); + eventDiv.addStyleDependentName("all-day"); + if (fromCompareToDate == 0) { + eventDiv.addStyleDependentName("start"); + eventDiv.setCaption(e.getCaption()); + + } else if (fromCompareToDate < 0 && cell == 0) { + eventDiv.addStyleDependentName("continued-from"); + eventDiv.setCaption(e.getCaption()); + } + if (toCompareToDate == 0) { + eventDiv.addStyleDependentName("end"); + } else if (toCompareToDate > 0 + && (cell + 1) == getMonthGrid().getCellCount(row)) { + eventDiv.addStyleDependentName("continued-to"); + } + if (e.getStyleName() != null) { + eventDiv.addStyleDependentName(e.getStyleName() + "-all-day"); + } + } + + return eventDiv; + } + + private void setUnlimitedCellHeight() { + scrollable = true; + addStyleDependentName("scrollable"); + } + + private void setLimitedCellHeight() { + scrollable = false; + removeStyleDependentName("scrollable"); + } + + public void addCalendarEvent(CalendarEvent e) { + eventCount++; + int slot = e.getSlotIndex(); + if (slot == -1) { + for (int i = 0; i < events.length; i++) { + if (events[i] == null) { + events[i] = e; + e.setSlotIndex(i); + break; + } + } + } else { + events[slot] = e; + } + } + + @SuppressWarnings("deprecation") + public void setMonthNameVisible(boolean b) { + monthNameVisible = b; + int dateOfMonth = date.getDate(); + caption.setText(dateOfMonth + " " + + calendar.getMonthNames()[date.getMonth()]); + } + + public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) { + return addDomHandler(handler, MouseMoveEvent.getType()); + } + + @Override + protected void onAttach() { + super.onAttach(); + mouseUpRegistration = addDomHandler(this, MouseUpEvent.getType()); + mouseDownRegistration = addDomHandler(this, MouseDownEvent.getType()); + mouseOverRegistration = addDomHandler(this, MouseOverEvent.getType()); + } + + @Override + protected void onDetach() { + mouseUpRegistration.removeHandler(); + mouseDownRegistration.removeHandler(); + mouseOverRegistration.removeHandler(); + super.onDetach(); + } + + public void onMouseUp(MouseUpEvent event) { + if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + return; + } + + Widget w = (Widget) event.getSource(); + if (moveRegistration != null) { + Event.releaseCapture(getElement()); + moveRegistration.removeHandler(); + moveRegistration = null; + keyDownHandler.removeHandler(); + keyDownHandler = null; + } + + if (w == bottomspacer && monthEventMouseDown) { + GWT.log("Mouse up over bottomspacer"); + + } else if (clickedWidget instanceof MonthEventLabel + && monthEventMouseDown) { + MonthEventLabel mel = (MonthEventLabel) clickedWidget; + + int endX = event.getClientX(); + int endY = event.getClientY(); + int xDiff = startX - endX; + int yDiff = startY - endY; + startX = -1; + startY = -1; + prevDayDiff = 0; + prevWeekDiff = 0; + + if (!mel.isTimeSpecificEvent() + && (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3)) { + eventMoved(moveEvent); + + } else if (calendar.getEventClickListener() != null) { + CalendarEvent e = getEventByWidget(mel); + calendar.getEventClickListener().eventClick(e); + } + + moveEvent = null; + } else if (w == this) { + getMonthGrid().setSelectionReady(); + + } else if (w instanceof Label && labelMouseDown) { + String clickedDate = calendar.getDateFormat().format(date); + if (calendar.getDateClickListener() != null) { + calendar.getDateClickListener().dateClick(clickedDate); + } + } + monthEventMouseDown = false; + labelMouseDown = false; + clickedWidget = null; + } + + public void onMouseDown(MouseDownEvent event) { + if (calendar.isDisabled() + || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + return; + } + + Widget w = (Widget) event.getSource(); + clickedWidget = w; + + if (w instanceof MonthEventLabel) { + // event clicks should be allowed even when read-only + monthEventMouseDown = true; + + if (w instanceof MonthEventLabel) { + startCalendarEventDrag(event, (MonthEventLabel) w); + } + } else if (!calendar.isReadOnly()) { + // these are not allowed when in read-only + if (w == bottomspacer) { + if (scrollable) { + setLimitedCellHeight(); + } else { + setUnlimitedCellHeight(); + } + reDraw(true); + + } else if (w == this && !scrollable) { + MonthGrid grid = getMonthGrid(); + if (grid.isEnabled() && calendar.isRangeSelectAllowed()) { + grid.setSelectionStart(this); + grid.setSelectionEnd(this); + } + } else if (w instanceof Label) { + labelMouseDown = true; + } + } + + event.stopPropagation(); + event.preventDefault(); + } + + public void onMouseOver(MouseOverEvent event) { + event.preventDefault(); + getMonthGrid().setSelectionEnd(this); + } + + public void onMouseMove(MouseMoveEvent event) { + if (clickedWidget instanceof MonthEventLabel && !monthEventMouseDown + || (startY < 0 && startX < 0)) { + return; + } + + MonthEventLabel w = (MonthEventLabel) clickedWidget; + + if (calendar.isDisabledOrReadOnly()) { + Event.releaseCapture(getElement()); + monthEventMouseDown = false; + startY = -1; + startX = -1; + return; + } + + int currentY = event.getClientY(); + int currentX = event.getClientX(); + int moveY = (currentY - startY); + int moveX = (currentX - startX); + if ((moveY < 5 && moveY > -6) && (moveX < 5 && moveX > -6)) { + return; + } + + int dateCellWidth = getWidth(); + int dateCellHeigth = getHeigth(); + + Element parent = getMonthGrid().getElement(); + int relativeX = event.getRelativeX(parent); + int relativeY = event.getRelativeY(parent); + int weekDiff = 0; + if (moveY > 0) { + weekDiff = (startYrelative + moveY) / dateCellHeigth; + } else { + weekDiff = (moveY - (dateCellHeigth - startYrelative)) + / dateCellHeigth; + } + + int dayDiff = 0; + if (moveX >= 0) { + dayDiff = (startXrelative + moveX) / dateCellWidth; + } else { + dayDiff = (moveX - (dateCellWidth - startXrelative)) + / dateCellWidth; + } + // Check boundaries + if (relativeY < 0 + || relativeY >= (calendar.getMonthGrid().getRowCount() * dateCellHeigth) + || relativeX < 0 + || relativeX >= (calendar.getMonthGrid().getColumnCount() * dateCellWidth)) { + return; + } + + GWT.log("Event moving delta: " + weekDiff + " weeks " + dayDiff + + " days" + " (" + getCell() + "," + getRow() + ")"); + + CalendarEvent e = moveEvent; + if (e == null) { + e = getEventByWidget(w); + } + + Date from = e.getStart(); + Date to = e.getEnd(); + long duration = to.getTime() - from.getTime(); + + long daysMs = dayDiff * DateConstants.DAYINMILLIS; + long weeksMs = weekDiff * DateConstants.WEEKINMILLIS; + from.setTime(startDateFrom.getTime() + weeksMs + daysMs); + to.setTime((from.getTime() + duration)); + e.setStart(from); + e.setEnd(to); + e.setStartTime(new Date(from.getTime())); + e.setEndTime(new Date(to.getTime())); + + updateDragPosition(w, dayDiff, weekDiff); + } + + private void eventMoved(CalendarEvent e) { + calendar.updateEventToMonthGrid(e); + if (calendar.getEventMovedListener() != null) { + calendar.getEventMovedListener().eventMoved(e); + } + } + + public void startCalendarEventDrag(MouseDownEvent event, + final MonthEventLabel w) { + if (w.isTimeSpecificEvent()) { + return; + } + + moveRegistration = addMouseMoveHandler(this); + startX = event.getClientX(); + startY = event.getClientY(); + startYrelative = event.getRelativeY(w.getParent().getElement()) + % getHeigth(); + startXrelative = event.getRelativeX(w.getParent().getElement()) + % getWidth(); + + CalendarEvent e = getEventByWidget(w); + startDateFrom = (Date) e.getStart().clone(); + startDateTo = (Date) e.getEnd().clone(); + + Event.setCapture(getElement()); + keyDownHandler = addKeyDownHandler(new KeyDownHandler() { + + public void onKeyDown(KeyDownEvent event) { + if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { + cancelEventDrag(w); + } + } + + }); + + focus(); + + GWT.log("Start drag"); + } + + protected void cancelEventDrag(MonthEventLabel w) { + if (moveRegistration != null) { + // reset position + if (moveEvent == null) { + moveEvent = getEventByWidget(w); + } + + moveEvent.setStart(startDateFrom); + moveEvent.setEnd(startDateTo); + calendar.updateEventToMonthGrid(moveEvent); + + // reset drag-related properties + Event.releaseCapture(getElement()); + moveRegistration.removeHandler(); + moveRegistration = null; + keyDownHandler.removeHandler(); + keyDownHandler = null; + setFocus(false); + monthEventMouseDown = false; + startY = -1; + startX = -1; + moveEvent = null; + labelMouseDown = false; + clickedWidget = null; + } + } + + public void updateDragPosition(MonthEventLabel w, int dayDiff, int weekDiff) { + // Draw event to its new position only when position has changed + if (dayDiff == prevDayDiff && weekDiff == prevWeekDiff) { + return; + } + + prevDayDiff = dayDiff; + prevWeekDiff = weekDiff; + + if (moveEvent == null) { + moveEvent = getEventByWidget(w); + } + + calendar.updateEventToMonthGrid(moveEvent); + } + + public int getRow() { + return row; + } + + public int getCell() { + return cell; + } + + public int getHeigth() { + return intHeight + BORDERPADDINGSIZE; + } + + public int getWidth() { + return getOffsetWidth() - BORDERPADDINGSIZE; + } + + public void setToday(boolean today) { + if (today) { + addStyleDependentName("today"); + } else { + removeStyleDependentName("today"); + } + } + + public boolean removeEvent(CalendarEvent targetEvent, + boolean reDrawImmediately) { + int slot = targetEvent.getSlotIndex(); + if (slot < 0) { + return false; + } + + CalendarEvent e = getCalendarEvent(slot); + if (targetEvent.equals(e)) { + events[slot] = null; + eventCount--; + if (reDrawImmediately) { + reDraw(moveEvent == null); + } + return true; + } + return false; + } + + private CalendarEvent getEventByWidget(MonthEventLabel eventWidget) { + int index = getWidgetIndex(eventWidget); + return getCalendarEvent(index - 1); + } + + public CalendarEvent getCalendarEvent(int i) { + return events[i]; + } + + public CalendarEvent[] getEvents() { + return events; + } + + public int getEventCount() { + return eventCount; + } + + public CalendarEvent getMoveEvent() { + return moveEvent; + } + + public void addEmphasisStyle() { + addStyleDependentName("dragemphasis"); + } + + public void removeEmphasisStyle() { + removeStyleDependentName("dragemphasis"); + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayToolbar.java new file mode 100644 index 0000000000..fc75136b93 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayToolbar.java @@ -0,0 +1,97 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Widget; + +/** + * + * @since 7.1.0 + * @author Vaadin Ltd. + * + */ +public class SimpleDayToolbar extends HorizontalPanel { + private int width = 0; + private boolean isWidthUndefined = false; + + public SimpleDayToolbar() { + setStylePrimaryName("v-calendar-header-month"); + } + + public void setDayNames(String[] dayNames) { + clear(); + for (int i = 0; i < dayNames.length; i++) { + Label l = new Label(dayNames[i]); + l.setStylePrimaryName("v-calendar-header-day"); + add(l); + } + updateCellWidth(); + } + + public void setWidthPX(int width) { + this.width = width; + + setWidthUndefined(width == -1); + + if (!isWidthUndefined()) { + super.setWidth(this.width + "px"); + if (getWidgetCount() == 0) { + return; + } + } + updateCellWidth(); + } + + private boolean isWidthUndefined() { + return isWidthUndefined; + } + + private void setWidthUndefined(boolean isWidthUndefined) { + this.isWidthUndefined = isWidthUndefined; + + if (isWidthUndefined) { + addStyleDependentName("Hsized"); + + } else { + removeStyleDependentName("Hsized"); + } + } + + private void updateCellWidth() { + int cellw = -1; + int widgetCount = getWidgetCount(); + if (widgetCount <= 0) { + return; + } + if (isWidthUndefined()) { + Widget widget = getWidget(0); + String w = widget.getElement().getStyle().getWidth(); + if (w.length() > 2) { + cellw = Integer.parseInt(w.substring(0, w.length() - 2)); + } + } else { + cellw = width / getWidgetCount(); + } + if (cellw > 0) { + for (int i = 0; i < getWidgetCount(); i++) { + Widget widget = getWidget(i); + setCellWidth(widget, cellw + "px"); + } + } + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java new file mode 100644 index 0000000000..f86ba03053 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java @@ -0,0 +1,108 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.ui.FlexTable; +import com.vaadin.client.ui.VCalendar; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class SimpleWeekToolbar extends FlexTable implements ClickHandler { + private int height; + private VCalendar calendar; + private boolean isHeightUndefined; + + public SimpleWeekToolbar(VCalendar parent) { + calendar = parent; + setCellSpacing(0); + setCellPadding(0); + setStyleName("v-calendar-week-numbers"); + } + + public void addWeek(int week, int year) { + WeekLabel l = new WeekLabel(week + "", week, year); + l.addClickHandler(this); + int rowCount = getRowCount(); + insertRow(rowCount); + setWidget(rowCount, 0, l); + updateCellHeights(); + } + + public void updateCellHeights() { + if (!isHeightUndefined()) { + int rowCount = getRowCount(); + if (rowCount == 0) { + return; + } + int cellheight = (height / rowCount) - 1; + int remainder = height % rowCount; + if (cellheight < 0) { + cellheight = 0; + } + for (int i = 0; i < rowCount; i++) { + if (remainder > 0) { + getWidget(i, 0).setHeight(cellheight + 1 + "px"); + } else { + getWidget(i, 0).setHeight(cellheight + "px"); + } + getWidget(i, 0).getElement().getStyle() + .setProperty("lineHeight", cellheight + "px"); + remainder--; + } + } else { + for (int i = 0; i < getRowCount(); i++) { + getWidget(i, 0).setHeight(""); + getWidget(i, 0).getElement().getStyle() + .setProperty("lineHeight", ""); + } + } + } + + public void setHeightPX(int intHeight) { + setHeightUndefined(intHeight == -1); + height = intHeight; + updateCellHeights(); + } + + public boolean isHeightUndefined() { + return isHeightUndefined; + } + + public void setHeightUndefined(boolean isHeightUndefined) { + this.isHeightUndefined = isHeightUndefined; + + if (isHeightUndefined) { + addStyleDependentName("Vsized"); + + } else { + removeStyleDependentName("Vsized"); + } + } + + public void onClick(ClickEvent event) { + WeekLabel wl = (WeekLabel) event.getSource(); + if (calendar.getWeekClickListener() != null) { + calendar.getWeekClickListener().weekClick( + wl.getYear() + "w" + wl.getWeek()); + } + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java new file mode 100644 index 0000000000..c5646f97ae --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java @@ -0,0 +1,677 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Arrays; +import java.util.Date; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ScrollEvent; +import com.google.gwt.event.dom.client.ScrollHandler; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.ScrollPanel; +import com.google.gwt.user.client.ui.SimplePanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.DateTimeService; +import com.vaadin.client.Util; +import com.vaadin.client.ui.VCalendar; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class WeekGrid extends SimplePanel { + + int width = 0; + private int height = 0; + final HorizontalPanel content; + private VCalendar calendar; + private boolean disabled; + final Timebar timebar; + private Panel wrapper; + private boolean verticalScrollEnabled; + private boolean horizontalScrollEnabled; + private int[] cellHeights; + private final int slotInMinutes = 30; + private int dateCellBorder; + private DateCell dateCellOfToday; + private int[] cellWidths; + private int firstHour; + private int lastHour; + + public WeekGrid(VCalendar parent, boolean format24h) { + setCalendar(parent); + content = new HorizontalPanel(); + timebar = new Timebar(format24h); + content.add(timebar); + + wrapper = new SimplePanel(); + wrapper.setStylePrimaryName("v-calendar-week-wrapper"); + wrapper.add(content); + + setWidget(wrapper); + } + + private void setVerticalScroll(boolean isVerticalScrollEnabled) { + if (isVerticalScrollEnabled && !(isVerticalScrollable())) { + verticalScrollEnabled = true; + horizontalScrollEnabled = false; + wrapper.remove(content); + + final ScrollPanel scrollPanel = new ScrollPanel(); + scrollPanel.setStylePrimaryName("v-calendar-week-wrapper"); + scrollPanel.setWidget(content); + + scrollPanel.addScrollHandler(new ScrollHandler() { + public void onScroll(ScrollEvent event) { + if (calendar.getScrollListener() != null) { + calendar.getScrollListener().scroll( + scrollPanel.getVerticalScrollPosition()); + } + } + }); + + setWidget(scrollPanel); + wrapper = scrollPanel; + + } else if (!isVerticalScrollEnabled && (isVerticalScrollable())) { + verticalScrollEnabled = false; + horizontalScrollEnabled = false; + wrapper.remove(content); + + SimplePanel simplePanel = new SimplePanel(); + simplePanel.setStylePrimaryName("v-calendar-week-wrapper"); + simplePanel.setWidget(content); + + setWidget(simplePanel); + wrapper = simplePanel; + } + } + + public void setVerticalScrollPosition(int verticalScrollPosition) { + if (isVerticalScrollable()) { + ((ScrollPanel) wrapper) + .setVerticalScrollPosition(verticalScrollPosition); + } + } + + public int getInternalWidth() { + return width; + } + + public void addDate(Date d) { + final DateCell dc = new DateCell(this, d); + dc.setDisabled(isDisabled()); + dc.setHorizontalSized(isHorizontalScrollable() || width < 0); + dc.setVerticalSized(isVerticalScrollable()); + content.add(dc); + } + + /** + * @param dateCell + * @return get the index of the given date cell in this week, starting from + * 0 + */ + public int getDateCellIndex(DateCell dateCell) { + return content.getWidgetIndex(dateCell) - 1; + } + + /** + * @return get the slot border in pixels + */ + public int getDateSlotBorder() { + return ((DateCell) content.getWidget(1)).getSlotBorder(); + } + + private boolean isVerticalScrollable() { + return verticalScrollEnabled; + } + + private boolean isHorizontalScrollable() { + return horizontalScrollEnabled; + } + + public void setWidthPX(int width) { + if (isHorizontalScrollable()) { + updateCellWidths(); + + // Otherwise the scroll wrapper is somehow too narrow = horizontal + // scroll + wrapper.setWidth(content.getOffsetWidth() + + Util.getNativeScrollbarSize() + "px"); + + this.width = content.getOffsetWidth() - timebar.getOffsetWidth(); + + } else { + this.width = (width == -1) ? width : width + - timebar.getOffsetWidth(); + + if (isVerticalScrollable() && width != -1) { + this.width = this.width - Util.getNativeScrollbarSize(); + } + updateCellWidths(); + } + } + + public void setHeightPX(int intHeight) { + height = intHeight; + + setVerticalScroll(height <= -1); + + // if not scrollable, use any height given + if (!isVerticalScrollable() && height > 0) { + + content.setHeight(height + "px"); + setHeight(height + "px"); + wrapper.setHeight(height + "px"); + wrapper.removeStyleDependentName("Vsized"); + updateCellHeights(); + timebar.setCellHeights(cellHeights); + timebar.setHeightPX(height); + + } else if (isVerticalScrollable()) { + updateCellHeights(); + wrapper.addStyleDependentName("Vsized"); + timebar.setCellHeights(cellHeights); + timebar.setHeightPX(height); + } + } + + public void clearDates() { + while (content.getWidgetCount() > 1) { + content.remove(1); + } + + dateCellOfToday = null; + } + + /** + * @return true if this weekgrid contains a date that is today + */ + public boolean hasToday() { + return dateCellOfToday != null; + } + + public void updateCellWidths() { + if (!isHorizontalScrollable() && width != -1) { + int count = content.getWidgetCount(); + int datesWidth = width; + if (datesWidth > 0 && count > 1) { + cellWidths = VCalendar + .distributeSize(datesWidth, count - 1, -1); + + for (int i = 1; i < count; i++) { + DateCell dc = (DateCell) content.getWidget(i); + dc.setHorizontalSized(isHorizontalScrollable() || width < 0); + dc.setWidthPX(cellWidths[i - 1]); + if (dc.isToday()) { + dc.setTimeBarWidth(getOffsetWidth()); + } + } + } + + } else { + int count = content.getWidgetCount(); + if (count > 1) { + for (int i = 1; i < count; i++) { + DateCell dc = (DateCell) content.getWidget(i); + dc.setHorizontalSized(isHorizontalScrollable() || width < 0); + } + } + } + } + + /** + * @return an int-array containing the widths of the cells (days) + */ + public int[] getDateCellWidths() { + return cellWidths; + } + + public void updateCellHeights() { + if (!isVerticalScrollable()) { + int count = content.getWidgetCount(); + if (count > 1) { + DateCell first = (DateCell) content.getWidget(1); + dateCellBorder = first.getSlotBorder(); + cellHeights = VCalendar.distributeSize(height, + first.getNumberOfSlots(), -dateCellBorder); + for (int i = 1; i < count; i++) { + DateCell dc = (DateCell) content.getWidget(i); + dc.setHeightPX(height, cellHeights); + } + } + + } else { + int count = content.getWidgetCount(); + if (count > 1) { + DateCell first = (DateCell) content.getWidget(1); + dateCellBorder = first.getSlotBorder(); + int dateHeight = (first.getOffsetHeight() / first + .getNumberOfSlots()) - dateCellBorder; + cellHeights = new int[48]; + Arrays.fill(cellHeights, dateHeight); + + for (int i = 1; i < count; i++) { + DateCell dc = (DateCell) content.getWidget(i); + dc.setVerticalSized(isVerticalScrollable()); + } + } + } + } + + public void addEvent(CalendarEvent e) { + int dateCount = content.getWidgetCount(); + Date from = e.getStart(); + Date toTime = e.getEndTime(); + for (int i = 1; i < dateCount; i++) { + DateCell dc = (DateCell) content.getWidget(i); + Date dcDate = dc.getDate(); + int comp = dcDate.compareTo(from); + int comp2 = dcDate.compareTo(toTime); + if (comp >= 0 + && comp2 < 0 + || (comp == 0 && comp2 == 0 && VCalendar + .isZeroLengthMidnightEvent(e))) { + // Same event may be over two DateCells if event's date + // range floats over one day. It can't float over two days, + // because event which range is over 24 hours, will be handled + // as a "fullDay" event. + dc.addEvent(dcDate, e); + } + } + } + + public int getPixelLengthFor(int startFromMinutes, int durationInMinutes) { + int pixelLength = 0; + int currentSlot = 0; + + int firstHourInMinutes = firstHour * 60; + + if (firstHourInMinutes > startFromMinutes) { + startFromMinutes = 0; + } else { + startFromMinutes -= firstHourInMinutes; + } + + // calculate full slots to event + int slotsTillEvent = startFromMinutes / slotInMinutes; + int startOverFlowTime = slotInMinutes + - (startFromMinutes % slotInMinutes); + if (startOverFlowTime == slotInMinutes) { + startOverFlowTime = 0; + currentSlot = slotsTillEvent; + } else { + currentSlot = slotsTillEvent + 1; + } + + int durationInSlots = 0; + int endOverFlowTime = 0; + + if (startOverFlowTime > 0) { + durationInSlots = (durationInMinutes - startOverFlowTime) + / slotInMinutes; + endOverFlowTime = (durationInMinutes - startOverFlowTime) + % slotInMinutes; + + } else { + durationInSlots = durationInMinutes / slotInMinutes; + endOverFlowTime = durationInMinutes % slotInMinutes; + } + + // calculate slot overflow at start + if (startOverFlowTime > 0 && currentSlot < cellHeights.length) { + int lastSlotHeight = cellHeights[currentSlot] + dateCellBorder; + pixelLength += (int) (((double) lastSlotHeight / (double) slotInMinutes) * startOverFlowTime); + } + + // calculate length in full slots + int lastFullSlot = currentSlot + durationInSlots; + for (; currentSlot < lastFullSlot && currentSlot < cellHeights.length; currentSlot++) { + pixelLength += cellHeights[currentSlot] + dateCellBorder; + } + + // calculate overflow at end + if (endOverFlowTime > 0 && currentSlot < cellHeights.length) { + int lastSlotHeight = cellHeights[currentSlot] + dateCellBorder; + pixelLength += (int) (((double) lastSlotHeight / (double) slotInMinutes) * endOverFlowTime); + } + + // reduce possible underflow at end + if (endOverFlowTime < 0) { + int lastSlotHeight = cellHeights[currentSlot] + dateCellBorder; + pixelLength += (int) (((double) lastSlotHeight / (double) slotInMinutes) * endOverFlowTime); + } + + return pixelLength; + } + + public int getPixelTopFor(int startFromMinutes) { + int pixelsToTop = 0; + int slotIndex = 0; + + int firstHourInMinutes = firstHour * 60; + + if (firstHourInMinutes > startFromMinutes) { + startFromMinutes = 0; + } else { + startFromMinutes -= firstHourInMinutes; + } + + // calculate full slots to event + int slotsTillEvent = startFromMinutes / slotInMinutes; + int overFlowTime = startFromMinutes % slotInMinutes; + if (slotsTillEvent > 0) { + for (slotIndex = 0; slotIndex < slotsTillEvent; slotIndex++) { + pixelsToTop += cellHeights[slotIndex] + dateCellBorder; + } + } + + // calculate lengths less than one slot + if (overFlowTime > 0) { + int lastSlotHeight = cellHeights[slotIndex] + dateCellBorder; + pixelsToTop += ((double) lastSlotHeight / (double) slotInMinutes) + * overFlowTime; + } + + return pixelsToTop; + } + + public void eventMoved(DateCellDayEvent dayEvent) { + Style s = dayEvent.getElement().getStyle(); + int left = Integer.parseInt(s.getLeft().substring(0, + s.getLeft().length() - 2)); + DateCell previousParent = (DateCell) dayEvent.getParent(); + DateCell newParent = (DateCell) content + .getWidget((left / getDateCellWidth()) + 1); + CalendarEvent se = dayEvent.getCalendarEvent(); + previousParent.removeEvent(dayEvent); + newParent.addEvent(dayEvent); + if (!previousParent.equals(newParent)) { + previousParent.recalculateEventWidths(); + } + newParent.recalculateEventWidths(); + if (calendar.getEventMovedListener() != null) { + calendar.getEventMovedListener().eventMoved(se); + } + } + + public void setToday(Date todayDate, Date todayTimestamp) { + int count = content.getWidgetCount(); + if (count > 1) { + for (int i = 1; i < count; i++) { + DateCell dc = (DateCell) content.getWidget(i); + if (dc.getDate().getTime() == todayDate.getTime()) { + if (isVerticalScrollable()) { + dc.setToday(todayTimestamp, -1); + } else { + dc.setToday(todayTimestamp, getOffsetWidth()); + } + } + dateCellOfToday = dc; + } + } + } + + public DateCell getDateCellOfToday() { + return dateCellOfToday; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public boolean isDisabled() { + return disabled; + } + + public Timebar getTimeBar() { + return timebar; + } + + public void setDateColor(Date when, Date to, String styleName) { + int dateCount = content.getWidgetCount(); + for (int i = 1; i < dateCount; i++) { + DateCell dc = (DateCell) content.getWidget(i); + Date dcDate = dc.getDate(); + int comp = dcDate.compareTo(when); + int comp2 = dcDate.compareTo(to); + if (comp >= 0 && comp2 <= 0) { + dc.setDateColor(styleName); + } + } + } + + /** + * @param calendar + * the calendar to set + */ + public void setCalendar(VCalendar calendar) { + this.calendar = calendar; + } + + /** + * @return the calendar + */ + public VCalendar getCalendar() { + return calendar; + } + + /** + * Get width of the single date cell + * + * @return Date cell width + */ + public int getDateCellWidth() { + int count = content.getWidgetCount() - 1; + int cellWidth = -1; + if (count <= 0) { + return cellWidth; + } + + if (width == -1) { + Widget firstWidget = content.getWidget(1); + cellWidth = firstWidget.getElement().getOffsetWidth(); + } else { + cellWidth = getInternalWidth() / count; + } + return cellWidth; + } + + /** + * @return the number of day cells in this week + */ + public int getDateCellCount() { + return content.getWidgetCount() - 1; + } + + public void setFirstHour(int firstHour) { + this.firstHour = firstHour; + timebar.setFirstHour(firstHour); + } + + public void setLastHour(int lastHour) { + this.lastHour = lastHour; + timebar.setLastHour(lastHour); + } + + public int getFirstHour() { + return firstHour; + } + + public int getLastHour() { + return lastHour; + } + + public static class Timebar extends HTML { + + private static final int[] timesFor12h = { 12, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11 }; + + private int height; + + private final int verticalPadding = 7; // FIXME measure this from DOM + + private int[] slotCellHeights; + + private int firstHour; + + private int lastHour; + + public Timebar(boolean format24h) { + createTimeBar(format24h); + } + + public void setLastHour(int lastHour) { + this.lastHour = lastHour; + } + + public void setFirstHour(int firstHour) { + this.firstHour = firstHour; + + } + + public void setCellHeights(int[] cellHeights) { + slotCellHeights = cellHeights; + } + + private void createTimeBar(boolean format24h) { + setStylePrimaryName("v-calendar-times"); + + // Fist "time" is empty + Element e = DOM.createDiv(); + setStyleName(e, "v-calendar-time"); + e.setInnerText(""); + getElement().appendChild(e); + + DateTimeService dts = new DateTimeService(); + + if (format24h) { + for (int i = firstHour + 1; i <= lastHour; i++) { + e = DOM.createDiv(); + setStyleName(e, "v-calendar-time"); + String delimiter = dts.getClockDelimeter(); + e.setInnerHTML("" + i + "" + delimiter + "00"); + getElement().appendChild(e); + } + } else { + // FIXME Use dts.getAmPmStrings(); and make sure that + // DateTimeService has a some Locale set. + String[] ampm = new String[] { "AM", "PM" }; + + int amStop = (lastHour < 11) ? lastHour : 11; + int pmStart = (firstHour > 11) ? firstHour % 11 : 0; + + if (firstHour < 12) { + for (int i = firstHour + 1; i <= amStop; i++) { + e = DOM.createDiv(); + setStyleName(e, "v-calendar-time"); + e.setInnerHTML("" + timesFor12h[i] + "" + + " " + ampm[0]); + getElement().appendChild(e); + } + } + + if (lastHour > 11) { + for (int i = pmStart; i < lastHour - 11; i++) { + e = DOM.createDiv(); + setStyleName(e, "v-calendar-time"); + e.setInnerHTML("" + timesFor12h[i] + "" + + " " + ampm[1]); + getElement().appendChild(e); + } + } + } + } + + public void updateTimeBar(boolean format24h) { + clear(); + createTimeBar(format24h); + } + + private void clear() { + while (getElement().getChildCount() > 0) { + getElement().removeChild(getElement().getChild(0)); + } + } + + public void setHeightPX(int pixelHeight) { + height = pixelHeight; + + if (pixelHeight > -1) { + // as the negative margins on children pulls the whole element + // upwards, we must compensate. otherwise the element would be + // too short + super.setHeight((height + verticalPadding) + "px"); + removeStyleDependentName("Vsized"); + updateChildHeights(); + + } else { + addStyleDependentName("Vsized"); + updateChildHeights(); + } + } + + private void updateChildHeights() { + int childCount = getElement().getChildCount(); + + if (height != -1) { + + // 23 hours + first is empty + // we try to adjust the height of time labels to the distributed + // heights of the time slots + int hoursPerDay = lastHour - firstHour + 1; + + int slotsPerHour = slotCellHeights.length / hoursPerDay; + int[] cellHeights = new int[slotCellHeights.length + / slotsPerHour]; + + int slotHeightPosition = 0; + for (int i = 0; i < cellHeights.length; i++) { + for (int j = slotHeightPosition; j < slotHeightPosition + + slotsPerHour; j++) { + cellHeights[i] += slotCellHeights[j] + 1; + // 1px more for borders + // FIXME measure from DOM + } + slotHeightPosition += slotsPerHour; + } + + for (int i = 0; i < childCount; i++) { + Element e = (Element) getElement().getChild(i); + e.getStyle().setHeight(cellHeights[i], Unit.PX); + } + + } else { + for (int i = 0; i < childCount; i++) { + Element e = (Element) getElement().getChild(i); + e.getStyle().setProperty("height", ""); + } + } + } + } + + public VCalendar getParentCalendar() { + return calendar; + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java new file mode 100644 index 0000000000..27ace91c4e --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +/** + * Internally used by the calendar + * + * @since 7.1 + */ +public class WeekGridMinuteTimeRange { + private final Date start; + private final Date end; + + /** + * Creates a Date time range between start and end date. Drops seconds + * from the range. + * + * @param start + * Start time of the range + * @param end + * End time of the range + * @param clearSeconds + * Boolean Indicates, if seconds should be dropped from the + * range start and end + */ + public WeekGridMinuteTimeRange(Date start, Date end) { + this.start = new Date(start.getTime()); + this.end = new Date(end.getTime()); + this.start.setSeconds(0); + this.end.setSeconds(0); + } + + public Date getStart() { + return start; + } + + public Date getEnd() { + return end; + } + + public static boolean doesOverlap(WeekGridMinuteTimeRange a, WeekGridMinuteTimeRange b) { + boolean overlaps = a.getStart().compareTo(b.getEnd()) < 0 + && a.getEnd().compareTo(b.getStart()) > 0; + return overlaps; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekLabel.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekLabel.java new file mode 100644 index 0000000000..bde8675435 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekLabel.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import com.google.gwt.user.client.ui.Label; + +/** + * A label in the {@link SimpleWeekToolbar} + * + * @since 7.1 + */ +public class WeekLabel extends Label { + private int week; + private int year; + + public WeekLabel(String string, int week2, int year2) { + super(string); + setStylePrimaryName("v-calendar-week-number"); + week = week2; + year = year2; + } + + public int getWeek() { + return week; + } + + public void setWeek(int week) { + this.week = week; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java new file mode 100644 index 0000000000..e3b7d5d7fe --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java @@ -0,0 +1,184 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; +import java.util.List; + +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.vaadin.client.ui.VCalendar; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public class WeeklyLongEvents extends HorizontalPanel implements HasTooltipKey { + + public static final int EVENT_HEIGTH = 15; + + public static final int EVENT_MARGIN = 1; + + private int rowCount = 0; + + private VCalendar calendar; + + private boolean undefinedWidth; + + public WeeklyLongEvents(VCalendar calendar) { + setStylePrimaryName("v-calendar-weekly-longevents"); + this.calendar = calendar; + } + + public void addDate(Date d) { + DateCellContainer dcc = new DateCellContainer(); + dcc.setDate(d); + dcc.setCalendar(calendar); + add(dcc); + } + + public void setWidthPX(int width) { + if (getWidgetCount() == 0) { + return; + } + undefinedWidth = (width < 0); + + updateCellWidths(); + } + + public void addEvents(List events) { + for (CalendarEvent e : events) { + addEvent(e); + } + } + + public void addEvent(CalendarEvent calendarEvent) { + updateEventSlot(calendarEvent); + + int dateCount = getWidgetCount(); + Date from = calendarEvent.getStart(); + Date to = calendarEvent.getEnd(); + boolean started = false; + for (int i = 0; i < dateCount; i++) { + DateCellContainer dc = (DateCellContainer) getWidget(i); + Date dcDate = dc.getDate(); + int comp = dcDate.compareTo(from); + int comp2 = dcDate.compareTo(to); + WeeklyLongEventsDateCell eventLabel = dc.getDateCell(calendarEvent.getSlotIndex()); + eventLabel.setStylePrimaryName("v-calendar-event"); + if (comp >= 0 && comp2 <= 0) { + eventLabel.setEvent(calendarEvent); + eventLabel.setCalendar(calendar); + + eventLabel.addStyleDependentName("all-day"); + if (comp == 0) { + eventLabel.addStyleDependentName("start"); + } + if (comp2 == 0) { + eventLabel.addStyleDependentName("end"); + } + if (!started && comp > 0 && comp2 <= 0) { + eventLabel.addStyleDependentName("continued-from"); + } else if (i == (dateCount - 1)) { + eventLabel.addStyleDependentName("continued-to"); + } + final String extraStyle = calendarEvent.getStyleName(); + if (extraStyle != null && extraStyle.length() > 0) { + eventLabel.addStyleDependentName(extraStyle + "-all-day"); + } + if (!started) { + eventLabel.setText(calendarEvent.getCaption()); + started = true; + } + } + } + } + + private void updateEventSlot(CalendarEvent e) { + boolean foundFreeSlot = false; + int slot = 0; + while (!foundFreeSlot) { + if (isSlotFree(slot, e.getStart(), e.getEnd())) { + e.setSlotIndex(slot); + foundFreeSlot = true; + + } else { + slot++; + } + } + } + + private boolean isSlotFree(int slot, Date start, Date end) { + int dateCount = getWidgetCount(); + + // Go over all dates this week + for (int i = 0; i < dateCount; i++) { + DateCellContainer dc = (DateCellContainer) getWidget(i); + Date dcDate = dc.getDate(); + int comp = dcDate.compareTo(start); + int comp2 = dcDate.compareTo(end); + + // check if the date is in the range we need + if (comp >= 0 && comp2 <= 0) { + + // check if the slot is taken + if (dc.hasEvent(slot)) { + return false; + } + } + } + + return true; + } + + public int getRowCount() { + return rowCount; + } + + public void updateCellWidths() { + int cells = getWidgetCount(); + if (cells <= 0) { + return; + } + + int cellWidth = -1; + + // if width is undefined, use the width of the first cell + // otherwise use distributed sizes + if (undefinedWidth) { + cellWidth = calendar.getWeekGrid().getDateCellWidth() + - calendar.getWeekGrid().getDateSlotBorder(); + } + + for (int i = 0; i < cells; i++) { + DateCellContainer dc = (DateCellContainer) getWidget(i); + + if (undefinedWidth) { + dc.setWidth(cellWidth + "px"); + + } else { + dc.setWidth(calendar.getWeekGrid().getDateCellWidths()[i] + + "px"); + } + } + } + + @Override + public String getTooltipKey() { + return null; + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEventsDateCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEventsDateCell.java new file mode 100644 index 0000000000..a97d352e81 --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEventsDateCell.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule; + +import java.util.Date; + +import com.google.gwt.user.client.ui.HTML; +import com.vaadin.client.ui.VCalendar; + +/** + * Represents a cell used in {@link WeeklyLongEvents} + * + * @since 7.1 + */ +public class WeeklyLongEventsDateCell extends HTML implements HasTooltipKey { + private Date date; + private CalendarEvent calendarEvent; + private VCalendar calendar; + + public WeeklyLongEventsDateCell() { + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public void setEvent(CalendarEvent event) { + calendarEvent = event; + } + + public CalendarEvent getEvent() { + return calendarEvent; + } + + public void setCalendar(VCalendar calendar) { + this.calendar = calendar; + } + + public VCalendar getCalendar() { + return calendar; + } + + @Override + public Object getTooltipKey() { + if (calendarEvent != null) { + return calendarEvent.getIndex(); + } + return null; + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java new file mode 100644 index 0000000000..03db4d091e --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule.dd; + +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ui.calendar.CalendarConnector; +import com.vaadin.client.ui.dd.VAbstractDropHandler; + +/** + * Abstract base class for calendar drop handlers. + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public abstract class CalendarDropHandler extends VAbstractDropHandler { + + protected CalendarConnector calendarConnector; + + /** + * Set the calendar instance + * + * @param calendarPaintable + */ + public void setConnector(CalendarConnector calendarConnector) { + this.calendarConnector = calendarConnector; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#getConnector() + */ + @Override + public CalendarConnector getConnector() { + return calendarConnector; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VDropHandler#getApplicationConnection + * () + */ + public ApplicationConnection getApplicationConnection() { + return calendarConnector.getClient(); + } + +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java new file mode 100644 index 0000000000..6e57fb6fef --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java @@ -0,0 +1,166 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule.dd; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.vaadin.client.Util; +import com.vaadin.client.ui.calendar.schedule.SimpleDayCell; +import com.vaadin.client.ui.dd.VAcceptCallback; +import com.vaadin.client.ui.dd.VDragEvent; + +/** + * Handles DD when the monthly view is showing in the Calendar. In the monthly + * view, drops are only allowed in the the day cells. Only the day index is + * included in the drop details sent to the server. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class CalendarMonthDropHandler extends CalendarDropHandler { + + private Element currentTargetElement; + private SimpleDayCell currentTargetDay; + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragAccepted + * (com.vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + protected void dragAccepted(VDragEvent drag) { + deEmphasis(); + currentTargetElement = drag.getElementOver(); + currentTargetDay = Util.findWidget(currentTargetElement, + SimpleDayCell.class); + emphasis(); + } + + /** + * Removed the emphasis CSS style name from the currently emphasized day + */ + private void deEmphasis() { + if (currentTargetElement != null && currentTargetDay != null) { + currentTargetDay.removeEmphasisStyle(); + currentTargetElement = null; + } + } + + /** + * Add CSS style name for the currently emphasized day + */ + private void emphasis() { + if (currentTargetElement != null && currentTargetDay != null) { + currentTargetDay.addEmphasisStyle(); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragOver(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragOver(final VDragEvent drag) { + if (isLocationValid(drag.getElementOver())) { + validate(new VAcceptCallback() { + public void accepted(VDragEvent event) { + dragAccepted(drag); + } + }, drag); + } + } + + /** + * Checks if the one can perform a drop in a element + * + * @param elementOver + * The element to check + * @return + */ + private boolean isLocationValid( + com.google.gwt.user.client.Element elementOver) { + com.google.gwt.user.client.Element monthGridElement = calendarConnector + .getWidget().getMonthGrid().getElement(); + + // drops are not allowed in: + // - weekday header + // - week number bart + return DOM.isOrHasChild(monthGridElement, elementOver); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragEnter(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragEnter(VDragEvent drag) { + // NOOP, we determine drag acceptance in dragOver + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#drop(com.vaadin + * .terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public boolean drop(VDragEvent drag) { + if (isLocationValid(drag.getElementOver())) { + updateDropDetails(drag); + deEmphasis(); + return super.drop(drag); + + } else { + deEmphasis(); + return false; + } + } + + /** + * Updates the drop details sent to the server + * + * @param drag + * The drag event + */ + private void updateDropDetails(VDragEvent drag) { + int dayIndex = calendarConnector.getWidget().getMonthGrid() + .getDayCellIndex(currentTargetDay); + + drag.getDropDetails().put("dropDayIndex", dayIndex); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragLeave(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragLeave(VDragEvent drag) { + deEmphasis(); + super.dragLeave(drag); + } +} diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java new file mode 100644 index 0000000000..fa7aaa428b --- /dev/null +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java @@ -0,0 +1,181 @@ +/* + * Copyright 2000-2013 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.client.ui.calendar.schedule.dd; + +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.vaadin.client.Util; +import com.vaadin.client.ui.calendar.schedule.DateCell; +import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent; +import com.vaadin.client.ui.dd.VAcceptCallback; +import com.vaadin.client.ui.dd.VDragEvent; + +/** + * Handles DD when the weekly view is showing in the Calendar. In the weekly + * view, drops are only allowed in the the time slots for each day. The slot + * index and the day index are included in the drop details sent to the server. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class CalendarWeekDropHandler extends CalendarDropHandler { + + private com.google.gwt.user.client.Element currentTargetElement; + private DateCell currentTargetDay; + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragAccepted + * (com.vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + protected void dragAccepted(VDragEvent drag) { + deEmphasis(); + currentTargetElement = drag.getElementOver(); + currentTargetDay = Util + .findWidget(currentTargetElement, DateCell.class); + emphasis(); + } + + /** + * Removes the CSS style name from the emphasized element + */ + private void deEmphasis() { + if (currentTargetElement != null) { + currentTargetDay.removeEmphasisStyle(currentTargetElement); + currentTargetElement = null; + } + } + + /** + * Add a CSS stylen name to current target element + */ + private void emphasis() { + currentTargetDay.addEmphasisStyle(currentTargetElement); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragOver(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragOver(final VDragEvent drag) { + if (isLocationValid(drag.getElementOver())) { + validate(new VAcceptCallback() { + public void accepted(VDragEvent event) { + dragAccepted(drag); + } + }, drag); + } + } + + /** + * Checks if the location is a valid drop location + * + * @param elementOver + * The element to check + * @return + */ + private boolean isLocationValid( + com.google.gwt.user.client.Element elementOver) { + com.google.gwt.user.client.Element weekGridElement = calendarConnector + .getWidget().getWeekGrid().getElement(); + com.google.gwt.user.client.Element timeBarElement = calendarConnector + .getWidget().getWeekGrid().getTimeBar().getElement(); + + com.google.gwt.user.client.Element todayBarElement = null; + if (calendarConnector.getWidget().getWeekGrid().hasToday()) { + todayBarElement = (Element) calendarConnector.getWidget() + .getWeekGrid().getDateCellOfToday().getTodaybarElement(); + } + + // drops are not allowed in: + // - weekday header + // - allday event list + // - todaybar + // - timebar + // - events + return DOM.isOrHasChild(weekGridElement, elementOver) + && !DOM.isOrHasChild(timeBarElement, elementOver) + && todayBarElement != elementOver + && (Util.findWidget(elementOver, DateCellDayEvent.class) == null); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragEnter(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragEnter(VDragEvent drag) { + // NOOP, we determine drag acceptance in dragOver + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#drop(com.vaadin + * .terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public boolean drop(VDragEvent drag) { + if (isLocationValid(drag.getElementOver())) { + updateDropDetails(drag); + deEmphasis(); + return super.drop(drag); + + } else { + deEmphasis(); + return false; + } + } + + /** + * Update the drop details sent to the server + * + * @param drag + * The drag event + */ + private void updateDropDetails(VDragEvent drag) { + int slotIndex = currentTargetDay.getSlotIndex(currentTargetElement); + int dayIndex = calendarConnector.getWidget().getWeekGrid() + .getDateCellIndex(currentTargetDay); + + drag.getDropDetails().put("dropDayIndex", dayIndex); + drag.getDropDetails().put("dropSlotIndex", slotIndex); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler#dragLeave(com + * .vaadin.terminal.gwt.client.ui.dd.VDragEvent) + */ + @Override + public void dragLeave(VDragEvent drag) { + deEmphasis(); + super.dragLeave(drag); + } +} diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java new file mode 100644 index 0000000000..4bf2885a8c --- /dev/null +++ b/server/src/com/vaadin/ui/Calendar.java @@ -0,0 +1,1822 @@ +/* + * Copyright 2000-2013 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.ui; + +import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.DateFormatSymbols; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.EventListener; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TimeZone; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.vaadin.data.Container; +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.event.Action; +import com.vaadin.event.Action.Handler; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.DropTarget; +import com.vaadin.event.dd.TargetDetails; +import com.vaadin.server.KeyMapper; +import com.vaadin.shared.ui.calendar.CalendarEventId; +import com.vaadin.shared.ui.calendar.CalendarServerRpc; +import com.vaadin.shared.ui.calendar.CalendarState; +import com.vaadin.shared.ui.calendar.DateConstants; +import com.vaadin.ui.components.calendar.CalendarComponentEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventClick; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventClickHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventMoveHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResize; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResizeHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.MoveEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.RangeSelectEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.RangeSelectHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClick; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClickHandler; +import com.vaadin.ui.components.calendar.CalendarDateRange; +import com.vaadin.ui.components.calendar.CalendarTargetDetails; +import com.vaadin.ui.components.calendar.ContainerEventProvider; +import com.vaadin.ui.components.calendar.event.BasicEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEditableEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeListener; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; +import com.vaadin.ui.components.calendar.handler.BasicBackwardHandler; +import com.vaadin.ui.components.calendar.handler.BasicDateClickHandler; +import com.vaadin.ui.components.calendar.handler.BasicEventMoveHandler; +import com.vaadin.ui.components.calendar.handler.BasicEventResizeHandler; +import com.vaadin.ui.components.calendar.handler.BasicForwardHandler; +import com.vaadin.ui.components.calendar.handler.BasicWeekClickHandler; + +/** + *

+ * Vaadin Calendar is for visualizing events in a calendar. Calendar events can + * be visualized in the variable length view depending on the start and end + * dates. + *

+ * + *
  • You can set the viewable date range with the {@link #setStartDate(Date)} + * and {@link #setEndDate(Date)} methods. Calendar has a default date range of + * one week
  • + * + *
  • Calendar has two kind of views: monthly and weekly view
  • + * + *
  • If date range is seven days or shorter, the weekly view is used.
  • + * + *
  • Calendar queries its events by using a + * {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider}. By default, a + * {@link com.vaadin.addon.calendar.event.BasicEventProvider BasicEventProvider} + * is used.
  • + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class Calendar extends AbstractComponent implements + CalendarComponentEvents.NavigationNotifier, + CalendarComponentEvents.EventMoveNotifier, + CalendarComponentEvents.RangeSelectNotifier, + CalendarComponentEvents.EventResizeNotifier, + CalendarEventProvider.EventSetChangeListener, DropTarget, + CalendarEditableEventProvider, Action.Container { + + /** + * Calendar can use either 12 hours clock or 24 hours clock. + */ + public enum TimeFormat { + + Format12H(), Format24H(); + } + + /** Defines currently active format for time. 12H/24H. */ + protected TimeFormat currentTimeFormat; + + /** Internal calendar data source. */ + protected java.util.Calendar currentCalendar = java.util.Calendar + .getInstance(); + + /** Defines the component's active time zone. */ + protected TimeZone timezone; + + /** Defines the calendar's date range starting point. */ + protected Date startDate = null; + + /** Defines the calendar's date range ending point. */ + protected Date endDate = null; + + /** Event provider. */ + private CalendarEventProvider calendarEventProvider; + + /** + * Internal buffer for the events that are retrieved from the event + * provider. + */ + protected List events; + + /** Date format that will be used in the UIDL for dates. */ + protected DateFormat df_date = new SimpleDateFormat("yyyy-MM-dd"); + + /** Time format that will be used in the UIDL for time. */ + protected DateFormat df_time = new SimpleDateFormat("HH:mm:ss"); + + /** Date format that will be used in the UIDL for both date and time. */ + protected DateFormat df_date_time = new SimpleDateFormat( + DateConstants.CLIENT_DATE_FORMAT + "-" + + DateConstants.CLIENT_TIME_FORMAT); + + /** + * Week view's scroll position. Client sends updates to this value so that + * scroll position wont reset all the time. + */ + private int scrollTop = 0; + + /** Caption format for the weekly view */ + private String weeklyCaptionFormat = null; + + /** Map from event ids to event handlers */ + private final Map handlers; + + /** + * Drop Handler for Vaadin DD. By default null. + */ + private DropHandler dropHandler; + + /** + * First day to show for a week + */ + private int firstDay = 1; + + /** + * Last day to show for a week + */ + private int lastDay = 7; + + /** + * First hour to show for a day + */ + private int firstHour = 0; + + /** + * Last hour to show for a day + */ + private int lastHour = 23; + + /** + * List of action handlers. + */ + private LinkedList actionHandlers = null; + + /** + * Action mapper. + */ + private KeyMapper actionMapper = null; + + /** + * + */ + private CalendarServerRpcImpl rpc = new CalendarServerRpcImpl(); + + /** + * Returns the logger for the calendar + */ + protected Logger getLogger() { + return Logger.getLogger(Calendar.class.getName()); + } + + /** + * Construct a Vaadin Calendar with a BasicEventProvider and no caption. + * Default date range is one week. + */ + public Calendar() { + this(null, new BasicEventProvider()); + } + + /** + * Construct a Vaadin Calendar with a BasicEventProvider and the provided + * caption. Default date range is one week. + * + * @param caption + */ + public Calendar(String caption) { + this(caption, new BasicEventProvider()); + } + + /** + *

    + * Construct a Vaadin Calendar with event provider. Event provider is + * obligatory, because calendar component will query active events through + * it. + *

    + * + *

    + * By default, Vaadin Calendar will show dates from the start of the current + * week to the end of the current week. Use {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)} to change this. + *

    + * + * @param eventProvider + * Event provider, cannot be null. + */ + public Calendar(CalendarEventProvider eventProvider) { + this(null, eventProvider); + } + + /** + *

    + * Construct a Vaadin Calendar with event provider and a caption. Event + * provider is obligatory, because calendar component will query active + * events through it. + *

    + * + *

    + * By default, Vaadin Calendar will show dates from the start of the current + * week to the end of the current week. Use {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)} to change this. + *

    + * + * @param eventProvider + * Event provider, cannot be null. + */ + // this is the constructor every other constructor calls + public Calendar(String caption, CalendarEventProvider eventProvider) { + registerRpc(rpc); + setCaption(caption); + handlers = new HashMap(); + setDefaultHandlers(); + currentCalendar.setTime(new Date()); + setEventProvider(eventProvider); + getState().firstDayOfWeek = firstDay; + getState().lastVisibleDayOfWeek = lastDay; + getState().firstHourOfDay = firstHour; + getState().lastHourOfDay = lastHour; + setTimeFormat(null); + + } + + @Override + public CalendarState getState() { + return (CalendarState) super.getState(); + } + + @Override + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); + + initCalendarWithLocale(); + + getState().format24H = TimeFormat.Format24H == getTimeFormat(); + setupDaysAndActions(); + setupCalendarEvents(); + rpc.scroll(scrollTop); + } + + /** + * Set all the wanted default handlers here. This is always called after + * constructing this object. All other events have default handlers except + * range and event click. + */ + protected void setDefaultHandlers() { + setHandler(new BasicBackwardHandler()); + setHandler(new BasicForwardHandler()); + setHandler(new BasicWeekClickHandler()); + setHandler(new BasicDateClickHandler()); + setHandler(new BasicEventMoveHandler()); + setHandler(new BasicEventResizeHandler()); + } + + /** + * Gets the calendar's start date. + * + * @return First visible date. + */ + public Date getStartDate() { + if (startDate == null) { + currentCalendar.set(java.util.Calendar.DAY_OF_WEEK, + currentCalendar.getFirstDayOfWeek()); + return currentCalendar.getTime(); + } + return startDate; + } + + /** + * Sets start date for the calendar. This and {@link #setEndDate(Date)} + * control the range of dates visible on the component. The default range is + * one week. + * + * @param date + * First visible date to show. + */ + public void setStartDate(Date date) { + if (!date.equals(startDate)) { + startDate = date; + markAsDirty(); + } + } + + /** + * Gets the calendar's end date. + * + * @return Last visible date. + */ + public Date getEndDate() { + if (endDate == null) { + currentCalendar.set(java.util.Calendar.DAY_OF_WEEK, + currentCalendar.getFirstDayOfWeek() + 6); + return currentCalendar.getTime(); + } + return endDate; + } + + /** + * Sets end date for the calendar. Starting from startDate, only six weeks + * will be shown if duration to endDate is longer than six weeks. + * + * This and {@link #setStartDate(Date)} control the range of dates visible + * on the component. The default range is one week. + * + * @param date + * Last visible date to show. + */ + public void setEndDate(Date date) { + if (startDate != null && startDate.after(date)) { + startDate = (Date) date.clone(); + markAsDirty(); + } else if (!date.equals(endDate)) { + endDate = date; + markAsDirty(); + } + } + + /** + * Sets the locale to be used in the Calendar component. + * + * @see com.vaadin.ui.AbstractComponent#setLocale(java.util.Locale) + */ + @Override + public void setLocale(Locale newLocale) { + super.setLocale(newLocale); + initCalendarWithLocale(); + } + + /** + * Initialize the java calendar instance with the current locale and + * timezone. + */ + private void initCalendarWithLocale() { + if (timezone != null) { + currentCalendar = java.util.Calendar.getInstance(timezone, + getLocale()); + + } else { + currentCalendar = java.util.Calendar.getInstance(getLocale()); + } + } + + private void setupCalendarEvents() { + int durationInDays = (int) (((endDate.getTime()) - startDate.getTime()) / DateConstants.DAYINMILLIS); + durationInDays++; + if (durationInDays > 60) { + throw new RuntimeException("Daterange is too big (max 60) = " + + durationInDays); + } + + Date firstDateToShow = expandStartDate(startDate, durationInDays > 7); + Date lastDateToShow = expandEndDate(endDate, durationInDays > 7); + + currentCalendar.setTime(firstDateToShow); + events = getEventProvider().getEvents(firstDateToShow, lastDateToShow); + + List calendarStateEvents = new ArrayList(); + if (events != null) { + for (int i = 0; i < events.size(); i++) { + CalendarEvent e = events.get(i); + CalendarState.Event event = new CalendarState.Event(); + event.index = i; + event.caption = e.getCaption() == null ? "" : e.getCaption(); + event.dateFrom = df_date.format(e.getStart()); + event.dateTo = df_date.format(e.getEnd()); + event.timeFrom = df_time.format(e.getStart()); + event.timeTo = df_time.format(e.getEnd()); + event.description = e.getDescription() == null ? "" : e + .getDescription(); + event.styleName = e.getStyleName() == null ? "" : e + .getStyleName(); + event.allDay = e.isAllDay(); + calendarStateEvents.add(event); + } + } + getState().events = calendarStateEvents; + } + + private void setupDaysAndActions() { + // Make sure we have a up-to-date locale + initCalendarWithLocale(); + + CalendarState state = getState(); + + state.firstDayOfWeek = currentCalendar.getFirstDayOfWeek(); + + // If only one is null, throw exception + // If both are null, set defaults + if (startDate == null ^ endDate == null) { + String message = "Schedule cannot be painted without a proper date range.\n"; + if (startDate == null) { + throw new IllegalStateException(message + + "You must set a start date using setStartDate(Date)."); + + } else { + throw new IllegalStateException(message + + "You must set an end date using setEndDate(Date)."); + } + + } else if (startDate == null && endDate == null) { + // set defaults + startDate = getStartDate(); + endDate = getEndDate(); + } + + int durationInDays = (int) (((endDate.getTime()) - startDate.getTime()) / DateConstants.DAYINMILLIS); + durationInDays++; + if (durationInDays > 60) { + throw new RuntimeException("Daterange is too big (max 60) = " + + durationInDays); + } + + state.dayNames = getDayNamesShort(); + state.monthNames = getMonthNamesShort(); + + // Use same timezone in all dates this component handles. + // Show "now"-marker in browser within given timezone. + Date now = new Date(); + currentCalendar.setTime(now); + now = currentCalendar.getTime(); + + // Reset time zones for custom date formats + df_date.setTimeZone(currentCalendar.getTimeZone()); + df_time.setTimeZone(currentCalendar.getTimeZone()); + + state.now = (df_date.format(now) + " " + df_time.format(now)); + + Date firstDateToShow = expandStartDate(startDate, durationInDays > 7); + Date lastDateToShow = expandEndDate(endDate, durationInDays > 7); + + currentCalendar.setTime(firstDateToShow); + + DateFormat weeklyCaptionFormatter = getWeeklyCaptionFormatter(); + weeklyCaptionFormatter.setTimeZone(currentCalendar.getTimeZone()); + + Map> actionMap = new HashMap>(); + + List days = new ArrayList(); + + // Send all dates to client from server. This + // approach was taken because gwt doesn't + // support date localization properly. + while (currentCalendar.getTime().compareTo(lastDateToShow) < 1) { + final Date date = currentCalendar.getTime(); + final CalendarState.Day day = new CalendarState.Day(); + day.date = df_date.format(date); + day.localizedDateFormat = weeklyCaptionFormatter.format(date); + day.dayOfWeek = getDowByLocale(currentCalendar); + day.week = currentCalendar.get(java.util.Calendar.WEEK_OF_YEAR); + + days.add(day); + + // Get actions for a specific date + if (actionHandlers != null) { + for (Action.Handler actionHandler : actionHandlers) { + + // Create calendar which omits time + GregorianCalendar cal = new GregorianCalendar( + getTimeZone(), getLocale()); + cal.clear(); + cal.set(currentCalendar.get(java.util.Calendar.YEAR), + currentCalendar.get(java.util.Calendar.MONTH), + currentCalendar.get(java.util.Calendar.DATE)); + + // Get day start and end times + Date start = cal.getTime(); + cal.add(java.util.Calendar.DATE, 1); + Date end = cal.getTime(); + + boolean monthView = (durationInDays > 7); + + /** + * If in day or week view add actions for each half-an-hour. + * If in month view add actions for each day + */ + if (monthView) { + setActionsForDay(actionMap, start, end, actionHandler); + } else { + setActionsForEachHalfHour(actionMap, start, end, + actionHandler); + } + + } + } + + currentCalendar.add(java.util.Calendar.DATE, 1); + } + state.days = days; + state.actions = createActionsList(actionMap); + } + + private void setActionsForEachHalfHour( + Map> actionMap, Date start, + Date end, Action.Handler actionHandler) { + GregorianCalendar cal = new GregorianCalendar(getTimeZone(), + getLocale()); + cal.setTime(start); + while (cal.getTime().before(end)) { + Date s = cal.getTime(); + cal.add(java.util.Calendar.MINUTE, 30); + Date e = cal.getTime(); + CalendarDateRange range = new CalendarDateRange(s, e, getTimeZone()); + Action[] actions = actionHandler.getActions(range, this); + if (actions != null) { + Set actionSet = new HashSet( + Arrays.asList(actions)); + actionMap.put(range, actionSet); + } + } + } + + private void setActionsForDay( + Map> actionMap, Date start, + Date end, Action.Handler actionHandler) { + CalendarDateRange range = new CalendarDateRange(start, end, + getTimeZone()); + Action[] actions = actionHandler.getActions(range, this); + if (actions != null) { + Set actionSet = new HashSet(Arrays.asList(actions)); + actionMap.put(range, actionSet); + } + } + + private List createActionsList( + Map> actionMap) { + if (actionMap.isEmpty()) { + return null; + } + + List calendarActions = new ArrayList(); + + SimpleDateFormat formatter = new SimpleDateFormat( + DateConstants.ACTION_DATE_FORMAT_PATTERN); + formatter.setTimeZone(getTimeZone()); + + for (Entry> entry : actionMap.entrySet()) { + CalendarDateRange range = entry.getKey(); + Set actions = entry.getValue(); + for (Action action : actions) { + String key = actionMapper.key(action); + CalendarState.Action calendarAction = new CalendarState.Action(); + calendarAction.actionKey = key; + calendarAction.caption = action.getCaption(); + setResource(key, action.getIcon()); + calendarAction.iconKey = key; + calendarAction.startDate = formatter.format(range.getStart()); + calendarAction.endDate = formatter.format(range.getEnd()); + calendarActions.add(calendarAction); + } + } + + return calendarActions; + } + + /** + * Gets currently active time format. Value is either TimeFormat.Format12H + * or TimeFormat.Format24H. + * + * @return TimeFormat Format for the time. + */ + public TimeFormat getTimeFormat() { + if (currentTimeFormat == null) { + SimpleDateFormat f = (SimpleDateFormat) SimpleDateFormat + .getTimeInstance(SimpleDateFormat.SHORT, getLocale()); + String p = f.toPattern(); + if (p.indexOf("HH") != -1 || p.indexOf("H") != -1) { + return TimeFormat.Format24H; + } + return TimeFormat.Format12H; + } + return currentTimeFormat; + } + + /** + * Example: setTimeFormat(TimeFormat.Format12H);
    Set to + * null, if you want the format being defined by the locale. + * + * @param format + * Set 12h or 24h format. Default is defined by the locale. + */ + public void setTimeFormat(TimeFormat format) { + currentTimeFormat = format; + markAsDirty(); + } + + /** + * Returns a time zone that is currently used by this component. + * + * @return Component's Time zone + */ + public TimeZone getTimeZone() { + if (timezone == null) { + return currentCalendar.getTimeZone(); + } + return timezone; + } + + /** + * Set time zone that this component will use. Null value sets the default + * time zone. + * + * @param zone + * Time zone to use + */ + public void setTimeZone(TimeZone zone) { + timezone = zone; + if (!currentCalendar.getTimeZone().equals(zone)) { + if (zone == null) { + zone = TimeZone.getDefault(); + } + currentCalendar.setTimeZone(zone); + df_date_time.setTimeZone(zone); + markAsDirty(); + } + } + + /** + * Get the internally used Calendar instance. This is the currently used + * instance of {@link java.util.Calendar} but is bound to change during the + * lifetime of the component. + * + * @return the currently used java calendar + */ + public java.util.Calendar getInternalCalendar() { + return currentCalendar; + } + + /** + *

    + * This method restricts the weekdays that are shown. This affects both the + * monthly and the weekly view. The general contract is that firstDay < + * lastDay. + *

    + * + *

    + * Note that this only affects the rendering process. Events are still + * requested by the dates set by {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)}. + *

    + * + * @param firstDay + * the first day of the week to show, between 1 and 7 + */ + public void setFirstVisibleDayOfWeek(int firstDay) { + if (this.firstDay != firstDay && firstDay >= 1 && firstDay <= 7 + && getLastVisibleDayOfWeek() >= firstDay) { + this.firstDay = firstDay; + getState().firstVisibleDayOfWeek = firstDay; + } + } + + /** + * Get the first visible day of the week. Returns the weekdays as integers + * represented by {@link java.util.Calendar#DAY_OF_WEEK} + * + * @return An integer representing the week day according to + * {@link java.util.Calendar#DAY_OF_WEEK} + */ + public int getFirstVisibleDayOfWeek() { + return firstDay; + } + + /** + *

    + * This method restricts the weekdays that are shown. This affects both the + * monthly and the weekly view. The general contract is that firstDay < + * lastDay. + *

    + * + *

    + * Note that this only affects the rendering process. Events are still + * requested by the dates set by {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)}. + *

    + * + * @param lastDay + * the first day of the week to show, between 1 and 7 + */ + public void setLastVisibleDayOfWeek(int lastDay) { + if (this.lastDay != lastDay && lastDay >= 1 && lastDay <= 7 + && getFirstVisibleDayOfWeek() <= lastDay) { + this.lastDay = lastDay; + getState().lastVisibleDayOfWeek = lastDay; + } + } + + /** + * Get the last visible day of the week. Returns the weekdays as integers + * represented by {@link java.util.Calendar#DAY_OF_WEEK} + * + * @return An integer representing the week day according to + * {@link java.util.Calendar#DAY_OF_WEEK} + */ + public int getLastVisibleDayOfWeek() { + return lastDay; + } + + /** + *

    + * This method restricts the hours that are shown per day. This affects the + * weekly view. The general contract is that firstHour < lastHour. + *

    + * + *

    + * Note that this only affects the rendering process. Events are still + * requested by the dates set by {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)}. + *

    + * + * @param firstHour + * the first hour of the day to show, between 0 and 23 + */ + public void setFirstVisibleHourOfDay(int firstHour) { + if (this.firstHour != firstHour && firstHour >= 0 && firstHour <= 23 + && firstHour <= getLastVisibleHourOfDay()) { + this.firstHour = firstHour; + getState().firstHourOfDay = firstHour; + } + } + + /** + * Returns the first visible hour in the week view. Returns the hour using a + * 24h time format + * + */ + public int getFirstVisibleHourOfDay() { + return firstHour; + } + + /** + *

    + * This method restricts the hours that are shown per day. This affects the + * weekly view. The general contract is that firstHour < lastHour. + *

    + * + *

    + * Note that this only affects the rendering process. Events are still + * requested by the dates set by {@link #setStartDate(Date)} and + * {@link #setEndDate(Date)}. + *

    + * + * @param lastHour + * the first hour of the day to show, between 0 and 23 + */ + public void setLastVisibleHourOfDay(int lastHour) { + if (this.lastHour != lastHour && lastHour >= 0 && lastHour <= 23 + && lastHour >= getFirstVisibleHourOfDay()) { + this.lastHour = lastHour; + getState().lastHourOfDay = lastHour; + } + } + + /** + * Returns the last visible hour in the week view. Returns the hour using a + * 24h time format + * + */ + public int getLastVisibleHourOfDay() { + return lastHour; + } + + /** + * Gets the date caption format for the weekly view. + * + * @return The pattern used in caption of dates in weekly view. + */ + public String getWeeklyCaptionFormat() { + return weeklyCaptionFormat; + } + + /** + * Sets custom date format for the weekly view. This is the caption of the + * date. Format could be like "mmm MM/dd". + * + * @param dateFormatPattern + * The date caption pattern. + */ + public void setWeeklyCaptionFormat(String dateFormatPattern) { + if ((weeklyCaptionFormat == null && dateFormatPattern != null) + || (weeklyCaptionFormat != null && !weeklyCaptionFormat + .equals(dateFormatPattern))) { + weeklyCaptionFormat = dateFormatPattern; + markAsDirty(); + } + } + + private DateFormat getWeeklyCaptionFormatter() { + if (weeklyCaptionFormat != null) { + return new SimpleDateFormat(weeklyCaptionFormat, getLocale()); + } else { + return SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT, + getLocale()); + } + } + + /** + * Get the day of week by the given calendar and its locale + * + * @param calendar + * The calendar to use + * @return + */ + private static int getDowByLocale(java.util.Calendar calendar) { + int fow = calendar.get(java.util.Calendar.DAY_OF_WEEK); + + // monday first + if (calendar.getFirstDayOfWeek() == java.util.Calendar.MONDAY) { + fow = (fow == java.util.Calendar.SUNDAY) ? 7 : fow - 1; + } + + return fow; + } + + /** + * Is the user allowed to trigger events which alters the events + * + * @return true if the client is allowed to send changes to server + * @see #isEventClickAllowed() + */ + protected boolean isClientChangeAllowed() { + return !isReadOnly() && isEnabled(); + } + + /** + * Is the user allowed to trigger click events + * + * @return true if the client is allowed to click events + * @see #isClientChangeAllowed() + */ + protected boolean isEventClickAllowed() { + return isEnabled(); + } + + /** + * Fires an event when the user selecing moving forward/backward in the + * calendar. + * + * @param forward + * True if the calendar moved forward else backward is assumed. + */ + protected void fireNavigationEvent(boolean forward) { + if (forward) { + fireEvent(new ForwardEvent(this)); + } else { + fireEvent(new BackwardEvent(this)); + } + } + + /** + * Fires an event move event to all server side move listerners + * + * @param index + * The index of the event in the events list + * @param newFromDatetime + * The changed from date time + */ + protected void fireEventMove(int index, Date newFromDatetime) { + MoveEvent event = new MoveEvent(this, events.get(index), + newFromDatetime); + + if (calendarEventProvider instanceof EventMoveHandler) { + // Notify event provider if it is an event move handler + ((EventMoveHandler) calendarEventProvider).eventMove(event); + } + + // Notify event move handler attached by using the + // setHandler(EventMoveHandler) method + fireEvent(event); + } + + /** + * Fires event when a week was clicked in the calendar. + * + * @param week + * The week that was clicked + * @param year + * The year of the week + */ + protected void fireWeekClick(int week, int year) { + fireEvent(new WeekClick(this, week, year)); + } + + /** + * Fires event when a date was clicked in the calendar. Uses an existing + * event from the event cache. + * + * @param index + * The index of the event in the event cache. + */ + protected void fireEventClick(Integer index) { + fireEvent(new EventClick(this, events.get(index))); + } + + /** + * Fires event when a date was clicked in the calendar. Creates a new event + * for the date and passes it to the listener. + * + * @param date + * The date and time that was clicked + */ + protected void fireDateClick(Date date) { + fireEvent(new DateClickEvent(this, date)); + } + + /** + * Fires an event range selected event. The event is fired when a user + * highlights an area in the calendar. The highlighted areas start and end + * dates are returned as arguments. + * + * @param from + * The start date and time of the highlighted area + * @param to + * The end date and time of the highlighted area + * @param monthlyMode + * Is the calendar in monthly mode + */ + protected void fireRangeSelect(Date from, Date to, boolean monthlyMode) { + fireEvent(new RangeSelectEvent(this, from, to, monthlyMode)); + } + + /** + * Fires an event resize event. The event is fired when a user resizes the + * event in the calendar causing the time range of the event to increase or + * decrease. The new start and end times are returned as arguments to this + * method. + * + * @param index + * The index of the event in the event cache + * @param startTime + * The new start date and time of the event + * @param endTime + * The new end date and time of the event + */ + protected void fireEventResize(int index, Date startTime, Date endTime) { + EventResize event = new EventResize(this, events.get(index), startTime, + endTime); + + if (calendarEventProvider instanceof EventResizeHandler) { + // Notify event provider if it is an event resize handler + ((EventResizeHandler) calendarEventProvider).eventResize(event); + } + + // Notify event resize handler attached by using the + // setHandler(EventMoveHandler) method + fireEvent(event); + } + + /** + * Localized display names for week days starting from sunday. Returned + * array's length is always 7. + * + * @return Array of localized weekday names. + */ + protected String[] getDayNamesShort() { + DateFormatSymbols s = new DateFormatSymbols(getLocale()); + return Arrays.copyOfRange(s.getWeekdays(), 1, 8); + } + + /** + * Localized display names for months starting from January. Returned + * array's length is always 12. + * + * @return Array of localized month names. + */ + protected String[] getMonthNamesShort() { + DateFormatSymbols s = new DateFormatSymbols(getLocale()); + return Arrays.copyOf(s.getShortMonths(), 12); + } + + /** + * Gets a date that is first day in the week that target given date belongs + * to. + * + * @param date + * Target date + * @return Date that is first date in same week that given date is. + */ + protected Date getFirstDateForWeek(Date date) { + int firstDayOfWeek = currentCalendar.getFirstDayOfWeek(); + currentCalendar.setTime(date); + while (firstDayOfWeek != currentCalendar + .get(java.util.Calendar.DAY_OF_WEEK)) { + currentCalendar.add(java.util.Calendar.DATE, -1); + } + return currentCalendar.getTime(); + } + + /** + * Gets a date that is last day in the week that target given date belongs + * to. + * + * @param date + * Target date + * @return Date that is last date in same week that given date is. + */ + protected Date getLastDateForWeek(Date date) { + currentCalendar.setTime(date); + currentCalendar.add(java.util.Calendar.DATE, 1); + int firstDayOfWeek = currentCalendar.getFirstDayOfWeek(); + // Roll to weeks last day using firstdayofweek. Roll until FDofW is + // found and then roll back one day. + while (firstDayOfWeek != currentCalendar + .get(java.util.Calendar.DAY_OF_WEEK)) { + currentCalendar.add(java.util.Calendar.DATE, 1); + } + currentCalendar.add(java.util.Calendar.DATE, -1); + return currentCalendar.getTime(); + } + + /** + * Calculates the end time of the day using the given calendar and date + * + * @param date + * @param calendar + * the calendar instance to be used in the calculation. The given + * instance is unchanged in this operation. + * @return the given date, with time set to the end of the day + */ + private static Date getEndOfDay(java.util.Calendar calendar, Date date) { + java.util.Calendar calendarClone = (java.util.Calendar) calendar + .clone(); + + calendarClone.setTime(date); + calendarClone.set(java.util.Calendar.MILLISECOND, + calendarClone.getActualMaximum(java.util.Calendar.MILLISECOND)); + calendarClone.set(java.util.Calendar.SECOND, + calendarClone.getActualMaximum(java.util.Calendar.SECOND)); + calendarClone.set(java.util.Calendar.MINUTE, + calendarClone.getActualMaximum(java.util.Calendar.MINUTE)); + calendarClone.set(java.util.Calendar.HOUR, + calendarClone.getActualMaximum(java.util.Calendar.HOUR)); + calendarClone.set(java.util.Calendar.HOUR_OF_DAY, + calendarClone.getActualMaximum(java.util.Calendar.HOUR_OF_DAY)); + + return calendarClone.getTime(); + } + + /** + * Calculates the end time of the day using the given calendar and date + * + * @param date + * @param calendar + * the calendar instance to be used in the calculation. The given + * instance is unchanged in this operation. + * @return the given date, with time set to the end of the day + */ + private static Date getStartOfDay(java.util.Calendar calendar, Date date) { + java.util.Calendar calendarClone = (java.util.Calendar) calendar + .clone(); + + calendarClone.setTime(date); + calendarClone.set(java.util.Calendar.MILLISECOND, 0); + calendarClone.set(java.util.Calendar.SECOND, 0); + calendarClone.set(java.util.Calendar.MINUTE, 0); + calendarClone.set(java.util.Calendar.HOUR, 0); + calendarClone.set(java.util.Calendar.HOUR_OF_DAY, 0); + + return calendarClone.getTime(); + } + + /** + * Finds the first day of the week and returns a day representing the start + * of that day + * + * @param start + * The actual date + * @param expandToFullWeek + * Should the returned date be moved to the start of the week + * @return If expandToFullWeek is set then it returns the first day of the + * week, else it returns a clone of the actual date with the time + * set to the start of the day + */ + protected Date expandStartDate(Date start, boolean expandToFullWeek) { + // If the duration is more than week, use monthly view and get startweek + // and endweek. Example if views daterange is from tuesday to next weeks + // wednesday->expand to monday to nextweeks sunday. If firstdayofweek = + // monday + if (expandToFullWeek) { + start = getFirstDateForWeek(start); + + } else { + start = (Date) start.clone(); + } + + // Always expand to the start of the first day to the end of the last + // day + start = getStartOfDay(currentCalendar, start); + + return start; + } + + /** + * Finds the last day of the week and returns a day representing the end of + * that day + * + * @param end + * The actual date + * @param expandToFullWeek + * Should the returned date be moved to the end of the week + * @return If expandToFullWeek is set then it returns the last day of the + * week, else it returns a clone of the actual date with the time + * set to the end of the day + */ + protected Date expandEndDate(Date end, boolean expandToFullWeek) { + // If the duration is more than week, use monthly view and get startweek + // and endweek. Example if views daterange is from tuesday to next weeks + // wednesday->expand to monday to nextweeks sunday. If firstdayofweek = + // monday + if (expandToFullWeek) { + end = getLastDateForWeek(end); + + } else { + end = (Date) end.clone(); + } + + // Always expand to the start of the first day to the end of the last + // day + end = getEndOfDay(currentCalendar, end); + + return end; + } + + /** + * Set the {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider} to be used with this calendar. The EventProvider + * is used to query for events to show, and must be non-null. By default a + * {@link com.vaadin.addon.calendar.event.BasicEventProvider + * BasicEventProvider} is used. + * + * @param calendarEventProvider + * the calendarEventProvider to set. Cannot be null. + */ + public void setEventProvider(CalendarEventProvider calendarEventProvider) { + if (calendarEventProvider == null) { + throw new IllegalArgumentException( + "Calendar event provider cannot be null"); + } + + // remove old listener + if (getEventProvider() instanceof EventSetChangeNotifier) { + ((EventSetChangeNotifier) getEventProvider()).removeEventSetChangeListener(this); + } + + this.calendarEventProvider = calendarEventProvider; + + // add new listener + if (calendarEventProvider instanceof EventSetChangeNotifier) { + ((EventSetChangeNotifier) calendarEventProvider).addEventSetChangeListener(this); + } + } + + /** + * @return the {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider} currently used + */ + public CalendarEventProvider getEventProvider() { + return calendarEventProvider; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarEvents.EventChangeListener#eventChange + * (com.vaadin.addon.calendar.ui.CalendarEvents.EventChange) + */ + public void eventSetChange(EventSetChangeEvent changeEvent) { + // sanity check + if (calendarEventProvider == changeEvent.getProvider()) { + markAsDirty(); + } + } + + /** + * Set the handler for the given type information. Mirrors + * {@link #addListener(String, Class, Object, Method) addListener} from + * AbstractComponent + * + * @param eventId + * A unique id for the event. Usually one of + * {@link CalendarEventId} + * @param eventType + * The class of the event, most likely a subclass of + * {@link CalendarComponentEvent} + * @param listener + * A listener that listens to the given event + * @param listenerMethod + * The method on the lister to call when the event is triggered + */ + protected void setHandler(String eventId, Class eventType, + EventListener listener, Method listenerMethod) { + if (handlers.get(eventId) != null) { + removeListener(eventId, eventType, handlers.get(eventId)); + handlers.remove(eventId); + } + + if (listener != null) { + addListener(eventId, eventType, listener, listenerMethod); + handlers.put(eventId, listener); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.NavigationNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardHandler) + */ + public void setHandler(ForwardHandler listener) { + setHandler(ForwardEvent.EVENT_ID, ForwardEvent.class, listener, + ForwardHandler.forwardMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.NavigationNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardHandler) + */ + public void setHandler(BackwardHandler listener) { + setHandler(BackwardEvent.EVENT_ID, BackwardEvent.class, listener, + BackwardHandler.backwardMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.NavigationNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickHandler) + */ + public void setHandler(DateClickHandler listener) { + setHandler(DateClickEvent.EVENT_ID, DateClickEvent.class, listener, + DateClickHandler.dateClickMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.NavigationNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventClickHandler) + */ + public void setHandler(EventClickHandler listener) { + setHandler(EventClick.EVENT_ID, EventClick.class, listener, + EventClickHandler.eventClickMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.NavigationNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClickHandler) + */ + public void setHandler(WeekClickHandler listener) { + setHandler(WeekClick.EVENT_ID, WeekClick.class, listener, + WeekClickHandler.weekClickMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler + * ) + */ + public void setHandler(EventResizeHandler listener) { + setHandler(EventResize.EVENT_ID, EventResize.class, listener, + EventResizeHandler.eventResizeMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.RangeSelectNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.RangeSelectHandler + * ) + */ + public void setHandler(RangeSelectHandler listener) { + setHandler(RangeSelectEvent.EVENT_ID, RangeSelectEvent.class, listener, + RangeSelectHandler.rangeSelectMethod); + + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler) + */ + public void setHandler(EventMoveHandler listener) { + setHandler(MoveEvent.EVENT_ID, MoveEvent.class, listener, + EventMoveHandler.eventMoveMethod); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.CalendarEventNotifier + * #getHandler(java.lang.String) + */ + public EventListener getHandler(String eventId) { + return handlers.get(eventId); + } + + /** + * Get the currently active drop handler + */ + public DropHandler getDropHandler() { + return dropHandler; + } + + /** + * Set the drop handler for the calendar See {@link DropHandler} for + * implementation details. + * + * @param dropHandler + * The drop handler to set + */ + public void setDropHandler(DropHandler dropHandler) { + this.dropHandler = dropHandler; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.event.dd.DropTarget#translateDropTargetDetails(java.util.Map) + */ + public TargetDetails translateDropTargetDetails( + Map clientVariables) { + Map serverVariables = new HashMap(1); + + if (clientVariables.containsKey("dropSlotIndex")) { + int slotIndex = (Integer) clientVariables.get("dropSlotIndex"); + int dayIndex = (Integer) clientVariables.get("dropDayIndex"); + + currentCalendar.setTime(getStartOfDay(currentCalendar, startDate)); + currentCalendar.add(java.util.Calendar.DATE, dayIndex); + + // change this if slot length is modified + currentCalendar.add(java.util.Calendar.MINUTE, slotIndex * 30); + + serverVariables.put("dropTime", currentCalendar.getTime()); + + } else { + int dayIndex = (Integer) clientVariables.get("dropDayIndex"); + currentCalendar.setTime(expandStartDate(startDate, true)); + currentCalendar.add(java.util.Calendar.DATE, dayIndex); + serverVariables.put("dropDay", currentCalendar.getTime()); + } + + CalendarTargetDetails td = new CalendarTargetDetails(serverVariables, + this); + td.setHasDropTime(clientVariables.containsKey("dropSlotIndex")); + + return td; + } + + /** + * Sets a container as a data source for the events in the calendar. + * Equivalent for doing + * Calendar.setEventProvider(new ContainerEventProvider(container)) + * + * Use this method if you are adding a container which uses the default + * property ids like {@link BeanItemContainer} for instance. If you are + * using custom properties instead use + * {@link Calendar#setContainerDataSource(com.vaadin.data.Container.Indexed, Object, Object, Object, Object, Object)} + * + * Please note that the container must be sorted by date! + * + * @param container + * The container to use as a datasource + */ + public void setContainerDataSource(Container.Indexed container) { + ContainerEventProvider provider = new ContainerEventProvider(container); + provider.addEventSetChangeListener(new CalendarEventProvider.EventSetChangeListener() { + public void eventSetChange(EventSetChangeEvent changeEvent) { + // Repaint if events change + markAsDirty(); + } + }); + provider.addEventChangeListener(new EventChangeListener() { + public void eventChange(EventChangeEvent changeEvent) { + // Repaint if event changes + markAsDirty(); + } + }); + setEventProvider(provider); + } + + /** + * Sets a container as a data source for the events in the calendar. + * Equivalent for doing + * Calendar.setEventProvider(new ContainerEventProvider(container)) + * + * Please note that the container must be sorted by date! + * + * @param container + * The container to use as a data source + * @param captionProperty + * The property that has the caption, null if no caption property + * is present + * @param descriptionProperty + * The property that has the description, null if no description + * property is present + * @param startDateProperty + * The property that has the starting date + * @param endDateProperty + * The property that has the ending date + * @param styleNameProperty + * The property that has the stylename, null if no stylname + * property is present + */ + public void setContainerDataSource(Container.Indexed container, + Object captionProperty, Object descriptionProperty, + Object startDateProperty, Object endDateProperty, + Object styleNameProperty) { + ContainerEventProvider provider = new ContainerEventProvider(container); + provider.setCaptionProperty(captionProperty); + provider.setDescriptionProperty(descriptionProperty); + provider.setStartDateProperty(startDateProperty); + provider.setEndDateProperty(endDateProperty); + provider.setStyleNameProperty(styleNameProperty); + provider.addEventSetChangeListener(new CalendarEventProvider.EventSetChangeListener() { + public void eventSetChange(EventSetChangeEvent changeEvent) { + // Repaint if events change + markAsDirty(); + } + }); + provider.addEventChangeListener(new EventChangeListener() { + public void eventChange(EventChangeEvent changeEvent) { + // Repaint if event changes + markAsDirty(); + } + }); + setEventProvider(provider); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. + * util.Date, java.util.Date) + */ + public List getEvents(Date startDate, Date endDate) { + return getEventProvider().getEvents(startDate, endDate); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void addEvent(CalendarEvent event) { + if (getEventProvider() instanceof CalendarEditableEventProvider) { + CalendarEditableEventProvider provider = (CalendarEditableEventProvider) getEventProvider(); + provider.addEvent(event); + markAsDirty(); + } else { + throw new UnsupportedOperationException( + "Event provider does not support adding events"); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void removeEvent(CalendarEvent event) { + if (getEventProvider() instanceof CalendarEditableEventProvider) { + CalendarEditableEventProvider provider = (CalendarEditableEventProvider) getEventProvider(); + provider.removeEvent(event); + markAsDirty(); + } else { + throw new UnsupportedOperationException( + "Event provider does not support removing events"); + } + } + + /** + * Adds an action handler to the calender that handles event produced by the + * context menu. + * + *

    + * The {@link Handler#getActions(Object, Object)} parameters depend on what + * view the Calendar is in: + *

      + *
    • If the Calendar is in Day or Week View then the target + * parameter will be a {@link CalendarDateRange} with a range of + * half-an-hour. The {@link Handler#getActions(Object, Object)} method will + * be called once per half-hour slot.
    • + *
    • If the Calendar is in Month View then the target parameter + * will be a {@link CalendarDateRange} with a range of one day. The + * {@link Handler#getActions(Object, Object)} will be called once for each + * day. + *
    + * The Dates passed into the {@link CalendarDateRange} are in the same + * timezone as the calendar is. + *

    + * + *

    + * The {@link Handler#handleAction(Action, Object, Object)} parameters + * depend on what the context menu is called upon: + *

      + *
    • If the context menu is called upon an event then the target parameter + * is the event, i.e. instanceof {@link CalendarEvent}
    • + *
    • If the context menu is called upon an empty slot then the target is a + * {@link Date} representing that slot + *
    + *

    + */ + public void addActionHandler(Handler actionHandler) { + if (actionHandler != null) { + if (actionHandlers == null) { + actionHandlers = new LinkedList(); + actionMapper = new KeyMapper(); + } + if (!actionHandlers.contains(actionHandler)) { + actionHandlers.add(actionHandler); + markAsDirty(); + } + } + } + + /** + * Is the calendar in a mode where all days of the month is shown + * + * @return Returns true if calendar is in monthly mode and false if it is in + * weekly mode + */ + public boolean isMonthlyMode() { + CalendarState state = (CalendarState) getState(false); + if (state.days != null) { + return state.days.size() > 7; + } else { + // Default mode + return true; + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.event.Action.Container#removeActionHandler(com.vaadin.event + * .Action.Handler) + */ + public void removeActionHandler(Handler actionHandler) { + if (actionHandlers != null && actionHandlers.contains(actionHandler)) { + actionHandlers.remove(actionHandler); + if (actionHandlers.isEmpty()) { + actionHandlers = null; + actionMapper = null; + } + markAsDirty(); + } + } + + private class CalendarServerRpcImpl implements CalendarServerRpc { + + @Override + public void eventMove(int eventIndex, String newDate) { + if (!isClientChangeAllowed()) { + return; + } + if (newDate != null) { + try { + Date d = df_date_time.parse(newDate); + if (eventIndex >= 0 && eventIndex < events.size() + && events.get(eventIndex) != null) { + fireEventMove(eventIndex, d); + } + } catch (ParseException e) { + getLogger().log(Level.WARNING, e.getMessage()); + } + } + } + + @Override + public void rangeSelect(String range) { + if (!isClientChangeAllowed()) { + return; + } + + if (range != null && range.length() > 14 && range.contains("TO")) { + String[] dates = range.split("TO"); + try { + Date d1 = df_date.parse(dates[0]); + Date d2 = df_date.parse(dates[1]); + + fireRangeSelect(d1, d2, true); + + } catch (ParseException e) { + // NOP + } + } else if (range != null && range.length() > 12 + && range.contains(":")) { + String[] dates = range.split(":"); + if (dates.length == 3) { + try { + Date d = df_date.parse(dates[0]); + currentCalendar.setTime(d); + int startMinutes = Integer.parseInt(dates[1]); + int endMinutes = Integer.parseInt(dates[2]); + currentCalendar.add(java.util.Calendar.MINUTE, + startMinutes); + Date start = currentCalendar.getTime(); + currentCalendar.add(java.util.Calendar.MINUTE, + endMinutes - startMinutes); + Date end = currentCalendar.getTime(); + fireRangeSelect(start, end, false); + } catch (ParseException e) { + // NOP + } catch (NumberFormatException e) { + // NOP + } + } + } + } + + @Override + public void forward() { + fireEvent(new ForwardEvent(Calendar.this)); + } + + @Override + public void backward() { + fireEvent(new BackwardEvent(Calendar.this)); + } + + @Override + public void dateClick(String date) { + if (!isClientChangeAllowed()) { + return; + } + if (date != null && date.length() > 6) { + try { + Date d = df_date.parse(date); + fireDateClick(d); + } catch (ParseException e) { + } + } + } + + @Override + public void weekClick(String event) { + if (!isClientChangeAllowed()) { + return; + } + if (event.length() > 0 && event.contains("w")) { + String[] splitted = event.split("w"); + if (splitted.length == 2) { + try { + int yr = 1900 + Integer.parseInt(splitted[0]); + int week = Integer.parseInt(splitted[1]); + fireWeekClick(week, yr); + } catch (NumberFormatException e) { + // NOP + } + } + } + } + + @Override + public void eventClick(int eventIndex) { + if (!isEventClickAllowed()) { + return; + } + if (eventIndex >= 0 && eventIndex < events.size() + && events.get(eventIndex) != null) { + fireEventClick(eventIndex); + } + } + + @Override + public void eventResize(int eventIndex, String newStartDate, + String newEndDate) { + if (!isClientChangeAllowed()) { + return; + } + if (newStartDate != null && !"".equals(newStartDate) + && newEndDate != null && !"".equals(newEndDate)) { + try { + Date newStartTime = df_date_time.parse(newStartDate); + Date newEndTime = df_date_time.parse(newEndDate); + + fireEventResize(eventIndex, newStartTime, newEndTime); + } catch (ParseException e) { + // NOOP + } + } + } + + @Override + public void scroll(int scrollPosition) { + scrollTop = scrollPosition; + markAsDirty(); + } + + @Override + public void actionOnEmptyCell(String actionKey, String startDate, + String endDate) { + Action action = actionMapper.get(actionKey); + SimpleDateFormat formatter = new SimpleDateFormat( + DateConstants.ACTION_DATE_FORMAT_PATTERN); + formatter.setTimeZone(getTimeZone()); + try { + Date start = formatter.parse(startDate); + for (Action.Handler ah : actionHandlers) { + ah.handleAction(action, this, start); + } + + } catch (ParseException e) { + getLogger().log(Level.WARNING, + "Could not parse action date string"); + } + + } + + @Override + public void actionOnEvent(String actionKey, String startDate, + String endDate, int eventIndex) { + Action action = actionMapper.get(actionKey); + SimpleDateFormat formatter = new SimpleDateFormat( + DateConstants.ACTION_DATE_FORMAT_PATTERN); + formatter.setTimeZone(getTimeZone()); + for (Action.Handler ah : actionHandlers) { + ah.handleAction(action, this, events.get(eventIndex)); + } + } + } +} \ No newline at end of file diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java new file mode 100644 index 0000000000..1f012157b5 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvent.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar; + +import com.vaadin.ui.Calendar; +import com.vaadin.ui.Component; + +/** + * All Calendar events extends this class. + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +@SuppressWarnings("serial") +public class CalendarComponentEvent extends Component.Event { + + /** + * Set the source of the event + * + * @param source + * The source calendar + * + */ + public CalendarComponentEvent(Calendar source) { + super(source); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Component.Event#getComponent() + */ + @Override + public Calendar getComponent() { + return (Calendar) super.getComponent(); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java new file mode 100644 index 0000000000..1904d69898 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/CalendarComponentEvents.java @@ -0,0 +1,603 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.Date; +import java.util.EventListener; + +import com.vaadin.shared.ui.calendar.CalendarEventId; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.util.ReflectTools; + +/** + * Interface for all Vaadin Calendar events. + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +public interface CalendarComponentEvents extends Serializable { + + /** + * Notifier interface for notifying listener of calendar events + */ + public interface CalendarEventNotifier extends Serializable { + /** + * Get the assigned event handler for the given eventId. + * + * @param eventId + * @return the assigned eventHandler, or null if no handler is assigned + */ + public EventListener getHandler(String eventId); + } + + /** + * Notifier interface for event drag & drops. + */ + public interface EventMoveNotifier extends CalendarEventNotifier { + + /** + * Set the EventMoveHandler. + * + * @param listener + * EventMoveHandler to be added + */ + public void setHandler(EventMoveHandler listener); + + } + + /** + * MoveEvent is sent when existing event is dragged to a new position. + */ + @SuppressWarnings("serial") + public class MoveEvent extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.EVENTMOVE; + + /** Index for the moved Schedule.Event. */ + private CalendarEvent calendarEvent; + + /** New starting date for the moved Calendar.Event. */ + private Date newStart; + + /** + * MoveEvent needs the target event and new start date. + * + * @param source + * Calendar component. + * @param calendarEvent + * Target event. + * @param newStart + * Target event's new start date. + */ + public MoveEvent(Calendar source, CalendarEvent calendarEvent, + Date newStart) { + super(source); + + this.calendarEvent = calendarEvent; + this.newStart = newStart; + } + + /** + * Get target event. + * + * @return Target event. + */ + public CalendarEvent getCalendarEvent() { + return calendarEvent; + } + + /** + * Get new start date. + * + * @return New start date. + */ + public Date getNewStart() { + return newStart; + } + } + + /** + * Handler interface for when events are being dragged on the calendar + * + */ + public interface EventMoveHandler extends EventListener, Serializable { + + /** Trigger method for the MoveEvent. */ + public static final Method eventMoveMethod = ReflectTools.findMethod( + EventMoveHandler.class, "eventMove", MoveEvent.class); + + /** + * This method will be called when event has been moved to a new + * position. + * + * @param event + * MoveEvent containing specific information of the new + * position and target event. + */ + public void eventMove(MoveEvent event); + } + + /** + * Handler interface for day or time cell drag-marking with mouse. + */ + public interface RangeSelectNotifier extends Serializable, + CalendarEventNotifier { + + /** + * Set the RangeSelectHandler that listens for drag-marking. + * + * @param listener + * RangeSelectHandler to be added. + */ + public void setHandler(RangeSelectHandler listener); + } + + /** + * RangeSelectEvent is sent when day or time cells are drag-marked with + * mouse. + */ + @SuppressWarnings("serial") + public class RangeSelectEvent extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.RANGESELECT; + + /** Calendar event's start date. */ + private Date start; + + /** Calendar event's end date. */ + private Date end; + + /** + * Defines the event's view mode. + */ + private boolean monthlyMode; + + /** + * RangeSelectEvent needs a start and end date. + * + * @param source + * Calendar component. + * @param start + * Start date. + * @param end + * End date. + * @param monthlyMode + * Calendar view mode. + */ + public RangeSelectEvent(Calendar source, Date start, Date end, + boolean monthlyMode) { + super(source); + this.start = start; + this.end = end; + this.monthlyMode = monthlyMode; + } + + /** + * Get start date. + * + * @return Start date. + */ + public Date getStart() { + return start; + } + + /** + * Get end date. + * + * @return End date. + */ + public Date getEnd() { + return end; + } + + /** + * Gets the event's view mode. Calendar can be be either in monthly or + * weekly mode, depending on the active date range. + * + * @deprecated User {@link Calendar#isMonthlyMode()} instead + * + * @return Returns true when monthly view is active. + */ + @Deprecated + public boolean isMonthlyMode() { + return monthlyMode; + } + } + + /** RangeSelectHandler handles RangeSelectEvent. */ + public interface RangeSelectHandler extends EventListener, Serializable { + + /** Trigger method for the RangeSelectEvent. */ + public static final Method rangeSelectMethod = ReflectTools + .findMethod(RangeSelectHandler.class, "rangeSelect", + RangeSelectEvent.class); + + /** + * This method will be called when day or time cells are drag-marked + * with mouse. + * + * @param event + * RangeSelectEvent that contains range start and end date. + */ + public void rangeSelect(RangeSelectEvent event); + } + + /** Notifier interface for navigation listening. */ + public interface NavigationNotifier extends Serializable { + /** + * Add a forward navigation listener. + * + * @param handler + * ForwardHandler to be added. + */ + public void setHandler(ForwardHandler handler); + + /** + * Add a backward navigation listener. + * + * @param handler + * BackwardHandler to be added. + */ + public void setHandler(BackwardHandler handler); + + /** + * Add a date click listener. + * + * @param handler + * DateClickHandler to be added. + */ + public void setHandler(DateClickHandler handler); + + /** + * Add a event click listener. + * + * @param handler + * EventClickHandler to be added. + */ + public void setHandler(EventClickHandler handler); + + /** + * Add a week click listener. + * + * @param handler + * WeekClickHandler to be added. + */ + public void setHandler(WeekClickHandler handler); + } + + /** + * ForwardEvent is sent when forward navigation button is clicked. + */ + @SuppressWarnings("serial") + public class ForwardEvent extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.FORWARD; + + /** + * ForwardEvent needs only the source component. + * + * @param source + * Calendar component. + */ + public ForwardEvent(Calendar source) { + super(source); + } + } + + /** ForwardHandler handles ForwardEvent. */ + public interface ForwardHandler extends EventListener, Serializable { + + /** Trigger method for the ForwardEvent. */ + public static final Method forwardMethod = ReflectTools.findMethod( + ForwardHandler.class, "forward", ForwardEvent.class); + + /** + * This method will be called when date range is moved forward. + * + * @param event + * ForwardEvent + */ + public void forward(ForwardEvent event); + } + + /** + * BackwardEvent is sent when backward navigation button is clicked. + */ + @SuppressWarnings("serial") + public class BackwardEvent extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.BACKWARD; + + /** + * BackwardEvent needs only the source source component. + * + * @param source + * Calendar component. + */ + public BackwardEvent(Calendar source) { + super(source); + } + } + + /** BackwardHandler handles BackwardEvent. */ + public interface BackwardHandler extends EventListener, Serializable { + + /** Trigger method for the BackwardEvent. */ + public static final Method backwardMethod = ReflectTools.findMethod( + BackwardHandler.class, "backward", BackwardEvent.class); + + /** + * This method will be called when date range is moved backwards. + * + * @param event + * BackwardEvent + */ + public void backward(BackwardEvent event); + } + + /** + * DateClickEvent is sent when a date is clicked. + */ + @SuppressWarnings("serial") + public class DateClickEvent extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.DATECLICK; + + /** Date that was clicked. */ + private Date date; + + /** DateClickEvent needs the target date that was clicked. */ + public DateClickEvent(Calendar source, Date date) { + super(source); + this.date = date; + } + + /** + * Get clicked date. + * + * @return Clicked date. + */ + public Date getDate() { + return date; + } + } + + /** DateClickHandler handles DateClickEvent. */ + public interface DateClickHandler extends EventListener, Serializable { + + /** Trigger method for the DateClickEvent. */ + public static final Method dateClickMethod = ReflectTools.findMethod( + DateClickHandler.class, "dateClick", DateClickEvent.class); + + /** + * This method will be called when a date is clicked. + * + * @param event + * DateClickEvent containing the target date. + */ + public void dateClick(DateClickEvent event); + } + + /** + * EventClick is sent when an event is clicked. + */ + @SuppressWarnings("serial") + public class EventClick extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.EVENTCLICK; + + /** Clicked source event. */ + private CalendarEvent calendarEvent; + + /** Target source event is needed for the EventClick. */ + public EventClick(Calendar source, CalendarEvent calendarEvent) { + super(source); + this.calendarEvent = calendarEvent; + } + + /** + * Get the clicked event. + * + * @return Clicked event. + */ + public CalendarEvent getCalendarEvent() { + return calendarEvent; + } + } + + /** EventClickHandler handles EventClick. */ + public interface EventClickHandler extends EventListener, Serializable { + + /** Trigger method for the EventClick. */ + public static final Method eventClickMethod = ReflectTools.findMethod( + EventClickHandler.class, "eventClick", EventClick.class); + + /** + * This method will be called when an event is clicked. + * + * @param event + * EventClick containing the target event. + */ + public void eventClick(EventClick event); + } + + /** + * WeekClick is sent when week is clicked. + */ + @SuppressWarnings("serial") + public class WeekClick extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.WEEKCLICK; + + /** Target week. */ + private int week; + + /** Target year. */ + private int year; + + /** + * WeekClick needs a target year and week. + * + * @param source + * Target source. + * @param week + * Target week. + * @param year + * Target year. + */ + public WeekClick(Calendar source, int week, int year) { + super(source); + this.week = week; + this.year = year; + } + + /** + * Get week as a integer. See {@link java.util.Calendar} for the allowed + * values. + * + * @return Week as a integer. + */ + public int getWeek() { + return week; + } + + /** + * Get year as a integer. See {@link java.util.Calendar} for the allowed + * values. + * + * @return Year as a integer + */ + public int getYear() { + return year; + } + } + + /** WeekClickHandler handles WeekClicks. */ + public interface WeekClickHandler extends EventListener, Serializable { + + /** Trigger method for the WeekClick. */ + public static final Method weekClickMethod = ReflectTools.findMethod( + WeekClickHandler.class, "weekClick", WeekClick.class); + + /** + * This method will be called when a week is clicked. + * + * @param event + * WeekClick containing the target week and year. + */ + public void weekClick(WeekClick event); + } + + /** + * EventResize is sent when an event is resized + */ + @SuppressWarnings("serial") + public class EventResize extends CalendarComponentEvent { + + public static final String EVENT_ID = CalendarEventId.EVENTRESIZE; + + private CalendarEvent calendarEvent; + + private Date startTime; + + private Date endTime; + + public EventResize(Calendar source, CalendarEvent calendarEvent, + Date startTime, Date endTime) { + super(source); + this.calendarEvent = calendarEvent; + this.startTime = startTime; + this.endTime = endTime; + } + + /** + * Get target event. + * + * @return Target event. + */ + public CalendarEvent getCalendarEvent() { + return calendarEvent; + } + + /** + * @deprecated Use {@link #getNewStart()} instead + * + * @return the new start time + */ + @Deprecated + public Date getNewStartTime() { + return startTime; + } + + /** + * Returns the updated start date/time of the event + * + * @return The new date for the event + */ + public Date getNewStart() { + return startTime; + } + + /** + * @deprecated Use {@link #getNewEnd()} instead + * + * @return the new end time + */ + @Deprecated + public Date getNewEndTime() { + return endTime; + } + + /** + * Returns the updates end date/time of the event + * + * @return The new date for the event + */ + public Date getNewEnd() { + return endTime; + } + } + + /** + * Notifier interface for event resizing. + */ + public interface EventResizeNotifier extends Serializable { + + /** + * Set a EventResizeHandler. + * + * @param handler + * EventResizeHandler to be set + */ + public void setHandler(EventResizeHandler handler); + } + + /** + * Handler for EventResize event. + */ + public interface EventResizeHandler extends EventListener, Serializable { + + /** Trigger method for the EventResize. */ + public static final Method eventResizeMethod = ReflectTools.findMethod( + EventResizeHandler.class, "eventResize", EventResize.class); + + void eventResize(EventResize event); + } + +} diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java new file mode 100644 index 0000000000..01b766a6db --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/CalendarDateRange.java @@ -0,0 +1,86 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar; + +import java.io.Serializable; +import java.util.Date; +import java.util.TimeZone; + +/** + * Class for representing a date range. + * + * @since 7.1.0 + * @author Vaadin Ltd. + * + */ +@SuppressWarnings("serial") +public class CalendarDateRange implements Serializable { + + private Date start; + + private Date end; + + private final transient TimeZone tz; + + /** + * Constructor + * + * @param start + * The start date and time of the date range + * @param end + * The end date and time of the date range + */ + public CalendarDateRange(Date start, Date end, TimeZone tz) { + super(); + this.start = start; + this.end = end; + this.tz = tz; + } + + /** + * Get the start date of the date range + * + * @return the start Date of the range + */ + public Date getStart() { + return start; + } + + /** + * Get the end date of the date range + * + * @return the end Date of the range + */ + public Date getEnd() { + return end; + } + + /** + * Is a date in the date range + * + * @param date + * The date to check + * @return true if the date range contains a date start and end of range + * inclusive; false otherwise + */ + public boolean inRange(Date date) { + if (date == null) { + return false; + } + + return date.compareTo(start) >= 0 && date.compareTo(end) <= 0; + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java b/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java new file mode 100644 index 0000000000..1a3ef67377 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/CalendarTargetDetails.java @@ -0,0 +1,80 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar; + +import java.util.Date; +import java.util.Map; + +import com.vaadin.event.dd.DropTarget; +import com.vaadin.event.dd.TargetDetailsImpl; +import com.vaadin.ui.Calendar; + +/** + * Drop details for {@link com.vaadin.ui.addon.calendar.ui.Calendar Calendar}. + * When something is dropped on the Calendar, this class contains the specific + * details of the drop point. Specifically, this class gives access to the date + * where the drop happened. If the Calendar was in weekly mode, the date also + * includes the start time of the slot. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class CalendarTargetDetails extends TargetDetailsImpl { + + private boolean hasDropTime; + + public CalendarTargetDetails(Map rawDropData, + DropTarget dropTarget) { + super(rawDropData, dropTarget); + } + + /** + * @return true if {@link #getDropTime()} will return a date object with the + * time set to the start of the time slot where the drop happened + */ + public boolean hasDropTime() { + return hasDropTime; + } + + /** + * Does the dropped item have a time associated with it + * + * @param hasDropTime + */ + public void setHasDropTime(boolean hasDropTime) { + this.hasDropTime = hasDropTime; + } + + /** + * @return the date where the drop happened + */ + public Date getDropTime() { + if (hasDropTime) { + return (Date) getData("dropTime"); + } else { + return (Date) getData("dropDay"); + } + } + + /** + * @return the {@link com.vaadin.ui.addon.calendar.ui.Calendar Calendar} + * instance which was the target of the drop + */ + public Calendar getTargetCalendar() { + return (Calendar) getTarget(); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java new file mode 100644 index 0000000000..b01140eb88 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java @@ -0,0 +1,566 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar; + +import java.util.Collections; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +import com.vaadin.data.Container; +import com.vaadin.data.Container.Indexed; +import com.vaadin.data.Container.ItemSetChangeEvent; +import com.vaadin.data.Container.ItemSetChangeNotifier; +import com.vaadin.data.Item; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeNotifier; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventMoveHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResize; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResizeHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.MoveEvent; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.CalendarEditableEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeListener; +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeNotifier; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeNotifier; + +/** + * A event provider which uses a {@link Container} as a datasource. Container + * used as data source. + * + * NOTE: The data source must be sorted by date! + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class ContainerEventProvider implements CalendarEditableEventProvider, + EventSetChangeNotifier, EventChangeNotifier, EventMoveHandler, + EventResizeHandler, Container.ItemSetChangeListener, + Property.ValueChangeListener { + + // Default property ids + public static final String CAPTION_PROPERTY = "caption"; + public static final String DESCRIPTION_PROPERTY = "description"; + public static final String STARTDATE_PROPERTY = "start"; + public static final String ENDDATE_PROPERTY = "end"; + public static final String STYLENAME_PROPERTY = "styleName"; + + /** + * Internal class to keep the container index which item this event + * represents + * + */ + private class ContainerCalendarEvent extends BasicEvent { + private final int index; + + public ContainerCalendarEvent(int containerIndex) { + super(); + index = containerIndex; + } + + public int getContainerIndex() { + return index; + } + } + + /** + * Listeners attached to the container + */ + private final List eventSetChangeListeners = new LinkedList(); + private final List eventChangeListeners = new LinkedList(); + + /** + * The event cache contains the events previously created by + * {@link #getEvents(Date, Date)} + */ + private final List eventCache = new LinkedList(); + + /** + * The container used as datasource + */ + private Indexed container; + + /** + * Container properties. Defaults based on using the {@link BasicEvent} + * helper class. + */ + private Object captionProperty = CAPTION_PROPERTY; + private Object descriptionProperty = DESCRIPTION_PROPERTY; + private Object startDateProperty = STARTDATE_PROPERTY; + private Object endDateProperty = ENDDATE_PROPERTY; + private Object styleNameProperty = STYLENAME_PROPERTY; + + /** + * Constructor + * + * @param container + * Container to use as a data source. + */ + public ContainerEventProvider(Container.Indexed container) { + this.container = container; + listenToContainerEvents(); + } + + /** + * Set the container data source + * + * @param container + * The container to use as datasource + * + */ + public void setContainerDataSource(Container.Indexed container) { + // Detach the previous container + detachContainerDataSource(); + + this.container = container; + listenToContainerEvents(); + } + + /** + * Returns the container used as data source + * + */ + public Container.Indexed getContainerDataSource() { + return container; + } + + /** + * Attaches listeners to the container so container events can be processed + */ + private void listenToContainerEvents() { + if (container instanceof ItemSetChangeNotifier) { + ((ItemSetChangeNotifier) container).addItemSetChangeListener(this); + } + if (container instanceof ValueChangeNotifier) { + ((ValueChangeNotifier) container).addValueChangeListener(this); + } + } + + /** + * Removes listeners from the container so no events are processed + */ + private void ignoreContainerEvents() { + if (container instanceof ItemSetChangeNotifier) { + ((ItemSetChangeNotifier) container) + .removeItemSetChangeListener(this); + } + if (container instanceof ValueChangeNotifier) { + ((ValueChangeNotifier) container).removeValueChangeListener(this); + } + } + + /** + * Converts an event in the container to an {@link CalendarEvent} + * + * @param index + * The index of the item in the container to get the event for + * @return + */ + private CalendarEvent getEvent(int index) { + + // Check the event cache first + for (CalendarEvent e : eventCache) { + if (e instanceof ContainerCalendarEvent + && ((ContainerCalendarEvent) e).getContainerIndex() == index) { + return e; + } else if (container.getIdByIndex(index) == e) { + return e; + } + } + + final Object id = container.getIdByIndex(index); + Item item = container.getItem(id); + CalendarEvent event; + if (id instanceof CalendarEvent) { + /* + * If we are using the BeanItemContainer or another container which + * stores the objects as ids then just return the instances + */ + event = (CalendarEvent) id; + + } else { + /* + * Else we use the properties to create the event + */ + BasicEvent basicEvent = new ContainerCalendarEvent(index); + + // Set values from property values + if (captionProperty != null + && item.getItemPropertyIds().contains(captionProperty)) { + basicEvent.setCaption(String.valueOf(item.getItemProperty( + captionProperty).getValue())); + } + if (descriptionProperty != null + && item.getItemPropertyIds().contains(descriptionProperty)) { + basicEvent.setDescription(String.valueOf(item.getItemProperty( + descriptionProperty).getValue())); + } + if (startDateProperty != null + && item.getItemPropertyIds().contains(startDateProperty)) { + basicEvent.setStart((Date) item.getItemProperty( + startDateProperty).getValue()); + } + if (endDateProperty != null + && item.getItemPropertyIds().contains(endDateProperty)) { + basicEvent.setEnd((Date) item.getItemProperty(endDateProperty) + .getValue()); + } + if (styleNameProperty != null + && item.getItemPropertyIds().contains(styleNameProperty)) { + basicEvent.setDescription(String.valueOf(item.getItemProperty( + descriptionProperty).getValue())); + } + event = basicEvent; + } + return event; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. + * util.Date, java.util.Date) + */ + public List getEvents(Date startDate, Date endDate) { + eventCache.clear(); + + int[] rangeIndexes = getFirstAndLastEventIndex(startDate, endDate); + for (int i = rangeIndexes[0]; i <= rangeIndexes[1] + && i < container.size(); i++) { + eventCache.add(getEvent(i)); + } + return Collections.unmodifiableList(eventCache); + } + + /** + * Get the first event for a date + * + * @param date + * The date to search for, NUll returns first event in container + * @return Returns an array where the first item is the start index and the + * second item is the end item + */ + private int[] getFirstAndLastEventIndex(Date start, Date end) { + int startIndex = 0; + int size = container.size(); + int endIndex = size - 1; + + if (start != null) { + /* + * Iterating from the start of the container, if range is in the end + * of the container then this will be slow TODO This could be + * improved by using some sort of divide and conquer algorithm + */ + while (startIndex < size) { + Object id = container.getIdByIndex(startIndex); + Item item = container.getItem(id); + Date d = (Date) item.getItemProperty(startDateProperty) + .getValue(); + if (d.compareTo(start) >= 0) { + break; + } + startIndex++; + } + } + + if (end != null) { + /* + * Iterate from the start index until range ends + */ + endIndex = startIndex; + while (endIndex < size - 1) { + Object id = container.getIdByIndex(endIndex); + Item item = container.getItem(id); + Date d = (Date) item.getItemProperty(endDateProperty) + .getValue(); + if (d == null) { + // No end date present, use start date + d = (Date) item.getItemProperty(startDateProperty) + .getValue(); + } + if (d.compareTo(end) >= 0) { + endIndex--; + break; + } + endIndex++; + } + } + + return new int[] { startIndex, endIndex }; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventProvider.EventSetChangeNotifier + * #addListener(com.vaadin.addon.calendar.event.CalendarEventProvider. + * EventSetChangeListener) + */ + public void addEventSetChangeListener(EventSetChangeListener listener) { + if (!eventSetChangeListeners.contains(listener)) { + eventSetChangeListeners.add(listener); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventProvider.EventSetChangeNotifier + * #removeListener(com.vaadin.addon.calendar.event.CalendarEventProvider. + * EventSetChangeListener) + */ + public void removeEventSetChangeListener(EventSetChangeListener listener) { + eventSetChangeListeners.remove(listener); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier#addListener + * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) + */ + public void addEventChangeListener(EventChangeListener listener) { + if (eventChangeListeners.contains(listener)) { + eventChangeListeners.add(listener); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier# + * removeListener + * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) + */ + public void removeEventChangeListener(EventChangeListener listener) { + eventChangeListeners.remove(listener); + } + + /** + * Get the property which provides the caption of the event + */ + public Object getCaptionProperty() { + return captionProperty; + } + + /** + * Set the property which provides the caption of the event + */ + public void setCaptionProperty(Object captionProperty) { + this.captionProperty = captionProperty; + } + + /** + * Get the property which provides the description of the event + */ + public Object getDescriptionProperty() { + return descriptionProperty; + } + + /** + * Set the property which provides the description of the event + */ + public void setDescriptionProperty(Object descriptionProperty) { + this.descriptionProperty = descriptionProperty; + } + + /** + * Get the property which provides the starting date and time of the event + */ + public Object getStartDateProperty() { + return startDateProperty; + } + + /** + * Set the property which provides the starting date and time of the event + */ + public void setStartDateProperty(Object startDateProperty) { + this.startDateProperty = startDateProperty; + } + + /** + * Get the property which provides the ending date and time of the event + */ + public Object getEndDateProperty() { + return endDateProperty; + } + + /** + * Set the property which provides the ending date and time of the event + */ + public void setEndDateProperty(Object endDateProperty) { + this.endDateProperty = endDateProperty; + } + + /** + * Get the property which provides the style name for the event + */ + public Object getStyleNameProperty() { + return styleNameProperty; + } + + /** + * Set the property which provides the style name for the event + */ + public void setStyleNameProperty(Object styleNameProperty) { + this.styleNameProperty = styleNameProperty; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange + * (com.vaadin.data.Container.ItemSetChangeEvent) + */ + public void containerItemSetChange(ItemSetChangeEvent event) { + if (event.getContainer() == container) { + // Trigger an eventset change event when the itemset changes + for (EventSetChangeListener listener : eventSetChangeListeners) { + listener.eventSetChange(new EventSetChangeEvent(this)); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data + * .Property.ValueChangeEvent) + */ + public void valueChange(ValueChangeEvent event) { + /* + * TODO Need to figure out how to get the item which triggered the the + * valuechange event and then trigger a EventChange event to the + * listeners + */ + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler + * #eventMove + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) + */ + public void eventMove(MoveEvent event) { + CalendarEvent ce = event.getCalendarEvent(); + if (eventCache.contains(ce)) { + int index; + if (ce instanceof ContainerCalendarEvent) { + index = ((ContainerCalendarEvent) ce).getContainerIndex(); + } else { + index = container.indexOfId(ce); + } + + long eventLength = ce.getEnd().getTime() - ce.getStart().getTime(); + Date newEnd = new Date(event.getNewStart().getTime() + eventLength); + + ignoreContainerEvents(); + Item item = container.getItem(container.getIdByIndex(index)); + item.getItemProperty(startDateProperty).setValue( + event.getNewStart()); + item.getItemProperty(endDateProperty).setValue(newEnd); + listenToContainerEvents(); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler + * #eventResize + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) + */ + public void eventResize(EventResize event) { + CalendarEvent ce = event.getCalendarEvent(); + if (eventCache.contains(ce)) { + int index; + if (ce instanceof ContainerCalendarEvent) { + index = ((ContainerCalendarEvent) ce).getContainerIndex(); + } else { + index = container.indexOfId(ce); + } + ignoreContainerEvents(); + Item item = container.getItem(container.getIdByIndex(index)); + item.getItemProperty(startDateProperty).setValue( + event.getNewStart()); + item.getItemProperty(endDateProperty).setValue(event.getNewEnd()); + listenToContainerEvents(); + } + } + + /** + * If you are reusing the container which previously have been attached to + * this ContainerEventProvider call this method to remove this event + * providers container listeners before attaching it to an other + * ContainerEventProvider + */ + public void detachContainerDataSource() { + ignoreContainerEvents(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void addEvent(CalendarEvent event) { + Item item; + try { + item = container.addItem(event); + } catch (UnsupportedOperationException uop) { + // Thrown if container does not support adding items with custom + // ids. JPAContainer for example. + item = container.getItem(container.addItem()); + } + if (item != null) { + item.getItemProperty(getCaptionProperty()).setValue( + event.getCaption()); + item.getItemProperty(getStartDateProperty()).setValue( + event.getStart()); + item.getItemProperty(getEndDateProperty()).setValue(event.getEnd()); + item.getItemProperty(getStyleNameProperty()).setValue( + event.getStyleName()); + item.getItemProperty(getDescriptionProperty()).setValue( + event.getDescription()); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void removeEvent(CalendarEvent event) { + container.removeItem(event); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java new file mode 100644 index 0000000000..ab342dfabf --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java @@ -0,0 +1,251 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeNotifier; + +/** + * Simple implementation of + * {@link com.vaadin.addon.calendar.event.CalendarEvent CalendarEvent}. Has + * setters for all required fields and fires events when this event is changed. + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { + + private String caption; + private String description; + private Date end; + private Date start; + private String styleName; + private transient List listeners = new ArrayList(); + + private boolean isAllDay; + + /** + * Default constructor + */ + public BasicEvent() { + + } + + /** + * Constructor for creating an event with the same start and end date + * + * @param caption + * The caption for the event + * @param description + * The description for the event + * @param date + * The date the event occurred + */ + public BasicEvent(String caption, String description, Date date) { + this.caption = caption; + this.description = description; + start = date; + end = date; + } + + /** + * Constructor for creating an event with a start date and an end date. + * Start date should be before the end date + * + * @param caption + * The caption for the event + * @param description + * The description for the event + * @param startDate + * The start date of the event + * @param endDate + * The end date of the event + */ + public BasicEvent(String caption, String description, Date startDate, + Date endDate) { + this.caption = caption; + this.description = description; + start = startDate; + end = endDate; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#getCaption() + */ + public String getCaption() { + return caption; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#getDescription() + */ + public String getDescription() { + return description; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#getEnd() + */ + public Date getEnd() { + return end; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStart() + */ + public Date getStart() { + return start; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#getStyleName() + */ + public String getStyleName() { + return styleName; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.addon.calendar.event.CalendarEvent#isAllDay() + */ + public boolean isAllDay() { + return isAllDay; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setCaption(java.lang + * .String) + */ + public void setCaption(String caption) { + this.caption = caption; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setDescription(java + * .lang.String) + */ + public void setDescription(String description) { + this.description = description; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setEnd(java.util. + * Date) + */ + public void setEnd(Date end) { + this.end = end; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setStart(java.util + * .Date) + */ + public void setStart(Date start) { + this.start = start; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setStyleName(java + * .lang.String) + */ + public void setStyleName(String styleName) { + this.styleName = styleName; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventEditor#setAllDay(boolean) + */ + public void setAllDay(boolean isAllDay) { + this.isAllDay = isAllDay; + fireEventChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener + * ) + */ + public void addEventChangeListener(EventChangeListener listener) { + listeners.add(listener); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeNotifier + * #removeListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener + * ) + */ + public void removeEventChangeListener(EventChangeListener listener) { + listeners.remove(listener); + } + + /** + * Fires an event change event to the listeners. Should be triggered when + * some property of the event changes. + */ + protected void fireEventChange() { + EventChangeEvent event = new EventChangeEvent(this); + + for (EventChangeListener listener : listeners) { + listener.eventChange(event); + } + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java new file mode 100644 index 0000000000..0314652245 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java @@ -0,0 +1,173 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.vaadin.ui.components.calendar.event.CalendarEvent.EventChangeEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider.EventSetChangeNotifier; + +/** + *

    + * Simple implementation of + * {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider}. Use {@link #addEvent(CalendarEvent)} and + * {@link #removeEvent(CalendarEvent)} to add / remove events. + *

    + * + *

    + * {@link com.vaadin.addon.calendar.event.CalendarEventProvider.EventSetChangeNotifier + * EventSetChangeNotifier} and + * {@link com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener + * EventChangeListener} are also implemented, so the Calendar is notified when + * an event is added, changed or removed. + *

    + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicEventProvider implements CalendarEditableEventProvider, + EventSetChangeNotifier, CalendarEvent.EventChangeListener { + + protected List eventList = new ArrayList(); + + private List listeners = new ArrayList(); + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. + * util.Date, java.util.Date) + */ + public List getEvents(Date startDate, Date endDate) { + ArrayList activeEvents = new ArrayList(); + + for (CalendarEvent ev : eventList) { + long from = startDate.getTime(); + long to = endDate.getTime(); + + if (ev.getStart() != null && ev.getEnd() != null) { + long f = ev.getStart().getTime(); + long t = ev.getEnd().getTime(); + // Select only events that overlaps with startDate and + // endDate. + if ((f <= to && f >= from) || (t >= from && t <= to) + || (f <= from && t >= to)) { + activeEvents.add(ev); + } + } + } + + return activeEvents; + } + + /** + * Does this event provider container this event + * + * @param event + * The event to check for + * @return If this provider has the event then true is returned, else false + */ + public boolean containsEvent(BasicEvent event) { + return eventList.contains(event); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeNotifier + * #addListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener + * ) + */ + public void addEventSetChangeListener(EventSetChangeListener listener) { + listeners.add(listener); + + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeNotifier + * #removeListener + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener + * ) + */ + public void removeEventSetChangeListener(EventSetChangeListener listener) { + listeners.remove(listener); + } + + /** + * Fires a eventsetchange event. The event is fired when either an event is + * added or removed to the event provider + */ + protected void fireEventSetChange() { + EventSetChangeEvent event = new EventSetChangeEvent(this); + + for (EventSetChangeListener listener : listeners) { + listener.eventSetChange(event); + } + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener + * #eventChange + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChange) + */ + public void eventChange(EventChangeEvent changeEvent) { + // naive implementation + fireEventSetChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void addEvent(CalendarEvent event) { + eventList.add(event); + if (event instanceof BasicEvent) { + ((BasicEvent) event).addEventChangeListener(this); + } + fireEventSetChange(); + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent + * (com.vaadin.addon.calendar.event.CalendarEvent) + */ + public void removeEvent(CalendarEvent event) { + eventList.remove(event); + if (event instanceof BasicEvent) { + ((BasicEvent) event).removeEventChangeListener(this); + } + fireEventSetChange(); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java new file mode 100644 index 0000000000..145d2b4aa4 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEditableEventProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +/** + * An event provider which allows adding and removing events + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +public interface CalendarEditableEventProvider extends CalendarEventProvider { + + /** + * Adds an event to the event provider + * + * @param event + * The event to add + */ + void addEvent(CalendarEvent event); + + /** + * Removes an event from the event provider + * + * @param event + * The event + */ + void removeEvent(CalendarEvent event); +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java new file mode 100644 index 0000000000..531ee72c7f --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEvent.java @@ -0,0 +1,146 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +import java.io.Serializable; +import java.util.Date; + +/** + *

    + * Event in the calendar. Customize your own event by implementing this + * interface. + *

    + * + *
  • Start and end fields are mandatory.
  • + * + *
  • In "allDay" events longer than one day, starting and ending clock times + * are omitted in UI and only dates are shown.
  • + * + * @since 7.1.0 + * @author Vaadin Ltd. + * + */ +public interface CalendarEvent extends Serializable { + + /** + * Gets start date of event. + * + * @return Start date. + */ + public Date getStart(); + + /** + * Get end date of event. + * + * @return End date; + */ + public Date getEnd(); + + /** + * Gets caption of event. + * + * @return Caption text + */ + public String getCaption(); + + /** + * Gets description of event. Shown as a tooltip over the event. + * + * @return Description text. + */ + public String getDescription(); + + /** + *

    + * Gets style name of event. In the client, style name will be set to the + * event's element class name and can be styled by CSS + *

    + * Styling example:
    Java code:
    + * event.setStyleName("color1"); + *

    + * CSS:
    + * .v-calendar-event-color1 {
    + *    background-color: #9effae;
    }
    + * + * @return Style name. + */ + public String getStyleName(); + + /** + * An all-day event typically does not occur at a specific time but targets + * a whole day or days. The rendering of all-day events differs from normal + * events. + * + * @return true if this event is an all-day event, false otherwise + */ + public boolean isAllDay(); + + /** + * Event to signal that an event has changed. + */ + @SuppressWarnings("serial") + public class EventChangeEvent implements Serializable { + + private CalendarEvent source; + + public EventChangeEvent(CalendarEvent source) { + this.source = source; + } + + /** + * @return the {@link com.vaadin.addon.calendar.event.CalendarEvent + * CalendarEvent} that has changed + */ + public CalendarEvent getCalendarEvent() { + return source; + } + } + + /** + * Listener for EventSetChange events. + */ + public interface EventChangeListener extends Serializable { + + /** + * Called when an Event has changed. + */ + public void eventChange(EventChangeEvent eventChangeEvent); + } + + /** + * Notifier interface for EventChange events. + */ + public interface EventChangeNotifier extends Serializable { + + /** + * Add a listener to listen for EventChangeEvents. These events are + * fired when a events properties are changed. + * + * @param listener + * The listener to add + */ + void addEventChangeListener(EventChangeListener listener); + + /** + * Remove a listener from the event provider. + * + * @param listener + * The listener to remove + */ + void removeEventChangeListener(EventChangeListener listener); + } + +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java new file mode 100644 index 0000000000..fefb2ca9b6 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/CalendarEventProvider.java @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * Interface for querying events. The Vaadin Calendar always has a + * CalendarEventProvider set. + * + * @since 7.1.0 + * @author Vaadin Ltd. + */ +public interface CalendarEventProvider extends Serializable { + /** + *

    + * Gets all available events in the target date range between startDate and + * endDate. The Vaadin Calendar queries the events from the range that is + * shown, which is not guaranteed to be the same as the date range that is + * set. + *

    + * + *

    + * For example, if you set the date range to be monday 22.2.2010 - wednesday + * 24.2.2000, the used Event Provider will be queried for events between + * monday 22.2.2010 00:00 and sunday 28.2.2010 23:59. Generally you can + * expect the date range to be expanded to whole days and whole weeks. + *

    + * + * @param startDate + * Start date + * @param endDate + * End date + * @return List of events + */ + public List getEvents(Date startDate, Date endDate); + + /** + * Event to signal that the set of events has changed and the calendar + * should refresh its view from the + * {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider} . + * + */ + @SuppressWarnings("serial") + public class EventSetChangeEvent implements Serializable { + + private CalendarEventProvider source; + + public EventSetChangeEvent(CalendarEventProvider source) { + this.source = source; + } + + /** + * @return the + * {@link com.vaadin.addon.calendar.event.CalendarEventProvider + * CalendarEventProvider} that has changed + */ + public CalendarEventProvider getProvider() { + return source; + } + } + + /** + * Listener for EventSetChange events. + */ + public interface EventSetChangeListener extends Serializable { + + /** + * Called when the set of Events has changed. + */ + public void eventSetChange(EventSetChangeEvent changeEvent); + } + + /** + * Notifier interface for EventSetChange events. + */ + public interface EventSetChangeNotifier extends Serializable { + + /** + * Add a listener for listening to when new events are adding or removed + * from the event provider. + * + * @param listener + * The listener to add + */ + void addEventSetChangeListener(EventSetChangeListener listener); + + /** + * Remove a listener which listens to {@link EventSetChangeEvent}-events + * + * @param listener + * The listener to remove + */ + void removeEventSetChangeListener(EventSetChangeListener listener); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java b/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java new file mode 100644 index 0000000000..e8a27ad50f --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/event/EditableCalendarEvent.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.event; + +import java.util.Date; + +/** + *

    + * Extension to the basic {@link com.vaadin.addon.calendar.event.CalendarEvent + * CalendarEvent}. This interface provides setters (and thus editing + * capabilities) for all {@link com.vaadin.addon.calendar.event.CalendarEvent + * CalendarEvent} fields. For descriptions on the fields, refer to the extended + * interface. + *

    + * + *

    + * This interface is used by some of the basic Calendar event handlers in the + * com.vaadin.addon.calendar.ui.handler package to determine + * whether an event can be edited. + *

    + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public interface EditableCalendarEvent extends CalendarEvent { + + /** + * Set the visible text in the calendar for the event. + * + * @param caption + * The text to show in the calendar + */ + void setCaption(String caption); + + /** + * Set the description of the event. This is shown in the calendar when + * hoovering over the event. + * + * @param description + * The text which describes the event + */ + void setDescription(String description); + + /** + * Set the end date of the event. Must be after the start date. + * + * @param end + * The end date to set + */ + void setEnd(Date end); + + /** + * Set the start date for the event. Must be before the end date + * + * @param start + * The start date of the event + */ + void setStart(Date start); + + /** + * Set the style name for the event used for styling the event cells + * + * @param styleName + * The stylename to use + * + */ + void setStyleName(String styleName); + + /** + * Does the event span the whole day. If so then set this to true + * + * @param isAllDay + * True if the event spans the whole day. In this case the start + * and end times are ignored. + */ + void setAllDay(boolean isAllDay); + +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java new file mode 100644 index 0000000000..fc2bfd6df4 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java @@ -0,0 +1,78 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Calendar; +import java.util.Date; + +import com.vaadin.shared.ui.calendar.DateConstants; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardHandler; + +/** + * Implements basic functionality needed to enable backwards navigation. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicBackwardHandler implements BackwardHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardHandler# + * backward + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardEvent) + */ + public void backward(BackwardEvent event) { + Date start = event.getComponent().getStartDate(); + Date end = event.getComponent().getEndDate(); + + // calculate amount to move back + int durationInDays = (int) (((end.getTime()) - start.getTime()) / DateConstants.DAYINMILLIS); + durationInDays++; + durationInDays = -durationInDays; + + // set new start and end times + Calendar javaCalendar = event.getComponent().getInternalCalendar(); + javaCalendar.setTime(start); + javaCalendar.add(java.util.Calendar.DATE, durationInDays); + Date newStart = javaCalendar.getTime(); + + javaCalendar.setTime(end); + javaCalendar.add(java.util.Calendar.DATE, durationInDays); + Date newEnd = javaCalendar.getTime(); + + setDates(event, newStart, newEnd); + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(BackwardEvent event, Date start, Date end) { + event.getComponent().setStartDate(start); + event.getComponent().setEndDate(end); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java new file mode 100644 index 0000000000..c91a238b86 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Calendar; +import java.util.Date; + +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickHandler; + +/** + * Implements basic functionality needed to switch to day view when a single day + * is clicked. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicDateClickHandler implements DateClickHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickHandler + * #dateClick + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickEvent) + */ + public void dateClick(DateClickEvent event) { + Date clickedDate = event.getDate(); + + Calendar javaCalendar = event.getComponent().getInternalCalendar(); + javaCalendar.setTime(clickedDate); + + // as times are expanded, this is all that is needed to show one day + Date start = javaCalendar.getTime(); + Date end = javaCalendar.getTime(); + + setDates(event, start, end); + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(DateClickEvent event, Date start, Date end) { + event.getComponent().setStartDate(start); + event.getComponent().setEndDate(end); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java new file mode 100644 index 0000000000..139837f339 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Date; + +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventMoveHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.MoveEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.EditableCalendarEvent; + +/** + * Implements basic functionality needed to enable moving events. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicEventMoveHandler implements EventMoveHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler + * #eventMove + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) + */ + public void eventMove(MoveEvent event) { + CalendarEvent calendarEvent = event.getCalendarEvent(); + + if (calendarEvent instanceof EditableCalendarEvent) { + + EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent; + + Date newFromTime = event.getNewStart(); + + // Update event dates + long length = editableEvent.getEnd().getTime() + - editableEvent.getStart().getTime(); + setDates(editableEvent, newFromTime, new Date(newFromTime.getTime() + + length)); + } + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(EditableCalendarEvent event, Date start, Date end) { + event.setStart(start); + event.setEnd(end); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java new file mode 100644 index 0000000000..c052d0d77b --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Date; + +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResize; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResizeHandler; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.EditableCalendarEvent; + +/** + * Implements basic functionality needed to enable event resizing. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicEventResizeHandler implements EventResizeHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler + * #eventResize + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) + */ + public void eventResize(EventResize event) { + CalendarEvent calendarEvent = event.getCalendarEvent(); + + if (calendarEvent instanceof EditableCalendarEvent) { + Date newStartTime = event.getNewStart(); + Date newEndTime = event.getNewEnd(); + + EditableCalendarEvent editableEvent = (EditableCalendarEvent) calendarEvent; + + setDates(editableEvent, newStartTime, newEndTime); + } + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(EditableCalendarEvent event, Date start, Date end) { + event.setStart(start); + event.setEnd(end); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java new file mode 100644 index 0000000000..a5307ffd5c --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Calendar; +import java.util.Date; + +import com.vaadin.shared.ui.calendar.DateConstants; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardHandler; + +/** + * Implements basic functionality needed to enable forward navigation. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicForwardHandler implements ForwardHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardHandler#forward + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardEvent) + */ + public void forward(ForwardEvent event) { + Date start = event.getComponent().getStartDate(); + Date end = event.getComponent().getEndDate(); + + // calculate amount to move forward + int durationInDays = (int) (((end.getTime()) - start.getTime()) / DateConstants.DAYINMILLIS); + durationInDays++; + + // set new start and end times + Calendar javaCalendar = Calendar.getInstance(); + javaCalendar.setTime(start); + javaCalendar.add(java.util.Calendar.DATE, durationInDays); + Date newStart = javaCalendar.getTime(); + + javaCalendar.setTime(end); + javaCalendar.add(java.util.Calendar.DATE, durationInDays); + Date newEnd = javaCalendar.getTime(); + + setDates(event, newStart, newEnd); + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(ForwardEvent event, Date start, Date end) { + event.getComponent().setStartDate(start); + event.getComponent().setEndDate(end); + } +} diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java new file mode 100644 index 0000000000..49efe49e48 --- /dev/null +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 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.ui.components.calendar.handler; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClick; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClickHandler; + +/** + * Implements basic functionality needed to change to week view when a week + * number is clicked. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +@SuppressWarnings("serial") +public class BasicWeekClickHandler implements WeekClickHandler { + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClickHandler + * #weekClick + * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClick) + */ + public void weekClick(WeekClick event) { + int week = event.getWeek(); + int year = event.getYear(); + + // set correct year and month + Calendar javaCalendar = event.getComponent().getInternalCalendar(); + javaCalendar.set(GregorianCalendar.YEAR, year); + javaCalendar.set(GregorianCalendar.WEEK_OF_YEAR, week); + + // starting at the beginning of the week + javaCalendar.set(GregorianCalendar.DAY_OF_WEEK, + javaCalendar.getFirstDayOfWeek()); + Date start = javaCalendar.getTime(); + + // ending at the end of the week + javaCalendar.add(GregorianCalendar.DATE, 6); + Date end = javaCalendar.getTime(); + + setDates(event, start, end); + + // times are automatically expanded, no need to worry about them + } + + /** + * Set the start and end dates for the event + * + * @param event + * The event that the start and end dates should be set + * @param start + * The start date + * @param end + * The end date + */ + protected void setDates(WeekClick event, Date start, Date end) { + event.getComponent().setStartDate(start); + event.getComponent().setEndDate(end); + } + +} diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java new file mode 100644 index 0000000000..5926cfa1ca --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/CalendarBasics.java @@ -0,0 +1,210 @@ +/* + * Copyright 2000-2013 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.server.component.calendar; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.junit.Test; + +import com.vaadin.ui.Calendar; +import com.vaadin.ui.Calendar.TimeFormat; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResize; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.MoveEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClick; +import com.vaadin.ui.components.calendar.event.BasicEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; + +/** + * Basic API tests for the calendar + */ +public class CalendarBasics { + + @Test + public void testEmptyConstructorInitialization() { + + Calendar calendar = new Calendar(); + + // The calendar should have a basic event provider with no events + CalendarEventProvider provider = calendar.getEventProvider(); + assertNotNull("Event provider should not be null", provider); + + // Basic event handlers should be registered + assertNotNull(calendar.getHandler(BackwardEvent.EVENT_ID)); + assertNotNull(calendar.getHandler(ForwardEvent.EVENT_ID)); + assertNotNull(calendar.getHandler(WeekClick.EVENT_ID)); + assertNotNull(calendar.getHandler(DateClickEvent.EVENT_ID)); + assertNotNull(calendar.getHandler(MoveEvent.EVENT_ID)); + assertNotNull(calendar.getHandler(EventResize.EVENT_ID)); + + // Calendar should have undefined size + assertTrue(calendar.getWidth() < 0); + assertTrue(calendar.getHeight() < 0); + } + + @Test + public void testConstructorWithCaption() { + final String caption = "My Calendar Caption"; + Calendar calendar = new Calendar(caption); + assertEquals(caption, calendar.getCaption()); + } + + @Test + public void testConstructorWithCustomEventProvider() { + BasicEventProvider myProvider = new BasicEventProvider(); + Calendar calendar = new Calendar(myProvider); + assertEquals(myProvider, calendar.getEventProvider()); + } + + @Test + public void testConstructorWithCustomEventProviderAndCaption() { + BasicEventProvider myProvider = new BasicEventProvider(); + final String caption = "My Calendar Caption"; + Calendar calendar = new Calendar(caption, myProvider); + assertEquals(caption, calendar.getCaption()); + assertEquals(myProvider, calendar.getEventProvider()); + } + + @Test + public void testDefaultStartAndEndDates() { + Calendar calendar = new Calendar(); + + // If no start and end date is set the calendar will display the current + // week + java.util.Calendar c = new GregorianCalendar(); + java.util.Calendar c2 = new GregorianCalendar(); + + c2.setTime(calendar.getStartDate()); + assertEquals(c.getFirstDayOfWeek(), + c2.get(java.util.Calendar.DAY_OF_WEEK)); + c2.setTime(calendar.getEndDate()); + + c.set(java.util.Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); + assertEquals(c.get(java.util.Calendar.DAY_OF_WEEK), + c2.get(java.util.Calendar.DAY_OF_WEEK)); + } + + @Test + public void testCustomStartAndEndDates() { + Calendar calendar = new Calendar(); + java.util.Calendar c = new GregorianCalendar(); + + Date start = c.getTime(); + c.add(java.util.Calendar.DATE, 3); + Date end = c.getTime(); + + calendar.setStartDate(start); + calendar.setEndDate(end); + + assertEquals(start.getTime(), calendar.getStartDate().getTime()); + assertEquals(end.getTime(), calendar.getEndDate().getTime()); + } + + @Test + public void testCustomLocale() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.CANADA_FRENCH); + + // Setting the locale should set the internal calendars locale + assertEquals(Locale.CANADA_FRENCH, calendar.getLocale()); + java.util.Calendar c = new GregorianCalendar(Locale.CANADA_FRENCH); + assertEquals(c.getTimeZone().getRawOffset(), calendar + .getInternalCalendar().getTimeZone().getRawOffset()); + } + + @Test + public void testTimeFormat() { + Calendar calendar = new Calendar(); + + // The default timeformat depends on the current locale + calendar.setLocale(Locale.ENGLISH); + assertEquals(TimeFormat.Format12H, calendar.getTimeFormat()); + + calendar.setLocale(Locale.ITALIAN); + assertEquals(TimeFormat.Format24H, calendar.getTimeFormat()); + + // Setting a specific time format overrides the locale + calendar.setTimeFormat(TimeFormat.Format12H); + assertEquals(TimeFormat.Format12H, calendar.getTimeFormat()); + } + + @Test + public void testTimeZone() { + Calendar calendar = new Calendar(); + calendar.setLocale(Locale.CANADA_FRENCH); + + // By default the calendars timezone is returned + assertEquals(calendar.getInternalCalendar().getTimeZone(), + calendar.getTimeZone()); + + // One can override the default behaviour by specifying a timezone + TimeZone customTimeZone = TimeZone.getTimeZone("Europe/Helsinki"); + calendar.setTimeZone(customTimeZone); + assertEquals(customTimeZone, calendar.getTimeZone()); + } + + @Test + public void testVisibleDaysOfWeek() { + Calendar calendar = new Calendar(); + + // The defaults are the whole week + assertEquals(1, calendar.getFirstVisibleDayOfWeek()); + assertEquals(7, calendar.getLastVisibleDayOfWeek()); + + calendar.setFirstVisibleDayOfWeek(0); // Invalid input + assertEquals(1, calendar.getFirstVisibleDayOfWeek()); + + calendar.setLastVisibleDayOfWeek(0); // Invalid input + assertEquals(7, calendar.getLastVisibleDayOfWeek()); + + calendar.setFirstVisibleDayOfWeek(8); // Invalid input + assertEquals(1, calendar.getFirstVisibleDayOfWeek()); + + calendar.setLastVisibleDayOfWeek(8); // Invalid input + assertEquals(7, calendar.getLastVisibleDayOfWeek()); + + calendar.setFirstVisibleDayOfWeek(4); + assertEquals(4, calendar.getFirstVisibleDayOfWeek()); + + calendar.setLastVisibleDayOfWeek(6); + assertEquals(6, calendar.getLastVisibleDayOfWeek()); + + calendar.setFirstVisibleDayOfWeek(7); // Invalid since last day is 6 + assertEquals(4, calendar.getFirstVisibleDayOfWeek()); + + calendar.setLastVisibleDayOfWeek(2); // Invalid since first day is 4 + assertEquals(6, calendar.getLastVisibleDayOfWeek()); + } + + @Test + public void testVisibleHoursInDay() { + Calendar calendar = new Calendar(); + + // Defaults are the whole day + assertEquals(0, calendar.getFirstVisibleHourOfDay()); + assertEquals(23, calendar.getLastVisibleHourOfDay()); + } + +} diff --git a/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java new file mode 100644 index 0000000000..2bc95e371c --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/calendar/ContainerDataSource.java @@ -0,0 +1,362 @@ +/* + * Copyright 2000-2013 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.server.component.calendar; + +import java.util.Date; +import java.util.List; + +import junit.framework.TestCase; + +import org.junit.Test; + +import com.vaadin.data.Container.Indexed; +import com.vaadin.data.Container.Sortable; +import com.vaadin.data.Item; +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.components.calendar.ContainerEventProvider; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent; + +public class ContainerDataSource extends TestCase { + + private Calendar calendar; + + @Override + public void setUp() { + calendar = new Calendar(); + } + + /** + * Tests adding a bean item container to the Calendar + */ + @Test + public void testWithBeanItemContainer() { + + // Create a container to use as a datasource + Indexed container = createTestBeanItemContainer(); + + // Set datasource + calendar.setContainerDataSource(container); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.setTime(((CalendarEvent) container.getIdByIndex(0)).getStart()); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Test the all events are returned + List events = calendar.getEventProvider().getEvents( + start, end); + assertEquals(container.size(), events.size()); + + // Test that a certain range is returned + cal.setTime(((CalendarEvent) container.getIdByIndex(6)).getStart()); + end = cal.getTime(); + events = calendar.getEventProvider().getEvents(start, end); + assertEquals(6, events.size()); + } + + /** + * This tests tests that if you give the Calendar an unsorted (== not sorted + * by starting date) container then the calendar should gracefully handle + * it. In this case the size of the container will be wrong. The test is + * exactly the same as {@link #testWithBeanItemContainer()} except that the + * beans has been intentionally sorted by caption instead of date. + */ + @Test + public void testWithUnsortedBeanItemContainer() { + // Create a container to use as a datasource + Indexed container = createTestBeanItemContainer(); + + // Make the container sorted by caption + ((Sortable) container).sort(new Object[] { "caption" }, + new boolean[] { true }); + + // Set data source + calendar.setContainerDataSource(container); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.setTime(((CalendarEvent) container.getIdByIndex(0)).getStart()); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Test the all events are returned + List events = calendar.getEventProvider().getEvents( + start, end); + assertEquals(container.size(), events.size()); + + // Test that a certain range is returned + cal.setTime(((CalendarEvent) container.getIdByIndex(6)).getStart()); + end = cal.getTime(); + events = calendar.getEventProvider().getEvents(start, end); + + // The events size is 1 since the getEvents returns the wrong range + assertEquals(1, events.size()); + } + + /** + * Tests adding a Indexed container to the Calendar + */ + @Test + public void testWithIndexedContainer() { + + // Create a container to use as a datasource + Indexed container = createTestIndexedContainer(); + + // Set datasource + calendar.setContainerDataSource(container, "testCaption", + "testDescription", "testStartDate", "testEndDate", null); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.setTime((Date) container.getItem(container.getIdByIndex(0)) + .getItemProperty("testStartDate").getValue()); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Test the all events are returned + List events = calendar.getEventProvider().getEvents( + start, end); + assertEquals(container.size(), events.size()); + + // Check that event values are present + CalendarEvent e = events.get(0); + assertEquals("Test 1", e.getCaption()); + assertEquals("Description 1", e.getDescription()); + assertTrue(e.getStart().compareTo(start) == 0); + + // Test that a certain range is returned + cal.setTime((Date) container.getItem(container.getIdByIndex(6)) + .getItemProperty("testStartDate").getValue()); + end = cal.getTime(); + events = calendar.getEventProvider().getEvents(start, end); + assertEquals(6, events.size()); + } + + @Test + public void testNullLimitsBeanItemContainer() { + // Create a container to use as a datasource + Indexed container = createTestBeanItemContainer(); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.setTime(((CalendarEvent) container.getIdByIndex(0)).getStart()); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Set datasource + calendar.setContainerDataSource(container); + + // Test null start time + List events = calendar.getEventProvider().getEvents( + null, end); + assertEquals(container.size(), events.size()); + + // Test null end time + events = calendar.getEventProvider().getEvents(start, null); + assertEquals(container.size(), events.size()); + + // Test both null times + events = calendar.getEventProvider().getEvents(null, null); + assertEquals(container.size(), events.size()); + } + + @Test + public void testNullLimitsIndexedContainer() { + // Create a container to use as a datasource + Indexed container = createTestIndexedContainer(); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.setTime((Date) container.getItem(container.getIdByIndex(0)) + .getItemProperty("testStartDate").getValue()); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Set datasource + calendar.setContainerDataSource(container, "testCaption", + "testDescription", "testStartDate", "testEndDate", null); + + // Test null start time + List events = calendar.getEventProvider().getEvents( + null, end); + assertEquals(container.size(), events.size()); + + // Test null end time + events = calendar.getEventProvider().getEvents(start, null); + assertEquals(container.size(), events.size()); + + // Test both null times + events = calendar.getEventProvider().getEvents(null, null); + assertEquals(container.size(), events.size()); + } + + /** + * Tests the addEvent convenience method with the default event provider + */ + @Test + public void testAddEventConvinienceMethod() { + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + + // Add an event + BasicEvent event = new BasicEvent("Test", "Test", start); + calendar.addEvent(event); + + // Ensure event exists + List events = calendar.getEvents(start, end); + assertEquals(1, events.size()); + assertEquals(events.get(0).getCaption(), event.getCaption()); + assertEquals(events.get(0).getDescription(), event.getDescription()); + assertEquals(events.get(0).getStart(), event.getStart()); + } + + /** + * Test the removeEvent convenience method with the default event provider + */ + @Test + public void testRemoveEventConvinienceMethod() { + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + + // Add an event + CalendarEvent event = new BasicEvent("Test", "Test", start); + calendar.addEvent(event); + + // Ensure event exists + assertEquals(1, calendar.getEvents(start, end).size()); + + // Remove event + calendar.removeEvent(event); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + } + + @Test + public void testAddEventConvinienceMethodWithCustomEventProvider() { + + // Use a container data source + calendar.setEventProvider(new ContainerEventProvider( + new BeanItemContainer(BasicEvent.class))); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + + // Add an event + BasicEvent event = new BasicEvent("Test", "Test", start); + calendar.addEvent(event); + + // Ensure event exists + List events = calendar.getEvents(start, end); + assertEquals(1, events.size()); + assertEquals(events.get(0).getCaption(), event.getCaption()); + assertEquals(events.get(0).getDescription(), event.getDescription()); + assertEquals(events.get(0).getStart(), event.getStart()); + } + + @Test + public void testRemoveEventConvinienceMethodWithCustomEventProvider() { + + // Use a container data source + calendar.setEventProvider(new ContainerEventProvider( + new BeanItemContainer(BasicEvent.class))); + + // Start and end dates to query for + java.util.Calendar cal = java.util.Calendar.getInstance(); + Date start = cal.getTime(); + cal.add(java.util.Calendar.MONTH, 1); + Date end = cal.getTime(); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + + // Add an event + BasicEvent event = new BasicEvent("Test", "Test", start); + calendar.addEvent(event); + + // Ensure event exists + List events = calendar.getEvents(start, end); + assertEquals(1, events.size()); + + // Remove event + calendar.removeEvent(event); + + // Ensure no events + assertEquals(0, calendar.getEvents(start, end).size()); + } + + private static Indexed createTestBeanItemContainer() { + BeanItemContainer eventContainer = new BeanItemContainer( + CalendarEvent.class); + java.util.Calendar cal = java.util.Calendar.getInstance(); + for (int i = 1; i <= 10; i++) { + eventContainer.addBean(new BasicEvent("Test " + i, "Description " + + i, cal.getTime())); + cal.add(java.util.Calendar.DAY_OF_MONTH, 2); + } + return eventContainer; + } + + private static Indexed createTestIndexedContainer() { + IndexedContainer container = new IndexedContainer(); + container.addContainerProperty("testCaption", String.class, ""); + container.addContainerProperty("testDescription", String.class, ""); + container.addContainerProperty("testStartDate", Date.class, null); + container.addContainerProperty("testEndDate", Date.class, null); + + java.util.Calendar cal = java.util.Calendar.getInstance(); + for (int i = 1; i <= 10; i++) { + Item item = container.getItem(container.addItem()); + item.getItemProperty("testCaption").setValue("Test " + i); + item.getItemProperty("testDescription") + .setValue("Description " + i); + item.getItemProperty("testStartDate").setValue(cal.getTime()); + item.getItemProperty("testEndDate").setValue(cal.getTime()); + cal.add(java.util.Calendar.DAY_OF_MONTH, 2); + } + return container; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/calendar/CalendarClientRpc.java b/shared/src/com/vaadin/shared/ui/calendar/CalendarClientRpc.java new file mode 100644 index 0000000000..c1ff8bdda5 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/calendar/CalendarClientRpc.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2013 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.shared.ui.calendar; + +import com.vaadin.shared.communication.ClientRpc; + +/** + * + * @since 7.1 + * @author Vaadin Ltd. + * + */ +public interface CalendarClientRpc extends ClientRpc { + void scroll(int scrollPosition); +} diff --git a/shared/src/com/vaadin/shared/ui/calendar/CalendarEventId.java b/shared/src/com/vaadin/shared/ui/calendar/CalendarEventId.java new file mode 100644 index 0000000000..6f52aabf43 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/calendar/CalendarEventId.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.shared.ui.calendar; + +/** + * CalendarEventId contains static String identifiers for all Calendar events. + * These are used both in the client and server side code. + * + * @since 7.1 + * @author Vaadin Ltd. + */ +public class CalendarEventId { + + public static final String EVENTMOVE = "eventMove"; + public static final String RANGESELECT = "rangeSelect"; + public static final String FORWARD = "forward"; + public static final String BACKWARD = "backward"; + public static final String DATECLICK = "dateClick"; + public static final String WEEKCLICK = "weekClick"; + public static final String EVENTCLICK = "eventClick"; + public static final String EVENTRESIZE = "eventResize"; + public static final String ACTION = "action"; +} diff --git a/shared/src/com/vaadin/shared/ui/calendar/CalendarServerRpc.java b/shared/src/com/vaadin/shared/ui/calendar/CalendarServerRpc.java new file mode 100644 index 0000000000..5257310cbf --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/calendar/CalendarServerRpc.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 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.shared.ui.calendar; + +import com.vaadin.shared.annotations.Delayed; +import com.vaadin.shared.communication.ServerRpc; + +/** + * @since 7.1 + * @author Vaadin Ltd. + */ +public interface CalendarServerRpc extends ServerRpc { + void eventMove(int eventIndex, String newDate); + + void rangeSelect(String range); + + void forward(); + + void backward(); + + void dateClick(String date); + + void weekClick(String event); + + void eventClick(int eventIndex); + + void eventResize(int eventIndex, String newStartDate, String newEndDate); + + void actionOnEmptyCell(String actionKey, String startDate, String endDate); + + void actionOnEvent(String actionKey, String startDate, String endDate, + int eventIndex); + + @Delayed(lastOnly = true) + void scroll(int scrollPosition); +} diff --git a/shared/src/com/vaadin/shared/ui/calendar/CalendarState.java b/shared/src/com/vaadin/shared/ui/calendar/CalendarState.java new file mode 100644 index 0000000000..fab5fd828e --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/calendar/CalendarState.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2013 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.shared.ui.calendar; + +import java.util.List; + +import com.vaadin.shared.AbstractComponentState; + +/** + * @since 7.1.0 + * @author Vaadin Ltd. + */ +public class CalendarState extends AbstractComponentState { + + public boolean format24H; + public String[] dayNames; + public String[] monthNames; + public int firstVisibleDayOfWeek = 1; + public int lastVisibleDayOfWeek = 7; + public int firstHourOfDay = 0; + public int lastHourOfDay = 23; + public int firstDayOfWeek; + public int scroll; + public String now; + public List days; + public List events; + public List actions; + + public static class Day implements java.io.Serializable { + public String date; + public String localizedDateFormat; + public int dayOfWeek; + public int week; + } + + public static class Action implements java.io.Serializable { + + public String caption; + public String iconKey; + public String actionKey; + public String startDate; + public String endDate; + } + + public static class Event implements java.io.Serializable { + public int index; + public String caption; + public String dateFrom; + public String dateTo; + public String timeFrom; + public String timeTo; + public String styleName; + public String description; + public boolean allDay; + } +} diff --git a/shared/src/com/vaadin/shared/ui/calendar/DateConstants.java b/shared/src/com/vaadin/shared/ui/calendar/DateConstants.java new file mode 100644 index 0000000000..8a840274c2 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/calendar/DateConstants.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 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.shared.ui.calendar; + +/** + * + * @since 7.1 + * + */ +public class DateConstants { + + public static final String ACTION_DATE_FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final String CLIENT_DATE_FORMAT = "yyyy-MM-dd"; + public static final String CLIENT_TIME_FORMAT = "HH-mm"; + public static final long MINUTEINMILLIS = 60 * 1000; + public static final long HOURINMILLIS = 60 * MINUTEINMILLIS; + public static final long DAYINMILLIS = 24 * HOURINMILLIS; + public static final long WEEKINMILLIS = 7 * DAYINMILLIS; + +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java new file mode 100644 index 0000000000..4e0b963534 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java @@ -0,0 +1,181 @@ +/** + * Copyright 2013 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.calendar; + +import java.util.Arrays; +import java.util.Date; + +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +import com.vaadin.data.util.BeanItem; +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.event.Action; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.DateField; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalSplitPanel; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.CloseEvent; +import com.vaadin.ui.components.calendar.ContainerEventProvider; +import com.vaadin.ui.components.calendar.event.BasicEvent; + +public class BeanItemContainerTestUI extends UI { + + private Calendar calendar; + + private Table table; + + private BeanItemContainer events = new BeanItemContainer( + BasicEvent.class); + + @SuppressWarnings("deprecation") + @Override + protected void init(VaadinRequest request) { + VerticalSplitPanel content = new VerticalSplitPanel(); + content.setSizeFull(); + setContent(content); + + // Create Calendar + calendar = new Calendar(); + calendar.setImmediate(true); + calendar.setSizeFull(); + calendar.setContainerDataSource(events); + calendar.setStartDate(new Date(100, 1, 1)); + calendar.setEndDate(new Date(100, 2, 1)); + + content.addComponent(calendar); + + // Add event table connected to same data source + table = createTable(); + table.setContainerDataSource(events); + table.setVisibleColumns(new Object[] { "caption", "description", + "start", "end" }); + content.addComponent(table); + } + + /** + * Creates a table with some actions + * + * @return + */ + private Table createTable() { + Table table = new Table(); + table.setSizeFull(); + table.addActionHandler(new Action.Handler() { + + private final Action ADD = new Action("Add event"); + private final Action EDIT = new Action("Edit event"); + private final Action REMOVE = new Action("Remove event"); + + public void handleAction(Action action, Object sender, Object target) { + if (action == ADD) { + BasicEvent event = new BasicEvent(); + event.setStart(new Date(100, 1, 1)); + event.setEnd(new Date(100, 1, 1)); + editEvent(event); + } else if (action == EDIT) { + editEvent((BasicEvent) target); + } else if (action == REMOVE) { + events.removeItem(target); + } + } + + public Action[] getActions(Object target, Object sender) { + if (target == null) { + return new Action[] { ADD }; + } else { + return new Action[] { EDIT, REMOVE }; + } + } + }); + return table; + } + + /** + * Opens up a modal dialog window where an event can be modified + * + * @param event + * The event to modify + */ + private void editEvent(final BasicEvent event) { + Window modal = new Window("Add event"); + modal.setModal(true); + modal.setResizable(false); + modal.setDraggable(false); + modal.setWidth("300px"); + final FieldGroup fieldGroup = new FieldGroup(); + + FormLayout formLayout = new FormLayout(); + TextField captionField = new TextField("Caption"); + captionField.setImmediate(true); + TextField descriptionField = new TextField("Description"); + descriptionField.setImmediate(true); + DateField startField = new DateField("Start"); + startField.setResolution(Resolution.MINUTE); + startField.setImmediate(true); + DateField endField = new DateField("End"); + endField.setImmediate(true); + endField.setResolution(Resolution.MINUTE); + + formLayout.addComponent(captionField); + formLayout.addComponent(descriptionField); + formLayout.addComponent(startField); + formLayout.addComponent(endField); + + fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); + fieldGroup.bind(descriptionField, + ContainerEventProvider.DESCRIPTION_PROPERTY); + fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); + fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); + + fieldGroup.setItemDataSource(new BeanItem(event, Arrays + .asList(ContainerEventProvider.CAPTION_PROPERTY, + ContainerEventProvider.DESCRIPTION_PROPERTY, + ContainerEventProvider.STARTDATE_PROPERTY, + ContainerEventProvider.ENDDATE_PROPERTY))); + modal.setContent(formLayout); + modal.addCloseListener(new Window.CloseListener() { + public void windowClose(CloseEvent e) { + // Commit changes to bean + try { + fieldGroup.commit(); + } catch (CommitException e1) { + e1.printStackTrace(); + } + + if (events.containsId(event)) { + /* + * BeanItemContainer does not notify container listeners + * when the bean changes so we need to trigger a + * ItemSetChange event + */ + BasicEvent dummy = new BasicEvent(); + events.addBean(dummy); + events.removeItem(dummy); + + } else { + events.addBean(event); + } + } + }); + getUI().addWindow(modal); + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java new file mode 100644 index 0000000000..f5c2d9da7e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java @@ -0,0 +1,107 @@ +/** + * Copyright 2013 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.calendar; + +import java.util.Date; +import java.util.Locale; + +import com.vaadin.event.Action; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.UI; +import com.vaadin.ui.components.calendar.CalendarDateRange; +import com.vaadin.ui.components.calendar.event.BasicEvent; + +public class CalendarActionsUI extends UI { + + @SuppressWarnings("deprecation") + @Override + protected void init(VaadinRequest request) { + GridLayout content = new GridLayout(1, 2); + content.setSizeFull(); + setContent(content); + + final Calendar calendar = new Calendar(); + calendar.setLocale(new Locale("fi", "FI")); + + calendar.setSizeFull(); + calendar.setStartDate(new Date(100, 1, 1)); + calendar.setEndDate(new Date(100, 2, 1)); + + calendar.addActionHandler(new Action.Handler() { + + public final Action NEW_EVENT = new Action("Add event"); + public final Action EDIT_EVENT = new Action("Edit event"); + public final Action REMOVE_EVENT = new Action("Remove event"); + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.event.Action.Handler#handleAction(com.vaadin.event + * .Action, java.lang.Object, java.lang.Object) + */ + public void handleAction(Action action, Object sender, Object target) { + Date date = (Date) target; + if (action == NEW_EVENT) { + BasicEvent event = new BasicEvent("New event", + "Hello world", date, date); + calendar.addEvent(event); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.event.Action.Handler#getActions(java.lang.Object, + * java.lang.Object) + */ + public Action[] getActions(Object target, Object sender) { + CalendarDateRange date = (CalendarDateRange) target; + + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(2000, 1, 1, 12, 0, 0); + + if (date.inRange(cal.getTime())) { + return new Action[] { NEW_EVENT, }; + } + + cal.add(java.util.Calendar.DAY_OF_WEEK, 1); + + if (date.inRange(cal.getTime())) { + return new Action[] { REMOVE_EVENT }; + } + + return null; + } + }); + + content.addComponent(calendar); + + content.addComponent(new Button("Set week view", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + calendar.setEndDate(new Date(100, 1, 7)); + } + })); + + content.setRowExpandRatio(0, 1); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java new file mode 100644 index 0000000000..530e47f1e0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java @@ -0,0 +1,1227 @@ +/** + * Copyright 2013 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.calendar; + +import java.text.DateFormatSymbols; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + +import com.vaadin.annotations.Theme; +import com.vaadin.data.Item; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.fieldgroup.FieldGroup.CommitException; +import com.vaadin.data.util.BeanItem; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.shared.ui.combobox.FilteringMode; +import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.Calendar.TimeFormat; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventClick; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventClickHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.RangeSelectEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.RangeSelectHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClick; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.WeekClickHandler; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.BasicEventProvider; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.handler.BasicDateClickHandler; +import com.vaadin.ui.components.calendar.handler.BasicWeekClickHandler; + +/** Calendar component test application */ +@Theme("tests-calendar") +public class CalendarTest extends UI { + + private static final long serialVersionUID = -5436777475398410597L; + + private static final String DEFAULT_ITEMID = "DEFAULT"; + + private enum Mode { + MONTH, WEEK, DAY; + } + + /** + * This Gregorian calendar is used to control dates and time inside of this + * test application. + */ + private GregorianCalendar calendar; + + /** Target calendar component that this test application is made for. */ + private Calendar calendarComponent; + + private Date currentMonthsFirstDate; + + private final Label captionLabel = new Label(""); + + private Button monthButton; + + private Button weekButton; + + private Button nextButton; + + private Button prevButton; + + private ComboBox timeZoneSelect; + + private ComboBox formatSelect; + + private ComboBox localeSelect; + + private CheckBox hideWeekendsButton; + + private CheckBox readOnlyButton; + + private TextField captionField; + + private Window scheduleEventPopup; + + private final FormLayout scheduleEventFieldLayout = new FormLayout(); + private FieldGroup scheduleEventFieldGroup = new FieldGroup(); + + private Button deleteEventButton; + + private Button applyEventButton; + + private Mode viewMode = Mode.MONTH; + + private BasicEventProvider dataSource; + + private Button addNewEvent; + + /* + * When testBench is set to true, CalendarTest will have static content that + * is more suitable for Vaadin TestBench testing. Calendar will use a static + * date Mon 10 Jan 2000. Enable by starting the application with a + * "testBench" parameter in the URL. + */ + private boolean testBench = false; + + private String calendarHeight = null; + + private String calendarWidth = null; + + private CheckBox disabledButton; + + private Integer firstHour; + + private Integer lastHour; + + private Integer firstDay; + + private Integer lastDay; + + private Locale defaultLocale = Locale.US; + + private boolean showWeeklyView; + + private boolean useSecondResolution; + + private DateField startDateField; + private DateField endDateField; + + @SuppressWarnings("serial") + @Override + public void init(VaadinRequest request) { + GridLayout layout = new GridLayout(); + layout.setSizeFull(); + layout.setMargin(true); + setContent(layout); + + handleURLParams(request.getParameterMap()); + + initContent(); + } + + private void handleURLParams(Map parameters) { + testBench = parameters.containsKey("testBench") + || parameters.containsKey("?testBench"); + + if (parameters.containsKey("width")) { + calendarWidth = parameters.get("width")[0]; + } + + if (parameters.containsKey("height")) { + calendarHeight = parameters.get("height")[0]; + } + + if (parameters.containsKey("firstDay")) { + firstDay = Integer.parseInt(parameters.get("firstDay")[0]); + } + + if (parameters.containsKey("lastDay")) { + lastDay = Integer.parseInt(parameters.get("lastDay")[0]); + } + + if (parameters.containsKey("firstHour")) { + firstHour = Integer.parseInt(parameters.get("firstHour")[0]); + } + + if (parameters.containsKey("lastHour")) { + lastHour = Integer.parseInt(parameters.get("lastHour")[0]); + } + + if (parameters.containsKey("locale")) { + String localeArray[] = parameters.get("locale")[0].split("_"); + defaultLocale = new Locale(localeArray[0], localeArray[1]); + setLocale(defaultLocale); + } + + if (parameters.containsKey(("secondsResolution"))) { + useSecondResolution = true; + } + + showWeeklyView = parameters.containsKey("weekly"); + + } + + public void initContent() { + // Set default Locale for this application + if (testBench) { + setLocale(defaultLocale); + + } else { + setLocale(Locale.getDefault()); + } + + // Initialize locale, timezone and timeformat selects. + localeSelect = createLocaleSelect(); + timeZoneSelect = createTimeZoneSelect(); + formatSelect = createCalendarFormatSelect(); + + initCalendar(); + initLayoutContent(); + addInitialEvents(); + } + + private Date resolveFirstDateOfWeek(Date today, + java.util.Calendar currentCalendar) { + int firstDayOfWeek = currentCalendar.getFirstDayOfWeek(); + currentCalendar.setTime(today); + while (firstDayOfWeek != currentCalendar + .get(java.util.Calendar.DAY_OF_WEEK)) { + currentCalendar.add(java.util.Calendar.DATE, -1); + } + return currentCalendar.getTime(); + } + + private Date resolveLastDateOfWeek(Date today, + java.util.Calendar currentCalendar) { + currentCalendar.setTime(today); + currentCalendar.add(java.util.Calendar.DATE, 1); + int firstDayOfWeek = currentCalendar.getFirstDayOfWeek(); + // Roll to weeks last day using firstdayofweek. Roll until FDofW is + // found and then roll back one day. + while (firstDayOfWeek != currentCalendar + .get(java.util.Calendar.DAY_OF_WEEK)) { + currentCalendar.add(java.util.Calendar.DATE, 1); + } + currentCalendar.add(java.util.Calendar.DATE, -1); + return currentCalendar.getTime(); + } + + private void addInitialEvents() { + Date originalDate = calendar.getTime(); + Date today = getToday(); + + // Add a event that last a whole week + + Date start = resolveFirstDateOfWeek(today, calendar); + Date end = resolveLastDateOfWeek(today, calendar); + CalendarTestEvent event = getNewEvent("Whole week event", start, end); + event.setAllDay(true); + event.setStyleName("color4"); + event.setDescription("Description for the whole week event."); + dataSource.addEvent(event); + + // Add a allday event + calendar.setTime(start); + calendar.add(GregorianCalendar.DATE, 3); + start = calendar.getTime(); + end = start; + event = getNewEvent("Allday event", start, end); + event.setAllDay(true); + event.setDescription("Some description."); + event.setStyleName("color3"); + dataSource.addEvent(event); + + // Add a second allday event + calendar.add(GregorianCalendar.DATE, 1); + start = calendar.getTime(); + end = start; + event = getNewEvent("Second allday event", start, end); + event.setAllDay(true); + event.setDescription("Some description."); + event.setStyleName("color2"); + dataSource.addEvent(event); + + calendar.add(GregorianCalendar.DATE, -3); + calendar.set(GregorianCalendar.HOUR_OF_DAY, 9); + calendar.set(GregorianCalendar.MINUTE, 30); + start = calendar.getTime(); + calendar.add(GregorianCalendar.HOUR_OF_DAY, 5); + calendar.set(GregorianCalendar.MINUTE, 0); + end = calendar.getTime(); + event = getNewEvent("Appointment", start, end); + event.setWhere("Office"); + event.setStyleName("color1"); + event.setDescription("A longer description, which should display correctly."); + dataSource.addEvent(event); + + calendar.add(GregorianCalendar.DATE, 1); + calendar.set(GregorianCalendar.HOUR_OF_DAY, 11); + calendar.set(GregorianCalendar.MINUTE, 0); + start = calendar.getTime(); + calendar.add(GregorianCalendar.HOUR_OF_DAY, 8); + end = calendar.getTime(); + event = getNewEvent("Training", start, end); + event.setStyleName("color2"); + dataSource.addEvent(event); + + calendar.add(GregorianCalendar.DATE, 4); + calendar.set(GregorianCalendar.HOUR_OF_DAY, 9); + calendar.set(GregorianCalendar.MINUTE, 0); + start = calendar.getTime(); + calendar.add(GregorianCalendar.HOUR_OF_DAY, 9); + end = calendar.getTime(); + event = getNewEvent("Free time", start, end); + dataSource.addEvent(event); + + calendar.setTime(originalDate); + } + + private void initLayoutContent() { + initNavigationButtons(); + initHideWeekEndButton(); + initReadOnlyButton(); + initDisabledButton(); + initAddNewEventButton(); + + HorizontalLayout hl = new HorizontalLayout(); + hl.setWidth("100%"); + hl.setSpacing(true); + hl.setMargin(new MarginInfo(false, false, true, false)); + hl.addComponent(prevButton); + hl.addComponent(captionLabel); + hl.addComponent(monthButton); + hl.addComponent(weekButton); + hl.addComponent(nextButton); + hl.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT); + hl.setComponentAlignment(captionLabel, Alignment.MIDDLE_CENTER); + hl.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER); + hl.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER); + hl.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT); + + monthButton.setVisible(viewMode == Mode.WEEK); + weekButton.setVisible(viewMode == Mode.DAY); + + HorizontalLayout controlPanel = new HorizontalLayout(); + controlPanel.setSpacing(true); + controlPanel.setMargin(new MarginInfo(false, false, true, false)); + controlPanel.setWidth("100%"); + controlPanel.addComponent(localeSelect); + controlPanel.addComponent(timeZoneSelect); + controlPanel.addComponent(formatSelect); + controlPanel.addComponent(hideWeekendsButton); + controlPanel.addComponent(readOnlyButton); + controlPanel.addComponent(disabledButton); + controlPanel.addComponent(addNewEvent); + + controlPanel.setComponentAlignment(timeZoneSelect, + Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(formatSelect, Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(localeSelect, Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(hideWeekendsButton, + Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(readOnlyButton, + Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(disabledButton, + Alignment.MIDDLE_LEFT); + controlPanel.setComponentAlignment(addNewEvent, Alignment.MIDDLE_LEFT); + + GridLayout layout = (GridLayout) getContent(); + layout.addComponent(controlPanel); + layout.addComponent(hl); + layout.addComponent(calendarComponent); + layout.setRowExpandRatio(layout.getRows() - 1, 1.0f); + } + + private void initNavigationButtons() { + monthButton = new Button("Month view", new ClickListener() { + + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + switchToMonthView(); + } + }); + + weekButton = new Button("Week view", new ClickListener() { + + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + // simulate week click + WeekClickHandler handler = (WeekClickHandler) calendarComponent + .getHandler(WeekClick.EVENT_ID); + handler.weekClick(new WeekClick(calendarComponent, calendar + .get(GregorianCalendar.WEEK_OF_YEAR), calendar + .get(GregorianCalendar.YEAR))); + } + }); + + nextButton = new Button("Next", new Button.ClickListener() { + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + handleNextButtonClick(); + } + }); + + prevButton = new Button("Prev", new Button.ClickListener() { + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + handlePreviousButtonClick(); + } + }); + } + + private void initHideWeekEndButton() { + hideWeekendsButton = new CheckBox("Hide weekends"); + hideWeekendsButton.setImmediate(true); + hideWeekendsButton + .addValueChangeListener(new Property.ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + @Override + public void valueChange(ValueChangeEvent event) { + setWeekendsHidden(hideWeekendsButton.getValue()); + } + }); + } + + private void setWeekendsHidden(boolean weekendsHidden) { + if (weekendsHidden) { + int firstToShow = (GregorianCalendar.MONDAY - calendar + .getFirstDayOfWeek()) % 7; + calendarComponent.setFirstVisibleDayOfWeek(firstToShow + 1); + calendarComponent.setLastVisibleDayOfWeek(firstToShow + 5); + } else { + calendarComponent.setFirstVisibleDayOfWeek(1); + calendarComponent.setLastVisibleDayOfWeek(7); + } + + } + + private void initReadOnlyButton() { + readOnlyButton = new CheckBox("Read-only mode"); + readOnlyButton.setImmediate(true); + readOnlyButton + .addValueChangeListener(new Property.ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + @Override + public void valueChange(ValueChangeEvent event) { + calendarComponent.setReadOnly(readOnlyButton.getValue()); + } + }); + } + + private void initDisabledButton() { + disabledButton = new CheckBox("Disabled"); + disabledButton.setImmediate(true); + disabledButton + .addValueChangeListener(new Property.ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + @Override + public void valueChange(ValueChangeEvent event) { + calendarComponent.setEnabled(!disabledButton.getValue()); + } + }); + } + + public void initAddNewEventButton() { + addNewEvent = new Button("Add new event"); + addNewEvent.addClickListener(new Button.ClickListener() { + + private static final long serialVersionUID = -8307244759142541067L; + + public void buttonClick(ClickEvent event) { + Date start = getToday(); + start.setHours(0); + start.setMinutes(0); + start.setSeconds(0); + + Date end = getEndOfDay(calendar, start); + + showEventPopup(createNewEvent(start, end), true); + } + }); + } + + private void initFormFields(Layout formLayout, + Class eventClass) { + + startDateField = createDateField("Start date"); + endDateField = createDateField("End date"); + + final CheckBox allDayField = createCheckBox("All-day"); + allDayField.addValueChangeListener(new Property.ValueChangeListener() { + + private static final long serialVersionUID = -7104996493482558021L; + + public void valueChange(ValueChangeEvent event) { + Object value = event.getProperty().getValue(); + if (value instanceof Boolean && Boolean.TRUE.equals(value)) { + setFormDateResolution(Resolution.DAY); + + } else { + setFormDateResolution(Resolution.MINUTE); + } + } + + }); + + captionField = createTextField("Caption"); + final TextField whereField = createTextField("Where"); + final TextArea descriptionField = createTextArea("Description"); + descriptionField.setRows(3); + + final ComboBox styleNameField = createStyleNameComboBox(); + + formLayout.addComponent(startDateField); + formLayout.addComponent(endDateField); + formLayout.addComponent(allDayField); + formLayout.addComponent(captionField); + if (eventClass == CalendarTestEvent.class) { + formLayout.addComponent(whereField); + } + formLayout.addComponent(descriptionField); + formLayout.addComponent(styleNameField); + + scheduleEventFieldGroup.bind(startDateField, "start"); + scheduleEventFieldGroup.bind(endDateField, "end"); + scheduleEventFieldGroup.bind(captionField, "caption"); + scheduleEventFieldGroup.bind(descriptionField, "description"); + if (eventClass == CalendarTestEvent.class) { + scheduleEventFieldGroup.bind(whereField, "where"); + } + scheduleEventFieldGroup.bind(styleNameField, "styleName"); + scheduleEventFieldGroup.bind(allDayField, "allDay"); + } + + private CheckBox createCheckBox(String caption) { + CheckBox cb = new CheckBox(caption); + cb.setImmediate(true); + return cb; + } + + private TextField createTextField(String caption) { + TextField f = new TextField(caption); + f.setNullRepresentation(""); + return f; + } + + private TextArea createTextArea(String caption) { + TextArea f = new TextArea(caption); + f.setNullRepresentation(""); + return f; + } + + private DateField createDateField(String caption) { + DateField f = new DateField(caption); + if (useSecondResolution) { + f.setResolution(Resolution.SECOND); + } else { + f.setResolution(Resolution.MINUTE); + } + return f; + } + + private ComboBox createStyleNameComboBox() { + ComboBox s = new ComboBox("Color"); + s.addContainerProperty("c", String.class, ""); + s.setItemCaptionPropertyId("c"); + Item i = s.addItem("color1"); + i.getItemProperty("c").setValue("Green"); + i = s.addItem("color2"); + i.getItemProperty("c").setValue("Blue"); + i = s.addItem("color3"); + i.getItemProperty("c").setValue("Red"); + i = s.addItem("color4"); + i.getItemProperty("c").setValue("Orange"); + return s; + } + + private void initCalendar() { + dataSource = new BasicEventProvider(); + + calendarComponent = new Calendar(dataSource); + calendarComponent.setLocale(getLocale()); + calendarComponent.setImmediate(true); + + if (calendarWidth != null || calendarHeight != null) { + if (calendarHeight != null) { + calendarComponent.setHeight(calendarHeight); + } + if (calendarWidth != null) { + calendarComponent.setWidth(calendarWidth); + } + } else { + calendarComponent.setSizeFull(); + } + + if (firstHour != null && lastHour != null) { + calendarComponent.setFirstVisibleHourOfDay(firstHour); + calendarComponent.setLastVisibleHourOfDay(lastHour); + } + + if (firstDay != null && lastDay != null) { + calendarComponent.setFirstVisibleDayOfWeek(firstDay); + calendarComponent.setLastVisibleDayOfWeek(lastDay); + } + + Date today = getToday(); + calendar = new GregorianCalendar(getLocale()); + calendar.setTime(today); + + updateCaptionLabel(); + + if (!showWeeklyView) { + int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1; + calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount); + resetTime(false); + currentMonthsFirstDate = calendar.getTime(); + calendarComponent.setStartDate(currentMonthsFirstDate); + calendar.add(GregorianCalendar.MONTH, 1); + calendar.add(GregorianCalendar.DATE, -1); + calendarComponent.setEndDate(calendar.getTime()); + } + + addCalendarEventListeners(); + } + + private Date getToday() { + if (testBench) { + GregorianCalendar testDate = new GregorianCalendar(); + testDate.set(GregorianCalendar.YEAR, 2000); + testDate.set(GregorianCalendar.MONTH, 0); + testDate.set(GregorianCalendar.DATE, 10); + testDate.set(GregorianCalendar.HOUR_OF_DAY, 0); + testDate.set(GregorianCalendar.MINUTE, 0); + testDate.set(GregorianCalendar.SECOND, 0); + testDate.set(GregorianCalendar.MILLISECOND, 0); + return testDate.getTime(); + } + return new Date(); + } + + @SuppressWarnings("serial") + private void addCalendarEventListeners() { + // Register week clicks by changing the schedules start and end dates. + calendarComponent.setHandler(new BasicWeekClickHandler() { + + @Override + public void weekClick(WeekClick event) { + // let BasicWeekClickHandler handle calendar dates, and update + // only the other parts of UI here + super.weekClick(event); + updateCaptionLabel(); + switchToWeekView(); + } + }); + + calendarComponent.setHandler(new EventClickHandler() { + + public void eventClick(EventClick event) { + showEventPopup(event.getCalendarEvent(), false); + } + }); + + calendarComponent.setHandler(new BasicDateClickHandler() { + + @Override + public void dateClick(DateClickEvent event) { + // let BasicDateClickHandler handle calendar dates, and update + // only the other parts of UI here + super.dateClick(event); + switchToDayView(); + } + }); + + calendarComponent.setHandler(new RangeSelectHandler() { + + public void rangeSelect(RangeSelectEvent event) { + handleRangeSelect(event); + } + }); + } + + private ComboBox createTimeZoneSelect() { + ComboBox s = new ComboBox("Timezone"); + s.addContainerProperty("caption", String.class, ""); + s.setItemCaptionPropertyId("caption"); + s.setFilteringMode(FilteringMode.CONTAINS); + + Item i = s.addItem(DEFAULT_ITEMID); + i.getItemProperty("caption").setValue( + "Default (" + TimeZone.getDefault().getID() + ")"); + for (String id : TimeZone.getAvailableIDs()) { + if (!s.containsId(id)) { + i = s.addItem(id); + i.getItemProperty("caption").setValue(id); + } + } + + if (testBench) { + s.select("America/New_York"); + } else { + s.select(DEFAULT_ITEMID); + } + s.setImmediate(true); + s.addValueChangeListener(new ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + public void valueChange(ValueChangeEvent event) { + + updateCalendarTimeZone(event.getProperty().getValue()); + } + }); + + return s; + } + + private ComboBox createCalendarFormatSelect() { + ComboBox s = new ComboBox("Calendar format"); + s.addContainerProperty("caption", String.class, ""); + s.setItemCaptionPropertyId("caption"); + + Item i = s.addItem(DEFAULT_ITEMID); + i.getItemProperty("caption").setValue("Default by locale"); + i = s.addItem(TimeFormat.Format12H); + i.getItemProperty("caption").setValue("12H"); + i = s.addItem(TimeFormat.Format24H); + i.getItemProperty("caption").setValue("24H"); + + s.select(DEFAULT_ITEMID); + s.setImmediate(true); + s.addValueChangeListener(new ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + public void valueChange(ValueChangeEvent event) { + updateCalendarFormat(event.getProperty().getValue()); + } + }); + + return s; + } + + private ComboBox createLocaleSelect() { + ComboBox s = new ComboBox("Locale"); + s.addContainerProperty("caption", String.class, ""); + s.setItemCaptionPropertyId("caption"); + s.setFilteringMode(FilteringMode.CONTAINS); + + for (Locale l : Locale.getAvailableLocales()) { + if (!s.containsId(l)) { + Item i = s.addItem(l); + i.getItemProperty("caption").setValue(getLocaleItemCaption(l)); + } + } + + s.select(getLocale()); + s.setImmediate(true); + s.addValueChangeListener(new ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + public void valueChange(ValueChangeEvent event) { + updateCalendarLocale((Locale) event.getProperty().getValue()); + } + }); + + return s; + } + + private void updateCalendarTimeZone(Object timezoneId) { + TimeZone tz = null; + if (!DEFAULT_ITEMID.equals(timezoneId)) { + tz = TimeZone.getTimeZone((String) timezoneId); + } + + // remember the week that was showing, so we can re-set it later + Date startDate = calendarComponent.getStartDate(); + calendar.setTime(startDate); + int weekNumber = calendar.get(java.util.Calendar.WEEK_OF_YEAR); + calendarComponent.setTimeZone(tz); + calendar.setTimeZone(calendarComponent.getTimeZone()); + + if (viewMode == Mode.WEEK) { + calendar.set(java.util.Calendar.WEEK_OF_YEAR, weekNumber); + calendar.set(java.util.Calendar.DAY_OF_WEEK, + calendar.getFirstDayOfWeek()); + + calendarComponent.setStartDate(calendar.getTime()); + calendar.add(java.util.Calendar.DATE, 6); + calendarComponent.setEndDate(calendar.getTime()); + } + } + + private void updateCalendarFormat(Object format) { + TimeFormat calFormat = null; + if (format instanceof TimeFormat) { + calFormat = (TimeFormat) format; + } + + calendarComponent.setTimeFormat(calFormat); + } + + private String getLocaleItemCaption(Locale l) { + String country = l.getDisplayCountry(getLocale()); + String language = l.getDisplayLanguage(getLocale()); + StringBuilder caption = new StringBuilder(country); + if (caption.length() != 0) { + caption.append(", "); + } + caption.append(language); + return caption.toString(); + } + + private void updateCalendarLocale(Locale l) { + int oldFirstDayOfWeek = calendar.getFirstDayOfWeek(); + setLocale(l); + calendarComponent.setLocale(l); + calendar = new GregorianCalendar(l); + int newFirstDayOfWeek = calendar.getFirstDayOfWeek(); + + // we are showing 1 week, and the first day of the week has changed + // update start and end dates so that the same week is showing + if (viewMode == Mode.WEEK && oldFirstDayOfWeek != newFirstDayOfWeek) { + calendar.setTime(calendarComponent.getStartDate()); + calendar.add(java.util.Calendar.DAY_OF_WEEK, 2); + // starting at the beginning of the week + calendar.set(GregorianCalendar.DAY_OF_WEEK, newFirstDayOfWeek); + Date start = calendar.getTime(); + + // ending at the end of the week + calendar.add(GregorianCalendar.DATE, 6); + Date end = calendar.getTime(); + + calendarComponent.setStartDate(start); + calendarComponent.setEndDate(end); + + // Week days depend on locale so this must be refreshed + setWeekendsHidden(hideWeekendsButton.getValue()); + } + + } + + private void handleNextButtonClick() { + switch (viewMode) { + case MONTH: + nextMonth(); + break; + case WEEK: + nextWeek(); + break; + case DAY: + nextDay(); + break; + } + } + + private void handlePreviousButtonClick() { + switch (viewMode) { + case MONTH: + previousMonth(); + break; + case WEEK: + previousWeek(); + break; + case DAY: + previousDay(); + break; + } + } + + private void handleRangeSelect(RangeSelectEvent event) { + Date start = event.getStart(); + Date end = event.getEnd(); + + /* + * If a range of dates is selected in monthly mode, we want it to end at + * the end of the last day. + */ + if (event.isMonthlyMode()) { + end = getEndOfDay(calendar, end); + } + + showEventPopup(createNewEvent(start, end), true); + } + + private void showEventPopup(CalendarEvent event, boolean newEvent) { + if (event == null) { + return; + } + + updateCalendarEventPopup(newEvent); + updateCalendarEventForm(event); + + if (!getWindows().contains(scheduleEventPopup)) { + addWindow(scheduleEventPopup); + } + } + + /* Initializes a modal window to edit schedule event. */ + private void createCalendarEventPopup() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.setSpacing(true); + + scheduleEventPopup = new Window(null, layout); + scheduleEventPopup.setWidth("400px"); + scheduleEventPopup.setModal(true); + scheduleEventPopup.center(); + + layout.addComponent(scheduleEventFieldLayout); + + applyEventButton = new Button("Apply", new ClickListener() { + + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + try { + commitCalendarEvent(); + } catch (CommitException e) { + e.printStackTrace(); + } + } + }); + Button cancel = new Button("Cancel", new ClickListener() { + + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + discardCalendarEvent(); + } + }); + deleteEventButton = new Button("Delete", new ClickListener() { + + private static final long serialVersionUID = 1L; + + public void buttonClick(ClickEvent event) { + deleteCalendarEvent(); + } + }); + scheduleEventPopup.addCloseListener(new Window.CloseListener() { + + private static final long serialVersionUID = 1L; + + public void windowClose(Window.CloseEvent e) { + discardCalendarEvent(); + } + }); + + HorizontalLayout buttons = new HorizontalLayout(); + buttons.setSpacing(true); + buttons.addComponent(deleteEventButton); + buttons.addComponent(applyEventButton); + buttons.addComponent(cancel); + layout.addComponent(buttons); + layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT); + } + + private void updateCalendarEventPopup(boolean newEvent) { + if (scheduleEventPopup == null) { + createCalendarEventPopup(); + } + + if (newEvent) { + scheduleEventPopup.setCaption("New event"); + } else { + scheduleEventPopup.setCaption("Edit event"); + } + + deleteEventButton.setVisible(!newEvent); + deleteEventButton.setEnabled(!calendarComponent.isReadOnly()); + applyEventButton.setEnabled(!calendarComponent.isReadOnly()); + } + + private void updateCalendarEventForm(CalendarEvent event) { + BeanItem item = new BeanItem(event); + scheduleEventFieldLayout.removeAllComponents(); + scheduleEventFieldGroup = new FieldGroup(); + initFormFields(scheduleEventFieldLayout, event.getClass()); + scheduleEventFieldGroup.setBuffered(true); + scheduleEventFieldGroup.setItemDataSource(item); + } + + private void setFormDateResolution(Resolution resolution) { + if (startDateField != null && endDateField != null) { + startDateField.setResolution(resolution); + endDateField.setResolution(resolution); + } + } + + private CalendarEvent createNewEvent(Date startDate, Date endDate) { + + BasicEvent event = new BasicEvent(); + event.setCaption(""); + event.setStart(startDate); + event.setEnd(endDate); + event.setStyleName("color1"); + return event; + } + + /* Removes the event from the data source and fires change event. */ + private void deleteCalendarEvent() { + BasicEvent event = getFormCalendarEvent(); + if (dataSource.containsEvent(event)) { + dataSource.removeEvent(event); + } + removeWindow(scheduleEventPopup); + } + + /* Adds/updates the event in the data source and fires change event. */ + private void commitCalendarEvent() throws CommitException { + scheduleEventFieldGroup.commit(); + BasicEvent event = getFormCalendarEvent(); + if (event.getEnd() == null) { + event.setEnd(event.getStart()); + } + if (!dataSource.containsEvent(event)) { + dataSource.addEvent(event); + } + + removeWindow(scheduleEventPopup); + } + + private void discardCalendarEvent() { + scheduleEventFieldGroup.discard(); + removeWindow(scheduleEventPopup); + } + + @SuppressWarnings("unchecked") + private BasicEvent getFormCalendarEvent() { + BeanItem item = (BeanItem) scheduleEventFieldGroup + .getItemDataSource(); + CalendarEvent event = item.getBean(); + return (BasicEvent) event; + } + + private void nextMonth() { + rollMonth(1); + } + + private void previousMonth() { + rollMonth(-1); + } + + private void nextWeek() { + rollWeek(1); + } + + private void previousWeek() { + rollWeek(-1); + } + + private void nextDay() { + rollDate(1); + } + + private void previousDay() { + rollDate(-1); + } + + private void rollMonth(int direction) { + calendar.setTime(currentMonthsFirstDate); + calendar.add(GregorianCalendar.MONTH, direction); + resetTime(false); + currentMonthsFirstDate = calendar.getTime(); + calendarComponent.setStartDate(currentMonthsFirstDate); + + updateCaptionLabel(); + + calendar.add(GregorianCalendar.MONTH, 1); + calendar.add(GregorianCalendar.DATE, -1); + resetCalendarTime(true); + } + + private void rollWeek(int direction) { + calendar.add(GregorianCalendar.WEEK_OF_YEAR, direction); + calendar.set(GregorianCalendar.DAY_OF_WEEK, + calendar.getFirstDayOfWeek()); + resetCalendarTime(false); + resetTime(true); + calendar.add(GregorianCalendar.DATE, 6); + calendarComponent.setEndDate(calendar.getTime()); + } + + private void rollDate(int direction) { + calendar.add(GregorianCalendar.DATE, direction); + resetCalendarTime(false); + resetCalendarTime(true); + } + + private void updateCaptionLabel() { + DateFormatSymbols s = new DateFormatSymbols(getLocale()); + String month = s.getShortMonths()[calendar.get(GregorianCalendar.MONTH)]; + captionLabel.setValue(month + " " + + calendar.get(GregorianCalendar.YEAR)); + } + + private CalendarTestEvent getNewEvent(String caption, Date start, Date end) { + CalendarTestEvent event = new CalendarTestEvent(); + event.setCaption(caption); + event.setStart(start); + event.setEnd(end); + + return event; + } + + /* + * Switch the view to week view. + */ + public void switchToWeekView() { + viewMode = Mode.WEEK; + weekButton.setVisible(false); + monthButton.setVisible(true); + } + + /* + * Switch the Calendar component's start and end date range to the target + * month only. (sample range: 01.01.2010 00:00.000 - 31.01.2010 23:59.999) + */ + public void switchToMonthView() { + viewMode = Mode.MONTH; + monthButton.setVisible(false); + weekButton.setVisible(false); + + calendar.setTime(currentMonthsFirstDate); + calendarComponent.setStartDate(currentMonthsFirstDate); + + updateCaptionLabel(); + + calendar.add(GregorianCalendar.MONTH, 1); + calendar.add(GregorianCalendar.DATE, -1); + resetCalendarTime(true); + } + + /* + * Switch to day view (week view with a single day visible). + */ + public void switchToDayView() { + viewMode = Mode.DAY; + monthButton.setVisible(true); + weekButton.setVisible(true); + } + + private void resetCalendarTime(boolean resetEndTime) { + resetTime(resetEndTime); + if (resetEndTime) { + calendarComponent.setEndDate(calendar.getTime()); + } else { + calendarComponent.setStartDate(calendar.getTime()); + updateCaptionLabel(); + } + } + + /* + * Resets the calendar time (hour, minute second and millisecond) either to + * zero or maximum value. + */ + private void resetTime(boolean max) { + if (max) { + calendar.set(GregorianCalendar.HOUR_OF_DAY, + calendar.getMaximum(GregorianCalendar.HOUR_OF_DAY)); + calendar.set(GregorianCalendar.MINUTE, + calendar.getMaximum(GregorianCalendar.MINUTE)); + calendar.set(GregorianCalendar.SECOND, + calendar.getMaximum(GregorianCalendar.SECOND)); + calendar.set(GregorianCalendar.MILLISECOND, + calendar.getMaximum(GregorianCalendar.MILLISECOND)); + } else { + calendar.set(GregorianCalendar.HOUR_OF_DAY, 0); + calendar.set(GregorianCalendar.MINUTE, 0); + calendar.set(GregorianCalendar.SECOND, 0); + calendar.set(GregorianCalendar.MILLISECOND, 0); + } + } + + private static Date getEndOfDay(java.util.Calendar calendar, Date date) { + java.util.Calendar calendarClone = (java.util.Calendar) calendar + .clone(); + + calendarClone.setTime(date); + calendarClone.set(java.util.Calendar.MILLISECOND, + calendarClone.getActualMaximum(java.util.Calendar.MILLISECOND)); + calendarClone.set(java.util.Calendar.SECOND, + calendarClone.getActualMaximum(java.util.Calendar.SECOND)); + calendarClone.set(java.util.Calendar.MINUTE, + calendarClone.getActualMaximum(java.util.Calendar.MINUTE)); + calendarClone.set(java.util.Calendar.HOUR, + calendarClone.getActualMaximum(java.util.Calendar.HOUR)); + calendarClone.set(java.util.Calendar.HOUR_OF_DAY, + calendarClone.getActualMaximum(java.util.Calendar.HOUR_OF_DAY)); + + return calendarClone.getTime(); + } + + private static Date getStartOfDay(java.util.Calendar calendar, Date date) { + java.util.Calendar calendarClone = (java.util.Calendar) calendar + .clone(); + + calendarClone.setTime(date); + calendarClone.set(java.util.Calendar.MILLISECOND, 0); + calendarClone.set(java.util.Calendar.SECOND, 0); + calendarClone.set(java.util.Calendar.MINUTE, 0); + calendarClone.set(java.util.Calendar.HOUR, 0); + calendarClone.set(java.util.Calendar.HOUR_OF_DAY, 0); + + return calendarClone.getTime(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarTestEvent.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarTestEvent.java new file mode 100644 index 0000000000..29b8f62403 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarTestEvent.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2013 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.calendar; + +import com.vaadin.ui.components.calendar.event.BasicEvent; + +/** + * Test CalendarEvent implementation. + * + * @see com.vaadin.addon.calendar.test.ui.Calendar.Event + */ +public class CalendarTestEvent extends BasicEvent { + + private static final long serialVersionUID = 2820133201983036866L; + private String where; + private Object data; + + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + fireEventChange(); + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + fireEventChange(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java b/uitest/src/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java new file mode 100644 index 0000000000..8b789098e6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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.calendar; + +import java.util.Date; +import java.util.Locale; + +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.Calendar; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.UI; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.BackwardHandler; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.ForwardHandler; + +public class HiddenFwdBackButtons extends UI { + + @SuppressWarnings("deprecation") + @Override + protected void init(VaadinRequest request) { + GridLayout content = new GridLayout(1, 2); + content.setSizeFull(); + setContent(content); + + final Calendar calendar = new Calendar(); + calendar.setLocale(new Locale("fi", "FI")); + + calendar.setSizeFull(); + calendar.setStartDate(new Date(100, 1, 1)); + calendar.setEndDate(new Date(100, 1, 7)); + content.addComponent(calendar); + Button button = new Button("Hide forward and back buttons"); + button.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // This should hide the forward and back navigation buttons + calendar.setHandler((BackwardHandler) null); + calendar.setHandler((ForwardHandler) null); + } + }); + content.addComponent(button); + + content.setRowExpandRatio(0, 1); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java b/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java new file mode 100644 index 0000000000..0bd327da18 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java @@ -0,0 +1,101 @@ +/* + * Copyright 2000-2013 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.calendar; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.UI; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickEvent; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.DateClickHandler; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; + +public class NotificationTestUI extends UI { + + private DummyEventProvider provider; + + private static class DummyEventProvider implements CalendarEventProvider { + + private int index; + private List events = new ArrayList(); + + public void addEvent(Date date) { + BasicEvent e = new BasicEvent(); + e.setAllDay(true); + e.setStart(date); + e.setEnd(date); + e.setCaption("Some event " + ++index); + events.add(e); + } + + public List getEvents(Date startDate, Date endDate) { + return events; + } + + } + + @Override + protected void init(com.vaadin.server.VaadinRequest request) { + GridLayout content = new GridLayout(1, 2); + content.setSizeFull(); + content.setRowExpandRatio(1, 1.0f); + setContent(content); + final Button btn = new Button("Show working notification", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + Notification + .show("This will disappear when you move your mouse!"); + } + }); + content.addComponent(btn); + + provider = new DummyEventProvider(); + final Calendar cal = new Calendar(provider); + cal.setLocale(Locale.US); + cal.setSizeFull(); + cal.setHandler(new DateClickHandler() { + public void dateClick(DateClickEvent event) { + provider.addEvent(event.getDate()); + Notification + .show("This should disappear, but if wont unless clicked."); + + // this requestRepaint call interferes with the notification + cal.markAsDirty(); + } + }); + content.addComponent(cal); + + java.util.Calendar javaCal = java.util.Calendar.getInstance(); + javaCal.set(java.util.Calendar.YEAR, 2000); + javaCal.set(java.util.Calendar.MONTH, 0); + javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1); + Date start = javaCal.getTime(); + javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31); + Date end = javaCal.getTime(); + + cal.setStartDate(start); + cal.setEndDate(end); + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/actions.html b/uitest/src/com/vaadin/tests/components/calendar/actions.html new file mode 100644 index 0000000000..bec3f2aded --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/actions.html @@ -0,0 +1,51 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.calendar.CalendarActionsUI?restartApplication
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[7]100,20
    screenCaptureaddEventContextMenu
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[8]100,20
    screenCaptureremoveEventContextMenu
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[8]
    screenCaptureNoContextMenu
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html b/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html new file mode 100644 index 0000000000..cccb88bfb2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html @@ -0,0 +1,236 @@ + + + + + + +basicNavigation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    basicNavigation
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Mar 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[5]/domChild[6]/domChild[0]/domChild[0]5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,44
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]1 AM
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[23]11 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,6
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/23/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/29/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]77,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Tuesday 1/11/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]8,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Friday 12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/30/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 2/5/00
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html b/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html new file mode 100644 index 0000000000..dcf6c1ec53 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html @@ -0,0 +1,110 @@ + + + + + + +eventSizingNoOverlap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    eventSizingNoOverlap
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]4,57
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 12:45 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]12:45-13:15
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:15-13:25
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:55 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:25-13:55
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html b/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html new file mode 100644 index 0000000000..8991e1983d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html @@ -0,0 +1,116 @@ + + + + + + +midnightEventsTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    midnightEventsTest
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&secondsResolution&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/3/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/4/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Midnight to midnight
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]84,10
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/7/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]10,48
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]50,4
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    dragAndDropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[5]+0,+5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html new file mode 100644 index 0000000000..760beef6c0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html @@ -0,0 +1,170 @@ + + + + + + +monthlyViewNewEvent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    monthlyViewNewEvent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field52,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]91,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]41,8
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]107,8
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html new file mode 100644 index 0000000000..68690f81b4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html @@ -0,0 +1,410 @@ + + + + + + +monthlyViewNewEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    monthlyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[2]98,83
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]38,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]7,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[4]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[3]125,80
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button6,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item249,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[4]45,85
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]5,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button13,18
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item357,9
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]12,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]72,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]44,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]79,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]47,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]72,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[3]37,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/notifications.html b/uitest/src/com/vaadin/tests/components/calendar/notifications.html new file mode 100644 index 0000000000..15bf29a0fd --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/notifications.html @@ -0,0 +1,41 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.calendar.NotificationTestUI?restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]83,11
    mouseMovevaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[3]/domChild[0]/domChild[3]10,10
    closeNotification//div[@id='runcomvaadintestscomponentscalendarNotificationTestUI-1842310749-overlays']/div0,0
    screenCaptureno-notification
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html new file mode 100644 index 0000000000..66d2c2f126 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest1000x600px + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest1000x600px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=1000px&height=600px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]7,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html new file mode 100644 index 0000000000..7c963f547f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest100percentXundefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest100percentXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]10,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html new file mode 100644 index 0000000000..19f03db784 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest100x100percent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest100x100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]12,54
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html new file mode 100644 index 0000000000..70f6dbd75b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest300pxXundefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest300pxXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]11,52
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html new file mode 100644 index 0000000000..59d39226d9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestSizeFull + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestSizeFull
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,56
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html new file mode 100644 index 0000000000..d48917904c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedX100percent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedX100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html new file mode 100644 index 0000000000..2dfce00635 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedX300px + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedX300px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,26
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html new file mode 100644 index 0000000000..3bfae6be35 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedXUndefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedXUndefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=&height=
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]8,52
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html b/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html new file mode 100644 index 0000000000..a0c6798edb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html @@ -0,0 +1,46 @@ + + + + + + +visibleHours24H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    visibleHours24H
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[0]9,55
    mouseClick//div[@id='gwt-uid-9']/div7,14
    mouseClick//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[4]/td120,15
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]9:00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]16:00
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html new file mode 100644 index 0000000000..b587288a24 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html @@ -0,0 +1,657 @@ + + + + + + +weeklyViewNewEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    weeklyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]3,49
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]/domChild[0]26,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/10/00 09:30 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/10/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]off
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Appointment
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]Office
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]A longer description, which should display correctly.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]/domChild[0]21,12
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]/domChild[48]/domChild[0]/domChild[0]19,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/15/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00 06:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Free time
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[6]/domChild[0]/domChild[0]22,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description for the whole week event.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[1]78,3
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[1]57,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 9:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 2:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[1]3,15
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item436,6
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]47,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]8,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]33,16
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#popupButton10,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1116,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#popupButton14,14
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1114,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]34,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 8:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Second test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]7,73
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]12,32
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]11,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[1]4,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]14,71
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]16,111
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]14,209
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]20,113
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]7,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]21,87
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]12,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[4]36,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[3]53,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[2]/domChild[0]48,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[4]/domChild[0]/domChild[1]50,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    + + -- cgit v1.2.3 From ad290f8c65057bdef33ec73cb49a8c6d10b9e356 Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Wed, 3 Apr 2013 14:12:42 +0300 Subject: Fix for CheckBox and Layout (#11407) Change in CheckBoxConnector led to wrong enabled behaviour and addition to top coordinate to prevent scrollbars with VPopupCalendar Change-Id: I381ab7c8a605535280ae58716181ef4c346997f7 --- WebContent/VAADIN/themes/base/common/common.scss | 1 + .../client/ui/checkbox/CheckBoxConnector.java | 4 +++- .../tests/layouts/CaptionsInLayoutsWaiAria.java | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'uitest/src') diff --git a/WebContent/VAADIN/themes/base/common/common.scss b/WebContent/VAADIN/themes/base/common/common.scss index 27c6dc949c..926bdc7b74 100644 --- a/WebContent/VAADIN/themes/base/common/common.scss +++ b/WebContent/VAADIN/themes/base/common/common.scss @@ -240,6 +240,7 @@ input::-ms-clear { .v-assistive-device-only { position: absolute; + top: -2000px; left: -2000px; width: 10px; overflow: hidden; diff --git a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java index ebfda2d715..7c2052e6f1 100644 --- a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java +++ b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java @@ -92,7 +92,9 @@ public class CheckBoxConnector extends AbstractFieldConnector implements } getWidget().setRequired(isRequired()); - getWidget().setEnabled(!isReadOnly()); + if (isReadOnly()) { + getWidget().setEnabled(false); + } if (getIcon() != null) { if (getWidget().icon == null) { diff --git a/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java index 4ffe7f806e..ec323f2db2 100644 --- a/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java +++ b/uitest/src/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -55,6 +55,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase { addComponent(toggleIcon()); addComponent(toggleReadOnly()); addComponent(toggleInvalid()); + addComponent(toggleEnabled()); addComponent(addCaptionText()); // layoutParent.addComponent(new // NativeButton("Button right of layout")); @@ -125,6 +126,21 @@ public class CaptionsInLayoutsWaiAria extends TestBase { return readOnlyToggle; } + private Component toggleEnabled() { + CheckBox enabledToggle = new CheckBox(); + enabledToggle.setImmediate(true); + enabledToggle.setValue(true); + enabledToggle.setCaption("Enabled"); + enabledToggle.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + setEnabled((Boolean) event.getProperty().getValue()); + } + }); + + return enabledToggle; + } + private Component toggleInvalid() { CheckBox invalid = new CheckBox("Invalid"); invalid.setImmediate(true); @@ -174,6 +190,12 @@ public class CaptionsInLayoutsWaiAria extends TestBase { } } + protected void setEnabled(boolean value) { + for (AbstractField c : components) { + c.setEnabled(value); + } + } + private Component toggleError() { CheckBox errorToggle = new CheckBox(); errorToggle.setImmediate(true); -- cgit v1.2.3 From b6928fde240d5b660a4a7be1076e7c58584b3303 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 3 Apr 2013 18:17:32 +0300 Subject: Reworked fix for ignoring /APP/ (#11192) * Fixed potential NPE by using existing helper method * Pass /APP/ urls also to session handlers as at least GlobalResourceHandler requires it * Fixed test to test /APP/ instead of /APP Change-Id: I8d913e6a5509c63f8e47813fce5751f5279ed4fc --- server/src/com/vaadin/server/BootstrapHandler.java | 3 +-- .../com/vaadin/server/communication/SessionRequestHandler.java | 8 -------- uitest/src/com/vaadin/tests/requesthandlers/AppResource404.java | 4 ++-- 3 files changed, 3 insertions(+), 12 deletions(-) (limited to 'uitest/src') diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 80cadb02c1..671279219e 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -115,8 +115,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { @Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { - String pathInfo = request.getPathInfo(); - if (pathInfo.startsWith("/" + ApplicationConstants.APP_PATH + "/")) { + if (ServletPortletHelper.isAppRequest(request)) { // We do not want to handle /APP requests here, instead let it fall // through and produce a 404 return false; diff --git a/server/src/com/vaadin/server/communication/SessionRequestHandler.java b/server/src/com/vaadin/server/communication/SessionRequestHandler.java index 14c940acf5..244cb0121d 100644 --- a/server/src/com/vaadin/server/communication/SessionRequestHandler.java +++ b/server/src/com/vaadin/server/communication/SessionRequestHandler.java @@ -22,7 +22,6 @@ import com.vaadin.server.RequestHandler; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; import com.vaadin.server.VaadinSession; -import com.vaadin.shared.ApplicationConstants; /** * Handles a request by passing it to each registered {@link RequestHandler} in @@ -51,13 +50,6 @@ public class SessionRequestHandler implements RequestHandler { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { - String pathInfo = request.getPathInfo(); - if (pathInfo.startsWith("/" + ApplicationConstants.APP_PATH + "/")) { - // // is reserved for Vaadin internal use and these - // requests should not be passed to session request handlers - return false; - } - // Use a copy to avoid ConcurrentModificationException session.lock(); ArrayList requestHandlers; diff --git a/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.java b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.java index dfd664c9cf..a6a5a5a084 100644 --- a/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.java +++ b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.java @@ -23,8 +23,8 @@ public class AppResource404 extends TestBase { addComponent(new Link("Existing resource", resource)); addComponent(new Link("Non-existing resource", new ExternalResource( baseUrl + "/APP/connector/0/4/asdfasdf"))); - addComponent(new Link("/APP url that should give 404", - new ExternalResource(baseUrl + "/APP"))); + addComponent(new Link("/APP/ url that should give 404", + new ExternalResource(baseUrl + "/APP/"))); addComponent(new Link("/APPLE url that should go to UI providers", new ExternalResource(baseUrl + "/APPLE"))); } -- cgit v1.2.3 From 008d51dba378c2feb57bd5d30550561567f3f91a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 4 Apr 2013 12:24:43 +0300 Subject: Renamed Calendar tests to be more consistent with other tests (#11079) Change-Id: I3c057c6c6ebf3cad982b5f8d2821b579f7aa57ea --- .../tests/components/calendar/CalendarActions.html | 51 ++ .../calendar/CalendarBasicNavigation.html | 236 ++++++++ .../calendar/CalendarEventSizingNoOverlap.html | 110 ++++ .../calendar/CalendarMidnightEventsTest.html | 116 ++++ .../calendar/CalendarMonthlyViewNewEvent.html | 170 ++++++ .../calendar/CalendarMonthlyViewNewEvents.html | 410 +++++++++++++ .../components/calendar/CalendarNotifications.html | 41 ++ .../calendar/CalendarSizeTest1000x600px.html | 41 ++ .../CalendarSizeTest100percentXundefined.html | 41 ++ .../calendar/CalendarSizeTest100x100percent.html | 41 ++ .../calendar/CalendarSizeTest300pxXundefined.html | 41 ++ .../calendar/CalendarSizeTestSizeFull.html | 41 ++ .../CalendarSizeTestUndefinedX100percent.html | 41 ++ .../calendar/CalendarSizeTestUndefinedX300px.html | 41 ++ .../CalendarSizeTestUndefinedXUndefined.html | 41 ++ .../calendar/CalendarVisibleHours24H.html | 46 ++ .../calendar/CalendarWeeklyViewNewEvents.html | 657 +++++++++++++++++++++ .../vaadin/tests/components/calendar/actions.html | 51 -- .../tests/components/calendar/basicNavigation.html | 236 -------- .../components/calendar/eventSizingNoOverlap.html | 110 ---- .../components/calendar/midnightEventsTest.html | 116 ---- .../components/calendar/monthlyViewNewEvent.html | 170 ------ .../components/calendar/monthlyViewNewEvents.html | 410 ------------- .../tests/components/calendar/notifications.html | 41 -- .../components/calendar/sizeTest1000x600px.html | 41 -- .../calendar/sizeTest100percentXundefined.html | 41 -- .../calendar/sizeTest100x100percent.html | 41 -- .../calendar/sizeTest300pxXundefined.html | 41 -- .../components/calendar/sizeTestSizeFull.html | 41 -- .../calendar/sizeTestUndefinedX100percent.html | 41 -- .../calendar/sizeTestUndefinedX300px.html | 41 -- .../calendar/sizeTestUndefinedXUndefined.html | 41 -- .../tests/components/calendar/visibleHours24H.html | 46 -- .../components/calendar/weeklyViewNewEvents.html | 657 --------------------- 34 files changed, 2165 insertions(+), 2165 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarActions.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarBasicNavigation.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarEventSizingNoOverlap.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarMidnightEventsTest.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvents.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarVisibleHours24H.html create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/actions.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/notifications.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarActions.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarActions.html new file mode 100644 index 0000000000..bec3f2aded --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarActions.html @@ -0,0 +1,51 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.calendar.CalendarActionsUI?restartApplication
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[7]100,20
    screenCaptureaddEventContextMenu
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[8]100,20
    screenCaptureremoveEventContextMenu
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[8]
    screenCaptureNoContextMenu
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarBasicNavigation.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarBasicNavigation.html new file mode 100644 index 0000000000..cccb88bfb2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarBasicNavigation.html @@ -0,0 +1,236 @@ + + + + + + +basicNavigation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    basicNavigation
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Mar 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[5]/domChild[6]/domChild[0]/domChild[0]5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,44
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]1 AM
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[23]11 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,6
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/23/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/29/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]77,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Tuesday 1/11/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]8,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Friday 12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/30/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 2/5/00
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarEventSizingNoOverlap.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarEventSizingNoOverlap.html new file mode 100644 index 0000000000..dcf6c1ec53 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarEventSizingNoOverlap.html @@ -0,0 +1,110 @@ + + + + + + +eventSizingNoOverlap + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    eventSizingNoOverlap
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]4,57
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 12:45 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]12:45-13:15
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:15-13:25
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:55 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:25-13:55
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarMidnightEventsTest.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarMidnightEventsTest.html new file mode 100644 index 0000000000..8991e1983d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMidnightEventsTest.html @@ -0,0 +1,116 @@ + + + + + + +midnightEventsTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    midnightEventsTest
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&secondsResolution&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/3/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/4/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Midnight to midnight
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]84,10
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/7/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]10,48
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]50,4
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    dragAndDropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[5]+0,+5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvent.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvent.html new file mode 100644 index 0000000000..760beef6c0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvent.html @@ -0,0 +1,170 @@ + + + + + + +monthlyViewNewEvent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    monthlyViewNewEvent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field52,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]91,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]41,8
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]107,8
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvents.html new file mode 100644 index 0000000000..68690f81b4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarMonthlyViewNewEvents.html @@ -0,0 +1,410 @@ + + + + + + +monthlyViewNewEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    monthlyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[2]98,83
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]38,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]7,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[4]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[3]125,80
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button6,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item249,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[4]45,85
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]5,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button13,18
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item357,9
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]12,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]72,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]44,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]79,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]47,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]72,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[3]37,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html new file mode 100644 index 0000000000..15bf29a0fd --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarNotifications.html @@ -0,0 +1,41 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.calendar.NotificationTestUI?restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]83,11
    mouseMovevaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[3]/domChild[0]/domChild[3]10,10
    closeNotification//div[@id='runcomvaadintestscomponentscalendarNotificationTestUI-1842310749-overlays']/div0,0
    screenCaptureno-notification
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html new file mode 100644 index 0000000000..66d2c2f126 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest1000x600px + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest1000x600px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=1000px&height=600px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]7,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html new file mode 100644 index 0000000000..7c963f547f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest100percentXundefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest100percentXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]10,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html new file mode 100644 index 0000000000..19f03db784 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest100x100percent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest100x100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]12,54
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html new file mode 100644 index 0000000000..70f6dbd75b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTest300pxXundefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTest300pxXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]11,52
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html new file mode 100644 index 0000000000..59d39226d9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestSizeFull + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestSizeFull
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,56
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html new file mode 100644 index 0000000000..d48917904c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedX100percent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedX100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,53
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html new file mode 100644 index 0000000000..2dfce00635 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedX300px + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedX300px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,26
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html new file mode 100644 index 0000000000..3bfae6be35 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html @@ -0,0 +1,41 @@ + + + + + + +sizeTestUndefinedXUndefined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sizeTestUndefinedXUndefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=&height=
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]8,52
    screenCapture
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarVisibleHours24H.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarVisibleHours24H.html new file mode 100644 index 0000000000..a0c6798edb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarVisibleHours24H.html @@ -0,0 +1,46 @@ + + + + + + +visibleHours24H + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    visibleHours24H
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[0]9,55
    mouseClick//div[@id='gwt-uid-9']/div7,14
    mouseClick//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[4]/td120,15
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]9:00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]16:00
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html new file mode 100644 index 0000000000..b587288a24 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html @@ -0,0 +1,657 @@ + + + + + + +weeklyViewNewEvents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    weeklyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]3,49
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]/domChild[0]26,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/10/00 09:30 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/10/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]off
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Appointment
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]Office
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]A longer description, which should display correctly.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]/domChild[0]21,12
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]/domChild[48]/domChild[0]/domChild[0]19,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/15/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00 06:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Free time
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[6]/domChild[0]/domChild[0]22,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description for the whole week event.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[1]78,3
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[1]57,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 9:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 2:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[1]3,15
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item436,6
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]47,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]8,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]33,16
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#popupButton10,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1116,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#popupButton14,14
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1114,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]34,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 8:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Second test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]7,73
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]12,32
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]11,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[1]4,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]14,71
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]16,111
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]14,209
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]20,113
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]7,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]21,87
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]12,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[4]36,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[3]53,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[2]/domChild[0]48,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[4]/domChild[0]/domChild[1]50,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    + + diff --git a/uitest/src/com/vaadin/tests/components/calendar/actions.html b/uitest/src/com/vaadin/tests/components/calendar/actions.html deleted file mode 100644 index bec3f2aded..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/actions.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    New Test
    open/run/com.vaadin.tests.components.calendar.CalendarActionsUI?restartApplication
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[7]100,20
    screenCaptureaddEventContextMenu
    contextMenuAtvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[8]100,20
    screenCaptureremoveEventContextMenu
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarActionsUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[8]
    screenCaptureNoContextMenu
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html b/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html deleted file mode 100644 index cccb88bfb2..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/basicNavigation.html +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - -basicNavigation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    basicNavigation
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Mar 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Feb 2000
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[5]/domChild[6]/domChild[0]/domChild[0]5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,44
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]1 AM
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[23]11 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,6
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]4,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/23/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/29/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]9,7
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/9/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 1/15/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]77,5
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Tuesday 1/11/00
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]8,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]10,9
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Friday 12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]Sunday 1/30/00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]Saturday 2/5/00
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html b/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html deleted file mode 100644 index dcf6c1ec53..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/eventSizingNoOverlap.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - -eventSizingNoOverlap - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    eventSizingNoOverlap
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]4,57
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 12:45 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]12:45-13:15
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:15 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:15-13:25
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00 13:25 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/9/00 13:55 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]13:25-13:55
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html b/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html deleted file mode 100644 index 8991e1983d..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/midnightEventsTest.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - -midnightEventsTest - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    midnightEventsTest
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&secondsResolution&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/3/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/4/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Midnight to midnight
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[2]84,10
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/7/00 12:00:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]10,48
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]50,4
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Zero-length midnight event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    dragAndDropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[5]+0,+5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html deleted file mode 100644 index 760beef6c0..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvent.html +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - -monthlyViewNewEvent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    monthlyViewNewEvent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,5
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field52,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]91,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]41,8
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]107,8
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html deleted file mode 100644 index 68690f81b4..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/monthlyViewNewEvents.html +++ /dev/null @@ -1,410 +0,0 @@ - - - - - - -monthlyViewNewEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    monthlyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[5]/domChild[0]/domChild[2]98,83
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[1]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]38,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]7,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    dragvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[4]
    dropvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[3]125,80
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]10,8
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button6,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item249,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[4]45,85
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]5,9
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button13,18
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item357,9
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]12,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]72,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/27/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/31/99
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]44,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[2]79,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/26/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Desc
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]47,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[2]72,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/30/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/1/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Third test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Testing
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[3]37,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field12/29/99
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Fourth test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Fourth event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/notifications.html b/uitest/src/com/vaadin/tests/components/calendar/notifications.html deleted file mode 100644 index 15bf29a0fd..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/notifications.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    New Test
    open/run/com.vaadin.tests.components.calendar.NotificationTestUI?restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]83,11
    mouseMovevaadin=runcomvaadintestscomponentscalendarNotificationTestUI::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[3]/domChild[0]/domChild[3]10,10
    closeNotification//div[@id='runcomvaadintestscomponentscalendarNotificationTestUI-1842310749-overlays']/div0,0
    screenCaptureno-notification
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html deleted file mode 100644 index 66d2c2f126..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTest1000x600px.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTest1000x600px - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTest1000x600px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=1000px&height=600px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]7,53
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html deleted file mode 100644 index 7c963f547f..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100percentXundefined.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTest100percentXundefined - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTest100percentXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]10,53
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html deleted file mode 100644 index 19f03db784..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTest100x100percent.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTest100x100percent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTest100x100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=100%25&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]12,54
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html deleted file mode 100644 index 70f6dbd75b..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTest300pxXundefined.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTest300pxXundefined - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTest300pxXundefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]11,52
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html deleted file mode 100644 index 59d39226d9..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTestSizeFull.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTestSizeFull - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTestSizeFull
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,56
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html deleted file mode 100644 index d48917904c..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX100percent.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTestUndefinedX100percent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTestUndefinedX100percent
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=100%25
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,53
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html deleted file mode 100644 index 2dfce00635..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedX300px.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTestUndefinedX300px - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTestUndefinedX300px
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&height=300px
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,26
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html b/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html deleted file mode 100644 index 3bfae6be35..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/sizeTestUndefinedXUndefined.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTestUndefinedXUndefined - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTestUndefinedXUndefined
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication&width=&height=
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]8,52
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html b/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html deleted file mode 100644 index a0c6798edb..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/visibleHours24H.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - -visibleHours24H - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    visibleHours24H
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&firstDay=1&lastDay=5&firstHour=8&lastHour=16&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[1]/domChild[0]/domChild[0]9,55
    mouseClick//div[@id='gwt-uid-9']/div7,14
    mouseClick//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[4]/td120,15
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]9:00
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]16:00
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html deleted file mode 100644 index b587288a24..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/weeklyViewNewEvents.html +++ /dev/null @@ -1,657 +0,0 @@ - - - - - - -weeklyViewNewEvents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    weeklyViewNewEvents
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&width=1000px&height=600px&restartApplication
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]3,49
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[48]/domChild[0]/domChild[0]26,5
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/10/00 09:30 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/10/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]off
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Appointment
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]Office
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]A longer description, which should display correctly.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Green
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]/domChild[0]21,12
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[7]/domChild[0]/domChild[48]/domChild[0]/domChild[0]19,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/15/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00 06:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Free time
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[6]/domChild[0]/domChild[0]22,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/9/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/15/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VCheckBox[0]/domChild[0]on
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Description for the whole week event.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[1]78,3
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/12/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Red
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[1]57,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Second allday event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Some description.
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Blue
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 9:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 2:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[1]3,15
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item436,6
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]47,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/13/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/13/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Test event description
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]/domChild[0]Orange
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]8,9
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]/domChild[48]/domChild[0]33,16
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#popupButton10,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1116,11
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#popupButton14,14
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::Root/VOverlay[0]/VCalendarPanel[0]#day1114,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]34,21
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 8:00 PM
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    enterCharactervaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextArea[0]Second test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]7,73
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]12,32
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]11,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[1]4,9
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]14,71
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]16,111
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[48]/domChild[0]14,209
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 10:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 08:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[49]/domChild[0]/domChild[0]20,113
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 11:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 07:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]7,8
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[50]/domChild[0]21,87
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[0]#field1/11/00 09:00 AM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VPopupCalendar[1]#field1/11/00 02:00 PM
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]12,10
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[4]36,10
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[3]53,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Training
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[2]/domChild[0]/domChild[2]/domChild[0]48,7
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Test event 2
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[4]/domChild[0]/domChild[1]50,6
    assertValuevaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]Whole week event
    clickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
    - - -- cgit v1.2.3 From d937722318c47831775d2f0e6c67b0f0f1d57688 Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Thu, 21 Feb 2013 17:04:48 +0200 Subject: Maximize Restore for Window #3400 Change-Id: I164ae83bd6cf98f7a3d7e76d8e717a56e8cb5183 --- WebContent/VAADIN/themes/base/window/window.scss | 27 +- .../VAADIN/themes/reindeer/window/img/maximize.png | Bin 0 -> 270 bytes .../VAADIN/themes/reindeer/window/img/restore.png | Bin 0 -> 328 bytes .../VAADIN/themes/reindeer/window/window.scss | 20 +- WebContent/VAADIN/themes/runo/window/window.scss | 23 +- .../client/ui/AbstractComponentConnector.java | 12 +- client/src/com/vaadin/client/ui/VWindow.java | 94 ++++--- .../vaadin/client/ui/window/WindowConnector.java | 287 +++++++++++++-------- server/src/com/vaadin/ui/Window.java | 147 ++++++++++- .../vaadin/shared/ui/window/WindowServerRpc.java | 6 + .../com/vaadin/shared/ui/window/WindowState.java | 6 + .../window/WindowMaximizeRestoreTest.html | 228 ++++++++++++++++ .../window/WindowMaximizeRestoreTest.java | 165 ++++++++++++ 13 files changed, 857 insertions(+), 158 deletions(-) create mode 100644 WebContent/VAADIN/themes/reindeer/window/img/maximize.png create mode 100644 WebContent/VAADIN/themes/reindeer/window/img/restore.png create mode 100644 uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html create mode 100644 uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java (limited to 'uitest/src') diff --git a/WebContent/VAADIN/themes/base/window/window.scss b/WebContent/VAADIN/themes/base/window/window.scss index b9e7b54139..05f3b115ad 100644 --- a/WebContent/VAADIN/themes/base/window/window.scss +++ b/WebContent/VAADIN/themes/base/window/window.scss @@ -38,6 +38,10 @@ } .#{$primaryStyleName}-header { font-weight: bold; + -khtml-user-select: none; + -moz-user-select: none; + -ie-user-select: none; + user-select: none; } /* A more specific selector to make sure padding isn't so easily overridden */ div.#{$primaryStyleName}-header { @@ -77,20 +81,37 @@ div.#{$primaryStyleName}-header { .#{$primaryStyleName} div.#{$primaryStyleName}-footer-noresize { height: 0; } -.#{$primaryStyleName}-resizebox-disabled { +.#{$primaryStyleName}-resizebox-disabled, +.#{$primaryStyleName}-restorebox-disabled, +.#{$primaryStyleName}-maximizebox-disabled { cursor: default; display: none; } -.#{$primaryStyleName}-closebox { +.#{$primaryStyleName}-closebox, +.#{$primaryStyleName}-restorebox, +.#{$primaryStyleName}-maximizebox { position: absolute; top: 0; right: 0; width: 1em; height: 1em; - background: red; cursor: pointer; overflow: hidden; } +.#{$primaryStyleName}-maximizebox, +.#{$primaryStyleName}-restorebox { + right: 1.1em; +} + +.#{$primaryStyleName}-closebox { + background: red; +} +.#{$primaryStyleName}-maximizebox { + background: blue; +} +.#{$primaryStyleName}-restorebox { + background: yellow; +} .#{$primaryStyleName}-modalitycurtain { top: 0; left: 0; diff --git a/WebContent/VAADIN/themes/reindeer/window/img/maximize.png b/WebContent/VAADIN/themes/reindeer/window/img/maximize.png new file mode 100644 index 0000000000..86ffff9760 Binary files /dev/null and b/WebContent/VAADIN/themes/reindeer/window/img/maximize.png differ diff --git a/WebContent/VAADIN/themes/reindeer/window/img/restore.png b/WebContent/VAADIN/themes/reindeer/window/img/restore.png new file mode 100644 index 0000000000..119ea04259 Binary files /dev/null and b/WebContent/VAADIN/themes/reindeer/window/img/restore.png differ diff --git a/WebContent/VAADIN/themes/reindeer/window/window.scss b/WebContent/VAADIN/themes/reindeer/window/window.scss index e6a73ee2c0..7a05e52aec 100644 --- a/WebContent/VAADIN/themes/reindeer/window/window.scss +++ b/WebContent/VAADIN/themes/reindeer/window/window.scss @@ -14,7 +14,7 @@ border-color: rgba(0,0,0,.2); } .#{$primaryStyleName}-outerheader { - padding: 12px 32px 0 14px; + padding: 12px 52px 0 14px; height: 37px; background: black repeat-x; background-image: url(img/header-bg.png); /** sprite-ref: verticals; sprite-alignment: repeat */ @@ -61,6 +61,24 @@ .#{$primaryStyleName}-closebox:active { background-image: url(img/close-pressed.png); /** sprite-ref: verticals */ } +.#{$primaryStyleName}-maximizebox, +.#{$primaryStyleName}-restorebox { + top: 12px; + right: 28px; + width: 15px; + height: 16px; + background: transparent; +} +.#{$primaryStyleName}-maximizebox { + &, &:hover,&:active { + background-image: url(img/maximize.png); /** sprite-ref: verticals */ + } +} +.#{$primaryStyleName}-restorebox { + &, &:hover,&:active { + background-image: url(img/restore.png); /** sprite-ref: verticals */ + } +} .#{$primaryStyleName}-contents { background: #fff; } diff --git a/WebContent/VAADIN/themes/runo/window/window.scss b/WebContent/VAADIN/themes/runo/window/window.scss index 994238f2ad..db153243e9 100644 --- a/WebContent/VAADIN/themes/runo/window/window.scss +++ b/WebContent/VAADIN/themes/runo/window/window.scss @@ -51,14 +51,33 @@ background: transparent; display: block; } -.#{$primaryStyleName}-closebox { +.#{$primaryStyleName}-closebox, +.#{$primaryStyleName}-maximizebox, +.#{$primaryStyleName}-restorebox { position: absolute; top: 21px; - right: 24px; width: 12px; height: 12px; background: transparent url(img/close.png); } +.#{$primaryStyleName}-closebox { + right: 24px; + background: transparent url(img/close.png); +} + +.#{$primaryStyleName}-maximizebox, +.#{$primaryStyleName}-restorebox { + right: 42px; +} + +.#{$primaryStyleName}-maximizebox { + background: transparent url(img/maximize.png); +} + +.#{$primaryStyleName}-restorebox { + background: transparent url(img/restore.png); +} + .#{$primaryStyleName}-closebox:hover { background-position: 0 -12px; } diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index ecd6abae08..e7f7379994 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -36,6 +36,8 @@ import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Type; import com.vaadin.client.metadata.TypeData; import com.vaadin.client.metadata.TypeDataStore; +import com.vaadin.client.ui.AbstractFieldConnector; +import com.vaadin.client.ui.ManagedLayout; import com.vaadin.client.ui.datefield.PopupDateFieldConnector; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.AbstractComponentState; @@ -205,12 +207,12 @@ public abstract class AbstractComponentConnector extends AbstractConnector } } - private void updateComponentSize() { - Profiler.enter("AbstractComponentConnector.updateComponentSize"); - - String newWidth = getState().width == null ? "" : getState().width; - String newHeight = getState().height == null ? "" : getState().height; + protected void updateComponentSize() { + updateComponentSize(getState().width == null ? "" : getState().width, + getState().height == null ? "" : getState().height); + } + protected void updateComponentSize(String newWidth, String newHeight) { // Parent should be updated if either dimension changed between relative // and non-relative if (newWidth.endsWith("%") != lastKnownWidth.endsWith("%")) { diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index fd2a701334..bd9a0ed07c 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -49,6 +49,7 @@ import com.vaadin.client.LayoutManager; import com.vaadin.client.Util; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.shared.EventId; +import com.vaadin.shared.ui.window.WindowState.DisplayState; /** * "Sub window" component. @@ -58,18 +59,6 @@ import com.vaadin.shared.EventId; public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, ScrollHandler, KeyDownHandler, FocusHandler, BlurHandler, Focusable { - /** - * Minimum allowed height of a window. This refers to the content area, not - * the outer borders. - */ - private static final int MIN_CONTENT_AREA_HEIGHT = 100; - - /** - * Minimum allowed width of a window. This refers to the content area, not - * the outer borders. - */ - private static final int MIN_CONTENT_AREA_WIDTH = 150; - private static ArrayList windowOrder = new ArrayList(); private static boolean orderingDefered; @@ -113,6 +102,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, /** For internal use only. May be removed or replaced in the future. */ public Element closeBox; + /** For internal use only. May be removed or replaced in the future. */ + public Element maximizeRestoreBox; + /** For internal use only. May be removed or replaced in the future. */ public ApplicationConnection client; @@ -262,6 +254,9 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, resizeBox = DOM.createDiv(); DOM.setElementProperty(resizeBox, "className", CLASSNAME + "-resizebox"); closeBox = DOM.createDiv(); + maximizeRestoreBox = DOM.createDiv(); + DOM.setElementProperty(maximizeRestoreBox, "className", CLASSNAME + + "-maximizebox"); DOM.setElementProperty(closeBox, "className", CLASSNAME + "-closebox"); DOM.appendChild(footer, resizeBox); @@ -269,14 +264,15 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, DOM.setElementProperty(wrapper, "className", CLASSNAME + "-wrap"); DOM.appendChild(wrapper, header); + DOM.appendChild(wrapper, maximizeRestoreBox); DOM.appendChild(wrapper, closeBox); DOM.appendChild(header, headerText); DOM.appendChild(wrapper, contents); DOM.appendChild(wrapper, footer); DOM.appendChild(super.getContainerElement(), wrapper); - sinkEvents(Event.MOUSEEVENTS | Event.TOUCHEVENTS | Event.ONCLICK - | Event.ONLOSECAPTURE); + sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS | Event.TOUCHEVENTS + | Event.ONCLICK | Event.ONLOSECAPTURE); setWidget(contentPanel); @@ -575,6 +571,31 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } } + public void updateMaximizeRestoreClassName(boolean visible, + DisplayState state) { + String className; + if (state == DisplayState.MAXIMIZED) { + className = CLASSNAME + "-restorebox"; + } else { + className = CLASSNAME + "-maximizebox"; + } + if (!visible) { + className = className + " " + className + "-disabled"; + } + maximizeRestoreBox.setClassName(className); + } + + // TODO this will eventually be removed, currently used to avoid updating to + // server side. + public void setPopupPositionNoUpdate(int left, int top) { + if (top < 0) { + // ensure window is not moved out of browser window from top of the + // screen + top = 0; + } + super.setPopupPosition(left, top); + } + @Override public void setPopupPosition(int left, int top) { if (top < 0) { @@ -616,6 +637,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, return contents; } + private Event headerDragPending; + @Override public void onBrowserEvent(final Event event) { boolean bubble = true; @@ -632,6 +655,28 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, onCloseClick(); } bubble = false; + } else if (target == maximizeRestoreBox) { + // handled in connector + if (type != Event.ONCLICK) { + bubble = false; + } + } else if (header.isOrHasChild(target) && !dragging) { + // dblclick handled in connector + if (type != Event.ONDBLCLICK && draggable) { + if (type == Event.ONMOUSEDOWN) { + headerDragPending = event; + } else if (type == Event.ONMOUSEMOVE + && headerDragPending != null) { + // ie won't work unless this is set here + dragging = true; + onDragEvent(headerDragPending); + onDragEvent(event); + headerDragPending = null; + } else { + headerDragPending = null; + } + bubble = false; + } } else if (dragging || !contents.isOrHasChild(target)) { onDragEvent(event); bubble = false; @@ -648,7 +693,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, */ if (type == Event.ONMOUSEDOWN && !contentPanel.getElement().isOrHasChild(target) - && target != closeBox) { + && target != closeBox && target != maximizeRestoreBox) { contentPanel.focus(); } @@ -746,16 +791,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } int w = Util.getTouchOrMouseClientX(event) - startX + origW; - int minWidth = getMinWidth(); - if (w < minWidth) { - w = minWidth; - } - int h = Util.getTouchOrMouseClientY(event) - startY + origH; - int minHeight = getMinHeight(); - if (h < minHeight) { - h = minHeight; - } setWidth(w + "px"); setHeight(h + "px"); @@ -775,7 +811,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, } } - private void updateContentsSize() { + public void updateContentsSize() { LayoutManager layoutManager = getLayoutManager(); layoutManager.setNeedsMeasure(ConnectorMap.get(client).getConnector( this)); @@ -959,10 +995,6 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, contentPanel.focus(); } - public int getMinHeight() { - return MIN_CONTENT_AREA_HEIGHT + getDecorationHeight(); - } - private int getDecorationHeight() { LayoutManager lm = getLayoutManager(); int headerHeight = lm.getOuterHeight(header); @@ -974,10 +1006,6 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, return LayoutManager.get(client); } - public int getMinWidth() { - return MIN_CONTENT_AREA_WIDTH + getDecorationWidth(); - } - private int getDecorationWidth() { LayoutManager layoutManager = getLayoutManager(); return layoutManager.getOuterWidth(getElement()) diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java index 8cfc25a9dc..66907fbfa4 100644 --- a/client/src/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java @@ -20,7 +20,10 @@ import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.user.client.DOM; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.DoubleClickEvent; +import com.google.gwt.event.dom.client.DoubleClickHandler; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; import com.vaadin.client.ApplicationConnection; @@ -31,6 +34,7 @@ import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.Util; +import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractSingleComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.PostLayoutListener; @@ -43,6 +47,7 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; +import com.vaadin.shared.ui.window.WindowState.DisplayState; @Connect(value = com.vaadin.ui.Window.class) public class WindowConnector extends AbstractSingleComponentContainerConnector @@ -57,7 +62,32 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector } }; - boolean minWidthChecked = false; + abstract class WindowEventHandler implements ClickHandler, + DoubleClickHandler { + } + + private WindowEventHandler maximizeRestoreClickHandler = new WindowEventHandler() { + + @Override + public void onClick(ClickEvent event) { + final Element target = event.getNativeEvent().getEventTarget() + .cast(); + if (target == getWidget().maximizeRestoreBox) { + // Click on maximize/restore box + onMaximizeRestore(); + } + } + + @Override + public void onDoubleClick(DoubleClickEvent event) { + final Element target = event.getNativeEvent().getEventTarget() + .cast(); + if (getWidget().header.isOrHasChild(target)) { + // Double click on header + onMaximizeRestore(); + } + } + }; @Override public boolean delegateCaptionHandling() { @@ -68,12 +98,18 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector protected void init() { super.init(); + VWindow window = getWidget(); + getLayoutManager().registerDependency(this, - getWidget().contentPanel.getElement()); - getLayoutManager().registerDependency(this, getWidget().header); - getLayoutManager().registerDependency(this, getWidget().footer); + window.contentPanel.getElement()); + getLayoutManager().registerDependency(this, window.header); + getLayoutManager().registerDependency(this, window.footer); - getWidget().setOwner(getConnection().getUIConnector().getWidget()); + window.addHandler(maximizeRestoreClickHandler, ClickEvent.getType()); + window.addHandler(maximizeRestoreClickHandler, + DoubleClickEvent.getType()); + + window.setOwner(getConnection().getUIConnector().getWidget()); } @Override @@ -87,109 +123,46 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - getWidget().id = getConnectorId(); - getWidget().client = client; - - // Workaround needed for Testing Tools (GWT generates window DOM - // slightly different in different browsers). - DOM.setElementProperty(getWidget().closeBox, "id", getConnectorId() - + "_window_close"); - if (isRealUpdate(uidl)) { - if (getState().modal != getWidget().vaadinModality) { - getWidget().setVaadinModality(!getWidget().vaadinModality); - } - if (!getWidget().isAttached()) { - getWidget().setVisible(false); // hide until - // possible centering - getWidget().show(); - } - if (getState().resizable != getWidget().resizable) { - getWidget().setResizable(getState().resizable); - } - getWidget().resizeLazy = getState().resizeLazy; + VWindow window = getWidget(); + String connectorId = getConnectorId(); - getWidget().setDraggable(getState().draggable); + window.id = getConnectorId(); + window.client = client; - // Caption must be set before required header size is measured. If - // the caption attribute is missing the caption should be cleared. - String iconURL = null; - if (getIcon() != null) { - iconURL = getIcon(); - } - getWidget().setCaption(getState().caption, iconURL); - } + // Workaround needed for Testing Tools (GWT generates window DOM + // slightly different in different browsers). + window.closeBox.setId(connectorId + "_window_close"); + window.maximizeRestoreBox + .setId(connectorId + "_window_maximizerestore"); - getWidget().visibilityChangesDisabled = true; + window.visibilityChangesDisabled = true; if (!isRealUpdate(uidl)) { return; } - getWidget().visibilityChangesDisabled = false; - - clickEventHandler.handleEventHandlerRegistration(); - - getWidget().immediate = getState().immediate; - - getWidget().setClosable(!isReadOnly()); - - // Initialize the position form UIDL - int positionx = getState().positionX; - int positiony = getState().positionY; - if (positionx >= 0 || positiony >= 0) { - if (positionx < 0) { - positionx = 0; - } - if (positiony < 0) { - positiony = 0; - } - getWidget().setPopupPosition(positionx, positiony); - } - - int childIndex = 0; + window.visibilityChangesDisabled = false; // we may have actions for (int i = 0; i < uidl.getChildCount(); i++) { UIDL childUidl = uidl.getChildUIDL(i); if (childUidl.getTag().equals("actions")) { - if (getWidget().shortcutHandler == null) { - getWidget().shortcutHandler = new ShortcutActionHandler( - getConnectorId(), client); + if (window.shortcutHandler == null) { + window.shortcutHandler = new ShortcutActionHandler( + connectorId, client); } - getWidget().shortcutHandler.updateActionMap(childUidl); + window.shortcutHandler.updateActionMap(childUidl); } } - // setting scrollposition must happen after children is rendered - getWidget().contentPanel.setScrollPosition(getState().scrollTop); - getWidget().contentPanel - .setHorizontalScrollPosition(getState().scrollLeft); - - // Center this window on screen if requested - // This had to be here because we might not know the content size before - // everything is painted into the window - - // centered is this is unset on move/resize - getWidget().centered = getState().centered; - getWidget().setVisible(true); - - // ensure window is not larger than browser window - if (getWidget().getOffsetWidth() > Window.getClientWidth()) { - getWidget().setWidth(Window.getClientWidth() + "px"); - } - if (getWidget().getOffsetHeight() > Window.getClientHeight()) { - getWidget().setHeight(Window.getClientHeight() + "px"); - } - if (uidl.hasAttribute("bringToFront")) { /* * Focus as a side-effect. Will be overridden by * ApplicationConnection if another component was focused by the * server side. */ - getWidget().contentPanel.focus(); - getWidget().bringToFrontSequence = uidl - .getIntAttribute("bringToFront"); + window.contentPanel.focus(); + window.bringToFrontSequence = uidl.getIntAttribute("bringToFront"); VWindow.deferOrdering(); } } @@ -224,26 +197,6 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector boolean hasContent = (content != null); Element contentElement = window.contentPanel.getElement(); - if (!minWidthChecked) { - boolean needsMinWidth = !isUndefinedWidth() || !hasContent - || content.isRelativeWidth(); - int minWidth = window.getMinWidth(); - if (needsMinWidth && lm.getInnerWidth(contentElement) < minWidth) { - minWidthChecked = true; - // Use minimum width if less than a certain size - window.setWidth(minWidth + "px"); - } - minWidthChecked = true; - } - - boolean needsMinHeight = !isUndefinedHeight() || !hasContent - || content.isRelativeHeight(); - int minHeight = window.getMinHeight(); - if (needsMinHeight && lm.getInnerHeight(contentElement) < minHeight) { - // Use minimum height if less than a certain size - window.setHeight(minHeight + "px"); - } - Style contentStyle = window.contents.getStyle(); int headerHeight = lm.getOuterHeight(window.header); @@ -291,9 +244,9 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector @Override public void postLayout() { - minWidthChecked = false; VWindow window = getWidget(); - if (window.centered) { + if (window.centered + && getState().displayState != DisplayState.MAXIMIZED) { window.center(); } window.positionOrSizeUpdated(); @@ -304,6 +257,124 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector return (WindowState) super.getState(); } + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + VWindow window = getWidget(); + WindowState state = getState(); + + if (state.modal != window.vaadinModality) { + window.setVaadinModality(!window.vaadinModality); + } + if (!window.isAttached()) { + window.setVisible(false); // hide until possible centering + window.show(); + } + boolean resizeable = state.resizable + && state.displayState == DisplayState.NORMAL; + window.setResizable(resizeable); + + window.resizeLazy = state.resizeLazy; + + window.setDraggable(state.draggable + && state.displayState == DisplayState.NORMAL); + + window.updateMaximizeRestoreClassName(state.resizable, + state.displayState); + + // Caption must be set before required header size is measured. If + // the caption attribute is missing the caption should be cleared. + String iconURL = null; + if (getIcon() != null) { + iconURL = getIcon(); + } + window.setCaption(state.caption, iconURL); + + clickEventHandler.handleEventHandlerRegistration(); + + window.immediate = state.immediate; + + window.setClosable(!isReadOnly()); + // initialize position from state + updateWindowPosition(); + + // setting scrollposition must happen after children is rendered + window.contentPanel.setScrollPosition(state.scrollTop); + window.contentPanel.setHorizontalScrollPosition(state.scrollLeft); + + // Center this window on screen if requested + // This had to be here because we might not know the content size before + // everything is painted into the window + + // centered is this is unset on move/resize + window.centered = state.centered; + window.setVisible(true); + + // ensure window is not larger than browser window + if (window.getOffsetWidth() > Window.getClientWidth()) { + window.setWidth(Window.getClientWidth() + "px"); + } + if (window.getOffsetHeight() > Window.getClientHeight()) { + window.setHeight(Window.getClientHeight() + "px"); + } + } + + // Need to override default because of DisplayState + @Override + protected void updateComponentSize() { + if (getState().displayState == DisplayState.NORMAL) { + super.updateComponentSize(); + } else if (getState().displayState == DisplayState.MAXIMIZED) { + super.updateComponentSize("100%", "100%"); + } + } + + protected void updateWindowPosition() { + VWindow window = getWidget(); + WindowState state = getState(); + if (state.displayState == DisplayState.NORMAL) { + // if centered, position handled in postLayout() + if (!state.centered) { + window.setPopupPosition(state.positionX, state.positionY); + } + } else if (state.displayState == DisplayState.MAXIMIZED) { + window.setPopupPositionNoUpdate(0, 0); + window.bringToFront(); + } + } + + protected void updateDisplayState() { + VWindow window = getWidget(); + WindowState state = getState(); + + // update draggable on widget + window.setDraggable(state.draggable + && state.displayState == DisplayState.NORMAL); + // update resizable on widget + window.setResizable(state.resizable + && state.displayState == DisplayState.NORMAL); + updateComponentSize(); + updateWindowPosition(); + window.updateMaximizeRestoreClassName(state.resizable, + state.displayState); + window.updateContentsSize(); + } + + protected void onMaximizeRestore() { + WindowState state = getState(); + if (state.resizable) { + if (state.displayState == DisplayState.MAXIMIZED) { + state.displayState = DisplayState.NORMAL; + } else { + state.displayState = DisplayState.MAXIMIZED; + } + updateDisplayState(); + getRpcProxy(WindowServerRpc.class).windowDisplayStateChanged( + state.displayState); + } + } + /** * Gives the WindowConnector an order number. As a side effect, moves the * window according to its order number so the windows are stacked. This diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index d8b33e6b25..0c1509663a 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -37,6 +37,8 @@ import com.vaadin.server.PaintTarget; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; +import com.vaadin.shared.ui.window.WindowState.DisplayState; +import com.vaadin.util.ReflectTools; /** * A component that represents a floating popup window that can be added to a @@ -71,6 +73,11 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(Window.this, mouseDetails)); } + + @Override + public void windowDisplayStateChanged(DisplayState newState) { + setDisplayState(newState); + } }; /** @@ -234,10 +241,11 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /** * Gets the distance of Window left border in pixels from left border of the - * containing (main window). + * containing (main window) when the window is in + * {@link DisplayState#NORMAL}. * * @return the Distance of Window left border in pixels from left border of - * the containing (main window). or -1 if unspecified. + * the containing (main window).or -1 if unspecified * @since 4.0.0 */ public int getPositionX() { @@ -246,7 +254,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /** * Sets the distance of Window left border in pixels from left border of the - * containing (main window). + * containing (main window). Has effect only if in + * {@link DisplayState#NORMAL} mode. * * @param positionX * the Distance of Window left border in pixels from left border @@ -260,10 +269,11 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /** * Gets the distance of Window top border in pixels from top border of the - * containing (main window). + * containing (main window) when the window is in + * {@link DisplayState#NORMAL} state, or when next set to that state. * * @return Distance of Window top border in pixels from top border of the - * containing (main window). or -1 if unspecified . + * containing (main window). or -1 if unspecified * * @since 4.0.0 */ @@ -273,7 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /** * Sets the distance of Window top border in pixels from top border of the - * containing (main window). + * containing (main window). Has effect only if in + * {@link DisplayState#NORMAL} mode. * * @param positionY * the Distance of Window top border in pixels from top border of @@ -401,6 +412,104 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, fireEvent(new Window.CloseEvent(this)); } + /** + * Event which is fired when the display state of the Window changes. + * + * @author Vaadin Ltd + * @since 7.1 + * + */ + public static class DisplayStateChangeEvent extends Component.Event { + + private final DisplayState displayState; + + /** + * + * @param source + */ + public DisplayStateChangeEvent(Component source, + DisplayState displayState) { + super(source); + this.displayState = displayState; + } + + /** + * Gets the Window. + * + * @return the window + */ + public Window getWindow() { + return (Window) getSource(); + } + + /** + * Gets the new DisplayState. + * + * @return the displayState + */ + public DisplayState getDisplayState() { + return displayState; + } + } + + /** + * An interface used for listening to Window maximize / restore events. Add + * the DisplayStateChangeListener to a window and + * {@link DisplayStateChangeListener#displayStateChanged(DisplayStateChangeEvent)} + * will be called whenever the window is maximized ( + * {@link DisplayState#MAXIMIZED}) or restored ({@link DisplayState#NORMAL} + * ). + */ + public interface DisplayStateChangeListener extends Serializable { + + public static final Method displayStateChangeMethod = ReflectTools + .findMethod(DisplayStateChangeListener.class, + "displayStateChanged", DisplayStateChangeEvent.class); + + /** + * Called when the user maximizes / restores a window. Use + * {@link DisplayStateChangeEvent#getWindow()} to get a reference to the + * {@link Window} that was maximized / restored. Use + * {@link DisplayStateChangeEvent#getDisplayState()} to get a reference + * to the new state. + * + * @param event + */ + public void displayStateChanged(DisplayStateChangeEvent event); + } + + /** + * Adds a DisplayStateChangeListener to the window. + * + * The DisplayStateChangeEvent is fired when the user changed the display + * state by clicking the maximize/restore button or by double clicking on + * the window header. The event is also fired if the state is changed using + * {@link #setDisplayState(DisplayState)}. + * + * @param listener + * the DisplayStateChangeListener to add. + */ + public void addDisplayStateChangeListener(DisplayStateChangeListener listener) { + addListener(DisplayStateChangeEvent.class, listener, + DisplayStateChangeListener.displayStateChangeMethod); + } + + /** + * Removes the DisplayStateChangeListener from the window. + * + * @param listener + * the DisplayStateChangeListener to remove. + */ + public void removeDisplayStateChangeListener(DisplayStateChangeListener listener) { + removeListener(DisplayStateChangeEvent.class, listener, + DisplayStateChangeListener.displayStateChangeMethod); + } + + protected void fireWindowDisplayStateChange() { + fireEvent(new Window.DisplayStateChangeEvent(this, + getState().displayState)); + } + /** * Method for the resize event. */ @@ -670,6 +779,27 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, getState().draggable = draggable; } + /** + * Gets the current DisplayState of the window. + * + * @return displayState the current DisplayState. + */ + public DisplayState getDisplayState() { + return getState(false).displayState; + } + + /** + * Sets the DisplayState for the window. + * + * @param displayState + */ + public void setDisplayState(DisplayState displayState) { + if (displayState != getDisplayState()) { + getState().displayState = displayState; + fireWindowDisplayStateChange(); + } + } + /* * Actions */ @@ -873,4 +1003,9 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, protected WindowState getState() { return (WindowState) super.getState(); } + + @Override + protected WindowState getState(boolean markAsDirty) { + return (WindowState) super.getState(markAsDirty); + } } diff --git a/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java index c42f91c006..0128adca40 100644 --- a/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java @@ -15,8 +15,14 @@ */ package com.vaadin.shared.ui.window; +import com.vaadin.shared.annotations.Delayed; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.ClickRpc; +import com.vaadin.shared.ui.window.WindowState.DisplayState; public interface WindowServerRpc extends ClickRpc, ServerRpc { + + @Delayed(lastOnly = true) + public void windowDisplayStateChanged(DisplayState newState); + } \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/window/WindowState.java b/shared/src/com/vaadin/shared/ui/window/WindowState.java index 4afc20f2b1..eb6f1c758a 100644 --- a/shared/src/com/vaadin/shared/ui/window/WindowState.java +++ b/shared/src/com/vaadin/shared/ui/window/WindowState.java @@ -21,6 +21,11 @@ public class WindowState extends PanelState { { primaryStyleName = "v-window"; } + + public enum DisplayState { + NORMAL, MAXIMIZED; + } + public boolean modal = false; public boolean resizable = true; public boolean resizeLazy = false; @@ -28,4 +33,5 @@ public class WindowState extends PanelState { public boolean centered = false;; public int positionX = -1; public int positionY = -1; + public DisplayState displayState = DisplayState.NORMAL; } \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html new file mode 100644 index 0000000000..090579d81d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html @@ -0,0 +1,228 @@ + + + + + + +WindowMaximizeRestoreTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    WindowMaximizeRestoreTest
    open/run/com.vaadin.tests.components.window.WindowMaximizeRestoreTest?restartApplication
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    assertTextvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Window 1
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]7,8
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-restorebox
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]9,7
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    doubleClickAtvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-restorebox
    doubleClickAtvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    assertVisiblevaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]8,3
    assertNotVisiblevaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]34,6
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-restorebox
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]34,6
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    doubleClickAtvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    doubleClickAtvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
    assertCSSClassvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]v-window-maximizebox
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]8,3
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[4]/VNativeButton[0]26,9
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
    screenCapturewindow-2-original-pos-window-1-centered
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]10,8
    screenCapturewindow-1-maximized-on-top-of-window-2
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VNativeButton[0]43,12
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[3]/VNativeButton[0]100,9
    screenCapturewindow-2-original-pos-window-1-centered
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[1]6,11
    screenCapturewindow-2-maximized-on-top-of-window-1
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[2]7,5
    screenCapturewindow-2-closed-window-1-centered
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VFilterSelect[0]/domChild[1]1,17
    mouseClick//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[2]/td122,6
    screenCapturewindow-2-added-maximized-on-top-of-window-1
    mouseClickvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[1]6,11
    doubleClickAtvaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]113,10
    screenCapturewindow-1-maximized-with-doubleclick
    + + diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java new file mode 100644 index 0000000000..fe45b036a1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java @@ -0,0 +1,165 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.data.Item; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.window.WindowState.DisplayState; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.ComponentContainer; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; +import com.vaadin.ui.Window.CloseEvent; +import com.vaadin.ui.Window.CloseListener; +import com.vaadin.ui.Window.DisplayStateChangeEvent; +import com.vaadin.ui.Window.DisplayStateChangeListener; + +public class WindowMaximizeRestoreTest extends AbstractTestUI { + Button.ClickListener addListener = new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + addWindow(createNewWindow()); + } + }; + + @Override + protected void setup(VaadinRequest request) { + Button addButton = new Button("Add new Window"); + addButton.addListener(addListener); + addComponent(addButton); + + addWindowAgain = new ComboBox("Add Window Again"); + addWindowAgain.setBuffered(false); + addWindowAgain.setImmediate(true); + addWindowAgain.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + Object value = event.getProperty().getValue(); + if (value != null && value instanceof Window) { + UI.getCurrent().addWindow((Window) value); + addWindowAgain.removeItem(value); + } + } + }); + addComponent(addWindowAgain); + + addWindow(createNewWindow()); + } + + private int windowCount = 0; + private ComboBox addWindowAgain; + + private Window createNewWindow() { + final Window w = new Window("Window " + (++windowCount)); + final VerticalLayout content = new VerticalLayout(); + w.setContent(content); + w.setData(windowCount); + w.setWidth("200px"); + w.setHeight("300px"); + w.setPositionX(200); + w.setPositionY(200); + final NativeButton maximize = new NativeButton("Maximize"); + Button.ClickListener listener = new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (w.getDisplayState() == DisplayState.MAXIMIZED) { + w.setDisplayState(DisplayState.NORMAL); + maximize.setCaption("Maximize"); + } else { + w.setDisplayState(DisplayState.MAXIMIZED); + maximize.setCaption("Restore"); + } + } + + }; + maximize.addClickListener(listener); + ((ComponentContainer) w.getContent()).addComponent(maximize); + + w.addDisplayStateChangeListener(new DisplayStateChangeListener() { + + @Override + public void displayStateChanged(DisplayStateChangeEvent event) { + DisplayState state = (event.getWindow().getDisplayState()); + if (state == DisplayState.NORMAL) { + w.setCaption("Window " + w.getData() + " Normal"); + maximize.setCaption("Maximize"); + } else if (state == DisplayState.MAXIMIZED) { + w.setCaption("Window " + w.getData() + " Maximized"); + maximize.setCaption("Restore"); + } + } + }); + final CheckBox resizeable = new CheckBox("Resizeable"); + resizeable.setValue(w.isResizable()); + resizeable.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + w.setResizable(resizeable.getValue()); + } + }); + ((ComponentContainer) w.getContent()).addComponent(resizeable); + final CheckBox closeable = new CheckBox("Closeable"); + closeable.setValue(w.isClosable()); + closeable.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + w.setClosable(closeable.getValue()); + } + }); + ((ComponentContainer) w.getContent()).addComponent(closeable); + NativeButton contentFull = new NativeButton("Set Content Size Full", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + w.getContent().setSizeFull(); + } + }); + contentFull.setWidth("100%"); + ((ComponentContainer) w.getContent()).addComponent(contentFull); + + NativeButton center = new NativeButton("Center"); + center.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + w.center(); + } + }); + ((ComponentContainer) w.getContent()).addComponent(center); + + w.addCloseListener(new CloseListener() { + + @Override + public void windowClose(CloseEvent e) { + Item item = addWindowAgain.addItem(w); + addWindowAgain.setItemCaption(w, "Window " + + w.getData().toString()); + } + }); + + return w; + } + + @Override + protected Integer getTicketNumber() { + return 3400; + } + + @Override + protected String getTestDescription() { + return "Tests the default maximize & restore funtionality. Max. makes window 100%*100% and pos(0, 0), and restore returns it to the values that are set in windows state."; + } +} -- cgit v1.2.3 From f980667fdfef13bcb3bfcd7e86910bed39f39bb2 Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Thu, 21 Mar 2013 10:40:45 +0200 Subject: WAI-ARIA functions for Tree (#11389) All to navigate the tree with an assisitve device Change-Id: I531cefc95d7a720caf69aca579549e5a497ad586 --- client/src/com/vaadin/client/ui/VContextMenu.java | 2 + client/src/com/vaadin/client/ui/VTree.java | 63 ++++++++++- .../com/vaadin/client/ui/tree/TreeConnector.java | 7 +- server/src/com/vaadin/ui/Tree.java | 51 +++++++++ .../com/vaadin/shared/ui/tree/TreeConstants.java | 2 + .../vaadin/tests/components/tree/SimpleTree.java | 122 +++++++++++++++++++++ 6 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tree/SimpleTree.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/VContextMenu.java b/client/src/com/vaadin/client/ui/VContextMenu.java index 80751652df..e601c8027a 100644 --- a/client/src/com/vaadin/client/ui/VContextMenu.java +++ b/client/src/com/vaadin/client/ui/VContextMenu.java @@ -37,6 +37,7 @@ import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.MenuBar; @@ -75,6 +76,7 @@ public class VContextMenu extends VOverlay implements SubPartAware { super(true, false, true); setWidget(menu); setStyleName("v-contextmenu"); + getElement().setId(DOM.createUniqueId()); } protected void imagesLoaded() { diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java index 624dce4f13..20b3050a5d 100644 --- a/client/src/com/vaadin/client/ui/VTree.java +++ b/client/src/com/vaadin/client/ui/VTree.java @@ -24,6 +24,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import com.google.gwt.aria.client.ExpandedValue; +import com.google.gwt.aria.client.Id; +import com.google.gwt.aria.client.Roles; +import com.google.gwt.aria.client.SelectedValue; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; @@ -75,7 +79,8 @@ import com.vaadin.shared.ui.tree.TreeConstants; */ public class VTree extends FocusElementPanel implements VHasDropHandler, FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler, - SubPartAware, ActionOwner { + SubPartAware, ActionOwner, HandlesAriaCaption { + private String lastNodeKey = ""; public static final String CLASSNAME = "v-tree"; @@ -168,6 +173,8 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, public VTree() { super(); setStyleName(CLASSNAME); + + Roles.getTreeRole().set(body.getElement()); add(body); addFocusHandler(this); @@ -865,12 +872,22 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, } protected void constructDom() { + String labelId = DOM.createUniqueId(); + addStyleName(CLASSNAME); + getElement().setId(DOM.createUniqueId()); + Roles.getTreeitemRole().set(getElement()); + Roles.getTreeitemRole().setAriaSelectedState(getElement(), + SelectedValue.FALSE); + Roles.getTreeitemRole().setAriaLabelledbyProperty(getElement(), + Id.of(labelId)); nodeCaptionDiv = DOM.createDiv(); DOM.setElementProperty(nodeCaptionDiv, "className", CLASSNAME + "-caption"); Element wrapper = DOM.createDiv(); + wrapper.setId(labelId); + nodeCaptionSpan = DOM.createSpan(); DOM.appendChild(getElement(), nodeCaptionDiv); DOM.appendChild(nodeCaptionDiv, wrapper); @@ -886,6 +903,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, childNodeContainer = new FlowPanel(); childNodeContainer.setStyleName(CLASSNAME + "-children"); + Roles.getGroupRole().set(childNodeContainer.getElement()); setWidget(childNodeContainer); } @@ -914,10 +932,13 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, new String[] { key }, true); } addStyleName(CLASSNAME + "-expanded"); + Roles.getTreeitemRole().setAriaExpandedState(getElement(), + ExpandedValue.TRUE); childNodeContainer.setVisible(true); - } else { removeStyleName(CLASSNAME + "-expanded"); + Roles.getTreeitemRole().setAriaExpandedState(getElement(), + ExpandedValue.FALSE); childNodeContainer.setVisible(false); if (notifyServer) { client.updateVariable(paintableId, "collapse", @@ -1094,15 +1115,17 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, Util.scrollIntoViewVertically(nodeCaptionDiv); } - public void setIcon(String iconUrl) { + public void setIcon(String iconUrl, String altText) { if (iconUrl != null) { // Add icon if not present if (icon == null) { icon = new Icon(client); + Roles.getImgRole().set(icon.getElement()); DOM.insertBefore(DOM.getFirstChild(nodeCaptionDiv), icon.getElement(), nodeCaptionSpan); } icon.setUri(iconUrl); + icon.getElement().setAttribute("alt", altText); } else { // Remove icon if present if (icon != null) { @@ -1517,10 +1540,34 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, // Unfocus previously focused node if (focusedNode != null) { focusedNode.setFocused(false); + + Roles.getTreeRole().removeAriaActivedescendantProperty( + focusedNode.getElement()); } if (node != null) { node.setFocused(true); + Roles.getTreeitemRole().setAriaSelectedState(node.getElement(), + SelectedValue.TRUE); + + /* + * FIXME: This code needs to be changed when the keyboard navigation + * doesn't immediately trigger a selection change anymore. + * + * Right now this function is called before and after the Tree is + * rebuilt when up/down arrow keys are pressed. This leads to the + * problem, that the newly selected item is announced too often with + * a screen reader. + * + * Behaviour is different when using the Tree with and without + * screen reader. + */ + if (node.key.equals(lastNodeKey)) { + Roles.getTreeRole().setAriaActivedescendantProperty( + getFocusElement(), Id.of(node.getElement())); + } else { + lastNodeKey = node.key; + } } focusedNode = node; @@ -2161,4 +2208,14 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, keyToNode.clear(); } + @Override + public void bindAriaCaption(Element captionElement) { + AriaHelper.bindCaption(body, captionElement); + } + + @Override + public void clearAriaCaption() { + AriaHelper.clearCaption(body); + } + } diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index 6e3fffb47c..d8ad7d6634 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -262,8 +262,11 @@ public class TreeConnector extends AbstractComponentConnector implements getWidget().selectedIds.add(nodeKey); } - treeNode.setIcon(uidl - .getStringAttribute(TreeConstants.ATTRIBUTE_NODE_ICON)); + String iconUrl = uidl + .getStringAttribute(TreeConstants.ATTRIBUTE_NODE_ICON); + String iconAltText = uidl + .getStringAttribute(TreeConstants.ATTRIBUTE_NODE_ICON_ALT); + treeNode.setIcon(iconUrl, iconAltText); } void renderChildNodes(TreeNode containerNode, Iterator i, int level) { diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index 34cfbaf61b..700195cd4b 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -72,6 +72,11 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, /* Private members */ + /** + * Item icons alt texts. + */ + private final HashMap itemIconAlts = new HashMap(); + /** * Set of expanded nodes. */ @@ -163,6 +168,50 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, super(caption, dataSource); } + @Override + public void setItemIcon(Object itemId, Resource icon) { + setItemIcon(itemId, icon, ""); + } + + /** + * Sets the icon for an item. + * + * @param itemId + * the id of the item to be assigned an icon. + * @param icon + * the icon to use or null. + * + * @param altText + * String with the alternative text for the icon + */ + public void setItemIcon(Object itemId, Resource icon, String altText) { + if (itemId != null) { + super.setItemIcon(itemId, icon); + + if (icon == null) { + itemIconAlts.remove(itemId); + } else if (altText == null) { + throw new IllegalArgumentException( + "Parameter 'altText' needs to be non null"); + } else { + itemIconAlts.put(itemId, altText); + } + markAsDirty(); + } + } + + /** + * Return the alternate text of an icon in a tree item. + * + * @param itemId + * Object with the ID of the item + * @return String with the alternate text of the icon, or null when no icon + * was set + */ + public String getItemIconAlternateText(Object itemId) { + return itemIconAlts.get(itemId); + } + /* Expanding and collapsing */ /** @@ -638,6 +687,8 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (icon != null) { target.addAttribute(TreeConstants.ATTRIBUTE_NODE_ICON, getItemIcon(itemId)); + target.addAttribute(TreeConstants.ATTRIBUTE_NODE_ICON_ALT, + getItemIconAlternateText(itemId)); } final String key = itemIdMapper.key(itemId); target.addAttribute("key", key); diff --git a/shared/src/com/vaadin/shared/ui/tree/TreeConstants.java b/shared/src/com/vaadin/shared/ui/tree/TreeConstants.java index 7adc69511d..a57ca31246 100644 --- a/shared/src/com/vaadin/shared/ui/tree/TreeConstants.java +++ b/shared/src/com/vaadin/shared/ui/tree/TreeConstants.java @@ -26,6 +26,8 @@ public class TreeConstants implements Serializable { public static final String ATTRIBUTE_NODE_CAPTION = "caption"; @Deprecated public static final String ATTRIBUTE_NODE_ICON = "icon"; + @Deprecated + public static final String ATTRIBUTE_NODE_ICON_ALT = "iconalt"; @Deprecated public static final String ATTRIBUTE_ACTION_CAPTION = "caption"; diff --git a/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java b/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java new file mode 100644 index 0000000000..2fd3f05dbb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java @@ -0,0 +1,122 @@ +package com.vaadin.tests.components.tree; + +import java.util.Date; + +import com.vaadin.data.Item; +import com.vaadin.data.util.HierarchicalContainer; +import com.vaadin.event.Action; +import com.vaadin.server.ThemeResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.Tree; + +public class SimpleTree extends TestBase implements Action.Handler { + private static final String[][] hardware = { // + { "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260", + "Dell OptiPlex GX280" }, + { "Monitors", "Benq T190HD", "Benq T220HD", "Benq T240HD" }, + { "Laptops", "IBM ThinkPad T40", "IBM ThinkPad T43", + "IBM ThinkPad T60" } }; + + ThemeResource notCachedFolderIconLargeOther = new ThemeResource( + "../runo/icons/16/ok.png?" + new Date().getTime()); + ThemeResource notCachedFolderIconLarge = new ThemeResource( + "../runo/icons/16/folder.png?" + new Date().getTime()); + + // Actions for the context menu + private static final Action ACTION_ADD = new Action("Add child item"); + private static final Action ACTION_DELETE = new Action("Delete"); + private static final Action[] ACTIONS = new Action[] { ACTION_ADD, + ACTION_DELETE }; + + private Tree tree; + + @Override + public void setup() { + // Create the Tree,a dd to layout + tree = new Tree("Hardware Inventory"); + addComponent(tree); + + // Contents from a (prefilled example) hierarchical container: + tree.setContainerDataSource(getHardwareContainer()); + + // Add actions (context menu) + tree.addActionHandler(this); + + // Cause valueChange immediately when the user selects + tree.setImmediate(true); + + // Set tree to show the 'name' property as caption for items + tree.setItemCaptionPropertyId("name"); + tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY); + + tree.setItemIcon(9, notCachedFolderIconLargeOther, "First Choice"); + tree.setItemIcon(11, notCachedFolderIconLarge); + + // Expand whole tree + for (Object id : tree.rootItemIds()) { + tree.expandItemsRecursively(id); + } + } + + public static HierarchicalContainer getHardwareContainer() { + Item item = null; + int itemId = 0; // Increasing numbering for itemId:s + + // Create new container + HierarchicalContainer hwContainer = new HierarchicalContainer(); + // Create containerproperty for name + hwContainer.addContainerProperty("name", String.class, null); + // Create containerproperty for icon + hwContainer.addContainerProperty("icon", ThemeResource.class, + new ThemeResource("../runo/icons/16/document.png")); + for (int i = 0; i < hardware.length; i++) { + // Add new item + item = hwContainer.addItem(itemId); + // Add name property for item + item.getItemProperty("name").setValue(hardware[i][0]); + // Allow children + hwContainer.setChildrenAllowed(itemId, true); + itemId++; + for (int j = 1; j < hardware[i].length; j++) { + if (j == 1) { + item.getItemProperty("icon").setValue( + new ThemeResource("../runo/icons/16/folder.png")); + } + + // Add child items + item = hwContainer.addItem(itemId); + item.getItemProperty("name").setValue(hardware[i][j]); + hwContainer.setParent(itemId, itemId - j); + + hwContainer.setChildrenAllowed(itemId, false); + if (j == 2) { + hwContainer.setChildrenAllowed(itemId, true); + } + + itemId++; + } + } + return hwContainer; + } + + @Override + protected String getDescription() { + return "Sample Tree for testing WAI-ARIA functionality"; + } + + @Override + protected Integer getTicketNumber() { + return 0; + } + + @Override + public Action[] getActions(Object target, Object sender) { + return ACTIONS; + } + + @Override + public void handleAction(Action action, Object sender, Object target) { + System.out.println("Action: " + action.getCaption()); + } +} \ No newline at end of file -- cgit v1.2.3 From c926a09f54cd08856c8cd7a15fd00cf0b62b63b5 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 5 Apr 2013 16:53:19 +0300 Subject: Global code reformat Change-Id: I4b3c74ede518aa2712038d1451974a93cdecabc2 --- .../themeutils/SASSAddonImportFileCreator.java | 7 +- .../server/widgetsetutils/ClassPathExplorer.java | 7 +- client/src/com/vaadin/client/ComponentLocator.java | 6 +- .../client/ConnectorHierarchyChangeEvent.java | 10 +- .../com/vaadin/client/HasComponentsConnector.java | 1 + client/src/com/vaadin/client/Util.java | 1 - .../client/debug/internal/HierarchySection.java | 1 + .../client/debug/internal/NetworkSection.java | 1 + .../JavaScriptManagerConnector.java | 2 +- .../client/ui/AbstractComponentConnector.java | 2 - .../com/vaadin/client/ui/AbstractConnector.java | 1 + .../client/ui/AbstractHasComponentsConnector.java | 2 +- .../src/com/vaadin/client/ui/VAbsoluteLayout.java | 8 +- client/src/com/vaadin/client/ui/VCalendar.java | 2 + .../src/com/vaadin/client/ui/VColorPickerArea.java | 1 + .../src/com/vaadin/client/ui/VOptionGroupBase.java | 2 + client/src/com/vaadin/client/ui/VScrollTable.java | 8 +- .../ui/absolutelayout/AbsoluteLayoutConnector.java | 3 +- .../client/ui/calendar/CalendarConnector.java | 18 +++- .../client/ui/calendar/schedule/DateCell.java | 46 ++++---- .../ui/calendar/schedule/DateCellContainer.java | 9 +- .../ui/calendar/schedule/DateCellDayEvent.java | 116 +++++++++------------ .../client/ui/calendar/schedule/DateCellGroup.java | 1 - .../client/ui/calendar/schedule/DayToolbar.java | 2 + .../calendar/schedule/FocusableComplexPanel.java | 5 + .../client/ui/calendar/schedule/FocusableGrid.java | 5 + .../client/ui/calendar/schedule/FocusableHTML.java | 5 + .../client/ui/calendar/schedule/MonthGrid.java | 1 + .../client/ui/calendar/schedule/SimpleDayCell.java | 5 + .../ui/calendar/schedule/SimpleWeekToolbar.java | 1 + .../client/ui/calendar/schedule/WeekGrid.java | 1 + .../calendar/schedule/WeekGridMinuteTimeRange.java | 11 +- .../ui/calendar/schedule/WeeklyLongEvents.java | 3 +- .../calendar/schedule/dd/CalendarDropHandler.java | 1 + .../schedule/dd/CalendarMonthDropHandler.java | 1 + .../schedule/dd/CalendarWeekDropHandler.java | 1 + .../src/com/vaadin/client/ui/ui/UIConnector.java | 4 +- .../src/com/vaadin/data/fieldgroup/FieldGroup.java | 3 +- .../src/com/vaadin/server/BrowserWindowOpener.java | 3 +- .../communication/AbstractStreamingEvent.java | 1 - .../communication/ConnectorHierarchyWriter.java | 2 +- .../communication/PortletListenerNotifier.java | 2 +- .../server/communication/ResourceWriter.java | 2 +- .../communication/StreamingEndEventImpl.java | 1 - .../communication/StreamingErrorEventImpl.java | 1 - .../communication/StreamingProgressEventImpl.java | 1 - .../communication/StreamingStartEventImpl.java | 1 - server/src/com/vaadin/ui/AbstractColorPicker.java | 1 + .../src/com/vaadin/ui/AbstractOrderedLayout.java | 1 + server/src/com/vaadin/ui/Calendar.java | 27 ++++- server/src/com/vaadin/ui/GridLayout.java | 1 + server/src/com/vaadin/ui/Window.java | 6 +- .../calendar/ContainerEventProvider.java | 11 ++ .../ui/components/calendar/event/BasicEvent.java | 14 +++ .../calendar/event/BasicEventProvider.java | 6 ++ .../calendar/handler/BasicBackwardHandler.java | 1 + .../calendar/handler/BasicDateClickHandler.java | 1 + .../calendar/handler/BasicEventMoveHandler.java | 1 + .../calendar/handler/BasicEventResizeHandler.java | 1 + .../calendar/handler/BasicForwardHandler.java | 1 + .../calendar/handler/BasicWeekClickHandler.java | 1 + .../ui/components/colorpicker/ColorPickerGrid.java | 2 + .../components/colorpicker/ColorPickerHistory.java | 2 + .../components/colorpicker/ColorPickerPopup.java | 8 ++ .../vaadin/data/util/AbstractContainerTest.java | 1 - .../data/util/ReflectToolsGetSuperField.java | 11 +- .../data/validator/TestStringLengthValidator.java | 2 +- .../abstractfield/RemoveListenersOnDetach.java | 3 +- .../fieldgroup/CaseInsensitiveBinding.java | 3 +- .../tests/server/component/tree/TreeTest.java | 3 +- .../util/ReflectToolsGetFieldValueByType.java | 4 +- .../util/ReflectToolsGetPrimitiveFieldValue.java | 4 +- .../src/com/vaadin/sass/SassCompiler.java | 5 +- .../scss/AbstractDirectoryScanningSassTests.java | 2 +- .../vaadin/launcher/DevelopmentServerLauncher.java | 3 +- .../button/ButtonWithShortcutNotRendered.java | 2 + .../calendar/BeanItemContainerTestUI.java | 3 + .../components/calendar/CalendarActionsUI.java | 3 + .../tests/components/calendar/CalendarTest.java | 19 +++- .../components/calendar/NotificationTestUI.java | 3 + .../checkbox/CheckBoxRevertValueChange.java | 2 + .../combobox/ComboBoxDuplicateCaption.java | 1 + .../ComboBoxSQLContainerFilteredValueChange.java | 5 +- .../VerticalRelativeSizeWithoutExpand.java | 1 + .../richtextarea/RichTextAreaEmptyString.java | 1 + .../RichTextAreaPreventsTextFieldAccess.java | 4 + .../components/select/OptionGroupBaseSelects.java | 2 + .../components/table/EmptyRowsWhenScrolling.java | 3 + .../components/table/LargeSelectionCausesNPE.java | 3 + .../table/TableColumnWidthsAndExpandRatios.java | 9 +- .../table/TableInSubWindowMemoryLeak.java | 4 + .../components/table/TableRowScrolledBottom.java | 1 - .../TableWithBrokenGeneratorAndContainer.java | 3 + .../table/ValueAfterClearingContainer.java | 9 ++ .../components/table/ViewPortCalculation.java | 2 + .../tabsheet/ExtraScrollbarsInTabSheet.java | 1 + .../tabsheet/HiddenTabSheetBrowserResize.java | 1 + .../tests/components/textarea/ScrollCursor.java | 5 + .../TextFieldMaxLengthRemovedFromDOM.java | 1 + .../treetable/TreeTableCacheOnPartialUpdates.java | 2 + .../treetable/TreeTableExtraScrollbar.java | 3 + .../TreeTableExtraScrollbarWithChildren.java | 3 + .../treetable/TreeTableInternalError.java | 3 + .../tests/components/uitest/BackButtonTest.java | 3 + .../components/upload/TestFileUploadSize.java | 4 + .../components/window/LegacyWindowOpenTest.java | 6 ++ .../tests/components/window/PageOpenTest.java | 6 ++ .../TableQueryWithNonUniqueFirstPrimaryKey.java | 1 + .../tests/minitutorials/v70/SimpleLoginUI.java | 10 +- .../tests/minitutorials/v70/SimpleLoginView.java | 8 +- .../v71beta/CSSInjectWithColorpicker.java | 54 +++++----- .../minitutorials/v7a1/AutoGeneratingForm.java | 2 +- .../tests/minitutorials/v7b6/OpeningUIInPopup.java | 7 +- .../vaadin/tests/minitutorials/v7b9/CountView.java | 1 + .../vaadin/tests/minitutorials/v7b9/LoginView.java | 1 + .../vaadin/tests/minitutorials/v7b9/MainView.java | 1 + .../minitutorials/v7b9/MainViewEarlierExample.java | 1 + .../tests/minitutorials/v7b9/SettingsView.java | 5 + 118 files changed, 436 insertions(+), 217 deletions(-) (limited to 'uitest/src') diff --git a/client-compiler/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java b/client-compiler/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java index 1fa259c06b..98ce639d16 100644 --- a/client-compiler/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java +++ b/client-compiler/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java @@ -43,7 +43,6 @@ public class SASSAddonImportFileCreator { private static final String ADDON_IMPORTS_FILE_TEXT = "This file is managed by the Eclipse plug-in and " + "will be overwritten from time to time. Do not manually edit this file."; - /** * @@ -78,7 +77,8 @@ public class SASSAddonImportFileCreator { addonImports.createNewFile(); } - LocationInfo info = ClassPathExplorer.getAvailableWidgetSetsAndStylesheets(); + LocationInfo info = ClassPathExplorer + .getAvailableWidgetSetsAndStylesheets(); try { PrintStream printStream = new PrintStream(new FileOutputStream( @@ -113,8 +113,7 @@ public class SASSAddonImportFileCreator { // Convention is to name the mixing after the stylesheet. Strip // .scss from filename String mixin = file.substring(file.lastIndexOf("/") + 1, - file.length() - - ".scss".length()); + file.length() - ".scss".length()); stream.print("@include " + mixin + ";"); } diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java index 018e19049b..5bc5c0d0ab 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java @@ -84,7 +84,7 @@ public class ClassPathExplorer { public LocationInfo(Map widgetsets, Map themes) { this.widgetsets = widgetsets; - this.addonStyles = themes; + addonStyles = themes; } public Map getWidgetsets() { @@ -186,8 +186,9 @@ public class ClassPathExplorer { * separators) to a URL (see {@link #classpathLocations}) - new * entries are added to this map */ - private static void searchForWidgetSetsAndAddonStyles(String locationString, - Map widgetsets, Map addonStyles) { + private static void searchForWidgetSetsAndAddonStyles( + String locationString, Map widgetsets, + Map addonStyles) { URL location = classpathLocations.get(locationString); File directory = new File(location.getFile()); diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index 543877448a..551f7bafcb 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -566,8 +566,7 @@ public class ComponentLocator { // ChildComponentContainer and VOrderedLayout$Slot have been // replaced with Slot if (w instanceof VAbstractOrderedLayout - && ("ChildComponentContainer" - .equals(widgetClassName) || "VOrderedLayout$Slot" + && ("ChildComponentContainer".equals(widgetClassName) || "VOrderedLayout$Slot" .equals(widgetClassName))) { widgetClassName = "Slot"; } @@ -592,8 +591,7 @@ public class ComponentLocator { * ChildComponentContainer) */ if ((w instanceof VGridLayout) - && "ChildComponentContainer" - .equals(widgetClassName) + && "ChildComponentContainer".equals(widgetClassName) && i + 1 < parts.length) { HasWidgets layout = (HasWidgets) w; diff --git a/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java b/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java index 56ae7c44ac..2896386933 100644 --- a/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java +++ b/client/src/com/vaadin/client/ConnectorHierarchyChangeEvent.java @@ -67,19 +67,17 @@ public class ConnectorHierarchyChangeEvent extends } /** - * Returns the {@link HasComponentsConnector} for which this event - * occurred. + * Returns the {@link HasComponentsConnector} for which this event occurred. * - * @return The {@link HasComponentsConnector} whose child collection - * has changed. Never returns null. + * @return The {@link HasComponentsConnector} whose child collection has + * changed. Never returns null. */ public HasComponentsConnector getParent() { return parent; } /** - * Sets the {@link HasComponentsConnector} for which this event - * occurred. + * Sets the {@link HasComponentsConnector} for which this event occurred. * * @param The * {@link HasComponentsConnector} whose child collection has diff --git a/client/src/com/vaadin/client/HasComponentsConnector.java b/client/src/com/vaadin/client/HasComponentsConnector.java index 0a1a7be97b..ebc6dbcd2a 100644 --- a/client/src/com/vaadin/client/HasComponentsConnector.java +++ b/client/src/com/vaadin/client/HasComponentsConnector.java @@ -21,6 +21,7 @@ import java.util.List; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.HasWidgets; import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; +import com.vaadin.ui.HasComponents; /** * An interface used by client-side connectors whose widget is a component diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 049a689cb6..9810156bcc 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -1347,5 +1347,4 @@ public class Util { } } - } diff --git a/client/src/com/vaadin/client/debug/internal/HierarchySection.java b/client/src/com/vaadin/client/debug/internal/HierarchySection.java index 3c2b7251f3..776ba9326d 100644 --- a/client/src/com/vaadin/client/debug/internal/HierarchySection.java +++ b/client/src/com/vaadin/client/debug/internal/HierarchySection.java @@ -246,6 +246,7 @@ class HierarchySection implements Section { } } + @Override public void meta(ApplicationConnection ac, ValueMap meta) { content.clear(); JsArray valueMapArray = meta diff --git a/client/src/com/vaadin/client/debug/internal/NetworkSection.java b/client/src/com/vaadin/client/debug/internal/NetworkSection.java index ff6466651b..ebdeff810f 100644 --- a/client/src/com/vaadin/client/debug/internal/NetworkSection.java +++ b/client/src/com/vaadin/client/debug/internal/NetworkSection.java @@ -77,6 +77,7 @@ public class NetworkSection implements Section { // NOP } + @Override public void uidl(ApplicationConnection ac, ValueMap uidl) { int sinceStart = VDebugWindow.getMillisSinceStart(); int sinceReset = VDebugWindow.getMillisSinceReset(); diff --git a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java index ce79b4c64c..8e6ad25407 100644 --- a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java +++ b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java @@ -23,8 +23,8 @@ import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.json.client.JSONArray; import com.vaadin.client.ServerConnector; -import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.JavaScriptMethodInvocation; +import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.shared.extension.javascriptmanager.ExecuteJavaScriptRpc; import com.vaadin.shared.extension.javascriptmanager.JavaScriptManagerState; diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index dcb159985c..5475c128c1 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -36,8 +36,6 @@ import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Type; import com.vaadin.client.metadata.TypeData; import com.vaadin.client.metadata.TypeDataStore; -import com.vaadin.client.ui.AbstractFieldConnector; -import com.vaadin.client.ui.ManagedLayout; import com.vaadin.client.ui.datefield.PopupDateFieldConnector; import com.vaadin.client.ui.ui.UIConnector; import com.vaadin.shared.AbstractComponentState; diff --git a/client/src/com/vaadin/client/ui/AbstractConnector.java b/client/src/com/vaadin/client/ui/AbstractConnector.java index 2c76aa93fe..6855c5cd2d 100644 --- a/client/src/com/vaadin/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractConnector.java @@ -439,6 +439,7 @@ public abstract class AbstractConnector implements ServerConnector, * * @see com.vaadin.client.ServerConnector#hasEventListener(java.lang.String) */ + @Override public boolean hasEventListener(String eventIdentifier) { Set reg = getState().registeredEventListeners; return (reg != null && reg.contains(eventIdentifier)); diff --git a/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java b/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java index 4a6aefd082..d833f076e4 100644 --- a/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractHasComponentsConnector.java @@ -20,9 +20,9 @@ import java.util.List; import com.google.gwt.event.shared.HandlerRegistration; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler; +import com.vaadin.client.HasComponentsConnector; public abstract class AbstractHasComponentsConnector extends AbstractComponentConnector implements HasComponentsConnector, diff --git a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java index ee5d1f039a..dc080bcf7d 100644 --- a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java +++ b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java @@ -322,7 +322,7 @@ public class VAbsoluteLayout extends ComplexPanel { } } } - + /** * Cleanup old wrappers which have been left empty by other inner layouts * moving the widget from the wrapper into their own hierarchy. This usually @@ -330,7 +330,7 @@ public class VAbsoluteLayout extends ComplexPanel { * automatically detaches the widget from the parent, in this case the * wrapper, and re-attaches it somewhere else. This has to be done in the * layout phase since the order of the hierarchy events are not defined. - */ + */ public void cleanupWrappers() { for (Widget widget : getChildren()) { if (widget instanceof AbsoluteWrapper) { @@ -339,9 +339,9 @@ public class VAbsoluteLayout extends ComplexPanel { wrapper.destroy(); super.remove(wrapper); continue; - } + } } - } + } } /** diff --git a/client/src/com/vaadin/client/ui/VCalendar.java b/client/src/com/vaadin/client/ui/VCalendar.java index e66a2d7552..c5c12f2d72 100644 --- a/client/src/com/vaadin/client/ui/VCalendar.java +++ b/client/src/com/vaadin/client/ui/VCalendar.java @@ -590,6 +590,7 @@ public class VCalendar extends Composite { cell.setMonthGrid(monthGrid); cell.setDate(d); cell.addDomHandler(new ContextMenuHandler() { + @Override public void onContextMenu(ContextMenuEvent event) { if (mouseEventListener != null) { event.preventDefault(); @@ -827,6 +828,7 @@ public class VCalendar extends Composite { public static Comparator getEventComparator() { return new Comparator() { + @Override public int compare(CalendarEvent o1, CalendarEvent o2) { if (o1.isAllDay() != o2.isAllDay()) { if (o2.isAllDay()) { diff --git a/client/src/com/vaadin/client/ui/VColorPickerArea.java b/client/src/com/vaadin/client/ui/VColorPickerArea.java index bdae65438f..81f2c8fcc7 100644 --- a/client/src/com/vaadin/client/ui/VColorPickerArea.java +++ b/client/src/com/vaadin/client/ui/VColorPickerArea.java @@ -67,6 +67,7 @@ public class VColorPickerArea extends Widget implements ClickHandler, HasHTML, * @param handler * @return HandlerRegistration used to remove the handler */ + @Override public HandlerRegistration addClickHandler(ClickHandler handler) { return addDomHandler(handler, ClickEvent.getType()); } diff --git a/client/src/com/vaadin/client/ui/VOptionGroupBase.java b/client/src/com/vaadin/client/ui/VOptionGroupBase.java index 4d60b2eba8..cc691130ad 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroupBase.java +++ b/client/src/com/vaadin/client/ui/VOptionGroupBase.java @@ -118,6 +118,7 @@ public abstract class VOptionGroupBase extends Composite implements Field, return multiselect; } + @Override public boolean isEnabled() { return enabled; } @@ -190,6 +191,7 @@ public abstract class VOptionGroupBase extends Composite implements Field, } } + @Override public void setEnabled(boolean enabled) { if (this.enabled != enabled) { this.enabled = enabled; diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 4d61fba429..d9dd542b15 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -1113,10 +1113,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (firstvisible != lastRequestedFirstvisible && scrollBody != null) { // received 'surprising' firstvisible from server: scroll there firstRowInViewPort = firstvisible; - + /* - * Schedule the scrolling to be executed last so no updates to the rows - * affect scrolling measurements. + * Schedule the scrolling to be executed last so no updates to the + * rows affect scrolling measurements. */ Scheduler.get().scheduleFinally(lazyScroller); } @@ -3056,7 +3056,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .hasNext(); columnIndex++) { if (it.next() == this) { break; - } + } } } final int cw = scrollBody.getColWidth(columnIndex); diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index cba9cc2fa1..da79639dcd 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -100,8 +100,7 @@ public class AbsoluteLayoutConnector extends /* * (non-Javadoc) * - * @see - * com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin + * @see com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin * .client.ComponentConnector) */ @Override diff --git a/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java index 120a65d842..c36521b3ac 100644 --- a/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java +++ b/client/src/com/vaadin/client/ui/calendar/CalendarConnector.java @@ -54,8 +54,8 @@ import com.vaadin.client.ui.calendar.schedule.CalendarDay; import com.vaadin.client.ui.calendar.schedule.CalendarEvent; import com.vaadin.client.ui.calendar.schedule.DateCell; import com.vaadin.client.ui.calendar.schedule.DateCell.DateCellSlot; -import com.vaadin.client.ui.calendar.schedule.DateUtil; import com.vaadin.client.ui.calendar.schedule.DateCellDayEvent; +import com.vaadin.client.ui.calendar.schedule.DateUtil; import com.vaadin.client.ui.calendar.schedule.HasTooltipKey; import com.vaadin.client.ui.calendar.schedule.SimpleDayCell; import com.vaadin.client.ui.calendar.schedule.dd.CalendarDropHandler; @@ -131,6 +131,7 @@ public class CalendarConnector extends AbstractComponentConnector implements */ protected void registerListeners() { getWidget().setListener(new DateClickListener() { + @Override public void dateClick(String date) { if (!getWidget().isDisabledOrReadOnly() && hasEventListener(CalendarEventId.DATECLICK)) { @@ -139,6 +140,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new ForwardListener() { + @Override public void forward() { if (hasEventListener(CalendarEventId.FORWARD)) { rpc.forward(); @@ -146,6 +148,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new BackwardListener() { + @Override public void backward() { if (hasEventListener(CalendarEventId.BACKWARD)) { rpc.backward(); @@ -153,6 +156,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new RangeSelectListener() { + @Override public void rangeSelected(String value) { if (hasEventListener(CalendarEventId.RANGESELECT)) { rpc.rangeSelect(value); @@ -160,6 +164,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new WeekClickListener() { + @Override public void weekClick(String event) { if (!getWidget().isDisabledOrReadOnly() && hasEventListener(CalendarEventId.WEEKCLICK)) { @@ -168,6 +173,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new EventMovedListener() { + @Override public void eventMoved(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTMOVE)) { StringBuilder sb = new StringBuilder(); @@ -180,6 +186,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new EventResizeListener() { + @Override public void eventResized(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTRESIZE)) { StringBuilder buffer = new StringBuilder(); @@ -205,12 +212,14 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new VCalendar.ScrollListener() { + @Override public void scroll(int scrollPosition) { // This call is @Delayed (== non-immediate) rpc.scroll(scrollPosition); } }); getWidget().setListener(new EventClickListener() { + @Override public void eventClick(CalendarEvent event) { if (hasEventListener(CalendarEventId.EVENTCLICK)) { rpc.eventClick(event.getIndex()); @@ -218,6 +227,7 @@ public class CalendarConnector extends AbstractComponentConnector implements } }); getWidget().setListener(new MouseEventListener() { + @Override public void contextMenu(ContextMenuEvent event, final Widget widget) { final NativeEvent ne = event.getNativeEvent(); int left = ne.getClientX(); @@ -225,14 +235,17 @@ public class CalendarConnector extends AbstractComponentConnector implements top += Window.getScrollTop(); left += Window.getScrollLeft(); getClient().getContextMenu().showAt(new ActionOwner() { + @Override public String getPaintableId() { return CalendarConnector.this.getPaintableId(); } + @Override public ApplicationConnection getClient() { return CalendarConnector.this.getClient(); } + @Override @SuppressWarnings("deprecation") public Action[] getActions() { if (widget instanceof SimpleDayCell) { @@ -423,6 +436,7 @@ public class CalendarConnector extends AbstractComponentConnector implements * @see * com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler#getDropHandler() */ + @Override public CalendarDropHandler getDropHandler() { return dropHandler; } @@ -548,6 +562,7 @@ public class CalendarConnector extends AbstractComponentConnector implements * Returns ALL currently registered events. Use {@link #getActions(Date)} to * get the actions for a specific date */ + @Override public Action[] getActions() { List actions = new ArrayList(); for (int i = 0; i < actionKeys.size(); i++) { @@ -573,6 +588,7 @@ public class CalendarConnector extends AbstractComponentConnector implements * * @see com.vaadin.terminal.gwt.client.ui.ActionOwner#getPaintableId() */ + @Override public String getPaintableId() { return getConnectorId(); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java index 05e2a808fe..516447153e 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCell.java @@ -122,8 +122,8 @@ public class DateCell extends FocusableComplexPanel implements long start = getDate().getTime() + firstHour * 3600000; long end = start + slotTime; for (int i = 0; i < numberOfSlots; i++) { - DateCellSlot slot = new DateCellSlot(this, new Date( - start), new Date(end)); + DateCellSlot slot = new DateCellSlot(this, new Date(start), + new Date(end)); if (i % 2 == 0) { slot.setStyleName("v-datecellslot-even"); } else { @@ -177,8 +177,7 @@ public class DateCell extends FocusableComplexPanel implements } } - throw new IllegalArgumentException( - "Element not found in this DateCell"); + throw new IllegalArgumentException("Element not found in this DateCell"); } public DateCellSlot getSlot(int index) { @@ -271,8 +270,7 @@ public class DateCell extends FocusableComplexPanel implements private void recalculateEventPositions() { for (int i = 0; i < getWidgetCount(); i++) { DateCellDayEvent dayEvent = (DateCellDayEvent) getWidget(i); - updatePositionFor(dayEvent, getDate(), - dayEvent.getCalendarEvent()); + updatePositionFor(dayEvent, getDate(), dayEvent.getCalendarEvent()); } } @@ -325,8 +323,8 @@ public class DateCell extends FocusableComplexPanel implements startingSlotHeight = height / numberOfSlots; for (int i = 0; i < slotElements.length; i++) { - slotElements[i].getStyle().setHeight(slotElementHeights[i], - Unit.PX); + slotElements[i].getStyle() + .setHeight(slotElementHeights[i], Unit.PX); } Iterator it = iterator(); @@ -412,8 +410,8 @@ public class DateCell extends FocusableComplexPanel implements DateCellDayEvent d = (DateCellDayEvent) getWidget(eventIndex); WeekGridMinuteTimeRange nextRange = new WeekGridMinuteTimeRange(d - .getCalendarEvent().getStartTime(), d - .getCalendarEvent().getEndTime()); + .getCalendarEvent().getStartTime(), d.getCalendarEvent() + .getEndTime()); if (WeekGridMinuteTimeRange.doesOverlap(dateRange, nextRange)) { skipIndex = col; @@ -459,9 +457,9 @@ public class DateCell extends FocusableComplexPanel implements int count = getWidgetCount(); DateCellDayEvent target = (DateCellDayEvent) getWidget(targetIndex); - WeekGridMinuteTimeRange targetRange = new WeekGridMinuteTimeRange(target - .getCalendarEvent().getStartTime(), target - .getCalendarEvent().getEndTime()); + WeekGridMinuteTimeRange targetRange = new WeekGridMinuteTimeRange( + target.getCalendarEvent().getStartTime(), target + .getCalendarEvent().getEndTime()); Date groupStart = targetRange.getStart(); Date groupEnd = targetRange.getEnd(); @@ -472,8 +470,8 @@ public class DateCell extends FocusableComplexPanel implements DateCellDayEvent d = (DateCellDayEvent) getWidget(i); WeekGridMinuteTimeRange nextRange = new WeekGridMinuteTimeRange(d - .getCalendarEvent().getStartTime(), d - .getCalendarEvent().getEndTime()); + .getCalendarEvent().getStartTime(), d.getCalendarEvent() + .getEndTime()); if (WeekGridMinuteTimeRange.doesOverlap(targetRange, nextRange)) { g.add(i); @@ -497,7 +495,8 @@ public class DateCell extends FocusableComplexPanel implements public void addEvent(Date targetDay, CalendarEvent calendarEvent) { Element main = getElement(); - DateCellDayEvent dayEvent = new DateCellDayEvent(this, weekgrid, calendarEvent); + DateCellDayEvent dayEvent = new DateCellDayEvent(this, weekgrid, + calendarEvent); dayEvent.setSlotHeightInPX(getSlotHeight()); dayEvent.setDisabled(isDisabled()); @@ -562,8 +561,8 @@ public class DateCell extends FocusableComplexPanel implements } index++; } - this.insert(dayEvent, (com.google.gwt.user.client.Element) main, - index, true); + this.insert(dayEvent, (com.google.gwt.user.client.Element) main, index, + true); } public void removeEvent(DateCellDayEvent dayEvent) { @@ -584,10 +583,10 @@ public class DateCell extends FocusableComplexPanel implements int eventStartHours = eventStart.getHours(); int eventEndHours = eventEnd.getHours(); - return (eventStartHours <= lastHour) - && (eventEndHours >= firstHour); + return (eventStartHours <= lastHour) && (eventEndHours >= firstHour); } + @Override public void onKeyDown(KeyDownEvent event) { int keycode = event.getNativeEvent().getKeyCode(); if (keycode == KeyCodes.KEY_ESCAPE && eventRangeStart > -1) { @@ -595,6 +594,7 @@ public class DateCell extends FocusableComplexPanel implements } } + @Override public void onMouseDown(MouseDownEvent event) { if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) { Element e = Element.as(event.getNativeEvent().getEventTarget()); @@ -610,6 +610,7 @@ public class DateCell extends FocusableComplexPanel implements } } + @Override @SuppressWarnings("deprecation") public void onMouseUp(MouseUpEvent event) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { @@ -676,6 +677,7 @@ public class DateCell extends FocusableComplexPanel implements } } + @Override public void onMouseMove(MouseMoveEvent event) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; @@ -782,8 +784,7 @@ public class DateCell extends FocusableComplexPanel implements return today != null; } - public void addEmphasisStyle( - com.google.gwt.user.client.Element elementOver) { + public void addEmphasisStyle(com.google.gwt.user.client.Element elementOver) { String originalStylename = getStyleName(elementOver); setStyleName(elementOver, originalStylename + DRAGEMPHASISSTYLE); } @@ -797,6 +798,7 @@ public class DateCell extends FocusableComplexPanel implements - DRAGEMPHASISSTYLE.length())); } + @Override public void onContextMenu(ContextMenuEvent event) { if (weekgrid.getCalendar().getMouseEventListener() != null) { event.preventDefault(); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java index f1b45c83c5..04e6bb7df6 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellContainer.java @@ -31,8 +31,8 @@ import com.vaadin.client.ui.VCalendar; * * since 7.1 */ -public class DateCellContainer extends FlowPanel implements - MouseDownHandler, MouseUpHandler { +public class DateCellContainer extends FlowPanel implements MouseDownHandler, + MouseUpHandler { private Date date; @@ -67,7 +67,8 @@ public class DateCellContainer extends FlowPanel implements public boolean hasEvent(int slotIndex) { return hasDateCell(slotIndex) - && ((WeeklyLongEventsDateCell) getChildren().get(slotIndex)).getEvent() != null; + && ((WeeklyLongEventsDateCell) getChildren().get(slotIndex)) + .getEvent() != null; } public boolean hasDateCell(int slotIndex) { @@ -94,12 +95,14 @@ public class DateCellContainer extends FlowPanel implements add(dateCell); } + @Override public void onMouseDown(MouseDownEvent event) { clickTargetWidget = (Widget) event.getSource(); event.stopPropagation(); } + @Override public void onMouseUp(MouseUpEvent event) { if (event.getSource() == clickTargetWidget && clickTargetWidget instanceof WeeklyLongEventsDateCell diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java index 039a00e25a..c56566bf25 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java @@ -51,8 +51,8 @@ import com.vaadin.shared.ui.calendar.DateConstants; * @since 7.1 */ public class DateCellDayEvent extends FocusableHTML implements - MouseDownHandler, MouseUpHandler, MouseMoveHandler, - KeyDownHandler, ContextMenuHandler, HasTooltipKey { + MouseDownHandler, MouseUpHandler, MouseMoveHandler, KeyDownHandler, + ContextMenuHandler, HasTooltipKey { private final DateCell dateCell; private Element caption = null; @@ -79,7 +79,8 @@ public class DateCellDayEvent extends FocusableHTML implements private final List handlers; private boolean mouseMoveCanceled; - public DateCellDayEvent(DateCell dateCell, WeekGrid parent, CalendarEvent event) { + public DateCellDayEvent(DateCell dateCell, WeekGrid parent, + CalendarEvent event) { super(); this.dateCell = dateCell; @@ -110,8 +111,7 @@ public class DateCellDayEvent extends FocusableHTML implements bottomResizeBar = DOM.createDiv(); topResizeBar.addClassName("v-calendar-event-resizetop"); - bottomResizeBar - .addClassName("v-calendar-event-resizebottom"); + bottomResizeBar.addClassName("v-calendar-event-resizebottom"); getElement().appendChild(topResizeBar); getElement().appendChild(bottomResizeBar); @@ -142,8 +142,7 @@ public class DateCellDayEvent extends FocusableHTML implements this.slotHeight = slotHeight; } - public void updatePosition(long startFromMinutes, - long durationInMinutes) { + public void updatePosition(long startFromMinutes, long durationInMinutes) { if (startFromMinutes < 0) { startFromMinutes = 0; } @@ -183,8 +182,7 @@ public class DateCellDayEvent extends FocusableHTML implements /** * @param bigMode - * If false, event is so small that caption must be in - * time-row + * If false, event is so small that caption must be in time-row */ private void updateCaptions(boolean bigMode) { String separator = bigMode ? "
    " : ": "; @@ -194,6 +192,7 @@ public class DateCellDayEvent extends FocusableHTML implements eventContent.setInnerHTML(""); } + @Override public void onKeyDown(KeyDownEvent event) { int keycode = event.getNativeEvent().getKeyCode(); if (keycode == KeyCodes.KEY_ESCAPE && mouseMoveStarted) { @@ -201,38 +200,31 @@ public class DateCellDayEvent extends FocusableHTML implements } } + @Override public void onMouseDown(MouseDownEvent event) { startX = event.getClientX(); startY = event.getClientY(); - if (isDisabled() - || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { + if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; } - clickTarget = Element.as(event.getNativeEvent() - .getEventTarget()); + clickTarget = Element.as(event.getNativeEvent().getEventTarget()); mouseMoveCanceled = false; - if (weekGrid.getCalendar().isEventMoveAllowed() - || clickTargetsResize()) { + if (weekGrid.getCalendar().isEventMoveAllowed() || clickTargetsResize()) { moveRegistration = addMouseMoveHandler(this); setFocus(true); try { - startYrelative = (int) ((double) event - .getRelativeY(caption) % slotHeight); - startXrelative = (event.getRelativeX(weekGrid - .getElement()) - weekGrid.timebar - .getOffsetWidth()) - % getDateCellWidth(); + startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight); + startXrelative = (event.getRelativeX(weekGrid.getElement()) - weekGrid.timebar + .getOffsetWidth()) % getDateCellWidth(); } catch (Exception e) { - GWT.log("Exception calculating relative start position", - e); + GWT.log("Exception calculating relative start position", e); } mouseMoveStarted = false; Style s = getElement().getStyle(); s.setZIndex(1000); - startDatetimeFrom = (Date) calendarEvent.getStartTime() - .clone(); + startDatetimeFrom = (Date) calendarEvent.getStartTime().clone(); startDatetimeTo = (Date) calendarEvent.getEndTime().clone(); Event.setCapture(getElement()); } @@ -243,13 +235,14 @@ public class DateCellDayEvent extends FocusableHTML implements } /* - * We need to stop the event propagation or else the WeekGrid - * range select will kick in + * We need to stop the event propagation or else the WeekGrid range + * select will kick in */ event.stopPropagation(); event.preventDefault(); } + @Override public void onMouseUp(MouseUpEvent event) { if (mouseMoveCanceled) { return; @@ -274,8 +267,7 @@ public class DateCellDayEvent extends FocusableHTML implements // check if mouse has moved over threshold of 3 pixels boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3); - if (!weekGrid.getCalendar().isDisabledOrReadOnly() - && mouseMoved) { + if (!weekGrid.getCalendar().isDisabledOrReadOnly() && mouseMoved) { // Event Move: // - calendar must be enabled // - calendar must not be in read-only mode @@ -283,8 +275,7 @@ public class DateCellDayEvent extends FocusableHTML implements } else if (!weekGrid.getCalendar().isDisabled()) { // Event Click: // - calendar must be enabled (read-only is allowed) - EventTarget et = event.getNativeEvent() - .getEventTarget(); + EventTarget et = event.getNativeEvent().getEventTarget(); Element e = Element.as(et); if (e == caption || e == eventContent || e.getParentElement() == caption) { @@ -304,6 +295,7 @@ public class DateCellDayEvent extends FocusableHTML implements } } + @Override @SuppressWarnings("deprecation") public void onMouseMove(MouseMoveEvent event) { if (startY < 0 && startX < 0) { @@ -330,8 +322,7 @@ public class DateCellDayEvent extends FocusableHTML implements mouseMoveStarted = true; } - HorizontalPanel parent = (HorizontalPanel) getParent() - .getParent(); + HorizontalPanel parent = (HorizontalPanel) getParent().getParent(); int relativeX = event.getRelativeX(parent.getElement()) - weekGrid.timebar.getOffsetWidth(); int halfHourDiff = 0; @@ -362,10 +353,9 @@ public class DateCellDayEvent extends FocusableHTML implements int dayOffsetPx = calculateDateCellOffsetPx(dayOffset) + weekGrid.timebar.getOffsetWidth(); - GWT.log("DateCellWidth: " + dateCellWidth + " dayDiff: " - + dayDiff + " dayOffset: " + dayOffset - + " dayOffsetPx: " + dayOffsetPx + " startXrelative: " - + startXrelative + " moveX: " + moveX); + GWT.log("DateCellWidth: " + dateCellWidth + " dayDiff: " + dayDiff + + " dayOffset: " + dayOffset + " dayOffsetPx: " + dayOffsetPx + + " startXrelative: " + startXrelative + " moveX: " + moveX); if (relativeX < 0 || relativeX >= getDatesWidth()) { return; @@ -391,11 +381,10 @@ public class DateCellDayEvent extends FocusableHTML implements calendarEvent.setEnd(new Date(to.getTime())); // Set new position for the event - long startFromMinutes = (from.getHours() * 60) - + from.getMinutes(); + long startFromMinutes = (from.getHours() * 60) + from.getMinutes(); long range = calendarEvent.getRangeInMinutes(); - startFromMinutes = calculateStartFromMinute( - startFromMinutes, from, to, dayOffsetPx); + startFromMinutes = calculateStartFromMinute(startFromMinutes, from, + to, dayOffsetPx); if (startFromMinutes < 0) { range += startFromMinutes; } @@ -404,8 +393,7 @@ public class DateCellDayEvent extends FocusableHTML implements s.setLeft(dayOffsetPx, Unit.PX); if (weekGrid.getDateCellWidths() != null) { - s.setWidth(weekGrid.getDateCellWidths()[dayOffset], - Unit.PX); + s.setWidth(weekGrid.getDateCellWidths()[dayOffset], Unit.PX); } else { setWidth(moveWidth); } @@ -415,10 +403,8 @@ public class DateCellDayEvent extends FocusableHTML implements long newStartTime = oldStartTime + ((long) halfHourInMilliSeconds * halfHourDiff); - if (!isTimeRangeTooSmall(newStartTime, - startDatetimeTo.getTime())) { - newStartTime = startDatetimeTo.getTime() - - getMinTimeRange(); + if (!isTimeRangeTooSmall(newStartTime, startDatetimeTo.getTime())) { + newStartTime = startDatetimeTo.getTime() - getMinTimeRange(); } from.setTime(newStartTime); @@ -427,8 +413,7 @@ public class DateCellDayEvent extends FocusableHTML implements calendarEvent.setStart(new Date(from.getTime())); // Set new position for the event - long startFromMinutes = (from.getHours() * 60) - + from.getMinutes(); + long startFromMinutes = (from.getHours() * 60) + from.getMinutes(); long range = calendarEvent.getRangeInMinutes(); updatePosition(startFromMinutes, range); @@ -438,10 +423,8 @@ public class DateCellDayEvent extends FocusableHTML implements long newEndTime = oldEndTime + ((long) halfHourInMilliSeconds * halfHourDiff); - if (!isTimeRangeTooSmall(startDatetimeFrom.getTime(), - newEndTime)) { - newEndTime = startDatetimeFrom.getTime() - + getMinTimeRange(); + if (!isTimeRangeTooSmall(startDatetimeFrom.getTime(), newEndTime)) { + newEndTime = startDatetimeFrom.getTime() + getMinTimeRange(); } to.setTime(newEndTime); @@ -453,8 +436,8 @@ public class DateCellDayEvent extends FocusableHTML implements long startFromMinutes = (startDatetimeFrom.getHours() * 60) + startDatetimeFrom.getMinutes(); long range = calendarEvent.getRangeInMinutes(); - startFromMinutes = calculateStartFromMinute( - startFromMinutes, from, to, dayOffsetPx); + startFromMinutes = calculateStartFromMinute(startFromMinutes, from, + to, dayOffsetPx); if (startFromMinutes < 0) { range += startFromMinutes; } @@ -509,14 +492,12 @@ public class DateCellDayEvent extends FocusableHTML implements // date methods are not deprecated in GWT @SuppressWarnings("deprecation") - private long calculateStartFromMinute(long startFromMinutes, - Date from, Date to, int dayOffset) { - boolean eventStartAtDifferentDay = from.getDate() != to - .getDate(); + private long calculateStartFromMinute(long startFromMinutes, Date from, + Date to, int dayOffset) { + boolean eventStartAtDifferentDay = from.getDate() != to.getDate(); if (eventStartAtDifferentDay) { - long minutesOnPrevDay = (getTargetDateByCurrentPosition( - dayOffset).getTime() - from.getTime()) - / DateConstants.MINUTEINMILLIS; + long minutesOnPrevDay = (getTargetDateByCurrentPosition(dayOffset) + .getTime() - from.getTime()) / DateConstants.MINUTEINMILLIS; startFromMinutes = -1 * minutesOnPrevDay; } @@ -554,8 +535,7 @@ public class DateCellDayEvent extends FocusableHTML implements } /** - * @return the minimum amount of ms that an event must last when - * resized + * @return the minimum amount of ms that an event must last when resized */ private long getMinTimeRange() { return DateConstants.MINUTEINMILLIS * 30; @@ -573,8 +553,7 @@ public class DateCellDayEvent extends FocusableHTML implements buffer.append(","); buffer.append(DateUtil.formatClientSideDate(event.getStart())); buffer.append("-"); - buffer.append(DateUtil.formatClientSideTime(event - .getStartTime())); + buffer.append(DateUtil.formatClientSideTime(event.getStartTime())); buffer.append(","); buffer.append(DateUtil.formatClientSideDate(event.getEnd())); buffer.append("-"); @@ -643,11 +622,12 @@ public class DateCellDayEvent extends FocusableHTML implements return disabled; } + @Override public void onContextMenu(ContextMenuEvent event) { - if (this.dateCell.weekgrid.getCalendar().getMouseEventListener() != null) { + if (dateCell.weekgrid.getCalendar().getMouseEventListener() != null) { event.preventDefault(); event.stopPropagation(); - this.dateCell.weekgrid.getCalendar().getMouseEventListener() + dateCell.weekgrid.getCalendar().getMouseEventListener() .contextMenu(event, this); } } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java index d2add53389..79276eab7b 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellGroup.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; - /** * Internally used by the calendar * diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java index bb0155d892..6233e8111e 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java @@ -109,6 +109,7 @@ public class DayToolbar extends HorizontalPanel implements ClickHandler { } l.addClickHandler(new ClickHandler() { + @Override public void onClick(ClickEvent event) { if (calendar.getDateClickListener() != null) { calendar.getDateClickListener().dateClick(date); @@ -133,6 +134,7 @@ public class DayToolbar extends HorizontalPanel implements ClickHandler { add(nextLabel); } + @Override public void onClick(ClickEvent event) { if (!calendar.isDisabledOrReadOnly()) { if (event.getSource() == nextLabel) { diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java index 62332385d2..6b42caec10 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableComplexPanel.java @@ -56,6 +56,7 @@ public class FocusableComplexPanel extends ComplexPanel implements * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. * google.gwt.event.dom.client.FocusHandler) */ + @Override public HandlerRegistration addFocusHandler(FocusHandler handler) { return addDomHandler(handler, FocusEvent.getType()); } @@ -67,6 +68,7 @@ public class FocusableComplexPanel extends ComplexPanel implements * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google * .gwt.event.dom.client.BlurHandler) */ + @Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return addDomHandler(handler, BlurEvent.getType()); } @@ -78,6 +80,7 @@ public class FocusableComplexPanel extends ComplexPanel implements * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( * com.google.gwt.event.dom.client.KeyDownHandler) */ + @Override public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { return addDomHandler(handler, KeyDownEvent.getType()); } @@ -89,6 +92,7 @@ public class FocusableComplexPanel extends ComplexPanel implements * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler * (com.google.gwt.event.dom.client.KeyPressHandler) */ + @Override public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return addDomHandler(handler, KeyPressEvent.getType()); } @@ -111,6 +115,7 @@ public class FocusableComplexPanel extends ComplexPanel implements /** * Focus the panel */ + @Override public void focus() { setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java index d3177362bf..b40f1c3652 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableGrid.java @@ -68,6 +68,7 @@ public class FocusableGrid extends Grid implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. * google.gwt.event.dom.client.FocusHandler) */ + @Override public HandlerRegistration addFocusHandler(FocusHandler handler) { return addDomHandler(handler, FocusEvent.getType()); } @@ -79,6 +80,7 @@ public class FocusableGrid extends Grid implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google * .gwt.event.dom.client.BlurHandler) */ + @Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return addDomHandler(handler, BlurEvent.getType()); } @@ -90,6 +92,7 @@ public class FocusableGrid extends Grid implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( * com.google.gwt.event.dom.client.KeyDownHandler) */ + @Override public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { return addDomHandler(handler, KeyDownEvent.getType()); } @@ -101,6 +104,7 @@ public class FocusableGrid extends Grid implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler * (com.google.gwt.event.dom.client.KeyPressHandler) */ + @Override public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return addDomHandler(handler, KeyPressEvent.getType()); } @@ -123,6 +127,7 @@ public class FocusableGrid extends Grid implements HasFocusHandlers, /** * Focus the panel */ + @Override public void focus() { setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java index c3fe1958f0..31d810608a 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/FocusableHTML.java @@ -58,6 +58,7 @@ public class FocusableHTML extends HTML implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasFocusHandlers#addFocusHandler(com. * google.gwt.event.dom.client.FocusHandler) */ + @Override public HandlerRegistration addFocusHandler(FocusHandler handler) { return addDomHandler(handler, FocusEvent.getType()); } @@ -69,6 +70,7 @@ public class FocusableHTML extends HTML implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasBlurHandlers#addBlurHandler(com.google * .gwt.event.dom.client.BlurHandler) */ + @Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return addDomHandler(handler, BlurEvent.getType()); } @@ -80,6 +82,7 @@ public class FocusableHTML extends HTML implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasKeyDownHandlers#addKeyDownHandler( * com.google.gwt.event.dom.client.KeyDownHandler) */ + @Override public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) { return addDomHandler(handler, KeyDownEvent.getType()); } @@ -91,6 +94,7 @@ public class FocusableHTML extends HTML implements HasFocusHandlers, * com.google.gwt.event.dom.client.HasKeyPressHandlers#addKeyPressHandler * (com.google.gwt.event.dom.client.KeyPressHandler) */ + @Override public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) { return addDomHandler(handler, KeyPressEvent.getType()); } @@ -113,6 +117,7 @@ public class FocusableHTML extends HTML implements HasFocusHandlers, /** * Focus the panel */ + @Override public void focus() { setFocus(true); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java index f5afd12e42..df9bc42d2a 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java @@ -191,6 +191,7 @@ public class MonthGrid extends FocusableGrid implements KeyDownHandler { return enabled; } + @Override public void onKeyDown(KeyDownEvent event) { int keycode = event.getNativeKeyCode(); if (KeyCodes.KEY_ESCAPE == keycode && selectionStart != null) { diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java index 8d1ca0fcda..a2bd008d01 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java @@ -361,6 +361,7 @@ public class SimpleDayCell extends FocusableFlowPanel implements super.onDetach(); } + @Override public void onMouseUp(MouseUpEvent event) { if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; @@ -415,6 +416,7 @@ public class SimpleDayCell extends FocusableFlowPanel implements clickedWidget = null; } + @Override public void onMouseDown(MouseDownEvent event) { if (calendar.isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { @@ -456,11 +458,13 @@ public class SimpleDayCell extends FocusableFlowPanel implements event.preventDefault(); } + @Override public void onMouseOver(MouseOverEvent event) { event.preventDefault(); getMonthGrid().setSelectionEnd(this); } + @Override public void onMouseMove(MouseMoveEvent event) { if (clickedWidget instanceof MonthEventLabel && !monthEventMouseDown || (startY < 0 && startX < 0)) { @@ -566,6 +570,7 @@ public class SimpleDayCell extends FocusableFlowPanel implements Event.setCapture(getElement()); keyDownHandler = addKeyDownHandler(new KeyDownHandler() { + @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) { cancelEventDrag(w); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java index f86ba03053..59902811cd 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleWeekToolbar.java @@ -98,6 +98,7 @@ public class SimpleWeekToolbar extends FlexTable implements ClickHandler { } } + @Override public void onClick(ClickEvent event) { WeekLabel wl = (WeekLabel) event.getSource(); if (calendar.getWeekClickListener() != null) { diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java index c5646f97ae..450ea29549 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGrid.java @@ -83,6 +83,7 @@ public class WeekGrid extends SimplePanel { scrollPanel.setWidget(content); scrollPanel.addScrollHandler(new ScrollHandler() { + @Override public void onScroll(ScrollEvent event) { if (calendar.getScrollListener() != null) { calendar.getScrollListener().scroll( diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java index 27ace91c4e..e634735be7 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeekGridMinuteTimeRange.java @@ -27,16 +27,16 @@ public class WeekGridMinuteTimeRange { private final Date end; /** - * Creates a Date time range between start and end date. Drops seconds - * from the range. + * Creates a Date time range between start and end date. Drops seconds from + * the range. * * @param start * Start time of the range * @param end * End time of the range * @param clearSeconds - * Boolean Indicates, if seconds should be dropped from the - * range start and end + * Boolean Indicates, if seconds should be dropped from the range + * start and end */ public WeekGridMinuteTimeRange(Date start, Date end) { this.start = new Date(start.getTime()); @@ -53,7 +53,8 @@ public class WeekGridMinuteTimeRange { return end; } - public static boolean doesOverlap(WeekGridMinuteTimeRange a, WeekGridMinuteTimeRange b) { + public static boolean doesOverlap(WeekGridMinuteTimeRange a, + WeekGridMinuteTimeRange b) { boolean overlaps = a.getStart().compareTo(b.getEnd()) < 0 && a.getEnd().compareTo(b.getStart()) > 0; return overlaps; diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java index e3b7d5d7fe..f7c5c0dac4 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/WeeklyLongEvents.java @@ -78,7 +78,8 @@ public class WeeklyLongEvents extends HorizontalPanel implements HasTooltipKey { Date dcDate = dc.getDate(); int comp = dcDate.compareTo(from); int comp2 = dcDate.compareTo(to); - WeeklyLongEventsDateCell eventLabel = dc.getDateCell(calendarEvent.getSlotIndex()); + WeeklyLongEventsDateCell eventLabel = dc.getDateCell(calendarEvent + .getSlotIndex()); eventLabel.setStylePrimaryName("v-calendar-event"); if (comp >= 0 && comp2 <= 0) { eventLabel.setEvent(calendarEvent); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java index 03db4d091e..aab9ca9c38 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarDropHandler.java @@ -57,6 +57,7 @@ public abstract class CalendarDropHandler extends VAbstractDropHandler { * com.vaadin.terminal.gwt.client.ui.dd.VDropHandler#getApplicationConnection * () */ + @Override public ApplicationConnection getApplicationConnection() { return calendarConnector.getClient(); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java index 6e57fb6fef..913477ee14 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarMonthDropHandler.java @@ -81,6 +81,7 @@ public class CalendarMonthDropHandler extends CalendarDropHandler { public void dragOver(final VDragEvent drag) { if (isLocationValid(drag.getElementOver())) { validate(new VAcceptCallback() { + @Override public void accepted(VDragEvent event) { dragAccepted(drag); } diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java index fa7aaa428b..0ea683dc3c 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/dd/CalendarWeekDropHandler.java @@ -80,6 +80,7 @@ public class CalendarWeekDropHandler extends CalendarDropHandler { public void dragOver(final VDragEvent drag) { if (isLocationValid(drag.getElementOver())) { validate(new VAcceptCallback() { + @Override public void accepted(VDragEvent event) { dragAccepted(drag); } diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 69296b537c..0843b3069d 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -338,8 +338,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector } /** - * Reads CSS strings and resources injected by {@link Styles#inject} - * from the UIDL stream. + * Reads CSS strings and resources injected by {@link Styles#inject} from + * the UIDL stream. * * @param uidl * The uidl which contains "css-resource" and "css-string" tags diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index 6c515dbdee..981aea387d 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -919,7 +919,8 @@ public class FieldGroup implements Serializable { for (Object itemPropertyId : dataSource.getItemPropertyIds()) { if (itemPropertyId instanceof String) { String itemPropertyName = (String) itemPropertyId; - if (minifiedFieldName.equals(minifyFieldName(itemPropertyName))) { + if (minifiedFieldName + .equals(minifyFieldName(itemPropertyName))) { return itemPropertyName; } } diff --git a/server/src/com/vaadin/server/BrowserWindowOpener.java b/server/src/com/vaadin/server/BrowserWindowOpener.java index 8e049ca454..a6e420f89c 100644 --- a/server/src/com/vaadin/server/BrowserWindowOpener.java +++ b/server/src/com/vaadin/server/BrowserWindowOpener.java @@ -38,7 +38,8 @@ public class BrowserWindowOpener extends AbstractExtension { private final String path; private final Class uiClass; - public BrowserWindowOpenerUIProvider(Class uiClass, String path) { + public BrowserWindowOpenerUIProvider(Class uiClass, + String path) { this.path = ensureInitialSlash(path); this.uiClass = uiClass; } diff --git a/server/src/com/vaadin/server/communication/AbstractStreamingEvent.java b/server/src/com/vaadin/server/communication/AbstractStreamingEvent.java index 054bc14f2d..b97a60fd56 100644 --- a/server/src/com/vaadin/server/communication/AbstractStreamingEvent.java +++ b/server/src/com/vaadin/server/communication/AbstractStreamingEvent.java @@ -15,7 +15,6 @@ */ package com.vaadin.server.communication; -import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable.StreamingEvent; /** diff --git a/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java b/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java index 963886edbb..467bddbdce 100644 --- a/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java +++ b/server/src/com/vaadin/server/communication/ConnectorHierarchyWriter.java @@ -26,8 +26,8 @@ import org.json.JSONException; import org.json.JSONObject; import com.vaadin.server.AbstractClientConnector; -import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.ClientConnector; +import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.PaintException; import com.vaadin.ui.UI; diff --git a/server/src/com/vaadin/server/communication/PortletListenerNotifier.java b/server/src/com/vaadin/server/communication/PortletListenerNotifier.java index c64819ca44..5c03a6f4dc 100644 --- a/server/src/com/vaadin/server/communication/PortletListenerNotifier.java +++ b/server/src/com/vaadin/server/communication/PortletListenerNotifier.java @@ -29,8 +29,8 @@ import javax.portlet.RenderResponse; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; -import com.vaadin.server.SynchronizedRequestHandler; import com.vaadin.server.ServletPortletHelper; +import com.vaadin.server.SynchronizedRequestHandler; import com.vaadin.server.VaadinPortletRequest; import com.vaadin.server.VaadinPortletResponse; import com.vaadin.server.VaadinPortletSession; diff --git a/server/src/com/vaadin/server/communication/ResourceWriter.java b/server/src/com/vaadin/server/communication/ResourceWriter.java index 86f8dd3b36..080027943f 100644 --- a/server/src/com/vaadin/server/communication/ResourceWriter.java +++ b/server/src/com/vaadin/server/communication/ResourceWriter.java @@ -25,8 +25,8 @@ import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; -import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.server.JsonPaintTarget; +import com.vaadin.server.LegacyCommunicationManager; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.UI; diff --git a/server/src/com/vaadin/server/communication/StreamingEndEventImpl.java b/server/src/com/vaadin/server/communication/StreamingEndEventImpl.java index e241bbbfaf..f8cfb160be 100644 --- a/server/src/com/vaadin/server/communication/StreamingEndEventImpl.java +++ b/server/src/com/vaadin/server/communication/StreamingEndEventImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.server.communication; -import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable.StreamingEndEvent; @SuppressWarnings("serial") diff --git a/server/src/com/vaadin/server/communication/StreamingErrorEventImpl.java b/server/src/com/vaadin/server/communication/StreamingErrorEventImpl.java index 1ee74c68b6..9d9a19e4fe 100644 --- a/server/src/com/vaadin/server/communication/StreamingErrorEventImpl.java +++ b/server/src/com/vaadin/server/communication/StreamingErrorEventImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.server.communication; -import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable.StreamingErrorEvent; @SuppressWarnings("serial") diff --git a/server/src/com/vaadin/server/communication/StreamingProgressEventImpl.java b/server/src/com/vaadin/server/communication/StreamingProgressEventImpl.java index c07e37e196..69f3bfb29c 100644 --- a/server/src/com/vaadin/server/communication/StreamingProgressEventImpl.java +++ b/server/src/com/vaadin/server/communication/StreamingProgressEventImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.server.communication; -import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable.StreamingProgressEvent; @SuppressWarnings("serial") diff --git a/server/src/com/vaadin/server/communication/StreamingStartEventImpl.java b/server/src/com/vaadin/server/communication/StreamingStartEventImpl.java index a7f13be499..bd16f08801 100644 --- a/server/src/com/vaadin/server/communication/StreamingStartEventImpl.java +++ b/server/src/com/vaadin/server/communication/StreamingStartEventImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.server.communication; -import com.vaadin.server.StreamVariable; import com.vaadin.server.StreamVariable.StreamingStartEvent; @SuppressWarnings("serial") diff --git a/server/src/com/vaadin/ui/AbstractColorPicker.java b/server/src/com/vaadin/ui/AbstractColorPicker.java index d7037e366d..c3bdd49155 100644 --- a/server/src/com/vaadin/ui/AbstractColorPicker.java +++ b/server/src/com/vaadin/ui/AbstractColorPicker.java @@ -405,6 +405,7 @@ public abstract class AbstractColorPicker extends AbstractComponent implements window.setImmediate(true); window.addCloseListener(this); window.addColorChangeListener(new ColorChangeListener() { + @Override public void colorChanged(ColorChangeEvent event) { AbstractColorPicker.this.colorChanged(event); } diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index b06b2e0871..c9eb756daa 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -439,6 +439,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * com.vaadin.ui.Layout.AlignmentHandler#setDefaultComponentAlignment(com * .vaadin.ui.Alignment) */ + @Override public void setDefaultComponentAlignment(Alignment defaultAlignment) { defaultComponentAlignment = defaultAlignment; } diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java index 4bf2885a8c..38fa355dd8 100644 --- a/server/src/com/vaadin/ui/Calendar.java +++ b/server/src/com/vaadin/ui/Calendar.java @@ -1206,14 +1206,16 @@ public class Calendar extends AbstractComponent implements // remove old listener if (getEventProvider() instanceof EventSetChangeNotifier) { - ((EventSetChangeNotifier) getEventProvider()).removeEventSetChangeListener(this); + ((EventSetChangeNotifier) getEventProvider()) + .removeEventSetChangeListener(this); } this.calendarEventProvider = calendarEventProvider; // add new listener if (calendarEventProvider instanceof EventSetChangeNotifier) { - ((EventSetChangeNotifier) calendarEventProvider).addEventSetChangeListener(this); + ((EventSetChangeNotifier) calendarEventProvider) + .addEventSetChangeListener(this); } } @@ -1232,6 +1234,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.addon.calendar.ui.CalendarEvents.EventChangeListener#eventChange * (com.vaadin.addon.calendar.ui.CalendarEvents.EventChange) */ + @Override public void eventSetChange(EventSetChangeEvent changeEvent) { // sanity check if (calendarEventProvider == changeEvent.getProvider()) { @@ -1276,6 +1279,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardHandler) */ + @Override public void setHandler(ForwardHandler listener) { setHandler(ForwardEvent.EVENT_ID, ForwardEvent.class, listener, ForwardHandler.forwardMethod); @@ -1289,6 +1293,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardHandler) */ + @Override public void setHandler(BackwardHandler listener) { setHandler(BackwardEvent.EVENT_ID, BackwardEvent.class, listener, BackwardHandler.backwardMethod); @@ -1302,6 +1307,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickHandler) */ + @Override public void setHandler(DateClickHandler listener) { setHandler(DateClickEvent.EVENT_ID, DateClickEvent.class, listener, DateClickHandler.dateClickMethod); @@ -1315,6 +1321,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventClickHandler) */ + @Override public void setHandler(EventClickHandler listener) { setHandler(EventClick.EVENT_ID, EventClick.class, listener, EventClickHandler.eventClickMethod); @@ -1328,6 +1335,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClickHandler) */ + @Override public void setHandler(WeekClickHandler listener) { setHandler(WeekClick.EVENT_ID, WeekClick.class, listener, WeekClickHandler.weekClickMethod); @@ -1342,6 +1350,7 @@ public class Calendar extends AbstractComponent implements * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler * ) */ + @Override public void setHandler(EventResizeHandler listener) { setHandler(EventResize.EVENT_ID, EventResize.class, listener, EventResizeHandler.eventResizeMethod); @@ -1356,6 +1365,7 @@ public class Calendar extends AbstractComponent implements * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.RangeSelectHandler * ) */ + @Override public void setHandler(RangeSelectHandler listener) { setHandler(RangeSelectEvent.EVENT_ID, RangeSelectEvent.class, listener, RangeSelectHandler.rangeSelectMethod); @@ -1370,6 +1380,7 @@ public class Calendar extends AbstractComponent implements * #addListener * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler) */ + @Override public void setHandler(EventMoveHandler listener) { setHandler(MoveEvent.EVENT_ID, MoveEvent.class, listener, EventMoveHandler.eventMoveMethod); @@ -1382,6 +1393,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.addon.calendar.ui.CalendarComponentEvents.CalendarEventNotifier * #getHandler(java.lang.String) */ + @Override public EventListener getHandler(String eventId) { return handlers.get(eventId); } @@ -1389,6 +1401,7 @@ public class Calendar extends AbstractComponent implements /** * Get the currently active drop handler */ + @Override public DropHandler getDropHandler() { return dropHandler; } @@ -1410,6 +1423,7 @@ public class Calendar extends AbstractComponent implements * @see * com.vaadin.event.dd.DropTarget#translateDropTargetDetails(java.util.Map) */ + @Override public TargetDetails translateDropTargetDetails( Map clientVariables) { Map serverVariables = new HashMap(1); @@ -1458,12 +1472,14 @@ public class Calendar extends AbstractComponent implements public void setContainerDataSource(Container.Indexed container) { ContainerEventProvider provider = new ContainerEventProvider(container); provider.addEventSetChangeListener(new CalendarEventProvider.EventSetChangeListener() { + @Override public void eventSetChange(EventSetChangeEvent changeEvent) { // Repaint if events change markAsDirty(); } }); provider.addEventChangeListener(new EventChangeListener() { + @Override public void eventChange(EventChangeEvent changeEvent) { // Repaint if event changes markAsDirty(); @@ -1506,12 +1522,14 @@ public class Calendar extends AbstractComponent implements provider.setEndDateProperty(endDateProperty); provider.setStyleNameProperty(styleNameProperty); provider.addEventSetChangeListener(new CalendarEventProvider.EventSetChangeListener() { + @Override public void eventSetChange(EventSetChangeEvent changeEvent) { // Repaint if events change markAsDirty(); } }); provider.addEventChangeListener(new EventChangeListener() { + @Override public void eventChange(EventChangeEvent changeEvent) { // Repaint if event changes markAsDirty(); @@ -1527,6 +1545,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. * util.Date, java.util.Date) */ + @Override public List getEvents(Date startDate, Date endDate) { return getEventProvider().getEvents(startDate, endDate); } @@ -1538,6 +1557,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void addEvent(CalendarEvent event) { if (getEventProvider() instanceof CalendarEditableEventProvider) { CalendarEditableEventProvider provider = (CalendarEditableEventProvider) getEventProvider(); @@ -1556,6 +1576,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void removeEvent(CalendarEvent event) { if (getEventProvider() instanceof CalendarEditableEventProvider) { CalendarEditableEventProvider provider = (CalendarEditableEventProvider) getEventProvider(); @@ -1599,6 +1620,7 @@ public class Calendar extends AbstractComponent implements * *

    */ + @Override public void addActionHandler(Handler actionHandler) { if (actionHandler != null) { if (actionHandlers == null) { @@ -1635,6 +1657,7 @@ public class Calendar extends AbstractComponent implements * com.vaadin.event.Action.Container#removeActionHandler(com.vaadin.event * .Action.Handler) */ + @Override public void removeActionHandler(Handler actionHandler) { if (actionHandlers != null && actionHandlers.contains(actionHandler)) { actionHandlers.remove(actionHandler); diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 60664c8937..53a25c1c83 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -1245,6 +1245,7 @@ public class GridLayout extends AbstractLayout implements * com.vaadin.ui.Layout.AlignmentHandler#setDefaultComponentAlignment(com * .vaadin.ui.Alignment) */ + @Override public void setDefaultComponentAlignment(Alignment defaultAlignment) { defaultComponentAlignment = defaultAlignment; } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 0c1509663a..479992d084 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -489,7 +489,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @param listener * the DisplayStateChangeListener to add. */ - public void addDisplayStateChangeListener(DisplayStateChangeListener listener) { + public void addDisplayStateChangeListener( + DisplayStateChangeListener listener) { addListener(DisplayStateChangeEvent.class, listener, DisplayStateChangeListener.displayStateChangeMethod); } @@ -500,7 +501,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @param listener * the DisplayStateChangeListener to remove. */ - public void removeDisplayStateChangeListener(DisplayStateChangeListener listener) { + public void removeDisplayStateChangeListener( + DisplayStateChangeListener listener) { removeListener(DisplayStateChangeEvent.class, listener, DisplayStateChangeListener.displayStateChangeMethod); } diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java index b01140eb88..37ea255d27 100644 --- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java +++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java @@ -239,6 +239,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. * util.Date, java.util.Date) */ + @Override public List getEvents(Date startDate, Date endDate) { eventCache.clear(); @@ -315,6 +316,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * #addListener(com.vaadin.addon.calendar.event.CalendarEventProvider. * EventSetChangeListener) */ + @Override public void addEventSetChangeListener(EventSetChangeListener listener) { if (!eventSetChangeListeners.contains(listener)) { eventSetChangeListeners.add(listener); @@ -329,6 +331,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * #removeListener(com.vaadin.addon.calendar.event.CalendarEventProvider. * EventSetChangeListener) */ + @Override public void removeEventSetChangeListener(EventSetChangeListener listener) { eventSetChangeListeners.remove(listener); } @@ -340,6 +343,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier#addListener * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) */ + @Override public void addEventChangeListener(EventChangeListener listener) { if (eventChangeListeners.contains(listener)) { eventChangeListeners.add(listener); @@ -353,6 +357,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * removeListener * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) */ + @Override public void removeEventChangeListener(EventChangeListener listener) { eventChangeListeners.remove(listener); } @@ -434,6 +439,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange * (com.vaadin.data.Container.ItemSetChangeEvent) */ + @Override public void containerItemSetChange(ItemSetChangeEvent event) { if (event.getContainer() == container) { // Trigger an eventset change event when the itemset changes @@ -450,6 +456,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data * .Property.ValueChangeEvent) */ + @Override public void valueChange(ValueChangeEvent event) { /* * TODO Need to figure out how to get the item which triggered the the @@ -466,6 +473,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * #eventMove * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) */ + @Override public void eventMove(MoveEvent event) { CalendarEvent ce = event.getCalendarEvent(); if (eventCache.contains(ce)) { @@ -496,6 +504,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * #eventResize * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) */ + @Override public void eventResize(EventResize event) { CalendarEvent ce = event.getCalendarEvent(); if (eventCache.contains(ce)) { @@ -531,6 +540,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void addEvent(CalendarEvent event) { Item item; try { @@ -560,6 +570,7 @@ public class ContainerEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void removeEvent(CalendarEvent event) { container.removeItem(event); } diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java index ab342dfabf..3f14145f0c 100644 --- a/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java +++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEvent.java @@ -91,6 +91,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#getCaption() */ + @Override public String getCaption() { return caption; } @@ -100,6 +101,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#getDescription() */ + @Override public String getDescription() { return description; } @@ -109,6 +111,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#getEnd() */ + @Override public Date getEnd() { return end; } @@ -118,6 +121,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#getStart() */ + @Override public Date getStart() { return start; } @@ -127,6 +131,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#getStyleName() */ + @Override public String getStyleName() { return styleName; } @@ -136,6 +141,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * * @see com.vaadin.addon.calendar.event.CalendarEvent#isAllDay() */ + @Override public boolean isAllDay() { return isAllDay; } @@ -147,6 +153,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * com.vaadin.addon.calendar.event.CalendarEventEditor#setCaption(java.lang * .String) */ + @Override public void setCaption(String caption) { this.caption = caption; fireEventChange(); @@ -159,6 +166,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * com.vaadin.addon.calendar.event.CalendarEventEditor#setDescription(java * .lang.String) */ + @Override public void setDescription(String description) { this.description = description; fireEventChange(); @@ -171,6 +179,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * com.vaadin.addon.calendar.event.CalendarEventEditor#setEnd(java.util. * Date) */ + @Override public void setEnd(Date end) { this.end = end; fireEventChange(); @@ -183,6 +192,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * com.vaadin.addon.calendar.event.CalendarEventEditor#setStart(java.util * .Date) */ + @Override public void setStart(Date start) { this.start = start; fireEventChange(); @@ -195,6 +205,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * com.vaadin.addon.calendar.event.CalendarEventEditor#setStyleName(java * .lang.String) */ + @Override public void setStyleName(String styleName) { this.styleName = styleName; fireEventChange(); @@ -206,6 +217,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * @see * com.vaadin.addon.calendar.event.CalendarEventEditor#setAllDay(boolean) */ + @Override public void setAllDay(boolean isAllDay) { this.isAllDay = isAllDay; fireEventChange(); @@ -220,6 +232,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener * ) */ + @Override public void addEventChangeListener(EventChangeListener listener) { listeners.add(listener); } @@ -233,6 +246,7 @@ public class BasicEvent implements EditableCalendarEvent, EventChangeNotifier { * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventChangeListener * ) */ + @Override public void removeEventChangeListener(EventChangeListener listener) { listeners.remove(listener); } diff --git a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java index 0314652245..b2b74a5e52 100644 --- a/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java +++ b/server/src/com/vaadin/ui/components/calendar/event/BasicEventProvider.java @@ -56,6 +56,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. * util.Date, java.util.Date) */ + @Override public List getEvents(Date startDate, Date endDate) { ArrayList activeEvents = new ArrayList(); @@ -98,6 +99,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener * ) */ + @Override public void addEventSetChangeListener(EventSetChangeListener listener) { listeners.add(listener); @@ -112,6 +114,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChangeListener * ) */ + @Override public void removeEventSetChangeListener(EventSetChangeListener listener) { listeners.remove(listener); } @@ -136,6 +139,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * #eventChange * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventSetChange) */ + @Override public void eventChange(EventChangeEvent changeEvent) { // naive implementation fireEventSetChange(); @@ -148,6 +152,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void addEvent(CalendarEvent event) { eventList.add(event); if (event instanceof BasicEvent) { @@ -163,6 +168,7 @@ public class BasicEventProvider implements CalendarEditableEventProvider, * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent * (com.vaadin.addon.calendar.event.CalendarEvent) */ + @Override public void removeEvent(CalendarEvent event) { eventList.remove(event); if (event instanceof BasicEvent) { diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java index fc2bfd6df4..65e9c94dec 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java @@ -39,6 +39,7 @@ public class BasicBackwardHandler implements BackwardHandler { * backward * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.BackwardEvent) */ + @Override public void backward(BackwardEvent event) { Date start = event.getComponent().getStartDate(); Date end = event.getComponent().getEndDate(); diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java index c91a238b86..ac2470e008 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicDateClickHandler.java @@ -39,6 +39,7 @@ public class BasicDateClickHandler implements DateClickHandler { * #dateClick * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.DateClickEvent) */ + @Override public void dateClick(DateClickEvent event) { Date clickedDate = event.getDate(); diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java index 139837f339..ae4c5fcc12 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventMoveHandler.java @@ -39,6 +39,7 @@ public class BasicEventMoveHandler implements EventMoveHandler { * #eventMove * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) */ + @Override public void eventMove(MoveEvent event) { CalendarEvent calendarEvent = event.getCalendarEvent(); diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java index c052d0d77b..ee7fc27360 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicEventResizeHandler.java @@ -39,6 +39,7 @@ public class BasicEventResizeHandler implements EventResizeHandler { * #eventResize * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) */ + @Override public void eventResize(EventResize event) { CalendarEvent calendarEvent = event.getCalendarEvent(); diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java index a5307ffd5c..e36c9e5756 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java @@ -38,6 +38,7 @@ public class BasicForwardHandler implements ForwardHandler { * com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardHandler#forward * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.ForwardEvent) */ + @Override public void forward(ForwardEvent event) { Date start = event.getComponent().getStartDate(); Date end = event.getComponent().getEndDate(); diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java index 49efe49e48..846fd7dd53 100644 --- a/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java +++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicWeekClickHandler.java @@ -40,6 +40,7 @@ public class BasicWeekClickHandler implements WeekClickHandler { * #weekClick * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.WeekClick) */ + @Override public void weekClick(WeekClick event) { int week = event.getWeek(); int year = event.getYear(); diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java index 9e9855afdd..9123245033 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGrid.java @@ -187,6 +187,7 @@ public class ColorPickerGrid extends AbstractComponent implements ColorSelector * @param listener * The color change listener */ + @Override public void addColorChangeListener(ColorChangeListener listener) { addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD); } @@ -202,6 +203,7 @@ public class ColorPickerGrid extends AbstractComponent implements ColorSelector * @param listener * The listener */ + @Override public void removeColorChangeListener(ColorChangeListener listener) { removeListener(ColorChangeEvent.class, listener); } diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java index e6edbcf40e..2902585f56 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerHistory.java @@ -194,6 +194,7 @@ public class ColorPickerHistory extends CustomComponent implements * @param listener * The listener */ + @Override public void addColorChangeListener(ColorChangeListener listener) { addListener(ColorChangeEvent.class, listener, COLOR_CHANGE_METHOD); } @@ -204,6 +205,7 @@ public class ColorPickerHistory extends CustomComponent implements * @param listener * The listener */ + @Override public void removeColorChangeListener(ColorChangeListener listener) { removeListener(ColorChangeEvent.class, listener); } diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java index c06ae9f6ff..fee52d1a24 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java @@ -283,6 +283,7 @@ public class ColorPickerPopup extends Window implements ClickListener, } redSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { double red = (Double) event.getProperty().getValue(); if (!updatingColors) { @@ -303,6 +304,7 @@ public class ColorPickerPopup extends Window implements ClickListener, } greenSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { double green = (Double) event.getProperty().getValue(); if (!updatingColors) { @@ -322,6 +324,7 @@ public class ColorPickerPopup extends Window implements ClickListener, } blueSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { double blue = (Double) event.getProperty().getValue(); if (!updatingColors) { @@ -380,6 +383,7 @@ public class ColorPickerPopup extends Window implements ClickListener, hueSlider.setWidth("220px"); hueSlider.setImmediate(true); hueSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { if (!updatingColors) { float hue = (Float.parseFloat(event.getProperty() @@ -417,6 +421,7 @@ public class ColorPickerPopup extends Window implements ClickListener, saturationSlider.setWidth("220px"); saturationSlider.setImmediate(true); saturationSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { if (!updatingColors) { float hue = (Float.parseFloat(hueSlider.getValue() @@ -444,6 +449,7 @@ public class ColorPickerPopup extends Window implements ClickListener, valueSlider.setWidth("220px"); valueSlider.setImmediate(true); valueSlider.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { if (!updatingColors) { float hue = (Float.parseFloat(hueSlider.getValue() @@ -754,6 +760,7 @@ public class ColorPickerPopup extends Window implements ClickListener, /** HSV color converter */ Coordinates2Color HSVConverter = new Coordinates2Color() { + @Override public int[] calculate(Color color) { float[] hsv = color.getHSV(); @@ -769,6 +776,7 @@ public class ColorPickerPopup extends Window implements ClickListener, return new int[] { x, y }; } + @Override public Color calculate(int x, int y) { float saturation = 1f - (y / 220.0f); float value = (x / 220.0f); diff --git a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java index 3d9909c42c..64db805623 100644 --- a/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/AbstractContainerTest.java @@ -324,7 +324,6 @@ public abstract class AbstractContainerTest extends TestCase { "com.vaadin.terminal.gwt.client.Focusable", "com.vaadin.data.Buffered", isFilteredOutItemNull(), 20); - // Filter by "contains da" (reversed as ad here) container.removeAllContainerFilters(); diff --git a/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java b/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java index efba6085ac..dc828689a8 100644 --- a/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java +++ b/server/tests/src/com/vaadin/data/util/ReflectToolsGetSuperField.java @@ -19,15 +19,16 @@ public class ReflectToolsGetSuperField { class MySubClass extends MyClass { // no fields here } - + PropertysetItem item = new PropertysetItem(); - item.addItemProperty("testProperty", new ObjectProperty("Value of testProperty")); - + item.addItemProperty("testProperty", new ObjectProperty( + "Value of testProperty")); + MySubClass form = new MySubClass(); - + FieldGroup binder = new FieldGroup(item); binder.bindMemberFields(form); - + assertTrue("Value of testProperty".equals(form.test.getValue())); } diff --git a/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java b/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java index 032b8b6d14..6b4b2b0d51 100644 --- a/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java +++ b/server/tests/src/com/vaadin/tests/data/validator/TestStringLengthValidator.java @@ -45,7 +45,7 @@ public class TestStringLengthValidator extends TestCase { validatorMinValue .isValid("This is a really long string to test that no upper bound exists")); } - + public void testNoLowerBound() { assertTrue("Didn't accept short string", validatorMaxValue.isValid("")); assertTrue("Didn't accept short string", validatorMaxValue.isValid("1")); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index 6dfd50c44c..731387d203 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -19,7 +19,8 @@ public class RemoveListenersOnDetach { int numReadOnlyChanges = 0; AbstractField field = new AbstractField() { - final private VaadinSession application = new AlwaysLockedVaadinSession(null); + final private VaadinSession application = new AlwaysLockedVaadinSession( + null); private UI uI = new UI() { @Override diff --git a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java index 3f4368c295..e571576990 100644 --- a/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java +++ b/server/tests/src/com/vaadin/tests/server/component/fieldgroup/CaseInsensitiveBinding.java @@ -68,7 +68,8 @@ public class CaseInsensitiveBinding { TextField firstName = new TextField("First name"); public MyForm() { - // should bind to the firstName property, not first_name property + // should bind to the firstName property, not first_name + // property addComponent(firstName); } } diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java index a0d57c4d59..3c9fc4c0cd 100644 --- a/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java @@ -88,8 +88,7 @@ public class TreeTest { tree.expandItem("parent"); tree.expandItem("child"); - Field expandedField = tree.getClass() - .getDeclaredField("expanded"); + Field expandedField = tree.getClass().getDeclaredField("expanded"); Field expandedItemIdField = tree.getClass().getDeclaredField( "expandedItemId"); diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java index 718a76804f..540ffb852d 100644 --- a/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java +++ b/server/tests/src/com/vaadin/util/ReflectToolsGetFieldValueByType.java @@ -54,8 +54,8 @@ public class ReflectToolsGetFieldValueByType { memberField = myInstance.getClass().getField("field"); // Should throw an IllegalArgument exception as the mySubClass class // doesn't have an Integer field. - ReflectTools.getJavaFieldValue(myInstance, - memberField, Integer.class); + ReflectTools.getJavaFieldValue(myInstance, memberField, + Integer.class); fail("Previous method call should have thrown an exception"); } catch (Exception e) { } diff --git a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java index df192c51f2..1e1fafe31c 100644 --- a/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java +++ b/server/tests/src/com/vaadin/util/ReflectToolsGetPrimitiveFieldValue.java @@ -17,8 +17,8 @@ public class ReflectToolsGetPrimitiveFieldValue { Object fieldValue = new Boolean(false); try { memberField = myInstance.getClass().getField("field"); - fieldValue = ReflectTools.getJavaFieldValue(myInstance, - memberField); + fieldValue = ReflectTools + .getJavaFieldValue(myInstance, memberField); } catch (Exception e) { } assertFalse(fieldValue instanceof Boolean); diff --git a/theme-compiler/src/com/vaadin/sass/SassCompiler.java b/theme-compiler/src/com/vaadin/sass/SassCompiler.java index 48b2d24c46..6a83425ca1 100644 --- a/theme-compiler/src/com/vaadin/sass/SassCompiler.java +++ b/theme-compiler/src/com/vaadin/sass/SassCompiler.java @@ -17,7 +17,6 @@ package com.vaadin.sass; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; @@ -49,12 +48,12 @@ public class SassCompiler { // ScssStylesheet.setStylesheetResolvers(new VaadinResolver()); ScssStylesheet scss = ScssStylesheet.get(input); - if(scss == null){ + if (scss == null) { System.err.println("The scss file " + input + " could not be found."); return; } - + scss.compile(); if (output == null) { System.out.println(scss.toString()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java index 47657f805c..d60756a2c9 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java @@ -33,7 +33,7 @@ import org.junit.Assert; import com.vaadin.sass.internal.ScssStylesheet; import com.vaadin.sass.testcases.scss.SassTestRunner.FactoryTest; -public abstract class AbstractDirectoryScanningSassTests { +public abstract class AbstractDirectoryScanningSassTests { public static Collection getScssResourceNames(URL directoryUrl) throws URISyntaxException { diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java index 444a70348c..ad372bd5bc 100644 --- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -58,8 +58,9 @@ public class DevelopmentServerLauncher { // Pass-through of arguments for Jetty final Map serverArgs = parseArguments(args); - if (!serverArgs.containsKey("shutdownPort")) + if (!serverArgs.containsKey("shutdownPort")) { serverArgs.put("shutdownPort", "8889"); + } int port = Integer.parseInt(serverArgs.get("shutdownPort")); if (port > 0) { diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java index b01e0a85d0..f866928054 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java @@ -83,6 +83,7 @@ public class ButtonWithShortcutNotRendered extends AbstractTestUI { addValueChangeListener(new Property.ValueChangeListener() { + @Override public void valueChange( com.vaadin.data.Property.ValueChangeEvent event) { final Item item = getItem(getValue()); @@ -162,6 +163,7 @@ public class ButtonWithShortcutNotRendered extends AbstractTestUI { } } + @Override public void buttonClick(ClickEvent event) { // NOP } diff --git a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java index 4e0b963534..83fc4a03cb 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java +++ b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java @@ -85,6 +85,7 @@ public class BeanItemContainerTestUI extends UI { private final Action EDIT = new Action("Edit event"); private final Action REMOVE = new Action("Remove event"); + @Override public void handleAction(Action action, Object sender, Object target) { if (action == ADD) { BasicEvent event = new BasicEvent(); @@ -98,6 +99,7 @@ public class BeanItemContainerTestUI extends UI { } } + @Override public Action[] getActions(Object target, Object sender) { if (target == null) { return new Action[] { ADD }; @@ -153,6 +155,7 @@ public class BeanItemContainerTestUI extends UI { ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { + @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java index f5c2d9da7e..ee898e0790 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionsUI.java @@ -57,6 +57,7 @@ public class CalendarActionsUI extends UI { * com.vaadin.event.Action.Handler#handleAction(com.vaadin.event * .Action, java.lang.Object, java.lang.Object) */ + @Override public void handleAction(Action action, Object sender, Object target) { Date date = (Date) target; if (action == NEW_EVENT) { @@ -72,6 +73,7 @@ public class CalendarActionsUI extends UI { * @see com.vaadin.event.Action.Handler#getActions(java.lang.Object, * java.lang.Object) */ + @Override public Action[] getActions(Object target, Object sender) { CalendarDateRange date = (CalendarDateRange) target; @@ -96,6 +98,7 @@ public class CalendarActionsUI extends UI { content.addComponent(new Button("Set week view", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { calendar.setEndDate(new Date(100, 1, 7)); } diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java index 530e47f1e0..a1bcca2e4e 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java @@ -260,9 +260,9 @@ public class CalendarTest extends UI { private void addInitialEvents() { Date originalDate = calendar.getTime(); Date today = getToday(); - + // Add a event that last a whole week - + Date start = resolveFirstDateOfWeek(today, calendar); Date end = resolveLastDateOfWeek(today, calendar); CalendarTestEvent event = getNewEvent("Whole week event", start, end); @@ -388,6 +388,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { switchToMonthView(); } @@ -397,6 +398,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { // simulate week click WeekClickHandler handler = (WeekClickHandler) calendarComponent @@ -410,6 +412,7 @@ public class CalendarTest extends UI { nextButton = new Button("Next", new Button.ClickListener() { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { handleNextButtonClick(); } @@ -418,6 +421,7 @@ public class CalendarTest extends UI { prevButton = new Button("Prev", new Button.ClickListener() { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { handlePreviousButtonClick(); } @@ -488,6 +492,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = -8307244759142541067L; + @Override public void buttonClick(ClickEvent event) { Date start = getToday(); start.setHours(0); @@ -512,6 +517,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = -7104996493482558021L; + @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); if (value instanceof Boolean && Boolean.TRUE.equals(value)) { @@ -675,6 +681,7 @@ public class CalendarTest extends UI { calendarComponent.setHandler(new EventClickHandler() { + @Override public void eventClick(EventClick event) { showEventPopup(event.getCalendarEvent(), false); } @@ -693,6 +700,7 @@ public class CalendarTest extends UI { calendarComponent.setHandler(new RangeSelectHandler() { + @Override public void rangeSelect(RangeSelectEvent event) { handleRangeSelect(event); } @@ -725,6 +733,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void valueChange(ValueChangeEvent event) { updateCalendarTimeZone(event.getProperty().getValue()); @@ -752,6 +761,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void valueChange(ValueChangeEvent event) { updateCalendarFormat(event.getProperty().getValue()); } @@ -779,6 +789,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void valueChange(ValueChangeEvent event) { updateCalendarLocale((Locale) event.getProperty().getValue()); } @@ -933,6 +944,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { try { commitCalendarEvent(); @@ -945,6 +957,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { discardCalendarEvent(); } @@ -953,6 +966,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void buttonClick(ClickEvent event) { deleteCalendarEvent(); } @@ -961,6 +975,7 @@ public class CalendarTest extends UI { private static final long serialVersionUID = 1L; + @Override public void windowClose(Window.CloseEvent e) { discardCalendarEvent(); } diff --git a/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java b/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java index 0bd327da18..6e5718a652 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java +++ b/uitest/src/com/vaadin/tests/components/calendar/NotificationTestUI.java @@ -50,6 +50,7 @@ public class NotificationTestUI extends UI { events.add(e); } + @Override public List getEvents(Date startDate, Date endDate) { return events; } @@ -64,6 +65,7 @@ public class NotificationTestUI extends UI { setContent(content); final Button btn = new Button("Show working notification", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Notification .show("This will disappear when you move your mouse!"); @@ -76,6 +78,7 @@ public class NotificationTestUI extends UI { cal.setLocale(Locale.US); cal.setSizeFull(); cal.setHandler(new DateClickHandler() { + @Override public void dateClick(DateClickEvent event) { provider.addEvent(event.getDate()); Notification diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java index 5b086fb935..cc26cf8845 100644 --- a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java @@ -29,6 +29,7 @@ public class CheckBoxRevertValueChange extends AbstractTestUIWithLog { final CheckBox alwaysUnchecked = new CheckBox("You may not check me"); alwaysUnchecked .addValueChangeListener(new Property.ValueChangeListener() { + @Override public void valueChange(Property.ValueChangeEvent event) { if (alwaysUnchecked.getValue()) { log("I said no checking!"); @@ -40,6 +41,7 @@ public class CheckBoxRevertValueChange extends AbstractTestUIWithLog { alwaysChecked.setValue(true); alwaysChecked .addValueChangeListener(new Property.ValueChangeListener() { + @Override public void valueChange(Property.ValueChangeEvent event) { if (!alwaysChecked.getValue()) { log("I said no unchecking!"); diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDuplicateCaption.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDuplicateCaption.java index 3c1e8a27d6..bd71850a89 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDuplicateCaption.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDuplicateCaption.java @@ -38,6 +38,7 @@ public class ComboBoxDuplicateCaption extends TestBase { box.setImmediate(true); box.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange( com.vaadin.data.Property.ValueChangeEvent event) { Person p = (Person) event.getProperty().getValue(); diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java index 23a75ae56e..75010f0ea9 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSQLContainerFilteredValueChange.java @@ -53,6 +53,7 @@ public class ComboBoxSQLContainerFilteredValueChange extends TestBase { myCombo.setWidth("100.0%"); myCombo.setHeight("-1px"); myCombo.addListener(new Property.ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { selectedLabel.setValue("Selected: " + event.getProperty().getValue()); @@ -72,6 +73,7 @@ public class ComboBoxSQLContainerFilteredValueChange extends TestBase { /** * (Re)creates the test table + * * @param connectionPool */ private void createTestTable(JDBCConnectionPool connectionPool) { @@ -97,6 +99,7 @@ public class ComboBoxSQLContainerFilteredValueChange extends TestBase { /** * Adds test data to the test table + * * @param connectionPool * @throws SQLException */ @@ -111,7 +114,7 @@ public class ComboBoxSQLContainerFilteredValueChange extends TestBase { statement.executeUpdate("INSERT INTO mytable VALUES(2, 'A1')"); statement.executeUpdate("INSERT INTO mytable VALUES(3, 'B0')"); statement.executeUpdate("INSERT INTO mytable VALUES(4, 'B1')"); - + statement.close(); conn.commit(); } catch (SQLException e) { diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java index 86525da3ef..0ac9a008d2 100755 --- a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeSizeWithoutExpand.java @@ -1,4 +1,5 @@ package com.vaadin.tests.components.orderedlayout; + import com.vaadin.data.util.BeanItemContainer; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.Panel; diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java index 5eddf9dc6d..01dc10220f 100644 --- a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaEmptyString.java @@ -29,6 +29,7 @@ public class RichTextAreaEmptyString extends TestBase { final Button b = new Button("get area value", new ClickListener() { + @Override public void buttonClick(ClickEvent event) { l.setValue(area.getValue()); } diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaPreventsTextFieldAccess.java b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaPreventsTextFieldAccess.java index f4ad149dd1..c3433c3054 100644 --- a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaPreventsTextFieldAccess.java +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaPreventsTextFieldAccess.java @@ -50,6 +50,7 @@ public class RichTextAreaPreventsTextFieldAccess extends TestBase { Button addWindowButton = new Button("Open RichTextArea-Dialog"); addWindowButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { getMainWindow().addWindow(subWindow); @@ -60,6 +61,7 @@ public class RichTextAreaPreventsTextFieldAccess extends TestBase { Button removeWindowButton = new Button("removeWindowButton"); removeWindowButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { getMainWindow().removeWindow(subWindow); @@ -70,6 +72,7 @@ public class RichTextAreaPreventsTextFieldAccess extends TestBase { Button focusButton = new Button("Set focus on TextField"); focusButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { testField.focus(); @@ -80,6 +83,7 @@ public class RichTextAreaPreventsTextFieldAccess extends TestBase { Button removeRTA = new Button("Remove RTA"); removeRTA.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { wLayout.removeComponent(rText); diff --git a/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java index f2dee69cbf..0df82688d1 100644 --- a/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java +++ b/uitest/src/com/vaadin/tests/components/select/OptionGroupBaseSelects.java @@ -29,6 +29,7 @@ public class OptionGroupBaseSelects extends ComponentTestCase CheckBox cb = new CheckBox("Switch Selects ReadOnly", false); cb.addListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { for (Iterator it = layout.getComponentIterator(); it .hasNext();) { @@ -42,6 +43,7 @@ public class OptionGroupBaseSelects extends ComponentTestCase CheckBox cb2 = new CheckBox("Switch Selects Enabled", true); cb2.addListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { for (Iterator it = layout.getComponentIterator(); it .hasNext();) { diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java b/uitest/src/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java index c1ae9b4118..3bc0d3dd1f 100644 --- a/uitest/src/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java +++ b/uitest/src/com/vaadin/tests/components/table/EmptyRowsWhenScrolling.java @@ -93,6 +93,7 @@ public class EmptyRowsWhenScrolling extends UI { table.setVisibleColumns(new String[] { "image", "id", "col1", "col2", "col3", "col4" }); table.addGeneratedColumn("image", new ColumnGenerator() { + @Override public Object generateCell(Table source, Object itemId, Object columnId) { int imgNum = new Random().nextInt(5) + 1; @@ -112,6 +113,7 @@ public class EmptyRowsWhenScrolling extends UI { image.setWidth("50px"); image.setHeight("50px"); image.addClickListener(new com.vaadin.event.MouseEvents.ClickListener() { + @Override public void click( com.vaadin.event.MouseEvents.ClickEvent event) { Notification.show("Image clicked!"); @@ -123,6 +125,7 @@ public class EmptyRowsWhenScrolling extends UI { // Refresh table button getBtnRefreshTable().addClickListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.refreshRowCache(); } diff --git a/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java index fb782b8ded..b6ee62ea59 100644 --- a/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java +++ b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java @@ -105,6 +105,7 @@ public class LargeSelectionCausesNPE extends TestBase { } Table.ValueChangeListener valueChangeListener = new Table.ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { // in multiselect mode, a Set of itemIds is returned, // in singleselect mode the itemId is returned directly @@ -119,6 +120,7 @@ public class LargeSelectionCausesNPE extends TestBase { Button.ClickListener clickListener = new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Property nameProperty = table.getContainerProperty(0, NAME); if (("0").equals(nameLabel.getValue())) { @@ -148,6 +150,7 @@ public class LargeSelectionCausesNPE extends TestBase { ColumnGenerator columnGenerator = new ColumnGenerator() { + @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label(); diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java b/uitest/src/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java index 747c99468f..b1ecb3fc10 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java +++ b/uitest/src/com/vaadin/tests/components/table/TableColumnWidthsAndExpandRatios.java @@ -38,10 +38,11 @@ public class TableColumnWidthsAndExpandRatios extends TestBase { return new NativeButton("Reset " + property + " width", new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - table.setColumnWidth(property, -1); - } - }); + @Override + public void buttonClick(ClickEvent event) { + table.setColumnWidth(property, -1); + } + }); } @Override diff --git a/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java b/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java index dcaabf98d6..c0c8876fca 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java +++ b/uitest/src/com/vaadin/tests/components/table/TableInSubWindowMemoryLeak.java @@ -20,6 +20,7 @@ public class TableInSubWindowMemoryLeak extends TestBase { final Button openButton = new Button("open me"); openButton.addClickListener(new ClickListener() { + @Override public void buttonClick(final ClickEvent event) { final Window window = new Window("Simple Window"); window.setModal(true); @@ -29,6 +30,7 @@ public class TableInSubWindowMemoryLeak extends TestBase { window.setContent(table); UI.getCurrent().addWindow(window); window.addCloseListener(new CloseListener() { + @Override public void windowClose(final CloseEvent e) { window.setContent(new Label()); UI.getCurrent().removeWindow(window); @@ -40,6 +42,7 @@ public class TableInSubWindowMemoryLeak extends TestBase { final Button openButton2 = new Button("open me without Table"); openButton2.addClickListener(new ClickListener() { + @Override public void buttonClick(final ClickEvent event) { final Window window = new Window("Simple Window"); window.setModal(true); @@ -47,6 +50,7 @@ public class TableInSubWindowMemoryLeak extends TestBase { window.setWidth("200px"); UI.getCurrent().addWindow(window); window.addCloseListener(new CloseListener() { + @Override public void windowClose(final CloseEvent e) { UI.getCurrent().removeWindow(window); } diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java index 9823fc1859..7d48dfa11e 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java +++ b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java @@ -5,7 +5,6 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -import com.vaadin.ui.VerticalLayout; public class TableRowScrolledBottom extends TestBase { diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java index 9c5ce9dc0c..efa1b1bdab 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java +++ b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java @@ -78,6 +78,7 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { this.brokenInterval = brokenInterval; } + @Override public Object generateCell(Table source, Object itemId, Object columnId) { if (counter++ % brokenInterval == 0 && Boolean.TRUE.equals(brokenGenerator.getValue())) { @@ -97,6 +98,7 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { clearTableOnError.setImmediate(true); clearTableOnError.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { Boolean value = clearTableOnError.getValue(); setErrorHandler(value != null ? value : false); @@ -110,6 +112,7 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase { Button refreshTableCache = new Button("Refresh table cache", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.markAsDirty(); table.refreshRowCache(); diff --git a/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java b/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java index f378c146ea..b0622e748c 100644 --- a/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java +++ b/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java @@ -26,6 +26,7 @@ public class ValueAfterClearingContainer extends TestBase { table.setImmediate(true); table.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { log.log("Value changed to " + event.getProperty().getValue()); } @@ -38,6 +39,7 @@ public class ValueAfterClearingContainer extends TestBase { multiselect.setId("multiselect"); multiselect.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { Boolean value = multiselect.getValue(); table.setMultiSelect(value == null ? false : value); @@ -46,6 +48,7 @@ public class ValueAfterClearingContainer extends TestBase { addComponent(multiselect); Button addItemsButton = new Button("Add table items", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { if (!table.getItemIds().isEmpty()) { Notification @@ -65,6 +68,7 @@ public class ValueAfterClearingContainer extends TestBase { Button showValueButton = new Button("Show value", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { log.log("Table selection: " + table.getValue()); } @@ -74,6 +78,7 @@ public class ValueAfterClearingContainer extends TestBase { Button removeItemsFromTableButton = new Button( "Remove items from table", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.removeAllItems(); } @@ -83,6 +88,7 @@ public class ValueAfterClearingContainer extends TestBase { Button removeItemsFromContainerButton = new Button( "Remove items from container", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.getContainerDataSource().removeAllItems(); } @@ -92,6 +98,7 @@ public class ValueAfterClearingContainer extends TestBase { Button removeItemsFromContainerAndSanitizeButton = new Button( "Remove items from container and sanitize", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.getContainerDataSource().removeAllItems(); table.sanitizeSelection(); @@ -102,6 +109,7 @@ public class ValueAfterClearingContainer extends TestBase { addComponent(removeItemsFromContainerAndSanitizeButton); Button removeSelectedFromTableButton = new Button( "Remove selected item from table", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Object selection = table.getValue(); if (selection == null) { @@ -117,6 +125,7 @@ public class ValueAfterClearingContainer extends TestBase { Button removeSelectedFromContainer = new Button( "Remove selected item from container", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Object selection = table.getValue(); if (selection == null) { diff --git a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java index 878dd0d3c4..de32ea1fc0 100644 --- a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java +++ b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java @@ -43,6 +43,7 @@ public class ViewPortCalculation extends TestBase { } table.setCellStyleGenerator(new CellStyleGenerator() { + @Override public String getStyle(Table source, Object itemId, Object propertyId) { if (itemId.equals(lastDoubleClickedItemId)) { @@ -53,6 +54,7 @@ public class ViewPortCalculation extends TestBase { }); table.addItemClickListener(new ItemClickListener() { + @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { lastDoubleClickedItemId = event.getItemId(); diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/ExtraScrollbarsInTabSheet.java b/uitest/src/com/vaadin/tests/components/tabsheet/ExtraScrollbarsInTabSheet.java index 2917eccbfb..fffc766e7c 100755 --- a/uitest/src/com/vaadin/tests/components/tabsheet/ExtraScrollbarsInTabSheet.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/ExtraScrollbarsInTabSheet.java @@ -1,4 +1,5 @@ package com.vaadin.tests.components.tabsheet; + import com.vaadin.annotations.Theme; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.HorizontalSplitPanel; diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java b/uitest/src/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java index 0fdb579997..eac786d9b3 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/HiddenTabSheetBrowserResize.java @@ -17,6 +17,7 @@ public class HiddenTabSheetBrowserResize extends TestBase { Button toggleButton = new Button("Toggle TabSheet", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { tabSheet.setVisible(!tabSheet.isVisible()); } diff --git a/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java index c95731d94f..154a30a64b 100644 --- a/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java +++ b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java @@ -27,6 +27,7 @@ public class ScrollCursor extends TestBase { Button button = new Button("Scroll"); button.addListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { textArea.setCursorPosition(getPosition()); } @@ -34,6 +35,7 @@ public class ScrollCursor extends TestBase { Button wrap = new Button("Set wrap"); wrap.addListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { textArea.setWordwrap(false); } @@ -42,6 +44,7 @@ public class ScrollCursor extends TestBase { Button toBegin = new Button("To begin"); toBegin.addListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { position = 3; } @@ -50,6 +53,7 @@ public class ScrollCursor extends TestBase { Button toMiddle = new Button("To middle"); toMiddle.addListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { position = 130; } @@ -58,6 +62,7 @@ public class ScrollCursor extends TestBase { Button toEnd = new Button("To end"); toEnd.addListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { position = textArea.getValue().toString().length(); } diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java index 28ff20c174..049b08d4e8 100644 --- a/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldMaxLengthRemovedFromDOM.java @@ -17,6 +17,7 @@ public class TextFieldMaxLengthRemovedFromDOM extends TestBase { tf.addFocusListener(new FieldEvents.FocusListener() { + @Override public void focus(FocusEvent event) { // Resetting Max length should not remove maxlength attribute tf.setMaxLength(11); diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java index f792a32f8f..85a69702a4 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableCacheOnPartialUpdates.java @@ -90,6 +90,7 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { } public class Col4ColumnGenerator implements ColumnGenerator { + @Override public Component generateCell(final com.vaadin.ui.Table source, final Object itemId, Object columnId) { TestBean tb = (TestBean) itemId; @@ -98,6 +99,7 @@ public class TreeTableCacheOnPartialUpdates extends TestBase { btnCol4.setId("cacheTestButtonToggle-" + tb.getCol1() + "-" + tb.getCol2()); btnCol4.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { treeTable.setCollapsed(itemId, !treeTable.isCollapsed(itemId)); diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java index 4af0da158d..79c967914f 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbar.java @@ -49,6 +49,7 @@ public class TreeTableExtraScrollbar extends TestBase { button.setId("button"); button.addClickListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.addItem(new TestObject("name 6-1", "value 6-1")); table.addItem(new TestObject("name 6-2", "value 6-2")); @@ -68,12 +69,14 @@ public class TreeTableExtraScrollbar extends TestBase { } private class EmptyColumnGenerator implements Table.ColumnGenerator { + @Override public Object generateCell(Table table, Object itemId, Object columnId) { return null; } } private class TypeColumnGenerator implements Table.ColumnGenerator { + @Override public Object generateCell(Table table, Object itemId, Object columnId) { if (itemId instanceof TestObject) { return new Label(((TestObject) itemId).getValue()); diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java index cad33e242f..0dc98b2c2e 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableExtraScrollbarWithChildren.java @@ -62,6 +62,7 @@ public class TreeTableExtraScrollbarWithChildren extends TestBase { button.setId("button"); button.addClickListener(new ClickListener() { + @Override public void buttonClick(ClickEvent event) { table.setCollapsed(parent, !table.isCollapsed(parent)); Notification.show("collapsed: " + table.isCollapsed(parent)); @@ -73,6 +74,7 @@ public class TreeTableExtraScrollbarWithChildren extends TestBase { } private class HierarchyColumnGenerator implements Table.ColumnGenerator { + @Override public Object generateCell(Table table, Object itemId, Object columnId) { Label label = new Label("this should be mostly hidden"); label.setSizeUndefined(); @@ -81,6 +83,7 @@ public class TreeTableExtraScrollbarWithChildren extends TestBase { } private class TypeColumnGenerator implements Table.ColumnGenerator { + @Override public Object generateCell(Table table, Object itemId, Object columnId) { if (itemId instanceof TestObject) { return new Label(((TestObject) itemId).getValue()); diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableInternalError.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableInternalError.java index f6d7f11eb7..1b510f1ac5 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableInternalError.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableInternalError.java @@ -30,6 +30,7 @@ public class TreeTableInternalError extends TestBase { Button button = new Button("Resize") { { addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { t.setHeight("300px"); } @@ -64,12 +65,14 @@ public class TreeTableInternalError extends TestBase { } public class ButtonColumnGenerator implements ColumnGenerator { + @Override public Component generateCell(final com.vaadin.ui.Table source, final Object itemId, Object columnId) { String identifier = "Expand/Collapse"; Button btnCol = new NativeButton(identifier); btnCol.setId("cacheTestButtonToggle-" + itemId); btnCol.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { t.setCollapsed(itemId, !t.isCollapsed(itemId)); } diff --git a/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java b/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java index d5bac0d509..7e7a084eed 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java +++ b/uitest/src/com/vaadin/tests/components/uitest/BackButtonTest.java @@ -57,6 +57,7 @@ public class BackButtonTest extends AbstractTestUI { addComponent(l); Button b = new Button("Go to Page 2", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { l.setCaption("Data from Page 1 : " + value); getPage().setUriFragment("page2"); @@ -85,6 +86,7 @@ public class BackButtonTest extends AbstractTestUI { addComponent(f); f.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { value = f.getValue(); p1.l.setCaption("Data from Page 2 : " + value); @@ -92,6 +94,7 @@ public class BackButtonTest extends AbstractTestUI { }); Button b = new Button("Go Back", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { getPage().setUriFragment("page1"); } diff --git a/uitest/src/com/vaadin/tests/components/upload/TestFileUploadSize.java b/uitest/src/com/vaadin/tests/components/upload/TestFileUploadSize.java index 32f5c93bfd..178f8f9393 100644 --- a/uitest/src/com/vaadin/tests/components/upload/TestFileUploadSize.java +++ b/uitest/src/com/vaadin/tests/components/upload/TestFileUploadSize.java @@ -28,6 +28,7 @@ public class TestFileUploadSize extends TestBase implements Receiver { Upload u = new Upload("Upload", new Upload.Receiver() { + @Override public OutputStream receiveUpload(String filename, String mimeType) { return baos; } @@ -35,12 +36,14 @@ public class TestFileUploadSize extends TestBase implements Receiver { u.setId("UPL"); u.addStartedListener(new Upload.StartedListener() { + @Override public void uploadStarted(StartedEvent event) { expectedSize.setValue(String.valueOf(event.getContentLength())); } }); u.addFinishedListener(new Upload.FinishedListener() { + @Override public void uploadFinished(FinishedEvent event) { label.setValue("Upload finished. Name: " + event.getFilename()); receivedSize.setValue(String.valueOf(baos.size())); @@ -62,6 +65,7 @@ public class TestFileUploadSize extends TestBase implements Receiver { addComponent(u); } + @Override public OutputStream receiveUpload(String filename, String MIMEType) { Notification.show("Receiving upload"); return new ByteArrayOutputStream(); diff --git a/uitest/src/com/vaadin/tests/components/window/LegacyWindowOpenTest.java b/uitest/src/com/vaadin/tests/components/window/LegacyWindowOpenTest.java index 175c3f6d8a..ad36e04d88 100644 --- a/uitest/src/com/vaadin/tests/components/window/LegacyWindowOpenTest.java +++ b/uitest/src/com/vaadin/tests/components/window/LegacyWindowOpenTest.java @@ -19,6 +19,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button("Window.open _blank always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.open(r, "_blank", true); } @@ -26,6 +27,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button("Window.open _blank NOT always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.open(r, "_blank", false); } @@ -33,6 +35,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button("Window.open _new always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.open(r, "_new", true); } @@ -40,6 +43,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button("Window.open _new NOT always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.open(r, "_new", false); } @@ -47,6 +51,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button( "Window execute Javascript window.open(www.google.com, _blank)", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.executeJavaScript("window.open(\"http://www.google.com\", \"_blank\");"); } @@ -54,6 +59,7 @@ public class LegacyWindowOpenTest extends TestBase { addComponent(new Button( "Window execute Javascript window.open(www.google.com, _blank, resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes)", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { win.executeJavaScript("window.open(\"http://www.google.com\", \"_blank\", \"resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes\");"); } diff --git a/uitest/src/com/vaadin/tests/components/window/PageOpenTest.java b/uitest/src/com/vaadin/tests/components/window/PageOpenTest.java index 2dbc24cb66..a566b09cdc 100644 --- a/uitest/src/com/vaadin/tests/components/window/PageOpenTest.java +++ b/uitest/src/com/vaadin/tests/components/window/PageOpenTest.java @@ -20,6 +20,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button("Page.open _blank always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { page.open(url, "_blank", true); } @@ -27,6 +28,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button("Page.open _blank NOT always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { page.open(url, "_blank", false); } @@ -34,6 +36,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button("Page.open _new always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { page.open(url, "_new", true); } @@ -41,6 +44,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button("Page.open _new NOT always as popup", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { page.open(url, "_new", false); } @@ -48,6 +52,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button( "Execute Javascript window.open(www.google.com, _blank)", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { JavaScript .getCurrent() @@ -58,6 +63,7 @@ public class PageOpenTest extends AbstractTestUI { addComponent(new Button( "Execute Javascript window.open(www.google.com, _blank, resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes)", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { JavaScript .getCurrent() diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKey.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKey.java index fa84c7cbb8..da3476610b 100644 --- a/uitest/src/com/vaadin/tests/containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKey.java +++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/TableQueryWithNonUniqueFirstPrimaryKey.java @@ -53,6 +53,7 @@ public class TableQueryWithNonUniqueFirstPrimaryKey extends LegacyApplication { myCombo.setWidth("100.0%"); myCombo.setHeight("-1px"); myCombo.addValueChangeListener(new Property.ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { if (myCombo.getValue() != null) { Item item = myCombo.getItem(event.getProperty() diff --git a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java index 2fbbff10a8..1f94d43abe 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginUI.java @@ -26,16 +26,16 @@ public class SimpleLoginUI extends UI { */ getNavigator().addView(SimpleLoginMainView.NAME, SimpleLoginMainView.class); - + /* * We use a view change handler to ensure the user is always redirected * to the login view if the user is not logged in. */ getNavigator().addViewChangeListener(new ViewChangeListener() { - + @Override public boolean beforeViewChange(ViewChangeEvent event) { - + // Check if a user has logged in boolean isLoggedIn = getSession().getAttribute("user") != null; boolean isLoginView = event.getNewView() instanceof SimpleLoginView; @@ -54,10 +54,10 @@ public class SimpleLoginUI extends UI { return true; } - + @Override public void afterViewChange(ViewChangeEvent event) { - + } }); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java index 88a2a8f678..3ff1c2df40 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v70/SimpleLoginView.java @@ -33,7 +33,8 @@ public class SimpleLoginView extends CustomComponent implements View, user.setWidth("300px"); user.setRequired(true); user.setInputPrompt("Your username (eg. joe@email.com)"); - user.addValidator(new EmailValidator("Username must be an email address")); + user.addValidator(new EmailValidator( + "Username must be an email address")); user.setInvalidAllowed(false); // Create the password input field @@ -61,7 +62,7 @@ public class SimpleLoginView extends CustomComponent implements View, viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); } - + @Override public void enter(ViewChangeEvent event) { // focus the username field when user arrives to the login view @@ -119,7 +120,7 @@ public class SimpleLoginView extends CustomComponent implements View, boolean isValid = username.equals("test@test.com") && password.equals("passw0rd"); - if(isValid){ + if (isValid) { // Store the current user in the service session getSession().setAttribute("user", username); @@ -134,4 +135,3 @@ public class SimpleLoginView extends CustomComponent implements View, } } } - diff --git a/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java index e3b8f997e0..63e43b29f1 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v71beta/CSSInjectWithColorpicker.java @@ -30,27 +30,26 @@ public class CSSInjectWithColorpicker extends UI { // Create a text editor Component editor = createEditor("Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - +"Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." - + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " - + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " - + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " - + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " - + "quam, ac urna eros est cras id cras, eleifend eu mattis nec."); - - + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec." + + "Lorem ipsum dolor sit amet, lacus pharetra sed, sit a " + + "tortor. Id aliquam lorem pede, orci ut enim metus, diam nulla mi " + + "suspendisse tempor tortor. Eleifend lorem proin, morbi vel diam ut. " + + "Tempor est tellus vitae, pretium condimentum facilisis sit. Sagittis " + + "quam, ac urna eros est cras id cras, eleifend eu mattis nec."); + VerticalLayout content = new VerticalLayout(editor); content.setMargin(true); setContent(content); @@ -100,10 +99,11 @@ public class CSSInjectWithColorpicker extends UI { TextArea textLabel = new TextArea(null, text); textLabel.setWidth("100%"); textLabel.setHeight("200px"); - - // IMPORTANT: We are here setting the style name of the label, we are going to use this in our injected styles to target the label + + // IMPORTANT: We are here setting the style name of the label, we are + // going to use this in our injected styles to target the label textLabel.setStyleName("text-label"); - + panelContent.addComponent(textLabel); return editor; @@ -203,8 +203,8 @@ public class CSSInjectWithColorpicker extends UI { */ private Component createFontSizeSelect() { - final ComboBox select = new ComboBox(null, Arrays.asList(8, 9, 10, - 12, 14, 16, 20, 25, 30, 40, 50)); + final ComboBox select = new ComboBox(null, Arrays.asList(8, 9, 10, 12, + 14, 16, 20, 25, 30, 40, 50)); select.setWidth("100px"); select.setValue(12); select.setInputPrompt("Font size"); @@ -213,7 +213,7 @@ public class CSSInjectWithColorpicker extends UI { select.setNullSelectionAllowed(false); select.setNewItemsAllowed(false); select.addValueChangeListener(new ValueChangeListener() { - + @Override public void valueChange(ValueChangeEvent event) { // Get the new font size diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java index 5547c1077e..a2723beab3 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java @@ -46,7 +46,7 @@ public class AutoGeneratingForm extends UI { fieldGroup.setItemDataSource(new BeanItem(new Person("John", "Doe", 34))); - // Loop through the properties, build fields for them and add the fields + // Loop through the properties, build fields for them and add the fields // to this root for (Object propertyId : fieldGroup.getUnboundPropertyIds()) { layout.addComponent(fieldGroup.buildAndBind(propertyId)); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java b/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java index 2152e05f14..da9c73dd94 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b6/OpeningUIInPopup.java @@ -27,16 +27,17 @@ public class OpeningUIInPopup extends UI { protected void init(VaadinRequest request) { Button popupButton = new Button("Open popup with MyPopupUI"); - BrowserWindowOpener popupOpener = new BrowserWindowOpener(MyPopupUI.class); + BrowserWindowOpener popupOpener = new BrowserWindowOpener( + MyPopupUI.class); popupOpener.setFeatures("height=300,width=300"); popupOpener.extend(popupButton); - + // Add a parameter popupOpener.setParameter("foo", "bar"); // Set a fragment popupOpener.setUriFragment("myfragment"); - + setContent(popupButton); } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java index 7aaf810355..59708f2bc7 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/CountView.java @@ -14,6 +14,7 @@ public class CountView extends Panel implements View { setContent(new Label("Created: " + count++)); } + @Override public void enter(ViewChangeEvent event) { } diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java index 3aa3e42a58..28f8443440 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/LoginView.java @@ -28,6 +28,7 @@ public class LoginView extends Panel implements View { layout.addComponent(password); final Button login = new Button("Login", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Notification.show("Ok, let's pretend you're " + email); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java index 3a1a685bbe..d37a39345f 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java @@ -42,6 +42,7 @@ public class MainView extends Panel implements View { layout.addComponent(lnk); logOut = new Button("Logout", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(null); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java index 0eac6a042e..861fd9f8a4 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainViewEarlierExample.java @@ -41,6 +41,7 @@ public class MainViewEarlierExample extends Panel implements View { // login/logout toggle so we can test this Button logInOut = new Button("Toggle login", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { Object user = ((NavigationtestUI) UI.getCurrent()) .getLoggedInUser(); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java index 61492adc39..74c4e68b93 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b9/SettingsView.java @@ -43,6 +43,7 @@ public class SettingsView extends Panel implements View { date.setBuffered(true); // show buttons when date is changed date.addValueChangeListener(new ValueChangeListener() { + @Override public void valueChange(ValueChangeEvent event) { hideOrShowButtons(); pendingViewAndParameters = null; @@ -51,6 +52,7 @@ public class SettingsView extends Panel implements View { // commit the TextField changes when "Save" is clicked apply = new Button("Apply", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { date.commit(); hideOrShowButtons(); @@ -61,6 +63,7 @@ public class SettingsView extends Panel implements View { // Discard the TextField changes when "Cancel" is clicked cancel = new Button("Cancel", new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { date.discard(); hideOrShowButtons(); @@ -72,6 +75,7 @@ public class SettingsView extends Panel implements View { // attach a listener so that we'll get asked isViewChangeAllowed? navigator.addViewChangeListener(new ViewChangeListener() { + @Override public boolean beforeViewChange(ViewChangeEvent event) { if (event.getOldView() == SettingsView.this && date.isModified()) { @@ -93,6 +97,7 @@ public class SettingsView extends Panel implements View { } } + @Override public void afterViewChange(ViewChangeEvent event) { pendingViewAndParameters = null; } -- cgit v1.2.3 From 309e3de9152ae9958e6e723ed348712b4b39452e Mon Sep 17 00:00:00 2001 From: johan Date: Mon, 8 Apr 2013 11:55:44 +0300 Subject: Implement range for date field (#6241) Change-Id: I34458f676fede39e1992316cbed8d62193ce8509 --- .../VAADIN/themes/base/datefield/datefield.scss | 13 +- .../src/com/vaadin/client/ui/VCalendarPanel.java | 416 +++++++++++++++++++-- .../src/com/vaadin/client/ui/VPopupCalendar.java | 24 ++ .../ui/datefield/InlineDateFieldConnector.java | 2 + .../ui/datefield/PopupDateFieldConnector.java | 2 + server/src/com/vaadin/ui/DateField.java | 175 +++++++++ .../shared/ui/datefield/InlineDateFieldState.java | 3 +- .../shared/ui/datefield/TextualDateFieldState.java | 14 + .../components/datefield/DateFieldRanges.java | 270 +++++++++++++ ...eCausesOutOfRangeExceptionIfImmediateField.html | 251 +++++++++++++ ...dRangeEarlierThanStartRangeCausesException.html | 91 +++++ .../DateFieldRanges_InitialDatesOutsideRange.html | 121 ++++++ ..._MonthChangeMeansFocusDayRolledInsideRange.html | 100 +++++ ...rClickableIfRangeAcceptsFractionOfNextYear.html | 191 ++++++++++ ...rClickableIfRangeAcceptsFractionOfPrevYear.html | 146 ++++++++ ...es_SettingValueOutsideRangeCausesException.html | 136 +++++++ 16 files changed, 1915 insertions(+), 40 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_ChangingRangeSoValueFallsOutsideRangeCausesOutOfRangeExceptionIfImmediateField.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_EndRangeEarlierThanStartRangeCausesException.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_InitialDatesOutsideRange.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_MonthChangeMeansFocusDayRolledInsideRange.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_NextYearClickableIfRangeAcceptsFractionOfNextYear.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_PrevYearClickableIfRangeAcceptsFractionOfPrevYear.html create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_SettingValueOutsideRangeCausesException.html (limited to 'uitest/src') diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.scss b/WebContent/VAADIN/themes/base/datefield/datefield.scss index 1d3d408ed2..cbba9b46f3 100644 --- a/WebContent/VAADIN/themes/base/datefield/datefield.scss +++ b/WebContent/VAADIN/themes/base/datefield/datefield.scss @@ -59,10 +59,21 @@ .v-disabled .#{$primaryStyleName}-calendarpanel-day-today { cursor: default; } -.#{$primaryStyleName}-calendarpanel-day-disabled { +.#{$primaryStyleName}-calendarpanel-day-disabled, +.#{$primaryStyleName}-calendarpanel-day-outside-range { cursor: default; opacity: .5; } + +.#{$primaryStyleName}-calendarpanel-prevyear, +.#{$primaryStyleName}-calendarpanel-nextyear, +.#{$primaryStyleName}-calendarpanel-prevmonth, +.#{$primaryStyleName}-calendarpanel-nextmonth { + button.outside-range{ + opacity: .5; + } +} + .#{$primaryStyleName}-calendarpanel-day-selected { cursor: default; background: #333; diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java index 3e81ec734b..311932b819 100644 --- a/client/src/com/vaadin/client/ui/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java @@ -121,6 +121,8 @@ public class VCalendarPanel extends FocusableFlexTable implements private static final String CN_OFFMONTH = "offmonth"; + private static final String CN_OUTSIDE_RANGE = "outside-range"; + /** * Represents a click handler for when a user selects a value by using the * mouse @@ -136,6 +138,9 @@ public class VCalendarPanel extends FocusableFlexTable implements @Override public void onClick(ClickEvent event) { Date newDate = ((Day) event.getSource()).getDate(); + if (!isDateInsideRange(newDate, Resolution.DAY)) { + return; + } if (newDate.getMonth() != displayedMonth.getMonth() || newDate.getYear() != displayedMonth.getYear()) { // If an off-month date was clicked, we must change the @@ -298,7 +303,7 @@ public class VCalendarPanel extends FocusableFlexTable implements * Updates year, month, day from focusedDate to value */ private void selectFocused() { - if (focusedDate != null) { + if (focusedDate != null && isDateInsideRange(focusedDate, resolution)) { if (value == null) { // No previously selected value (set to null on server side). // Create a new date using current date and time @@ -405,10 +410,13 @@ public class VCalendarPanel extends FocusableFlexTable implements prevMonth = new VEventButton(); prevMonth.setHTML("‹"); prevMonth.setStyleName("v-button-prevmonth"); + prevMonth.setTabIndex(-1); + nextMonth = new VEventButton(); nextMonth.setHTML("›"); nextMonth.setStyleName("v-button-nextmonth"); + nextMonth.setTabIndex(-1); setWidget(0, 3, nextMonth); @@ -422,18 +430,23 @@ public class VCalendarPanel extends FocusableFlexTable implements } if (prevYear == null) { + prevYear = new VEventButton(); prevYear.setHTML("«"); prevYear.setStyleName("v-button-prevyear"); + prevYear.setTabIndex(-1); nextYear = new VEventButton(); nextYear.setHTML("»"); nextYear.setStyleName("v-button-nextyear"); + nextYear.setTabIndex(-1); setWidget(0, 0, prevYear); setWidget(0, 4, nextYear); } + updateControlButtonRangeStyles(needsMonth); + final String monthName = needsMonth ? getDateTimeService().getMonth( displayedMonth.getMonth()) : ""; final int year = displayedMonth.getYear() + 1900; @@ -454,6 +467,48 @@ public class VCalendarPanel extends FocusableFlexTable implements + ""); } + private void updateControlButtonRangeStyles(boolean needsMonth) { + + if (focusedDate == null) { + return; + } + + if (needsMonth) { + Date prevMonthDate = (Date) focusedDate.clone(); + removeOneMonth(prevMonthDate); + + if (!isDateInsideRange(prevMonthDate, Resolution.MONTH)) { + prevMonth.addStyleName(CN_OUTSIDE_RANGE); + } else { + prevMonth.removeStyleName(CN_OUTSIDE_RANGE); + } + Date nextMonthDate = (Date) focusedDate.clone(); + addOneMonth(nextMonthDate); + if (!isDateInsideRange(nextMonthDate, Resolution.MONTH)) { + nextMonth.addStyleName(CN_OUTSIDE_RANGE); + } else { + nextMonth.removeStyleName(CN_OUTSIDE_RANGE); + } + } + + Date prevYearDate = (Date) focusedDate.clone(); + prevYearDate.setYear(prevYearDate.getYear() - 1); + if (!isDateInsideRange(prevYearDate, Resolution.YEAR)) { + prevYear.addStyleName(CN_OUTSIDE_RANGE); + } else { + prevYear.removeStyleName(CN_OUTSIDE_RANGE); + } + + Date nextYearDate = (Date) focusedDate.clone(); + nextYearDate.setYear(nextYearDate.getYear() + 1); + if (!isDateInsideRange(nextYearDate, Resolution.YEAR)) { + nextYear.addStyleName(CN_OUTSIDE_RANGE); + } else { + nextYear.removeStyleName(CN_OUTSIDE_RANGE); + } + + } + private DateTimeService getDateTimeService() { return dateTimeService; } @@ -477,6 +532,107 @@ public class VCalendarPanel extends FocusableFlexTable implements this.showISOWeekNumbers = showISOWeekNumbers; } + /** + * Checks inclusively whether a date is inside a range of dates or not. + * + * @param date + * @return + */ + private boolean isDateInsideRange(Date date, Resolution minResolution) { + assert (date != null); + + return isAcceptedByRangeEnd(date, minResolution) + && isAcceptedByRangeStart(date, minResolution); + } + + /** + * Accepts dates greater than or equal to rangeStart, depending on the + * resolution. If the resolution is set to DAY, the range will compare on a + * day-basis. If the resolution is set to YEAR, only years are compared. So + * even if the range is set to one millisecond in next year, also next year + * will be included. + * + * @param date + * @param minResolution + * @return + */ + private boolean isAcceptedByRangeStart(Date date, Resolution minResolution) { + assert (date != null); + + // rangeStart == null means that we accept all values below rangeEnd + if (rangeStart == null) { + return true; + } + + Date valueDuplicate = (Date) date.clone(); + Date rangeStartDuplicate = (Date) rangeStart.clone(); + + if (minResolution == Resolution.YEAR) { + return valueDuplicate.getYear() >= rangeStartDuplicate.getYear(); + } + if (minResolution == Resolution.MONTH) { + valueDuplicate = clearDateBelowMonth(valueDuplicate); + rangeStartDuplicate = clearDateBelowMonth(rangeStartDuplicate); + } else { + valueDuplicate = clearDateBelowDay(valueDuplicate); + rangeStartDuplicate = clearDateBelowDay(rangeStartDuplicate); + } + + return !rangeStartDuplicate.after(valueDuplicate); + } + + /** + * Accepts dates earlier than or equal to rangeStart, depending on the + * resolution. If the resolution is set to DAY, the range will compare on a + * day-basis. If the resolution is set to YEAR, only years are compared. So + * even if the range is set to one millisecond in next year, also next year + * will be included. + * + * @param date + * @param minResolution + * @return + */ + private boolean isAcceptedByRangeEnd(Date date, Resolution minResolution) { + assert (date != null); + + // rangeEnd == null means that we accept all values above rangeStart + if (rangeEnd == null) { + return true; + } + + Date valueDuplicate = (Date) date.clone(); + Date rangeEndDuplicate = (Date) rangeEnd.clone(); + + if (minResolution == Resolution.YEAR) { + return valueDuplicate.getYear() <= rangeEndDuplicate.getYear(); + } + if (minResolution == Resolution.MONTH) { + valueDuplicate = clearDateBelowMonth(valueDuplicate); + rangeEndDuplicate = clearDateBelowMonth(rangeEndDuplicate); + } else { + valueDuplicate = clearDateBelowDay(valueDuplicate); + rangeEndDuplicate = clearDateBelowDay(rangeEndDuplicate); + } + + return !rangeEndDuplicate.before(valueDuplicate); + + } + + private static Date clearDateBelowMonth(Date date) { + date.setDate(1); + return clearDateBelowDay(date); + } + + private static Date clearDateBelowDay(Date date) { + date.setHours(0); + date.setMinutes(0); + date.setSeconds(0); + // Clearing milliseconds + long time = date.getTime() / 1000; + date = new Date(time * 1000); + return date; + } + /** * Builds the day and time selectors of the calendar. */ @@ -563,10 +719,16 @@ public class VCalendarPanel extends FocusableFlexTable implements for (int dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) { // Actually write the day of month - Day day = new Day((Date) curr.clone()); + Date dayDate = (Date) curr.clone(); + Day day = new Day(dayDate); + day.setStyleName(parent.getStylePrimaryName() + "-calendarpanel-day"); + if (!isDateInsideRange(dayDate, Resolution.DAY)) { + day.addStyleDependentName(CN_OUTSIDE_RANGE); + } + if (curr.equals(selectedDate)) { day.addStyleDependentName(CN_SELECTED); Roles.getGridcellRole().setAriaSelectedState( @@ -672,6 +834,17 @@ public class VCalendarPanel extends FocusableFlexTable implements * Moves the focus forward the given number of days. */ private void focusNextDay(int days) { + if (focusedDate == null) { + return; + } + + Date focusCopy = ((Date) focusedDate.clone()); + focusCopy.setDate(focusedDate.getDate() + days); + if (!isDateInsideRange(focusCopy, resolution)) { + // If not inside allowed range, then do not move anything + return; + } + int oldMonth = focusedDate.getMonth(); int oldYear = focusedDate.getYear(); focusedDate.setDate(focusedDate.getDate() + days); @@ -681,6 +854,7 @@ public class VCalendarPanel extends FocusableFlexTable implements // Month did not change, only move the selection focusDay(focusedDate); } else { + // If the month changed we need to re-render the calendar displayedMonth.setMonth(focusedDate.getMonth()); displayedMonth.setYear(focusedDate.getYear()); @@ -700,38 +874,83 @@ public class VCalendarPanel extends FocusableFlexTable implements */ private void focusNextMonth() { - int currentMonth = focusedDate.getMonth(); - focusedDate.setMonth(currentMonth + 1); + if (focusedDate == null) { + return; + } + // Trying to request next month + Date requestedNextMonthDate = (Date) focusedDate.clone(); + addOneMonth(requestedNextMonthDate); + + if (!isDateInsideRange(requestedNextMonthDate, Resolution.MONTH)) { + return; + } + + // Now also checking whether the day is inside the range or not. If not + // inside, + // correct it + if (!isDateInsideRange(requestedNextMonthDate, Resolution.DAY)) { + requestedNextMonthDate = adjustDateToFitInsideRange(requestedNextMonthDate); + } + focusedDate.setYear(requestedNextMonthDate.getYear()); + focusedDate.setMonth(requestedNextMonthDate.getMonth()); + focusedDate.setDate(requestedNextMonthDate.getDate()); + displayedMonth.setMonth(displayedMonth.getMonth() + 1); + + renderCalendar(); + } + + private static void addOneMonth(Date date) { + int currentMonth = date.getMonth(); int requestedMonth = (currentMonth + 1) % 12; + date.setMonth(date.getMonth() + 1); + /* * If the selected value was e.g. 31.3 the new value would be 31.4 but * this value is invalid so the new value will be 1.5. This is taken * care of by decreasing the value until we have the correct month. */ - while (focusedDate.getMonth() != requestedMonth) { - focusedDate.setDate(focusedDate.getDate() - 1); + while (date.getMonth() != requestedMonth) { + date.setDate(date.getDate() - 1); } - displayedMonth.setMonth(displayedMonth.getMonth() + 1); - - renderCalendar(); } - /** - * Selects the previous month - */ - private void focusPreviousMonth() { - int currentMonth = focusedDate.getMonth(); - focusedDate.setMonth(currentMonth - 1); + private static void removeOneMonth(Date date) { + int currentMonth = date.getMonth(); + + date.setMonth(date.getMonth() - 1); /* * If the selected value was e.g. 31.12 the new value would be 31.11 but * this value is invalid so the new value will be 1.12. This is taken * care of by decreasing the value until we have the correct month. */ - while (focusedDate.getMonth() == currentMonth) { - focusedDate.setDate(focusedDate.getDate() - 1); + while (date.getMonth() == currentMonth) { + date.setDate(date.getDate() - 1); } + } + + /** + * Selects the previous month + */ + private void focusPreviousMonth() { + + if (focusedDate == null) { + return; + } + Date requestedPreviousMonthDate = (Date) focusedDate.clone(); + removeOneMonth(requestedPreviousMonthDate); + + if (!isDateInsideRange(requestedPreviousMonthDate, Resolution.MONTH)) { + return; + } + + if (!isDateInsideRange(requestedPreviousMonthDate, Resolution.DAY)) { + requestedPreviousMonthDate = adjustDateToFitInsideRange(requestedPreviousMonthDate); + } + focusedDate.setYear(requestedPreviousMonthDate.getYear()); + focusedDate.setMonth(requestedPreviousMonthDate.getMonth()); + focusedDate.setDate(requestedPreviousMonthDate.getDate()); displayedMonth.setMonth(displayedMonth.getMonth() - 1); renderCalendar(); @@ -741,16 +960,41 @@ public class VCalendarPanel extends FocusableFlexTable implements * Selects the previous year */ private void focusPreviousYear(int years) { - int currentMonth = focusedDate.getMonth(); - focusedDate.setYear(focusedDate.getYear() - years); - displayedMonth.setYear(displayedMonth.getYear() - years); - /* - * If the focused date was a leap day (Feb 29), the new date becomes Mar - * 1 if the new year is not also a leap year. Set it to Feb 28 instead. - */ - if (focusedDate.getMonth() != currentMonth) { - focusedDate.setDate(0); + + if (focusedDate == null) { + return; } + Date previousYearDate = (Date) focusedDate.clone(); + previousYearDate.setYear(previousYearDate.getYear() - years); + // Do not focus if not inside range + if (!isDateInsideRange(previousYearDate, Resolution.YEAR)) { + return; + } + // If we remove one year, but have to roll back a bit, fit it + // into the calendar. Also the months have to be changed + if (!isDateInsideRange(previousYearDate, Resolution.DAY)) { + previousYearDate = adjustDateToFitInsideRange(previousYearDate); + + focusedDate.setYear(previousYearDate.getYear()); + focusedDate.setMonth(previousYearDate.getMonth()); + focusedDate.setDate(previousYearDate.getDate()); + displayedMonth.setYear(previousYearDate.getYear()); + displayedMonth.setMonth(previousYearDate.getMonth()); + } else { + + int currentMonth = focusedDate.getMonth(); + focusedDate.setYear(focusedDate.getYear() - years); + displayedMonth.setYear(displayedMonth.getYear() - years); + /* + * If the focused date was a leap day (Feb 29), the new date becomes + * Mar 1 if the new year is not also a leap year. Set it to Feb 28 + * instead. + */ + if (focusedDate.getMonth() != currentMonth) { + focusedDate.setDate(0); + } + } + renderCalendar(); } @@ -758,16 +1002,41 @@ public class VCalendarPanel extends FocusableFlexTable implements * Selects the next year */ private void focusNextYear(int years) { - int currentMonth = focusedDate.getMonth(); - focusedDate.setYear(focusedDate.getYear() + years); - displayedMonth.setYear(displayedMonth.getYear() + years); - /* - * If the focused date was a leap day (Feb 29), the new date becomes Mar - * 1 if the new year is not also a leap year. Set it to Feb 28 instead. - */ - if (focusedDate.getMonth() != currentMonth) { - focusedDate.setDate(0); + + if (focusedDate == null) { + return; + } + Date nextYearDate = (Date) focusedDate.clone(); + nextYearDate.setYear(nextYearDate.getYear() + years); + // Do not focus if not inside range + if (!isDateInsideRange(nextYearDate, Resolution.YEAR)) { + return; } + // If we add one year, but have to roll back a bit, fit it + // into the calendar. Also the months have to be changed + if (!isDateInsideRange(nextYearDate, Resolution.DAY)) { + nextYearDate = adjustDateToFitInsideRange(nextYearDate); + + focusedDate.setYear(nextYearDate.getYear()); + focusedDate.setMonth(nextYearDate.getMonth()); + focusedDate.setDate(nextYearDate.getDate()); + displayedMonth.setYear(nextYearDate.getYear()); + displayedMonth.setMonth(nextYearDate.getMonth()); + } else { + + int currentMonth = focusedDate.getMonth(); + focusedDate.setYear(focusedDate.getYear() + years); + displayedMonth.setYear(displayedMonth.getYear() + years); + /* + * If the focused date was a leap day (Feb 29), the new date becomes + * Mar 1 if the new year is not also a leap year. Set it to Feb 28 + * instead. + */ + if (focusedDate.getMonth() != currentMonth) { + focusedDate.setDate(0); + } + } + renderCalendar(); } @@ -1265,6 +1534,20 @@ public class VCalendarPanel extends FocusableFlexTable implements } } + /** + * Adjusts a date to fit inside the range, only if outside + * + * @param date + */ + private Date adjustDateToFitInsideRange(Date date) { + if (rangeStart != null && rangeStart.after(date)) { + date = (Date) rangeStart.clone(); + } else if (rangeEnd != null && rangeEnd.before(date)) { + date = (Date) rangeEnd.clone(); + } + return date; + } + /** * Sets the data of the Panel. * @@ -1277,12 +1560,42 @@ public class VCalendarPanel extends FocusableFlexTable implements if (currentDate == value && currentDate != null) { return; } + boolean currentDateWasAdjusted = false; + // Check that selected date is inside the allowed range + if (currentDate != null && !isDateInsideRange(currentDate, resolution)) { + currentDate = adjustDateToFitInsideRange(currentDate); + currentDateWasAdjusted = true; + } Date oldDisplayedMonth = displayedMonth; value = currentDate; - if (value == null) { - focusedDate = displayedMonth = null; + // If current date was adjusted, we will not select any date, + // since that will look like a date is selected. Instead we + // only focus on the adjusted value + if (value == null || currentDateWasAdjusted) { + // If ranges enabled, we may need to focus on a different view to + // potentially not get stuck + if (rangeStart != null || rangeEnd != null) { + Date dateThatFitsInsideRange = adjustDateToFitInsideRange(new Date()); + focusedDate = new FocusedDate( + dateThatFitsInsideRange.getYear(), + dateThatFitsInsideRange.getMonth(), + dateThatFitsInsideRange.getDate()); + displayedMonth = new FocusedDate( + dateThatFitsInsideRange.getYear(), + dateThatFitsInsideRange.getMonth(), 1); + // value was adjusted. Set selected to null to not cause + // confusion, but this is only needed (and allowed) when we have + // a day + // resolution + if (getResolution().getCalendarField() >= Resolution.DAY + .getCalendarField()) { + value = null; + } + } else { + focusedDate = displayedMonth = null; + } } else { focusedDate = new FocusedDate(value.getYear(), value.getMonth(), value.getDate()); @@ -1725,6 +2038,10 @@ public class VCalendarPanel extends FocusableFlexTable implements private static final String SUBPART_DAY = "day"; private static final String SUBPART_MONTH_YEAR_HEADER = "header"; + private Date rangeStart; + + private Date rangeEnd; + @Override public String getSubPartName(Element subElement) { if (contains(nextMonth, subElement)) { @@ -1888,4 +2205,29 @@ public class VCalendarPanel extends FocusableFlexTable implements } } } + + /** + * Sets the start range for this component. The start range is inclusive, + * and it depends on the current resolution, what is considered inside the + * range. + * + * @param startDate + * - the allowed range's start date + */ + public void setRangeStart(Date rangeStart) { + this.rangeStart = rangeStart; + + } + + /** + * Sets the end range for this component. The end range is inclusive, and it + * depends on the current resolution, what is considered inside the range. + * + * @param endDate + * - the allowed range's end date + */ + public void setRangeEnd(Date rangeEnd) { + this.rangeEnd = rangeEnd; + + } } diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java index aa34a1b4e3..87dd4061a7 100644 --- a/client/src/com/vaadin/client/ui/VPopupCalendar.java +++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java @@ -581,4 +581,28 @@ public class VPopupCalendar extends VTextualDate implements Field, public String getDescriptionForAssistiveDevices() { return descriptionForAssisitveDevicesElement.getInnerText(); } + + /** + * Sets the start range for this component. The start range is inclusive, + * and it depends on the current resolution, what is considered inside the + * range. + * + * @param startDate + * - the allowed range's start date + */ + public void setRangeStart(Date rangeStart) { + calendar.setRangeStart(rangeStart); + } + + /** + * Sets the end range for this component. The end range is inclusive, and it + * depends on the current resolution, what is considered inside the range. + * + * @param endDate + * - the allowed range's end date + */ + public void setRangeEnd(Date rangeEnd) { + calendar.setRangeEnd(rangeEnd); + } + } diff --git a/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java b/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java index beff3eaa72..2fb40b3cdb 100644 --- a/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java +++ b/client/src/com/vaadin/client/ui/datefield/InlineDateFieldConnector.java @@ -114,6 +114,8 @@ public class InlineDateFieldConnector extends AbstractDateFieldConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); getWidget().setTabIndex(getState().tabIndex); + getWidget().calendarPanel.setRangeStart(getState().rangeStart); + getWidget().calendarPanel.setRangeEnd(getState().rangeEnd); } @Override diff --git a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java index f59ac713e8..b3bb481658 100644 --- a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java +++ b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java @@ -138,6 +138,8 @@ public class PopupDateFieldConnector extends TextualDateConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); getWidget().setTextFieldEnabled(getState().textFieldEnabled); + getWidget().setRangeStart(getState().rangeStart); + getWidget().setRangeEnd(getState().rangeEnd); } @Override diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 78c86ceb00..c1c3ffe0bf 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -29,6 +29,7 @@ import com.vaadin.data.Property; import com.vaadin.data.Validator; import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.data.util.converter.Converter; +import com.vaadin.data.validator.DateRangeValidator; import com.vaadin.event.FieldEvents; import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; @@ -38,6 +39,7 @@ import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.shared.ui.datefield.DateFieldConstants; import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.shared.ui.datefield.TextualDateFieldState; /** *

    @@ -146,6 +148,10 @@ public class DateField extends AbstractField implements private TimeZone timeZone = null; private static Map variableNameForResolution = new HashMap(); + + private String dateOutOfRangeMessage = "Date is out of allowed range"; + + private DateRangeValidator currentRangeValidator; { variableNameForResolution.put(Resolution.SECOND, "sec"); variableNameForResolution.put(Resolution.MINUTE, "min"); @@ -277,6 +283,174 @@ public class DateField extends AbstractField implements return super.shouldHideErrors() && uiHasValidDateString; } + @Override + protected TextualDateFieldState getState() { + return (TextualDateFieldState) super.getState(); + } + + @Override + protected TextualDateFieldState getState(boolean markAsDirty) { + return (TextualDateFieldState) super.getState(markAsDirty); + } + + /** + * Sets the start range for this component. If the value is set before this + * date (taking the resolution into account), the component will not + * validate. If startDate is set to null, any + * value before endDate will be accepted by the range + * + * @param startDate + * - the allowed range's start date + */ + public void setRangeStart(Date startDate) { + if (startDate != null && getState().rangeEnd != null + && startDate.after(getState().rangeEnd)) { + throw new IllegalStateException( + "startDate cannot be later than endDate"); + } + getState().rangeStart = startDate; + // rangeStart = startDate; + // This has to be done to correct for the resolution + // updateRangeState(); + updateRangeValidator(); + } + + /** + * Sets the current error message if the range validation fails. + * + * @param dateOutOfRangeMessage + * - Localizable message which is shown when value (the date) is + * set outside allowed range + */ + public void setDateOutOfRangeMessage(String dateOutOfRangeMessage) { + this.dateOutOfRangeMessage = dateOutOfRangeMessage; + updateRangeValidator(); + } + + /** + * Gets the end range for a certain resolution. The range is inclusive, so + * if rangeEnd is set to zero milliseconds past year n and resolution is set + * to YEAR, any date in year n will be accepted. Resolutions lower than DAY + * will be interpreted on a DAY level. That is, everything below DATE is + * cleared + * + * @param forResolution + * - the range conforms to the resolution + * @return + */ + private Date getRangeEnd(Resolution forResolution) { + // We need to set the correct resolution for the dates, + // otherwise the range validator will complain + + Date rangeEnd = getState(false).rangeEnd; + if (rangeEnd == null) { + return null; + } + + Calendar endCal = Calendar.getInstance(); + endCal.setTime(rangeEnd); + + if (forResolution == Resolution.YEAR) { + // Adding one year (minresolution) and clearing the rest. + endCal.set(endCal.get(Calendar.YEAR) + 1, 0, 1, 0, 0, 0); + } else if (forResolution == Resolution.MONTH) { + // Adding one month (minresolution) and clearing the rest. + endCal.set(endCal.get(Calendar.YEAR), + endCal.get(Calendar.MONTH) + 1, 1, 0, 0, 0); + } else { + endCal.set(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH), + endCal.get(Calendar.DATE) + 1, 0, 0, 0); + } + // removing one millisecond will now get the endDate to return to + // current resolution's set time span (year or month) + endCal.set(Calendar.MILLISECOND, -1); + return endCal.getTime(); + } + + /** + * Gets the start range for a certain resolution. The range is inclusive, so + * if rangeStart is set to one millisecond before year n and + * resolution is set to YEAR, any date in year n - 1 will be accepted. + * Lowest supported resolution is DAY. + * + * @param forResolution + * - the range conforms to the resolution + * @return + */ + private Date getRangeStart(Resolution forResolution) { + if (getState(false).rangeStart == null) { + return null; + } + Calendar startCal = Calendar.getInstance(); + startCal.setTime(getState(false).rangeStart); + + if (forResolution == Resolution.YEAR) { + startCal.set(startCal.get(Calendar.YEAR), 0, 1, 0, 0, 0); + } else if (forResolution == Resolution.MONTH) { + startCal.set(startCal.get(Calendar.YEAR), + startCal.get(Calendar.MONTH), 1, 0, 0, 0); + } else { + startCal.set(startCal.get(Calendar.YEAR), + startCal.get(Calendar.MONTH), startCal.get(Calendar.DATE), + 0, 0, 0); + } + + startCal.set(Calendar.MILLISECOND, 0); + return startCal.getTime(); + } + + private void updateRangeValidator() { + if (currentRangeValidator != null) { + removeValidator(currentRangeValidator); + } + + currentRangeValidator = new DateRangeValidator(dateOutOfRangeMessage, + getRangeStart(resolution), getRangeEnd(resolution), null); + + addValidator(currentRangeValidator); + + } + + /** + * Sets the end range for this component. If the value is set after this + * date (taking the resolution into account), the component will not + * validate. If endDate is set to null, any value + * after startDate will be accepted by the range. + * + * @param endDate + * - the allowed range's end date (inclusive, based on the + * current resolution) + */ + public void setRangeEnd(Date endDate) { + if (endDate != null && getState().rangeStart != null + && getState().rangeStart.after(endDate)) { + throw new IllegalStateException( + "endDate cannot be earlier than startDate"); + } + // rangeEnd = endDate; + getState().rangeEnd = endDate; + updateRangeValidator(); + } + + /** + * Returns the precise rangeStart used. + * + * @param startDate + * + */ + public Date getRangeStart() { + return getState(false).rangeStart; + } + + /** + * Returns the precise rangeEnd used. + * + * @param startDate + */ + public Date getRangeEnd() { + return getState(false).rangeEnd; + } + /* * Invoked when a variable of the component changes. Don't add a JavaDoc * comment here, we use the default documentation from implemented @@ -572,6 +746,7 @@ public class DateField extends AbstractField implements */ public void setResolution(Resolution resolution) { this.resolution = resolution; + updateRangeValidator(); markAsDirty(); } diff --git a/shared/src/com/vaadin/shared/ui/datefield/InlineDateFieldState.java b/shared/src/com/vaadin/shared/ui/datefield/InlineDateFieldState.java index 405f89d538..d15d8de100 100644 --- a/shared/src/com/vaadin/shared/ui/datefield/InlineDateFieldState.java +++ b/shared/src/com/vaadin/shared/ui/datefield/InlineDateFieldState.java @@ -15,9 +15,8 @@ */ package com.vaadin.shared.ui.datefield; -import com.vaadin.shared.AbstractFieldState; -public class InlineDateFieldState extends AbstractFieldState { +public class InlineDateFieldState extends TextualDateFieldState { { primaryStyleName = "v-inline-datefield"; } diff --git a/shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java b/shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java index c34f3d8eda..11ad4cdb59 100644 --- a/shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java +++ b/shared/src/com/vaadin/shared/ui/datefield/TextualDateFieldState.java @@ -15,10 +15,24 @@ */ package com.vaadin.shared.ui.datefield; +import java.util.Date; + import com.vaadin.shared.AbstractFieldState; public class TextualDateFieldState extends AbstractFieldState { { primaryStyleName = "v-datefield"; } + + /* + * Start range that has been cleared, depending on the resolution of the + * date field + */ + public Date rangeStart = null; + + /* + * End range that has been cleared, depending on the resolution of the date + * field + */ + public Date rangeEnd = null; } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges.java new file mode 100644 index 0000000000..2daa3e3f96 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges.java @@ -0,0 +1,270 @@ +package com.vaadin.tests.components.datefield; + +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.shared.ui.datefield.Resolution; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.DateField; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.Label; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.VerticalLayout; + +public class DateFieldRanges extends AbstractTestUI { + + @Override + protected Integer getTicketNumber() { + return 6241; + } + + private Label label = new Label(); + private NativeSelect resoSelect = new NativeSelect("Resolution"); + private DateField fromRange = new DateField("Range start"); + private DateField toRange = new DateField("Range end"); + private DateField valueDF = new DateField("Value"); + private CheckBox immediateCB = new CheckBox("Immediate"); + private Button recreate = new Button("Recreate static datefields"); + private Button clearRangeButton = new Button("Clear range"); + + private GridLayout currentStaticContainer; + + private DateField inlineDynamicDateField; + private DateField dynamicDateField; + + private Calendar createCalendar() { + Calendar c = Calendar.getInstance(); + c.set(2013, 3, 26, 6, 1, 12); + return c; + } + + private Date newDate() { + return createCalendar().getTime(); + } + + private void initializeControlFields() { + resoSelect.addItem(Resolution.MINUTE); + resoSelect.addItem(Resolution.SECOND); + resoSelect.addItem(Resolution.HOUR); + resoSelect.addItem(Resolution.DAY); + resoSelect.addItem(Resolution.MONTH); + resoSelect.addItem(Resolution.YEAR); + resoSelect.setImmediate(true); + resoSelect.setValue(Resolution.DAY); + resoSelect.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + Resolution r = (Resolution) resoSelect.getValue(); + inlineDynamicDateField.setResolution(r); + dynamicDateField.setResolution(r); + + } + }); + + fromRange.setValue(null); + fromRange.setImmediate(true); + fromRange.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + inlineDynamicDateField.setRangeStart(fromRange.getValue()); + dynamicDateField.setRangeStart(fromRange.getValue()); + + } + }); + + toRange.setValue(null); + toRange.setImmediate(true); + toRange.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + inlineDynamicDateField.setRangeEnd(toRange.getValue()); + dynamicDateField.setRangeEnd(toRange.getValue()); + + } + }); + + valueDF.setValue(null); + valueDF.setImmediate(true); + valueDF.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + inlineDynamicDateField.setValue(valueDF.getValue()); + dynamicDateField.setValue(valueDF.getValue()); + + } + }); + + immediateCB.setValue(true); + immediateCB.setImmediate(true); + immediateCB.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + inlineDynamicDateField.setImmediate(immediateCB.getValue()); + dynamicDateField.setImmediate(immediateCB.getValue()); + + } + }); + + recreate.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + GridLayout newContainer = createStaticFields(); + replaceComponent(currentStaticContainer, newContainer); + currentStaticContainer = newContainer; + } + }); + + clearRangeButton.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + fromRange.setValue(null); + toRange.setValue(null); + } + }); + + Calendar startCal = createCalendar(); + Calendar endCal = createCalendar(); + endCal.add(Calendar.DATE, 30); + + dynamicDateField = createDateField(startCal.getTime(), + endCal.getTime(), null, Resolution.DAY, false); + inlineDynamicDateField = createDateField(startCal.getTime(), + endCal.getTime(), null, Resolution.DAY, true); + + resoSelect.setId("resoSelect"); + fromRange.setId("fromRange"); + toRange.setId("toRange"); + valueDF.setId("valueDF"); + immediateCB.setId("immediateCB"); + recreate.setId("recreate"); + clearRangeButton.setId("clearRangeButton"); + dynamicDateField.setId("dynamicDateField"); + inlineDynamicDateField.setId("inlineDynamicDateField"); + + } + + @Override + protected void setup(VaadinRequest request) { + setLocale(new Locale("en", "US")); + getLayout().setWidth(100, Unit.PERCENTAGE); + getLayout().setHeight(null); + getLayout().setMargin(new MarginInfo(true, false, false, false)); + getLayout().setSpacing(true); + + initializeControlFields(); + + GridLayout gl = new GridLayout(2, 2); + gl.setSpacing(true); + + gl.addComponent(dynamicDateField); + gl.addComponent(inlineDynamicDateField); + + HorizontalLayout hl = new HorizontalLayout(); + hl.setSpacing(true); + hl.addComponent(resoSelect); + hl.addComponent(fromRange); + hl.addComponent(toRange); + hl.addComponent(valueDF); + hl.addComponent(immediateCB); + hl.addComponent(recreate); + hl.addComponent(clearRangeButton); + addComponent(hl); + addComponent(new Label("Dynamic DateFields")); + addComponent(gl); + currentStaticContainer = createStaticFields(); + addComponent(new Label("Static DateFields")); + addComponent(currentStaticContainer); + + addComponent(label); + + } + + private GridLayout createStaticFields() { + Calendar startCal = createCalendar(); + Calendar endCal = createCalendar(); + endCal.add(Calendar.DATE, 30); + GridLayout gl = new GridLayout(2, 2); + gl.setSpacing(true); + DateField df = createDateField(startCal.getTime(), endCal.getTime(), + null, Resolution.DAY, false); + gl.addComponent(df); + DateField inline = createDateField(startCal.getTime(), + endCal.getTime(), null, Resolution.DAY, true); + gl.addComponent(inline); + inline.setId("staticInline"); + VerticalLayout vl = new VerticalLayout(); + + return gl; + } + + private DateField createDateField(Date rangeStart, Date rangeEnd, + Date value, Resolution resolution, boolean inline) { + + DateField df = null; + + if (inline) { + df = new InlineDateField(); + } else { + df = new DateField(); + } + + final DateField gg = df; + updateValuesForDateField(df); + + df.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + label.setValue((gg.getValue() == null ? "Nothing" : gg + .getValue().toString()) + + " selected. isValid: " + + gg.isValid()); + } + }); + return df; + } + + @Override + protected String getTestDescription() { + return "Not defined yet"; + + } + + private void updateValuesForDateField(DateField df) { + Date fromVal = fromRange.getValue(); + Date toVal = toRange.getValue(); + Date 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); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_ChangingRangeSoValueFallsOutsideRangeCausesOutOfRangeExceptionIfImmediateField.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_ChangingRangeSoValueFallsOutsideRangeCausesOutOfRangeExceptionIfImmediateField.html new file mode 100644 index 0000000000..e6b498c6f7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_ChangingRangeSoValueFallsOutsideRangeCausesOutOfRangeExceptionIfImmediateField.html @@ -0,0 +1,251 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges?restartApplication
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field59,10
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4/4/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field36,13
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field2
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field2
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field2/2/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field48,13
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5/5/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field50,7
    mouseClickxpath=(//button[@type='button'])[8]12,14
    assertTextPresentApril 2013
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#popupButton14,15
    mouseClickxpath=(//button[@type='button'])[15]14,11
    mouseClickxpath=(//button[@type='button'])[15]14,11
    mouseClick//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[4]/span18,12
    assertCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    assertTextPresentMarch 2013
    assertTextPresentApril 2013
    clickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]
    assertTextNotPresentApril 2013
    mouseClickxpath=(//button[@type='button'])[7]15,7
    mouseClickxpath=(//button[@type='button'])[7]15,7
    mouseClickxpath=(//button[@type='button'])[6]14,14
    mouseClickxpath=(//button[@type='button'])[12]18,11
    mouseClickxpath=(//button[@type='button'])[12]12,10
    mouseClickxpath=(//button[@type='button'])[11]17,14
    assertTextPresentFebruary 2013
    assertCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    mouseClick//div[@id='staticInline']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[5]/span14,7
    mouseClick//div[@id='inlineDynamicDateField']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[5]/span15,6
    assertCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    assertCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    mouseClick//div[@id='staticInline']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[8]/span14,8
    mouseClick//div[@id='inlineDynamicDateField']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[8]/span19,4
    assertNotCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    assertNotCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    + + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_EndRangeEarlierThanStartRangeCausesException.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_EndRangeEarlierThanStartRangeCausesException.html new file mode 100644 index 0000000000..e0c5721c27 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_EndRangeEarlierThanStartRangeCausesException.html @@ -0,0 +1,91 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges?restartApplication
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field44,6
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field4/4/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field41,14
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field3
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field3
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field3/3/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field33,9
    assertCSSClass//div[@id='gwt-uid-16']/span[2]v-errorindicator
    + + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_InitialDatesOutsideRange.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_InitialDatesOutsideRange.html new file mode 100644 index 0000000000..eeeda5270b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_InitialDatesOutsideRange.html @@ -0,0 +1,121 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field39,14
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1/1/13
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field31,13
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field2
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field1/2/11
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field111
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field1/1/10
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field52,12
    clickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[5]/VButton[0]/domChild[0]
    assertCSSClassvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VGridLayout[0]/domChild[2]/domChild[0]/domChild[0]v-errorindicator
    + + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_MonthChangeMeansFocusDayRolledInsideRange.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_MonthChangeMeansFocusDayRolledInsideRange.html new file mode 100644 index 0000000000..6e1ca024cb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_MonthChangeMeansFocusDayRolledInsideRange.html @@ -0,0 +1,100 @@ + + open + /run/com.vaadin.tests.components.datefield.DateFieldRanges + + + + mouseClick + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + 27,11 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + 1 + + + pressSpecialKey + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + shift 7 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + 1 + + + pressSpecialKey + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + shift 7 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field + 1/1/10 + + + mouseClick + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + 47,10 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + 2 + + + pressSpecialKey + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + shift 7 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + 2 + + + pressSpecialKey + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + shift 7 + + + type + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field + 2/2/10 + + + mouseClick + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field + 15,8 + + + mouseClick + vaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VGridLayout[0]/VPopupCalendar[0]#popupButton + 9,14 + + + pressSpecialKey + id=PID_VAADIN_POPUPCAL + left + + + pressSpecialKey + id=PID_VAADIN_POPUPCAL + left + + + assertText + //table[@id='PID_VAADIN_POPUPCAL']/tbody/tr/td[3]/span + January 2010 + + + pressSpecialKey + id=PID_VAADIN_POPUPCAL + right + + + assertText + //table[@id='PID_VAADIN_POPUPCAL']/tbody/tr/td[3]/span + February 2010 + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_NextYearClickableIfRangeAcceptsFractionOfNextYear.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_NextYearClickableIfRangeAcceptsFractionOfNextYear.html new file mode 100644 index 0000000000..f5d7ee97ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_NextYearClickableIfRangeAcceptsFractionOfNextYear.html @@ -0,0 +1,191 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field37,13
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field1/1/15
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field35,7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field12
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field12
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field12/12/14
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field40,10
    assertTextPresentDecember 2014
    mouseClickxpath=(//button[@type='button'])[8]11,8
    assertTextPresentJanuary 2015
    mouseClickxpath=(//button[@type='button'])[7]13,10
    assertTextPresentJanuary 2015
    mouseClickxpath=(//button[@type='button'])[8]6,7
    assertTextPresentJanuary 2015
    mouseClickxpath=(//button[@type='button'])[6]15,7
    mouseClickxpath=(//button[@type='button'])[5]8,8
    assertTextPresentDecember 2013
    selectvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::PID_SresoSelect/domChild[0]label=MONTH
    mouseClickxpath=(//button[@type='button'])[8]13,11
    assertTextPresentJanuary 2015
    mouseClickxpath=(//button[@type='button'])[6]12,13
    mouseClickxpath=(//button[@type='button'])[5]12,13
    assertTextPresentDecember 2013
    selectvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::PID_SresoSelect/domChild[0]label=YEAR
    mouseClickxpath=(//button[@type='button'])[6]8,12
    mouseClickxpath=(//button[@type='button'])[6]8,12
    mouseClickxpath=(//button[@type='button'])[6]8,12
    assertTextPresent2015
    + + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_PrevYearClickableIfRangeAcceptsFractionOfPrevYear.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_PrevYearClickableIfRangeAcceptsFractionOfPrevYear.html new file mode 100644 index 0000000000..4c671b266d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_PrevYearClickableIfRangeAcceptsFractionOfPrevYear.html @@ -0,0 +1,146 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field33,10
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field12
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field12
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field12/12/10
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field32,9
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field11
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldenter
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field1/1/11
    assertTextPresentJanuary 2011
    mouseClickxpath=(//button[@type='button'])[5]13,12
    assertTextPresentDecember 2010
    mouseClickxpath=(//button[@type='button'])[6]9,7
    assertTextPresentDecember 2010
    mouseClickxpath=(//button[@type='button'])[5]5,0
    assertTextPresentDecember 2010
    mouseClickxpath=(//button[@type='button'])[7]16,9
    mouseClickxpath=(//button[@type='button'])[7]16,9
    mouseClickxpath=(//button[@type='button'])[8]19,8
    assertTextPresentFebruary 2012
    + + diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_SettingValueOutsideRangeCausesException.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_SettingValueOutsideRangeCausesException.html new file mode 100644 index 0000000000..c3f7e021a8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldRanges_SettingValueOutsideRangeCausesException.html @@ -0,0 +1,136 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run/com.vaadin.tests.components.datefield.DateFieldRanges
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field36,8
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#field4/4/12
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field40,11
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field3
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field3
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VPopupCalendar[0]#field3/3/12
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field40,5
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5
    pressSpecialKeyvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#fieldshift 7
    typevaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[2]/VPopupCalendar[0]#field5/5/12
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]393,89
    mouseClickvaadin=runcomvaadintestscomponentsdatefieldDateFieldRanges::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[3]/VPopupCalendar[0]#popupButton10,8
    mouseClickxpath=(//button[@type='button'])[17]12,11
    mouseClick//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[5]/span13,9
    assertTextPresentMay 2012
    + + -- cgit v1.2.3 From 8a2e8ff43e477f6269dc21469efee044d65e12b8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 5 Apr 2013 18:41:52 +0300 Subject: Fixed broken tests * Added missing screenshot identifiers * Removed redundant test * DebugConsole -> DebugWindow * Updated test to show why serialization fails * Fixed problems caused by added maximize button Change-Id: I5cf76fec7170747120b7243f9693851cd52c12af --- .../calendar/CalendarSizeTest1000x600px.html | 4 +- .../CalendarSizeTest100percentXundefined.html | 4 +- .../calendar/CalendarSizeTest100x100percent.html | 4 +- .../calendar/CalendarSizeTest300pxXundefined.html | 4 +- .../calendar/CalendarSizeTestSizeFull.html | 41 ---------------- .../CalendarSizeTestUndefinedX100percent.html | 4 +- .../calendar/CalendarSizeTestUndefinedX300px.html | 4 +- .../CalendarSizeTestUndefinedXUndefined.html | 4 +- .../tests/components/ui/UIInitException.html | 4 +- .../tests/components/ui/UISerialization.java | 56 ++++++++++++---------- .../tests/components/window/CloseSubWindow.html | 7 +-- .../tests/components/window/CloseSubWindow.java | 2 +- .../tests/components/window/SubWindowOrder.html | 6 +-- .../window/WindowMaximizeRestoreTest.html | 2 +- .../window/WindowWithInvalidCloseListener.html | 2 +- .../com/vaadin/tests/debug/DebugWindowPresent.html | 16 +++---- .../tests/requesthandlers/AppResource404.html | 7 ++- 17 files changed, 69 insertions(+), 102 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html index 66d2c2f126..bd4c671361 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest1000x600px.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html index 7c963f547f..64b5444d34 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100percentXundefined.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html index 19f03db784..0905034b13 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest100x100percent.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html index 70f6dbd75b..99327a01df 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTest300pxXundefined.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html deleted file mode 100644 index 59d39226d9..0000000000 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestSizeFull.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -sizeTestSizeFull - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    sizeTestSizeFull
    open/run/com.vaadin.tests.components.calendar.CalendarTest?testBench&restartApplication
    assertTextvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VHorizontalLayout[1]/Slot[1]/VLabel[0]Jan 2000
    screenCapture
    mouseClickvaadin=runcomvaadintestscomponentscalendarCalendarTest::/VGridLayout[0]/VCalendar[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]9,56
    screenCapture
    - - diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html index d48917904c..2e4c811ff1 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX100percent.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html index 2dfce00635..cca66c7145 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedX300px.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html index 3bfae6be35..e4a8da691b 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarSizeTestUndefinedXUndefined.html @@ -24,7 +24,7 @@ screenCapture - + month mouseClick @@ -34,7 +34,7 @@ screenCapture - + week diff --git a/uitest/src/com/vaadin/tests/components/ui/UIInitException.html b/uitest/src/com/vaadin/tests/components/ui/UIInitException.html index c2b1b33059..68b11e7942 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIInitException.html +++ b/uitest/src/com/vaadin/tests/components/ui/UIInitException.html @@ -17,9 +17,9 @@ - assertText - //html/body/div/pre + assertTextPresent Catch me if you can + diff --git a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java index 5f3d8d97de..90021a0bf4 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UISerialization.java +++ b/uitest/src/com/vaadin/tests/components/ui/UISerialization.java @@ -20,15 +20,19 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.PrintWriter; import java.io.Serializable; +import java.io.StringWriter; import java.util.Date; import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; public class UISerialization extends AbstractTestUI { @@ -42,21 +46,29 @@ public class UISerialization extends AbstractTestUI { @Override public void buttonClick(ClickEvent event) { Date d = new Date(); - byte[] result = serialize(UISerialization.this); - long elapsed = new Date().getTime() - d.getTime(); - log.log("Serialized UI in " + elapsed + "ms into " - + result.length + " bytes"); - Object diffStateBefore = getConnectorTracker().getDiffState( - UISerialization.this); - UISerialization app = (UISerialization) deserialize(result); - log.log("Deserialized UI in " + elapsed + "ms"); - Object diffStateAfter = getConnectorTracker().getDiffState( - UISerialization.this); - if (diffStateBefore.equals(diffStateAfter)) { - log.log("Diff states match, size: " - + diffStateBefore.toString().length()); - } else { - log.log("Diff states do not match"); + try { + byte[] result = serialize(UISerialization.this); + long elapsed = new Date().getTime() - d.getTime(); + log.log("Serialized UI in " + elapsed + "ms into " + + result.length + " bytes"); + Object diffStateBefore = getConnectorTracker() + .getDiffState(UISerialization.this); + UISerialization app = (UISerialization) deserialize(result); + log.log("Deserialized UI in " + elapsed + "ms"); + Object diffStateAfter = getConnectorTracker().getDiffState( + UISerialization.this); + if (diffStateBefore.equals(diffStateAfter)) { + log.log("Diff states match, size: " + + diffStateBefore.toString().length()); + } else { + log.log("Diff states do not match"); + } + } catch (Exception e) { + log.log("Exception caught: " + e.getMessage()); + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + addComponent(new Label(sw.toString(), + ContentMode.PREFORMATTED)); } } @@ -64,20 +76,16 @@ public class UISerialization extends AbstractTestUI { } protected void serializeInstance(Class cls) - throws InstantiationException, IllegalAccessException { + throws InstantiationException, IllegalAccessException, IOException { serialize((Serializable) cls.newInstance()); } - protected byte[] serialize(Serializable serializable) { + protected byte[] serialize(Serializable serializable) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream oos; - try { - oos = new ObjectOutputStream(os); - oos.writeObject(serializable); - return os.toByteArray(); - } catch (IOException e) { - throw new RuntimeException("Serialization failed", e); - } + oos = new ObjectOutputStream(os); + oos.writeObject(serializable); + return os.toByteArray(); } protected Object deserialize(byte[] result) { diff --git a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html index 6e3eb906b7..ac81dfdefb 100644 --- a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html +++ b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html @@ -16,11 +16,6 @@ /run/com.vaadin.tests.components.window.CloseSubWindow?restartApplication - - waitForVaadin - - - click vaadin=runcomvaadintestscomponentswindowCloseSubWindow::PID_Sopensub/domChild[0]/domChild[0] @@ -45,7 +40,7 @@ click - vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] diff --git a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.java b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.java index e2a59b6005..6aad3e9170 100644 --- a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.java +++ b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.java @@ -33,7 +33,7 @@ public class CloseSubWindow extends TestBase { private Window createClosableSubWindow(final String title) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); - layout.setSizeFull(); + layout.setSizeUndefined(); final Window window = new Window(title, layout); window.setSizeUndefined(); window.setClosable(true); diff --git a/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html b/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html index 0476de6c35..8374a90b52 100644 --- a/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html +++ b/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html @@ -90,7 +90,7 @@ mouseClick - vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[3]/domChild[0]/domChild[0]/domChild[1] + vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[3]/domChild[0]/domChild[0]/domChild[2] 11,15 @@ -101,7 +101,7 @@ mouseClick - vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[1] + vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[2] 6,8 @@ -139,7 +139,7 @@ mouseClick - vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[1] + vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[2] 10,5 diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html index 090579d81d..ed76caed54 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html @@ -170,7 +170,7 @@ screenCapture - window-2-original-pos-window-1-centered + window-2-original-pos-window-1-centered-again diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html index 923276b613..fa63e5e1e6 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html @@ -18,7 +18,7 @@ mouseClick - vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 6,7 diff --git a/uitest/src/com/vaadin/tests/debug/DebugWindowPresent.html b/uitest/src/com/vaadin/tests/debug/DebugWindowPresent.html index 11640ef6c3..fb4c266db1 100644 --- a/uitest/src/com/vaadin/tests/debug/DebugWindowPresent.html +++ b/uitest/src/com/vaadin/tests/debug/DebugWindowPresent.html @@ -28,7 +28,7 @@ assertElementPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -38,7 +38,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -48,7 +48,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -58,7 +58,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -68,7 +68,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -78,7 +78,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -88,7 +88,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] @@ -98,7 +98,7 @@ assertElementNotPresent - vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugConsole[0] + vaadin=runcomvaadintestsdebugDebugWindowPresent::Root/VDebugWindow[0] diff --git a/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.html b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.html index 16f3db6a1a..543faa30dd 100644 --- a/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.html +++ b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404.html @@ -53,7 +53,12 @@ assertTextPresent - /APP can not be found + HTTP ERROR 404 + + + + assertTextPresent + Problem accessing /run/APP/ -- cgit v1.2.3 From 6f593d5847389edfc9dbb7bb65114dc4be6066ae Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 10 Apr 2013 10:21:59 +0300 Subject: Don't process push messages until init JSON is processed (#11529) * The test is not running reliably in all browsers, but assuming this is a symptom of other push issues and not related to this particular bug. Change-Id: I848b57502aa01467b0f60624cf599247ec76f32f --- .../com/vaadin/client/ApplicationConnection.java | 65 ++++++++++++++++++++-- uitest/src/com/vaadin/tests/push/PushFromInit.html | 32 +++++++++++ uitest/src/com/vaadin/tests/push/PushFromInit.java | 36 ++++++++++++ 3 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/push/PushFromInit.html create mode 100644 uitest/src/com/vaadin/tests/push/PushFromInit.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 0341a9d5c4..2fa82c6004 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -183,6 +183,19 @@ public class ApplicationConnection { protected boolean applicationRunning = false; + /** + * Keep track of whether the initialization JSON has been handled. We should + * not process any push messages until the initial JSON has been processed. + */ + private boolean initJsonHandled = false; + + /** + * Keep track of any push messages that arrive before + * {@link #initJsonHandled} is set to true. + */ + private JsArrayString incommingPushMessageQueue = JsArrayString + .createArray().cast(); + private boolean hasActiveRequest = false; /** @@ -1114,6 +1127,26 @@ public class ApplicationConnection { checkForPendingVariableBursts(); runPostRequestHooks(configuration.getRootPanelId()); } + + if (!initJsonHandled) { + /* + * Assume that the first request that is fully handled is the one + * with the initialization data. + */ + initJsonHandled = true; + + int queueLength = incommingPushMessageQueue.length(); + if (queueLength > 0) { + VConsole.log("Init handled, processing " + queueLength + + " enqueued messages"); + for (int i = 0; i < queueLength; i++) { + handlePushMessage(incommingPushMessageQueue.get(i)); + } + incommingPushMessageQueue.setLength(0); + } + + } + // deferring to avoid flickering Scheduler.get().scheduleDeferred(new Command() { @Override @@ -1258,6 +1291,14 @@ public class ApplicationConnection { return; } + /* + * Lock response handling to avoid a situation where something pushed + * from the server gets processed while waiting for e.g. lazily loaded + * connectors that are needed for processing the current message. + */ + final Object lock = new Object(); + suspendReponseHandling(lock); + VConsole.log("Handling message from server"); eventBus.fireEvent(new ResponseHandlingStartedEvent(this)); @@ -1476,6 +1517,7 @@ public class ApplicationConnection { // not sent asynchronously endRequest(); } + resumeResponseHandling(lock); if (Profiler.isEnabled()) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -3264,11 +3306,19 @@ public class ApplicationConnection { * suspended. */ private void handlePendingMessages() { - for (PendingUIDLMessage pending : pendingUIDLMessages) { - handleUIDLMessage(pending.getStart(), pending.getJsonText(), - pending.getJson()); + if (!pendingUIDLMessages.isEmpty()) { + /* + * Clear the list before processing enqueued messages to support + * reentrancy + */ + List pendingMessages = pendingUIDLMessages; + pendingUIDLMessages = new ArrayList(); + + for (PendingUIDLMessage pending : pendingMessages) { + handleReceivedJSONMessage(pending.getStart(), + pending.getJsonText(), pending.getJson()); + } } - pendingUIDLMessages.clear(); } private boolean handleErrorInDelegate(String details, int statusCode) { @@ -3348,6 +3398,11 @@ public class ApplicationConnection { } public void handlePushMessage(String message) { - handleJSONText(message, 200); + if (initJsonHandled) { + handleJSONText(message, 200); + } else { + VConsole.log("Enqueuing push message has init has not yet been handled"); + incommingPushMessageQueue.push(message); + } } } diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.html b/uitest/src/com/vaadin/tests/push/PushFromInit.html new file mode 100644 index 0000000000..d009eb3baf --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushFromInit.html @@ -0,0 +1,32 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + +
    New Test
    open/run-push/com.vaadin.tests.push.PushFromInit?debug&restartApplication
    waitForTextvaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_11. Logged in init
    assertTextvaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_02. Logged from background thread started in init
    + + diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java new file mode 100644 index 0000000000..c43739ec04 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java @@ -0,0 +1,36 @@ +package com.vaadin.tests.push; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; + +public class PushFromInit extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + new Thread() { + @Override + public void run() { + runSafely(new Runnable() { + @Override + public void run() { + log("Logged from background thread started in init"); + } + }); + } + }.start(); + log("Logged in init"); + addComponent(new Button("Sync")); + } + + @Override + protected String getTestDescription() { + return "Pusing something to a newly created UI should not cause race conditions"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(11529); + } + +} -- cgit v1.2.3 From fd4f1d280e8eb6a453868db01b8accc1e7b8d0b1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 9 Apr 2013 01:01:48 +0300 Subject: Fixed test to close windows instead of maximizing them Change-Id: I4c1bd7d8962f30cf756512e8d8e1f198b9604ec2 --- .../com/vaadin/tests/components/uitest/base_theme_test.html | 10 +++++----- .../vaadin/tests/components/uitest/chameleon_theme_test.html | 10 +++++----- .../com/vaadin/tests/components/uitest/liferay_theme_test.html | 10 +++++----- .../vaadin/tests/components/uitest/reindeer_theme_test.html | 10 +++++----- .../com/vaadin/tests/components/uitest/runo_theme_test.html | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html index 0308a09a16..614ae7bcda 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html @@ -289,7 +289,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,8 @@ -304,7 +304,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 11,6 @@ -319,7 +319,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 8,5 @@ -334,7 +334,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,6 @@ -349,7 +349,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 10,7 diff --git a/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html index fb00029d8f..7d9ffc65b8 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html @@ -289,7 +289,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,8 @@ -304,7 +304,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 11,6 @@ -319,7 +319,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 8,5 @@ -334,7 +334,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,6 @@ -349,7 +349,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 10,7 diff --git a/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html index 193c648916..d0ee96c7ef 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html @@ -289,7 +289,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,8 @@ -304,7 +304,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 11,6 @@ -319,7 +319,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 8,5 @@ -334,7 +334,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,6 @@ -349,7 +349,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 10,7 diff --git a/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html index b1340831bc..a330f5bf61 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html @@ -289,7 +289,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,8 @@ -304,7 +304,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 11,6 @@ -319,7 +319,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 8,5 @@ -334,7 +334,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,6 @@ -349,7 +349,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 10,7 diff --git a/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html index fadc503abd..61ba58a0e6 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html @@ -289,7 +289,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,8 @@ -304,7 +304,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 11,6 @@ -319,7 +319,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 8,5 @@ -334,7 +334,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 9,6 @@ -349,7 +349,7 @@ mouseClick - vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[1] + vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2] 10,7 -- cgit v1.2.3 From 150352f64cdb49a27b110bd32e049c307fcf3486 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 5 Apr 2013 18:33:55 +0300 Subject: Implemented poll interval for UI (#11495) Change-Id: Ic56b0123970f18e282c75d67863569ac55c72ea8 --- .../com/vaadin/client/ApplicationConnection.java | 17 ++++ .../src/com/vaadin/client/ui/ui/UIConnector.java | 38 +++++++++ server/src/com/vaadin/ui/UI.java | 34 ++++++++ .../shared/communication/MethodInvocation.java | 27 +++++++ .../src/com/vaadin/shared/ui/ui/UIServerRpc.java | 7 ++ shared/src/com/vaadin/shared/ui/ui/UIState.java | 1 + .../com/vaadin/tests/components/ui/UIPolling.html | 53 +++++++++++++ .../com/vaadin/tests/components/ui/UIPolling.java | 90 ++++++++++++++++++++++ 8 files changed, 267 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/ui/UIPolling.html create mode 100644 uitest/src/com/vaadin/tests/components/ui/UIPolling.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 2fa82c6004..2cc5a85996 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -2387,6 +2387,23 @@ public class ApplicationConnection { } } + /** + * Removes any pending invocation of the given method from the queue + * + * @param invocation + * The invocation to remove + */ + public void removePendingInvocations(MethodInvocation invocation) { + Iterator iter = pendingInvocations.values() + .iterator(); + while (iter.hasNext()) { + MethodInvocation mi = iter.next(); + if (mi.equals(invocation)) { + iter.remove(); + } + } + } + /** * This method sends currently queued variable changes to server. It is * called when immediate variable update must happen. diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 07481063c3..f3b4f36670 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -37,6 +37,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; @@ -61,6 +62,7 @@ import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.server.Page.Styles; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; @@ -417,6 +419,8 @@ public class UIConnector extends AbstractSingleComponentContainerConnector }; + private Timer pollTimer = null; + @Override public void updateCaption(ComponentConnector component) { // NOP The main view never draws caption for its layout @@ -580,5 +584,39 @@ public class UIConnector extends AbstractSingleComponentContainerConnector getConnection().getLoadingIndicator().setDelayStateDelay( getState().loadingIndicatorConfiguration.delayStateDelay); } + + if (stateChangeEvent.hasPropertyChanged("pollInterval")) { + configurePolling(); + } + } + + private void configurePolling() { + if (pollTimer != null) { + pollTimer.cancel(); + pollTimer = null; + } + if (getState().pollInterval >= 0) { + pollTimer = new Timer() { + @Override + public void run() { + /* + * Verify that polling has not recently been canceled. This + * is needed because Timer.cancel() does not always work + * properly in IE 8 until GWT issue 8101 has been fixed. + */ + if (pollTimer != null) { + getRpcProxy(UIServerRpc.class).poll(); + // Send changes even though poll is @Delayed + getConnection().sendPendingVariableChanges(); + } + } + }; + pollTimer.scheduleRepeating(getState().pollInterval); + } else { + // Ensure no more polls are sent as polling has been disabled + getConnection().removePendingInvocations( + new MethodInvocation(getConnectorId(), UIServerRpc.class + .getName(), "poll")); + } } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 2d9f49b122..6160978542 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -148,6 +148,14 @@ public abstract class UI extends AbstractSingleComponentContainer implements UI.this.scrollTop = scrollTop; UI.this.scrollLeft = scrollLeft; } + + @Override + public void poll() { + /* + * No-op. This is only called to cause a server visit to check for + * changes. + */ + } }; /** @@ -1171,4 +1179,30 @@ public abstract class UI extends AbstractSingleComponentContainer implements public void setPushConnection(PushConnection connection) { pushConnection = connection; } + + /** + * Sets the interval with which the UI should poll the server to see if + * there are any changes. Polling is disabled by default. + *

    + * Note that it is possible to enable push and polling at the same time but + * it should not be done to avoid excessive server traffic. + *

    + * + * @param intervalInMillis + * The interval (in ms) with which the UI should poll the server + * or -1 to disable polling + */ + public void setPollInterval(int intervalInMillis) { + getState().pollInterval = intervalInMillis; + } + + /** + * Returns the interval with which the UI polls the server. + * + * @return The interval (in ms) with which the UI polls the server or -1 if + * polling is disabled + */ + public int getPollInterval() { + return getState(false).pollInterval; + } } diff --git a/shared/src/com/vaadin/shared/communication/MethodInvocation.java b/shared/src/com/vaadin/shared/communication/MethodInvocation.java index 417ced76be..d5bf8324ef 100644 --- a/shared/src/com/vaadin/shared/communication/MethodInvocation.java +++ b/shared/src/com/vaadin/shared/communication/MethodInvocation.java @@ -19,6 +19,8 @@ package com.vaadin.shared.communication; import java.io.Serializable; import java.util.Arrays; +import com.vaadin.shared.util.SharedUtil; + /** * Information needed by the framework to send an RPC method invocation from the * client to the server or vice versa. @@ -85,4 +87,29 @@ public class MethodInvocation implements Serializable { return connectorId + "-" + getInterfaceName() + "-" + getMethodName(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof MethodInvocation)) { + return false; + } + MethodInvocation other = (MethodInvocation) obj; + if (!SharedUtil.equals(getConnectorId(), other.getConnectorId())) { + return false; + } + + if (!SharedUtil.equals(getInterfaceName(), other.getInterfaceName())) { + return false; + } + + if (!SharedUtil.equals(getMethodName(), other.getMethodName())) { + return false; + } + + if (!SharedUtil.equals(getParameters(), other.getParameters())) { + return false; + } + + return true; + + } } \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java b/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java index 358ba2e24e..576ee83980 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java @@ -26,4 +26,11 @@ public interface UIServerRpc extends ClickRpc, ServerRpc { @Delayed(lastOnly = true) public void scroll(int scrollTop, int scrollLeft); + + @Delayed(lastOnly = true) + /* + * @Delayed just to get lastOnly semantics, sendPendingVariableChanges() + * should always be called to ensure the message is flushed right away. + */ + public void poll(); } \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index d5ee4c30e6..fbb6427c6f 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -22,6 +22,7 @@ import com.vaadin.shared.ui.TabIndexState; public class UIState extends TabIndexState { public TooltipConfiguration tooltipConfiguration = new TooltipConfiguration(); public LoadingIndicatorConfiguration loadingIndicatorConfiguration = new LoadingIndicatorConfiguration(); + public int pollInterval = -1; public static class LoadingIndicatorConfiguration implements Serializable { public int initialDelay = 300; diff --git a/uitest/src/com/vaadin/tests/components/ui/UIPolling.html b/uitest/src/com/vaadin/tests/components/ui/UIPolling.html new file mode 100644 index 0000000000..0e3cc2bc6e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIPolling.html @@ -0,0 +1,53 @@ + + + + + + +WindowMaximizeRestoreTest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    WindowMaximizeRestoreTest
    open/run/UIPolling?restartApplication
    typeid=gwt-uid-5500
    pause2000
    assertTextPresent2. 1000ms has passed
    typeid=gwt-uid-5-1
    pause2000
    assertTextNotPresent8. 4000ms has passed
    + + diff --git a/uitest/src/com/vaadin/tests/components/ui/UIPolling.java b/uitest/src/com/vaadin/tests/components/ui/UIPolling.java new file mode 100644 index 0000000000..a7add63801 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIPolling.java @@ -0,0 +1,90 @@ +/* + * Copyright 2000-2013 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.ui; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.data.util.MethodProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.TextField; + +public class UIPolling extends AbstractTestUIWithLog { + + protected static final long SLEEP_TIME = 500; + + private class BackgroundLogger extends Thread { + + @Override + public void run() { + int i = 0; + while (true) { + i++; + try { + Thread.sleep(SLEEP_TIME); + } catch (InterruptedException e) { + } + final int iteration = i; + runSafely(new Runnable() { + @Override + public void run() { + log.log((iteration * SLEEP_TIME) + "ms has passed"); + } + }); + } + } + } + + private BackgroundLogger logger = null; + + @Override + protected void setup(VaadinRequest request) { + log = new Log(20); + log.setNumberLogRows(true); + TextField pollingInterval = new TextField("Poll interval", + new MethodProperty(this, "pollInterval")); + pollingInterval.setImmediate(true); + pollingInterval.setValue("-1"); + pollingInterval.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + if (logger != null) { + logger.stop(); + logger = null; + } + if (getPollInterval() >= 0) { + logger = new BackgroundLogger(); + logger.start(); + } + } + }); + addComponent(pollingInterval); + + } + + @Override + protected String getTestDescription() { + return "Tests the polling feature of UI. Set the polling interval using the text field. Enabling polling will at the same time start a background thread which logs every 500ms"; + } + + @Override + protected Integer getTicketNumber() { + return 11495; + } + +} -- cgit v1.2.3 From c89b2e6556b1432cb2b5f9de2868f3104b7ff000 Mon Sep 17 00:00:00 2001 From: michaelvogt Date: Thu, 11 Apr 2013 13:47:51 +0300 Subject: TestBench test for Button (#11581) Makes sure the WAI-ARIA functions work Change-Id: If3835f038f5cca009bef678fdfe037d4287ece7e --- client/src/com/vaadin/client/ui/VButton.java | 4 +- .../tests/components/button/ButtonsWaiAria.html | 82 ++++++++++++++++++++++ .../tests/components/button/ButtonsWaiAria.java | 51 ++++++++++++++ 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.html create mode 100644 uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java (limited to 'uitest/src') diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java index 28a2221380..c67a9f8747 100644 --- a/client/src/com/vaadin/client/ui/VButton.java +++ b/client/src/com/vaadin/client/ui/VButton.java @@ -357,12 +357,14 @@ public class VButton extends FocusWidget implements ClickHandler { this.enabled = enabled; if (!enabled) { cleanupCaptureState(); + Roles.getButtonRole().setAriaDisabledState(getElement(), + !enabled); super.setTabIndex(-1); } else { + Roles.getButtonRole().removeAriaDisabledState(getElement()); super.setTabIndex(tabIndex); } - Roles.getButtonRole().setAriaDisabledState(getElement(), !enabled); } } diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.html b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.html new file mode 100644 index 0000000000..42c39ca0ed --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.html @@ -0,0 +1,82 @@ + + + + + + +ButtonsWaiAria + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ButtonsWaiAria
    open/run/com.vaadin.tests.components.button.ButtonsWaiAria?restartApplication
    verifyElementPresentvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/
    assertAttributevaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]@rolebutton
    verifyElementPresentvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/
    assertElementPresentxpath=/html/body/div/div/div[2]/div/div[2]/div/div[5]/div/span/img[@alt='']
    storeAttributevaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]@altemptyAlt
    verifyElementPresentvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/
    assertAttributevaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]@altuser icon
    verifyElementPresentvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]/
    mouseClickvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::PID_Scheckboxaction-Enabled/domChild[0]7,7
    assertAttributevaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/@aria-disabledtrue
    mouseClickvaadin=runcomvaadintestscomponentsbuttonButtonsWaiAria::PID_Scheckboxaction-Enabled/domChild[0]7,7
    assertElementNotPresent/html/body/div/div/div[2]/div/div[2]/div/div[3]/div[@aria-disabled]
    + + diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java new file mode 100644 index 0000000000..1208b8be3b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java @@ -0,0 +1,51 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.NativeButton; + +public class ButtonsWaiAria extends ComponentTestCase