use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class SideMenuBuilder method build.
protected void build(SideMenu menu, List<MenuItem> rootItems) {
Window window = ComponentsHelper.getWindowImplementation(menu);
if (window == null) {
throw new IllegalStateException("SideMenu is not belong to Window");
}
for (MenuItem menuItem : rootItems) {
// AppMenu does not support separators
if (menuItem.isPermitted(session) && !menuItem.isSeparator()) {
createMenuBarItem(window, menu, menuItem);
}
}
removeExtraSeparators(menu);
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class MainTabSheetActionHandler method analyzeLayout.
protected void analyzeLayout(Object target) {
Window window = findWindow((Layout) target);
if (window != null) {
LayoutAnalyzer analyzer = new LayoutAnalyzer();
List<LayoutTip> tipsList = analyzer.analyze(window);
if (tipsList.isEmpty()) {
window.showNotification("No layout problems found", Frame.NotificationType.HUMANIZED);
} else {
window.openWindow("layoutAnalyzer", WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
}
}
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebWindowManager method createCloseShortcut.
public ShortcutListener createCloseShortcut(Window.TopLevelWindow topLevelWindow) {
String closeShortcut = clientConfig.getCloseShortcut();
KeyCombination combination = KeyCombination.create(closeShortcut);
return new ShortcutListener("onClose", combination.getKey().getCode(), KeyCombination.Modifier.codes(combination.getModifiers())) {
@Override
public void handleAction(Object sender, Object target) {
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(topLevelWindow));
if (workArea.getState() != AppWorkArea.State.WINDOW_CONTAINER) {
return;
}
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
if (tabSheet != null) {
Layout layout = (Layout) tabSheet.getSelectedTab();
if (layout != null) {
tabSheet.focus();
WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (!canWindowBeClosed(breadCrumbs.getCurrentWindow())) {
return;
}
if (isCloseWithShortcutPrevented(breadCrumbs.getCurrentWindow())) {
return;
}
if (stacks.get(breadCrumbs).empty()) {
final Component previousTab = tabSheet.getPreviousTab(layout);
if (previousTab != null) {
breadCrumbs.getCurrentWindow().closeAndRun(Window.CLOSE_ACTION_ID, () -> tabSheet.setSelectedTab(previousTab));
} else {
breadCrumbs.getCurrentWindow().close(Window.CLOSE_ACTION_ID);
}
} else {
breadCrumbs.getCurrentWindow().close(Window.CLOSE_ACTION_ID);
}
}
}
} else {
Iterator<WindowBreadCrumbs> it = tabs.values().iterator();
if (it.hasNext()) {
Window currentWindow = it.next().getCurrentWindow();
if (!isCloseWithShortcutPrevented(currentWindow)) {
ui.focus();
currentWindow.close(Window.CLOSE_ACTION_ID);
}
}
}
}
};
}
use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.
the class WebWindowManager method showWindowNewTab.
protected Component showWindowNewTab(final Window window, final boolean multipleOpen) {
getDialogParams().reset();
final WindowBreadCrumbs breadCrumbs = createWindowBreadCrumbs(window);
breadCrumbs.addListener(new WindowBreadCrumbs.Listener() {
@Override
public void windowClick(final Window window) {
Runnable op = new Runnable() {
@Override
public void run() {
Window currentWindow = breadCrumbs.getCurrentWindow();
if (currentWindow != null && window != currentWindow) {
if (!isCloseWithCloseButtonPrevented(currentWindow)) {
currentWindow.closeAndRun(Window.CLOSE_ACTION_ID, this);
}
}
}
};
op.run();
}
});
breadCrumbs.addWindow(window);
// noinspection UnnecessaryLocalVariable
final Layout layout = createNewTabLayout(window, multipleOpen, breadCrumbs);
return layout;
}
use of com.haulmont.cuba.gui.components.Window 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();
}
}
}
}
Aggregations