private static final long serialVersionUID = 1L;
private void openFieldCalculationDialog(final AjaxLink<Void> ajaxLink, AjaxRequestTarget target) {
ModalWindow modal = ajaxLink.findParent(PivotAreaPanel.class).getModal();
modal.setTitle("Calculation");
final FieldCalculationPanel panel = new FieldCalculationPanel(modal.getContentId(), Model.of(field),
Model.of(pivotModel));
panel.setTitle(field.getTitle());
panel.add(AttributeModifier.append("style", "padding: 10px;"));
modal.setContent(panel);
modal.setAutoSize(true);
modal.setResizable(false);
modal.show(target);
modal.setWindowClosedCallback(new WindowClosedCallback() {
private static final long serialVersionUID = 1L;
@Override
public void onClose(AjaxRequestTarget target) {
if (!panel.isOkPressed()) {
return;
}
target.add(ajaxLink.findParent(PivotAreaPanel.class));
PivotModel pivotModel = getPivotModel(ajaxLink);
PivotField pivotField = pivotModel.getField(field.getName());
pivotField.setFieldCalculation(panel.getFieldCalculation());
pivotField.setTitle(panel.getTitle());
if (pivotModel.isAutoCalculate()) {
ajaxLink.findParent(PivotPanel.class).compute(target);
}
}
});