List of usage examples for javafx.scene.control TreeItem getValue
public final T getValue()
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.NavPanel.java
private void updateControllersGroup() { final TreeItem<TreeNode> selectedItem = activeTreeProperty.get().getSelectionModel().getSelectedItem(); if (selectedItem != null && selectedItem.getValue() != null && selectedItem.getValue().getGroup() != null) { controller.advance(GroupViewState.tile(selectedItem.getValue().getGroup())); }// ww w . j av a 2 s . co m }
From source file:sonicScream.models.Script.java
/** * Returns the Script's tree with everything removed but each entry's title * and its wave file list, and flattens the hierarchy. * Initializes the rootNode if it has not yet been initialized. * @param forceUpdate If true, will force the method to regenerate the simple tree from the current rootNode tree. * @return A simplified version of the Script's tree. *//*from ww w . jav a 2s . co m*/ public TreeItem<String> getSimpleTree(boolean forceUpdate) { if (_simpleRootNode != null && !forceUpdate) { return _simpleRootNode; } if (_rootNode == null) { _rootNode = getRootNode(); } TreeItem<String> local = new TreeItem<String>("root"); for (TreeItem<String> child : getRootNode().getChildren()) { List<TreeItem<String>> localWaveStrings = FXCollections.observableArrayList(); List<TreeItem<String>> waveStrings = getWaveStrings(child).orElse(null); if (waveStrings == null) continue; for (TreeItem<String> wave : waveStrings) { TreeItem<String> sound = new TreeItem<String>(); //Remove whitespace, quotes, and value# text. String waveValue = wave.getValue().trim(); int thirdQuoteIndex = StringUtils.ordinalIndexOf(waveValue, "\"", 3); waveValue = (waveValue.substring(thirdQuoteIndex + 1, waveValue.length() - 1)); sound.setValue(waveValue); localWaveStrings.add(sound); } TreeItem<String> localChild = new TreeItem<>(child.getValue()); localChild.getChildren().setAll(localWaveStrings); local.getChildren().add(localChild); } _simpleRootNode = local; return _simpleRootNode; }
From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java
private void loadImages(TreeItem<Path> treeItem) { overlayViewFlowPane.getChildren().clear(); if (treeItem != null) loadImages(treeItem.getValue().toFile()); }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java
/** * {@inheritDoc}/*from w w w.j ava 2 s . c o m*/ * * @param row * Not used! */ @Override protected String convertValueToText(final Object node, final int row) throws StepExecutionException { String result = EventThreadQueuerJavaFXImpl.invokeAndWait("convertValueToText", new Callable<String>() { //$NON-NLS-1$ @Override public String call() throws Exception { TreeItem<?> item = (TreeItem<?>) node; if (item != null) { Object val = item.getValue(); if (val != null) { return val.toString(); } } return null; } }); return result; }
From source file:sonicScream.controllers.CategoryTabController.java
public CategoryTabController(Category category) { URL location = getClass().getResource("/sonicScream/views/CategoryTab.fxml"); FXMLLoader loader = new FXMLLoader(location); loader.setRoot(this); loader.setController(this); try {/* w w w. j ava 2s . com*/ loader.load(); } catch (IOException ex) { throw new RuntimeException(ex); } _category = category; this.textProperty().bind(_category.categoryNameProperty()); CategoryTabComboBox.setItems(_category.getCategoryScripts()); //These two bindings handle changing between categories with only a single //script (items) and those with multiple (everything else) SimpleListProperty bindableList = new SimpleListProperty(); bindableList.bind(new SimpleObjectProperty<>(_category.getCategoryScripts())); CategoryTabComboBox.visibleProperty().bind(Bindings.greaterThan(bindableList.sizeProperty(), 1)); selectedScriptNodeProperty().bind(CategoryTabTreeView.getSelectionModel().selectedItemProperty()); selectedScript.bind(CategoryTabComboBox.getSelectionModel().selectedItemProperty()); if (_category.getCategoryScripts() != null && !_category.getCategoryScripts().isEmpty()) { CategoryTabComboBox.valueProperty().set(_category.getCategoryScripts().get(0)); handleComboBoxChanged(null); } SwapDisplayModeButton.textProperty().bind(Bindings.when(displayMode.isEqualTo(CategoryDisplayMode.SIMPLE)) .then("Advanced >>").otherwise("<< Simple")); CategoryTabTreeView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> { if (newValue != null) { TreeItem<String> scriptValue = TreeUtils.getRootMinusOne((TreeItem<String>) newValue); TreeItem<String> selectedValue = (TreeItem<String>) newValue; CategoryTabScriptValueLabel.setText(scriptValue.getValue()); selectedScriptNodeIsLeaf.set(selectedValue.isLeaf()); } }); }
From source file:sonicScream.models.Script.java
/** * Takes the currently active simple tree, and uses its values to update the main * rootNode tree, then returns the newly-updated tree. * @return The newly-updated tree.//from w w w .j av a 2s . c om */ public TreeItem<String> updateRootNodeWithSimpleTree() { if (_simpleRootNode == null) { return getRootNode(); } for (TreeItem<String> entry : _simpleRootNode.getChildren()) { List<TreeItem<String>> sounds = entry.getChildren(); for (int i = 0; i < sounds.size(); i++) { TreeItem<String> currentEntryInRoot = TreeUtils.findKey(_rootNode, entry.getValue()); List<TreeItem<String>> rootSounds = TreeUtils.getWaveStrings(currentEntryInRoot).orElseThrow(null); if (rootSounds != null && rootSounds.size() > i) { if (rootSounds.get(i).getValue().contains(sounds.get(i).getValue())) { continue; } String rootSoundString = rootSounds.get(i).getValue(); String soundPrefix = StringUtils.substringBetween(rootSoundString, "\"", "\""); soundPrefix = soundPrefix.substring(0, soundPrefix.length() - 1); //Remove the number from the prefix String value = "\"" + soundPrefix + i + "\" \"" + sounds.get(i).getValue() + "\""; rootSounds.get(i).setValue(value); } } } return _rootNode; }
From source file:com.heliosdecompiler.helios.gui.controller.FileTreeController.java
@FXML public void onClickTreeItem(MouseEvent event) { if (event.getClickCount() == 2) { TreeItem<TreeNode> selectedItem = this.root.getSelectionModel().getSelectedItem(); if (selectedItem != null) { if (getParentController().getAllFilesViewerController().handleClick(selectedItem.getValue())) { event.consume();/* www . ja v a2 s . co m*/ } } } }
From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeTableOperationContext.java
@Override protected String convertValueToText(final Object node, final int row) throws StepExecutionException { String result = EventThreadQueuerJavaFXImpl.invokeAndWait("convertValueToText", new Callable<String>() { //$NON-NLS-1$ @Override//from w w w .j a va 2s. c o m public String call() throws Exception { if (node instanceof TreeItem) { TreeItem<?> item = (TreeItem<?>) node; if (item != null) { Object val = item.getValue(); if (val != null) { return val.toString(); } } } return node.toString(); } }); return result; }
From source file:net.rptools.tokentool.client.TokenTool.java
/** * /* w ww . j av a 2 s. c o m*/ * @author Jamz * @throws IOException * @since 2.0 * * This method loads and processes all the overlays found in user.home/overlays and it can take a minute to load as it creates thumbnail versions for the comboBox so we call this during the * init and display progress in the preLoader (splash screen). * */ private TreeItem<Path> cacheOverlays(File dir, TreeItem<Path> parent, int THUMB_SIZE) throws IOException { TreeItem<Path> root = new TreeItem<>(dir.toPath()); root.setExpanded(false); log.debug("caching " + dir.getAbsolutePath()); File[] files = dir.listFiles(); for (File file : files) { if (file.isDirectory()) { cacheOverlays(file, root, THUMB_SIZE); } else { Path filePath = file.toPath(); TreeItem<Path> imageNode = new TreeItem<>(filePath, ImageUtil.getOverlayThumb(new ImageView(), filePath)); root.getChildren().add(imageNode); notifyPreloader(new Preloader.ProgressNotification((double) loadCount++ / overlayCount)); } } if (parent != null) { // When we show the overlay image, the TreeItem value is "" so we need to // sort those to the bottom for a cleaner look and keep sub dir's at the top. // If a node has no children then it's an overlay, otherwise it's a directory... root.getChildren().sort(new Comparator<TreeItem<Path>>() { @Override public int compare(TreeItem<Path> o1, TreeItem<Path> o2) { if (o1.getChildren().size() == 0 && o2.getChildren().size() == 0) return 0; else if (o1.getChildren().size() == 0) return Integer.MAX_VALUE; else if (o2.getChildren().size() == 0) return Integer.MIN_VALUE; else return o1.getValue().compareTo(o2.getValue()); } }); parent.getChildren().add(root); } return root; }
From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java
public ObservableList<TreeItem<JEVisClass>> getChildrenList(TreeItem<JEVisClass> item) { if (item == null || item.getValue() == null) { return FXCollections.emptyObservableList(); }//from w w w. j a va 2 s . c o m if (_itemChildren.containsKey(item)) { return _itemChildren.get(item); } ObservableList<TreeItem<JEVisClass>> list = FXCollections.observableArrayList(); try { for (JEVisClass child : item.getValue().getHeirs()) { TreeItem<JEVisClass> newItem = buildItem(child); list.add(newItem); } } catch (JEVisException ex) { Logger.getLogger(ClassTree.class.getName()).log(Level.SEVERE, null, ex); } // sortList(list); _itemChildren.put(item, list); return list; }