Search in sources :

Example 26 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class FxExcelUtil method appendAllColumns.

/**
	 * 테이블뷰의 모든 컬럼을 찾기위한 재귀함수.
	 * 
	 * (( 설마 테이블컬럼이 무한대로 있는 화면은 없겠지. ))
	 * @작성자 : KYJ
	 * @작성일 : 2016. 9. 6. 
	 * @param parent 계층형 컬럼의 부모를 가리킴.
	 * @param pocket 컬럼이 일렬로 저정된다.
	 * @param index 트리레벨을 가리킴. 다른말로하면 컬럼의 순서를 가리킴.
	 * @param col
	 * @param level 계층형 컬럼의 현재 레벨을 가리킴.
	 * @param use 엑셀처리에 사용할 컬럼인지 처리여부
	 * @return 가장 Depth가 긴 레벨을 리턴.
	 */
static <T> int appendAllColumns(ExcelColumnExpression parent, List<ExcelColumnExpression> pocket, TableColumn<T, ?> col, int level, ITableColumnForExcel use) {
    int maxLevel = level;
    int myLevel = level;
    if (col == null)
        /*|| !col.isVisible()*/
        return maxLevel;
    if (use != null) {
        boolean test = use.test(col.getTableView(), col);
        if (!test)
            return maxLevel;
    }
    ExcelColumnExpression columnExpr = new ExcelColumnExpression();
    String text = ValueUtil.isEmpty(col.getText()) ? "-" : col.getText();
    boolean visible = col.isVisible();
    double width = col.getWidth();
    columnExpr.setRealText(text);
    columnExpr.setTableColumn(col);
    columnExpr.setIndex(pocket.isEmpty() ? 0 : pocket.get(pocket.size() - 1).getIndex() + 1);
    columnExpr.setLevel(myLevel);
    columnExpr.setVisible(visible);
    columnExpr.setParent(parent);
    LOGGER.debug("col : {} , isVisible : {} , level : {}, width : {} ", text, col.isVisible(), myLevel, width);
    pocket.add(columnExpr);
    if (parent != null) {
        parent.getChildrens().add(columnExpr);
    }
    List<TableColumn<T, ?>> columns = col.getColumns();
    if (columns == null || columns.isEmpty()) {
        return maxLevel;
    } else {
        int visibledColumnCount = 0;
        for (int i = 0; i < columns.size(); i++) {
            TableColumn<T, ?> subCol = columns.get(i);
            if (use.test(subCol.getTableView(), subCol)) {
                int _level = appendAllColumns(columnExpr, pocket, subCol, (myLevel + 1), use);
                if (maxLevel < _level)
                    maxLevel = _level;
                visibledColumnCount++;
            }
        }
        List<ExcelColumnExpression> subList = pocket.subList(pocket.size() - visibledColumnCount, pocket.size());
        //			if (parent != null) {
        //fix indexㅒ
        int idx = 0;
        for (ExcelColumnExpression c : subList) {
            //				if (c.isVisible()) {
            c.setIndex(columnExpr.getIndex() + idx);
            idx++;
        //				}
        }
        return maxLevel;
    }
}
Also used : TableColumn(javafx.scene.control.TableColumn) ExcelColumnExpression(com.kyj.fx.voeditor.visual.framework.excel.ExcelColumnExpression)

Example 27 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class ColorPickerExample method start.

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("DockFX");
    TableView<Map<String, Object>> tableView = new TableView<Map<String, Object>>();
    tableView.setEditable(true);
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("color", Color.RED);
        tableView.getItems().add(map);
    }
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("color", Color.GREEN);
        tableView.getItems().add(map);
    }
    tableView.setEditable(true);
    tableView.getColumns().add(new ColorPickerTableColumn<>(new TableColumn<>(), "color"));
    tableView.setOnMouseClicked(event -> {
        System.out.println("mouse click event");
    });
    Button btnAdd = new Button("추가");
    btnAdd.setOnMouseClicked(event -> {
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("color", Color.RED);
        tableView.getItems().add(hashMap);
    });
    BorderPane root = new BorderPane(tableView);
    root.setTop(new BorderPane(btnAdd));
    primaryStage.setScene(new Scene(root, 1100, 700));
    // primaryStage.setScene(new Scene(new BorderPane(new
    // MysqlPane("sample")), 1100, 700));
    primaryStage.sizeToScene();
    primaryStage.show();
    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    DockPane.initializeDefaultUserAgentStylesheet();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Button(javafx.scene.control.Button) HashMap(java.util.HashMap) Scene(javafx.scene.Scene) Map(java.util.Map) HashMap(java.util.HashMap) ColorPickerTableColumn(com.kyj.fx.voeditor.visual.component.ColorPickerTableColumn) TableColumn(javafx.scene.control.TableColumn) TableView(javafx.scene.control.TableView)

