Search in sources :

Example 1 with NumberingCellValueFactory

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

the class AbstractTableColumnInformationController method initialize.

@FXML
public void initialize() {
    colNumber.setCellValueFactory(new NumberingCellValueFactory<TableColumnMetaVO>(tbColumns));
    colKeyType.setCellFactory(param -> new TableCell<TableColumnMetaVO, KEY_TYPE>() {

        @Override
        protected void updateItem(KEY_TYPE item, boolean empty) {
            super.updateItem(item, empty);
            if (empty) {
                setGraphic(null);
            } else {
                ImageView image = null;
                switch(item) {
                    case PRI:
                        image = getImage(PRIMAKRY_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    case MULTI:
                        image = getImage(MULTI_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    case FOREIGN:
                        image = getImage(FOREIGN_KEY_IMAGE_NAME);
                        image.setFitWidth(getPrefWidth());
                        setGraphic(image);
                        break;
                    default:
                        image = new ImageView();
                }
                setGraphic(image);
            }
        }
    });
    colReference.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TableColumnMetaVO, String>, ObservableValue<String>>() {

        @Override
        public ObservableValue<String> call(CellDataFeatures<TableColumnMetaVO, String> param) {
            TableColumnMetaVO value = param.getValue();
            SimpleStringProperty stringProperty = new SimpleStringProperty();
            if (value != null && value.getRefs() != null) {
                Optional<String> reduce = value.getRefs().stream().map(v -> v.getPkColumnName() + " ->  [ " + v.getFkTableName() + "-" + v.getFkColumnName() + " ]").reduce((str1, str2) -> str1.concat("\n").concat(str2));
                reduce.ifPresent(stringProperty::setValue);
            }
            return stringProperty;
        }
    });
    colKeyType.setCellValueFactory(new PropertyValueFactory<>("keyType"));
    colKeyType.setStyle("-fx-alignment:center");
    this.tbColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    FxUtil.installClipboardKeyEvent(this.tbColumns);
}
Also used : KEY_TYPE(com.kyj.fx.voeditor.visual.component.sql.table.IKeyType.KEY_TYPE) NumberingCellValueFactory(com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) DatabaseMetaData(java.sql.DatabaseMetaData) Function(java.util.function.Function) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) SQLException(java.sql.SQLException) TableCell(javafx.scene.control.TableCell) ResultSet(java.sql.ResultSet) Map(java.util.Map) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Set(java.util.Set) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) ImageView(javafx.scene.image.ImageView) RowMapper(org.springframework.jdbc.core.RowMapper) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) Collections(java.util.Collections) Image(javafx.scene.image.Image) InputStream(java.io.InputStream) CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ImageView(javafx.scene.image.ImageView) KEY_TYPE(com.kyj.fx.voeditor.visual.component.sql.table.IKeyType.KEY_TYPE) FXML(javafx.fxml.FXML)

Aggregations

NumberingCellValueFactory (com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory)1 KEY_TYPE (com.kyj.fx.voeditor.visual.component.sql.table.IKeyType.KEY_TYPE)1 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)1 InputStream (java.io.InputStream)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)1 ObservableValue (javafx.beans.value.ObservableValue)1