< prev index next >

src/org/netbeans/jemmy/operators/Operator.java

Print this page




 676      * constants defined in public static final {@code *_DPROP} fields for
 677      * each operator type.
 678      *
 679      * @return a Hashtable containing name-value pairs.
 680      */
 681     public Hashtable<String, Object> getDump() {
 682         Hashtable<String, Object> result = new Hashtable<>();
 683         result.put(CLASS_DPROP, getSource().getClass().getName());
 684         result.put(TO_STRING_DPROP, getSource().toString());
 685         return result;
 686     }
 687 
 688     /**
 689      * Waits a state specified by a ComponentChooser instance.
 690      *
 691      * @param state a ComponentChooser defining the state criteria.
 692      * @throws TimeoutExpiredException if the state has not achieved in a value
 693      * defined by {@code "ComponentOperator.WaitStateTimeout"}
 694      */
 695     public void waitState(final ComponentChooser state) {
 696         Waiter<String, Void> stateWaiter = new Waiter<>(new Waitable<String, Void>() {
 697             @Override
 698             public String actionProduced(Void obj) {
 699                 return state.checkComponent(getSource()) ? "" : null;
 700             }
 701 
 702             @Override
 703             public String getDescription() {
 704                 return "Wait \"" + state.getDescription()
 705                         + "\" state to be reached";
 706             }
 707 
 708             @Override
 709             public String toString() {
 710                 return "Operator.waitState.Waitable{description = " + getDescription() + '}';
 711             }
 712         });
 713         stateWaiter.setTimeoutsToCloneOf(getTimeouts(), "ComponentOperator.WaitStateTimeout");





 714         stateWaiter.setOutput(getOutput().createErrorOutput());
 715         try {
 716             stateWaiter.waitAction(null);
 717         } catch (InterruptedException e) {
 718             throw (new JemmyException("Waiting of \"" + state.getDescription()


 719                     + "\" state has been interrupted!"));
 720         }
 721     }
 722 
 723     /**
 724      * Waits a state specified by a ComponentChooser instance on EDT queue.
 725      *
 726      * @param state a ComponentChooser defining the state criteria.
 727      * @throws TimeoutExpiredException if the state has not achieved in a value
 728      * defined by {@code "ComponentOperator.WaitStateTimeout"}
 729      */
 730     public void waitStateOnQueue(final ComponentChooser state) {
 731         waitState((comp) -> {
 732             return (boolean) (queueTool.invokeSmoothly(
 733                     new QueueTool.QueueAction<Object>("checkComponent") {
 734                 @Override
 735                 public final Object launch() throws Exception {
 736                     return state.checkComponent(comp);
 737                 }
 738             }));




 676      * constants defined in public static final {@code *_DPROP} fields for
 677      * each operator type.
 678      *
 679      * @return a Hashtable containing name-value pairs.
 680      */
 681     public Hashtable<String, Object> getDump() {
 682         Hashtable<String, Object> result = new Hashtable<>();
 683         result.put(CLASS_DPROP, getSource().getClass().getName());
 684         result.put(TO_STRING_DPROP, getSource().toString());
 685         return result;
 686     }
 687 
 688     /**
 689      * Waits a state specified by a ComponentChooser instance.
 690      *
 691      * @param state a ComponentChooser defining the state criteria.
 692      * @throws TimeoutExpiredException if the state has not achieved in a value
 693      * defined by {@code "ComponentOperator.WaitStateTimeout"}
 694      */
 695     public void waitState(final ComponentChooser state) {
 696         waitState(new Waitable<String, Void>() {
 697             @Override
 698             public String actionProduced(Void obj) {
 699                 return state.checkComponent(getSource()) ? "" : null;
 700             }
 701 
 702             @Override
 703             public String getDescription() {
 704                 return "Wait \"" + state.getDescription()
 705                         + "\" state to be reached";
 706             }
 707 
 708             @Override
 709             public String toString() {
 710                 return "Operator.waitState.Waitable{description = " + getDescription() + '}';
 711             }
 712         });
 713     }
 714 
 715     public <R> R waitState(Waitable<R, Void> waitable) {
 716         Waiter<R, Void> stateWaiter = new Waiter<>(waitable);
 717         stateWaiter.setTimeoutsToCloneOf(getTimeouts(),
 718                 "ComponentOperator.WaitStateTimeout");
 719         stateWaiter.setOutput(getOutput().createErrorOutput());
 720         try {
 721             return stateWaiter.waitAction(null);
 722         } catch (InterruptedException e) {
 723             Thread.currentThread().interrupt();
 724             throw (new JemmyException(
 725                     "Waiting of \"" + waitable.getDescription()
 726                             + "\" state has been interrupted!"));
 727         }
 728     }
 729 
 730     /**
 731      * Waits a state specified by a ComponentChooser instance on EDT queue.
 732      *
 733      * @param state a ComponentChooser defining the state criteria.
 734      * @throws TimeoutExpiredException if the state has not achieved in a value
 735      * defined by {@code "ComponentOperator.WaitStateTimeout"}
 736      */
 737     public void waitStateOnQueue(final ComponentChooser state) {
 738         waitState((comp) -> {
 739             return (boolean) (queueTool.invokeSmoothly(
 740                     new QueueTool.QueueAction<Object>("checkComponent") {
 741                 @Override
 742                 public final Object launch() throws Exception {
 743                     return state.checkComponent(comp);
 744                 }
 745             }));


< prev index next >