Search in sources :

Example 1 with CrudBaseGridView

use of com.kyj.fx.voeditor.visual.component.grid.CrudBaseGridView in project Gargoyle by callakrsos.

the class CommonsGridExample method start.

/*
	 * (non-Javadoc)
	 *
	 * @see javafx.application.Application#start(javafx.stage.Stage) KYJ
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    try {
        primaryStage.setWidth(1100);
        primaryStage.setHeight(800);
        BorderPane root = new BorderPane();
        Person person1 = new Person();
        person1.setName("김영준");
        person1.setAge("28");
        person1.setAddress("광주 광역시 북구 운암동");
        person1.setMarrayYn("N");
        Person person2 = new Person();
        person2.setName("박종광");
        person2.setAge("33");
        person2.setAddress("경기도 용인시 수지구 상현동");
        person2.setPhoneNumber("123342342");
        person2.setMarrayYn("Y");
        Person person3 = new Person();
        person3.setName("홍정호");
        person3.setAge("33");
        person3.setAddress("경기도 용인시 수지구 상현동    ㅁㄴㅇㅁㄴㅇㅁㄴㅇ");
        person3.setPhoneNumber("23423423423");
        person3.setMarrayYn("N");
        // 컬럼명이 name인경우 이름으로 alias를 준다.
        AnnotationOptions<Person> options = new AnnotationOptions<Person>(Person.class) {

            @Override
            public String convert(String columnName) {
                String name = columnName;
                if ("name".equals(columnName)) {
                    name = "이름";
                } else if ("address".equals(columnName)) {
                    name = "주소";
                }
                return name;
            }

            @Override
            public boolean editable(String columnName) {
                if ("address".equals(columnName)) {
                    return false;
                }
                return true;
            }

            @Override
            public CommboInfo<?> comboBox(String columnName) {
                if ("marrayYn".equals(columnName)) {
                    CodeDVO y = new CodeDVO("Y", "Y");
                    CodeDVO n = new CodeDVO("N", "N");
                    return new CommboInfo<>(FXCollections.observableArrayList(y, n), "code", "codeNm");
                }
                return null;
            }
        };
        CrudBaseGridView<Person> grid = new CrudBaseGridView<Person>(Person.class, /*
																						 * 사용하지고
																						 * 하는
																						 * 데이터셋
																						 * 객체
																						 */
        FXCollections.emptyObservableList(), /*
													 * 컬럼정렬순서 혹은 사용하고자하는 특정컬럼만
													 * 사용하고자하는경우
													 */
        options);
        // 저장버튼을 클릭한경우 처리할 콜백 등록
        grid.setSaveClickCallback(list -> {
            list.forEach(vo -> System.out.println("status : [" + vo.get_status() + "]  item : " + vo));
        });
        // 그리드에 데이터 바인드
        ObservableList<Person> asList = FXCollections.observableArrayList(Arrays.asList(person1, person2, person3));
        grid.addItems(asList);
        root.setCenter(grid);
        Scene scene = new Scene(root, 400, 400);
        primaryStage.setScene(scene);
        primaryStage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CommboInfo(com.kyj.fx.voeditor.visual.component.grid.CommboInfo) BorderPane(javafx.scene.layout.BorderPane) AnnotationOptions(com.kyj.fx.voeditor.visual.component.grid.AnnotationOptions) CrudBaseGridView(com.kyj.fx.voeditor.visual.component.grid.CrudBaseGridView) Scene(javafx.scene.Scene)

Aggregations

AnnotationOptions (com.kyj.fx.voeditor.visual.component.grid.AnnotationOptions)1 CommboInfo (com.kyj.fx.voeditor.visual.component.grid.CommboInfo)1 CrudBaseGridView (com.kyj.fx.voeditor.visual.component.grid.CrudBaseGridView)1 Scene (javafx.scene.Scene)1 BorderPane (javafx.scene.layout.BorderPane)1