Search in sources :

Example 11 with ListView

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");
    });
}
Also used : ListView(javafx.scene.control.ListView) FileChooser(javafx.stage.FileChooser) File(java.io.File) Test(org.junit.Test)

Example 12 with ListView

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();
}
Also used : Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) JFXButton(com.jfoenix.controls.JFXButton) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) JFXListView(com.jfoenix.controls.JFXListView) JFXListView(com.jfoenix.controls.JFXListView)

Example 13 with ListView

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);
            }
        }
    };
}
Also used : Button(javafx.scene.control.Button) KeyBindingRepository(org.jabref.gui.keyboard.KeyBindingRepository) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) AbstractController(org.jabref.gui.AbstractController) Node(javafx.scene.Node) DialogService(org.jabref.gui.DialogService) IconTheme(org.jabref.gui.IconTheme) KeyEvent(javafx.scene.input.KeyEvent) VBox(javafx.scene.layout.VBox) Inject(javax.inject.Inject) FXML(javafx.fxml.FXML) SelectionMode(javafx.scene.control.SelectionMode) ListChangeListener(javafx.collections.ListChangeListener) ClipBoardManager(org.jabref.gui.ClipBoardManager) ObservableList(javafx.collections.ObservableList) Callback(javafx.util.Callback) ContentDisplay(javafx.scene.control.ContentDisplay) KeyBinding(org.jabref.gui.keyboard.KeyBinding) BuildInfo(org.jabref.logic.util.BuildInfo) HBox(javafx.scene.layout.HBox) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) Label(javafx.scene.control.Label) VBox(javafx.scene.layout.VBox)

Example 14 with ListView

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);
}
Also used : Button(javafx.scene.control.Button) TempCustomerPassingData(CustomerGuiHelpers.TempCustomerPassingData) Initializable(javafx.fxml.Initializable) ListView(javafx.scene.control.ListView) URL(java.net.URL) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) IConfiramtionDialog(UtilsContracts.IConfiramtionDialog) ICustomer(CustomerContracts.ICustomer) Logger(org.apache.log4j.Logger) CatalogProduct(BasicCommonClasses.CatalogProduct) ResourceBundle(java.util.ResourceBundle) BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) Subscribe(com.google.common.eventbus.Subscribe) Callback(javafx.util.Callback) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat) GridPane(javafx.scene.layout.GridPane) CartProduct(BasicCommonClasses.CartProduct) Label(javafx.scene.control.Label) MalformedURLException(java.net.MalformedURLException) SmartCode(BasicCommonClasses.SmartCode) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) SMException(SMExceptions.SMException) DialogMessagesService(GuiUtils.DialogMessagesService) File(java.io.File) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) ActionEvent(javafx.event.ActionEvent) IBarcodeEventHandler(UtilsContracts.IBarcodeEventHandler) Stage(javafx.stage.Stage) ImageView(javafx.scene.image.ImageView) LocalDate(java.time.LocalDate) SmartcodeScanEvent(UtilsContracts.SmartcodeScanEvent) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) AbstractApplicationScreen(GuiUtils.AbstractApplicationScreen) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) JFXTextField(com.jfoenix.controls.JFXTextField) ListView(javafx.scene.control.ListView) JFXListView(com.jfoenix.controls.JFXListView) ListCell(javafx.scene.control.ListCell) CartProduct(BasicCommonClasses.CartProduct) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat)

Example 15 with ListView

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;
}
Also used : Arrays(java.util.Arrays) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) FXCollections(javafx.collections.FXCollections) JavaSVNManager(com.kyj.scm.manager.svn.java.JavaSVNManager) VBox(javafx.scene.layout.VBox) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) Callback(javafx.util.Callback) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Collection(java.util.Collection) SVNNodeKind(org.tmatesoft.svn.core.SVNNodeKind) Node(javafx.scene.Node) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) Collectors(java.util.stream.Collectors) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) SelectionMode(javafx.scene.control.SelectionMode) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) ObservableList(javafx.collections.ObservableList) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) TextArea(javafx.scene.control.TextArea) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) ListCell(javafx.scene.control.ListCell) Label(javafx.scene.control.Label) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ListView(javafx.scene.control.ListView) ObservableList(javafx.collections.ObservableList) Collection(java.util.Collection) List(java.util.List) ObservableList(javafx.collections.ObservableList) VBox(javafx.scene.layout.VBox)

Aggregations

ListView (javafx.scene.control.ListView)28 Label (javafx.scene.control.Label)15 ListCell (javafx.scene.control.ListCell)13 Button (javafx.scene.control.Button)12 Callback (javafx.util.Callback)10 GridPane (javafx.scene.layout.GridPane)9 ChangeListener (javafx.beans.value.ChangeListener)8 Insets (javafx.geometry.Insets)8 ImageView (javafx.scene.image.ImageView)8 Inject (javax.inject.Inject)8 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)7 AnchorPane (javafx.scene.layout.AnchorPane)7 UserThread (bisq.common.UserThread)6 Tuple2 (bisq.common.util.Tuple2)6 Res (bisq.core.locale.Res)6 FxmlView (bisq.desktop.common.view.FxmlView)6 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 File (java.io.File)6 ObservableList (javafx.collections.ObservableList)6