Package org.pentaho.openformula.ui

Examples of org.pentaho.openformula.ui.FormulaEditorDialog


  protected FormulaEditorDialog createEditorDialog()
  {
    Window windowAncestor = SwingUtilities.getWindowAncestor(this);
    if (windowAncestor instanceof Dialog)
    {
      return new FormulaEditorDialog((Dialog) windowAncestor);
    }
    else if (windowAncestor instanceof Frame)
    {
      return new FormulaEditorDialog((Frame) windowAncestor);
    }
    else
    {
      return new FormulaEditorDialog();
    }
  }
View Full Code Here


     * Invoked when an action occurs.
     */
    public void actionPerformed(final ActionEvent e)
    {
      final JComboBox comboBox = getComboBox();
      final FormulaEditorDialog editorDialog = FormulaFragmentCellEditor.this.createEditorDialog();
      final String originalFormula = (String) comboBox.getSelectedItem();
      final String formula = editorDialog.editFormula(originalFormula, getFields());
      if (formula != null)
      {
        comboBox.setSelectedItem(formula);
      }
      stopCellEditing();
View Full Code Here

          comboBox.setSelectedItem(selectedGroup);
        }
      }
      else if (FORMULA_VALUE_ROLE.equals(valueRole))
      {
        final FormulaEditorDialog editorDialog =
            GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), AbstractStringValueCellEditor.this);

        final String originalFormula = (String) comboBox.getSelectedItem();
        final String formula = editorDialog.editFormula(originalFormula, getFields());
        if (formula != null)
        {
          comboBox.setSelectedItem(formula);
        }
      }
      else if (NUMBER_FORMAT_VALUE_ROLE.equals(valueRole) || DATE_FORMAT_VALUE_ROLE.equals(valueRole))
      {
        final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
        final TextAreaPropertyEditorDialog editorDialog;
        if (window instanceof Frame)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
        }
        else if (window instanceof Dialog)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
        }
        else
        {
          editorDialog = new TextAreaPropertyEditorDialog();
        }
        final String originalFormula = (String) comboBox.getSelectedItem();
        final String text = editorDialog.performEdit(originalFormula);
        if (editorDialog.isConfirmed())
        {
          comboBox.setSelectedItem(text);
        }
      }
      else
      {
        final Window window = LibSwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
        final TextAreaPropertyEditorDialog editorDialog;
        if (window instanceof Frame)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
        }
        else if (window instanceof Dialog)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
        }
        else
        {
          editorDialog = new TextAreaPropertyEditorDialog();
        }

        final JTextComponent textField = getTextField();
        final String originalValue = textField.getText();
        final String text = editorDialog.performEdit(originalValue);
        if (editorDialog.isConfirmed())
        {
          textField.setText(text);
        }
      }
View Full Code Here

    if (GraphicsEnvironment.isHeadless())
    {
      return;
    }
    ReportDesignerBoot.getInstance().start();
    final FormulaEditorDialog dialog =
        GUIUtils.createFormulaEditorDialog(new DefaultReportDesignerContext(new TestReportDesignerView()), null);
    dialog.editFormula("=AND(", new FieldDefinition[0]);
  }
View Full Code Here

      final JComboBox expressionEditor = getExpressionEditor();
      final Object selectedItem = expressionEditor.getSelectedItem();
      if (selectedItem instanceof FormulaExpression)
      {
        final FormulaExpression fe = (FormulaExpression) selectedItem;
        final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), ExpressionEditorPane.this);

        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);
      }
      else if (selectedItem instanceof Expression)
      {
        final ExpressionPropertiesDialog dialog;
        if (w instanceof Frame)
        {
          dialog = new ExpressionPropertiesDialog((Frame) w);
        }
        else if (w instanceof Dialog)
        {
          dialog = new ExpressionPropertiesDialog((Dialog) w);
        }
        else
        {
          dialog = new ExpressionPropertiesDialog();
        }
        final Expression expression = dialog.editExpression((Expression) selectedItem, reportDesignerContext);
        if (expression != selectedItem)
        {
          expressionEditor.setSelectedItem(expression);
        }
      }
      else if (selectedItem instanceof ExpressionMetaData)
      {
        try
        {
          final ExpressionMetaData emd = (ExpressionMetaData) selectedItem;
          final Expression expression = (Expression) emd.getExpressionType().newInstance();
          final ExpressionPropertiesDialog dialog;
          if (w instanceof Frame)
          {
            dialog = new ExpressionPropertiesDialog((Frame) w);
          }
          else if (w instanceof Dialog)
          {
            dialog = new ExpressionPropertiesDialog((Dialog) w);
          }
          else
          {
            dialog = new ExpressionPropertiesDialog();
          }

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

    /**
     * Invoked when an action occurs.
     */
    public void actionPerformed(final ActionEvent e)
    {
      final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), FormulaEditorPanel.this);
      final String formula = dialog.editFormula(formulaField.getText(), computeFields());
      if (formula == null)
      {
        // cancel pressed ... do nothing ...
        return;
      }
View Full Code Here

    /**
     * Invoked when an action occurs.
     */
    public void actionPerformed(final ActionEvent e)
    {
      final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), FormulaEditorPanel.this);
      final String formula = dialog.editFormula(formulaField.getText(), computeFields());
      if (formula == null)
      {
        // cancel pressed ... do nothing ...
        return;
      }
