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
4   69   3   1.33
0   32   0.75   3
3     1  
1    
 
  JFileChooserFormatter       Line # 32 4 0% 3 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Dec 23, 2007
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 @2007-2010 the original author or authors.
15    */
16    package org.fest.swing.format;
17   
18    import static java.lang.String.valueOf;
19    import static javax.swing.JFileChooser.*;
20    import static org.fest.util.Strings.concat;
21    import static org.fest.util.Strings.quote;
22   
23    import java.awt.Component;
24   
25    import javax.swing.JFileChooser;
26   
27    /**
28    * Understands a formatter for <code>{@link JFileChooser}</code>s.
29    *
30    * @author Yvonne Wang
31    */
 
32    public class JFileChooserFormatter extends ComponentFormatterTemplate {
33   
34    private static final IntEnum DIALOG_TYPES = new IntEnum();
 
35  324 toggle static {
36  324 DIALOG_TYPES.put(OPEN_DIALOG, "OPEN_DIALOG")
37    .put(SAVE_DIALOG, "SAVE_DIALOG")
38    .put(CUSTOM_DIALOG, "CUSTOM_DIALOG");
39    }
40   
41    /**
42    * Returns the <code>String</code> representation of the given <code>{@link Component}</code>, which should be a
43    * <code>{@link JFileChooser}</code> (or subclass.)
44    * @param c the given <code>Component</code>.
45    * @return the <code>String</code> representation of the given <code>JFileChooser</code>.
46    */
 
47  11 toggle protected String doFormat(Component c) {
48  11 JFileChooser fileChooser = (JFileChooser)c;
49  11 return concat(
50    fileChooser.getClass().getName(), "[",
51    "name=", quote(fileChooser.getName()), ", ",
52    "dialogTitle=", quote(fileChooser.getDialogTitle()), ", ",
53    "dialogType=", DIALOG_TYPES.get(fileChooser.getDialogType()), ", ",
54    "currentDirectory=", fileChooser.getCurrentDirectory(), ", ",
55    "enabled=", valueOf(fileChooser.isEnabled()), ", ",
56    "visible=", valueOf(fileChooser.isVisible()), ", ",
57    "showing=", valueOf(fileChooser.isShowing()),
58    "]"
59    );
60    }
61   
62    /**
63    * Indicates that this formatter supports <code>{@link JFileChooser}</code> only.
64    * @return <code>JFileChooser.class</code>.
65    */
 
66  335 toggle public Class<? extends Component> targetType() {
67  335 return JFileChooser.class;
68    }
69    }