use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopTree method handleClickAction.
protected void handleClickAction() {
Action action = getItemClickAction();
if (action == null) {
action = getEnterPressAction();
if (action == null) {
action = getAction("edit");
if (action == null) {
action = getAction("view");
}
}
}
if (action != null && action.isEnabled()) {
Window window = ComponentsHelper.getWindowImplementation(DesktopTree.this);
if (window instanceof Window.Wrapper) {
window = ((Window.Wrapper) window).getWrappedWindow();
}
if (!(window instanceof Window.Lookup)) {
action.actionPerform(DesktopTree.this);
} else {
Window.Lookup lookup = (Window.Lookup) window;
com.haulmont.cuba.gui.components.Component lookupComponent = lookup.getLookupComponent();
if (lookupComponent != this)
action.actionPerform(DesktopTree.this);
else if (action.getId().equals(WindowDelegate.LOOKUP_ITEM_CLICK_ACTION_ID)) {
action.actionPerform(DesktopTree.this);
}
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class DesktopWindow method close.
@Override
public boolean close(final String actionId) {
if (!forceClose) {
if (!delegate.preClose(actionId))
return false;
}
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (!forceClose && isModified()) {
final Committable committable = (getWrapper() instanceof Committable) ? (Committable) getWrapper() : (this instanceof Committable) ? (Committable) this : null;
if ((committable != null) && clientConfig.getUseSaveConfirmation()) {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("saveUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.OK, Status.PRIMARY).withCaption(messages.getMainMessage("closeUnsaved.save")).withHandler(event -> {
committable.commitAndClose();
}), new BaseAction("discard").withIcon("icons/cancel.png").withCaption(messages.getMainMessage("closeUnsaved.discard")).withHandler(event -> {
committable.close(actionId, true);
}), new DialogAction(Type.CANCEL).withIcon(null).withHandler(event -> {
doAfterClose = null;
}) });
} else {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.YES).withHandler(event -> {
getWrapper().close(actionId, true);
}), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> {
doAfterClose = null;
}) });
}
return false;
}
if (!clientConfig.getManualScreenSettingsSaving()) {
if (delegate.getWrapper() != null) {
delegate.getWrapper().saveSettings();
} else {
saveSettings();
}
}
delegate.disposeComponents();
windowManager.close(this);
boolean res = onClose(actionId);
if (res && doAfterClose != null) {
doAfterClose.run();
}
stopTimers();
userActionsLog.trace("Window {} was closed", getId());
return res;
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebWindowManager method checkModificationsAndCloseAll.
/**
* Check modifications and close all screens in all main windows.
*
* @param runIfOk a closure to run after all screens are closed
* @param runIfCancel a closure to run if there were modifications and a user canceled the operation
*/
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());
}
if (window instanceof WrappedWindow && ((WrappedWindow) window).getWrapper() != null) {
((WrappedWindow) window).getWrapper().saveSettings();
} else {
window.saveSettings();
}
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 BaseAction("closeApplication").withCaption(messages.getMainMessage("closeApplication")).withIcon(icons.get(CubaIcon.DIALOG_OK)).withHandler(event -> {
closeAllWindows();
runIfOk.run();
}), new DialogAction(Type.CANCEL, Status.PRIMARY).withHandler(event -> {
if (runIfCancel != null) {
runIfCancel.run();
}
}) });
} else {
closeAllWindows();
runIfOk.run();
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class ChangePasswordAfterLoginListener method onApplicationEvent.
@Override
public void onApplicationEvent(AppLoggedInEvent event) {
App app = event.getApp();
Connection connection = app.getConnection();
if (connection.isAuthenticated() && !isLoggedInWithExternalAuth(connection.getSessionNN())) {
User user = connection.getSessionNN().getUser();
// Change password on logon
if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
WebWindowManager wm = app.getWindowManager();
for (Window window : wm.getOpenWindows()) {
window.setEnabled(false);
}
WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
Window changePasswordWindow = wm.openWindow(changePasswordDialog, WindowManager.OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", Boolean.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 WindowBreadCrumbs method isCloseWithCloseButtonPrevented.
protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
WebWindow webWindow = (WebWindow) ComponentsHelper.getWindowImplementation(currentWindow);
if (webWindow != null) {
Window.BeforeCloseWithCloseButtonEvent event = new Window.BeforeCloseWithCloseButtonEvent(webWindow);
webWindow.fireBeforeCloseWithCloseButton(event);
return event.isClosePrevented();
}
return false;
}
Aggregations