use of javafx.scene.control.ListCell in project bitsquare by bitsquare.
the class AltCoinAccountsView method buildForm.
///////////////////////////////////////////////////////////////////////////////////////////
// Base form
///////////////////////////////////////////////////////////////////////////////////////////
private void buildForm() {
addTitledGroupBg(root, gridRow, 1, "Manage accounts");
Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your altcoin accounts:", Layout.FIRST_ROW_DISTANCE);
GridPane.setValignment(tuple.first, VPos.TOP);
paymentAccountsListView = tuple.second;
paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14);
paymentAccountsListView.setCellFactory(new Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>>() {
@Override
public ListCell<PaymentAccount> call(ListView<PaymentAccount> list) {
return new ListCell<PaymentAccount>() {
final Label label = new Label();
final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
final Button removeButton = new Button("", icon);
final AnchorPane pane = new AnchorPane(label, removeButton);
{
label.setLayoutY(5);
removeButton.setId("icon-button");
AnchorPane.setRightAnchor(removeButton, 0d);
}
@Override
public void updateItem(final PaymentAccount item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
label.setText(item.getAccountName());
removeButton.setOnAction(e -> onDeleteAccount(item));
setGraphic(pane);
} else {
setGraphic(null);
}
}
};
}
});
Tuple3<Button, Button, Button> tuple3 = add3ButtonsAfterGroup(root, ++gridRow, "Add new account", "Export Accounts", "Import Accounts");
addAccountButton = tuple3.first;
exportButton = tuple3.second;
importButton = tuple3.third;
}
use of javafx.scene.control.ListCell in project Gargoyle by callakrsos.
the class UtubeDownloaderComposite method initialize.
@FXML
public void initialize() {
btnDownload.setDisable(true);
this.txtDownloadLocation.setText(System.getProperty("user.home"));
this.txtDownloadLocation.setPromptText("Downlaod Location");
// this.lvDownlaodCont.setCellFactory(new Callback<ListView<UtubeItemDVO>, ListCell<UtubeItemDVO>>() {
//
// @Override
// public ListCell<UtubeItemDVO> call(ListView<UtubeItemDVO> param) {
// return new UtubeListCell();
// }
// });
// this.lvDownlaodCont.setOnDragDetected(ev -> {
// ev.setDragDetect(true);
// });
txtUtubeURL.setOnDragOver(ev -> {
if (ev.getDragboard().hasUrl()) {
ev.acceptTransferModes(TransferMode.LINK);
ev.consume();
}
});
txtUtubeURL.setOnDragDropped(ev -> {
Dragboard dragboard = ev.getDragboard();
String url = dragboard.getUrl();
txtUtubeURL.setText(url);
});
txtUtubeURL.textProperty().addListener((oba, o, n) -> {
btnDownload.setDisable(n.trim().isEmpty());
});
// 초기값
this.cbQuality.getItems().addAll(YoutubeQuality.values());
// 디폴트
this.cbQuality.getSelectionModel().select(YoutubeQuality.p480);
this.cbQuality.setCellFactory(new Callback<ListView<YoutubeQuality>, ListCell<YoutubeQuality>>() {
@Override
public ListCell<YoutubeQuality> call(ListView<YoutubeQuality> param) {
return new TextFieldListCell<>(new StringConverter<YoutubeQuality>() {
@Override
public String toString(YoutubeQuality object) {
return object.name();
}
@Override
public YoutubeQuality fromString(String string) {
return YoutubeQuality.valueOf(string);
}
});
}
});
this.wasDownloading.addListener((oba, o, n) -> {
if (n != null)
this.btnDownload.setDisable(n.booleanValue());
});
this.downloadedFile.addListener((oba, o, n) -> {
if (n != null && n.exists()) {
// btnOpen.setDisable(false);
this.txtFileName.setText(n.getName());
} else {
// btnOpen.setDisable(true);
}
});
}
use of javafx.scene.control.ListCell in project Gargoyle by callakrsos.
the class FxSVNHistoryDataSupplier method createEntryListView.
// MenuItem createDiffMenu(){
//
// }
ListView<SVNLogEntry> createEntryListView(ObservableList<SVNLogEntry> list) {
ListView<SVNLogEntry> listView = new ListView<SVNLogEntry>(list);
listView.setCellFactory(new Callback<ListView<SVNLogEntry>, ListCell<SVNLogEntry>>() {
@Override
public ListCell<SVNLogEntry> call(ListView<SVNLogEntry> param) {
ListCell<SVNLogEntry> listCell = new ListCell<SVNLogEntry>() {
/* (non-Javadoc)
* @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
*/
@Override
protected void updateItem(SVNLogEntry item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
long revision = item.getRevision();
String author = item.getAuthor();
String dateString = YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate());
String message = item.getMessage();
setText(String.format("Resivion :%d author %s date :%s message :%s ", revision, author, dateString, message));
}
}
};
return listCell;
}
});
listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
SVNLogEntry selectedItem = listView.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
Map<String, SVNLogEntryPath> changedPaths = selectedItem.getChangedPaths();
if (ValueUtil.isNotEmpty(changedPaths)) {
ObservableList<GargoyleSVNLogEntryPath> collect = createStream(Arrays.asList(selectedItem)).collect(FxCollectors.toObservableList());
Node showing = null;
if (collect.isEmpty()) {
showing = new Label("Empty.");
showing.setStyle("-fx-text-fill:black");
} else {
showing = createHistoryListView(collect);
}
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showing);
}
}
}
});
return listView;
}
use of javafx.scene.control.ListCell in project jabref by JabRef.
the class ErrorConsoleController method createCellFactory.
private Callback<ListView<LogEventViewModel>, ListCell<LogEventViewModel>> createCellFactory() {
return cell -> new ListCell<LogEventViewModel>() {
private HBox graphic;
private Node icon;
private VBox message;
private Label heading;
private Label stacktrace;
{
graphic = new HBox(10);
heading = new Label();
stacktrace = new Label();
message = new VBox();
message.getChildren().setAll(heading, stacktrace);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
@Override
public void updateItem(LogEventViewModel event, boolean empty) {
super.updateItem(event, empty);
if (event == null || empty) {
setGraphic(null);
} else {
icon = event.getIcon().getGraphicNode();
heading.setText(event.getDisplayText());
heading.getStyleClass().setAll(event.getStyleClass());
stacktrace.setText(event.getStackTrace().orElse(""));
graphic.getStyleClass().setAll(event.getStyleClass());
graphic.getChildren().setAll(icon, message);
setGraphic(graphic);
}
}
};
}
use of javafx.scene.control.ListCell in project jabref by JabRef.
the class ViewModelListCellFactory method call.
@Override
public ListCell<T> call(ListView<T> param) {
return new ListCell<T>() {
@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
T viewModel = getItem();
if (empty || viewModel == null) {
setText(null);
setGraphic(null);
setOnMouseClicked(null);
setTooltip(null);
} else {
if (toText != null) {
setText(toText.call(viewModel));
}
if (toGraphic != null) {
setGraphic(toGraphic.call(viewModel));
}
if (toOnMouseClickedEvent != null) {
setOnMouseClicked(toOnMouseClickedEvent.call(viewModel));
}
if (toStyleClass != null) {
getStyleClass().setAll(toStyleClass.call(viewModel));
}
if (toTooltip != null) {
String tooltipText = toTooltip.call(viewModel);
if (StringUtil.isNotBlank(tooltipText)) {
setTooltip(new Tooltip(tooltipText));
}
}
}
getListView().refresh();
}
};
}
Aggregations