001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.tests;
015:
016: import org.jetbrains.annotations.NotNull;
017:
018: import java.beans.BeanInfo;
019: import java.beans.IntrospectionException;
020: import java.beans.Introspector;
021: import java.beans.PropertyDescriptor;
022: import java.util.Arrays;
023: import java.util.Comparator;
024: import java.util.HashSet;
025:
026: /**
027: * User: Martin
028: * Date: 26.01.2007
029: * Time: 12:57:50
030: */
031: @SuppressWarnings({"ALL"})
032: public class ChartPropertyLister {
033: @NotNull
034: private static final HashSet<String> exludedExpressionProperties;
035:
036: static {
037: exludedExpressionProperties = new HashSet<String>();
038: exludedExpressionProperties.add("value");//NON-NLS
039: exludedExpressionProperties.add("active");//NON-NLS
040: exludedExpressionProperties.add("dataRow");//NON-NLS
041: exludedExpressionProperties.add("instance");//NON-NLS
042: }
043:
044: public static void main(@NotNull
045: String[] args) throws ClassNotFoundException,
046: IntrospectionException {
047: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.AreaChartExpression");
048: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.BarChartExpression");
049: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.CategorySetCollectorFunction");
050: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.LineChartExpression");
051: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.MultiPieChartExpression");
052: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.PieChartExpression");
053: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.PieSetCollectorFunction");
054: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.RingChartExpression");
055: //listProperties("org.pentaho.plugin.jfreereport.reportcharts.WaterfallChartExpressions");
056:
057: listProperties("org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression");
058: listProperties("org.pentaho.plugin.jfreereport.reportcharts.BubbleChartExpression");
059: listProperties("org.pentaho.plugin.jfreereport.reportcharts.ExtendedXYLineChartExpression");
060: listProperties("org.pentaho.plugin.jfreereport.reportcharts.ScatterPlotChartExpression");
061: listProperties("org.pentaho.plugin.jfreereport.reportcharts.XYAreaChartExpression");
062: listProperties("org.pentaho.plugin.jfreereport.reportcharts.XYBarChartExpression");
063: listProperties("org.pentaho.plugin.jfreereport.reportcharts.XYLineChartExpression");
064:
065: listProperties("org.pentaho.plugin.jfreereport.reportcharts.PivotCategorySetCollectorFunction");
066: listProperties("org.pentaho.plugin.jfreereport.reportcharts.XYSeriesCollectorFunction");
067: listProperties("org.pentaho.plugin.jfreereport.reportcharts.XYZSeriesCollectorFunction");
068: listProperties("org.pentaho.plugin.jfreereport.reportcharts.TimeSeriesCollectorFunction");
069:
070: }
071:
072: private static void listProperties(@NotNull
073: String classname) throws ClassNotFoundException,
074: IntrospectionException {
075: BeanInfo beanInfo = Introspector.getBeanInfo(Class
076: .forName(classname));
077: PropertyDescriptor[] propertyDescriptors = beanInfo
078: .getPropertyDescriptors();
079:
080: //sort alphabetically, the file name (from superclass) will be the first.
081: Arrays.sort(propertyDescriptors,
082: new Comparator<PropertyDescriptor>() {
083: public int compare(@NotNull
084: PropertyDescriptor o1, @NotNull
085: PropertyDescriptor o2) {
086: return o1.getName().compareTo(o2.getName());
087: }
088: });
089:
090: for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
091: if (propertyDescriptor.getReadMethod() != null
092: && propertyDescriptor.getWriteMethod() != null
093: && !exludedExpressionProperties
094: .contains(propertyDescriptor.getName())) {
095: System.out
096: .println("propertyInfos.put(\""
097: + classname
098: + "."
099: + propertyDescriptor.getName()
100: + "\", new PropertyInfo(PropertyKeys.GROUP_REQUIRED, -1));//NON-NLS");
101: }
102: }
103:
104: System.out.println();
105: }
106: }
|