Search in sources :

Example 1 with TopLevelFrame

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

the class DesktopExportDisplay method saveFileAction.

private void saveFileAction(String fileName, JFrame frame, ExportDataProvider dataProvider) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setSelectedFile(new File(fileName));
    if (fileChooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
        File selectedFile = fileChooser.getSelectedFile();
        boolean success = saveFile(dataProvider, selectedFile);
        TopLevelFrame mainFrame = App.getInstance().getMainFrame();
        if (success) {
            mainFrame.showNotification(messages.getMessage(DesktopExportDisplay.class, "export.saveSuccess"), Frame.NotificationType.TRAY);
        } else {
            mainFrame.showNotification(messages.getMessage(DesktopExportDisplay.class, "export.saveError"), Frame.NotificationType.ERROR);
        }
    }
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) File(java.io.File)

Example 2 with TopLevelFrame

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

the class DesktopFileMultiUploadField method uploadFiles.

protected void uploadFiles(File[] files) {
    for (File file : files) {
        try {
            fireFileUploadStart(file.getName(), file.length());
            FileInfo fileInfo = fileUploading.createFile();
            UUID tempFileId = fileInfo.getId();
            File tmpFile = fileInfo.getFile();
            FileUtils.copyFile(file, tmpFile);
            filesMap.put(tempFileId, file.getName());
            fireFileUploadFinish(file.getName(), file.length());
        } catch (Exception ex) {
            Messages messages = AppBeans.get(Messages.NAME);
            String uploadError = messages.formatMessage(DesktopFileMultiUploadField.class, "multiupload.uploadError", file.getName());
            TopLevelFrame topLevelFrame = DesktopComponentsHelper.getTopLevelFrame(this);
            topLevelFrame.showNotification(uploadError, Frame.NotificationType.ERROR);
            fireFileUploadError(file.getName(), file.length(), ex);
        }
    }
    fireQueueUploadComplete();
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) FileInfo(com.haulmont.cuba.gui.upload.FileUploadingAPI.FileInfo) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) File(java.io.File)

Example 3 with TopLevelFrame

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

the class DesktopWindowManager method showExceptionDialog.

@Override
public void showExceptionDialog(Throwable throwable, @Nullable String caption, @Nullable String message) {
    Preconditions.checkNotNullArgument(throwable);
    JXErrorPane errorPane = new JXErrorPaneExt();
    errorPane.setErrorInfo(createErrorInfo(caption, message, throwable));
    final TopLevelFrame mainFrame = App.getInstance().getMainFrame();
    JDialog dialog = JXErrorPane.createDialog(mainFrame, errorPane);
    dialog.setMinimumSize(new Dimension(600, (int) dialog.getMinimumSize().getHeight()));
    final DialogWindow lastDialogWindow = getLastDialogWindow();
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            if (lastDialogWindow != null) {
                lastDialogWindow.enableWindow();
            } else {
                mainFrame.activate();
            }
        }
    });
    dialog.setModal(false);
    if (lastDialogWindow != null) {
        lastDialogWindow.disableWindow(null);
    } else {
        mainFrame.deactivate(null);
    }
    dialog.setVisible(true);
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) JXErrorPane(org.jdesktop.swingx.JXErrorPane)

Example 4 with TopLevelFrame

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

the class DesktopWindowManager method createTopLevelFrame.

protected TopLevelFrame createTopLevelFrame(String caption) {
    final TopLevelFrame windowFrame = new TopLevelFrame(caption);
    Dimension size = frame.getSize();
    int width = Math.round(size.width * NEW_WINDOW_SCALE);
    int height = Math.round(size.height * NEW_WINDOW_SCALE);
    windowFrame.setSize(width, height);
    windowFrame.setLocationRelativeTo(frame);
    return windowFrame;
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame)

Example 5 with TopLevelFrame

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

the class FontDialog method open.

public void open() {
    TopLevelFrame topLevelFrame = DesktopComponentsHelper.getTopLevelFrame(this);
    DialogWindow lastDialogWindow = topLevelFrame.getWindowManager().getLastDialogWindow();
    if (lastDialogWindow == null) {
        topLevelFrame.deactivate(null);
    } else {
        lastDialogWindow.disableWindow(null);
    }
    setVisible(true);
}
Also used : TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame)

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