use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class UrlChangeHandler method restoreState.
public void restoreState() {
if (notSuitableMode()) {
log.debug("UrlChangeHandler is disabled for '{}' URL handling mode", webConfig.getUrlHandlingMode());
return;
}
NavigationState currentState = urlTools.parseState(ui.getPage().getUriFragment());
if (currentState == null || currentState == NavigationState.EMPTY) {
RootWindow topLevelWindow = ui.getTopLevelWindow();
if (topLevelWindow instanceof WebWindow) {
NavigationState topScreenState = ((WebWindow) topLevelWindow).getResolvedState();
urlTools.replaceState(topScreenState.asRoute(), ui);
}
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WindowBreadCrumbs method isCloseWithCloseButtonPrevented.
protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
WebWindow webWindow = (WebWindow) currentWindow;
if (webWindow != null) {
Window.BeforeCloseEvent event = new Window.BeforeCloseEvent(webWindow, CloseOriginType.CLOSE_BUTTON);
webWindow.fireBeforeClose(event);
return event.isClosePrevented();
}
return false;
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method moveFocus.
protected void moveFocus(TabSheetBehaviour tabSheet, String tabId) {
// noinspection SuspiciousMethodCalls
Window window = tabs.get(tabSheet.getTabComponent(tabId)).getCurrentWindow();
if (window != null) {
boolean focused = false;
String focusComponentId = window.getFocusComponent();
if (focusComponentId != null) {
com.haulmont.cuba.gui.components.Component focusComponent = window.getComponent(focusComponentId);
if (focusComponent != null && focusComponent.isEnabled() && focusComponent.isVisible()) {
focusComponent.requestFocus();
focused = true;
}
}
if (!focused && window instanceof Window.Wrapper) {
Window.Wrapper wrapper = (Window.Wrapper) window;
focused = ((WebWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
if (!focused) {
tabSheet.focus();
}
}
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method setWindowCaption.
@Override
public void setWindowCaption(Window window, String caption, String description) {
Window webWindow = window;
if (window instanceof Window.Wrapper) {
webWindow = ((Window.Wrapper) window).getWrappedWindow();
}
window.setCaption(caption);
window.setDebugId(description);
WindowOpenInfo openInfo = windowOpenMode.get(webWindow);
String formattedCaption;
if (openInfo != null && (openInfo.getOpenMode() == OpenMode.NEW_TAB || openInfo.getOpenMode() == OpenMode.NEW_WINDOW || openInfo.getOpenMode() == OpenMode.THIS_TAB)) {
formattedCaption = formatTabCaption(caption, description);
} else {
formattedCaption = formatTabDescription(caption, description);
}
if (openInfo != null) {
if (openInfo.getOpenMode() == OpenMode.DIALOG) {
com.vaadin.ui.Window dialog = (com.vaadin.ui.Window) openInfo.getData();
dialog.setCaption(formattedCaption);
} else {
if (getConfiguredWorkArea(createWorkAreaContext(window)).getMode() == Mode.SINGLE) {
return;
}
Component tabContent = (Component) openInfo.getData();
if (tabContent == null) {
return;
}
TabSheetBehaviour tabSheet = getConfiguredWorkArea(createWorkAreaContext(window)).getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(tabContent);
if (tabId == null) {
return;
}
tabSheet.setTabCaption(tabId, formattedCaption);
String formattedDescription = formatTabDescription(caption, description);
if (!Objects.equals(formattedDescription, formattedCaption)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
}
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method closeAllTabbedWindowsExcept.
public void closeAllTabbedWindowsExcept(@Nullable ComponentContainer keepOpened) {
boolean modified = false;
List<WebWindow> windowsToClose = new ArrayList<>();
WindowBreadCrumbs keepOpenedCrumbs = tabs.get(keepOpened);
Frame keepOpenedFrame = keepOpenedCrumbs != null ? keepOpenedCrumbs.getCurrentWindow().getFrame() : null;
for (Window window : getOpenWindows()) {
if (!canWindowBeClosed(window)) {
continue;
}
OpenMode openMode = windowOpenMode.get(window).getOpenMode();
WindowBreadCrumbs windowBreadCrumbs = tabs.get(windowOpenMode.get(window).getData());
Window currentWindow = (windowBreadCrumbs != null && window != windowBreadCrumbs.getCurrentWindow()) ? windowBreadCrumbs.getCurrentWindow() : window;
if (window.getFrame() == keepOpenedFrame || openMode == OpenMode.DIALOG || keepOpenedCrumbs == windowBreadCrumbs || isCloseWithCloseButtonPrevented(currentWindow))
continue;
if (window.getDsContext() != null && window.getDsContext().isModified()) {
modified = true;
}
windowsToClose.add((WebWindow) window);
}
disableSavingScreenHistory = true;
if (modified) {
showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("discardChangesInTabs"), MessageType.WARNING, new Action[] { new AbstractAction(messages.getMainMessage("closeTabs")) {
{
icon = icons.get(CubaIcon.DIALOG_OK);
}
@Override
public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
closeTabsForce(windowsToClose);
}
}, new DialogAction(Type.CANCEL, Status.PRIMARY) });
} else {
closeTabsForce(windowsToClose);
}
}
Aggregations