use of javafx.scene.control.TreeItem in project dwoss by gg-net.
the class TreeTableController method getProductGroups.
private ObservableList<TreeItem<DataWrapper>> getProductGroups(TradeName tradeName) {
ObservableList<TreeItem<DataWrapper>> result = FXCollections.observableArrayList();
for (ProductGroup group : ProductGroup.values()) {
TreeItem<DataWrapper> item = new TreeItem<>();
ProductGroupWrapper productGroupWrapper = new ProductGroupWrapper(group, tradeName, item);
item.setValue(productGroupWrapper);
item.getChildren().add(loading);
item.expandedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (productGroupWrapper.isLoading()) {
return;
}
productGroupWrapper.setLoading(true);
new Thread(new Runnable() {
@Override
public void run() {
item.getChildren().addAll(getCategoryProducts(productGroupWrapper.getTradeName(), productGroupWrapper.getProductGroup()));
item.getChildren().remove(loading);
}
}).start();
L.info("Products loaded");
}
});
result.add(item);
}
return result;
}
use of javafx.scene.control.TreeItem in project Smartcity-Smarthouse by TechnionYP5777.
the class MainSystemGuiController method setupFSTreeView.
private void setupFSTreeView(SystemCore model) {
TreeItem<String> rootElement = new TreeItem<>("File System View");
rootElement.setExpanded(true);
createTree(model.getFileSystem().getReadOnlyFileSystem(), rootElement);
TreeTableColumn<String, String> fsViewCol = new TreeTableColumn<>();
fsViewCol.prefWidthProperty().bind(fsTreeView.widthProperty());
fsViewCol.setCellValueFactory((CellDataFeatures<String, String> p) -> new ReadOnlyStringWrapper(p.getValue().getValue()));
fsTreeView.setRoot(rootElement);
fsTreeView.getColumns().add(fsViewCol);
mainSplitPane.getItems().add(fsTreeView);
mainSplitPane.getDividers().get(0).setPosition(0.7);
}
use of javafx.scene.control.TreeItem in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketViewerController method buildPacketDetailTree.
/**
* Build packet detail tree
*
* @param packetData
*/
private void buildPacketDetailTree(String packetData) {
String[] mainNode = packetData.split("\n");
TreeItem root = new TreeItem();
packetDetailTree.setRoot(root);
packetDetailTree.setShowRoot(false);
for (String node : mainNode) {
node = node.replaceAll("\r", "").trim();
if ("[".equals(node.substring(0, 1))) {
TreeItem subRoot = new TreeItem(node);
root.getChildren().add(subRoot);
} else {
TreeItem sub = new TreeItem(node);
((TreeItem) root.getChildren().get(root.getChildren().size() - 1)).getChildren().add(sub);
}
}
}
use of javafx.scene.control.TreeItem in project tokentool by RPTools.
the class TokenTool_Controller method cacheOverlays.
private TreeItem<Path> cacheOverlays(File dir, TreeItem<Path> parent, int THUMB_SIZE) throws IOException {
log.debug("Caching " + dir.getAbsolutePath());
TreeItem<Path> root = new TreeItem<>(dir.toPath());
root.setExpanded(false);
File[] files = dir.listFiles();
final String I18N_CACHE_TEXT = I18N.getString("TokenTool.treeview.caching");
final Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
for (File file : files) {
if (loadOverlaysThread.isInterrupted())
break;
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);
loadCount.getAndIncrement();
overlayTreeProgressBar.progressProperty().set(loadCount.doubleValue() / overlayCount);
}
}
if (parent != null) {
// When we show the overlay image, the TreeItem value is empty 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);
parent.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());
}
});
}
return null;
}
};
overlayTreeProgressBar.progressProperty().addListener(observable -> {
Platform.runLater(() -> progressBarLabel.setText(I18N_CACHE_TEXT + Math.round(overlayCount - loadCount.doubleValue()) + "..."));
});
// Only add this listener to the parent task so it's only called once
if (parent == null) {
overlayTreeProgressBar.progressProperty().addListener(observable -> {
Platform.runLater(() -> {
if (overlayTreeProgressBar.getProgress() >= 1)
treeViewFinish();
});
});
}
executorService.execute(task);
return root;
}
use of javafx.scene.control.TreeItem in project tokentool by RPTools.
the class TokenTool method cacheOverlays.
/**
* @author Jamz
* @throws IOException
* @since 2.0
* <p>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;
}
Aggregations