Search in sources :

Example 16 with FileChooser

use of javafx.stage.FileChooser in project Gargoyle by callakrsos.

the class VoEditorController method btnExcelExportOnMouseClick.

/**
	 * 엑셀 export
	 *
	 * @param e
	 */
@FXML
public void btnExcelExportOnMouseClick(MouseEvent e) {
    File saveFile = DialogUtil.showFileSaveCheckDialog(SharedMemory.getPrimaryStage(), new Consumer<FileChooser>() {

        @Override
        public void accept(FileChooser choser) {
            String fileName = txtClassName.getText();
            File dir = SystemUtils.getUserDir();
            choser.setInitialFileName(fileName);
            choser.setInitialDirectory(dir);
            choser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLSX_NAME, GargoyleExtensionFilters.XLSX));
        }
    });
    boolean isSuccess = false;
    if (saveFile != null) {
        try {
            File createExcelFile = VoWizardUtil.createExcelFile(saveFile.getParentFile(), saveFile.getName(), tbVoEditor.getItems(), true);
            if (createExcelFile != null && createExcelFile.exists()) {
                isSuccess = true;
            }
        } catch (GargoyleFileAlreadyExistException e1) {
            ValueUtil.toString(e1);
            DialogUtil.showExceptionDailog(e1);
            return;
        }
    }
    if (isSuccess) {
        if (chkWriteThenOpen.isSelected()) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().open(saveFile);
                } catch (IOException e1) {
                    DialogUtil.showExceptionDailog(e1);
                }
            }
        }
    }
}
Also used : ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) GargoyleFileAlreadyExistException(com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException) FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) File(java.io.File) FXML(javafx.fxml.FXML)

Example 17 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class DatabasePathAction method getFileToSave.

public static File getFileToSave() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.NewFile"));
    final File file = fileChooser.showSaveDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(DatabasePathAction.class);
        pref.put(LAST_DIR, file.getParentFile().getAbsolutePath());
    }
    return file;
}
Also used : FileChooser(javafx.stage.FileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 18 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class DatabasePathAction method getFileToOpen.

public static File getFileToOpen() {
    final ResourceBundle resources = ResourceUtils.getBundle();
    final FileChooser fileChooser = configureFileChooser();
    fileChooser.setTitle(resources.getString("Title.Open"));
    final File file = fileChooser.showOpenDialog(MainView.getPrimaryStage());
    if (file != null) {
        Preferences pref = Preferences.userNodeForPackage(DatabasePathAction.class);
        pref.put(LAST_DIR, file.getParentFile().getAbsolutePath());
    }
    return file;
}
Also used : FileChooser(javafx.stage.FileChooser) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 19 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ExecuteJavaScriptAction method configureFileChooser.

private static FileChooser configureFileChooser() {
    final Preferences pref = Preferences.userNodeForPackage(ExecuteJavaScriptAction.class);
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(pref.get(LAST_DIR, System.getProperty("user.home"))));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JavaScript Files", "*.js"));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All Files", "*.*"));
    return fileChooser;
}
Also used : FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 20 with FileChooser

use of javafx.stage.FileChooser in project jgnash by ccavanaugh.

the class ExportAccountsAction method configureFileChooser.

private static FileChooser configureFileChooser() {
    final Preferences pref = Preferences.userNodeForPackage(ExportAccountsAction.class);
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(pref.get(LAST_DIR, System.getProperty("user.home"))));
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter(ResourceUtils.getString("Label.XMLFiles") + " (*.xml)", "*.xml", "*.XML"));
    return fileChooser;
}
Also used : FileChooser(javafx.stage.FileChooser) Preferences(java.util.prefs.Preferences) File(java.io.File)

Aggregations

FileChooser (javafx.stage.FileChooser)64 File (java.io.File)59 Preferences (java.util.prefs.Preferences)21 IOException (java.io.IOException)17 ResourceBundle (java.util.ResourceBundle)11 FXML (javafx.fxml.FXML)11 FileOutputStream (java.io.FileOutputStream)5 ArrayList (java.util.ArrayList)5 Alert (javafx.scene.control.Alert)5 Button (javafx.scene.control.Button)4 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 List (java.util.List)3 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)2 Palette (fractal.Palette)2 Path (java.nio.file.Path)2 ObservableList (javafx.collections.ObservableList)2 FilteredList (javafx.collections.transformation.FilteredList)2 SortedList (javafx.collections.transformation.SortedList)2 Task (javafx.concurrent.Task)2 Insets (javafx.geometry.Insets)2