/** * Click previous/decrement spinner button * @param times number of times to click. Must be greater than 0 * @throws VerificationException if the element doesn't exist */ @PublicAtsApi public void clickPrevious( int times ) { if (times <= 0) { throw new UiElementException("The number of times to click must be greater than 0", this); } new SwingElementState(this).waitToBecomeExisting(); ((JSpinnerFixture) SwingElementLocator.findFixture(this)).decrement(times); }
/** * Click next/increment spinner button * @param times number of times to click. Must be greater than 0 * @throws VerificationException if the element doesn't exist */ @PublicAtsApi public void clickNext( int times ) { if (times <= 0) { throw new UiElementException("The number of times to click must be greater than 0", this); } new SwingElementState(this).waitToBecomeExisting(); ((JSpinnerFixture) SwingElementLocator.findFixture(this)).increment(times); }
/** * Get spinner text value * @throws VerificationException if the element doesn't exist */ @PublicAtsApi public String getValue() { new SwingElementState(this).waitToBecomeExisting(); return ((JSpinnerFixture) SwingElementLocator.findFixture(this)).text(); }
} else if (componentClass.equals(JSpinner.class)) { return (ComponentFixture<? extends Component>) new JSpinnerFixture(containerFixture.robot, (JSpinner) findElement(uiElement)); } else if (componentClass.equals(JTabbedPane.class)) {
/** * Set spinner text value (entering and committing the given text in the JSpinner) * @throws VerificationException if the element doesn't exist */ @PublicAtsApi public void setValue( String value ) { new SwingElementState(this).waitToBecomeExisting(); JSpinnerFixture spinnerFixture = (JSpinnerFixture) SwingElementLocator.findFixture(this); int delayBetweenEvents = spinnerFixture.robot.settings().delayBetweenEvents(); try { // enterTextAndCommit() method sets the text value using the Robot, so we will speed it up String delay = AtsSystemProperties.getPropertyAsString(AtsSystemProperties.UI_ENGINE__SWING_ROBOT_DELAY_BETWEEN_EVENTS); if (delay != null) { int ms = -1; try { ms = Integer.parseInt(delay); } catch (NumberFormatException ex) { log.error("Illegal robot dealy between events specified! Will be used default one", ex); } if (ms >= 0) { spinnerFixture.robot.settings().delayBetweenEvents(ms); } } else { spinnerFixture.robot.settings().delayBetweenEvents(100); // hardcode to 100ms } spinnerFixture.enterTextAndCommit(value); } finally { spinnerFixture.robot.settings().delayBetweenEvents(delayBetweenEvents); } }
/** * Enter text in the spinner text field without committing the value. * @throws VerificationException if the element doesn't exist */ @PublicAtsApi public void enterText( String text ) { new SwingElementState(this).waitToBecomeExisting(); JSpinnerFixture spinnerFixture = (JSpinnerFixture) SwingElementLocator.findFixture(this); int delayBetweenEvents = spinnerFixture.robot.settings().delayBetweenEvents(); try { // enterText() method sets the text value using the Robot, so we will speed it up spinnerFixture.robot.settings().delayBetweenEvents(10); spinnerFixture.enterText(text); } finally { spinnerFixture.robot.settings().delayBetweenEvents(delayBetweenEvents); } }