svn changeset:10761/svn branch:6.3tags/6.7.0.beta1
@@ -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], |
@@ -176,6 +176,10 @@ public class BrowserInfo { | |||
return isGecko; | |||
} | |||
public boolean isWebkit() { | |||
return isAppleWebKit; | |||
} | |||
public boolean isFF2() { | |||
return isGecko && version == 1.8; | |||
} |
@@ -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() { |
@@ -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,10 +502,20 @@ 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 | |||
*/ |
@@ -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) { |
@@ -24,7 +24,6 @@ import com.vaadin.Application; | |||
* @author marc | |||
*/ | |||
@SuppressWarnings( { "serial", "unchecked" }) | |||
@Deprecated | |||
public class PortletApplicationContext extends WebApplicationContext implements | |||
Serializable { | |||
@@ -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; | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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 |
@@ -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(" ", Label.CONTENT_XHTML); | |||
l.setWidth(null); | |||
return l; | |||
} | |||
} | |||
@Override | |||
public void init() { | |||
Window w = new Window("main window"); |
@@ -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(); | |||
@@ -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(" ", Label.CONTENT_XHTML); | |||
l.setWidth(null); | |||
return l; | |||
} | |||
} |