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