use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class ShowPivotAction method execute.
private void execute() {
if (target == null) {
throw new IllegalStateException("ShowPivotAction target is not set");
}
if (needShowAll()) {
showPivotTable(ShowPivotMode.ALL_ROWS);
} else {
Action[] actions = new Action[] { new BaseAction("actions.showPivotAction.SELECTED_ROWS").withCaption(messages.getMessage("actions.showPivotAction.SELECTED_ROWS")).withPrimary(true).withHandler(event -> showPivotTable(ShowPivotMode.SELECTED_ROWS)), new BaseAction("actions.showPivotAction.ALL_ROWS").withCaption(messages.getMessage("actions.showPivotAction.ALL_ROWS")).withHandler(event -> showPivotTable(ShowPivotMode.ALL_ROWS)), new DialogAction(DialogAction.Type.CANCEL) };
Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();
dialogs.createOptionDialog().withCaption(messages.getMessage("actions.showPivotAction.dialogTitle")).withMessage(messages.getMessage("actions.showPivotAction.dialogMessage")).withActions(actions).show();
}
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class ExportAction method execute.
protected void execute() {
if (tableExporter == null) {
throw new IllegalStateException("Table exporter is not defined");
}
if (needExportAll()) {
doExport(ExportMode.ALL);
} else {
AbstractAction exportSelectedAction = new AbstractAction("actions.export.SELECTED_ROWS", Status.PRIMARY) {
@Override
public void actionPerform(Component component) {
doExport(ExportMode.SELECTED);
}
};
exportSelectedAction.setCaption(getMessage(exportSelectedAction.getId()));
AbstractAction exportAllAction = new AbstractAction("actions.export.ALL_ROWS") {
@Override
public void actionPerform(Component component) {
doExport(ExportMode.ALL);
}
};
exportAllAction.setCaption(getMessage(exportAllAction.getId()));
Action[] actions = new Action[] { exportSelectedAction, exportAllAction, new DialogAction(DialogAction.Type.CANCEL) };
Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();
dialogs.createOptionDialog().withCaption(getMessage("actions.exportSelectedTitle")).withMessage(getMessage("actions.exportSelectedCaption")).withActions(actions).show();
}
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class LocalizedTaskWrapper method showExecutionError.
protected void showExecutionError(Exception ex) {
Screen ownerFrame = wrappedTask.getOwnerScreen();
if (ownerFrame != null) {
Dialogs dialogs = getScreenContext().getDialogs();
dialogs.createExceptionDialog().withThrowable(ex).withCaption(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.executionError")).withMessage(ex.getLocalizedMessage()).show();
}
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class RemoveAction method confirmAndRemove.
protected void confirmAndRemove(Set<Entity> selected) {
Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs();
dialogs.createOptionDialog().withCaption(getConfirmationTitle()).withMessage(getConfirmationMessage()).withActions(new DialogAction(DialogAction.Type.OK, Status.PRIMARY).withHandler(event -> {
try {
remove(selected);
} finally {
if (target instanceof Component.Focusable) {
((Component.Focusable) target).focus();
}
Set<Entity> filtered = new HashSet<>(selected);
filtered.retainAll(target.getDatasource().getItems());
// noinspection unchecked
target.setSelected(filtered);
}
}), new DialogAction(DialogAction.Type.CANCEL).withHandler(event -> {
// move focus to owner
if (target instanceof Component.Focusable) {
((Component.Focusable) target).focus();
}
})).show();
}
Aggregations