Beispiel #1
0
 public static List<TreePath> collectExpandedPaths(final JTree tree, TreePath path) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   if (!tree.isExpanded(path)) return result;
   final Object lastPathComponent = path.getLastPathComponent();
   final TreeModel model = tree.getModel();
   if (model.isLeaf(lastPathComponent)) {
     result.add(path);
   } else {
     boolean pathWasAdded = false;
     for (int i = model.getChildCount(lastPathComponent) - 1; i >= 0; i--) {
       final TreePath childPath = path.pathByAddingChild(model.getChild(lastPathComponent, i));
       if (model.isLeaf(lastPathComponent)) {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       } else if (tree.isExpanded(childPath)) {
         result.addAll(collectExpandedPaths(tree, childPath));
       } else {
         if (!pathWasAdded) {
           result.add(path);
           pathWasAdded = true;
         }
       }
     }
   }
   return result;
 }
Beispiel #2
0
 public static List<TreePath> collectExpandedPaths(@NotNull final JTree tree) {
   final ArrayList<TreePath> result = new ArrayList<TreePath>();
   final Object root = tree.getModel().getRoot();
   final TreePath rootPath = new TreePath(root);
   result.addAll(collectExpandedPaths(tree, rootPath));
   return result;
 }
 public Explorer() {
   super(new DynamicNode(ROOT));
   PropertiesSet preferences = PropertiesManager.getPreferencePropertiesSet();
   if (preferences != null) {
     preferences.addPrefixPropertyChangeListener(
         DisplayToolTipsOptionGroup.class,
         DisplayToolTipsOptionGroup.TOOLTIPS_FIELD_VISIBILITY_PREFIX,
         new PreferencesListener());
     Db.addDbListener(dbslistener);
     tooltipsFields.addAll(Arrays.asList(DisplayToolTipsOptionGroup.getAvailableMetaFields()));
   }
 }