Package org.pentaho.reporting.engine.classic.core.function

Examples of org.pentaho.reporting.engine.classic.core.function.FormulaExpression


  private String computeFormula(final Expression expression, final String staticValue)
  {
    if (expression instanceof FormulaExpression)
    {
      final FormulaExpression formulaExpression = (FormulaExpression) expression;
      return formulaExpression.getFormula();
    }
    if (expression == null &&
        StringUtils.isEmpty(staticValue) == false)
    {
      return '=' + FormulaUtil.quoteString(staticValue);
View Full Code Here


    }

    final String formulaText = drillDownEditor.getDrillDownFormula();
    if (StringUtils.isEmpty(formulaText) == false)
    {
      final FormulaExpression formulaExpression = new FormulaExpression();
      formulaExpression.setFormula(formulaText);
      styleSheet.setStyleProperty(ElementStyleKeys.HREF_TARGET, null);
      styleExpressions.put(ElementStyleKeys.HREF_TARGET, formulaExpression);
    }
    else
    {
      styleExpressions.put(ElementStyleKeys.HREF_TARGET, null);
      styleSheet.setStyleProperty(ElementStyleKeys.HREF_TARGET, null);
    }

    final String targetText = drillDownEditor.getTargetFormula();
    if (StringUtils.isEmpty(targetText) == false)
    {
      final String staticText = FormulaUtil.extractStaticTextFromFormula(targetText);
      if (staticText != null)
      {
        styleSheet.setStyleProperty(ElementStyleKeys.HREF_WINDOW, staticText);
        styleExpressions.put(ElementStyleKeys.HREF_WINDOW, null);
      }
      else
      {
        final FormulaExpression formulaExpression = new FormulaExpression();
        formulaExpression.setFormula(targetText);
        styleSheet.setStyleProperty(ElementStyleKeys.HREF_WINDOW, null);
        styleExpressions.put(ElementStyleKeys.HREF_WINDOW, formulaExpression);
      }
    }
    else
    {
      styleSheet.setStyleProperty(ElementStyleKeys.HREF_WINDOW, null);
      styleExpressions.put(ElementStyleKeys.HREF_WINDOW, null);
    }

    final String tooltipText = drillDownEditor.getTooltipFormula();
    if (StringUtils.isEmpty(tooltipText) == false)
    {
      final String staticText = FormulaUtil.extractStaticTextFromFormula(tooltipText);
      if (staticText != null)
      {
        styleSheet.setStyleProperty(ElementStyleKeys.HREF_TITLE, staticText);
        styleExpressions.put(ElementStyleKeys.HREF_TITLE, null);
      }
      else
      {
        final FormulaExpression formulaExpression = new FormulaExpression();
        formulaExpression.setFormula(tooltipText);
        styleSheet.setStyleProperty(ElementStyleKeys.HREF_TITLE, null);
        styleExpressions.put(ElementStyleKeys.HREF_TITLE, formulaExpression);
      }
    }
    else
View Full Code Here

    if (!(expression instanceof FormulaExpression))
    {
      return;
    }

    final FormulaExpression fe = (FormulaExpression) expression;
    final String s = fe.getFormula();
    if (StringUtils.isEmpty(s, true))
    {
      final AttributeMetaData attrMeta =
          element.getMetaData().getAttributeDescription(attributeNamespace, attributeName);
      if (attrMeta != null)
View Full Code Here

    if (expression instanceof FormulaExpression == false)
    {
      return;
    }
    final FormulaExpression fe = (FormulaExpression) expression;
    final String s = fe.getFormula();
    if (StringUtils.isEmpty(s, true))
    {
      final StyleMetaData description = element.getMetaData().getStyleDescription(styleKey);
      if (description == null)
      {
View Full Code Here

   */
  public void setItem(final Object anObject)
  {
    if (anObject instanceof FormulaExpression)
    {
      final FormulaExpression fe = (FormulaExpression) anObject;
      this.value = fe;
      this.textField.setEnabled(true);
      this.textField.setText(fe.getFormula());
    }
    else if (anObject instanceof Expression)
    {
      this.value = anObject;
      this.textField.setEnabled(false);
      if (ExpressionRegistry.getInstance().isExpressionRegistered(value.getClass().getName()))
      {
        final ExpressionMetaData data =
            ExpressionRegistry.getInstance().getExpressionMetaData(value.getClass().getName());
        this.textField.setText(data.getDisplayName(Locale.getDefault()));
      }
      else
      {
        this.textField.setText(value.getClass().getName());
      }
    }
    else if (anObject instanceof ExpressionMetaData)
    {
      final ExpressionMetaData emd = (ExpressionMetaData) anObject;
      this.value = anObject;
      this.textField.setEnabled(false);
      this.textField.setText(emd.getDisplayName(Locale.getDefault()));
    }
    else if (anObject != null)
    {
      DebugLog.log("ExpressionComboBoxEditor: Invalid object encountered: " + anObject); // NON-NLS
      this.value = null;
      this.textField.setEnabled(false);
      this.textField.setText("");
    }
    else
    {
      this.value = new FormulaExpression();
      this.textField.setEnabled(true);
      this.textField.setText("");
    }

    this.orginalText = this.textField.getText();
View Full Code Here

      }
      if (ObjectUtilities.equal(orginalText, editorText))
      {
        return value;
      }
      final FormulaExpression ofe = (FormulaExpression) value;
      final FormulaExpression fe = (FormulaExpression) ofe.getInstance();
      fe.setFormula(editorText);
      return fe;
    }
    return value;
  }
View Full Code Here

    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    setText(" ");
    setToolTipText(null);
    if (value instanceof FormulaExpression)
    {
      final FormulaExpression fx = (FormulaExpression) value;
      setText(fx.getFormula());
    }
    else if (value != null)
    {
      final ExpressionRegistry registry = ExpressionRegistry.getInstance();
      final String expressionName = value.getClass().getName();
View Full Code Here

    {
      final Window window = SwingUtil.getWindowAncestor(carrierPanel);
      final Object selectedItem = expressionEditor.getSelectedItem();
      if (selectedItem instanceof FormulaExpression)
      {
        final FormulaExpression fe = (FormulaExpression) selectedItem;
        final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), carrierPanel);
        final String formula = dialog.editFormula(fe.getFormula(), getFields());
        if (formula == null)
        {
          // cancel pressed ... do nothing ...
          return;
        }

        final FormulaExpression derived = (FormulaExpression) fe.getInstance();
        derived.setFormula(formula);
        expressionEditor.setSelectedItem(derived);
        fireEditingStopped();
      }
      else if (selectedItem instanceof Expression)
      {
        final ExpressionPropertiesDialog optionPane;
        if (window instanceof JFrame)
        {
          optionPane = new ExpressionPropertiesDialog((JFrame) window);
        }
        else if (window instanceof JDialog)
        {
          optionPane = new ExpressionPropertiesDialog((JDialog) window);
        }
        else
        {
          optionPane = new ExpressionPropertiesDialog();
        }
        final Expression expression = optionPane.editExpression((Expression) selectedItem);
        if (expression != selectedItem)
        {
          expressionEditor.setSelectedItem(expression);
          fireEditingStopped();
        }
      }
      else if (selectedItem instanceof ExpressionMetaData)
      {
        try
        {
          final ExpressionMetaData emd = (ExpressionMetaData) selectedItem;
          final Expression expression = (Expression) emd.getExpressionType().newInstance();

          final ExpressionPropertiesDialog optionPane;
          if (window instanceof JFrame)
          {
            optionPane = new ExpressionPropertiesDialog((JFrame) window);
          }
          else if (window instanceof JDialog)
          {
            optionPane = new ExpressionPropertiesDialog((JDialog) window);
          }
          else
          {
            optionPane = new ExpressionPropertiesDialog();
          }

          final Expression resultexpression = optionPane.editExpression(expression);
          if (resultexpression != expression)
          {
            expressionEditor.setSelectedItem(resultexpression);
            fireEditingStopped();
          }
        }
        catch (Throwable e1)
        {
          UncaughtExceptionsModel.getInstance().addException(e1);
        }
      }
      else
      {
        // assume that we want to edit a formula ..
        final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), carrierPanel);
        final String formula = dialog.editFormula(null, getFields());
        if (formula == null)
        {
          // cancel pressed ... do nothing ...
          return;
        }

        final FormulaExpression derived = new FormulaExpression();
        derived.setFormula(formula);
        expressionEditor.setSelectedItem(derived);
        fireEditingStopped();
      }
    }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.function.FormulaExpression

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.