Example 28 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class ColumnExample method start.

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("DockFX");
    TableView<ClassTypeCodeDVO> tableView = new TableView<ClassTypeCodeDVO>();
    tableView.setEditable(true);
    {
        ClassTypeCodeDVO e = new ClassTypeCodeDVO();
        e.setCommCode("코드1");
        e.setCommCodeNm("데이터 1");
        tableView.getItems().add(e);
    }
    {
        ClassTypeCodeDVO e = new ClassTypeCodeDVO();
        e.setCommCode("코드1");
        e.setCommCodeNm("데이터 2123123123123123123123123112312312331232\n\n\n\n\n\n\n\34534958345093443850934583409583405934850349534095830534098");
        tableView.getItems().add(e);
    }
    {
        ClassTypeCodeDVO e = new ClassTypeCodeDVO();
        e.setCommCode("코드3");
        e.setCommCodeNm("데이터 3");
        tableView.getItems().add(e);
    }
    {
        ClassTypeCodeDVO e = new ClassTypeCodeDVO();
        e.setCommCode("코드4");
        e.setCommCodeNm("데이터 4");
        tableView.getItems().add(e);
    }
    ObservableList<CodeDVO> observableArrayList = FXCollections.observableArrayList(Arrays.asList(new CodeDVO("출력용 코드명1", "코드1"), new CodeDVO("출력용코드명2", "코드2"), new CodeDVO("출력용코드명3", "코드3")));
    tableView.getColumns().add(new ComboBoxTableColumn<>("commCode", observableArrayList, "code", "codeNm"));
    TableColumn<ClassTypeCodeDVO, Object> e = new TableColumn<>("SAMPLE");
    e.setCellValueFactory(new PropertyValueFactory<>("commCodeNm"));
    tableView.getColumns().add(e);
    tableView.getColumns().add(new TableColumn<>("emptyCol1"));
    tableView.getColumns().add(new TableColumn<>("emptyCol2"));
    tableView.getColumns().add(new TableColumn<>("emptyCol3"));
    tableView.getColumns().add(new TableColumn<>("emptyCol4"));
    tableView.getColumns().add(new TableColumn<>("emptyCol5"));
    tableView.getColumns().add(new TableColumn<>("emptyCol6"));
    tableView.setOnMouseClicked(event -> {
        ClassTypeCodeDVO selectedItem = tableView.getSelectionModel().getSelectedItem();
        System.out.println("유효성 체크입니다.");
        System.out.println("코드 : 데이터 형태로 출력되야합니다.");
        System.out.println(selectedItem.getCommCode() + " : " + selectedItem.getCommCodeNm());
    });
    primaryStage.setScene(new Scene(new BorderPane(tableView), 1100, 700));
    // primaryStage.setScene(new Scene(new BorderPane(new
    // MysqlPane("sample")), 1100, 700));
    primaryStage.sizeToScene();
    primaryStage.show();
    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    DockPane.initializeDefaultUserAgentStylesheet();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) ClassTypeCodeDVO(com.kyj.fx.voeditor.visual.main.model.vo.ClassTypeCodeDVO) ClassTypeCodeDVO(com.kyj.fx.voeditor.visual.main.model.vo.ClassTypeCodeDVO) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) ComboBoxTableColumn(com.kyj.fx.voeditor.visual.component.ComboBoxTableColumn) TableView(javafx.scene.control.TableView)

