| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.format; |
| 17 |
|
|
| 18 |
|
import static java.lang.String.valueOf; |
| 19 |
|
import static org.fest.util.Strings.concat; |
| 20 |
|
import static org.fest.util.Strings.quote; |
| 21 |
|
|
| 22 |
|
import java.awt.Component; |
| 23 |
|
import java.util.ArrayList; |
| 24 |
|
import java.util.List; |
| 25 |
|
|
| 26 |
|
import javax.swing.JComboBox; |
| 27 |
|
|
| 28 |
|
import org.fest.util.Arrays; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 35 |
|
public class JComboBoxFormatter extends ComponentFormatterTemplate { |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
@link |
| 40 |
|
@param |
| 41 |
|
@return |
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 43 |
41
|
protected String doFormat(Component c) {... |
| 44 |
41
|
JComboBox comboBox = (JComboBox)c; |
| 45 |
41
|
return concat( |
| 46 |
|
comboBox.getClass().getName(), "[", |
| 47 |
|
"name=", quote(comboBox.getName()), ", ", |
| 48 |
|
"selectedItem=", quote(comboBox.getSelectedItem()), ", ", |
| 49 |
|
"contents=", Arrays.format(contentsOf(comboBox)), ", ", |
| 50 |
|
"editable=", valueOf(comboBox.isEditable()), ", ", |
| 51 |
|
"enabled=", valueOf(comboBox.isEnabled()), ", ", |
| 52 |
|
"visible=", valueOf(comboBox.isVisible()), ", ", |
| 53 |
|
"showing=", valueOf(comboBox.isShowing()), |
| 54 |
|
"]" |
| 55 |
|
); |
| 56 |
|
} |
| 57 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 58 |
41
|
private Object[] contentsOf(final JComboBox comboBox) {... |
| 59 |
41
|
List<Object> contents = new ArrayList<Object>(); |
| 60 |
41
|
int count = comboBox.getItemCount(); |
| 61 |
167
|
for (int i = 0; i < count; i++) contents.add(comboBox.getItemAt(i)); |
| 62 |
41
|
return contents.toArray(); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
@link |
| 67 |
|
@return |
| 68 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 69 |
366
|
public Class<? extends Component> targetType() {... |
| 70 |
366
|
return JComboBox.class; |
| 71 |
|
} |
| 72 |
|
} |