| 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 |
|
|
| 24 |
|
import javax.swing.JTabbedPane; |
| 25 |
|
|
| 26 |
|
import org.fest.util.Arrays; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
@link |
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 8 |
Complexity Density: 0.5 |
|
| 33 |
|
public class JTabbedPaneFormatter extends ComponentFormatterTemplate { |
| 34 |
|
|
| 35 |
|
private static final String NO_SELECTION = "<No selection>"; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
@link |
| 40 |
|
@param |
| 41 |
|
@return |
| 42 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 43 |
16
|
protected String doFormat(Component c) {... |
| 44 |
16
|
JTabbedPane tabbedPane = (JTabbedPane)c; |
| 45 |
16
|
return concat( |
| 46 |
|
tabbedPane.getClass().getName(), "[", |
| 47 |
|
"name=", quote(tabbedPane.getName()), ", ", |
| 48 |
|
"selectedTabIndex=", valueOf(tabbedPane.getSelectedIndex()), ", ", |
| 49 |
|
"selectedTabTitle=", selectedTab(tabbedPane), ", ", |
| 50 |
|
"tabCount=", valueOf(tabbedPane.getTabCount()), ", ", |
| 51 |
|
"tabTitles=", Arrays.format(tabTitles(tabbedPane)), ", ", |
| 52 |
|
"enabled=", valueOf(tabbedPane.isEnabled()), ", ", |
| 53 |
|
"visible=", valueOf(tabbedPane.isVisible()), ", ", |
| 54 |
|
"showing=", valueOf(tabbedPane.isShowing()), |
| 55 |
|
"]" |
| 56 |
|
); |
| 57 |
|
} |
| 58 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 59 |
16
|
private String selectedTab(JTabbedPane tabbedPane) {... |
| 60 |
1
|
if (tabbedPane.getTabCount() == 0) return NO_SELECTION; |
| 61 |
15
|
int index = tabbedPane.getSelectedIndex(); |
| 62 |
1
|
if (index == -1) return NO_SELECTION; |
| 63 |
14
|
return quote(tabbedPane.getTitleAt(index)); |
| 64 |
|
} |
| 65 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 66 |
16
|
private String[] tabTitles(JTabbedPane tabbedPane) {... |
| 67 |
16
|
int count = tabbedPane.getTabCount(); |
| 68 |
1
|
if (count == 0) return new String[0]; |
| 69 |
15
|
String[] titles = new String[count]; |
| 70 |
26
|
for (int i = 0; i < count; i++) titles[i] = tabbedPane.getTitleAt(i); |
| 71 |
15
|
return titles; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@link |
| 76 |
|
@return |
| 77 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
340
|
public Class<? extends Component> targetType() {... |
| 79 |
340
|
return JTabbedPane.class; |
| 80 |
|
} |
| 81 |
|
} |