Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
8   61   5   2.67
2   23   0.62   3
3     1.67  
1    
 
  GuiQuery       Line # 29 8 0% 5 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Jul 22, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.edt;
17   
18    import static javax.swing.SwingUtilities.isEventDispatchThread;
19    import static org.fest.swing.exception.ActionFailedException.actionFailure;
20   
21    import org.fest.swing.exception.ActionFailedException;
22   
23    /**
24    * Understands executing an action, in the event dispatch thread, that returns a value.
25    * @param <T> the return type of the action to execute.
26    *
27    * @author Alex Ruiz
28    */
 
29    public abstract class GuiQuery<T> extends GuiAction {
30   
31    private T result;
32   
33    /**
34    * Executes the query in the event dispatch thread. This method waits until the action has finish its execution.
35    * @throws ActionFailedException if this task is not executed in the event dispatch thread.
36    */
 
37  148956 toggle public final void run() {
38  148956 if (!isEventDispatchThread())
39  1 throw actionFailure("Query should be executed in the event dispatch thread");
40  148955 try {
41  148955 result = executeInEDT();
42    } catch (Throwable t) {
43  283 catchedException(t);
44    } finally {
45  148955 notifyExecutionCompleted();
46    }
47    }
48   
49    /**
50    * Specifies the action to execute in the event dispatch thread.
51    * @return the result of the execution of the action.
52    * @throws Throwable any error thrown when executing an action in the event dispatch thread.
53    */
54    protected abstract T executeInEDT() throws Throwable;
55   
 
56  148955 toggle final T result() { return result; }
57   
 
58  148955 toggle final void clearResult() {
59  148955 result = null;
60    }
61    }