Search in sources :

Example 1 with Grid

use of org.controlsfx.control.spreadsheet.Grid 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 2 with Grid

use of org.controlsfx.control.spreadsheet.Grid 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 3 with Grid

use of org.controlsfx.control.spreadsheet.Grid in project Gargoyle by callakrsos.

the class GagoyleSpreadSheetView method paste.

/**
	 * 특수문자에대한 문자열 paste에 대한 버그를 수정하기 위한 함수.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 11. 23.
	 * @param items
	 * @param startRowIndex
	 * @param startColumnIndex
	 */
public void paste(List<Map<String, Object>> items, int startRowIndex, 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 (Map<String, Object> str : items) {
        //			String[] split2 = str.split("\t");
        _column = column;
        Iterator<String> iterator = str.keySet().iterator();
        while (iterator.hasNext()) {
            String strCol = iterator.next();
            Object value = str.get(strCol);
            SpreadsheetCell spreadsheetCell = null;
            if (rows.size() > row) {
                ObservableList<SpreadsheetCell> observableList = rows.get(row);
                try {
                    spreadsheetCell = observableList.get(_column);
                } catch (IndexOutOfBoundsException e) {
                    e.printStackTrace();
                }
            } else /* 새로운 로우를 생성함. */
            {
                ObservableList<SpreadsheetCell> newCells = createNewRow();
                spreadsheetCell = newCells.get(_column);
            }
            if (value != null)
                value = value.toString();
            spreadsheetCell.setItem(value);
            _column++;
        }
        row++;
    }
}
Also used : SpreadsheetCell(org.controlsfx.control.spreadsheet.SpreadsheetCell) ObservableList(javafx.collections.ObservableList) Grid(org.controlsfx.control.spreadsheet.Grid)

Aggregations

ObservableList (javafx.collections.ObservableList)3 Grid (org.controlsfx.control.spreadsheet.Grid)3 SpreadsheetCell (org.controlsfx.control.spreadsheet.SpreadsheetCell)3