Lines 88-93
Link Here
|
88 |
import org.openide.nodes.Node; |
88 |
import org.openide.nodes.Node; |
89 |
import org.openide.util.Exceptions; |
89 |
import org.openide.util.Exceptions; |
90 |
import org.openide.util.ImageUtilities; |
90 |
import org.openide.util.ImageUtilities; |
|
|
91 |
import org.openide.util.actions.SystemAction; |
91 |
import org.openide.util.datatransfer.PasteType; |
92 |
import org.openide.util.datatransfer.PasteType; |
92 |
import org.openide.util.lookup.Lookups; |
93 |
import org.openide.util.lookup.Lookups; |
93 |
|
94 |
|
Lines 125-131
Link Here
|
125 |
this.details = details; |
126 |
this.details = details; |
126 |
this.resultModel = resultModel; |
127 |
this.resultModel = resultModel; |
127 |
this.basicComposition = basicComposition; |
128 |
this.basicComposition = basicComposition; |
128 |
this.resultsNode = new ResultsNode(); |
129 |
this.resultsNode = new ResultsNode(resultModel); |
129 |
this.infoNode = infoNode; |
130 |
this.infoNode = infoNode; |
130 |
this.invisibleRoot = new RootNode(resultsNode, infoNode); |
131 |
this.invisibleRoot = new RootNode(resultsNode, infoNode); |
131 |
this.matchingObjectNodes = new LinkedList<MatchingObjectNode>(); |
132 |
this.matchingObjectNodes = new LinkedList<MatchingObjectNode>(); |
Lines 312-318
Link Here
|
312 |
private FolderTreeChildren folderTreeChildren; |
313 |
private FolderTreeChildren folderTreeChildren; |
313 |
private String htmlDisplayName = null; |
314 |
private String htmlDisplayName = null; |
314 |
|
315 |
|
315 |
public ResultsNode() { |
316 |
public ResultsNode(ResultModel model) { |
316 |
super(new FlatChildren()); |
317 |
super(new FlatChildren()); |
317 |
this.flatChildren = (FlatChildren) this.getChildren(); |
318 |
this.flatChildren = (FlatChildren) this.getChildren(); |
318 |
this.folderTreeChildren = new FolderTreeChildren(rootPathItem); |
319 |
this.folderTreeChildren = new FolderTreeChildren(rootPathItem); |
Lines 387-392
Link Here
|
387 |
*/ |
388 |
*/ |
388 |
private class FlatChildren extends Children.Keys<MatchingObject> { |
389 |
private class FlatChildren extends Children.Keys<MatchingObject> { |
389 |
|
390 |
|
|
|
391 |
public FlatChildren() { |
392 |
resultModel.addPropertyChangeListener(ResultModel.PROP_RESULTS_EDIT, |
393 |
new PropertyChangeListener() { |
394 |
@Override |
395 |
public void propertyChange(PropertyChangeEvent evt) { |
396 |
update(); |
397 |
} |
398 |
}); |
399 |
} |
400 |
|
390 |
@Override |
401 |
@Override |
391 |
protected Node[] createNodes(MatchingObject key) { |
402 |
protected Node[] createNodes(MatchingObject key) { |
392 |
return new Node[]{createNodeForMatchingObject(key)}; |
403 |
return new Node[]{createNodeForMatchingObject(key)}; |
Lines 479-489
Link Here
|
479 |
return; |
490 |
return; |
480 |
} |
491 |
} |
481 |
} |
492 |
} |
482 |
parentItem.addChild(new FolderTreeItem(matchingObject)); |
493 |
parentItem.addChild(new FolderTreeItem(matchingObject, parentItem)); |
483 |
} else { |
494 |
} else { |
484 |
try { |
495 |
try { |
485 |
FolderTreeItem newChild = new FolderTreeItem( |
496 |
FolderTreeItem newChild = new FolderTreeItem( |
486 |
DataObject.find(path.get(0))); |
497 |
DataObject.find(path.get(0)), parentItem); |
487 |
parentItem.addChild(newChild); |
498 |
parentItem.addChild(newChild); |
488 |
createInTreeView(newChild, path.subList(1, path.size()), |
499 |
createInTreeView(newChild, path.subList(1, path.size()), |
489 |
matchingObject); |
500 |
matchingObject); |
Lines 497-502
Link Here
|
497 |
|
508 |
|
498 |
private static final String PROP_SELECTED = "selected"; //NOI18N |
509 |
private static final String PROP_SELECTED = "selected"; //NOI18N |
499 |
private static final String PROP_CHILDREN = "children"; //NOI18N |
510 |
private static final String PROP_CHILDREN = "children"; //NOI18N |
|
|
511 |
private FolderTreeItem parent; |
500 |
private DataObject folder = null; |
512 |
private DataObject folder = null; |
501 |
private MatchingObject matchingObject = null; |
513 |
private MatchingObject matchingObject = null; |
502 |
private List<FolderTreeItem> children = |
514 |
private List<FolderTreeItem> children = |
Lines 508-516
Link Here
|
508 |
* Constructor for root node |
520 |
* Constructor for root node |
509 |
*/ |
521 |
*/ |
510 |
public FolderTreeItem() { |
522 |
public FolderTreeItem() { |
|
|
523 |
this.parent = null; |
511 |
} |
524 |
} |
512 |
|
525 |
|
513 |
public FolderTreeItem(MatchingObject matchingObject) { |
526 |
public FolderTreeItem(MatchingObject matchingObject, |
|
|
527 |
FolderTreeItem parent) { |
528 |
this.parent = parent; |
514 |
this.matchingObject = matchingObject; |
529 |
this.matchingObject = matchingObject; |
515 |
matchingObject.addPropertyChangeListener( |
530 |
matchingObject.addPropertyChangeListener( |
516 |
new PropertyChangeListener() { |
531 |
new PropertyChangeListener() { |
Lines 520-535
Link Here
|
520 |
if (pn.equals(MatchingObject.PROP_SELECTED)) { |
535 |
if (pn.equals(MatchingObject.PROP_SELECTED)) { |
521 |
setSelected(FolderTreeItem.this.matchingObject |
536 |
setSelected(FolderTreeItem.this.matchingObject |
522 |
.isSelected()); |
537 |
.isSelected()); |
|
|
538 |
} else if (pn.equals(MatchingObject.PROP_REMOVED)) { |
539 |
remove(); |
523 |
} |
540 |
} |
524 |
} |
541 |
} |
525 |
}); |
542 |
}); |
526 |
} |
543 |
} |
527 |
|
544 |
|
528 |
public FolderTreeItem(DataObject file) { |
545 |
public FolderTreeItem(DataObject file, FolderTreeItem parent) { |
|
|
546 |
this.parent = parent; |
529 |
this.folder = file; |
547 |
this.folder = file; |
530 |
} |
548 |
} |
531 |
|
549 |
|
532 |
void addChild(FolderTreeItem pathItem) { |
550 |
synchronized void addChild(FolderTreeItem pathItem) { |
533 |
children.add(pathItem); |
551 |
children.add(pathItem); |
534 |
firePropertyChange(PROP_CHILDREN, null, null); |
552 |
firePropertyChange(PROP_CHILDREN, null, null); |
535 |
} |
553 |
} |
Lines 538-545
Link Here
|
538 |
return folder; |
556 |
return folder; |
539 |
} |
557 |
} |
540 |
|
558 |
|
541 |
public List<FolderTreeItem> getChildren() { |
559 |
public synchronized List<FolderTreeItem> getChildren() { |
542 |
return children; |
560 |
return new ArrayList<FolderTreeItem>(children); |
|
|
561 |
} |
562 |
|
563 |
public synchronized void remove() { |
564 |
// remove children first, then... |
565 |
// NOTE uses a copy of the children to prevent a ConcurrentModifcationException |
566 |
for (FolderTreeItem fti : new ArrayList<FolderTreeItem>(children)) { |
567 |
if (fti.isPathLeaf()) { |
568 |
// remove the matching node |
569 |
fti.getMatchingObject().remove(); |
570 |
} else { |
571 |
// remove all folder children - starts a recursion |
572 |
fti.remove(); |
573 |
} |
574 |
} |
575 |
// ... then try to remove itself |
576 |
if (parent != null) { |
577 |
parent.removeChild(this); |
578 |
} |
579 |
} |
580 |
|
581 |
private synchronized void removeChild(FolderTreeItem child) { |
582 |
boolean result = children.remove(child); |
583 |
if (result) { |
584 |
child.parent = null; |
585 |
} |
586 |
if (children.isEmpty() && parent != null) { |
587 |
remove(); |
588 |
} else { |
589 |
firePropertyChange(PROP_CHILDREN, null, null); |
590 |
} |
543 |
} |
591 |
} |
544 |
|
592 |
|
545 |
public MatchingObject getMatchingObject() { |
593 |
public MatchingObject getMatchingObject() { |
Lines 607-613
Link Here
|
607 |
@Override |
655 |
@Override |
608 |
public void propertyChange(PropertyChangeEvent evt) { |
656 |
public void propertyChange(PropertyChangeEvent evt) { |
609 |
fireIconChange(); |
657 |
fireIconChange(); |
610 |
toggleParentSelected(FolderTreeNode.this); |
658 |
String prop = evt.getPropertyName(); |
|
|
659 |
if (prop.equals(FolderTreeItem.PROP_SELECTED)) { |
660 |
toggleParentSelected( |
661 |
FolderTreeNode.this.getParentNode()); |
662 |
} else if (prop.equals(FolderTreeItem.PROP_CHILDREN)) { |
663 |
toggleParentSelected(FolderTreeNode.this); |
664 |
} |
611 |
} |
665 |
} |
612 |
}); |
666 |
}); |
613 |
if (!pathItem.isPathLeaf()) { |
667 |
if (!pathItem.isPathLeaf()) { |
Lines 627-639
Link Here
|
627 |
} |
681 |
} |
628 |
|
682 |
|
629 |
@Override |
683 |
@Override |
|
|
684 |
public boolean canDestroy () { |
685 |
return true; |
686 |
} |
687 |
|
688 |
@Override |
689 |
public void destroy () throws IOException { |
690 |
FolderTreeItem folder = this.getLookup().lookup(FolderTreeItem.class); |
691 |
folder.remove(); |
692 |
} |
693 |
|
694 |
@Override |
630 |
public Transferable drag() throws IOException { |
695 |
public Transferable drag() throws IOException { |
631 |
return UiUtils.DISABLE_TRANSFER; |
696 |
return UiUtils.DISABLE_TRANSFER; |
632 |
} |
697 |
} |
633 |
|
698 |
|
634 |
@Override |
699 |
@Override |
635 |
public Action[] getActions(boolean context) { |
700 |
public Action[] getActions(boolean context) { |
636 |
return new Action[0]; |
701 |
return new Action[]{SystemAction.get(HideResultAction.class)}; |
637 |
} |
702 |
} |
638 |
} |
703 |
} |
639 |
|
704 |
|
Lines 675-682
Link Here
|
675 |
} |
740 |
} |
676 |
} |
741 |
} |
677 |
|
742 |
|
678 |
public static void toggleParentSelected(Node node) { |
743 |
public static void toggleParentSelected(Node parent) { |
679 |
Node parent = node.getParentNode(); |
|
|
680 |
if (parent == null) { |
744 |
if (parent == null) { |
681 |
return; |
745 |
return; |
682 |
} |
746 |
} |