|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GuiLazyLoadingDescription | Line # 29 | 2 | 0% | 2 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | /* | |
| 2 | * Created on Oct 27, 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 org.fest.swing.edt.GuiActionRunner.execute; | |
| 19 | ||
| 20 | import org.fest.assertions.Description; | |
| 21 | import org.fest.swing.annotation.RunsInCurrentThread; | |
| 22 | ||
| 23 | /** | |
| 24 | * Understands a <code>{@link Description}</code> that loads the text to return in the event dispatch thread. | |
| 25 | * | |
| 26 | * @author Alex Ruiz | |
| 27 | * @author Yvonne Wang | |
| 28 | */ | |
| 29 | public abstract class GuiLazyLoadingDescription implements Description { | |
| 30 | ||
| 31 | /** | |
| 32 | * Executes <code>{@link #loadDescription()}</code> in the event dispatch thread. | |
| 33 | * @return the text loaded in the event dispatch thread. | |
| 34 | */ | |
| 35 | 90 |
public final String value() { |
| 36 | 90 | return execute(new GuiQuery<String>() { |
| 37 | 90 |
protected String executeInEDT() { |
| 38 | 90 | return loadDescription(); |
| 39 | } | |
| 40 | }); | |
| 41 | } | |
| 42 | ||
| 43 | /** | |
| 44 | * Returns the lazy-loaded text of this description. | |
| 45 | * <p> | |
| 46 | * <b>Note:</b> This method is <b>not</b> guaranteed to be executed in the event dispatch thread (EDT.) Clients are | |
| 47 | * responsible for calling this method from the EDT. | |
| 48 | * </p> | |
| 49 | * @return the lazy-loaded text of this description. | |
| 50 | */ | |
| 51 | @RunsInCurrentThread | |
| 52 | protected abstract String loadDescription(); | |
| 53 | } | |
|
||||||||||||