use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class FXMLLoaderTest method start.
@Override
public void start(Stage primaryStage) throws Exception {
TableView tb = FxUtil.load(SampleController.class, (TableView tv) -> {
System.out.println("load complete...");
});
Scene scene = new Scene(tb);
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class FilterTableExample method start.
@Override
public void start(Stage primaryStage) throws Exception {
TableView<DataItem> tableView = new TableView<>();
FxUtil.installClipboardKeyEvent(tableView);
tableView.setItems(FXCollections.observableArrayList());
IntStream.range(0, 20000).mapToObj(i -> new DataItem()).forEach(d -> tableView.getItems().add(d));
TableColumn<DataItem, Integer> smallInt = new TableColumn<>("Small Int");
smallInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getSmallIntValue()));
TableColumn<DataItem, Integer> largeInt = new TableColumn<>("Large Int");
largeInt.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getLargeIntValue()));
TableColumn<DataItem, String> randomLetter = new TableColumn<>("Letter");
randomLetter.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomLetter()));
TableColumn<DataItem, String> randomString1 = new TableColumn<>("AlphaNum 1");
randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr1()));
TableColumn<DataItem, String> randomString2 = new TableColumn<>("AlphaNum 2");
randomString1.setCellValueFactory(cb -> new ReadOnlyObjectWrapper<>(cb.getValue().getRandomStr2()));
tableView.getColumns().addAll(smallInt, largeInt, randomLetter, randomString1, randomString2);
Platform.runLater(() -> new TableFilter<>(tableView));
GridPane grp = new GridPane();
GridPane.setFillHeight(tableView, true);
GridPane.setFillWidth(tableView, true);
GridPane.setHgrow(tableView, Priority.ALWAYS);
GridPane.setVgrow(tableView, Priority.ALWAYS);
grp.getChildren().add(tableView);
Scene scene = new Scene(grp);
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class SqlMultiplePane method menuExportExcelOnAction.
/**
* 엑셀 export기능
*
* @param tbResult
*
* @param e
*/
public void menuExportExcelOnAction(TableView<Map<String, Object>> tbResult) {
File saveFile = DialogUtil.showFileSaveDialog(SharedMemory.getPrimaryStage().getOwner(), option -> {
option.setInitialFileName(DateUtil.getCurrentDateString(DateUtil.SYSTEM_DATEFORMAT_YYYYMMDDHHMMSS));
option.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLSX_NAME, GargoyleExtensionFilters.XLSX));
option.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.XLS_NAME, GargoyleExtensionFilters.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 = tbResult.getItems();
ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
List<String> columns = tbResult.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
toExcelFileFunction.generate0(saveFile, columns, items);
DialogUtil.showMessageDialog("complete...");
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class SqlMultiplePane method newTabAction.
/********************************
* 작성일 : 2016. 4. 20. 작성자 : KYJ
*
* 새로운 탭을 만들고 그 안에 consumer라는 행위 처리를 한다.
*
* @param consumer
********************************/
@SuppressWarnings("unchecked")
private void newTabAction(Consumer<TableView<Map<String, Object>>> consumer) {
Tab newTab = addNewTabResult();
BorderPane borderPane = (BorderPane) newTab.getContent();
TableView<Map<String, Object>> content = (TableView<Map<String, Object>>) borderPane.getCenter();
NullExpresion.ifNotNullDo(content, consumer);
resultTabPane.getTabs().add(newTab);
resultTabPane.getSelectionModel().selectLast();
}
use of javafx.scene.control.TableView in project Gargoyle by callakrsos.
the class FxUtil method exportExcelFile.
/**
* tableView의 item을 엑셀파일로 전환
* @작성자 : KYJ
* @작성일 : 2017. 3. 31.
* @param saveFile
* @param tableView
*/
public static void exportExcelFile(File saveFile, TableView<?> tableView) {
List<Map<String, Object>> items = tableView.getItems().stream().map(v -> {
if (v instanceof Map) {
return (Map<String, Object>) v;
}
return (Map<String, Object>) ObjectUtil.toMap(v);
}).collect(Collectors.toList());
// ObservableList<Map<String, Object>> items = this.tbResult.getItems();
ToExcelFileFunction toExcelFileFunction = new ToExcelFileFunction();
List<String> columns = tableView.getColumns().stream().map(col -> col.getText()).collect(Collectors.toList());
toExcelFileFunction.generate0(saveFile, columns, items);
DialogUtil.showMessageDialog("complete...");
}
Aggregations