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);
}
}
}
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();
}
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);
}
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;
}
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);
}
Aggregations