summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-01-15 18:39:11 +0000
committerArtur Signell <artur.signell@itmill.com>2010-01-15 18:39:11 +0000
commit38d932279fd73eaa6e1dde33136709faaae2155f (patch)
treec946c4077f0807dee782849ec1fda2dd5dd7434b
parent2342d517d8d53a51ef47db82b3558d2b850b027e (diff)
downloadvaadin-framework-38d932279fd73eaa6e1dde33136709faaae2155f.tar.gz
vaadin-framework-38d932279fd73eaa6e1dde33136709faaae2155f.zip
Merged 6.2.2 fixes from /versions/6.2
svn changeset:10761/svn branch:6.3
-rw-r--r--src/com/vaadin/data/util/DefaultItemSorter.java14
-rw-r--r--src/com/vaadin/terminal/gwt/client/BrowserInfo.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java56
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java3
-rw-r--r--src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java1
-rw-r--r--tests/src/com/vaadin/tests/components/TestBase.java5
-rw-r--r--tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java37
-rw-r--r--tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java2
-rw-r--r--tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java39
-rw-r--r--tests/src/com/vaadin/tests/server/container/TestContainerSorting.java25
-rw-r--r--tests/src/com/vaadin/tests/util/Log.java43
12 files changed, 183 insertions, 57 deletions
diff --git a/src/com/vaadin/data/util/DefaultItemSorter.java b/src/com/vaadin/data/util/DefaultItemSorter.java
index 5cec2dc461..aefdbf1cc9 100644
--- a/src/com/vaadin/data/util/DefaultItemSorter.java
+++ b/src/com/vaadin/data/util/DefaultItemSorter.java
@@ -62,6 +62,20 @@ public class DefaultItemSorter implements ItemSorter {
Item item1 = container.getItem(o1);
Item item2 = container.getItem(o2);
+ /*
+ * Items can be null if the container is filtered. Null is considered
+ * "less" than not-null.
+ */
+ if (item1 == null) {
+ if (item2 == null) {
+ return 0;
+ } else {
+ return 1;
+ }
+ } else if (item2 == null) {
+ return -1;
+ }
+
for (int i = 0; i < sortPropertyIds.length; i++) {
int result = compareProperty(sortPropertyIds[i], sortDirections[i],
diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
index 2872ca360e..fe5c6958ed 100644
--- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
+++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
@@ -176,6 +176,10 @@ public class BrowserInfo {
return isGecko;
}
+ public boolean isWebkit() {
+ return isAppleWebKit;
+ }
+
public boolean isFF2() {
return isGecko && version == 1.8;
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 4e17dcb879..0a28fd6b41 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -57,6 +57,8 @@ public class VMenuBar extends Widget implements Paintable,
private Timer layoutTimer;
+ private boolean enabled = true;
+
public VMenuBar() {
// Create an empty horizontal menubar
this(false);
@@ -107,6 +109,7 @@ public class VMenuBar extends Widget implements Paintable,
if (client.updateComponent(this, uidl, true)) {
return;
}
+ this.enabled = !uidl.getBooleanAttribute("disabled");
// For future connections
this.client = client;
@@ -371,13 +374,13 @@ public class VMenuBar extends Widget implements Paintable,
switch (DOM.eventGetType(e)) {
case Event.ONCLICK:
- if (targetItem.isEnabled()) {
+ if (isEnabled() && targetItem.isEnabled()) {
itemClick(targetItem);
}
break;
case Event.ONMOUSEOVER:
- if (targetItem.isEnabled()) {
+ if (isEnabled() && targetItem.isEnabled()) {
itemOver(targetItem);
}
break;
@@ -389,6 +392,10 @@ public class VMenuBar extends Widget implements Paintable,
}
}
+ private boolean isEnabled() {
+ return enabled;
+ }
+
private void requestLayout() {
if (layoutTimer == null) {
layoutTimer = new Timer() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
index ffada53252..27fdf9506f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSplitPanel.java
@@ -40,12 +40,29 @@ public class VSplitPanel extends ComplexPanel implements Container,
@Override
protected <H extends EventHandler> HandlerRegistration registerHandler(
H handler, Type<H> type) {
- return addDomHandler(handler, type);
+ if ((Event.getEventsSunk(splitter) & Event.getTypeInt(type
+ .getName())) != 0) {
+ // If we are already sinking the event for the splitter we do
+ // not want to additionally sink it for the root element
+ return addHandler(handler, type);
+ } else {
+ return addDomHandler(handler, type);
+ }
}
@Override
+ public void onContextMenu(
+ com.google.gwt.event.dom.client.ContextMenuEvent event) {
+ Element target = event.getNativeEvent().getEventTarget().cast();
+ if (splitter.isOrHasChild(target)) {
+ super.onContextMenu(event);
+ }
+ };
+
+ @Override
protected void fireClick(NativeEvent event) {
- if (splitter.isOrHasChild((Element) event.getEventTarget().cast())) {
+ Element target = event.getEventTarget().cast();
+ if (splitter.isOrHasChild(target)) {
super.fireClick(event);
}
}
@@ -127,7 +144,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
setHeight(MIN_SIZE + "px");
constructDom();
setOrientation(orientation);
- DOM.sinkEvents(splitter, (Event.MOUSEEVENTS));
DOM.sinkEvents(getElement(), (Event.MOUSEEVENTS));
}
@@ -183,7 +199,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
}
clickEventHandler.handleEventHandlerRegistration(client);
-
if (uidl.hasAttribute("style")) {
componentStyleNames = uidl.getStringAttribute("style").split(" ");
} else {
@@ -371,6 +386,14 @@ public class VSplitPanel extends ComplexPanel implements Container,
case Event.ONMOUSEDOWN:
onMouseDown(event);
break;
+ case Event.ONMOUSEOUT:
+ // Dragging curtain interferes with click events if added in
+ // mousedown so we add it only when needed i.e., if the mouse moves
+ // outside the splitter.
+ if (resizing) {
+ showDraggingCurtain();
+ }
+ break;
case Event.ONMOUSEUP:
if (resizing) {
onMouseUp(event);
@@ -383,6 +406,10 @@ public class VSplitPanel extends ComplexPanel implements Container,
// Only fire click event listeners if the splitter isn't moved
if (!resized) {
super.onBrowserEvent(event);
+ } else if (DOM.eventGetType(event) == Event.ONMOUSEUP) {
+ // Reset the resized flag after a mouseup has occured so the next
+ // mousedown/mouseup can be interpreted as a click.
+ resized = false;
}
}
@@ -393,10 +420,6 @@ public class VSplitPanel extends ComplexPanel implements Container,
final Element trg = DOM.eventGetTarget(event);
if (trg == splitter || trg == DOM.getChild(splitter, 0)) {
resizing = true;
- resized = false;
- if (BrowserInfo.get().isGecko()) {
- showDraggingCurtain();
- }
DOM.setCapture(getElement());
origX = DOM.getElementPropertyInt(splitter, "offsetLeft");
origY = DOM.getElementPropertyInt(splitter, "offsetTop");
@@ -456,9 +479,7 @@ public class VSplitPanel extends ComplexPanel implements Container,
public void onMouseUp(Event event) {
DOM.releaseCapture(getElement());
- if (BrowserInfo.get().isGecko()) {
- hideDraggingCurtain();
- }
+ hideDraggingCurtain();
resizing = false;
onMouseMove(event);
updateSplitPositionToServer();
@@ -469,6 +490,9 @@ public class VSplitPanel extends ComplexPanel implements Container,
* iframe.
*/
private void showDraggingCurtain() {
+ if (!isDraggingCurtainRequired()) {
+ return;
+ }
if (draggingCurtain == null) {
draggingCurtain = DOM.createDiv();
DOM.setStyleAttribute(draggingCurtain, "position", "absolute");
@@ -478,11 +502,21 @@ public class VSplitPanel extends ComplexPanel implements Container,
DOM.setStyleAttribute(draggingCurtain, "height", "100%");
DOM.setStyleAttribute(draggingCurtain, "zIndex", ""
+ VOverlay.Z_INDEX);
+
DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain);
}
}
/**
+ * A dragging curtain is required in Gecko and Webkit.
+ *
+ * @return true if the browser requires a dragging curtain
+ */
+ private boolean isDraggingCurtainRequired() {
+ return (BrowserInfo.get().isGecko() || BrowserInfo.get().isWebkit());
+ }
+
+ /**
* Hides dragging curtain
*/
private void hideDraggingCurtain() {
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index fc7f174a62..72c383b0c1 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -383,7 +383,8 @@ public abstract class AbstractCommunicationManager implements
if (item.isFormField()) {
// ignored, upload requests contains only files
} else {
- final String pid = name.split("_")[0];
+ int separatorPos = name.lastIndexOf("_");
+ final String pid = name.substring(0, separatorPos);
final Upload uploadComponent = (Upload) idPaintableMap
.get(pid);
if (uploadComponent == null) {
diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java
index af9ed1b9a6..bbfecb5d65 100644
--- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java
+++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext.java
@@ -24,7 +24,6 @@ import com.vaadin.Application;
* @author marc
*/
@SuppressWarnings( { "serial", "unchecked" })
-@Deprecated
public class PortletApplicationContext extends WebApplicationContext implements
Serializable {
diff --git a/tests/src/com/vaadin/tests/components/TestBase.java b/tests/src/com/vaadin/tests/components/TestBase.java
index 62368d1525..b3012b1163 100644
--- a/tests/src/com/vaadin/tests/components/TestBase.java
+++ b/tests/src/com/vaadin/tests/components/TestBase.java
@@ -2,7 +2,6 @@ package com.vaadin.tests.components;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
@@ -26,13 +25,13 @@ public abstract class TestBase extends AbstractTestCase {
}
private Window window;
- private Layout layout;
+ private VerticalLayout layout;
public TestBase() {
}
- protected Layout getLayout() {
+ protected VerticalLayout getLayout() {
return layout;
}
diff --git a/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java
new file mode 100644
index 0000000000..f5e5435d45
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/splitpanel/SplitPanelWithRichTextArea.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.splitpanel;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.RichTextArea;
+import com.vaadin.ui.SplitPanel;
+
+public class SplitPanelWithRichTextArea extends TestBase {
+
+ @Override
+ protected void setup() {
+ SplitPanel sp = new SplitPanel();
+ sp.setSizeFull();
+ RichTextArea rta = new RichTextArea();
+ rta.setSizeFull();
+ Label label = new Label("One side of the panel");
+
+ sp.setFirstComponent(label);
+ sp.setSecondComponent(rta);
+
+ addComponent(sp);
+ sp.setSizeFull();
+ getLayout().setSizeFull();
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Dragging the splitter should work even if the cursor happens to move over the RichTextArea because of slow updates.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3792;
+ }
+
+}
diff --git a/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java b/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java
index 77cc587915..98f3e546f5 100644
--- a/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java
+++ b/tests/src/com/vaadin/tests/components/textfield/TextFieldFocusAndBlurListeners.java
@@ -7,7 +7,7 @@ import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.layouts.TestLayoutClickListeners.Log;
+import com.vaadin.tests.util.Log;
import com.vaadin.ui.TextField;
public class TextFieldFocusAndBlurListeners extends TestBase implements
diff --git a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
index 9a7dca7e30..386608f01f 100644
--- a/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
+++ b/tests/src/com/vaadin/tests/layouts/TestLayoutClickListeners.java
@@ -1,11 +1,9 @@
package com.vaadin.tests.layouts;
-import java.util.ArrayList;
-import java.util.List;
-
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
@@ -22,41 +20,6 @@ public class TestLayoutClickListeners extends AbstractTestCase {
private Log log = new Log(5);
- public static class Log extends VerticalLayout {
- List<Label> eventLabels = new ArrayList<Label>();
-
- public Log(int nr) {
- for (int i = 0; i < nr; i++) {
- Label l = createEventLabel();
- eventLabels.add(l);
- addComponent(l);
- }
-
- setCaption("Events:");
- }
-
- public void clear() {
- for (Label l : eventLabels) {
- l.setValue("");
- }
- }
-
- public void log(String event) {
- int nr = eventLabels.size();
- for (int i = nr - 1; i > 0; i--) {
- eventLabels.get(i).setValue(eventLabels.get(i - 1).getValue());
- }
- eventLabels.get(0).setValue(event);
- }
-
- private Label createEventLabel() {
- Label l = new Label("&nbsp;", Label.CONTENT_XHTML);
- l.setWidth(null);
- return l;
- }
-
- }
-
@Override
public void init() {
Window w = new Window("main window");
diff --git a/tests/src/com/vaadin/tests/server/container/TestContainerSorting.java b/tests/src/com/vaadin/tests/server/container/TestContainerSorting.java
index e51bb25072..d1960899e6 100644
--- a/tests/src/com/vaadin/tests/server/container/TestContainerSorting.java
+++ b/tests/src/com/vaadin/tests/server/container/TestContainerSorting.java
@@ -32,6 +32,31 @@ public class TestContainerSorting extends TestCase {
super.setUp();
}
+ public void testEmptyFilteredIndexedContainer() {
+ IndexedContainer ic = new IndexedContainer();
+
+ addProperties(ic);
+ populate(ic);
+
+ ic.addContainerFilter(PROPERTY_STRING_ID, "aasdfasdfasdf", true, false);
+ ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
+
+ }
+
+ public void testFilteredIndexedContainer() {
+ IndexedContainer ic = new IndexedContainer();
+
+ addProperties(ic);
+ populate(ic);
+
+ ic.addContainerFilter(PROPERTY_STRING_ID, "a", true, false);
+ ic.sort(new Object[] { PROPERTY_STRING_ID }, new boolean[] { true });
+ verifyOrder(ic,
+ new String[] { ITEM_ANOTHER_NULL, ITEM_DATA_MINUS1,
+ ITEM_DATA_MINUS1_NULL, ITEM_DATA_MINUS2,
+ ITEM_DATA_MINUS2_NULL, });
+ }
+
public void testIndexedContainer() {
IndexedContainer ic = new IndexedContainer();
diff --git a/tests/src/com/vaadin/tests/util/Log.java b/tests/src/com/vaadin/tests/util/Log.java
new file mode 100644
index 0000000000..75ac5d2f1e
--- /dev/null
+++ b/tests/src/com/vaadin/tests/util/Log.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class Log extends VerticalLayout {
+ List<Label> eventLabels = new ArrayList<Label>();
+
+ public Log(int nr) {
+ for (int i = 0; i < nr; i++) {
+ Label l = createEventLabel();
+ eventLabels.add(l);
+ addComponent(l);
+ }
+
+ setCaption("Events:");
+ }
+
+ public void clear() {
+ for (Label l : eventLabels) {
+ l.setValue("");
+ }
+ }
+
+ public void log(String event) {
+ int nr = eventLabels.size();
+ for (int i = nr - 1; i > 0; i--) {
+ eventLabels.get(i).setValue(eventLabels.get(i - 1).getValue());
+ }
+ eventLabels.get(0).setValue(event);
+ System.out.println(event);
+ }
+
+ private Label createEventLabel() {
+ Label l = new Label("&nbsp;", Label.CONTENT_XHTML);
+ l.setWidth(null);
+ return l;
+ }
+
+}