Java 类javafx.scene.control.Cell 实例源码
项目:ABC-List
文件: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);
}
}
项目:ABC-List
文件: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);
}
}
项目:ABC-List
文件: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();
}
项目:ABC-List
文件: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;
}
项目:ABC-List
文件: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);
}
}
项目:Gargoyle
文件:PasswordTextFieldTableCell.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);
}
}
}
项目:Gargoyle
文件:PasswordTextFieldTableCell.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();
}
项目:Gargoyle
文件:PasswordTextFieldTableCell.java
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
final TextField textField = new TextField();
textField.setPromptText("user password.");
textField.setText(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;
}
项目: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);
}
};
}
项目: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;
}
项目:ABC-List
文件: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);
}
项目:ABC-List
文件:CellUtils.java
static <T> ChoiceBox<T> createChoiceBox(
final Cell<T> cell,
final ObservableList<T> items,
final ObjectProperty<StringConverter<T>> converter
) {
final ChoiceBox<T> choiceBox = new ChoiceBox<>(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;
}
项目:ABC-List
文件:CellUtils.java
static <T> ComboBox<T> createComboBox(final Cell<T> cell,
final ObservableList<T> items,
final ObjectProperty<StringConverter<T>> converter
) {
final ComboBox<T> comboBox = new ComboBox<>(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;
}
项目:org.csstudio.display.builder
文件:StringTable.java
/** Set style of table cell to reflect optional background color
* @param cell
* @param row Table row
* @param col Table column
*/
private void setCellStyle(Cell<String> cell, final int row, final int col)
{
final Color color = getCellColor(row, col);
if (color == null)
cell.setStyle(null);
else
{ // Based on modena.css
// .table-cell has no -fx-background-color to see overall background,
// but .table-cell:selected uses this to get border with an inset color
cell.setStyle("-fx-background-color: -fx-table-cell-border-color, " + JFXUtil.webRGB(color) +
";-fx-background-insets: 0, 0 0 1 0;");
}
}
项目:javafx-dpi-scaling
文件:AdjusterTest.java
@Test
public void testGetCellAdjuster() {
Adjuster adjuster = Adjuster.getAdjuster(Cell.class);
assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
项目:dwoss
文件:CustomTableCell.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);
}
}
}
项目:dwoss
文件:CustomTableCell.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();
}
项目:ABC-List
文件: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());
}
项目:ABC-List
文件:CellUtils.java
static <T> void cancelEdit(Cell<T> cell, final StringConverter<T> converter, Node graphic) {
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
项目:Gargoyle
文件:PasswordTextFieldTableCell.java
static <T> void updateItem(final Cell<T> cell, final StringConverter<T> converter, final PasswordField textField) {
updateItem(cell, converter, null, null, textField);
}
项目:Gargoyle
文件:PasswordTextFieldTableCell.java
static <T> void cancelEdit(Cell<T> cell, final StringConverter<T> converter, Node graphic) {
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
项目:dwoss
文件:CustomTableCell.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.");
}
/**
* original code:
* cell.commitEdit(converter.fromString(textField.getText()));
* event.consume();
*/
try
{
cell.commitEdit(converter.fromString(textField.getText()));
} catch (NumberFormatException e)
{
cell.cancelEdit();
} finally
{
event.consume();
}
});
textField.setOnKeyReleased(t ->
{
if (t.getCode() == KeyCode.ESCAPE)
{
cell.cancelEdit();
t.consume();
}
});
return textField;
}
项目:dwoss
文件:CustomTableCell.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());
}
项目:dwoss
文件:CustomTableCell.java
static <T> void updateItem(final Cell<T> cell,
final StringConverter<T> converter,
final TextField textField)
{
updateItem(cell, converter, null, null, textField);
}
项目:ABC-List
文件: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);
}
项目:ABC-List
文件:CellUtils.java
/**
* *************************************************************************
* *
* ComboBox convenience * *
*************************************************************************
*/
static <T> void updateItem(Cell<T> cell, StringConverter<T> converter, ComboBox<T> comboBox) {
updateItem(cell, converter, null, null, comboBox);
}