use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method isCloseWithShortcutPrevented.
protected boolean isCloseWithShortcutPrevented(Window currentWindow) {
DesktopWindow desktopWindow = (DesktopWindow) ComponentsHelper.getWindowImplementation(currentWindow);
if (desktopWindow != null) {
Window.BeforeCloseWithShortcutEvent event = new Window.BeforeCloseWithShortcutEvent(desktopWindow);
desktopWindow.fireBeforeCloseWithShortcut(event);
return event.isClosePrevented();
}
return false;
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method checkModificationsAndCloseAll.
public void checkModificationsAndCloseAll(final Runnable runIfOk, @Nullable final Runnable runIfCancel) {
boolean modified = false;
for (Window window : getOpenWindows()) {
if (!disableSavingScreenHistory) {
screenHistorySupport.saveScreenHistory(window, windowOpenMode.get(window).getOpenMode());
}
recursiveFramesClose = true;
try {
if (window instanceof WrappedWindow && ((WrappedWindow) window).getWrapper() != null) {
((WrappedWindow) window).getWrapper().saveSettings();
} else {
window.saveSettings();
}
} finally {
recursiveFramesClose = false;
}
if (window.getDsContext() != null && window.getDsContext().isModified()) {
modified = true;
}
}
disableSavingScreenHistory = true;
if (modified) {
showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("discardChangesOnClose"), MessageType.WARNING, new Action[] { new com.haulmont.cuba.gui.components.AbstractAction(messages.getMainMessage("closeApplication")) {
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
if (runIfOk != null)
runIfOk.run();
}
@Override
public String getIcon() {
return "icons/ok.png";
}
}, new com.haulmont.cuba.gui.components.AbstractAction(messages.getMainMessage("actions.Cancel"), Status.PRIMARY) {
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
if (runIfCancel != null)
runIfCancel.run();
}
@Override
public String getIcon() {
return "icons/cancel.png";
}
} });
} else {
runIfOk.run();
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindowManager method cleanupAfterModalDialogClosed.
protected void cleanupAfterModalDialogClosed(@Nullable Window closingWindow) {
WindowOpenInfo previous = null;
for (Iterator<Window> it = windowOpenMode.keySet().iterator(); it.hasNext(); ) {
Window w = it.next();
// Check if there is a modal window opened before the current
WindowOpenInfo mode = windowOpenMode.get(w);
if (w != closingWindow && mode.getOpenMode() == OpenMode.DIALOG) {
previous = mode;
}
// If there are windows opened after the current, close them
if (w == closingWindow && it.hasNext()) {
close(it.next());
break;
}
}
if (previous == null) {
frame.activate();
} else if (previous.getData() instanceof DialogWindow) {
((DialogWindow) previous.getData()).enableWindow();
} else if (previous.getData() instanceof JDialog) {
((JDialog) previous.getData()).requestFocus();
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class App method afterLoggedIn.
/**
* Perform actions after success login
*/
protected void afterLoggedIn() {
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
User user = sessionSource.getUserSession().getUser();
// Change password on logon
if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
mainFrame.deactivate("");
final DesktopWindowManager wm = mainFrame.getWindowManager();
for (Window window : wm.getOpenWindows()) {
window.setEnabled(false);
}
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
Window changePasswordWindow = wm.openWindow(changePasswordDialog, OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", false));
changePasswordWindow.addCloseListener(actionId -> {
for (Window window : wm.getOpenWindows()) {
window.setEnabled(true);
}
});
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class MenuBuilder method build.
protected void build(AppMenu appMenu, List<MenuItem> rootItems) {
this.appMenu = appMenu;
Window window = ComponentsHelper.getWindowImplementation(appMenu);
if (window == null) {
throw new IllegalStateException("AppMenu is not belong to Window");
}
for (MenuItem menuItem : rootItems) {
// AppMenu does not load top-level separators
if (menuItem.isPermitted(session) && !menuItem.isSeparator()) {
createMenuBarItem(window, menuItem);
}
}
removeExtraSeparators();
}
Aggregations