use of javafx.scene.control.TableColumn.CellDataFeatures in project Gargoyle by callakrsos.
the class ColumnExample3Con method initialize.
@FXML
public void initialize() {
tableView.setEditable(true);
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드1");
hashMap.put("commCodeNm", "데이터 1");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드1");
hashMap.put("commCodeNm", "데이터 223492342309842402394823049238420942384029343809248420934809428409238409238423094823049");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드3");
hashMap.put("commCodeNm", "데이터 3");
tableView.getItems().add(hashMap);
}
{
Map<String, String> hashMap = new HashMap<String, String>();
hashMap.put("commCode", "코드4");
hashMap.put("commCodeNm", "데이터 4");
tableView.getItems().add(hashMap);
}
colCode.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> param) {
return new SimpleStringProperty(param.getValue().get("commCode"));
}
});
colCodeNm.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map<String, String>, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<Map<String, String>, String> param) {
return new SimpleStringProperty(param.getValue().get("commCodeNm"));
}
});
}
use of javafx.scene.control.TableColumn.CellDataFeatures in project org.csstudio.display.builder by kasemir.
the class PointsTable method create.
/**
* @return Top-level {@link Node}
*/
public Node create() {
// Layout:
//
// | table | [Add]
// | table | [Remove]
// | table |
// | table |
// Create table with editable columns for type Double (supported as Number)
final TableColumn<Point, Number> x_col = new TableColumn<>(Messages.PointsTable_X);
x_col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
@Override
public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
return new SimpleDoubleProperty(param.getValue().getX());
}
});
x_col.setCellFactory(TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
x_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
points.setX(row, event.getNewValue().doubleValue());
});
final TableColumn<Point, Number> y_col = new TableColumn<>(Messages.PointsTable_Y);
y_col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Point, Number>, ObservableValue<Number>>() {
@Override
public ObservableValue<Number> call(CellDataFeatures<Point, Number> param) {
return new SimpleDoubleProperty(param.getValue().getY());
}
});
y_col.setCellFactory(TextFieldTableCell.<Point, Number>forTableColumn(new NumberStringConverter()));
y_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
points.setY(row, event.getNewValue().doubleValue());
});
final ObservableList<Point> data = new PointsAdapter(points);
final TableView<Point> table = new TableView<>(data);
table.getColumns().add(x_col);
table.getColumns().add(y_col);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.setPlaceholder(new Label(Messages.PointsTable_Empty));
table.setEditable(true);
// Buttons
final Button add = new Button(Messages.Add, JFXUtil.getIcon("add.png"));
add.setMaxWidth(Double.MAX_VALUE);
add.setOnAction(event -> data.add(new Point(0, 0)));
final Button remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
remove.setMaxWidth(Double.MAX_VALUE);
remove.setOnAction(event -> {
final int sel = table.getSelectionModel().getSelectedIndex();
if (sel >= 0)
data.remove(sel);
});
final Button up = new Button(Messages.MoveUp, JFXUtil.getIcon("up.png"));
up.setMaxWidth(Double.MAX_VALUE);
up.setOnAction(event -> TableHelper.move_item_up(table, data));
final Button down = new Button(Messages.MoveDown, JFXUtil.getIcon("down.png"));
down.setMaxWidth(Double.MAX_VALUE);
down.setOnAction(event -> TableHelper.move_item_down(table, data));
final VBox buttons = new VBox(10, add, remove, up, down);
final HBox content = new HBox(10, table, buttons);
HBox.setHgrow(table, Priority.ALWAYS);
return content;
}
use of javafx.scene.control.TableColumn.CellDataFeatures in project Gargoyle by callakrsos.
the class CheckBoxTableCellExam method start.
/*
* (non-Javadoc)
*
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage primaryStage) throws Exception {
TableView<SampleVO> center = new TableView<>();
center.setEditable(true);
TableColumn<SampleVO, Boolean> e = new TableColumn<SampleVO, Boolean>();
e.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<SampleVO, Boolean>, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(CellDataFeatures<SampleVO, Boolean> param) {
return param.getValue().checked;
}
});
e.setCellFactory(new Callback<TableColumn<SampleVO, Boolean>, TableCell<SampleVO, Boolean>>() {
@Override
public TableCell<SampleVO, Boolean> call(TableColumn<SampleVO, Boolean> param) {
return new CheckBoxTableCell<SampleVO, Boolean>() {
/*
* (non-Javadoc)
*
* @see
* javafx.scene.control.cell.CheckBoxTableCell#updateItem(
* java.lang.Object, boolean)
*/
@Override
public void updateItem(Boolean item, boolean empty) {
super.updateItem(item, empty);
}
/*
* (non-Javadoc)
*
* @see
* javafx.scene.control.Cell#isItemChanged(java.lang.Object,
* java.lang.Object)
*/
@Override
protected boolean isItemChanged(Boolean oldItem, Boolean newItem) {
System.out.println(oldItem + " : " + newItem);
return super.isItemChanged(oldItem, newItem);
}
};
}
});
e.setEditable(true);
TableColumn<SampleVO, String> e2 = new TableColumn<SampleVO, String>();
e2.setCellValueFactory(new PropertyValueFactory<SampleVO, String>("name"));
center.getColumns().add(e);
center.getColumns().add(e2);
center.getItems().add(new SampleVO(true, "kim"));
center.getItems().add(new SampleVO(true, "young"));
BorderPane borderPane = new BorderPane(center);
primaryStage.setScene(new Scene(borderPane));
primaryStage.show();
}
use of javafx.scene.control.TableColumn.CellDataFeatures 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);
}
use of javafx.scene.control.TableColumn.CellDataFeatures in project Gargoyle by callakrsos.
the class TextBaseDiffAppController method initialize.
@FXML
public void initialize() {
/* initControls */
ivReviced = new ImageView();
ivpReviced = new ImageViewPane(ivReviced);
ivpReviced.setPrefWidth(200);
ivpReviced.setPrefHeight(150);
ivOrigin = new ImageView();
ivpOrigin = new ImageViewPane(ivOrigin);
ivpOrigin.setPrefWidth(200);
ivpOrigin.setPrefHeight(150);
gpSnap.add(ivpReviced, 0, 0);
gpSnap.add(ivpOrigin, 1, 0);
lvOrinal.setCellFactory(param -> new DefaultTextFieldListCell(ORIGINAL));
lvRevice.setCellFactory(param -> new DefaultTextFieldListCell(REVICED));
fileCompareResultProperty.addListener(compareResultListener);
lvRevice.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvRevice.getSelectionModel().getSelectedItem();
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getOriginal() != null) {
movePosition = selectedItem.getPosition();
lvOrinal.scrollTo(movePosition - 1);
lvOrinal.getSelectionModel().select(movePosition);
}
}
});
lvOrinal.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
int movePosition = -1;
ChunkWrapper selectedItem = lvOrinal.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
Delta delta = selectedItem.getDelta();
if (delta != null && delta.getRevised() != null) {
movePosition = delta.getRevised().getPosition();
lvRevice.scrollTo(movePosition - 1);
lvRevice.getSelectionModel().select(movePosition);
}
}
}
});
lvOrinal.addEventFilter(ScrollEvent.SCROLL, event -> {
snappOriginShot();
});
lvRevice.addEventFilter(ScrollEvent.SCROLL, event -> {
snappReviceShot();
});
btnCompare.setOnMouseClicked(event -> {
String ori = txtOrigin.getText();
String rev = txtRevice.getText();
if (!(ori.isEmpty() && rev.isEmpty())) {
clear();
try {
this.compare.setOriginal(ori);
this.compare.setRevised(rev);
CompareResult chunkResult = this.compare.getChunkResult();
this.fileCompareResultProperty.set(chunkResult);
snappOriginShot();
snappReviceShot();
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
}
});
colStatus.setCellValueFactory(new Callback<CellDataFeatures<ChunkWrapper, String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<ChunkWrapper, String> param) {
TYPE type = param.getValue().getType();
StringProperty prop = new SimpleStringProperty();
if (type != null)
prop.set(type.name());
return prop;
}
});
colPosition.setCellValueFactory(param -> new SimpleIntegerProperty(new Integer(param.getValue().getPosition() + 1)));
colRevice.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getRevised();
prop.setValue(c.getLines().toString());
}
return prop;
});
colOrigin.setCellValueFactory(param -> {
Delta delta = param.getValue().getDelta();
SimpleStringProperty prop = new SimpleStringProperty();
if (delta != null) {
Chunk c = delta.getOriginal();
prop.setValue(c.getLines().toString());
}
return prop;
});
}
Aggregations