< prev index next >
src/org/netbeans/jemmy/operators/JSpinnerOperator.java
Print this page
*** 26,36 ****
import java.awt.Container;
import java.text.ParseException;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
- import java.util.Objects;
import javax.swing.JComponent;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
--- 26,35 ----
*** 965,975 ****
}
}
/**
* Abstract class for a scrolling of a spinner having unknown model type. A
! * subclass needs to override {@code equals(Object)} value to specify a
* criteria of successful scrolling.
*/
public abstract static class ObjectScrollAdjuster implements ScrollAdjuster {
SpinnerModel model;
--- 964,974 ----
}
}
/**
* Abstract class for a scrolling of a spinner having unknown model type. A
! * subclass needs to override {@code reached(Object)} method to specify a
* criteria of successful scrolling.
*/
public abstract static class ObjectScrollAdjuster implements ScrollAdjuster {
SpinnerModel model;
*** 987,997 ****
model = oper.getModel();
}
@Override
public int getScrollDirection() {
! if (equals(model.getValue())) {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
} else if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION
&& model.getNextValue() != null
|| direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION
&& model.getPreviousValue() != null) {
--- 986,996 ----
model = oper.getModel();
}
@Override
public int getScrollDirection() {
! if (reached(model.getValue())) {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
} else if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION
&& model.getNextValue() != null
|| direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION
&& model.getPreviousValue() != null) {
*** 999,1009 ****
} else {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
}
}
! public abstract boolean equals(Object curvalue);
@Override
public int getScrollOrientation() {
return SwingConstants.VERTICAL;
}
--- 998,1008 ----
} else {
return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
}
}
! public abstract boolean reached(Object curvalue);
@Override
public int getScrollOrientation() {
return SwingConstants.VERTICAL;
}
*** 1027,1045 ****
public ExactScrollAdjuster(JSpinnerOperator oper, Object obj, int direction) {
super(oper, direction);
this.obj = obj;
}
- public boolean equals(Object curvalue) {
- return curvalue != null && curvalue.equals(obj);
- }
-
@Override
! public int hashCode() {
! int hash = 7;
! hash = 79 * hash + Objects.hashCode(this.obj);
! return hash;
}
@Override
public String getDescription() {
return "Spin to " + obj.toString() + " value";
--- 1026,1038 ----
public ExactScrollAdjuster(JSpinnerOperator oper, Object obj, int direction) {
super(oper, direction);
this.obj = obj;
}
@Override
! public boolean reached(Object curvalue) {
! return curvalue != null && curvalue.equals(obj);
}
@Override
public String getDescription() {
return "Spin to " + obj.toString() + " value";
*** 1091,1112 ****
*/
public ToStringScrollAdjuster(JSpinnerOperator oper, String pattern, int direction) {
this(oper, pattern, oper.getComparator(), direction);
}
- public boolean equals(Object curvalue) {
-
- // TODO: This abuses the semantics of Object.equals()
- return curvalue != null && comparator.equals(curvalue.toString(), pattern);
- }
-
@Override
! public int hashCode() {
! int hash = 7;
! hash = 97 * hash + Objects.hashCode(this.pattern);
! hash = 97 * hash + Objects.hashCode(this.comparator);
! return hash;
}
@Override
public String getDescription() {
return "Spin to \"" + pattern + "\" value";
--- 1084,1096 ----
*/
public ToStringScrollAdjuster(JSpinnerOperator oper, String pattern, int direction) {
this(oper, pattern, oper.getComparator(), direction);
}
@Override
! public boolean reached(Object curvalue) {
! return curvalue != null && comparator.equals(curvalue.toString(), pattern);
}
@Override
public String getDescription() {
return "Spin to \"" + pattern + "\" value";
< prev index next >