Example usage for javafx.scene.control ListCell getListView

List of usage examples for javafx.scene.control ListCell getListView

Introduction

In this page you can find the example usage for javafx.scene.control ListCell getListView.

Prototype

public final ListView<T> getListView() 

Source Link

Usage

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.ListViewAdapter.java

/** {@inheritDoc} **/
public void clickOnIndex(final Integer index, ClickOptions co) {
    final int actualItemCount = EventThreadQueuerJavaFXImpl.invokeAndWait("scrollIndexVisible", //$NON-NLS-1$
            new Callable<Integer>() {
                public Integer call() throws Exception {
                    final ObservableList items = getRealComponent().getItems();
                    int itemCount = items != null ? items.size() : -1;
                    return new Integer(itemCount);
                }//from   w  ww  .  j a  v a  2 s. co m
            }).intValue();

    if (index >= actualItemCount || (index < 0)) {
        throw new StepExecutionException("List index '" + index //$NON-NLS-1$
                + "' is out of range", //$NON-NLS-1$
                EventFactory.createActionError(TestErrorEvent.INVALID_INDEX));
    }

    Rectangle r = EventThreadQueuerJavaFXImpl.invokeAndWait("scrollIndexVisible", //$NON-NLS-1$
            new Callable<Rectangle>() {
                public Rectangle call() throws Exception {
                    final T listView = getRealComponent();
                    listView.scrollTo(index.intValue());
                    listView.layout();
                    TraverseHelper<ListCell> helper = new TraverseHelper<ListCell>();
                    List<ListCell> lCells = helper.getInstancesOf(listView, ListCell.class);
                    for (ListCell cell : lCells) {
                        if (cell.getIndex() == index.intValue() && cell.getListView() == listView) {

                            Bounds b = cell.getBoundsInParent();
                            Point2D pos = cell.localToScreen(0, 0);
                            Point2D parentPos = listView.localToScreen(0, 0);
                            return new Rectangle(Rounding.round(pos.getX() - parentPos.getX()),
                                    Rounding.round(pos.getY() - parentPos.getY()), Rounding.round(b.getWidth()),
                                    Rounding.round(b.getHeight()));
                        }
                    }
                    return null;
                }
            });

    getRobot().click(getRealComponent(), r, co.setClickType(ClickOptions.ClickType.RELEASED));
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.ListViewAdapter.java

/** {@inheritDoc} **/
public String[] getSelectedValues() {
    return EventThreadQueuerJavaFXImpl.invokeAndWait("getSelectedValues", //$NON-NLS-1$
            new Callable<String[]>() {
                /** {@inheritDoc} **/
                public String[] call() throws Exception {
                    final T listView = getRealComponent();
                    ObservableList<Integer> sIndices = listView.getSelectionModel().getSelectedIndices();

                    List<String> selectedValues = new LinkedList<String>();
                    for (Integer i : sIndices) {
                        int index = i.intValue();
                        listView.scrollTo(index);
                        listView.layout();
                        TraverseHelper<ListCell> helper = new TraverseHelper<ListCell>();
                        List<ListCell> lCells = helper.getInstancesOf(listView, ListCell.class);
                        for (ListCell cell : lCells) {
                            if (cell.getIndex() == index && cell.getListView() == listView) {
                                selectedValues.add(cell.getText());
                                break;
                            }/*from www  .ja  v  a 2  s . c  o  m*/
                        }
                    }
                    return selectedValues.toArray(new String[0]);
                }
            });
}

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.ListViewAdapter.java

/** {@inheritDoc} **/
public String[] getValues() {
    return EventThreadQueuerJavaFXImpl.invokeAndWait("getValues", //$NON-NLS-1$
            new Callable<String[]>() {
                /** {@inheritDoc} **/
                public String[] call() throws Exception {
                    List<String> values = new LinkedList<String>();
                    final T listView = getRealComponent();
                    ObservableList items = listView.getItems();
                    int itemCount = items != null ? items.size() : -1;
                    for (int i = 0; i < itemCount; i++) {
                        listView.scrollTo(i);
                        listView.layout();
                        TraverseHelper<ListCell> helper = new TraverseHelper<ListCell>();
                        List<ListCell> lCells = helper.getInstancesOf(listView, ListCell.class);
                        for (ListCell cell : lCells) {
                            if (cell.getIndex() == i && cell.getListView() == listView) {
                                values.add(cell.getText());
                                break;
                            }/*from   w w  w. j  a v a  2 s. c  om*/
                        }
                    }
                    return values.toArray(new String[0]);
                }
            });
}