use of javafx.scene.control.ListView in project trex-stateless-gui by cisco-system-traffic-generator.
the class TestTrafficProfiles method testLoadProfile.
@Test
public void testLoadProfile() throws Exception {
openTrafficProfilesDialog();
final FileChooser fileChooser = Mockito.spy(FileChooser.class);
FileChooserFactory.set(fileChooser);
final File file = new File(getTestTrafficProfilesFolder() + "/profile.yaml");
Mockito.doReturn(file).when(fileChooser).showOpenDialog(Mockito.any());
assertCall(() -> {
clickOn("#load-profile-button");
FileChooserFactory.set(null);
}, () -> {
final ListView profileList = lookup("#traffic-profile-dialog-profiles-list-view").query();
return profileList.getItems().contains("profile.yaml");
});
}
use of javafx.scene.control.ListView in project JFoenix by jfoenixadmin.
the class ListViewDemo method start.
@Override
public void start(Stage stage) throws Exception {
JFXListView<Label> list = new JFXListView<>();
for (int i = 0; i < 4; i++) {
list.getItems().add(new Label(ITEM + i));
}
list.getStyleClass().add("mylistview");
ListView<String> javaList = new ListView<>();
for (int i = 0; i < 4; i++) {
javaList.getItems().add(ITEM + i);
}
FlowPane pane = new FlowPane();
pane.setStyle("-fx-background-color:WHITE");
JFXButton button3D = new JFXButton("3D");
button3D.setOnMouseClicked(e -> list.depthProperty().set(++counter % 2));
JFXButton buttonExpand = new JFXButton("EXPAND");
buttonExpand.setOnMouseClicked(e -> {
list.depthProperty().set(1);
list.setExpanded(true);
});
JFXButton buttonCollapse = new JFXButton("COLLAPSE");
buttonCollapse.setOnMouseClicked(e -> {
list.depthProperty().set(1);
list.setExpanded(false);
});
pane.getChildren().add(button3D);
pane.getChildren().add(buttonExpand);
pane.getChildren().add(buttonCollapse);
AnchorPane listsPane = new AnchorPane();
listsPane.getChildren().add(list);
AnchorPane.setLeftAnchor(list, 20.0);
listsPane.getChildren().add(javaList);
AnchorPane.setLeftAnchor(javaList, 300.0);
VBox box = new VBox();
box.getChildren().add(pane);
box.getChildren().add(listsPane);
box.setSpacing(40);
StackPane main = new StackPane();
main.getChildren().add(box);
main.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
StackPane.setMargin(pane, new Insets(20, 0, 0, 20));
final Scene scene = new Scene(main, 600, 600, Color.WHITE);
stage.setTitle("JFX ListView Demo ");
scene.getStylesheets().add(ListViewDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
use of javafx.scene.control.ListView 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.ListView in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(customerMainScreenPane);
barcodeEventHandler.register(this);
customer = TempCustomerPassingData.customer;
filteredProductList = new FilteredList<>(productsObservableList, s -> true);
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
filteredProductList.setPredicate((filter == null || filter.length() == 0) ? s -> true : s -> s.getCatalogProduct().getName().contains(filter));
});
productsListView.setItems(filteredProductList);
productsListView.setCellFactory(new Callback<ListView<CartProduct>, ListCell<CartProduct>>() {
@Override
public ListCell<CartProduct> call(ListView<CartProduct> __) {
return new CustomerProductCellFormat();
}
});
productsListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CartProduct>() {
@Override
public void changed(ObservableValue<? extends CartProduct> __, CartProduct oldValue, CartProduct newValue) {
updateProductInfoPaine(newValue.getCatalogProduct(), newValue.getTotalAmount(), ProductInfoPaneVisibleMode.PRESSED_PRODUCT);
}
});
productsListView.depthProperty().set(1);
productsListView.setExpanded(true);
setAbilityAndVisibilityOfProductInfoPane(false);
}
use of javafx.scene.control.ListView in project Gargoyle by callakrsos.
the class FxSVNHistoryDataSupplier method createHistoryListView.
public ListView<GargoyleSVNLogEntryPath> createHistoryListView(ObservableList<GargoyleSVNLogEntryPath> list) {
ListView<GargoyleSVNLogEntryPath> listView = new ListView<GargoyleSVNLogEntryPath>(list);
listView.setCellFactory(new Callback<ListView<GargoyleSVNLogEntryPath>, ListCell<GargoyleSVNLogEntryPath>>() {
@Override
public ListCell<GargoyleSVNLogEntryPath> call(ListView<GargoyleSVNLogEntryPath> param) {
ListCell<GargoyleSVNLogEntryPath> listCell = new ListCell<GargoyleSVNLogEntryPath>() {
/* (non-Javadoc)
* @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
*/
@Override
protected void updateItem(GargoyleSVNLogEntryPath item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
String type = "Modify";
switch(item.getType()) {
case GargoyleSVNLogEntryPath.TYPE_ADDED:
type = "Add";
break;
case GargoyleSVNLogEntryPath.TYPE_MODIFIED:
type = "Modify";
break;
case GargoyleSVNLogEntryPath.TYPE_REPLACED:
type = "Replace";
break;
case GargoyleSVNLogEntryPath.TYPE_DELETED:
type = "Delete";
break;
}
String path = item.getPath();
setText(String.format("Resivion :%d File : %s Date : %s Type : %s ", item.getCopyRevision(), path.substring(path.lastIndexOf("/")), YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate()), type));
}
}
};
return listCell;
}
});
listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
ContextMenu contextMenu = null;
ObservableList<GargoyleSVNLogEntryPath> selectedItems = listView.getSelectionModel().getSelectedItems();
GargoyleSVNLogEntryPath selectedItem = null;
if (selectedItems != null && !selectedItems.isEmpty()) {
selectedItem = selectedItems.get(0);
}
if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
if (selectedItem != null) {
String path = selectedItem.getPath();
long copyRevision = selectedItem.getCopyRevision();
String rootUrl = getRootUrl();
LOGGER.debug("{}", rootUrl);
LOGGER.debug("Cat Command, Path : {} Revision {}", path, copyRevision);
String content = "";
VBox vBox = new VBox(5);
if (isExists(path)) {
content = cat(path, String.valueOf(copyRevision));
List<SVNLogEntry> log = log(path, String.valueOf(copyRevision), ex -> {
LOGGER.error(ValueUtil.toString(ex));
});
if (ValueUtil.isNotEmpty(log)) {
SVNLogEntry svnLogEntry = log.get(0);
String apply = getManager().fromPrettySVNLogConverter().apply(svnLogEntry);
Label e = new Label(apply);
e.setStyle("-fx-text-fill:black");
vBox.getChildren().add(e);
}
vBox.getChildren().add(createJavaTextArea(content));
} else {
content = "Does not exists. Repository. [Removed]";
Label e = new Label(content);
e.setStyle("-fx-text-fill:black");
vBox.getChildren().add(e);
}
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), vBox);
}
ev.consume();
} else if (ev.getClickCount() == 1 && ev.getButton() == MouseButton.SECONDARY) {
ObservableList<MenuItem> menus = FXCollections.observableArrayList();
MenuItem miHist = new MenuItem("History");
miHist.setUserData(selectedItem);
MenuItem miAllHist = new MenuItem("All History");
MenuItem miDiff = new MenuItem("Diff");
miDiff.setDisable(true);
menus.add(miHist);
menus.add(miAllHist);
menus.add(new SeparatorMenuItem());
menus.add(miDiff);
if (selectedItems.size() == 2) {
miDiff.setUserData(selectedItems);
miDiff.setDisable(false);
}
miHist.setOnAction(event -> {
GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
if (userData == null)
return;
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(userData.getPath()));
});
miAllHist.setOnAction(event -> {
GargoyleSVNLogEntryPath userData = (GargoyleSVNLogEntryPath) miHist.getUserData();
if (userData == null)
return;
String path = userData.getPath();
try {
Collection<SVNLogEntry> allLogs = getManager().getAllLogs(path);
ObservableList<GargoyleSVNLogEntryPath> collect = createStream(allLogs).filter(v -> {
return path.equals(v.getPath());
}).collect(FxCollectors.toObservableList());
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), createHistoryListView(collect));
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
});
miDiff.setOnAction(event -> {
List<GargoyleSVNLogEntryPath> userData = (List<GargoyleSVNLogEntryPath>) miDiff.getUserData();
if (userData == null && userData.size() != 2)
return;
GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath1 = userData.get(0);
GargoyleSVNLogEntryPath gargoyleSVNLogEntryPath2 = userData.get(1);
try {
String diff = diff(gargoyleSVNLogEntryPath1.getPath(), gargoyleSVNLogEntryPath1.getCopyRevision(), gargoyleSVNLogEntryPath2.getCopyRevision());
TextArea showingNode = new TextArea(diff);
showingNode.setPrefSize(600d, 800d);
FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showingNode);
} catch (Exception e) {
e.printStackTrace();
}
});
contextMenu = new ContextMenu(menus.stream().toArray(MenuItem[]::new));
contextMenu.show(ev.getPickResult().getIntersectedNode(), ev.getScreenX(), ev.getScreenY());
}
});
return listView;
}
Aggregations