diff options
author | Henrik Paul <henrik@vaadin.com> | 2015-03-24 15:11:23 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-03-25 14:03:22 +0000 |
commit | 6a7437cc96da860e50297e064abe7aef387c9e2c (patch) | |
tree | 5031b0eccb298de0dbf7d27cb264fdea5f64ada1 /shared | |
parent | ff5f4e29731e534a85c5c22fab292eea0476237b (diff) | |
download | vaadin-framework-6a7437cc96da860e50297e064abe7aef387c9e2c.tar.gz vaadin-framework-6a7437cc96da860e50297e064abe7aef387c9e2c.zip |
Fixes edge case in null details generation for Grid (#17274)
Change-Id: I1bf4c2f0600baea8b925bd31dcd42c1e901a7c8b
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/com/vaadin/shared/ui/grid/DetailsConnectorChange.java | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/shared/src/com/vaadin/shared/ui/grid/DetailsConnectorChange.java b/shared/src/com/vaadin/shared/ui/grid/DetailsConnectorChange.java index 5b80f27b1e..171a7738a6 100644 --- a/shared/src/com/vaadin/shared/ui/grid/DetailsConnectorChange.java +++ b/shared/src/com/vaadin/shared/ui/grid/DetailsConnectorChange.java @@ -16,6 +16,7 @@ package com.vaadin.shared.ui.grid; import java.io.Serializable; +import java.util.Comparator; import com.vaadin.shared.Connector; @@ -28,9 +29,25 @@ import com.vaadin.shared.Connector; */ public class DetailsConnectorChange implements Serializable { + public static final Comparator<DetailsConnectorChange> REMOVED_FIRST_COMPARATOR = new Comparator<DetailsConnectorChange>() { + @Override + public int compare(DetailsConnectorChange a, DetailsConnectorChange b) { + boolean deleteA = a.getNewIndex() == null; + boolean deleteB = b.getNewIndex() == null; + if (deleteA && !deleteB) { + return -1; + } else if (!deleteA && deleteB) { + return 1; + } else { + return 0; + } + } + }; + private Connector connector; private Integer oldIndex; private Integer newIndex; + private boolean shouldStillBeVisible; /** Create a new connector index change */ public DetailsConnectorChange() { @@ -48,12 +65,15 @@ public class DetailsConnectorChange implements Serializable { * the old index * @param newIndex * the new index + * @param shouldStillBeVisible + * details should be visible regardless of {@code connector} */ public DetailsConnectorChange(Connector connector, Integer oldIndex, - Integer newIndex) { + Integer newIndex, boolean shouldStillBeVisible) { this.connector = connector; this.oldIndex = oldIndex; this.newIndex = newIndex; + this.shouldStillBeVisible = shouldStillBeVisible; assert assertStateIsOk(); } @@ -144,4 +164,27 @@ public class DetailsConnectorChange implements Serializable { public void setNewIndex(Integer newIndex) { this.newIndex = newIndex; } + + /** + * Checks whether whether the details should remain open, even if connector + * might be <code>null</code>. + * + * @return <code>true</code> iff the details should remain open, even if + * connector might be <code>null</code> + */ + public boolean isShouldStillBeVisible() { + return shouldStillBeVisible; + } + + /** + * Sets whether the details should remain open, even if connector might be + * <code>null</code>. + * + * @param shouldStillBeVisible + * <code>true</code> iff the details should remain open, even if + * connector might be <code>null</code> + */ + public void setShouldStillBeVisible(boolean shouldStillBeVisible) { + this.shouldStillBeVisible = shouldStillBeVisible; + } } |