コード例 #1
0
 /**
  * Creates a new export task.
  *
  * @param dialog the progress dialog that will monitor the report progress.
  * @param report the report that should be exported.
  */
 public ExcelExportTask(
     final MasterReport report,
     final ReportProgressDialog dialog,
     final SwingGuiContext swingGuiContext)
     throws ReportProcessingException {
   if (report == null) {
     throw new NullPointerException(
         "ExcelExportTask(..): Null report parameter not permitted"); //$NON-NLS-1$
   }
   this.fileName =
       report
           .getConfiguration()
           .getConfigProperty(
               "org.pentaho.reporting.engine.classic.core.modules.gui.xls.FileName"); //$NON-NLS-1$
   if (fileName == null) {
     throw new ReportProcessingException(
         "ExcelExportTask(): Filename is not defined"); //$NON-NLS-1$
   }
   this.progressDialog = dialog;
   this.report = report;
   if (swingGuiContext != null) {
     this.statusListener = swingGuiContext.getStatusListener();
     this.messages =
         new Messages(
             swingGuiContext.getLocale(),
             ExcelExportPlugin.BASE_RESOURCE_CLASS,
             ObjectUtilities.getClassLoader(ExcelExportPlugin.class));
   }
 }
コード例 #2
0
 /** DefaultConstructor. */
 public ExcelExportPlugin() {
   resources =
       new ResourceBundleSupport(
           Locale.getDefault(),
           ExcelExportPlugin.BASE_RESOURCE_CLASS,
           ObjectUtilities.getClassLoader(ExcelExportPlugin.class));
 }
コード例 #3
0
public class Messages {
  private static final Log logger = LogFactory.getLog(Messages.class);
  private static ResourceBundleSupport bundle =
      new ResourceBundleSupport(
          Locale.getDefault(),
          "org.pentaho.reporting.ui.datasources.scriptable.messages",
          ObjectUtilities.getClassLoader(Messages.class));

  private Messages() {}

  /**
   * Formats the message stored in the resource bundle (using a MessageFormat).
   *
   * @param key the resourcebundle key
   * @param param1 the parameter for the message
   * @return the formated string
   */
  public static String getString(final String key, final Object... param1) {
    try {
      return bundle.formatMessage(key, param1);
    } catch (MissingResourceException e) {
      logger.warn("Missing localization: " + key, e);
      return '!' + key + '!';
    }
  }

  public static Icon getIcon(final String key, final boolean large) {
    return bundle.getIcon(key, large);
  }

  public static Icon getIcon(final String key) {
    return bundle.getIcon(key);
  }

  public static Integer getMnemonic(final String key) {
    return bundle.getMnemonic(key);
  }

  public static Integer getOptionalMnemonic(final String key) {
    return bundle.getOptionalMnemonic(key);
  }

  public static KeyStroke getKeyStroke(final String key) {
    return bundle.getKeyStroke(key);
  }

  public static KeyStroke getOptionalKeyStroke(final String key) {
    return bundle.getOptionalKeyStroke(key);
  }

  public static KeyStroke getKeyStroke(final String key, final int mask) {
    return bundle.getKeyStroke(key, mask);
  }

  public static KeyStroke getOptionalKeyStroke(final String key, final int mask) {
    return bundle.getOptionalKeyStroke(key, mask);
  }
}
コード例 #4
0
 public boolean initialize(final SwingGuiContext context) {
   super.initialize(context);
   resources =
       new ResourceBundleSupport(
           context.getLocale(),
           SwingPreviewModule.BUNDLE_NAME,
           ObjectUtilities.getClassLoader(SwingPreviewModule.class));
   return true;
 }
コード例 #5
0
 /**
  * Tries to load a class to indirectly check for the existence of a certain library.
  *
  * @param name the name of the library class.
  * @param context the context class to get a classloader from.
  * @return true, if the class could be loaded, false otherwise.
  */
 protected static boolean isClassLoadable(final String name, final Class context) {
   try {
     final ClassLoader loader = ObjectUtilities.getClassLoader(context);
     Class.forName(name, false, loader);
     return true;
   } catch (Exception e) {
     return false;
   }
 }
