Search in sources :

Example 41 with ObservableList

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);
    }
}
Also used : MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) Series(javafx.scene.chart.XYChart.Series) SimpleDateFormat(java.text.SimpleDateFormat) XYChart(javafx.scene.chart.XYChart) LinkedHashMap(java.util.LinkedHashMap) LineChart(javafx.scene.chart.LineChart) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) SVNException(org.tmatesoft.svn.core.SVNException) Data(javafx.scene.chart.XYChart.Data) Collection(java.util.Collection) Node(javafx.scene.Node) Set(java.util.Set) MasterSlaveChartComposite(com.kyj.fx.voeditor.visual.component.MasterSlaveChartComposite) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) TreeMap(java.util.TreeMap) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ValueUtil(kyj.Fx.dao.wizard.core.util.ValueUtil) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) GagoyleDate(com.kyj.fx.voeditor.visual.framework.model.GagoyleDate) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) Series(javafx.scene.chart.XYChart.Series) ObservableList(javafx.collections.ObservableList) BarChart(javafx.scene.chart.BarChart) LineChart(javafx.scene.chart.LineChart)

Example 42 with ObservableList

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...");
}
Also used : Button(javafx.scene.control.Button) SystemLayoutViewController(com.kyj.fx.voeditor.visual.main.layout.SystemLayoutViewController) CheckComboBox(org.controlsfx.control.CheckComboBox) Connection(java.sql.Connection) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) LoggerFactory(org.slf4j.LoggerFactory) NullExpresion(com.kyj.fx.voeditor.visual.util.NullExpresion) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) Application(javafx.application.Application) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) EncrypUtil(com.kyj.fx.voeditor.visual.util.EncrypUtil) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) SQLPaneMotionable(com.kyj.fx.voeditor.visual.component.sql.functions.SQLPaneMotionable) GargoyleExtensionFilters(com.kyj.fx.voeditor.visual.util.GargoyleExtensionFilters) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) VariableMappingView(com.kyj.fx.voeditor.visual.component.popup.VariableMappingView) DockPos(com.kyj.fx.voeditor.visual.component.dock.pane.DockPos) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) TableView(javafx.scene.control.TableView) SystemUtils(org.apache.commons.lang.SystemUtils) HBox(javafx.scene.layout.HBox) Pair(javafx.util.Pair) MenuItem(javafx.scene.control.MenuItem) KeyEvent(javafx.scene.input.KeyEvent) 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) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) SqlTab(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTab) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) MouseButton(javafx.scene.input.MouseButton) TreeItem(javafx.scene.control.TreeItem) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) 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) BigDataDVO(com.kyj.fx.voeditor.visual.framework.BigDataDVO) TableColumn(javafx.scene.control.TableColumn) Tooltip(javafx.scene.control.Tooltip) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) 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) StringConverter(javafx.util.StringConverter) SchoolMgrerSpreadSheetView(com.kyj.fx.voeditor.visual.main.layout.SchoolMgrerSpreadSheetView) File(java.io.File) SqlTabPane(com.kyj.fx.voeditor.visual.component.sql.tab.SqlTabPane) Menu(javafx.scene.control.Menu) Consumer(java.util.function.Consumer) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) ActionEvent(javafx.event.ActionEvent) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) 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) HashMap(java.util.HashMap) Pair(javafx.util.Pair)

Example 43 with ObservableList

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;
}
Also used : SpreadsheetCell(org.controlsfx.control.spreadsheet.SpreadsheetCell) ObservableList(javafx.collections.ObservableList) Grid(org.controlsfx.control.spreadsheet.Grid)

Example 44 with ObservableList

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);
}
Also used : SpreadsheetCell(org.controlsfx.control.spreadsheet.SpreadsheetCell) ObservableList(javafx.collections.ObservableList) Grid(org.controlsfx.control.spreadsheet.Grid)

Example 45 with ObservableList

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();
}
Also used : Image(javafx.scene.image.Image) SpreadsheetCell(org.controlsfx.control.spreadsheet.SpreadsheetCell) TablePosition(javafx.scene.control.TablePosition) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) File(java.io.File)

Aggregations

ObservableList (javafx.collections.ObservableList)77 List (java.util.List)46 ArrayList (java.util.ArrayList)31 Collectors (java.util.stream.Collectors)29 Map (java.util.Map)28 FXCollections (javafx.collections.FXCollections)28 HashMap (java.util.HashMap)21 Node (javafx.scene.Node)20 TableColumn (javafx.scene.control.TableColumn)20 Label (javafx.scene.control.Label)18 Optional (java.util.Optional)17 ActionEvent (javafx.event.ActionEvent)16 FXML (javafx.fxml.FXML)16 TableView (javafx.scene.control.TableView)16 MouseEvent (javafx.scene.input.MouseEvent)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 Button (javafx.scene.control.Button)15 BorderPane (javafx.scene.layout.BorderPane)15 File (java.io.File)14