Search in sources :

Example 1 with ExtensionFilter

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

the class SceneBuilderLocationComposite method btnBrowseOnMouseClick.

/***********************************************************************************/
/* 이벤트 구현 */
@FXML
public void btnBrowseOnMouseClick() {
    File selectedFile = DialogUtil.showFileDialog(this.getScene().getWindow(), chooser -> {
        String property = System.getProperty("user.home");
        String pathname = String.join(File.separator, property, "AppData", "Local", "SceneBuilder");
        File file = new File(pathname);
        if (!file.exists())
            file = new File(property);
        chooser.setTitle("Scenebuilder Location");
        chooser.setInitialFileName("SceneBuilder.exe");
        chooser.setInitialDirectory(file);
        chooser.setSelectedExtensionFilter(new ExtensionFilter(GargoyleExtensionFilters.EXE_NAME, GargoyleExtensionFilters.EXE));
    });
    if (selectedFile != null && selectedFile.exists()) {
        txtLocation.setText(selectedFile.getAbsolutePath());
    }
}
Also used : ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) File(java.io.File) FXML(javafx.fxml.FXML)

Example 2 with ExtensionFilter

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

the class SqlPane method menuExportExcelOnAction.

/**
	 * Excel Export.
	 *
	 * @param e
	 */
public void menuExportExcelOnAction(ActionEvent e) {
    File saveFile = DialogUtil.showFileSaveDialog(SharedMemory.getPrimaryStage().getOwner(), option -> {
        option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
        option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xlsx)", "*.xlsx"));
        option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xls)", "*.xls"));
        option.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
        option.setTitle("Save Excel");
        option.setInitialDirectory(new File(SystemUtils.USER_HOME));
    });
    if (saveFile == null) {
        return;
    }
    if (saveFile.exists()) {
        Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("overwrite ?? ", FILE_OVERWIRTE_MESSAGE);
        showYesOrNoDialog.ifPresent(consume -> {
            String key = consume.getKey();
            String value = consume.getValue();
            if (!("RESULT".equals(key) && "Y".equals(value))) {
                return;
            }
        });
    }
    ObservableList<Map<String, Object>> items = this.tbResult.getItems();
    ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
    List<String> columns = this.tbResult.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
    toExcelFileFunction.generate0(saveFile, columns, items);
    DialogUtil.showMessageDialog("complete...");
}
Also used : SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) Arrays(java.util.Arrays) CheckComboBox(org.controlsfx.control.CheckComboBox) Application(javafx.application.Application) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) MacroControl(com.kyj.fx.voeditor.visual.component.macro.MacroControl) Map(java.util.Map) SQLPaneMotionable(com.kyj.fx.voeditor.visual.component.sql.functions.SQLPaneMotionable) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) VariableMappingView(com.kyj.fx.voeditor.visual.component.popup.VariableMappingView) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) SystemUtils(org.apache.commons.lang.SystemUtils) Strings(com.sun.btrace.BTraceUtils.Strings) ColumnExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ColumnExpression) SplitPane(javafx.scene.control.SplitPane) Pair(javafx.util.Pair) EditableTableViewComposite(com.kyj.fx.voeditor.visual.component.grid.EditableTableViewComposite) KeyEvent(javafx.scene.input.KeyEvent) ValueExpression(com.kyj.fx.voeditor.visual.component.grid.EditableTableView.ValueExpression) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) CustomInputDialogAction(com.kyj.fx.voeditor.visual.util.DialogUtil.CustomInputDialogAction) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TitledBorderPane(com.kyj.fx.voeditor.visual.component.TitledBorderPane) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) MouseButton(javafx.scene.input.MouseButton) ASTSqlCodeAreaHelper(com.kyj.fx.voeditor.visual.component.text.ASTSqlCodeAreaHelper) TreeItem(javafx.scene.control.TreeItem) FXCollections(javafx.collections.FXCollections) GagoyleTabProxy(com.kyj.fx.voeditor.visual.main.layout.GagoyleTabProxy) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Supplier(java.util.function.Supplier) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) TableItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.TableItemTree) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) TableOpenResourceView(com.kyj.fx.voeditor.visual.component.popup.TableOpenResourceView) StringConverter(javafx.util.StringConverter) SchoolMgrerSpreadSheetView(com.kyj.fx.voeditor.visual.main.layout.SchoolMgrerSpreadSheetView) GridPane(jfxtras.scene.layout.GridPane) File(java.io.File) SqlTabPane(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTabPane) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ResultDialog(com.kyj.fx.voeditor.visual.component.ResultDialog) Button(javafx.scene.control.Button) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) LoggerFactory(org.slf4j.LoggerFactory) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) EncrypUtil(com.kyj.fx.voeditor.visual.util.EncrypUtil) ContextMenu(javafx.scene.control.ContextMenu) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) Orientation(javafx.geometry.Orientation) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) Main(com.kyj.fx.voeditor.visual.main.Main) MenuItem(javafx.scene.control.MenuItem) SimpleTextView(com.kyj.fx.voeditor.visual.component.text.SimpleTextView) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) ISchemaTreeItem(com.kyj.fx.voeditor.visual.component.sql.functions.ISchemaTreeItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) Entry(java.util.Map.Entry) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Function(java.util.function.Function) BigDataDVO(com.kyj.fx.voeditor.visual.framework.BigDataDVO) TableColumn(javafx.scene.control.TableColumn) Insets(javafx.geometry.Insets) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Tooltip(javafx.scene.control.Tooltip) KeyCode(javafx.scene.input.KeyCode) ObjectProperty(javafx.beans.property.ObjectProperty) Modality(javafx.stage.Modality) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Consumer(java.util.function.Consumer) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) File(java.io.File) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Pair(javafx.util.Pair)

