use of io.jmix.ui.screen.StandardCloseAction in project jmix by jmix-framework.
the class SaveSetWindow method onInsertBtnClick.
@Subscribe("insertBtn")
protected void onInsertBtnClick(Button.ClickEvent event) {
SearchFolder folder = folderSelect.getValue();
AppUI appUI = AppUI.getCurrent();
if (appUI != null && folder == null) {
appUI.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(getMessage("saveSetWindow.notSelected")).show();
return;
}
String filterXml = folder.getFilterXml();
folder.setFilterXml(UserSetHelper.addEntities(filterXml, ids));
foldersPane.saveFolder(folder);
foldersPane.refreshFolders();
close(new StandardCloseAction(COMMIT_ACTION_ID, false));
}
use of io.jmix.ui.screen.StandardCloseAction in project jmix by jmix-framework.
the class DropLayoutTools method addComponent.
public void addComponent(DashboardLayout layout, UUID targetLayoutUuid, WidgetDropLocation location) {
DashboardLayout targetLayout = findLayout(getDashboard().getVisualModel(), targetLayoutUuid);
if (layout instanceof CssLayout) {
Screen screen = createScreen(CssLayoutCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
CssLayoutCreationDialog dialog = (CssLayoutCreationDialog) e.getSource();
CssLayout cssLayout = layoutManager.createCssLayout(dialog.getResponsive(), dialog.getCssStyleName());
reorderWidgetsAndPushEvents(cssLayout, targetLayout, location);
}
});
}
if (layout instanceof GridLayout) {
Screen screen = createScreen(GridCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
GridCreationDialog dialog = (GridCreationDialog) e.getSource();
GridLayout gridLayout = layoutManager.createGridLayout(dialog.getCols(), dialog.getRows());
reorderWidgetsAndPushEvents(gridLayout, targetLayout, location);
}
});
} else if (layout instanceof WidgetTemplateLayout) {
WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetTemplateLayout) layout).getWidget(), true);
reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
} else if (layout instanceof WidgetLayout) {
WidgetLayout widgetLayout = layoutManager.createWidgetLayout(((WidgetLayout) layout).getWidget(), false);
screenBuilders.editor(Widget.class, dashboardEdit).newEntity(widgetLayout.getWidget()).withOpenMode(OpenMode.DIALOG).build().show().addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
widgetLayout.setWidget(((WidgetEdit) e.getSource()).getEditedEntity());
reorderWidgetsAndPushEvents(widgetLayout, targetLayout, location);
}
});
} else if (layout instanceof VerticalLayout) {
reorderWidgetsAndPushEvents(metadata.create(VerticalLayout.class), targetLayout, location);
} else if (layout instanceof HorizontalLayout) {
reorderWidgetsAndPushEvents(metadata.create(HorizontalLayout.class), targetLayout, location);
} else if (layout instanceof ResponsiveLayout) {
Screen screen = createScreen(ResponsiveCreationDialog.class);
screen.addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
ResponsiveCreationDialog dialog = (ResponsiveCreationDialog) e.getSource();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
ResponsiveLayout responsiveLayout = layoutManager.createResponsiveLayout(dialog.getXs(), dialog.getSm(), dialog.getMd(), dialog.getLg());
reorderWidgetsAndPushEvents(responsiveLayout, targetLayout, location);
}
});
}
}
use of io.jmix.ui.screen.StandardCloseAction in project jmix by jmix-framework.
the class MultipleResourcePolicyModelCreateScreen method initScreenActions.
protected void initScreenActions() {
Window window = getWindow();
Messages messages = getApplicationContext().getBean(Messages.class);
Icons icons = getApplicationContext().getBean(Icons.class);
String commitShortcut = getApplicationContext().getBean(UiScreenProperties.class).getCommitShortcut();
Action commitAndCloseAction = new BaseAction(COMMIT_ACTION_ID).withCaption(messages.getMessage("actions.Ok")).withIcon(icons.get(JmixIcon.EDITOR_OK)).withPrimary(true).withShortcut(commitShortcut).withHandler(actionPerformedEvent -> {
ValidationErrors validationErrors = validateScreen();
if (!validationErrors.isEmpty()) {
screenValidation.showValidationErrors(this, validationErrors);
} else {
close(new StandardCloseAction(COMMIT_ACTION_ID));
}
});
window.addAction(commitAndCloseAction);
Action closeAction = new BaseAction(CANCEL_ACTION_ID).withIcon(icons.get(JmixIcon.EDITOR_CANCEL)).withCaption(messages.getMessage("actions.Cancel")).withHandler(actionPerformedEvent -> close(new StandardCloseAction(CANCEL_ACTION_ID)));
window.addAction(closeAction);
}
use of io.jmix.ui.screen.StandardCloseAction in project jmix by jmix-framework.
the class DialogWindowImpl method onCloseShortcutTriggered.
protected void onCloseShortcutTriggered(@SuppressWarnings("unused") Object sender, @SuppressWarnings("unused") Object target) {
if (this.isCloseable()) {
Component component = getComponent();
AppUI ui = (AppUI) component.getUI();
if (!ui.isAccessibleForUser(component)) {
LoggerFactory.getLogger(WindowImpl.class).debug("Ignore shortcut action because Window is inaccessible for user");
return;
}
BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.SHORTCUT);
fireBeforeClose(event);
if (!event.isClosePrevented()) {
getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
}
}
}
use of io.jmix.ui.screen.StandardCloseAction in project jmix by jmix-framework.
the class DialogWindowImpl method onCloseButtonClick.
protected void onCloseButtonClick(JmixWindow.PreCloseEvent preCloseEvent) {
preCloseEvent.setPreventClose(true);
Component component = getComponent();
AppUI ui = (AppUI) component.getUI();
if (!ui.isAccessibleForUser(component)) {
LoggerFactory.getLogger(WindowImpl.class).debug("Ignore close button click because Window is inaccessible for user");
return;
}
BeforeCloseEvent event = new BeforeCloseEvent(this, CloseOriginType.CLOSE_BUTTON);
fireBeforeClose(event);
if (!event.isClosePrevented()) {
// user has clicked on X
getFrameOwner().close(new StandardCloseAction(Window.CLOSE_ACTION_ID));
}
}
Aggregations