Search in sources :

Example 6 with TopLevelFrame

use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.

the class DesktopWindow method setDescription.

@Override
public void setDescription(String description) {
    this.description = description;
    DialogWindow dialogWindow = asDialogWindow();
    if (dialogWindow != null) {
        dialogWindow.setTitle(caption);
    } else {
        JPanel tabWindow = asTabWindow();
        if (tabWindow != null) {
            setTabCaptionAndDescription(tabWindow);
        } else {
            JPanel singleWindow = asDetachedWindow();
            if (singleWindow != null) {
                TopLevelFrame topLevelFrame = asTopLevelFrame();
                if (topLevelFrame != null) {
                    topLevelFrame.setTitle(formatTabCaption(caption, description));
                }
            }
        }
    }
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) DialogWindow(com.haulmont.cuba.desktop.sys.DialogWindow)

Example 7 with TopLevelFrame

use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.

the class DesktopWindow method setCaption.

@Override
public void setCaption(String caption) {
    this.caption = caption;
    DialogWindow dialogWindow = asDialogWindow();
    if (dialogWindow != null) {
        dialogWindow.setTitle(caption);
    } else {
        JPanel tabWindow = asTabWindow();
        if (tabWindow != null) {
            setTabCaptionAndDescription(tabWindow);
        } else {
            JPanel singleWindow = asDetachedWindow();
            if (singleWindow != null) {
                TopLevelFrame topLevelFrame = asTopLevelFrame();
                if (topLevelFrame != null) {
                    topLevelFrame.setTitle(formatTabCaption(caption, description));
                }
                windowManager.getBreadCrumbs(singleWindow).update();
            }
        }
    }
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) DialogWindow(com.haulmont.cuba.desktop.sys.DialogWindow)

Example 8 with TopLevelFrame

use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.

the class DesktopWindowManager method showNewWindow.

protected JComponent showNewWindow(Window window, OpenType openType, String caption) {
    window.setHeight("100%");
    window.setWidth("100%");
    TopLevelFrame windowFrame = createTopLevelFrame(caption);
    windowFrame.setName(window.getId());
    Dimension dimension = new Dimension();
    dimension.width = 800;
    if (openType.getWidth() != null) {
        dimension.width = openType.getWidth().intValue();
    }
    dimension.height = 500;
    if (openType.getHeight() != null) {
        dimension.height = openType.getHeight().intValue();
    }
    boolean resizable = true;
    if (openType.getResizable() != null) {
        resizable = openType.getResizable();
    }
    windowFrame.setResizable(resizable);
    windowFrame.setMinimumSize(dimension);
    windowFrame.pack();
    getDialogParams().reset();
    WindowBreadCrumbs breadCrumbs = createBreadCrumbs();
    breadCrumbs.addWindow(window);
    JComponent tabContent = createTabPanel(window, breadCrumbs);
    WindowOpenInfo openInfo = new WindowOpenInfo(window, OpenMode.NEW_WINDOW);
    openInfo.setData(tabContent);
    Map<Window, WindowOpenInfo> openInfos = new HashMap<>();
    if (window instanceof Window.Wrapper) {
        Window wrappedWindow = ((Window.Wrapper) window).getWrappedWindow();
        openInfos.put(wrappedWindow, openInfo);
    } else {
        openInfos.put(window, openInfo);
    }
    windowFrame.getWindowManager().attachTab(breadCrumbs, new Stack<>(), window, getWindowHashCode(window), tabContent, openInfos);
    App.getInstance().registerFrame(windowFrame);
    windowFrame.setVisible(true);
    return DesktopComponentsHelper.getComposition(window);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame)

Example 9 with TopLevelFrame

use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.

the class DesktopWindowManager method detachTab.

