Search in sources :

Example 1 with EventDispatcher

use of javafx.event.EventDispatcher in project Gargoyle by callakrsos.

the class CrudBaseColumnMapper method textField.

private TextFieldTableCell<T, Object> textField(Class<?> classType, String columnName, IOptions naming) {
    TextFieldTableCell<T, Object> textFieldTableCell = new TextFieldTableCell<T, Object>() {

        /*
			 * (non-Javadoc)
			 *
			 * @see javafx.scene.control.cell.TextFieldTableCell#startEdit()
			 */
        @Override
        public void startEdit() {
            Object vo = tableViewProperty().get().getItems().get(getIndex());
            if (vo instanceof AbstractDVO) {
                AbstractDVO _abstractvo = (AbstractDVO) vo;
                if (Objects.equals(CommonConst._STATUS_CREATE, _abstractvo.get_status())) {
                    // 아래와 같은형태가 되어선안됨.
                    // if (annotationClass != null &&
                    // naming.editable(columnName)) {
                    // 새로 추가된 항목은 NotEditable항목 편집가능하게 함.
                    boolean editable = naming.editable(columnName);
                    if (!editable)
                        return;
                    super.startEdit();
                    LOGGER.debug("start Edit");
                } 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");
                    }
                }
            } else {
                LOGGER.debug("start Edit");
                super.startEdit();
            }
        }
    };
    StringConverter<Object> converter = naming.stringConverter(columnName);
    if (converter == null) {
        textFieldTableCell.setConverter(converter(textFieldTableCell, classType));
    } else {
        textFieldTableCell.setConverter(converter);
    }
    EventDispatcher originalDispatcher = textFieldTableCell.getEventDispatcher();
    textFieldTableCell.setEventDispatcher((event, tail) -> {
        return textFieldCellEventDispatcher(textFieldTableCell, originalDispatcher, event, tail);
    });
    return textFieldTableCell;
}
Also used : EventDispatcher(javafx.event.EventDispatcher) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell)

Example 2 with EventDispatcher

use of javafx.event.EventDispatcher 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

EventDispatcher (javafx.event.EventDispatcher)2 TextFieldTableCell (javafx.scene.control.cell.TextFieldTableCell)2 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 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 StringConverter (javafx.util.StringConverter)1