类javafx.scene.control.Cell源码实例Demo

下面列出了怎么用javafx.scene.control.Cell的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ARMStrong   文件: CellUtils.java
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
源代码2 项目: ARMStrong   文件: CellUtils.java
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                            + "StringConverter is null. Be sure to set a StringConverter "
                            + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
 
源代码3 项目: phoebus   文件: CellUtiles.java
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    textField.setText(getItemText(cell, converter));
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
源代码4 项目: phoebus   文件: CellUtiles.java
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                            + "StringConverter is null. Be sure to set a StringConverter "
                            + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
 
源代码5 项目: chvote-1-0   文件: AdditionalTableViewMatchers.java
@Factory
public static <T> Matcher<Node> cellWithValue(final Matcher<T> contentsMatcher) {
    return new TypeSafeMatcher<Node>(Cell.class) {
        @Override
        protected boolean matchesSafely(Node item) {
            return contentsMatcher.matches(((Cell) item).getItem());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText(Cell.class.getSimpleName())
                    .appendText(" ")
                    .appendText("with value")
                    .appendDescriptionOf(contentsMatcher);
        }
    };
}
 
源代码6 项目: Open-Lowcode   文件: CTimePeriodField.java
static void updateItem(
		final Cell<TimePeriod> cell,
		final HBox hbox,
		final Node graphic,
		final TimePeriodField timeperiodfield) {
	if (cell.isEmpty()) {
		cell.setText(null);
		cell.setGraphic(null);
	} else {
		if (cell.isEditing()) {
			if (timeperiodfield != null) {
				timeperiodfield.setTimePeriod(cell.getItem());
			}
			cell.setText(null);

			if (graphic != null) {
				hbox.getChildren().setAll(graphic, timeperiodfield);
				cell.setGraphic(hbox);
			} else {
				cell.setGraphic(timeperiodfield);
			}
		} else {
			cell.setText((cell.getItem() != null ? cell.getItem().toString() : ""));
			cell.setGraphic(graphic);
		}
	}
}
 
源代码7 项目: pmd-designer   文件: AttributeNameTableCell.java
public AttributeNameTableCell() {
    getStyleClass().add("attribute-name");

    Val.wrap(tableRowProperty())
       .flatMap(Cell::itemProperty)
       .values()
       .distinct()
        .subscribe(this::updateAttr);
}
 
