use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class ShowLinkAction method actionPerform.
@Override
public void actionPerform(io.jmix.ui.component.Component component) {
if (ds == null) {
return;
}
Messages messages = AppBeans.get(Messages.class);
Dialogs dialogs = AppUI.getCurrent().getDialogs();
dialogs.createMessageDialog().withCaption(messages.getMessage("table.showLinkAction")).withMessage(compileLink(ds)).show();
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class ScreenValidation method showUnsavedChangesDialog.
/**
* Shows standard unsaved changes dialog with Discard and Cancel actions.
*
* @param origin screen controller
* @param closeAction close action
* @return result
*/
public UnsavedChangesDialogResult showUnsavedChangesDialog(FrameOwner origin, @SuppressWarnings("unused") CloseAction closeAction) {
UnsavedChangesDialogResult result = new UnsavedChangesDialogResult();
Dialogs dialogs = getScreenContext(origin).getDialogs();
dialogs.createOptionDialog().withCaption(messages.getMessage("closeUnsaved.caption")).withMessage(messages.getMessage("closeUnsaved")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(e -> {
result.discard();
}), new DialogAction(DialogAction.Type.NO, Action.Status.PRIMARY).withHandler(e -> {
Frame frame = UiControllerUtils.getFrame(origin);
ComponentsHelper.focusChildComponent(frame);
result.cancel();
})).show();
return result;
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class FilterRemoveAction method execute.
@Override
public void execute() {
ScreenContext screenContext = ComponentsHelper.getScreenContext(filter);
Dialogs dialogs = screenContext.getDialogs();
dialogs.createOptionDialog().withCaption(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.caption")).withMessage(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.message")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(actionPerformedEvent -> filterSupport.removeCurrentFilterConfiguration(filter)), new DialogAction(DialogAction.Type.NO)).show();
}
use of io.jmix.ui.Dialogs in project jmix by jmix-framework.
the class ListPrintFormAction method actionPerform.
@Override
public void actionPerform(Component component) {
DialogAction cancelAction = new DialogAction(DialogAction.Type.CANCEL);
ScreenContext screenContext = ComponentsHelper.getScreenContext(target);
Preconditions.checkState(screenContext != null, "Component is not attached to window");
Dialogs dialogs = screenContext.getDialogs();
Set selected = target.getSelected();
if (CollectionUtils.isNotEmpty(selected)) {
if (selected.size() > 1) {
Action printSelectedAction = new AbstractAction("actions.printSelected", Status.PRIMARY) {
@Override
public void actionPerform(Component component) {
printSelected(selected);
}
};
printSelectedAction.setIcon(JmixIcon.BARS.source());
printSelectedAction.setCaption(messages.getMessage(getClass(), "actions.printSelected"));
Action printAllAction = new AbstractAction("actions.printAll") {
@Override
public void actionPerform(Component component) {
printAll();
}
};
printAllAction.setIcon(JmixIcon.TABLE.source());
printAllAction.setCaption(messages.getMessage(getClass(), "actions.printAll"));
dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintSelectedHeader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintSelected")).withActions(printAllAction, printSelectedAction, cancelAction).show();
} else {
printSelected(selected);
}
} else {
if (isDataAvailable()) {
Action yesAction = new DialogAction(DialogAction.Type.OK) {
@Override
public void actionPerform(Component component) {
printAll();
}
};
cancelAction.setPrimary(true);
dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintAllheader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintAll")).withActions(yesAction, cancelAction).show();
} else {
Notifications notifications = screenContext.getNotifications();
notifications.create().withCaption(messages.getMessage(getClass(), "notifications.noSelectedEntity")).withType(Notifications.NotificationType.HUMANIZED).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