Clover coverage report - net.sourceforge.astyleclipse Coverage Report
Coverage timestamp: 星期六 九月 23 2006 23:19:47 CST
file stats: LOC: 179   Methods: 11
NCLOC: 110   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
ASFormatterBeanInfo.java 0% 0% 0% 0%
coverage
 1    /*
 2    * :tabSize=8:indentSize=4:noTabs=true:maxLineLen=0:
 3    *
 4    * Copyright (c) 2001 Dirk Moebius. All rights reserved.
 5    *
 6    * ASFormatterBeanInfo.java
 7    * by Dirk Moebius (dmoebius@gmx.net).
 8    * This file is a part of "Artistic Style" - an indentater and reformatter
 9    * of C++, C, and Java source files.
 10    *
 11    * The "Artistic Style" project, including all files needed to compile it,
 12    * is free software; you can redistribute it and/or use it and/or modify it
 13    * under the terms of EITHER the "Artistic License" OR
 14    * the GNU Library General Public License as published by the Free Software
 15    * Foundation; either version 2 of the License, or (at your option) any later
 16    * version.
 17    *
 18    * This program is distributed in the hope that it will be useful,
 19    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 20    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 21    *
 22    * You should have received a copy of EITHER the "Artistic License" or
 23    * the GNU Library General Public License along with this program.
 24    */
 25   
 26   
 27    package net.sourceforge.astyleclipse.astyle;
 28   
 29   
 30    import java.beans.*;
 31    import java.lang.reflect.*;
 32    import java.util.Locale;
 33    import java.util.ResourceBundle;
 34    import java.util.Vector;
 35   
 36   
 37    public class ASFormatterBeanInfo extends SimpleBeanInfo {
 38   
 39  0 public ASFormatterBeanInfo() {
 40  0 super();
 41  0 propertyDescriptors = new Vector();
 42  0 resources = ResourceBundle.getBundle("astyle.ASFormatterBeanInfoTexts");
 43   
 44    // 1) add property descriptions from superclass ASBeautifier:
 45  0 addPropertyDescription("blockIndent");
 46  0 addPropertyDescription("bracketIndent");
 47  0 addPropertyDescription("caseIndent");
 48  0 addPropertyDescription("classIndent");
 49  0 addPropertyDescription("cStyle");
 50  0 addPropertyDescription("emptyLineFill");
 51  0 addPropertyDescription("forceTabs");
 52  0 addPropertyDescription("labelIndent");
 53  0 addPropertyDescription("maxInStatementIndentLength");
 54  0 addPropertyDescription("minConditionalIndentLength");
 55  0 addPropertyDescription("namespaceIndent");
 56  0 addPropertyDescription("preprocessorIndent");
 57  0 addPropertyDescription("spaceIndentation");
 58  0 addPropertyDescription("switchIndent");
 59  0 addPropertyDescription("tabIndentation");
 60  0 addPropertyDescription("useTabs");
 61   
 62    // 2) add property descriptions from class ASFormatter:
 63  0 addPropertyDescription("bracketFormatMode", BracketFormatModePropertyEditor.class);
 64  0 addPropertyDescription("breakBlocksMode");
 65  0 addPropertyDescription("breakClosingHeaderBlocksMode");
 66  0 addPropertyDescription("breakClosingHeaderBracketsMode");
 67  0 addPropertyDescription("breakElseIfsMode");
 68  0 addPropertyDescription("breakOneLineBlocksMode");
 69  0 addPropertyDescription("operatorPaddingMode");
 70  0 addPropertyDescription("parenthesisPaddingMode");
 71  0 addPropertyDescription("singleStatementsMode");
 72  0 addPropertyDescription("tabSpaceConversionMode");
 73    }
 74   
 75   
 76  0 public BeanDescriptor getBeanDescriptor() {
 77  0 return new BeanDescriptor(ASFormatter.class);
 78    }
 79   
 80   
 81  0 public PropertyDescriptor[] getPropertyDescriptors() {
 82  0 PropertyDescriptor[] pds = new PropertyDescriptor[propertyDescriptors.size()];
 83  0 propertyDescriptors.copyInto(pds);
 84  0 return pds;
 85    }
 86   
 87   
 88  0 protected void addPropertyDescription(String name, String displayName, String description, Class propertyEditorClass, Class beanClass) {
 89  0 try {
 90  0 PropertyDescriptor pd = new PropertyDescriptor(name, beanClass);
 91  0 pd.setDisplayName(displayName);
 92  0 pd.setShortDescription(description);
 93  0 if (propertyEditorClass != null)
 94  0 pd.setPropertyEditorClass(propertyEditorClass);
 95  0 propertyDescriptors.addElement(pd);
 96    }
 97    catch (IntrospectionException e) {
 98  0 System.err.println(e);
 99    }
 100    }
 101   
 102   
 103    /**
 104    * Removes the property description for the specified property name.
 105    * Does nothing if no property description with the specified name
 106    * is found.
 107    */
 108  0 protected void removePropertyDescription(final String name) {
 109  0 for (int i = propertyDescriptors.size() - 1; i >= 0; --i) {
 110  0 PropertyDescriptor pd = (PropertyDescriptor) propertyDescriptors.elementAt(i);
 111  0 if (name.equals(pd.getName())) {
 112  0 propertyDescriptors.removeElementAt(i);
 113  0 return;
 114    }
 115    }
 116    }
 117   
 118   
 119  0 private void addPropertyDescription(String key, Class propertyEditorClass) {
 120  0 addPropertyDescription(
 121    key,
 122    resources.getString(key + ".label"),
 123    resources.getString(key + ".description"),
 124    propertyEditorClass,
 125    ASFormatter.class
 126    );
 127    }
 128   
 129   
 130  0 private void addPropertyDescription(String key) {
 131  0 addPropertyDescription(key, null);
 132    }
 133   
 134   
 135    protected Vector propertyDescriptors;
 136    protected ResourceBundle resources;
 137   
 138   
 139    private static final String[] bracketTypeTags = new String[4];
 140   
 141   
 142    static {
 143  0 bracketTypeTags[ASResource.BREAK_MODE] = "ANSI C/C++";
 144  0 bracketTypeTags[ASResource.ATTACH_MODE] = "Java / K&R";
 145  0 bracketTypeTags[ASResource.BDAC_MODE] = "Linux";
 146  0 bracketTypeTags[ASResource.NONE_MODE] = "None";
 147    }
 148   
 149   
 150    public static class BracketFormatModePropertyEditor extends PropertyEditorSupport {
 151   
 152  0 public BracketFormatModePropertyEditor() {
 153  0 super();
 154    }
 155   
 156   
 157  0 public String[] getTags() {
 158  0 return bracketTypeTags;
 159    }
 160   
 161   
 162  0 public String getAsText() {
 163  0 return bracketTypeTags[((Integer)getValue()).intValue()];
 164    }
 165   
 166   
 167  0 public void setAsText(String text) {
 168  0 for (int i = 0; i < 4; ++i) {
 169  0 if (bracketTypeTags[i].equals(text)) {
 170  0 setValue(new Integer(i));
 171  0 return;
 172    }
 173    }
 174  0 throw new IllegalArgumentException("illegal text value: " + text);
 175    }
 176   
 177    }
 178   
 179    }