use of javafx.beans.value.ObservableValue in project Retrospector by NonlinearFruit.
the class SearchTabController method initSearchTab.
private void initSearchTab() {
searchEditMedia.setDisable(true);
searchDeleteMedia.setDisable(true);
// Table Double Click
searchTable.setRowFactory(tv -> {
TableRow<Media> row = new TableRow<>();
row.setOnMouseClicked(event -> {
if (event.getClickCount() == 2 && (!row.isEmpty())) {
setMedia(row.getItem());
setTab(TAB.MEDIA);
}
});
return row;
});
// Table data setup
searchTableData = DataManager.getMedia();
FilteredList<Media> mediaFiltered = new FilteredList(searchTableData, x -> true);
SortedList<Media> mediaSortable = new SortedList<>(mediaFiltered);
searchTable.setItems(mediaSortable);
mediaSortable.comparatorProperty().bind(searchTable.comparatorProperty());
// Link to data properties
searchTitleColumn.setCellValueFactory(new PropertyValueFactory<>("Title"));
searchCreatorColumn.setCellValueFactory(new PropertyValueFactory<>("Creator"));
searchSeasonColumn.setCellValueFactory(new PropertyValueFactory<>("SeasonId"));
searchEpisodeColumn.setCellValueFactory(new PropertyValueFactory<>("EpisodeId"));
searchCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("Category"));
// Values for special columns
searchNumberColumn.setSortable(false);
searchNumberColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + searchTable.getItems().indexOf(p.getValue())));
searchReviewsColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, Integer>, ObservableValue<Integer>>() {
@Override
public ObservableValue<Integer> call(TableColumn.CellDataFeatures<Media, Integer> p) {
return new ReadOnlyObjectWrapper(p.getValue().getReviews().size());
}
});
searchMeanRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {
@Override
public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
return new ReadOnlyObjectWrapper(p.getValue().getAverageRating());
}
});
searchCurrentRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {
@Override
public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
return new ReadOnlyObjectWrapper(p.getValue().getCurrentRating());
}
});
// Comparators for string columns
searchTitleColumn.setComparator(new NaturalOrderComparator());
searchCreatorColumn.setComparator(new NaturalOrderComparator());
searchSeasonColumn.setComparator(new NaturalOrderComparator());
searchEpisodeColumn.setComparator(new NaturalOrderComparator());
searchCategoryColumn.setComparator(new NaturalOrderComparator());
searchTable.getSelectionModel().selectedItemProperty().addListener((observe, old, neo) -> {
setMedia(neo);
});
searchBox.textProperty().addListener((observa, old, neo) -> {
String query = neo;
if (query == null || query.equals(""))
mediaFiltered.setPredicate(x -> true);
else {
String[] queries = query.split(":");
mediaFiltered.setPredicate(x -> QueryProcessor.isMatchForMedia(query, x));
}
updateStats();
});
// Buttons
searchNewMedia.setOnAction(e -> {
Media neo = new Media();
neo.setId(DataManager.createDB(neo));
setMedia(neo);
setTab(TAB.MEDIA);
});
searchQuickEntry.setOnAction(e -> {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("QuickEntry.fxml"));
Parent root1 = (Parent) fxmlLoader.load();
QuickEntryController qec = fxmlLoader.getController();
qec.setup(currentTab);
Stage stage = new Stage();
stage.setTitle("Quick Entry");
stage.setScene(new Scene(root1));
stage.show();
} catch (Exception ex) {
}
});
searchStandardEntry.setOnAction(e -> {
Media neo = new Media();
neo.setId(DataManager.createDB(neo));
setMedia(neo);
setTab(TAB.MEDIA);
});
searchBackup.setOnAction(e -> DataManager.makeBackup());
searchCheatsheet.setOnAction(e -> {
new Cheatsheet().start(new Stage());
});
searchEditMedia.setOnAction(e -> {
setTab(TAB.MEDIA);
});
searchDeleteMedia.setOnAction(e -> {
if (new Alert(Alert.AlertType.WARNING, "Are you sure you want to delete this?", ButtonType.NO, ButtonType.YES).showAndWait().get().equals(ButtonType.YES)) {
DataManager.deleteDB(getMedia());
updateSearchTab();
}
});
// Init stuff
updateStats();
}
use of javafx.beans.value.ObservableValue 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.beans.value.ObservableValue in project bitsquare by bitsquare.
the class OfferBookChartView method getOfferTable.
private Tuple4<TableView<OfferListItem>, VBox, Button, Label> getOfferTable(Offer.Direction direction) {
TableView<OfferListItem> tableView = new TableView<>();
tableView.setMinHeight(109);
tableView.setPrefHeight(121);
//530
tableView.setMinWidth(480);
// price
TableColumn<OfferListItem, OfferListItem> priceColumn = new TableColumn<>();
priceColumn.textProperty().bind(priceColumnLabel);
//130
priceColumn.setMinWidth(115);
//130
priceColumn.setMaxWidth(115);
priceColumn.setSortable(false);
priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
priceColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText(formatter.formatPrice(offer.getPrice()));
model.priceFeedService.currenciesUpdateFlagProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
if (offerListItem.offer.getPrice() == null) {
this.offer = offerListItem.offer;
model.priceFeedService.currenciesUpdateFlagProperty().addListener(listener);
setText("N/A");
} else {
setText(formatter.formatPrice(offerListItem.offer.getPrice()));
}
} else {
if (listener != null)
model.priceFeedService.currenciesUpdateFlagProperty().removeListener(listener);
this.offer = null;
setText("");
}
}
};
}
});
// volume
TableColumn<OfferListItem, OfferListItem> volumeColumn = new TableColumn<>();
//125
volumeColumn.setMinWidth(115);
volumeColumn.setSortable(false);
volumeColumn.textProperty().bind(volumeColumnLabel);
volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
volumeColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
private Offer offer;
ChangeListener<Number> listener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (offer != null && offer.getPrice() != null) {
setText(formatter.formatVolume(offer.getOfferVolume()));
model.priceFeedService.currenciesUpdateFlagProperty().removeListener(listener);
}
}
};
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty) {
this.offer = offerListItem.offer;
if (offer.getPrice() == null) {
this.offer = offerListItem.offer;
model.priceFeedService.currenciesUpdateFlagProperty().addListener(listener);
setText("N/A");
} else {
setText(formatter.formatVolume(offer.getOfferVolume()));
}
} else {
if (listener != null)
model.priceFeedService.currenciesUpdateFlagProperty().removeListener(listener);
this.offer = null;
setText("");
}
}
};
}
});
// amount
TableColumn<OfferListItem, OfferListItem> amountColumn = new TableColumn<>("Amount in BTC");
//125
amountColumn.setMinWidth(115);
amountColumn.setSortable(false);
amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
amountColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty)
setText(formatter.formatCoin(offerListItem.offer.getAmount()));
else
setText("");
}
};
}
});
// accumulated
TableColumn<OfferListItem, OfferListItem> accumulatedColumn = new TableColumn<>("Sum in BTC");
//130
accumulatedColumn.setMinWidth(100);
accumulatedColumn.setSortable(false);
accumulatedColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
accumulatedColumn.setCellFactory(new Callback<TableColumn<OfferListItem, OfferListItem>, TableCell<OfferListItem, OfferListItem>>() {
@Override
public TableCell<OfferListItem, OfferListItem> call(TableColumn<OfferListItem, OfferListItem> column) {
return new TableCell<OfferListItem, OfferListItem>() {
@Override
public void updateItem(final OfferListItem offerListItem, boolean empty) {
super.updateItem(offerListItem, empty);
if (offerListItem != null && !empty)
setText(formatter.formatRoundedDoubleWithPrecision(offerListItem.accumulated, 4));
else
setText("");
}
};
}
});
if (direction == Offer.Direction.BUY) {
tableView.getColumns().add(accumulatedColumn);
tableView.getColumns().add(volumeColumn);
tableView.getColumns().add(amountColumn);
tableView.getColumns().add(priceColumn);
} else {
tableView.getColumns().add(priceColumn);
tableView.getColumns().add(amountColumn);
tableView.getColumns().add(volumeColumn);
tableView.getColumns().add(accumulatedColumn);
}
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new Label("Currently there are no offers available");
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
Label titleLabel = new Label();
titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));
boolean isSellOffer = direction == Offer.Direction.SELL;
Button button = new Button();
ImageView iconView = new ImageView();
iconView.setId(isSellOffer ? "image-buy-white" : "image-sell-white");
button.setGraphic(iconView);
button.setGraphicTextGap(10);
button.setText(isSellOffer ? "I want to buy bitcoin" : "I want to sell bitcoin");
button.setMinHeight(40);
button.setId(isSellOffer ? "buy-button-big" : "sell-button-big");
button.setOnAction(e -> {
if (isSellOffer) {
model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
navigation.navigateTo(MainView.class, BuyOfferView.class);
} else {
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
navigation.navigateTo(MainView.class, SellOfferView.class);
}
});
VBox vBox = new VBox();
vBox.setSpacing(10);
vBox.setFillWidth(true);
vBox.setMinHeight(190);
vBox.getChildren().addAll(titleLabel, tableView, button);
button.prefWidthProperty().bind(vBox.widthProperty());
return new Tuple4<>(tableView, vBox, button, titleLabel);
}
use of javafx.beans.value.ObservableValue in project Gargoyle by callakrsos.
the class WebViewExam method start.
/***********************************************************************************/
/* 이벤트 구현 */
@Override
public void start(Stage primaryStage) throws Exception {
WebView view = new WebView();
WebEngine engine = view.getEngine();
engine.setJavaScriptEnabled(true);
engine.setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
@Override
public WebEngine call(PopupFeatures p) {
Stage stage = new Stage(StageStyle.UTILITY);
WebView wv2 = new WebView();
VBox vBox = new VBox(5);
vBox.getChildren().add(wv2);
vBox.getChildren().add(new Button("업로딩"));
wv2.getEngine().setJavaScriptEnabled(true);
stage.setScene(new Scene(vBox));
stage.show();
return wv2.getEngine();
}
});
engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue ov, State oldState, State newState) {
if (newState == Worker.State.SUCCEEDED) {
primaryStage.setTitle(engine.getLocation());
}
}
});
engine.setConfirmHandler(new Callback<String, Boolean>() {
@Override
public Boolean call(String param) {
System.out.println("confirm handler : " + param);
return true;
}
});
engine.setOnAlert((WebEvent<String> wEvent) -> {
System.out.println("Alert Event - Message: " + wEvent.getData());
});
engine.load("http://localhost:15501/MemoWebapp/SmartEditor2.html");
primaryStage.setScene(new Scene(new BorderPane(view), 1200, 700));
primaryStage.show();
}
use of javafx.beans.value.ObservableValue in project Board-Instrumentation-Framework by intel.
the class SteelGaugeRadialWidget method Create.
@Override
public boolean Create(GridPane pane, DataManager dataMgr) {
SetParent(pane);
_ParentGridPane = pane;
if (false == SetupGauge()) {
return false;
}
_Gauge.setValue(_InitialValue);
ConfigureDimentions();
ConfigureAlignment();
SetupTaskAction();
SetupPeekaboo(dataMgr);
pane.add(_Gauge, getColumn(), getRow(), getColumnSpan(), getRowSpan());
dataMgr.AddListener(getMinionID(), getNamespace(), new ChangeListener() {
@Override
public void changed(ObservableValue o, Object oldVal, Object newVal) {
if (IsPaused()) {
return;
}
double newDialValue = 0;
double oldDialValue = 0;
String strVal = newVal.toString();
try {
newDialValue = Double.parseDouble(strVal);
// oldDialValue = Double.parseDouble(oldVal.toString());
} catch (Exception ex) {
LOGGER.severe("Invalid data for Gauge received: " + strVal);
return;
}
_Gauge.setValue(newDialValue);
}
});
return ApplyCSS();
}
Aggregations