Java 类javafx.scene.control.IndexedCell 实例源码

项目:EpiStats    文件:RankingView.java   
public void scrollToVisible(int index) {
    VirtualFlow<?> flow = (VirtualFlow<?>) lookup(".virtual-flow");
    IndexedCell firstCell = flow.getFirstVisibleCell();
    if (firstCell == null)
        return;
    int first = firstCell.getIndex();
    int last = flow.getLastVisibleCell().getIndex();
    if (index <= first) {
        while (index <= first && flow.adjustPixels((index - first) - 1) < 0) {
            first = flow.getFirstVisibleCell().getIndex();
        }
    } else {
        while (index >= last && flow.adjustPixels((index - last) + 1) > 0) {
            last = flow.getLastVisibleCell().getIndex();
        }
    }
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
protected Wrap<? extends IndexedCell> getIndexedCellWrap(final String text) {

        final String styleClass = isTreeTests ? "tree-cell" : "tree-table-cell";

        Lookup<IndexedCell> lookup = testedControl.as(Parent.class, IndexedCell.class)
                .lookup(IndexedCell.class, new LookupCriteria<IndexedCell>() {
            public boolean check(IndexedCell cell) {
                return text.equals(cell.getText()) && cell.getStyleClass().contains(styleClass);
            }
        });

        final int size = lookup.size();

        testedControl.waitState(new State<Boolean>() {
            public Boolean reached() {
                if (1 == size) {
                    return Boolean.TRUE;
                } else {
                    return null;
                }
            }
        });

        return lookup.wrap();
    }
项目:openjfx-8u-dev-tests    文件:TreeViewTest.java   
@Override
public boolean check(IndexedCell control) {
    if (control.isVisible() && control.getOpacity() == 1.0) {
        if (isTreeViewTests) {
            if (control instanceof TreeCell) {
                if ((((TreeCell) control).getTreeItem() != null) && ((TreeCell) control).getTreeItem().equals(item)) {
                    return true;
                }
            }
        } else {
            if (control instanceof TreeTableCell) {
                if ((((TreeTableCell) control).getTreeTableRow().getTreeItem() != null) && ((TreeTableCell) control).getTreeTableRow().getTreeItem().equals(item)) {
                    return true;
                }
            }
        }
    }
    return false;
}
项目:main    文件:MainController.java   
/**
 * Shifts the list view on display to start with the indicated index.
 */
private void setFirstVisibleId() {
    ListViewSkin<?> listViewSkin = (ListViewSkin<?>) getCurrentListView().getSkin();
    VirtualFlow<?> virtualFlow = (VirtualFlow<?>) listViewSkin.getChildren().get(0);
    IndexedCell<?> firstVisibleCell = virtualFlow.getFirstVisibleCellWithinViewPort();
    if (firstVisibleCell != null) {
        firstVisibleId = firstVisibleCell.getIndex();
    }
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
protected Wrap getDisclosureNode(final Wrap<? extends IndexedCell> cellWrap) {

        final IndexedCell cell = cellWrap.getControl();
        final String arrowStyle = "tree-disclosure-node";

        if (TreeCell.class.isAssignableFrom(cell.getClass())) {
            return cellWrap.as(Parent.class, Node.class).lookup(new ByStyleClass(arrowStyle)).wrap();
        } else if (TreeTableCell.class.isAssignableFrom(cell.getClass())) {
            final NodeWrap<IndexedCell> nodeWrap = new NodeWrap(cellWrap.getEnvironment(), cellWrap.getControl().getParent());
            Parent cellAsParent = nodeWrap.as(Parent.class, IndexedCell.class);
            return cellAsParent.lookup(new ByStyleClass(arrowStyle)).wrap();
        } else {
            throw new IllegalStateException();
        }
    }
项目:openjfx-8u-dev-tests    文件:TableViewNewTest.java   
boolean checkSortResult(String[][] testData) {
    Boolean state = Boolean.TRUE;

    for (int j = 0; j < testData[0].length; j++) {
        final int fj = j;
        for (int i = 0; i < testData.length; i++) {
            final int fi = i;
            final Wrap<? extends IndexedCell> cellWrap = getCellWrap(j, i);
            final String expected = testData[i][j];

            state = cellWrap.waitState(new State<Boolean>() {
                public Boolean reached() {
                    String actual = cellWrap.getControl().getText();
                    if (!expected.equals(actual)) {
                        System.out.println("i = " + fi + " j = " + fj);
                        System.out.println(String.format("exp|act:%s|%s", expected, actual));
                    }
                    return expected.equals(actual) ? Boolean.TRUE : Boolean.FALSE;
                }
            });
        }

        if (Boolean.FALSE == state) {
            System.out.println(String.format("Column %d ended.", j));
        }
    }
    return state.booleanValue();
}
项目:openjfx-8u-dev-tests    文件:TableViewMultipleCellSelectionTest.java   
/**
 * Deselects selected cell with SHIFT + LEFT and then pushes this
 * combination once more to check that selection remains.
 */
@Smoke
@Test(timeout = 300000)
public void testDeselectionNearLeftBoundary() {
    enableMultipleCellSelection();

    scrollTo(0, 0);
    KeyboardModifiers ctrl = CTRL_DOWN_MASK_OS;
    Wrap<? extends IndexedCell> cellWrap = getCellWrap(0, 0);

    cellWrap.mouse().click(1, cellWrap.getClickPoint(), Mouse.MouseButtons.BUTTON1, ctrl);
    selectionHelper.click(0, 0);
    checkSelection();

    KeyboardButtons btn = KeyboardButtons.LEFT;
    KeyboardModifiers shift = KeyboardModifiers.SHIFT_DOWN_MASK;

    for (int i = 0; i < 1; i++) {
        tableViewWrap.keyboard().pushKey(btn, shift);
        selectionHelper.push(btn, shift);
    }
    checkSelection();

    //Select the entire row
    btn = KeyboardButtons.RIGHT;
    for (int i = 0; i < DATA_FIELDS_NUM; i++) {
        tableViewWrap.keyboard().pushKey(btn, shift);
        selectionHelper.push(btn, shift);
    }
    checkSelection();

    //Apply combo once more to ensure that it doesn't affect selection
    tableViewWrap.keyboard().pushKey(btn, shift);
    selectionHelper.push(btn, shift);
    checkSelection();
}
项目:openjfx-8u-dev-tests    文件:TestBaseCommon.java   
public static Wrap<? extends TableCell> getCellWrap(Wrap<? extends Control> testedControl, final int column, final int row) {
    scrollTo(testedControl, column, row);
    Lookup lookup = testedControl.as(Parent.class, Node.class).lookup(IndexedCell.class, new TableViewTest.ByPosition(column, row));
    if (lookup.size() == 0) { // TODO: what's that?!!
        scrollTo(testedControl, column, row);
        lookup.size();
    }
    return lookup.wrap();
}
项目:openjfx-8u-dev-tests    文件:TreeTableAsNewTableTest.java   
private Wrap<? extends Node> getRootAsWrap(final String rootText) {
        return parent.lookup(IndexedCell.class, new LookupCriteria<IndexedCell>() {
            public boolean check(IndexedCell cell) {
//                System.out.println("rootText = " + rootText);
//                System.out.println("cell.getText() = " + cell.getText());
//                System.out.println("cell.getStyleClass() = " + cell.getStyleClass());
//                System.out.println("cell.getStyleClass().contains(TREE_TABLE_ROW_CELL) = " + cell.getStyleClass().contains(TREE_TABLE_CELL));
                return rootText.equals(cell.getText()) && cell.getStyleClass().contains(TREE_TABLE_CELL);
            }
        }).wrap();
    }
项目:openjfx-8u-dev-tests    文件:TableUtils.java   
/**
 * Identifies which elements are shown in the TableView currently.
 *
 * @return {minColumn, minRow, maxColumn, maxRow} of cells that are fully
 * visible in the list.
 */
public static <CellClass extends IndexedCell> int[] shown(
        Environment env,
        final Wrap<? extends Control> wrap,
        final Function<CellClass, Point> infoProvider,
        final Class<CellClass> cellType) {

    final Rectangle actuallyVisibleArea = getActuallyVisibleArea(wrap);

    return shown(env, wrap, infoProvider, cellType, actuallyVisibleArea);
}
项目:openjfx-8u-dev-tests    文件:TableUtils.java   
private static <CellClass extends IndexedCell> int[] shown(
        Environment env,
        final Wrap<? extends Control> wrap,
        final Function<CellClass, Point> infoProvider,
        final Class<CellClass> cellType,
        final Rectangle actuallyVisibleArea) {
    return new FutureAction<>(env, () -> {
        final int[] res = new int[]{Integer.MAX_VALUE, Integer.MAX_VALUE, -1, -1};

        final Parent<Node> parent = wrap.as(Parent.class, Node.class);
        parent.lookup(cellType, control -> {
            if (control.isVisible() && control.getParent().isVisible() && control.getOpacity() == 1.0) {
                Rectangle bounds = NodeWrap.getScreenBounds(wrap.getEnvironment(), control);
                Point cellCoord = infoProvider.apply(control);
                int column = cellCoord.x;
                int row = cellCoord.y;
                if (actuallyVisibleArea.contains(bounds) && row >= 0 && column >= 0) {
                    res[0] = Math.min(res[0], column);
                    res[1] = Math.min(res[1], row);
                    res[2] = Math.max(res[2], column);
                    res[3] = Math.max(res[3], row);
                }
            }
            return false;
        }).size();

        return res;
    }).get();
}
项目:openjfx-8u-dev-tests    文件:TableUtils.java   
/**
 * Special for TableView, and TreeTableView, as the last column contains
 * empty not clickable space.
 */
private static Rectangle constructClickableArea(Wrap<?> wrap) {
    Rectangle rec = null;
    final Lookup lookup = wrap.as(Parent.class, Node.class).lookup(IndexedCell.class);
    for (int i = 0; i < lookup.size(); i++) {
        Wrap cell = lookup.wrap(i);
        if (rec == null) {
            rec = cell.getScreenBounds();
        } else {
            rec = rec.union(cell.getScreenBounds());
        }
    }
    return rec;
}
项目:jfx-torrent    文件:TableUtils.java   
public static <T> void applyTableRowColorization(final IndexedCell<T> tableRow) {
    if(tableRow.getIndex() % 2 != 0 && ApplicationPreferences.getProperty(
            GuiProperties.ALTERNATE_LIST_ROW_COLOR, false)) {
        tableRow.getStyleClass().removeAll(CssProperties.ALTERNATE_LIST_ROW_EVEN);
        tableRow.getStyleClass().add(CssProperties.ALTERNATE_LIST_ROW_ODD);
    }
    else {
        tableRow.getStyleClass().removeAll(CssProperties.ALTERNATE_LIST_ROW_ODD);
        tableRow.getStyleClass().add(CssProperties.ALTERNATE_LIST_ROW_EVEN);
    }
}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetIndexedCellAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(IndexedCell.class);

    assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
项目:Introspect-Framework    文件:RfxVerticalFlingScroller.java   
private static ReadOnlyDoubleProperty createTotalContentHeightProperty(ListView<?> listView) {
    return new ReadOnlyDoublePropertyBase() {

        @SuppressWarnings({ "rawtypes" })
        @Override
        public double get() {
            VirtualFlow flow = (VirtualFlow) listView.lookup(".virtual-flow");
            int nrOfItems = listView.getItems().size();
            if (nrOfItems == 0) {
                return 0;
            }
            IndexedCell cell = flow.getCell(0);
            // assuming all cells have same size
            double cellHeight = cell.getBoundsInLocal().getHeight();
            double totalContentHeight = cellHeight * nrOfItems;
            return totalContentHeight;
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public Object getBean() {
            return null;
        }
    };
}
项目:vidada-desktop    文件:GridViewViewPort.java   
/**
 * Gets the visible cell range in this GridView viewport
 * @return
 */
private IndexRange fetchVisibleCellRange(){

    IndexRange outRange = null; 

    try {
        final VirtualFlow vf = getVirtualFlow();

        if(vf != null){
            final IndexedCell firstVisibleRow = vf.getFirstVisibleCell();
            final IndexedCell lastVisibleRow = vf.getLastVisibleCell();

            if(firstVisibleRow != null && lastVisibleRow != null){
                final ObservableList<Node> firsts = firstVisibleRow.getChildrenUnmodifiable();
                final GridCell firstVisibleCell =  firsts.size() > 0 ? (GridCell)firsts.get(0) : null;
                final ObservableList<Node> lasts = lastVisibleRow.getChildrenUnmodifiable();
                final GridCell lastVisibleCell = lasts.size() > 0 ? (GridCell)lasts.get(lasts.size()-1) : null;

                outRange = new IndexRange(
                        firstVisibleCell != null ? firstVisibleCell.getIndex() : 0,
                                lastVisibleCell != null ? lastVisibleCell.getIndex() : 0);
            }
        }
    } catch (IllegalArgumentException e) {
           logger.error(e);
    }

    if(outRange == null){
        outRange = IndexRange.Undefined;
    }

    return outRange;
}
项目:Gargoyle    文件:CTableViewSkin.java   
@Override
protected CVirtualFlow createVirtualFlow() {
    CVirtualFlow<IndexedCell> cVirtualFlow = new CVirtualFlow<>();
    cVirtualFlow.init((CTableView<?>) getSkinnable());
    return cVirtualFlow;
}
项目:openjfx-8u-dev-tests    文件:TreeViewTest.java   
@Test(timeout = 600000)
@Smoke
/*
 * This test create a tree : Root -> item1 -> item2 and apply
 * collapsing/expanding operations over it. And observe, how
 * expanding/collapsing events are called for all treeItems, participating
 * in a tree.
 * When visible items are collapsed or expanded then mouse clicking is used
 * to test that one mouse click on disclosure node or double click on the node do the job.
 */
public void branchExpandedAndCollapsedTest() throws InterruptedException {
    final String ITEM_NAME = "item1";

    if (!isTreeTests) {
        switchToPropertiesTab(TREE_DATA_COLUMN_NAME);
        setPropertyBySlider(SettingType.SETTER, Properties.prefWidth, 150);
    }

    addElement(ITEM_NAME, ROOT_NAME, 0, true);
    addElement("item2", ITEM_NAME, 0, true);

    checkExpandedCollapsedCounters(0, 0, 0, 0, 0, 0);

    switchToPropertiesTab(ITEM_NAME);
    setPropertyByToggleClick(SettingType.SETTER, Properties.expanded, true);
    checkExpandedCollapsedCounters(1, 1, 0, 0, 0, 0);

    //Expand the root by single click
    final Wrap<? extends IndexedCell> wrap = parent.lookup(IndexedCell.class,
            new LookupCriteria<IndexedCell>() {
                public boolean check(IndexedCell cell) {
                    if (ROOT_NAME.equals(cell.getText())
                    && cell.getStyleClass().contains("tree-cell")) {
                        return true;
                    }
                    if (cell.getStyleClass().contains("tree-table-row-cell")) {
                        Set<Node> set = cell.lookupAll(".text");
                        for (Node node : set) {
                            if (node instanceof Text) {
                                final String text = ((Text) node).getText();
                                if (text != null && text.equals(ROOT_NAME)) {
                                    return true;
                                }
                            }
                        }
                    }
                    return false;
                }
            }).wrap();
    wrap.as(Parent.class, Node.class).lookup(new ByStyleClass("tree-disclosure-node")).wrap().mouse().click();
    checkExpandedCollapsedCounters(2, 1, 0, 0, 0, 0);

    //Collapse the item by double ckick
    getCellWrap(ITEM_NAME).mouse().click(2);
    checkExpandedCollapsedCounters(2, 1, 0, 1, 1, 0);

    switchToPropertiesTab(ROOT_NAME);
    setPropertyByToggleClick(SettingType.SETTER, Properties.expanded, false);
    checkExpandedCollapsedCounters(2, 1, 0, 2, 1, 0);

    switchToPropertiesTab(ROOT_NAME);
    setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.expanded, true);
    checkExpandedCollapsedCounters(3, 1, 0, 2, 1, 0);

    switchToPropertiesTab(ITEM_NAME);
    setPropertyByToggleClick(SettingType.BIDIRECTIONAL, Properties.expanded, true);
    checkExpandedCollapsedCounters(4, 2, 0, 2, 1, 0);

    switchToPropertiesTab(ROOT_NAME);
    setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.expanded, false);
    checkExpandedCollapsedCounters(4, 2, 0, 3, 1, 0);

    switchToPropertiesTab(ITEM_NAME);
    setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, Properties.expanded, false);
    checkExpandedCollapsedCounters(4, 2, 0, 4, 2, 0);
}
项目:openjfx-8u-dev-tests    文件:TreeViewTest.java   
/**
 * Check that the control is rendered properly when tree item children are
 * modified.
 */