View Full Code Here

      final JComboBox expressionEditor = getExpressionEditor();
      final Object selectedItem = expressionEditor.getSelectedItem();
      if (selectedItem instanceof FormulaExpression)
      {
        final FormulaExpression fe = (FormulaExpression) selectedItem;
        final FormulaEditorDialog dialog = GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), ExpressionEditorPane.this);

        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);
      }
      else if (selectedItem instanceof Expression)
      {
        final ExpressionPropertiesDialog dialog;
        if (w instanceof Frame)
        {
          dialog = new ExpressionPropertiesDialog((Frame) w);
        }
        else if (w instanceof Dialog)
        {
          dialog = new ExpressionPropertiesDialog((Dialog) w);
        }
        else
        {
          dialog = new ExpressionPropertiesDialog();
        }
        final Expression expression = dialog.editExpression((Expression) selectedItem);
        if (expression != selectedItem)
        {
          expressionEditor.setSelectedItem(expression);
        }
      }
      else if (selectedItem instanceof ExpressionMetaData)
      {
        try
        {
          final ExpressionMetaData emd = (ExpressionMetaData) selectedItem;
          final Expression expression = (Expression) emd.getExpressionType().newInstance();
          final ExpressionPropertiesDialog dialog;
          if (w instanceof Frame)
          {
            dialog = new ExpressionPropertiesDialog((Frame) w);
          }
          else if (w instanceof Dialog)
          {
            dialog = new ExpressionPropertiesDialog((Dialog) w);
          }
          else
          {
            dialog = new ExpressionPropertiesDialog();
          }

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

          comboBox.setSelectedItem(selectedGroup);
        }
      }
      else if (FORMULA_VALUE_ROLE.equals(valueRole))
      {
        final FormulaEditorDialog editorDialog =
            GUIUtils.createFormulaEditorDialog(getReportDesignerContext(), AbstractStringValueCellEditor.this);

        final String originalFormula = (String) comboBox.getSelectedItem();
        final String formula = editorDialog.editFormula(originalFormula, getFields());
        if (formula != null)
        {
          comboBox.setSelectedItem(formula);
        }
      }
      else if (NUMBER_FORMAT_VALUE_ROLE.equals(valueRole) || DATE_FORMAT_VALUE_ROLE.equals(valueRole))
      {
        final Window window = SwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
        final TextAreaPropertyEditorDialog editorDialog;
        if (window instanceof Frame)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
        }
        else if (window instanceof Dialog)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
        }
        else
        {
          editorDialog = new TextAreaPropertyEditorDialog();
        }
        final String originalFormula = (String) comboBox.getSelectedItem();
        final String text = editorDialog.performEdit(originalFormula);
        if (editorDialog.isConfirmed())
        {
          comboBox.setSelectedItem(text);
        }
      }
      else
      {
        final Window window = SwingUtil.getWindowAncestor(AbstractStringValueCellEditor.this);
        final TextAreaPropertyEditorDialog editorDialog;
        if (window instanceof Frame)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Frame) window);
        }
        else if (window instanceof Dialog)
        {
          editorDialog = new TextAreaPropertyEditorDialog((Dialog) window);
        }
        else
        {
          editorDialog = new TextAreaPropertyEditorDialog();
        }

        final JTextComponent textField = getTextField();
        final String originalValue = textField.getText();
        final String text = editorDialog.performEdit(originalValue);
        if (editorDialog.isConfirmed())
        {
          textField.setText(text);
        }
      }
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;
        }
View Full Code Here

TOP

Related Classes of org.pentaho.openformula.ui.FormulaEditorDialog

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.