List of usage examples for javafx.scene.control TreeItem equals
public boolean equals(Object obj)
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java
private void initializeFilesTree() { folderTree.setOnMouseClicked(event -> handleFolderChange()); folderTree.setCellFactory(treeView -> { HBox hbox = new HBox(); hbox.setMaxWidth(200);/*from w ww . ja v a 2 s.c o m*/ hbox.setPrefWidth(200); hbox.setSpacing(7); FontAwesomeIconView openFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN_ALT); openFolderIcon.setTranslateY(7); FontAwesomeIconView closedFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT); closedFolderIcon.setTranslateY(7); Label dirName = new Label(); dirName.setMaxWidth(150); FontAwesomeIconView removeIcon = new FontAwesomeIconView(FontAwesomeIcon.REMOVE); Tooltip deleteToolTip = new Tooltip(); deleteToolTip.setText("Verzeichnis aus Workspace entfernen"); Button button = new Button(null, removeIcon); button.setTooltip(deleteToolTip); button.setTranslateX(8); return new TreeCell<String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); setText(null); } else if (getTreeItem() instanceof FilePathTreeItem) { hbox.getChildren().clear(); dirName.setText(item); if (getTreeItem().isExpanded()) { hbox.getChildren().add(openFolderIcon); } else { hbox.getChildren().add(closedFolderIcon); } hbox.getChildren().add(dirName); TreeItem<String> treeItem = getTreeItem(); TreeItem<String> parent = treeItem != null ? treeItem.getParent() : null; if (parent != null && parent.equals(folderTree.getRoot())) { String path = ((FilePathTreeItem) getTreeItem()).getFullPath(); button.setOnAction(event -> handleDeleteDirectory(Paths.get(path))); hbox.getChildren().add(button); } setGraphic(hbox); } } }; }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java
@Override public String getRenderedText(final Object node) throws StepExecutionException { String result = EventThreadQueuerJavaFXImpl.invokeAndWait("getRenderedText", new Callable<String>() { //$NON-NLS-1$ @Override//from ww w . j a va 2s. co m public String call() throws Exception { List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class); for (TreeCell<?> cell : tCells) { TreeItem<?> item = cell.getTreeItem(); if (item != null && item.equals(node)) { return cell.getText(); } } return null; } }); return result; }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java
@Override public void expandNode(final Object node) { scrollNodeToVisible(node);/*from w w w . j a v a 2s . c o m*/ Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("expandNode", //$NON-NLS-1$ new Callable<Object>() { @Override public Object call() throws Exception { List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class); for (TreeCell<?> cell : tCells) { TreeItem<?> item = cell.getTreeItem(); if (item != null && item.equals(node) && !item.isExpanded()) { TreeView<?> tree = ((TreeView<?>) getTree()); // Update the layout coordinates otherwise // we would get old position values tree.layout(); return cell.getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("expandNodeCheckIfExpanded", //$NON-NLS-1$ new Callable<Void>() { @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!((TreeView<?>) getTree()).isDisabled() && !item.isExpanded()) { log.warn("Expand node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(true); } return null; } }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java
@Override public void collapseNode(final Object node) { scrollNodeToVisible(node);// w w w .j a v a 2 s . co m Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNode", new Callable<Object>() { //$NON-NLS-1$ @Override public Object call() throws Exception { List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class); for (TreeCell<?> cell : tCells) { TreeItem<?> item = cell.getTreeItem(); if (item != null && item.equals(node) && item.isExpanded()) { TreeView<?> tree = ((TreeView<?>) getTree()); // Update the layout coordinates otherwise // we would get old position values tree.layout(); return cell.getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNodeCheckIfCollapsed", new Callable<Void>() { //$NON-NLS-1$ @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!((TreeView<?>) getTree()).isDisabled() && item.isExpanded()) { log.warn("Collapse node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(false); } return null; } }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java
@Override public Rectangle getNodeBounds(final Object node) { Rectangle result = EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$ @Override//from w w w . j a v a2 s . co m public Rectangle call() throws Exception { List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class); for (TreeCell<?> cell : tCells) { TreeItem<?> item = cell.getTreeItem(); TreeView<?> tree = (TreeView<?>) getTree(); if ((item != null && item.equals(node))) { // Update the layout coordinates otherwise // we would get old position values tree.layout(); Point2D posTree = tree.localToScreen(0, 0); Point2D posCell = cell.localToScreen(0, 0); Bounds b = cell.getBoundsInParent(); Rectangle cBounds = new Rectangle( Math.abs(Rounding.round((posCell.getX() - posTree.getX()))), Math.abs(Rounding.round((posCell.getY() - posTree.getY()))), Rounding.round(b.getWidth()), Rounding.round(b.getHeight())); return cBounds; } } return null; } }); return result; }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
/** * Gets the rendered text of a TreeTableCell * //from ww w.j a v a2 s .c o m * @param node * this can be a cell or a tree item * @param col * if node is a tree item this parameter is used to find the cell * to get the rendered text from * @return the rendered text */ private String getRenderedTextFromCell(final Object node, final int col) { if (node instanceof TreeItem<?>) { scrollNodeToVisible(node); } String result = EventThreadQueuerJavaFXImpl.invokeAndWait("getRenderedText", new Callable<String>() { //$NON-NLS-1$ @Override public String call() throws Exception { if (node instanceof TreeTableCell) { TreeTableCell<?, ?> cell = (TreeTableCell<?, ?>) node; return cell.getText(); } else if (node instanceof TreeItem) { TreeItem<?> item = (TreeItem<?>) node; TreeTableView<?> treeTable = getTree(); List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>().getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> cell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = cell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && treeTable.getColumns().indexOf(cell.getTableColumn()) == col) { return cell.getText(); } } } return null; } }); return result; }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override public void expandNode(final Object node) { scrollNodeToVisible(node);//from www . j av a 2 s . c o m Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("expandNode", //$NON-NLS-1$ new Callable<Object>() { @Override public Object call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; TreeTableView<?> treeTable = getTree(); List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>() .getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> treeTableCell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && !item.isExpanded()) { return treeTableCell.getTreeTableRow().getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("expandNodeCheckIfExpanded", //$NON-NLS-1$ new Callable<Void>() { @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!getTree().isDisabled() && !item.isExpanded()) { log.warn("Expand node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(true); } return null; } }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override public void collapseNode(final Object node) { scrollNodeToVisible(node);/*from ww w . j ava2s.c o m*/ Object result = EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNode", //$NON-NLS-1$ new Callable<Object>() { @Override public Object call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; TreeTableView<?> treeTable = getTree(); List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>() .getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> treeTableCell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = treeTableCell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && item.isExpanded()) { return treeTableCell.getTreeTableRow().getDisclosureNode(); } } return null; } }); if (result != null) { getRobot().click(result, null, ClickOptions.create().setClickCount(1).setMouseButton(1)); } EventThreadQueuerJavaFXImpl.invokeAndWait("collapseNodeCheckIfExpanded", //$NON-NLS-1$ new Callable<Void>() { @Override public Void call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (!getTree().isDisabled() && item.isExpanded()) { log.warn("Expand node fallback used for: " //$NON-NLS-1$ + item.getValue()); item.setExpanded(true); } return null; } }); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override public Rectangle getNodeBounds(final Object node) { scrollNodeToVisible(node);/* w ww .j av a 2 s . com*/ return EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$ @Override public Rectangle call() throws Exception { TreeTableView<?> treeTable = getTree(); treeTable.layout(); TreeItem<?> item = (TreeItem<?>) node; List<TreeTableCell> cells = new NodeTraverseHelper<TreeTableCell>().getInstancesOf(treeTable, TreeTableCell.class); for (TreeTableCell<?, ?> cell : cells) { // Nullchecks because of the virtual flow cells // are created which might not be associated // with a row or an item TreeTableRow<?> ttRow = cell.getTreeTableRow(); if (ttRow == null) { continue; } TreeItem<?> checkItem = ttRow.getTreeItem(); if (checkItem == null) { continue; } if (item != null && checkItem.equals(item) && treeTable.getColumns().indexOf(cell.getTableColumn()) == m_column) { Rectangle b = NodeBounds.getAbsoluteBounds(cell); Rectangle treeB = NodeBounds.getAbsoluteBounds(treeTable); return new Rectangle(Math.abs(treeB.x - b.x), Math.abs(treeB.y - b.y), Rounding.round(b.getWidth()), Rounding.round(b.getHeight())); } } return null; } }); }