Search in sources :

Example 1 with ChoiceBoxTableCell

use of javafx.scene.control.cell.ChoiceBoxTableCell in project Gargoyle by callakrsos.

the class CrudBaseColumnMapper method commboBox.

private CommboBoxTableColumn<T, Object> commboBox(Class<?> classType, String columnName, IOptions naming) {
    CommboInfo<?> comboBox = naming.comboBox(columnName);
    ObservableList codeList = (ObservableList) comboBox.getCodeList();
    String code = comboBox.getCode();
    String codeNm = comboBox.getCodeNm();
    Supplier<ChoiceBoxTableCell<T, Object>> supplier = () -> {
        ChoiceBoxTableCell<T, Object> choiceBoxTableCell = new ChoiceBoxTableCell<T, Object>(codeList) {

            @Override
            public void startEdit() {
                Object vo = tableViewProperty().get().getItems().get(super.getIndex());
                if (vo instanceof AbstractDVO) {
                    AbstractDVO _abstractvo = (AbstractDVO) vo;
                    if (Objects.equals(CommonConst._STATUS_CREATE, _abstractvo.get_status())) {
                        boolean editable = naming.editable(columnName);
                        if (!editable)
                            return;
                        super.startEdit();
                    } else if (Objects.equals(CommonConst._STATUS_UPDATE, _abstractvo.get_status())) {
                        boolean editable = naming.editable(columnName);
                        if (!editable)
                            return;
                        NonEditable annotationClass = getAnnotationClass(_abstractvo.getClass(), NonEditable.class, columnName);
                        if (annotationClass != null) {
                            LOGGER.debug("non start Edit");
                        } else {
                            super.startEdit();
                            LOGGER.debug("start Edit");
                        }
                    }
                }
            }
        };
        EventDispatcher originalDispatcher = choiceBoxTableCell.getEventDispatcher();
        choiceBoxTableCell.setEventDispatcher((event, tail) -> {
            return choiceBoxTableCellCellEventDispatcher(choiceBoxTableCell, originalDispatcher, event, tail);
        });
        // 아직까지는 codeList가 쓰일일이 없어서 주석처리함.. 과연 필요한 케이스가 생길지...?
        choiceBoxTableCell.setConverter(new CommboBoxStringConverter<Object>(/* codeList, */
        code, codeNm));
        return choiceBoxTableCell;
    };
    CommboBoxTableColumn<T, Object> combobox = new CommboBoxTableColumn<T, Object>(supplier, columnName, codeList, code, codeNm);
    return combobox;
}
Also used : Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) TableRow(javafx.scene.control.TableRow) LoggerFactory(org.slf4j.LoggerFactory) Property(javafx.beans.property.Property) Event(javafx.event.Event) CheckBox(javafx.scene.control.CheckBox) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) StringConverter(javafx.util.StringConverter) Field(java.lang.reflect.Field) Supplier(java.util.function.Supplier) EventDispatcher(javafx.event.EventDispatcher) TableColumn(javafx.scene.control.TableColumn) Objects(java.util.Objects) EventDispatchChain(javafx.event.EventDispatchChain) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) Annotation(java.lang.annotation.Annotation) ChoiceBoxTableCell(javafx.scene.control.cell.ChoiceBoxTableCell) ObservableList(javafx.collections.ObservableList) TableView(javafx.scene.control.TableView) ChoiceBoxTableCell(javafx.scene.control.cell.ChoiceBoxTableCell) EventDispatcher(javafx.event.EventDispatcher) ObservableList(javafx.collections.ObservableList)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 Objects (java.util.Objects)1 Supplier (java.util.function.Supplier)1 BooleanProperty (javafx.beans.property.BooleanProperty)1 Property (javafx.beans.property.Property)1 ObservableList (javafx.collections.ObservableList)1 ActionEvent (javafx.event.ActionEvent)1 Event (javafx.event.Event)1 EventDispatchChain (javafx.event.EventDispatchChain)1 EventDispatcher (javafx.event.EventDispatcher)1 CheckBox (javafx.scene.control.CheckBox)1 TableColumn (javafx.scene.control.TableColumn)1 TableRow (javafx.scene.control.TableRow)1 TableView (javafx.scene.control.TableView)1 CheckBoxTableCell (javafx.scene.control.cell.CheckBoxTableCell)1 ChoiceBoxTableCell (javafx.scene.control.cell.ChoiceBoxTableCell)1 PropertyValueFactory (javafx.scene.control.cell.PropertyValueFactory)1 TextFieldTableCell (javafx.scene.control.cell.TextFieldTableCell)1 StringConverter (javafx.util.StringConverter)1