Example 3 with ExtensionFilter

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

the class SqlTab method miOenOnAction.

public void miOenOnAction(ActionEvent e) {
    File showFileDialog = DialogUtil.showFileDialog(/*SharedMemory.getPrimaryStage()*/
    null, choser -> {
        choser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.SQL_NAME, GargoyleExtensionFilters.SQL));
    });
    //선택한 파일이 정상적으로 선택된 경우는 null이 아님.
    if (showFileDialog != null) {
        String fileContent = FileUtil.readFile(showFileDialog, new LoadFileOptionHandler());
        if (fileContent != null) /*공백여부는 체크안함. 파일 내용에 실제 공백이 포함될 수 있으므로...*/
        {
            setTxtSql(fileContent);
            setText(showFileDialog.getName());
        }
    }
    e.consume();
}
Also used : LoadFileOptionHandler(com.kyj.fx.voeditor.visual.functions.LoadFileOptionHandler) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) File(java.io.File)

Example 4 with ExtensionFilter

use of javafx.stage.FileChooser.ExtensionFilter 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 5 with ExtensionFilter

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

the class ExcelFileChooserHandler method accept.

@Override
public void accept(FileChooser option) {
    option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
    option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xlsx)", "*.xlsx"));
    option.getExtensionFilters().add(new ExtensionFilter("Excel files (*.xls)", "*.xls"));
    option.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
    option.setTitle("Save Excel");
    option.setInitialDirectory(new File(System.getProperty("user.home")));
}
Also used : ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) File(java.io.File)

Aggregations

File (java.io.File)11 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)11 ResourceLoader (com.kyj.fx.voeditor.visual.momory.ResourceLoader)3 DbUtil (com.kyj.fx.voeditor.visual.util.DbUtil)3 DialogUtil (com.kyj.fx.voeditor.visual.util.DialogUtil)3 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)3 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)3 IOException (java.io.IOException)3 List (java.util.List)3 ObservableList (javafx.collections.ObservableList)3 Menu (javafx.scene.control.Menu)3 MenuItem (javafx.scene.control.MenuItem)3 Pair (javafx.util.Pair)3 DockPane (com.kyj.fx.voeditor.visual.component.dock.pane.DockPane)2 VariableMappingView (com.kyj.fx.voeditor.visual.component.popup.VariableMappingView)2 GargoyleExtensionFilters (com.kyj.fx.voeditor.visual.util.GargoyleExtensionFilters)2 Connection (java.sql.Connection)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Optional (java.util.Optional)2