use of javafx.collections.ObservableList in project Gargoyle by callakrsos.
the class ScmCommitComposite method scmHistoryWalk.
private void scmHistoryWalk() throws SVNException {
List<GagoyleDate> periodDaysByWeek = DateUtil.getPeriodDaysByWeek(supplier.getWeekSize());
Collection<SVNLogEntry> allLogs = supplier.getAllLogs();
// supplier.createStream(allLogs);
TreeMap<String, Long> dayOfMonths = allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN.format(v.getDate()), () -> new TreeMap<>(), Collectors.counting()));
Map<String, Long> dayOfWeeks = new LinkedHashMap<>();
//초기값 세팅. [중요한건 정렬순서를 유지해아하므로. 초기값을 넣어준것.]
for (GagoyleDate d : DateUtil.getPeriodDaysByWeek()) {
String eee = FxSVNHistoryDataSupplier.EEE_PATTERN.format(d.toDate());
dayOfWeeks.put(eee, new Long(0));
}
//실제값 add
dayOfWeeks.putAll(allLogs.stream().collect(Collectors.groupingBy(v -> FxSVNHistoryDataSupplier.EEE_PATTERN.format(v.getDate()), Collectors.counting())));
{
BarChart<String, Long> barChartDayOfMonth = getBarChartDayOfMonth();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.YYYYMMDD_EEE_PATTERN, periodDaysByWeek, dayOfMonths, true);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
barChartDayOfMonth.getData().add(series);
}
{
LineChart<String, Long> lineChartDayOfWeek = getLineChartDayOfWeek();
ObservableList<Data<String, Long>> convert = convert(FxSVNHistoryDataSupplier.EEE_PATTERN, DateUtil.getPeriodDaysByWeek(), dayOfWeeks, false);
Series<String, Long> series = new Series<>(SERIES_LABEL, convert);
lineChartDayOfWeek.getData().add(series);
}
}
use of javafx.collections.ObservableList 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.collections.ObservableList in project Gargoyle by callakrsos.
the class GagoyleSpreadSheetView method createNewRow.
/**
* 새로운 Row를 생성한다.
*
* @param newRow
* 생성할 로우
* @return
*/
private ObservableList<SpreadsheetCell> createNewRow() {
Grid grid = ssv.getGrid();
ObservableList<ObservableList<SpreadsheetCell>> rows = grid.getRows();
int columnCount = grid.getColumnCount();
int newRow = rows.size();
ObservableList<SpreadsheetCell> newCells = FXCollections.observableArrayList(new ArrayList<>(columnCount));
for (int newCol = 0; newCol < columnCount; newCol++) {
newCells.add(SpreadsheetCellType.STRING.createCell(newRow, newCol, 1, 1, ""));
}
return newCells;
}
use of javafx.collections.ObservableList in project Gargoyle by callakrsos.
the class GagoyleSpreadSheetView method paste.
/**
* 붙여넣기
*
* @param pastString
*/
public void paste(final String pastString, final int startRowIndex, final int startColumnIndex) {
int row = startRowIndex;
int column = startColumnIndex;
int _column = column;
String[] split = pastString.split("\n");
Grid grid = ssv.getGrid();
ObservableList<ObservableList<SpreadsheetCell>> rows = grid.getRows();
for (String str : split) {
String[] split2 = str.split("\t");
_column = column;
for (String str2 : split2) {
SpreadsheetCell spreadsheetCell = null;
if (rows.size() > row)
spreadsheetCell = rows.get(row).get(_column);
else /* 새로운 로우를 생성함. */
{
ObservableList<SpreadsheetCell> newCells = createNewRow();
spreadsheetCell = newCells.get(_column);
rows.add(newCells);
}
spreadsheetCell.setItem(str2);
_column++;
}
row++;
}
ssv.setGrid(grid);
}
use of javafx.collections.ObservableList in project Gargoyle by callakrsos.
the class GagoyleSpreadSheetView method spreadSheetKeyPress.
public void spreadSheetKeyPress(KeyEvent e) {
if (e.isControlDown() && e.getCode() == KeyCode.C) {
StringBuffer clipboardContent = new StringBuffer();
ObservableList<TablePosition> selectedCells = ssv.getSelectionModel().getSelectedCells();
int prevRow = -1;
for (TablePosition<?, ?> pos : selectedCells) {
int currentRow = pos.getRow();
int currentColumn = pos.getColumn();
if ((prevRow != -1 && prevRow != currentRow)) {
clipboardContent.setLength(clipboardContent.length() - 1);
LOGGER.debug(clipboardContent.toString());
/*
* 라인세퍼레이터 사용하지말것. 이유는 클립보드에 들어가는 컨텐츠가 /r/n이되면서 엑셀에 붙여넣기시
* 잘못된 값이 입력됨. [ 금지 : SystemUtils.LINE_SEPARATOR = /r/n ]
*/
clipboardContent.append("\n");
}
prevRow = currentRow;
SpreadsheetCell spreadsheetCell = ssv.getGrid().getRows().get(currentRow).get(currentColumn);
clipboardContent.append(spreadsheetCell.getText()).append("\t");
}
clipboardContent.setLength(clipboardContent.length() - 1);
LOGGER.debug(String.format("clipboard content : \n%s", clipboardContent.toString()));
FxClipboardUtil.putString(clipboardContent.toString());
// 상위 이벤트가 호출되서 클립보드가 없어지는것을 방지한다.
e.consume();
} else if (e.isControlDown() && e.getCode() == KeyCode.V) {
int type = FxClipboardUtil.getCipboardContentTypes();
switch(type) {
case FxClipboardUtil.IMAGE:
{
Image pastImage = FxClipboardUtil.pastImage();
ObservableList<TablePosition> selectedCells = ssv.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
int row = tablePosition.getRow();
int column = tablePosition.getColumn();
SpreadsheetCell cell = new ImageCellType().createCell(row, column, 1, 1, pastImage);
ssv.getGrid().getRows().get(tablePosition.getRow()).set(tablePosition.getColumn(), cell);
// this.getGrid().setCellValue(tablePosition.getRow(),
// tablePosition.getColumn(), new ImageView(pastImage));
}
break;
case FxClipboardUtil.FILE:
List<File> pastFiles = FxClipboardUtil.pasteFiles();
File file = pastFiles.get(0);
if (file != null && file.exists()) {
try {
Image pastImage = new Image(file.toURI().toURL().openStream());
ObservableList<TablePosition> selectedCells = ssv.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
int row = tablePosition.getRow();
int column = tablePosition.getColumn();
SpreadsheetCell cell = new ImageCellType().createCell(row, column, 1, 1, pastImage);
ssv.getGrid().getRows().get(tablePosition.getRow()).set(tablePosition.getColumn(), cell);
} catch (Exception e1) {
e1.printStackTrace();
}
}
break;
case FxClipboardUtil.URL:
{
String pasteUrl = FxClipboardUtil.pasteUrl();
Image pastImage = new Image(pasteUrl);
ObservableList<TablePosition> selectedCells = ssv.getSelectionModel().getSelectedCells();
TablePosition tablePosition = selectedCells.get(0);
int row = tablePosition.getRow();
int column = tablePosition.getColumn();
SpreadsheetCell cell = new ImageCellType().createCell(row, column, 1, 1, pastImage);
ssv.getGrid().getRows().get(tablePosition.getRow()).set(tablePosition.getColumn(), cell);
}
break;
case FxClipboardUtil.STRING:
paste();
break;
default:
paste();
break;
}
}
e.consume();
}
Aggregations