Fixes #11909tags/8.10.3
@@ -116,10 +116,10 @@ public class Criterion implements Serializable { | |||
*/ | |||
private Criterion(String key, ComparisonOperator operator, String value, | |||
Payload.ValueType valueType) { | |||
this.key = key; | |||
this.value = value; | |||
this.valueType = valueType; | |||
this.operator = operator; | |||
setKey(key); | |||
setValue(value); | |||
setValueType(valueType); | |||
setOperator(operator); | |||
} | |||
/** | |||
@@ -131,6 +131,16 @@ public class Criterion implements Serializable { | |||
return key; | |||
} | |||
/** | |||
* Sets the key of the payload to be compared. | |||
* | |||
* @param key | |||
* key of the payload to be compared | |||
*/ | |||
public void setKey(String key) { | |||
this.key = key; | |||
} | |||
/** | |||
* Gets the value of the payload to be compared. | |||
* | |||
@@ -140,6 +150,16 @@ public class Criterion implements Serializable { | |||
return value; | |||
} | |||
/** | |||
* Sets the value of the payload to be compared. | |||
* | |||
* @param value | |||
* value of the payload to be compared | |||
*/ | |||
public void setValue(String value) { | |||
this.value = value; | |||
} | |||
/** | |||
* Gets the type of the payload value to be compared. | |||
* | |||
@@ -149,6 +169,16 @@ public class Criterion implements Serializable { | |||
return valueType; | |||
} | |||
/** | |||
* Sets the type of the payload value to be compared. | |||
* | |||
* @param valueType | |||
* type of the payload to be compared | |||
*/ | |||
public void setValueType(Payload.ValueType valueType) { | |||
this.valueType = valueType; | |||
} | |||
/** | |||
* Gets the comparison operator. | |||
* | |||
@@ -158,6 +188,16 @@ public class Criterion implements Serializable { | |||
return operator; | |||
} | |||
/** | |||
* Sets the comparison operator. | |||
* | |||
* @param operator | |||
* comparison operator | |||
*/ | |||
public void setOperator(ComparisonOperator operator) { | |||
this.operator = operator; | |||
} | |||
/** | |||
* Compares this criterion's value to the given payload's value and returns | |||
* whether the result matches the criterion's operator. The comparison is |
@@ -0,0 +1,59 @@ | |||
package com.vaadin.tests.dnd; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUIWithLog; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.dnd.DragSourceExtension; | |||
import com.vaadin.ui.dnd.DropTargetExtension; | |||
public class CriterionSerialization extends AbstractTestUIWithLog { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
Button button = new Button(); | |||
button.setCaption("drag me"); | |||
button.setId("drag"); | |||
DragSourceExtension<Button> dragSource = new DragSourceExtension<>( | |||
button); | |||
dragSource.setPayload("test", "value"); | |||
dragSource.addDragStartListener(e -> { | |||
log("drag started"); | |||
}); | |||
dragSource.addDragEndListener(e -> { | |||
log("drag ended"); | |||
}); | |||
Button dropArea1 = new Button(); | |||
dropArea1.setCaption("drop here works"); | |||
dropArea1.setId("dropWorks"); | |||
DropTargetExtension<Button> dropTarget = new DropTargetExtension<>( | |||
dropArea1); | |||
dropTarget.addDropListener(e -> { | |||
log("dropArea1 drop listener invoked (expected to happen)"); | |||
}); | |||
dropTarget.setDropCriterion("test", "value"); | |||
Button dropArea2 = new Button(); | |||
dropArea2.setCaption("drop here fails"); | |||
dropArea2.setId("dropFails"); | |||
DropTargetExtension<Button> dropTarget2 = new DropTargetExtension<>( | |||
dropArea2); | |||
dropTarget2.addDropListener(e -> { | |||
log("dropArea2 drop listener invoked (should not happen)"); | |||
}); | |||
dropTarget2.setDropCriterion("test", "value2"); | |||
getLayout().addComponents(button, dropArea1, dropArea2); | |||
} | |||
@Override | |||
protected String getTestDescription() { | |||
return "Dropping the draggable button on the button without matching " | |||
+ "Criterion should not trigger drop listener."; | |||
} | |||
@Override | |||
protected Integer getTicketNumber() { | |||
return 11909; | |||
} | |||
} |