aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin
diff options
context:
space:
mode:
authorYuriy Artamonov <jreznot@users.noreply.github.com>2017-06-29 09:44:16 +0400
committerHenri Sara <henri.sara@gmail.com>2017-06-29 08:44:16 +0300
commit173ac5b1def8785ac5b1c5b1fdd08b8bdf09b936 (patch)
tree66089a9bc0b906e7d9c6c15f36ad5a58a9f9b09f /server/src/main/java/com/vaadin
parentc56630b3c5da519a6537e3a7c14365f4c996ba82 (diff)
downloadvaadin-framework-173ac5b1def8785ac5b1c5b1fdd08b8bdf09b936.tar.gz
vaadin-framework-173ac5b1def8785ac5b1c5b1fdd08b8bdf09b936.zip
Provide old value of position in SplitPositionChangeEvent of *SplitPanel (#9578)
Provide old value of position in SplitPositionChangeEvent of *SplitPanel New properties have been added to SplitPositionChangeEvent: oldSplitPositionUnit, oldSplitPosition, userOriginated Resolves #9472
Diffstat (limited to 'server/src/main/java/com/vaadin')
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java76
1 files changed, 71 insertions, 5 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
index 93afdcfc2a..898a25674f 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSplitPanel.java
@@ -64,9 +64,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
@Override
public void setSplitterPosition(float position) {
+ float oldPosition = getSplitPosition();
+
getSplitterState().position = position;
- fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this,
- position, getSplitPositionUnit()));
+
+ fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this, true,
+ oldPosition, getSplitPositionUnit(), position, getSplitPositionUnit()));
}
};
@@ -331,13 +334,16 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
if (unit != Unit.PERCENTAGE) {
pos = Math.round(pos);
}
+ float oldPosition = getSplitPosition();
+ Unit oldUnit = getSplitPositionUnit();
+
SplitterState splitterState = getSplitterState();
splitterState.position = pos;
splitterState.positionUnit = unit.getSymbol();
splitterState.positionReversed = reverse;
posUnit = unit;
- fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this, pos,
- posUnit));
+ fireEvent(new SplitPositionChangeEvent(AbstractSplitPanel.this, false,
+ oldPosition, oldUnit, pos, posUnit));
}
/**
@@ -559,24 +565,84 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
*/
public static class SplitPositionChangeEvent extends Component.Event {
+ private final float oldPosition;
+ private final Unit oldUnit;
+
private final float position;
private final Unit unit;
+ private final boolean userOriginated;
+
public SplitPositionChangeEvent(final Component source,
- final float position, final Unit unit) {
+ final boolean userOriginated,
+ final float oldPosition, final Unit oldUnit,
+ final float position, final Unit unit) {
super(source);
+ this.userOriginated = userOriginated;
+ this.oldUnit = oldUnit;
+ this.oldPosition = oldPosition;
this.position = position;
this.unit = unit;
}
+ /**
+ * Returns the new split position that triggered this change event.
+ *
+ * @since 7.5.0
+ *
+ * @return the new value of split position
+ */
public float getSplitPosition() {
return position;
}
+ /**
+ * Returns the new split position unit that triggered this change event.
+ *
+ * @since 7.5.0
+ *
+ * @return the new value of split position
+ */
public Unit getSplitPositionUnit() {
return unit;
}
+ /**
+ * Returns the position of the split before this change event occurred.
+ *
+ * @since 8.1
+ *
+ * @return the split position previously set to the source of this event
+ */
+ public float getOldSplitPosition() {
+ return oldPosition;
+ }
+
+ /**
+ * Returns the position unit of the split before this change event
+ * occurred.
+ *
+ * @since 8.1
+ *
+ * @return the split position unit previously set to the source of
+ * this event
+ */
+ public Unit getOldSplitPositionUnit() {
+ return oldUnit;
+ }
+
+ /**
+ * Returns whether this event was triggered by user interaction, on the
+ * client side, or programmatically, on the server side.
+ *
+ * @since 8.1
+ *
+ * @return {@code true} if this event originates from the client,
+ * {@code false} otherwise.
+ */
+ public boolean isUserOriginated() {
+ return userOriginated;
+ }
}
public Registration addSplitterClickListener(