Package org.pentaho.reporting.libraries.formula.function

Examples of org.pentaho.reporting.libraries.formula.function.FunctionDescription


    final FunctionRegistry functionRegistry = context.getFunctionRegistry();
    final String[] names = functionRegistry.getFunctionNames();
    for (int i = 0; i < names.length; i++)
    {
      final String name = names[i];
      final FunctionDescription data = functionRegistry.getMetaData(name);
      try
      {
        assertNotNull(data.getCategory());
        assertNotNull(data.getDescription(Locale.ENGLISH));
        assertNotNull(data.getDisplayName(Locale.ENGLISH));
        assertNotNull(data.getValueType());
        final int count = data.getParameterCount();
        for (int x = 0; x < count; x++)
        {
          assertNotNull(data.getParameterType(x));
          assertNotNull(data.getParameterDescription(x, Locale.ENGLISH));
          assertNotNull(data.getParameterDisplayName(x, Locale.ENGLISH));
        }
      }
      catch (Throwable t)
      {
        System.out.println("Failed at " + name);
View Full Code Here


        return nStartPos;
    }

    public XFunctionDescription getFunctionByName(String arg0) throws NoSuchElementException
    {
        final FunctionDescription func = functionRegistry.getMetaData(arg0);
        if ( func == null )
            throw new NoSuchElementException();
        int i = 0;
        for (; i < categories.length; i++)
        {
            if ( categories[i] == func.getCategory() )
                break;
        }
        try
        {
            return new StarFunctionDescription(defaultContext, m_xContext, getCategory(i), functionRegistry, func);
View Full Code Here

  }

  @Override
  public void setSelectedFunction(final FunctionParameterContext context)
  {
    final FunctionDescription fnDesc = context.getFunction();
    final int functionStart = context.getFunctionInformation().getFunctionOffset();

    // Ensure that the parameter field editor has been initialized. This can
    // happen if user manually types in the whole formula in text-area.
    final boolean switchParameterEditor;
    if (this.selectedFunction == null)
    {
      switchParameterEditor = true;
      context.setSwitchParameterEditor(true);
    }
    else
    {
      switchParameterEditor = context.isSwitchParameterEditor();
    }

    this.selectedFunction = fnDesc;
    this.functionStartIndex = functionStart;

    final String name = fnDesc.getCanonicalName();
    if ((activeEditor != null) && (switchParameterEditor == true))
    {
      activeEditor.removeParameterUpdateListener(parameterUpdateHandler);
    }
View Full Code Here

   * @param context
   * @return
   */
  private boolean updateCurrentParameterField(final FunctionParameterContext context)
  {
    final FunctionDescription selectedFunction = context.getFunction();
    final String[] parameterValues = context.getParameterValues();

    // Iterate over each parameter field looking to find the field associated with
    // the embedded formula.  If we find it, build up the formula in parameter field
    // to reflect what was typed into the formula text-area
    for (int i = 0; i < textFields.length; i++)
    {
      final String parameterValue = textFields[i].getText();
      if ((parameterValue != null) && (parameterValue.startsWith(selectedFunction.getCanonicalName()) == true))
      {
        String updatedFormula = selectedFunction.getCanonicalName() + "(";
        for (int paramIndex = 0; paramIndex < parameterValues.length; paramIndex++)
        {
          if (parameterValues[paramIndex] != null)
          {
            updatedFormula = updatedFormula + parameterValues[paramIndex];
View Full Code Here

  {
    try
    {
      inSetupUpdate = true;

      final FunctionDescription fnDesc = context.getFunction();

      //this is empty function?
      if (fnDesc == null)
      {
        for (int i = 0; i < textFields.length; i++)
View Full Code Here

    if (fnInfo == null)
    {
      functionParameterEditor.clearSelectedFunction();
      return;
    }
    final FunctionDescription fnDesc = formulaContext.getFunctionRegistry().getMetaData(fnInfo.getCanonicalName());
    if (fnDesc == null)
    {
      functionParameterEditor.clearSelectedFunction();
      return;
    }
View Full Code Here

  private void refreshInformationPanel()
  {
    final FunctionInformation currentFunction = editorModel.getCurrentFunction();

    final FunctionDescription description;
    if (currentFunction != null)
    {
      description = formulaContext.getFunctionRegistry().getMetaData(currentFunction.getCanonicalName());
    }
    else
View Full Code Here

     *
     * @noinspection MagicCharacter
     */
    public void actionPerformed(final ActionEvent e)
    {
      final FunctionDescription selectedFunction = functionSelectorPanel.getSelectedValue();
      final StringBuilder b = new StringBuilder(100);
      b.append(selectedFunction.getCanonicalName());
      b.append('(');

      final int count;
      if (selectedFunction.isInfiniteParameterCount())
      {
        count = Math.min(1, selectedFunction.getParameterCount());
      }
      else
      {
        count = selectedFunction.getParameterCount();
      }
      for (int i = 0; i < count; i++)
      {
        if (i > 0)
        {
          b.append(";");
        }
        final Type type = selectedFunction.getParameterType(i);
        b.append(TypeUtil.getParameterType(type, getLocale()));
      }
      b.append(')');

      try
View Full Code Here

    return selectedValue;
  }

  public void setSelectedValue(final FunctionDescription selectedValue)
  {
    final FunctionDescription old = this.selectedValue;
    this.selectedValue = selectedValue;
    firePropertyChange("selectedValue", old, selectedValue); // NON-NLS
  }
View Full Code Here

                                                final boolean cellHasFocus)
  {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (value instanceof FunctionDescription)
    {
      final FunctionDescription cat = (FunctionDescription) value;
      setText(cat.getDisplayName(Locale.getDefault()));
      setToolTipText(cat.getDescription(Locale.getDefault()));
    }
    else
    {
      setText(" "); // NON-NLS
      setToolTipText(null);
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.formula.function.FunctionDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.