|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BasicCellRendererReader | Line # 28 | 3 | 0% | 2 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | /* | |
| 2 | * Created on Oct 21, 2008 | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | |
| 5 | * 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 is distributed on | |
| 10 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| 11 | * specific language governing permissions and limitations under the License. | |
| 12 | * | |
| 13 | * Copyright @2008-2010 the original author or authors. | |
| 14 | */ | |
| 15 | package org.fest.swing.driver; | |
| 16 | ||
| 17 | import java.awt.Component; | |
| 18 | ||
| 19 | import javax.swing.JLabel; | |
| 20 | ||
| 21 | import org.fest.swing.annotation.RunsInCurrentThread; | |
| 22 | ||
| 23 | /** | |
| 24 | * Understands a basic implementation of <code>{@link CellRendererReader}</code>. | |
| 25 | * | |
| 26 | * @author Alex Ruiz | |
| 27 | */ | |
| 28 | public class BasicCellRendererReader implements CellRendererReader { | |
| 29 | ||
| 30 | /** | |
| 31 | * Reads the value in the given cell renderer component, or returns <code>null</code> if the renderer belongs to an | |
| 32 | * unknown component type. Internally, this method will call <code>getText()</code> if the given renderer is an | |
| 33 | * instance of <code>{@link JLabel}</code></li>. | |
| 34 | * <p> | |
| 35 | * <b>Note:</b> This method is <b>not</b> guaranteed to be executed in the event dispatch thread (EDT.) Clients are | |
| 36 | * responsible for calling this method from the EDT. | |
| 37 | * </p> | |
| 38 | * @param c the given cell renderer component. | |
| 39 | * @return the value of the given <code>Component</code>, or <code>null</code> if the renderer belongs to an unknown | |
| 40 | * component type. | |
| 41 | */ | |
| 42 | 1646 |
@RunsInCurrentThread |
| 43 | public String valueFrom(Component c) { | |
| 44 | 1615 | if (c instanceof JLabel) return ((JLabel)c).getText(); |
| 45 | 31 | return null; |
| 46 | } | |
| 47 | } | |
|
||||||||||||