}
public void reloadData() {
- final TreeSnapshot snapshot = new TreeSnapshot(tree);
+ final TreeSnapshot snapshot = new TreeSnapshot(tree) {
+ @Override
+ protected boolean isSamePath(TreePath oldPath, TreePath newPath) {
+ String oldString = oldPath.toString();
+ if (oldString.endsWith("/]"))
+ oldString = oldString.substring(0, oldString.length() - 2) + "]";
+
+ String newString = newPath.toString();
+ if (newString.endsWith("/]"))
+ newString = newString.substring(0, newString.length() - 2) + "]";
+
+ return oldString.equals(newString);
+ }
+ };
SwingWorker<Map<String, List<String>>, Integer> worker = new SwingWorker<Map<String, List<String>>, Integer>() {
@Override
protected Map<String, List<String>> doInBackground() throws Exception {
}
String display = value == null ? "" : value.toString();
- if (!display.isEmpty())
- display = keyToDisplay(display);
+ display = keyToDisplay(display);
return super.getTreeCellRendererComponent(tree, display, selected, expanded, leaf, row, hasFocus);
}
TreePath newPath = nodeToPath(newNode);
if (newPath != null) {
for (TreePath path : selectionPaths) {
- if (newPath.toString().equals(path.toString())) {
+ if (isSamePath(path, newPath)) {
newSlectionPaths.add(newPath);
if (expanded.contains(path)) {
newExpanded.add(newPath);
tree.setSelectionPaths(newSlectionPaths.toArray(new TreePath[0]));
}
+ // You can override this
+ protected boolean isSamePath(TreePath oldPath, TreePath newPath) {
+ return newPath.toString().equals(oldPath.toString());
+ }
+
private void forEach(JTree tree, NodeAction action) {
forEach(tree.getModel(), tree.getModel().getRoot(), action);
}