Lines 53-58
Link Here
|
53 |
import java.beans.PropertyChangeSupport; |
53 |
import java.beans.PropertyChangeSupport; |
54 |
import java.io.IOException; |
54 |
import java.io.IOException; |
55 |
import java.util.ArrayList; |
55 |
import java.util.ArrayList; |
|
|
56 |
import java.util.Collection; |
56 |
import java.util.Collections; |
57 |
import java.util.Collections; |
57 |
import java.util.Enumeration; |
58 |
import java.util.Enumeration; |
58 |
import java.util.LinkedList; |
59 |
import java.util.LinkedList; |
Lines 73-78
Link Here
|
73 |
import org.netbeans.modules.search.MatchingObject; |
74 |
import org.netbeans.modules.search.MatchingObject; |
74 |
import org.netbeans.modules.search.ResultModel; |
75 |
import org.netbeans.modules.search.ResultModel; |
75 |
import org.netbeans.modules.search.Selectable; |
76 |
import org.netbeans.modules.search.Selectable; |
|
|
77 |
import org.netbeans.modules.search.TextDetail; |
76 |
import org.netbeans.modules.search.ui.AbstractSearchResultsPanel.RootNode; |
78 |
import org.netbeans.modules.search.ui.AbstractSearchResultsPanel.RootNode; |
77 |
import org.netbeans.swing.etable.ETableColumnModel; |
79 |
import org.netbeans.swing.etable.ETableColumnModel; |
78 |
import org.netbeans.swing.outline.Outline; |
80 |
import org.netbeans.swing.outline.Outline; |
Lines 95-101
Link Here
|
95 |
* |
97 |
* |
96 |
* @author jhavlin |
98 |
* @author jhavlin |
97 |
*/ |
99 |
*/ |
98 |
public class ResultsOutlineSupport { |
100 |
public class ResultsOutlineSupport implements PropertyChangeListener { |
99 |
|
101 |
|
100 |
@StaticResource |
102 |
@StaticResource |
101 |
private static final String ROOT_NODE_ICON = |
103 |
private static final String ROOT_NODE_ICON = |
Lines 125-135
Link Here
|
125 |
this.details = details; |
127 |
this.details = details; |
126 |
this.resultModel = resultModel; |
128 |
this.resultModel = resultModel; |
127 |
this.basicComposition = basicComposition; |
129 |
this.basicComposition = basicComposition; |
128 |
this.resultsNode = new ResultsNode(); |
130 |
this.resultsNode = new ResultsNode(resultModel); |
129 |
this.infoNode = infoNode; |
131 |
this.infoNode = infoNode; |
130 |
this.invisibleRoot = new RootNode(resultsNode, infoNode); |
132 |
this.invisibleRoot = new RootNode(resultsNode, infoNode); |
131 |
this.matchingObjectNodes = new LinkedList<MatchingObjectNode>(); |
133 |
this.matchingObjectNodes = new LinkedList<MatchingObjectNode>(); |
132 |
createOutlineView(); |
134 |
createOutlineView(); |
|
|
135 |
this.resultModel.addPropertyChangeListener( |
136 |
ResultModel.PROP_REMOVED, this); |
137 |
} |
138 |
|
139 |
@Override |
140 |
@SuppressWarnings("unchecked") |
141 |
public void propertyChange(PropertyChangeEvent evt) { |
142 |
List<MatchingObject> items = (List<MatchingObject>) evt.getOldValue(); |
143 |
|
144 |
//support folders (multiple matching objects) or single matching objects |
145 |
for (MatchingObject mo : items) { |
146 |
removedMatchingObject(mo); |
147 |
} |
148 |
|
149 |
// rebuild the tree from the modified model |
150 |
this.update(); |
133 |
} |
151 |
} |
134 |
|
152 |
|
135 |
private void createOutlineView() { |
153 |
private void createOutlineView() { |
Lines 312-321
Link Here
|
312 |
private FolderTreeChildren folderTreeChildren; |
330 |
private FolderTreeChildren folderTreeChildren; |
313 |
private String htmlDisplayName = null; |
331 |
private String htmlDisplayName = null; |
314 |
|
332 |
|
315 |
public ResultsNode() { |
333 |
public ResultsNode(ResultModel model) { |
316 |
super(new FlatChildren()); |
334 |
super(new FlatChildren()); |
317 |
this.flatChildren = (FlatChildren) this.getChildren(); |
335 |
this.flatChildren = (FlatChildren) this.getChildren(); |
318 |
this.folderTreeChildren = new FolderTreeChildren(rootPathItem); |
336 |
this.folderTreeChildren = |
|
|
337 |
new FolderTreeChildren(rootPathItem, model); |
319 |
} |
338 |
} |
320 |
|
339 |
|
321 |
void update() { |
340 |
void update() { |
Lines 412-419
Link Here
|
412 |
} else { |
431 |
} else { |
413 |
children = key.getDetailsChildren(replacing); |
432 |
children = key.getDetailsChildren(replacing); |
414 |
} |
433 |
} |
415 |
MatchingObjectNode mon = |
434 |
MatchingObjectNode mon = new MatchingObjectNode( |
416 |
new MatchingObjectNode(delegate, children, key, replacing); |
435 |
delegate, children, key, replacing, resultModel); |
417 |
synchronized (this) { |
436 |
synchronized (this) { |
418 |
if (!closed) { |
437 |
if (!closed) { |
419 |
matchingObjectNodes.add(mon); |
438 |
matchingObjectNodes.add(mon); |
Lines 444-449
Link Here
|
444 |
} |
463 |
} |
445 |
return rootFiles; |
464 |
return rootFiles; |
446 |
} |
465 |
} |
|
|
466 |
public synchronized void removedMatchingObject(MatchingObject mo) { |
467 |
if (closed) { |
468 |
return; |
469 |
} |
470 |
removeFilesFromTreeView(rootPathItem, mo); |
471 |
removeEmptyFoldersFromTreeView(rootPathItem); |
472 |
} |
473 |
|
474 |
public synchronized void removedTextDetail(TextDetail detail) { |
475 |
if (closed) { |
476 |
return; |
477 |
} |
478 |
// removeFilesFromTreeView(rootPathItem, mo); |
479 |
removeEmptyFoldersFromTreeView(rootPathItem); |
480 |
} |
447 |
|
481 |
|
448 |
private List<FileObject> getRelativePath(FileObject parent, FileObject fo) { |
482 |
private List<FileObject> getRelativePath(FileObject parent, FileObject fo) { |
449 |
List<FileObject> l = new LinkedList<FileObject>(); |
483 |
List<FileObject> l = new LinkedList<FileObject>(); |
Lines 458-463
Link Here
|
458 |
return l; |
492 |
return l; |
459 |
} |
493 |
} |
460 |
|
494 |
|
|
|
495 |
private void removeFilesFromTreeView(FolderTreeItem parentItem, |
496 |
MatchingObject matchingObject) { |
497 |
List<FolderTreeItem> removeableItems = new ArrayList<FolderTreeItem>(); |
498 |
|
499 |
for (FolderTreeItem pi : parentItem.getChildren()) { |
500 |
if (!pi.isPathLeaf()) { |
501 |
//start recursion for folders |
502 |
removeFilesFromTreeView(pi, matchingObject); |
503 |
} else { |
504 |
if (pi.getMatchingObject().equals(matchingObject)) { |
505 |
// collect all the files which have to be removed |
506 |
removeableItems.add(pi); |
507 |
} |
508 |
} |
509 |
} |
510 |
parentItem.removeChildren(removeableItems); |
511 |
} |
512 |
|
513 |
private void removeEmptyFoldersFromTreeView(FolderTreeItem parentItem) { |
514 |
List<FolderTreeItem> emptyFolders = new ArrayList<FolderTreeItem>(); |
515 |
|
516 |
for (FolderTreeItem pi : parentItem.getChildren()) { |
517 |
{ |
518 |
// start recursion |
519 |
removeEmptyFoldersFromTreeView(pi); |
520 |
|
521 |
if (pi.getChildren().isEmpty() |
522 |
&& null == pi.getMatchingObject()) { |
523 |
// collect all the empty folders which have to be removed |
524 |
emptyFolders.add(pi); |
525 |
} |
526 |
} |
527 |
} |
528 |
// remove empty folders |
529 |
parentItem.removeChildren(emptyFolders); |
530 |
} |
531 |
|
461 |
private void addToTreeView(FolderTreeItem parentItem, List<FileObject> path, |
532 |
private void addToTreeView(FolderTreeItem parentItem, List<FileObject> path, |
462 |
MatchingObject matchingObject) { |
533 |
MatchingObject matchingObject) { |
463 |
for (FolderTreeItem pi : parentItem.getChildren()) { |
534 |
for (FolderTreeItem pi : parentItem.getChildren()) { |
Lines 542-547
Link Here
|
542 |
return children; |
613 |
return children; |
543 |
} |
614 |
} |
544 |
|
615 |
|
|
|
616 |
public boolean removeChildren (Collection<FolderTreeItem> list) { |
617 |
boolean result = children.removeAll(list); |
618 |
firePropertyChange(PROP_CHILDREN, null, null); |
619 |
return result; |
620 |
} |
621 |
|
545 |
public MatchingObject getMatchingObject() { |
622 |
public MatchingObject getMatchingObject() { |
546 |
return matchingObject; |
623 |
return matchingObject; |
547 |
} |
624 |
} |
Lines 596-608
Link Here
|
596 |
} |
673 |
} |
597 |
|
674 |
|
598 |
private class FolderTreeNode extends FilterNode { |
675 |
private class FolderTreeNode extends FilterNode { |
|
|
676 |
private ResultModel model; |
599 |
|
677 |
|
600 |
public FolderTreeNode(FolderTreeItem pathItem) { |
678 |
public FolderTreeNode(FolderTreeItem pathItem, ResultModel model) { |
601 |
super(pathItem.getFolder().getNodeDelegate(), |
679 |
super(pathItem.getFolder().getNodeDelegate(), |
602 |
new FolderTreeChildren(pathItem), |
680 |
new FolderTreeChildren(pathItem, model), |
603 |
Lookups.fixed(pathItem, |
681 |
Lookups.fixed(pathItem, |
604 |
new ReplaceCheckableNode(pathItem, replacing), |
682 |
new ReplaceCheckableNode(pathItem, replacing), |
605 |
pathItem.getFolder().getPrimaryFile())); |
683 |
pathItem.getFolder().getPrimaryFile())); |
|
|
684 |
this.model=model; |
606 |
pathItem.addPropertyChangeListener(new PropertyChangeListener() { |
685 |
pathItem.addPropertyChangeListener(new PropertyChangeListener() { |
607 |
@Override |
686 |
@Override |
608 |
public void propertyChange(PropertyChangeEvent evt) { |
687 |
public void propertyChange(PropertyChangeEvent evt) { |
Lines 627-632
Link Here
|
627 |
} |
706 |
} |
628 |
|
707 |
|
629 |
@Override |
708 |
@Override |
|
|
709 |
public boolean canDestroy () { |
710 |
return true; |
711 |
} |
712 |
|
713 |
@Override |
714 |
public void destroy () throws IOException { |
715 |
//FIXME alter the model |
716 |
FolderTreeItem folder = |
717 |
this.getLookup().lookup(FolderTreeItem.class); |
718 |
this.model.removeFolder(folder.getFolder()); |
719 |
// this.resultModel.remove(this.getLookup().lookup(FolderTreeItem.class)); |
720 |
} |
721 |
|
722 |
@Override |
630 |
public Transferable drag() throws IOException { |
723 |
public Transferable drag() throws IOException { |
631 |
return UiUtils.DISABLE_TRANSFER; |
724 |
return UiUtils.DISABLE_TRANSFER; |
632 |
} |
725 |
} |
Lines 640-647
Link Here
|
640 |
private class FolderTreeChildren extends Children.Keys<FolderTreeItem> { |
733 |
private class FolderTreeChildren extends Children.Keys<FolderTreeItem> { |
641 |
|
734 |
|
642 |
private FolderTreeItem item = null; |
735 |
private FolderTreeItem item = null; |
|
|
736 |
private final ResultModel model; |
643 |
|
737 |
|
644 |
public FolderTreeChildren(FolderTreeItem pathItem) { |
738 |
public FolderTreeChildren(FolderTreeItem pathItem, ResultModel model) { |
645 |
this.item = pathItem; |
739 |
this.item = pathItem; |
646 |
pathItem.addPropertyChangeListener(new PropertyChangeListener() { |
740 |
pathItem.addPropertyChangeListener(new PropertyChangeListener() { |
647 |
@Override |
741 |
@Override |
Lines 652-657
Link Here
|
652 |
} |
746 |
} |
653 |
} |
747 |
} |
654 |
}); |
748 |
}); |
|
|
749 |
this.model = model; |
655 |
} |
750 |
} |
656 |
|
751 |
|
657 |
@Override |
752 |
@Override |
Lines 669-675
Link Here
|
669 |
if (key.isPathLeaf()) { |
764 |
if (key.isPathLeaf()) { |
670 |
n = createNodeForMatchingObject(key.getMatchingObject()); |
765 |
n = createNodeForMatchingObject(key.getMatchingObject()); |
671 |
} else { |
766 |
} else { |
672 |
n = new FolderTreeNode(key); |
767 |
n = new FolderTreeNode(key, model); |
673 |
} |
768 |
} |
674 |
return new Node[]{n}; |
769 |
return new Node[]{n}; |
675 |
} |
770 |
} |