源代码8 项目: ARMStrong   文件: CellUtils.java
/***************************************************************************
 *                                                                         *
 * ChoiceBox convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final ChoiceBox<T> choiceBox) {
    updateItem(cell, converter, null, null, choiceBox);
}
 
源代码9 项目: ARMStrong   文件: CellUtils.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ChoiceBox<T> choiceBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (choiceBox != null) {
                choiceBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, choiceBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(choiceBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码10 项目: ARMStrong   文件: CellUtils.java
static <T> ChoiceBox<T> createChoiceBox(
        final Cell<T> cell,
        final ObservableList<T> items,
        final ObjectProperty<StringConverter<T>> converter) {
    ChoiceBox<T> choiceBox = new ChoiceBox<T>(items);
    choiceBox.setMaxWidth(Double.MAX_VALUE);
    choiceBox.converterProperty().bind(converter);
    choiceBox.showingProperty().addListener(o -> {
        if (!choiceBox.isShowing()) {
            cell.commitEdit(choiceBox.getSelectionModel().getSelectedItem());
        }
    });
    return choiceBox;
}
 
源代码11 项目: ARMStrong   文件: CellUtils.java
/***************************************************************************
 *                                                                         *
 * TextField convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
源代码12 项目: ARMStrong   文件: CellUtils.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final TextField textField) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (textField != null) {
                //textField.setText(getItemText(cell, converter));
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, textField);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(textField);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码13 项目: ARMStrong   文件: CellUtils.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码14 项目: ARMStrong   文件: CellUtils.java
private static <T> void tryComboBoxCommit(ComboBox<T> comboBox, Cell<T> cell) {
    StringConverter<T> sc = comboBox.getConverter();
    if (comboBox.isEditable() && sc != null) {
        T value = sc.fromString(comboBox.getEditor().getText());
        cell.commitEdit(value);
    } else {
        cell.commitEdit(comboBox.getValue());
    }
}
 
源代码15 项目: ARMStrong   文件: CellUtils.java
private static <T> boolean listenToComboBoxSkin(final ComboBox<T> comboBox, final Cell<T> cell) {
    Skin<?> skin = comboBox.getSkin();
    if (skin != null && skin instanceof ComboBoxListViewSkin) {
        ComboBoxListViewSkin cbSkin = (ComboBoxListViewSkin) skin;
        Node popupContent = cbSkin.getPopupContent();
        if (popupContent != null && popupContent instanceof ListView) {
            popupContent.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> cell.commitEdit(comboBox.getValue()));
            return true;
        }
    }
    return false;
}
 
源代码16 项目: marathonv5   文件: JavaFXComboBoxCellElement.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    StringConverter converter = getConverter();
    Object item = ((Cell) node).getItem();
    if (converter != null) {
        return converter.toString(item);
    }
    return item.toString();
}
 
源代码17 项目: marathonv5   文件: JavaFXTextInputControlElement.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public boolean marathon_select(String value) {
    TextInputControl tc = (TextInputControl) getComponent();
    Boolean isCellEditor = (Boolean) tc.getProperties().get("marathon.celleditor");
    tc.setText("");
    if (isCellEditor != null && isCellEditor) {
        super.sendKeys(value, JavaAgentKeys.ENTER);
        Cell cell = (Cell) tc.getProperties().get("marathon.cell");
        cell.commitEdit(value);
    } else {
        super.sendKeys(value);
    }
    return true;
}
 
源代码18 项目: marathonv5   文件: JavaFXChoiceBoxCellElement.java
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    StringConverter converter = getConverter();
    Object item = ((Cell) node).getItem();
    if (converter != null) {
        return converter.toString(item);
    }
    return item.toString();
}
 
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public boolean marathon_select(String value) {
    GenericStyledArea gsa = new GenericStyledArea(getComponent());
    Boolean isCellEditor = (Boolean) gsa.getProperties().get("marathon.celleditor");
    gsa.clear();
    if (isCellEditor != null && isCellEditor) {
        super.sendKeys(value, JavaAgentKeys.ENTER);
        Cell cell = (Cell) gsa.getProperties().get("marathon.cell");
        cell.commitEdit(value);
    } else {
        super.sendKeys(convertNewLines(value));
    }
    return true;
}
 
源代码20 项目: phoebus   文件: CellUtiles.java
/***************************************************************************
 *                                                                         *
 * ChoiceBox convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final ChoiceBox<T> choiceBox) {
    updateItem(cell, converter, null, null, choiceBox);
}
 
源代码21 项目: phoebus   文件: CellUtiles.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ChoiceBox<T> choiceBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (choiceBox != null) {
                choiceBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, choiceBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(choiceBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码22 项目: phoebus   文件: CellUtiles.java
static <T> ChoiceBox<T> createChoiceBox(
        final Cell<T> cell,
        final ObservableList<T> items,
        final ObjectProperty<StringConverter<T>> converter) {
    ChoiceBox<T> choiceBox = new ChoiceBox<T>(items);
    choiceBox.setMaxWidth(Double.MAX_VALUE);
    choiceBox.converterProperty().bind(converter);
    choiceBox.getSelectionModel().selectedItemProperty().addListener((ov, oldValue, newValue) -> {
        if (cell.isEditing()) {
            cell.commitEdit(newValue);
        }
    });
    return choiceBox;
}
 
源代码23 项目: phoebus   文件: CellUtiles.java
/***************************************************************************
 *                                                                         *
 * TextField convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
源代码24 项目: phoebus   文件: CellUtiles.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final TextField textField) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (textField != null) {
                textField.setText(getItemText(cell, converter));
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, textField);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(textField);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码25 项目: phoebus   文件: CellUtiles.java
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
源代码26 项目: phoebus   文件: CellUtiles.java
static <T> ComboBox<T> createComboBox(final Cell<T> cell,
                                      final ObservableList<T> items,
                                      final ObjectProperty<StringConverter<T>> converter) {
    ComboBox<T> comboBox = new ComboBox<T>(items);
    comboBox.converterProperty().bind(converter);
    comboBox.setMaxWidth(Double.MAX_VALUE);
    comboBox.getSelectionModel().selectedItemProperty().addListener((ov, oldValue, newValue) -> {
        if (cell.isEditing()) {
            cell.commitEdit(newValue);
        }
    });
    return comboBox;
}
 
源代码27 项目: ARMStrong   文件: CellUtils.java
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
    return converter == null ?
        cell.getItem() == null ? "" : cell.getItem().toString() :
        converter.toString(cell.getItem());
}
 
源代码28 项目: ARMStrong   文件: CellUtils.java
static <T> void cancelEdit(Cell<T> cell, final StringConverter<T> converter, Node graphic) {
    cell.setText(getItemText(cell, converter));
    cell.setGraphic(graphic);
}
 
源代码29 项目: ARMStrong   文件: CellUtils.java
static <T> ComboBox<T> createComboBox(final Cell<T> cell,
                                      final ObservableList<T> items,
                                      final ObjectProperty<StringConverter<T>> converter) {
    ComboBox<T> comboBox = new ComboBox<T>(items);
    comboBox.converterProperty().bind(converter);
    comboBox.setMaxWidth(Double.MAX_VALUE);

    // setup listeners to properly commit any changes back into the data model.
    // First listener attempts to commit or cancel when the ENTER or ESC keys are released.
    // This is applicable in cases where the ComboBox is editable, and the user has
    // typed some input, and also when the ComboBox popup is showing.
    comboBox.addEventFilter(KeyEvent.KEY_RELEASED, e -> {
        if (e.getCode() == KeyCode.ENTER) {
            tryComboBoxCommit(comboBox, cell);
        } else if (e.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
        }
    });

    // Second listener attempts to commit when the user is in the editor of
    // the ComboBox, and moves focus away.
    comboBox.getEditor().focusedProperty().addListener(o -> {
        if (!comboBox.isFocused()) {
            tryComboBoxCommit(comboBox, cell);
        }
    });

    // Third listener makes an assumption about the skin being used, and attempts to add
    // a listener to the ListView within it, such that when the user mouse clicks on a
    // on an item, that is immediately committed and the cell exits the editing mode.
    boolean success = listenToComboBoxSkin(comboBox, cell);
    if (!success) {
        comboBox.skinProperty().addListener(new InvalidationListener() {
            @Override public void invalidated(Observable observable) {
                boolean successInListener = listenToComboBoxSkin(comboBox, cell);
                if (successInListener) {
                    comboBox.skinProperty().removeListener(this);
                }
            }
        });
    }

    return comboBox;
}
 
源代码30 项目: phoebus   文件: CellUtiles.java
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
    return converter == null ?
        cell.getItem() == null ? "" : cell.getItem().toString() :
        converter.toString(cell.getItem());
}
 
 类所在包
 类方法
 同包方法