}
private OverlayDecorator createOverlay() {
BorderLayoutBuilder cp = new BorderLayoutBuilder(getUi());
cp.withEmptyBorder(10, 10, 10, 10);
OverlayDecorator overlay = new OverlayDecorator(cp, getSuggestedTitle()) {
@Override
protected void onCancel() {
handleCancel();
}
@Override
protected void onHidden() {
undoRedo.dispose();
visible = false;
}
@Override
protected void onDisplayed() {
installUndoRedo();
}
private void installUndoRedo() {
// TODO(?): Hook into the page's undo-redo system? If we do that we must
// remember to clear all edits originating from the formula builder when
// the formula builder is closed.
TextUndoRedoControllerFactory f = UndoRedoControllers.textFactory();
undoRedo = f.newController(getUi().getExpressionArea().getTextPane());
undoRedo.alwaysConsumeKeyboardTriggers();
}
};
overlay.setFillOut();
overlay.setTitleStyle(TextStyles.DefaultBold);
Action okAction = new OkAction();
overlay.setOkAction(okAction);
JComponent buttons = createOverlayButtons(overlay, okAction);
getUi().setButtonPanel(buttons);
overlay.setOkAsDefault(true);
overlay.setBlocking(true);
overlay.setFocusReceiverWhenClosed(getTreeMapper());
installShortcuts(overlay);
return overlay;
}