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;
}
Aggregations