protected void detachTab(int tabIndex) {
    // Create new top-level frame, put this tab to it with breadcrumbs.
    // remove tab data from this window manager
    JComponent tabContent = (JComponent) tabsPane.getComponentAt(tabIndex);
    WindowBreadCrumbs breadCrumbs = tabs.get(tabContent);
    Window window = breadCrumbs.getCurrentWindow();
    if (window == null) {
        throw new IllegalArgumentException("window is null");
    }
    // WindowOpenMode map
    Map<Window, WindowOpenInfo> detachOpenModes = new HashMap<>();
    detachOpenModes.put((Window) window.getFrame(), windowOpenMode.get(window.<Window>getFrame()));
    windowOpenMode.remove(window.<Window>getFrame());
    Stack<Map.Entry<Window, Integer>> stack = stacks.get(breadCrumbs);
    for (Map.Entry<Window, Integer> entry : stack) {
        WindowOpenInfo openInfo = windowOpenMode.get(entry.getKey().<Window>getFrame());
        detachOpenModes.put((Window) entry.getKey().getFrame(), openInfo);
        windowOpenMode.remove(entry.getKey().<Window>getFrame());
    }
    tabs.remove(tabContent);
    Integer hashCode = windows.remove(window);
    tabsPane.remove(tabIndex);
    stacks.remove(breadCrumbs);
    final TopLevelFrame windowFrame = createTopLevelFrame(window.getCaption());
    App.getInstance().registerFrame(windowFrame);
    windowFrame.setVisible(true);
    windowFrame.getWindowManager().attachTab(breadCrumbs, stack, window, hashCode, tabContent, detachOpenModes);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) ParamsMap(com.haulmont.bali.util.ParamsMap)

Example 10 with TopLevelFrame

use of com.haulmont.cuba.desktop.TopLevelFrame in project cuba by cuba-platform.

the class JXErrorPaneExt method sendSupportEmail.

private void sendSupportEmail(ErrorInfo jXErrorPaneInfo) {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    ExceptionReportService reportService = AppBeans.get(ExceptionReportService.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    TopLevelFrame mainFrame = App.getInstance().getMainFrame();
    Messages messages = AppBeans.get(Messages.NAME);
    Locale locale = App.getInstance().getLocale();
    try {
        TimeSource timeSource = AppBeans.get(TimeSource.NAME);
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp());
        UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
        User user = userSessionSource.getUserSession().getUser();
        Map<String, Object> binding = new HashMap<>();
        binding.put("timestamp", date);
        binding.put("errorMessage", jXErrorPaneInfo.getBasicErrorMessage());
        binding.put("stacktrace", getStackTrace(jXErrorPaneInfo.getErrorException()));
        binding.put("systemId", clientConfig.getSystemID());
        binding.put("userLogin", user.getLogin());
        if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) {
            binding.putAll(additionalExceptionReportBinding);
        }
        reportService.sendExceptionReport(clientConfig.getSupportEmail(), ImmutableMap.copyOf(binding));
        mainFrame.showNotification(messages.getMainMessage("errorPane.emailSent", locale), Frame.NotificationType.TRAY);
    } catch (Throwable e) {
        mainFrame.showNotification(messages.getMainMessage("errorPane.emailSendingErr", locale), Frame.NotificationType.ERROR);
        log.error("Can't send error report", e);
    }
}
Also used : Locale(java.util.Locale) User(com.haulmont.cuba.security.entity.User) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) HashMap(java.util.HashMap) ExceptionReportService(com.haulmont.cuba.core.app.ExceptionReportService) ClientConfig(com.haulmont.cuba.client.ClientConfig) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)11 DialogWindow (com.haulmont.cuba.desktop.sys.DialogWindow)3 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)2 Window (com.haulmont.cuba.gui.components.Window)2 File (java.io.File)2 ParamsMap (com.haulmont.bali.util.ParamsMap)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 ExceptionReportService (com.haulmont.cuba.core.app.ExceptionReportService)1 Messages (com.haulmont.cuba.core.global.Messages)1 FileInfo (com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo)1 User (com.haulmont.cuba.security.entity.User)1 java.awt (java.awt)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 JXErrorPane (org.jdesktop.swingx.JXErrorPane)1