Example 29 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class ColumnExample2 method start.

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("DockFX");
    TableView<Map<String, String>> tableView = new TableView<Map<String, String>>();
    tableView.setEditable(true);
    {
        Map<String, String> hashMap = new HashMap<String, String>();
        hashMap.put("commCode", "코드1");
        hashMap.put("commCodeNm", "데이터 1");
        tableView.getItems().add(hashMap);
    }
    {
        Map<String, String> hashMap = new HashMap<String, String>();
        hashMap.put("commCode", "코드1");
        hashMap.put("commCodeNm", "데이터 2");
        tableView.getItems().add(hashMap);
    }
    {
        Map<String, String> hashMap = new HashMap<String, String>();
        hashMap.put("commCode", "코드3");
        hashMap.put("commCodeNm", "데이터 3");
        tableView.getItems().add(hashMap);
    }
    {
        Map<String, String> hashMap = new HashMap<String, String>();
        hashMap.put("commCode", "코드4");
        hashMap.put("commCodeNm", "데이터 4");
        tableView.getItems().add(hashMap);
    }
    ObservableList<CodeDVO> observableArrayList = FXCollections.observableArrayList(Arrays.asList(new CodeDVO("출력용 코드명1", "코드1"), new CodeDVO("출력용코드명2", "코드2"), new CodeDVO("출력용코드명3", "코드3")));
    tableView.getColumns().add(new ComboBoxTableColumn<>("commCode", observableArrayList, "code", "codeNm"));
    TableColumn<Map<String, String>, Object> e = new TableColumn<>("SAMPLE");
    e.setCellValueFactory(new MapValueFactory("commCodeNm"));
    tableView.getColumns().add(e);
    tableView.setOnMouseClicked(event -> {
        Map<String, String> selectedItem = tableView.getSelectionModel().getSelectedItem();
        System.out.println("유효성 체크입니다.");
        System.out.println("코드 : 데이터 형태로 출력되야합니다.");
        System.out.println(selectedItem.get("commCode") + " : " + selectedItem.get("commCodeNm"));
    });
    primaryStage.setScene(new Scene(new BorderPane(tableView), 1100, 700));
    // primaryStage.setScene(new Scene(new BorderPane(new
    // MysqlPane("sample")), 1100, 700));
    primaryStage.sizeToScene();
    primaryStage.show();
    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    DockPane.initializeDefaultUserAgentStylesheet();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) ComboBoxTableColumn(com.kyj.fx.voeditor.visual.component.ComboBoxTableColumn) MapValueFactory(javafx.scene.control.cell.MapValueFactory) HashMap(java.util.HashMap) Map(java.util.Map) TableView(javafx.scene.control.TableView)

Example 30 with TableColumn

use of javafx.scene.control.TableColumn in project Gargoyle by callakrsos.

the class CheckBoxTableCellExam method start.

/*
	 * (non-Javadoc)
	 *
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    TableView<SampleVO> center = new TableView<>();
    center.setEditable(true);
    TableColumn<SampleVO, Boolean> e = new TableColumn<SampleVO, Boolean>();
    e.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SampleVO, Boolean>, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(CellDataFeatures<SampleVO, Boolean> param) {
            return param.getValue().checked;
        }
    });
    e.setCellFactory(new Callback<TableColumn<SampleVO, Boolean>, TableCell<SampleVO, Boolean>>() {

        @Override
        public TableCell<SampleVO, Boolean> call(TableColumn<SampleVO, Boolean> param) {
            return new CheckBoxTableCell<SampleVO, Boolean>() {

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.cell.CheckBoxTableCell#updateItem(
					 * java.lang.Object, boolean)
					 */
                @Override
                public void updateItem(Boolean item, boolean empty) {
                    super.updateItem(item, empty);
                }

                /*
					 * (non-Javadoc)
					 *
					 * @see
					 * javafx.scene.control.Cell#isItemChanged(java.lang.Object,
					 * java.lang.Object)
					 */
                @Override
                protected boolean isItemChanged(Boolean oldItem, Boolean newItem) {
                    System.out.println(oldItem + " : " + newItem);
                    return super.isItemChanged(oldItem, newItem);
                }
            };
        }
    });
    e.setEditable(true);
    TableColumn<SampleVO, String> e2 = new TableColumn<SampleVO, String>();
    e2.setCellValueFactory(new PropertyValueFactory<SampleVO, String>("name"));
    center.getColumns().add(e);
    center.getColumns().add(e2);
    center.getItems().add(new SampleVO(true, "kim"));
    center.getItems().add(new SampleVO(true, "young"));
    BorderPane borderPane = new BorderPane(center);
    primaryStage.setScene(new Scene(borderPane));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ObservableValue(javafx.beans.value.ObservableValue) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) SampleVO(com.kyj.fx.voeditor.visual.example.CheckBoxTableCellExam.SampleVO) TableView(javafx.scene.control.TableView)

Aggregations

TableColumn (javafx.scene.control.TableColumn)40 TableView (javafx.scene.control.TableView)13 BigDecimal (java.math.BigDecimal)11 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)10 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)9 LocalDate (java.time.LocalDate)8 Map (java.util.Map)8 Scene (javafx.scene.Scene)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 BorderPane (javafx.scene.layout.BorderPane)7 List (java.util.List)6 FXML (javafx.fxml.FXML)5 TableCell (javafx.scene.control.TableCell)5 ObjectProperty (javafx.beans.property.ObjectProperty)4 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)4 ObservableValue (javafx.beans.value.ObservableValue)4 ObservableList (javafx.collections.ObservableList)4 Button (javafx.scene.control.Button)4 SelectionMode (javafx.scene.control.SelectionMode)4