@Test
public void childrenModificationImmediateRenderingTest() {

    if (!isTreeTests) {
        switchToPropertiesTab(TREE_DATA_COLUMN_NAME);
        try {
            setPropertyBySlider(SettingType.SETTER, Properties.prefWidth, 90);
        } catch (InterruptedException ex) {
            Logger.getLogger(TreeViewTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
    }

    final String PARENT_NAME = "parent";
    final LookupCriteria<IndexedCell> lookupCriterion = new LookupCriteria<IndexedCell>() {
        public boolean check(IndexedCell cell) {
            return (cell.getStyleClass().contains("tree-table-cell") || cell.getStyleClass().contains("tree-cell"))
                    && null != cell.getText()
                    && cell.getText().length() > 4
                    && "item".equals(cell.getText().substring(0, 4));
        }
    };
    final State<Integer> state = new State<Integer>() {
        public Integer reached() {
            return Integer.valueOf(parent.lookup(IndexedCell.class, lookupCriterion).size());
        }

        @Override
        public String toString() {
            return "[Expected number of cells]";
        }
    };

    addElement(PARENT_NAME, ROOT_NAME, 0, true);
    switchToPropertiesTab(ROOT_NAME);
    setPropertyByToggleClick(SettingType.SETTER, Properties.expanded, true);
    switchToPropertiesTab(PARENT_NAME);
    setPropertyByToggleClick(SettingType.SETTER, Properties.expanded, true);

    addElement("item0", PARENT_NAME, 0);
    addElement("item1", PARENT_NAME, 1);
    testedControl.waitState(state, Integer.valueOf(2));

    addElement("item2", PARENT_NAME, 2);
    testedControl.waitState(state, Integer.valueOf(3));

    removeItem("item0");
    removeItem("item1");
    testedControl.waitState(state, Integer.valueOf(1));
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
protected Wrap<? extends IndexedCell> getCellWrap(final int column, final int row) {
    return TestBaseCommon.getCellWrap(testedControl, column, row);
}
项目:openjfx-8u-dev-tests    文件:TreeViewTest.java   
@Smoke
@Test(timeout = 300000)
public void checkVerticalScrollBar() {
    final Lookup<TreeItem> lookup = expandAll();
    tree.waitState(new State() {
        public Object reached() {
            int cellSize = treeAsNodeParent.lookup(cellClass).wrap(treeAsNodeParent.lookup(cellClass).size() / 2).getScreenBounds().height;
            int listSize = tree.getScreenBounds().height;
            int enoghToHaveScroll = (int) Math.ceil(listSize / cellSize);
            MultipleSelectionHelper localSelectionHelper = new MultipleSelectionHelper(getRoot());
            int currentItemsCount = localSelectionHelper.getList().size();
            if (enoghToHaveScroll < currentItemsCount) {
                return Boolean.TRUE;
            } else {
                return null;
            }
        }
    });
    Scroll scroll = treeAsNodeParent.lookup(ScrollBar.class, new ScrollBarWrap.ByOrientationScrollBar(true)).as(Scroll.class);
    scroll.to(scroll.maximum());
    tree.waitState(new State() {
        public Object reached() {
            TreeItem lastItem = lookup.get(lookup.size() - 1);
            Wrap lastItemWrap = treeAsNodeParent.lookup(IndexedCell.class, new TreeItemByObjectLookup<Object>(lastItem)).wrap();
            if (tree.getScreenBounds().intersects(lastItemWrap.getScreenBounds())) {
                return true;
            } else {
                return null;
            }
        }
    });
    scroll.to(scroll.minimum());
    tree.waitState(new State() {
        public Object reached() {
            TreeItem firstItem = lookup.get(0);
            Wrap firstItemWrap = treeAsNodeParent.lookup(IndexedCell.class, new TreeItemByObjectLookup<Object>(firstItem)).wrap();
            if (tree.getScreenBounds().intersects(firstItemWrap.getScreenBounds())) {
                return true;
            } else {
                return null;
            }
        }
    });
}
项目:openjfx-8u-dev-tests    文件:TreeTableViewWrap.java   
protected int getRowIndex(IndexedCell tableCell) {
    return ((TreeTableCell) tableCell).getTreeTableRow().getIndex();
}
项目:openjfx-8u-dev-tests    文件:TreeTableViewWrap.java   
protected int getColumnIndex(IndexedCell tableCell) {
    return ((TreeTableCell) tableCell).getTreeTableView().getVisibleLeafIndex(((TreeTableCell) tableCell).getTableColumn());
}
项目:openjfx-8u-dev-tests    文件:TreeTableViewWrap.java   
public IndexedCell getTreeCell(TreeItem item) {
    return (TreeTableRow) new TreeTableNodeWrap<>(item, new TreeTableItemWrap<>(Object.class, item, this, null), this, null).getNode().getControl();
}