Search in sources :

Example 6 with TextFieldTableCell

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

the class FxTableViewUtil method getDisplayText.

/**
	 * 테이블컬럼에서 화면에 보여주는 텍스트를 리턴한다.
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 31. 
	 * @param tc
	 * @param row
	 * @return
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object getDisplayText(TableColumn<?, ?> tc, int row) {
    Callback cellFactory = tc.getCellFactory();
    if (cellFactory != null) /*&& cellObservableValue != null*/
    {
        //			Object value = cellObservableValue.getValue();
        Object call = cellFactory.call(tc);
        if (call != null && call instanceof TableCell) {
            TableCell cell = (TableCell) call;
            StringConverter converter = null;
            if (cell instanceof TextFieldTableCell) {
                TextFieldTableCell txtCell = (TextFieldTableCell) cell;
                converter = txtCell.getConverter();
            } else //					} 
            if (cell instanceof ComboBoxTableCell) {
                ComboBoxTableCell txtCell = (ComboBoxTableCell) cell;
                converter = txtCell.getConverter();
            } else //					else if (cell instanceof HyperlinkTableCell) {
            //						HyperlinkTableCell txtCell = (HyperlinkTableCell) cell;
            //						converter = txtCell.getConverter();
            //					}
            /* else 기본값. */
            {
                try {
                    Method m = cell.getClass().getMethod("converterProperty");
                    if (m != null) {
                        Object object = m.invoke(cell);
                        if (object != null && object instanceof ObjectProperty) {
                            ObjectProperty<StringConverter> convert = (ObjectProperty<StringConverter>) object;
                            converter = convert.get();
                        }
                    }
                } catch (Exception e) {
                // Nothing...
                }
            }
            if (converter != null) {
                Object cellData = tc.getCellData(row);
                return converter.toString(cellData);
            }
        }
        return call;
    }
    return tc.getCellData(row);
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) Callback(javafx.util.Callback) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableCell(javafx.scene.control.TableCell) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Method(java.lang.reflect.Method) StringConverter(javafx.util.StringConverter) ComboBoxTableCell(javafx.scene.control.cell.ComboBoxTableCell)

Aggregations

TextFieldTableCell (javafx.scene.control.cell.TextFieldTableCell)6 StringConverter (javafx.util.StringConverter)4 Method (java.lang.reflect.Method)3 ObjectProperty (javafx.beans.property.ObjectProperty)3 TableCell (javafx.scene.control.TableCell)3 ComboBoxTableCell (javafx.scene.control.cell.ComboBoxTableCell)3 Callback (javafx.util.Callback)3 BaseOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView)1 MeerketAbstractVoOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView)1 IOException (java.io.IOException)1 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)1 EventDispatcher (javafx.event.EventDispatcher)1 FXML (javafx.fxml.FXML)1 TableColumn (javafx.scene.control.TableColumn)1 PropertyValueFactory (javafx.scene.control.cell.PropertyValueFactory)1 TbmSysDaoDVO (kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO)1 TbpSysDaoMethodsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO)1