Search in sources :

Example 1 with FormulaDialog

use of org.csstudio.apputil.ui.formula.FormulaDialog in project org.csstudio.display.builder by kasemir.

the class EditFormulaDialog method open.

/**
 * Open, i.e. display the dialog.
 *  @return <code>true</code> when the item was updated,
 *          <code>false</code> for 'cancel'
 */
public boolean open() {
    try {
        // Edit
        dialog = new FormulaDialog(shell, formula.getExpression(), determineInputs());
        if (dialog.open() != Window.OK)
            return false;
        // Update model item with new formula from dialog
        final Model model = formula.getModel().get();
        final ArrayList<FormulaInput> new_inputs = new ArrayList<FormulaInput>();
        for (final InputItem input : dialog.getInputs()) {
            final ModelItem item = model.getItem(input.getInputName());
            if (item == null)
                // $NON-NLS-1$
                throw new Exception("Cannot locate formula input " + input.getInputName());
            new_inputs.add(new FormulaInput(item, input.getVariableName()));
        }
        // Update formula via undo-able command
        new ChangeFormulaCommand(shell, operations_manager, formula, dialog.getFormula(), new_inputs.toArray(new FormulaInput[new_inputs.size()]));
    } catch (final Exception ex) {
        ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
        return false;
    }
    return true;
}
Also used : FormulaDialog(org.csstudio.apputil.ui.formula.FormulaDialog) InputItem(org.csstudio.apputil.ui.formula.InputItem) Model(org.csstudio.trends.databrowser3.model.Model) ArrayList(java.util.ArrayList) FormulaInput(org.csstudio.trends.databrowser3.model.FormulaInput) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem)

Aggregations

ArrayList (java.util.ArrayList)1 FormulaDialog (org.csstudio.apputil.ui.formula.FormulaDialog)1 InputItem (org.csstudio.apputil.ui.formula.InputItem)1 FormulaInput (org.csstudio.trends.databrowser3.model.FormulaInput)1 Model (org.csstudio.trends.databrowser3.model.Model)1 ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)1