diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-05 19:15:49 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-06-05 19:15:54 +0300 |
commit | 1f144228f657b5014bc8fd3b08cf8f33950966f6 (patch) | |
tree | 13ab5e89e98194030a0912c91e5dfce951696cee | |
parent | fad7bf7a791db16349467ccbc508d0e472330fa0 (diff) | |
parent | 14ebd0d9c8bdfa9940786492876172d1891f593f (diff) | |
download | vaadin-framework-1f144228f657b5014bc8fd3b08cf8f33950966f6.tar.gz vaadin-framework-1f144228f657b5014bc8fd3b08cf8f33950966f6.zip |
Merge changes from origin/7.0
892b8ba Do not submit TextArea value on enter in IE (#11982)
bd3f975 Properly disable combobox when parent is disabled (#10734)
1b85e59 Added missing import (#11982)
3c8a3bf Merge of properly focus clicked input element in Webkit (#11854, #11297)
d647d7a Ensure VBrowserFrame content is unloaded in IE (#11683)
08ba394 Disable drag&drop when source or target component is disabled, re-implementation of 6.8 fix for #11801
b01427a Change field types from LinkedHashSet back to HashSet to retain binary compatibility (#11432)
14ebd0d Fixed newlines
Change-Id: Icea535d8d5130e013327dd76a194e3910f533332
15 files changed, 587 insertions, 24 deletions
diff --git a/client/src/com/vaadin/client/ui/VBrowserFrame.java b/client/src/com/vaadin/client/ui/VBrowserFrame.java index c1e131a6c5..4e13921582 100644 --- a/client/src/com/vaadin/client/ui/VBrowserFrame.java +++ b/client/src/com/vaadin/client/ui/VBrowserFrame.java @@ -19,6 +19,7 @@ import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.IFrameElement; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.BrowserInfo; public class VBrowserFrame extends Widget { @@ -134,4 +135,23 @@ public class VBrowserFrame extends Widget { iframe.setName(name); } } + + @Override + protected void onDetach() { + if (BrowserInfo.get().isIE()) { + // Force browser to fire unload event when component is detached + // from the view (IE doesn't do this automatically) + if (iframe != null) { + /* + * src was previously set to javascript:false, but this was not + * enough to overcome a bug when detaching an iframe with a pdf + * loaded in IE9. about:blank seems to cause the adobe reader + * plugin to unload properly before the iframe is removed. See + * #7855 + */ + iframe.setSrc("about:blank"); + } + } + super.onDetach(); + } } diff --git a/client/src/com/vaadin/client/ui/VCheckBox.java b/client/src/com/vaadin/client/ui/VCheckBox.java index bb49dd7f0a..94b37f418e 100644 --- a/client/src/com/vaadin/client/ui/VCheckBox.java +++ b/client/src/com/vaadin/client/ui/VCheckBox.java @@ -16,10 +16,13 @@ package com.vaadin.client.ui; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.Util; import com.vaadin.client.VTooltip; import com.vaadin.client.ui.aria.AriaHelper; @@ -55,6 +58,17 @@ public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements (DOM.getEventsSunk(el) | VTooltip.TOOLTIP_EVENTS)); el = DOM.getNextSibling(el); } + + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + setFocus(true); + } + }); + } } @Override diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java index f23bf88969..1c1173c295 100644 --- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java +++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java @@ -80,7 +80,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public void onMouseDown(MouseDownEvent event) { - if (startDrag(event.getNativeEvent())) { + if (getConnector().isEnabled() + && startDrag(event.getNativeEvent())) { event.preventDefault(); // prevent text selection } } @@ -90,7 +91,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public void onTouchStart(TouchStartEvent event) { - if (startDrag(event.getNativeEvent())) { + if (getConnector().isEnabled() + && startDrag(event.getNativeEvent())) { /* * Dont let eg. panel start scrolling. */ @@ -112,8 +114,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements private boolean startDrag(NativeEvent event) { if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) { VTransferable transferable = new VTransferable(); - transferable.setDragSource(ConnectorMap.get(client).getConnector( - VDragAndDropWrapper.this)); + transferable.setDragSource(getConnector()); ComponentConnector paintable = Util.findPaintable(client, (Element) event.getEventTarget().cast()); @@ -187,7 +188,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements private boolean uploading; - private ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() { + private final ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() { @Override public void onReadyStateChange(XMLHttpRequest xhr) { @@ -261,8 +262,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements } if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) { VTransferable transferable = new VTransferable(); - transferable.setDragSource(ConnectorMap.get(client) - .getConnector(this)); + transferable.setDragSource(getConnector()); vaadinDragEvent = VDragAndDropManager.get().startDrag( transferable, event, false); @@ -458,6 +458,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public void dragEnter(VDragEvent drag) { + if (!getConnector().isEnabled()) { + return; + } updateDropDetails(drag); currentlyValid = false; super.dragEnter(drag); @@ -471,6 +474,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public void dragOver(final VDragEvent drag) { + if (!getConnector().isEnabled()) { + return; + } boolean detailsChanged = updateDropDetails(drag); if (detailsChanged) { currentlyValid = false; @@ -486,6 +492,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override public boolean drop(VDragEvent drag) { + if (!getConnector().isEnabled()) { + return false; + } deEmphasis(true); Map<String, Object> dd = drag.getDropDetails(); @@ -511,14 +520,16 @@ public class VDragAndDropWrapper extends VCustomComponent implements @Override protected void dragAccepted(VDragEvent drag) { + if (!getConnector().isEnabled()) { + return; + } currentlyValid = true; emphasis(drag); } @Override public ComponentConnector getConnector() { - return ConnectorMap.get(client).getConnector( - VDragAndDropWrapper.this); + return VDragAndDropWrapper.this.getConnector(); } @Override @@ -528,6 +539,10 @@ public class VDragAndDropWrapper extends VCustomComponent implements } + public ComponentConnector getConnector() { + return ConnectorMap.get(client).getConnector(this); + } + protected native void hookHtml5DragStart(Element el) /*-{ var me = this; @@ -594,8 +609,7 @@ public class VDragAndDropWrapper extends VCustomComponent implements } private void notifySizePotentiallyChanged() { - LayoutManager.get(client).setNeedsMeasure( - ConnectorMap.get(client).getConnector(getElement())); + LayoutManager.get(client).setNeedsMeasure(getConnector()); } protected void emphasis(VDragEvent drag) { diff --git a/client/src/com/vaadin/client/ui/VNativeButton.java b/client/src/com/vaadin/client/ui/VNativeButton.java index 71413a76e6..67fa6f2ee3 100644 --- a/client/src/com/vaadin/client/ui/VNativeButton.java +++ b/client/src/com/vaadin/client/ui/VNativeButton.java @@ -143,8 +143,10 @@ public class VNativeButton extends Button implements ClickHandler { return; } - if (BrowserInfo.get().isSafari()) { - VNativeButton.this.setFocus(true); + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + setFocus(true); } if (disableOnClick) { setEnabled(false); diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java index eed5549e39..a4c8b6733c 100644 --- a/client/src/com/vaadin/client/ui/VOptionGroup.java +++ b/client/src/com/vaadin/client/ui/VOptionGroup.java @@ -41,6 +41,7 @@ import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.shared.EventId; @@ -161,8 +162,16 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler, public void onClick(ClickEvent event) { super.onClick(event); if (event.getSource() instanceof CheckBox) { - final boolean selected = ((CheckBox) event.getSource()).getValue(); - final String key = optionsToKeys.get(event.getSource()); + CheckBox source = (CheckBox) event.getSource(); + + if (BrowserInfo.get().isWebkit()) { + // Webkit does not focus non-text input elements on click + // (#11854) + source.setFocus(true); + } + + final boolean selected = source.getValue(); + final String key = optionsToKeys.get(source); if (!isMultiselect()) { selectedKeys.clear(); } diff --git a/client/src/com/vaadin/client/ui/VTextArea.java b/client/src/com/vaadin/client/ui/VTextArea.java index 45e0532451..2a697969df 100644 --- a/client/src/com/vaadin/client/ui/VTextArea.java +++ b/client/src/com/vaadin/client/ui/VTextArea.java @@ -22,6 +22,7 @@ import com.google.gwt.dom.client.Style.WhiteSpace; import com.google.gwt.dom.client.TextAreaElement; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; +import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.user.client.Command; @@ -285,4 +286,12 @@ public class VTextArea extends VTextField { } this.wordwrap = wordwrap; } + + @Override + public void onKeyDown(KeyDownEvent event) { + // Overridden to avoid submitting TextArea value on enter in IE. This is + // another reason why widgets should inherit a common abstract + // class instead of directly each other. + } + } diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index d9eac91e2b..f91ff9e2b9 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -50,9 +50,6 @@ public class ComboBoxConnector extends AbstractFieldConnector implements getWidget().paintableId = uidl.getId(); getWidget().readonly = isReadOnly(); - getWidget().enabled = isEnabled(); - - getWidget().tb.setEnabled(getWidget().enabled); getWidget().updateReadOnly(); if (!isRealUpdate(uidl)) { @@ -280,4 +277,11 @@ public class ComboBoxConnector extends AbstractFieldConnector implements widget.updateRootWidth(); } } + + @Override + public void setWidgetEnabled(boolean widgetEnabled) { + super.setWidgetEnabled(widgetEnabled); + getWidget().enabled = widgetEnabled; + getWidget().tb.setEnabled(widgetEnabled); + } } diff --git a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java index ffc146ad04..dd838fdeff 100644 --- a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java +++ b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java @@ -287,7 +287,7 @@ public class VDragAndDropManager { protected VDragAndDropManager() { } - private NativePreviewHandler defaultDragAndDropEventHandler = new DefaultDragAndDropEventHandler(); + private final NativePreviewHandler defaultDragAndDropEventHandler = new DefaultDragAndDropEventHandler(); /** * Flag to indicate if drag operation has really started or not. Null check @@ -469,7 +469,8 @@ public class VDragAndDropManager { if (w == null) { return null; } - while (!(w instanceof VHasDropHandler)) { + while (!(w instanceof VHasDropHandler) + || !isDropEnabled((VHasDropHandler) w)) { w = w.getParent(); if (w == null) { break; @@ -492,6 +493,15 @@ public class VDragAndDropManager { } /** + * Checks if the given {@link VHasDropHandler} really is able to accept + * drops. + */ + private static boolean isDropEnabled(VHasDropHandler target) { + VDropHandler dh = target.getDropHandler(); + return dh != null && dh.getConnector().isEnabled(); + } + + /** * Drag is ended (drop happened) on current drop handler. Calls drop method * on current drop handler and does appropriate cleanup. */ diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index ce3e27d539..8d7a64b364 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -15,6 +15,7 @@ */ package com.vaadin.event; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; @@ -43,11 +44,15 @@ public class ActionManager implements Action.Container, Action.Handler, private static final long serialVersionUID = 1641868163608066491L; - /** List of action handlers */ - protected LinkedHashSet<Action> ownActions = null; + /** + * List of action handlers. Guaranteed to keep the original insertion order. + */ + protected HashSet<Action> ownActions = null; - /** List of action handlers */ - protected LinkedHashSet<Handler> actionHandlers = null; + /** + * List of action handlers. Guaranteed to keep the original insertion order. + */ + protected HashSet<Handler> actionHandlers = null; /** Action mapper */ protected KeyMapper<Action> actionMapper = null; diff --git a/server/src/com/vaadin/server/DragAndDropService.java b/server/src/com/vaadin/server/DragAndDropService.java index cc571853fe..df2361e887 100644 --- a/server/src/com/vaadin/server/DragAndDropService.java +++ b/server/src/com/vaadin/server/DragAndDropService.java @@ -64,6 +64,16 @@ public class DragAndDropService implements VariableOwner, ClientConnector { public void changeVariables(Object source, Map<String, Object> variables) { Object owner = variables.get("dhowner"); + final Component sourceComponent = (Component) variables + .get("component"); + if (sourceComponent != null && !sourceComponent.isEnabled()) { + // source component not supposed to be enabled + getLogger().warning( + "Client dropped from " + sourceComponent + + " even though it's disabled"); + return; + } + // Validate drop handler owner if (!(owner instanceof DropTarget)) { getLogger() @@ -74,6 +84,15 @@ public class DragAndDropService implements VariableOwner, ClientConnector { // owner cannot be null here DropTarget dropTarget = (DropTarget) owner; + + if (!dropTarget.isEnabled()) { + getLogger() + .warning( + "Client dropped on " + owner + + " even though it's disabled"); + return; + } + lastVisitId = (Integer) variables.get("visitId"); // request may be dropRequest or request during drag operation (commonly diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java b/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java new file mode 100644 index 0000000000..161f9cd520 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractfield/FieldFocusOnClick.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.components.abstractfield; + +import java.util.Arrays; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.TextField; + +public class FieldFocusOnClick extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + addComponent(new TextField(null, "TextField")); + addComponent(new CheckBox("CheckBox")); + addComponent(new OptionGroup(null, + Arrays.asList("Option 1", "Option 2"))); + addComponent(new NativeButton("NativeButton")); + } + + @Override + protected String getTestDescription() { + return "Webkit doesn't focus non-text input elements when clicked"; + } + + @Override + protected Integer getTicketNumber() { + return 11854; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.html new file mode 100644 index 0000000000..ab8c4f81d0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.html @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.combobox.ComboBoxParentDisable?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button</td> + <td>6,16</td> +</tr> +<tr> + <td>assertText</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[2]/td/span</td> + <td>Item 1</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/domChild[1]</td> + <td>371,22</td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']</td> + <td>Item 1</td> +</tr> +<!--Disable combobox--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button</td> + <td>8,12</td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']</td> + <td>Item 1</td> +</tr> +<!--Enable combobox--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>100</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button</td> + <td>8,12</td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']</td> + <td>Item 1</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/domChild[1]</td> + <td>371,22</td> +</tr> +<!--Disable parent--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button</td> + <td>8,12</td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']</td> + <td>Item 1</td> +</tr> +<!--Enable parent--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>100</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VFilterSelect[0]#button</td> + <td>8,12</td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>//div[@id='VAADIN_COMBOBOX_OPTIONLIST']</td> + <td>Item 1</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentscomboboxComboBoxParentDisable::/VVerticalLayout[0]/domChild[1]</td> + <td>371,22</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.java new file mode 100644 index 0000000000..84355c4d89 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxParentDisable.java @@ -0,0 +1,81 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.data.Property; +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.ComboBox; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.VerticalLayout; + +/** + * The Application's "main" class + */ +@SuppressWarnings("serial") +public class ComboBoxParentDisable extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + final FormLayout formLayout = new FormLayout(); + + final ComboBox combo = new ComboBox("Item:"); + combo.addItem("Item 1"); + combo.addItem("Item 2"); + combo.addItem("Item 3"); + combo.addItem("Item 4"); + combo.addValueChangeListener(new MyValueChangeListener()); + combo.setImmediate(true); + + Button btn1 = new Button("Click me"); + btn1.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log.log("you clicked me"); + } + }); + + formLayout.addComponent(combo); + formLayout.addComponent(btn1); + + layout.addComponent(formLayout); + + Button btn = new Button("Enable/Disable combobox", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + combo.setEnabled(!combo.isEnabled()); + } + }); + layout.addComponent(btn); + btn = new Button("Enable/Disable parent", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + formLayout.setEnabled(!formLayout.isEnabled()); + } + }); + layout.addComponent(btn); + + } + + private class MyValueChangeListener implements Property.ValueChangeListener { + @Override + public void valueChange(Property.ValueChangeEvent event) { + log.log("you made a selection change"); + } + } + + @Override + protected String getTestDescription() { + return "Test for ensuring that disabling a parent properly disables the combobox"; + } + + @Override + protected Integer getTicketNumber() { + return 10734; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.html b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.html new file mode 100644 index 0000000000..1565e5eb96 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.html @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>DragAndDropDisable</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">DragAndDropDisable</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/DragAndDropDisable?restartApplication</td> + <td></td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>18,25</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>34,51</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>7,4</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>20,32</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>37,59</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]/VLabel[0]</td> + <td>59,10</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>68,15</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]/VLabel[0]</td> + <td>68,160</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>82,9</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runDragAndDropDisable::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VPanel[0]/VDragAndDropWrapper[0]/VCssLayout[0]</td> + <td>118,50</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.java new file mode 100644 index 0000000000..fb7ed92967 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.java @@ -0,0 +1,142 @@ +package com.vaadin.tests.components.draganddropwrapper; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.DragAndDropWrapper.DragStartMode; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.TableDragMode; + +public class DragAndDropDisable extends AbstractTestUI { + + @Override + protected Integer getTicketNumber() { + return 11801; + } + + @Override + protected void setup(VaadinRequest request) { + { + final Panel p = new Panel("Drag here"); + addComponent(p); + + final CssLayout layout = new CssLayout(); + layout.setHeight("100px"); + + final DragAndDropWrapper dnd = new DragAndDropWrapper(layout); + p.setContent(dnd); + + final CheckBox enabled = new CheckBox("Enabled", true); + addComponent(enabled); + enabled.setImmediate(true); + enabled.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + dnd.setEnabled(enabled.booleanValue()); + } + }); + + dnd.setDropHandler(new DropHandler() { + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(DragAndDropEvent event) { + layout.addComponent(new Label("You dropped something!")); + } + }); + + dnd.setDragStartMode(DragStartMode.COMPONENT); + } + + { + final Panel p = new Panel("Drag here"); + addComponent(p); + + final CssLayout layout = new CssLayout(); + layout.setHeight("100px"); + + final DragAndDropWrapper dnd = new DragAndDropWrapper(layout); + p.setContent(dnd); + + final CheckBox enabled = new CheckBox("Enabled", true); + addComponent(enabled); + enabled.setImmediate(true); + enabled.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + dnd.setEnabled(enabled.booleanValue()); + } + }); + + dnd.setDropHandler(new DropHandler() { + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(DragAndDropEvent event) { + layout.addComponent(new Label("You dropped something!")); + } + }); + + dnd.setDragStartMode(DragStartMode.COMPONENT); + } + + { + final Table tbl = new Table(); + tbl.addContainerProperty("column", String.class, + "drag/drop to/from here"); + for (int i = 0; i < 5; i++) { + tbl.addItem(); + } + addComponent(tbl); + tbl.setDragMode(TableDragMode.ROW); + tbl.setDropHandler(new DropHandler() { + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(DragAndDropEvent event) { + tbl.getItem(tbl.addItem()).getItemProperty("column") + .setValue("You dropped something"); + } + }); + final CheckBox enabled = new CheckBox("Enabled", true); + addComponent(enabled); + enabled.setImmediate(true); + enabled.addListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + tbl.setEnabled(enabled.booleanValue()); + } + }); + } + } + + @Override + protected String getTestDescription() { + return "DragAndDropWrapper must be disableable"; + } +} |