コード例 #6
0
  /**
   * Done parsing.
   *
   * @throws org.xml.sax.SAXException if there is a parsing error.
   */
  public void doneParsing() throws SAXException {
    super.doneParsing();
    final String result = getResult();
    final String propertyName =
        CompatibilityMapperUtil.mapExpressionProperty(
            originalExpressionClass, expressionClass, this.propertyName);
    if (beanUtility == null) {
      throw new ParseException("No current beanUtility", getLocator());
    }
    try {
      if (propertyType != null) {
        final ClassLoader cl = ObjectUtilities.getClassLoader(ExpressionPropertyReadHandler.class);
        final Class c = Class.forName(propertyType, false, cl);
        beanUtility.setPropertyAsString(propertyName, c, result);
      } else {
        beanUtility.setPropertyAsString(propertyName, result);
      }
    } catch (BeanException e) {
      if (strictParsing) {
        throw new ParseException(
            "Unable to assign property '"
                + propertyName
                + "' to expression '"
                + expressionName
                + '\'',
            e,
            getLocator());
      }

      logger.warn(
          "Legacy-Parser warning: Unable to assign property '"
              + propertyName
              + "' to expression '"
              + expressionName
              + '\'',
          new ParseException(
              "Unable to assign property '"
                  + propertyName
                  + "' to expression '"
                  + expressionName
                  + '\'',
              e,
              getLocator()));
    } catch (ClassNotFoundException e) {
      throw new ParseException(
          "Unable to assign property '"
              + propertyName
              + "' to expression '"
              + expressionName
              + '\'',
          e,
          getLocator());
    }
  }
コード例 #7
0
 public boolean initialize(final SwingGuiContext context) {
   super.initialize(context);
   resources =
       new ResourceBundleSupport(
           context.getLocale(),
           SwingPreviewModule.BUNDLE_NAME,
           ObjectUtilities.getClassLoader(SwingPreviewModule.class));
   eventSource = context.getEventSource();
   eventSource.addPropertyChangeListener(updateListener);
   revalidate();
   return true;
 }
コード例 #8
0
  /**
   * Starts parsing.
   *
   * @param attrs the attributes.
   * @throws SAXException if there is a parsing error.
   */
  protected void startParsing(final Attributes attrs) throws SAXException {
    super.startParsing(attrs);
    namespace = attrs.getValue(getUri(), "namespace"); // NON-NLS
    if (namespace == null) {
      throw new ParseException("Attribute 'namespace' is undefined", getLocator());
    }

    namespacePrefix = attrs.getValue(getUri(), "namespace-prefix"); // NON-NLS
    if (namespacePrefix == null) {
      namespacePrefix = ElementTypeRegistry.getInstance().getNamespacePrefix(namespace);
    }
    mandatory = "true".equals(attrs.getValue(getUri(), "mandatory")); // NON-NLS
    computed = "true".equals(attrs.getValue(getUri(), "computed")); // NON-NLS
    transientFlag = "true".equals(attrs.getValue(getUri(), "transient")); // NON-NLS
    bulk = "true".equals(attrs.getValue(getUri(), "prefer-bulk")); // NON-NLS
    designTimeValue = "true".equals(attrs.getValue(getUri(), "design-time-value")); // NON-NLS

    final String valueTypeText = attrs.getValue(getUri(), "value-type"); // NON-NLS
    if (valueTypeText == null) {
      throw new ParseException("Attribute 'value-type' is undefined", getLocator());
    }
    try {
      final ClassLoader classLoader = ObjectUtilities.getClassLoader(getClass());
      valueType = Class.forName(valueTypeText, false, classLoader);
    } catch (Exception e) {
      throw new ParseException("Attribute 'value-type' is not valid", e, getLocator());
    }

    valueRole = attrs.getValue(getUri(), "value-role"); // NON-NLS
    if (valueRole == null) {
      valueRole = "Value"; // NON-NLS
    }

    propertyEditor = attrs.getValue(getUri(), "propertyEditor"); // NON-NLS

    final String metaDataCoreClass = attrs.getValue(getUri(), "impl"); // NON-NLS
    if (metaDataCoreClass != null) {
      attributeCore =
          ObjectUtilities.loadAndInstantiate(
              metaDataCoreClass, AttributeReadHandler.class, AttributeCore.class);
      if (attributeCore == null) {
        throw new ParseException(
            "Attribute 'impl' references a invalid AttributeCore implementation.", getLocator());
      }
    } else {
      attributeCore = new DefaultAttributeCore();
    }
  }
コード例 #9
0
  /** @noinspection ProhibitedExceptionCaught */
  public static synchronized void registerDefaults() {
    final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig();
    final Iterator it =
        config.findPropertyKeys("org.pentaho.reporting.engine.classic.core.stylekeys.");
    final ClassLoader classLoader = ObjectUtilities.getClassLoader(StyleKey.class);

    while (it.hasNext()) {
      final String key = (String) it.next();
      final String keyClass = config.getConfigProperty(key);
      try {
        final Class c = Class.forName(keyClass, false, classLoader);
        registerClass(c);
      } catch (ClassNotFoundException e) {
        // ignore that class
        logger.warn("Unable to register keys from " + keyClass);
      } catch (NullPointerException e) {
        // ignore invalid values as well.
        logger.warn("Unable to register keys from " + keyClass);
      }
    }
  }
コード例 #10
0
 /**
  * A private constructor so that no outsider can create a bundle.
  *
  * @param locale the locale for which to create a message bundle.
  * @param s the locale name,
  */
 private Messages(final Locale locale, final String s) {
   super(locale, s, ObjectUtilities.getClassLoader(Messages.class));
 }