This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 200020
Collapse All | Expand All

(-)a/api.search/src/org/netbeans/modules/search/MatchingObject.java (-4 / +7 lines)
Lines 535-548 Link Here
535
535
536
        List<Node> detailNodes = new ArrayList<Node>(textDetails.size());
536
        List<Node> detailNodes = new ArrayList<Node>(textDetails.size());
537
        for (TextDetail txtDetail : textDetails) {
537
        for (TextDetail txtDetail : textDetails) {
538
            detailNodes.add(new TextDetail.DetailNode(txtDetail, false));
538
            detailNodes.add(
539
                    new TextDetail.DetailNode(txtDetail, false, resultModel));
539
        }
540
        }
540
541
541
        return detailNodes.toArray(new Node[detailNodes.size()]);
542
        return detailNodes.toArray(new Node[detailNodes.size()]);
542
    }
543
    }
543
544
544
    public Children getDetailsChildren(boolean replacing) {
545
    public Children getDetailsChildren(boolean replacing) {
545
        return new DetailsChildren(replacing);
546
        return new DetailsChildren(replacing, resultModel);
546
    }
547
    }
547
548
548
    /**
549
    /**
Lines 1032-1046 Link Here
1032
    private class DetailsChildren extends Children.Keys<TextDetail> {
1033
    private class DetailsChildren extends Children.Keys<TextDetail> {
1033
1034
1034
        private boolean replacing;
1035
        private boolean replacing;
1036
        private final ResultModel model;
1035
1037
1036
        public DetailsChildren(boolean replacing) {
1038
        public DetailsChildren(boolean replacing, ResultModel model) {
1037
            this.replacing = replacing;
1039
            this.replacing = replacing;
1038
            setKeys(getTextDetails());
1040
            setKeys(getTextDetails());
1041
            this.model = model;
1039
        }
1042
        }
1040
1043
1041
        @Override
1044
        @Override
1042
        protected Node[] createNodes(TextDetail key) {
1045
        protected Node[] createNodes(TextDetail key) {
1043
            return new Node[]{new TextDetail.DetailNode(key, replacing)};
1046
            return new Node[]{new TextDetail.DetailNode(key, replacing, model)};
1044
        }
1047
        }
1045
    }
1048
    }
1046
1049
(-)a/api.search/src/org/netbeans/modules/search/ResultModel.java (-1 / +78 lines)
Lines 48-59 Link Here
48
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeListener;
49
import java.beans.PropertyChangeSupport;
49
import java.beans.PropertyChangeSupport;
50
import java.nio.charset.Charset;
50
import java.nio.charset.Charset;
51
import java.util.ArrayList;
52
import java.util.Arrays;
51
import java.util.List;
53
import java.util.List;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
52
import javax.swing.event.ChangeEvent;
56
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.ChangeListener;
57
import javax.swing.event.ChangeListener;
54
import org.netbeans.modules.search.Constants.Limit;
58
import org.netbeans.modules.search.Constants.Limit;
55
import org.openide.ErrorManager;
59
import org.openide.ErrorManager;
56
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileUtil;
62
import org.openide.loaders.DataObject;
57
import org.openide.nodes.Node;
63
import org.openide.nodes.Node;
58
64
59
65
Lines 64-70 Link Here
64
 * @author  Marian Petras
70
 * @author  Marian Petras
65
 */
71
 */
66
public final class ResultModel {
72
public final class ResultModel {
67
73
    private static final Logger LOG =
74
            Logger.getLogger(ResultModel.class.getName());
75
    public static final String PROP_REMOVED = "remove";                 //NOI18N
76
    public static final String PROP_REMOVEDDETAIL = "removeDetail";     //NOI18N
68
    public static final String PROP_SELECTION = "selection";            //NOI18N
77
    public static final String PROP_SELECTION = "selection";            //NOI18N
69
    public static final String PROP_VALID = "valid";                    //NOI18N
78
    public static final String PROP_VALID = "valid";                    //NOI18N
70
    public static final String PROP_MATCHING_OBJECTS =
79
    public static final String PROP_MATCHING_OBJECTS =
Lines 115-120 Link Here
115
	isFullText = (basicCriteria != null) && basicCriteria.isFullText();        
124
	isFullText = (basicCriteria != null) && basicCriteria.isFullText();        
116
        startTime = -1;
125
        startTime = -1;
117
    }
126
    }
127
128
    /**
129
     * Remove the {@link MatchingObject} from the model and informs the
130
     * listeners.
131
     *
132
     * @param mo Matching object to remove.
133
     */
134
    public void remove(MatchingObject mo) {
135
136
        matchingObjects.remove(mo);
137
        totalDetailsCount -= getDetailsCount(mo);
138
139
        mo.cleanup();
140
        // inform listeners, old object contains removed object
141
        propertyChangeSupport.firePropertyChange(PROP_REMOVED,
142
                Arrays.asList(mo), null);
143
    }
144
145
    public void removeDetailMatch(TextDetail txtDetail) {
146
        MatchingObject found = getMatchingObjectFor(txtDetail);
147
        LOG.log(Level.FINE, "Found {0}", found);                        //NOI18N
148
        if (null != found) {
149
            found.textDetails.remove(txtDetail);
150
            totalDetailsCount--;
151
152
            if (found.textDetails.isEmpty()) {
153
                remove(found);
154
            } else {
155
                propertyChangeSupport.firePropertyChange(PROP_REMOVEDDETAIL,
156
                        Arrays.asList(), null);
157
            }
158
            // inform listeners, old object contains removed object
159
        }
160
    }
161
162
    public void removeFolder(DataObject folder) {
163
        List<MatchingObject> list = new ArrayList<MatchingObject>();
164
165
        for (MatchingObject mo : matchingObjects) {
166
            FileObject folderOfFile = mo.getFileObject().getParent();
167
            FileObject folderToRemove = folder.getPrimaryFile();
168
            boolean isInFolder = folderOfFile.equals(folderToRemove);
169
            boolean isInSubFolder = FileUtil.isParentOf(
170
                    folderToRemove, folderOfFile);
171
            if (isInFolder || isInSubFolder) {
172
                list.add(mo);
173
            }
174
        }
175
        matchingObjects.removeAll(list);
176
        for (MatchingObject mo : list) {
177
178
            totalDetailsCount -= getDetailsCount(mo);
179
            mo.cleanup();
180
        }
181
        // inform listeners, old object contains removed objects
182
        propertyChangeSupport.firePropertyChange(PROP_REMOVED, list, null);
183
    }
184
185
    private MatchingObject getMatchingObjectFor(TextDetail txtDetail) {
186
        for (MatchingObject mo : matchingObjects) {
187
            for (TextDetail textDetail : mo.getTextDetails()) {
188
                if (textDetail == txtDetail) {
189
                    return mo;
190
                }
191
            }
192
        }
193
        return null;
194
    }
118
    
195
    
119
    /**
196
    /**
120
     */
197
     */
(-)a/api.search/src/org/netbeans/modules/search/TextDetail.java (-1 / +15 lines)
Lines 50-55 Link Here
50
import java.awt.datatransfer.Transferable;
50
import java.awt.datatransfer.Transferable;
51
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionEvent;
52
import java.io.CharConversionException;
52
import java.io.CharConversionException;
53
import java.io.IOException;
53
import java.util.List;
54
import java.util.List;
54
import java.util.logging.Level;
55
import java.util.logging.Level;
55
import java.util.logging.Logger;
56
import java.util.logging.Logger;
Lines 451-456 Link Here
451
        /** Cached toString value. */
452
        /** Cached toString value. */
452
        private String name;
453
        private String name;
453
        private String htmlDisplayName;
454
        private String htmlDisplayName;
455
        private final ResultModel model;
454
        
456
        
455
        /**
457
        /**
456
         * Constructs a node representing the specified information about
458
         * Constructs a node representing the specified information about
Lines 458-468 Link Here
458
         *
460
         *
459
         * @param txtDetail  information to be represented by this node
461
         * @param txtDetail  information to be represented by this node
460
         */
462
         */
461
        public DetailNode(TextDetail txtDetail, boolean replacing) {
463
        public DetailNode(TextDetail txtDetail, boolean replacing,
464
                ResultModel model) {
462
            super(Children.LEAF, Lookups.fixed(txtDetail,
465
            super(Children.LEAF, Lookups.fixed(txtDetail,
463
                    new ReplaceCheckableNode(txtDetail, replacing)));
466
                    new ReplaceCheckableNode(txtDetail, replacing)));
464
            
467
            
465
            this.txtDetail = txtDetail;
468
            this.txtDetail = txtDetail;
469
            this.model = model;
466
            
470
            
467
            setValue(SearchDisplayer.ATTR_OUTPUT_LINE,
471
            setValue(SearchDisplayer.ATTR_OUTPUT_LINE,
468
                     DetailNode.getFullDesc(txtDetail));
472
                     DetailNode.getFullDesc(txtDetail));
Lines 823-828 Link Here
823
        protected void createPasteTypes(Transferable t, List<PasteType> s) {
827
        protected void createPasteTypes(Transferable t, List<PasteType> s) {
824
        }
828
        }
825
        
829
        
830
        @Override
831
        public boolean canDestroy() {
832
            return true;
833
        }
834
835
        @Override
836
        public void destroy() throws IOException {
837
            this.model.removeDetailMatch(txtDetail);
838
//            super.destroy();
839
        }
826
    } // End of DetailNode class.
840
    } // End of DetailNode class.
827
841
828
    /**
842
    /**
(-)a/api.search/src/org/netbeans/modules/search/ui/AbstractSearchResultsPanel.java (+6 lines)
Lines 126-131 Link Here
126
        this.searchProviderPresenter = searchProviderPresenter;
126
        this.searchProviderPresenter = searchProviderPresenter;
127
        initComponents();
127
        initComponents();
128
        explorerManager = new ExplorerManager();
128
        explorerManager = new ExplorerManager();
129
130
        ActionMap map = this.getActionMap();
131
        // map delete key to delete action
132
        map.put("delete", //NOI18N
133
                ExplorerUtils.actionDelete(explorerManager, false));
134
129
        lookup = ExplorerUtils.createLookup(explorerManager,
135
        lookup = ExplorerUtils.createLookup(explorerManager,
130
                ResultView.getInstance().getActionMap());
136
                ResultView.getInstance().getActionMap());
131
        initActions();
137
        initActions();
(-)a/api.search/src/org/netbeans/modules/search/ui/BasicAbstractResultsPanel.java (-1 / +10 lines)
Lines 45-50 Link Here
45
import java.awt.EventQueue;
45
import java.awt.EventQueue;
46
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
47
import java.awt.event.ActionListener;
48
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyVetoException;
50
import java.beans.PropertyVetoException;
49
import java.util.ResourceBundle;
51
import java.util.ResourceBundle;
50
import javax.accessibility.AccessibleContext;
52
import javax.accessibility.AccessibleContext;
Lines 74-80 Link Here
74
 * @author jhavlin
76
 * @author jhavlin
75
 */
77
 */
76
public abstract class BasicAbstractResultsPanel
78
public abstract class BasicAbstractResultsPanel
77
        extends AbstractSearchResultsPanel {
79
        extends AbstractSearchResultsPanel implements PropertyChangeListener {
78
80
79
    @StaticResource
81
    @StaticResource
80
    private static final String SHOW_DETAILS_ICON =
82
    private static final String SHOW_DETAILS_ICON =
Lines 120-127 Link Here
120
        setRootDisplayName(NbBundle.getMessage(ResultView.class,
122
        setRootDisplayName(NbBundle.getMessage(ResultView.class,
121
                "TEXT_SEARCHING___"));                                  //NOI18N
123
                "TEXT_SEARCHING___"));                                  //NOI18N
122
        initAccessibility();
124
        initAccessibility();
125
        this.resultModel.addPropertyChangeListener(
126
                ResultModel.PROP_REMOVED, this);
123
    }
127
    }
124
128
129
    @Override
130
    public void propertyChange (PropertyChangeEvent evt) {
131
        // update the root node after change in model
132
        setFinalRootNodeText();
133
    }
125
134
126
    public void update() {
135
    public void update() {
127
        if (details && btnExpand.isVisible() && !btnExpand.isEnabled()) {
136
        if (details && btnExpand.isVisible() && !btnExpand.isEnabled()) {
(-)a/api.search/src/org/netbeans/modules/search/ui/MatchingObjectNode.java (-6 / +17 lines)
Lines 59-64 Link Here
59
import org.netbeans.api.annotations.common.StaticResource;
59
import org.netbeans.api.annotations.common.StaticResource;
60
import org.netbeans.modules.search.MatchingObject;
60
import org.netbeans.modules.search.MatchingObject;
61
import org.netbeans.modules.search.MatchingObject.InvalidityStatus;
61
import org.netbeans.modules.search.MatchingObject.InvalidityStatus;
62
import org.netbeans.modules.search.ResultModel;
63
import org.openide.actions.DeleteAction;
62
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
64
import org.openide.loaders.DataObject;
66
import org.openide.loaders.DataObject;
Lines 100-121 Link Here
100
    private boolean valid = true;
102
    private boolean valid = true;
101
    private PropertyChangeListener validityListener;
103
    private PropertyChangeListener validityListener;
102
    private PropertyChangeListener selectionListener;
104
    private PropertyChangeListener selectionListener;
105
    private ResultModel resultModel;
103
    PropertySet[] propertySets;
106
    PropertySet[] propertySets;
104
107
105
    public MatchingObjectNode(Node original,
108
    public MatchingObjectNode(Node original,
106
            org.openide.nodes.Children children,
109
            org.openide.nodes.Children children, MatchingObject matchingObject,
107
            MatchingObject matchingObject, final boolean replacing) {
110
            final boolean replacing, ResultModel model) {
108
        this(original, children, matchingObject,
111
        this(original, children, matchingObject,
109
                new ReplaceCheckableNode(matchingObject, replacing));
112
                new ReplaceCheckableNode(matchingObject, replacing), model);
110
    }
113
    }
111
114
112
    private MatchingObjectNode(Node original,
115
    private MatchingObjectNode(Node original,
113
            org.openide.nodes.Children children,
116
            org.openide.nodes.Children children,
114
            final MatchingObject matchingObject,
117
            final MatchingObject matchingObject,
115
            ReplaceCheckableNode checkableNode) {
118
            ReplaceCheckableNode checkableNode, ResultModel model) {
116
        super(children, Lookups.fixed(matchingObject, checkableNode,
119
        super(children, Lookups.fixed(matchingObject, checkableNode,
117
                matchingObject.getFileObject()));
120
                matchingObject.getFileObject()));
118
        Parameters.notNull("original", original);                       //NOI18N
121
        Parameters.notNull("original", original);                       //NOI18N
122
        this.resultModel = model;
119
        this.matchingObject = matchingObject;
123
        this.matchingObject = matchingObject;
120
        if (matchingObject.isObjectValid()) {
124
        if (matchingObject.isObjectValid()) {
121
            this.original = original;
125
            this.original = original;
Lines 165-171 Link Here
165
        if (!context) {
169
        if (!context) {
166
            return new Action[]{
170
            return new Action[]{
167
                        SystemAction.get(OpenMatchingObjectsAction.class),
171
                        SystemAction.get(OpenMatchingObjectsAction.class),
168
                        new CopyPathAction()
172
                        new CopyPathAction(),
173
                        SystemAction.get(DeleteAction.class)
169
                    };
174
                    };
170
        } else {
175
        } else {
171
            return new Action[0];
176
            return new Action[0];
Lines 234-240 Link Here
234
239
235
    @Override
240
    @Override
236
    public boolean canDestroy() {
241
    public boolean canDestroy() {
237
        return false;
242
        return true;
238
    }
243
    }
239
244
240
    public void clean() {
245
    public void clean() {
Lines 274-279 Link Here
274
        return propertySets;
279
        return propertySets;
275
    }
280
    }
276
281
282
    @Override
283
    public void destroy () throws IOException {
284
        // when removing the node, the node's content is removed from model
285
        resultModel.remove(this.matchingObject);
286
    }
287
277
    /**
288
    /**
278
     * Check whether the file object is valid and a valid data object can be
289
     * Check whether the file object is valid and a valid data object can be
279
     * found for it. It should be checked after original node is destroyed. It
290
     * found for it. It should be checked after original node is destroyed. It
(-)a/api.search/src/org/netbeans/modules/search/ui/ResultsOutlineSupport.java (-10 / +105 lines)
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
        }
(-)a/api.search/test/unit/src/org/netbeans/modules/search/TextDetailTest.java (-1 / +1 lines)
Lines 144-150 Link Here
144
144
145
    public String createHtmlDisplayName(String line, String match) {
145
    public String createHtmlDisplayName(String line, String match) {
146
        TextDetail td = createMockTextDetail(line, match);
146
        TextDetail td = createMockTextDetail(line, match);
147
        DetailNode detailNode = new TextDetail.DetailNode(td, false);
147
        DetailNode detailNode = new TextDetail.DetailNode(td, false, null);
148
        String htmlDisplayName = detailNode.getHtmlDisplayName();
148
        String htmlDisplayName = detailNode.getHtmlDisplayName();
149
        Pattern p = Pattern.compile("(<html><font .*>\\s*\\d+: </font>)(.*?)(\\s+<font .*>\\[.*\\]</font></html>)");
149
        Pattern p = Pattern.compile("(<html><font .*>\\s*\\d+: </font>)(.*?)(\\s+<font .*>\\[.*\\]</font></html>)");
150
        Matcher m = p.matcher(htmlDisplayName);
150
        Matcher m = p.matcher(htmlDisplayName);
(-)a/api.search/test/unit/src/org/netbeans/modules/search/ui/MatchingObjectNodeTest.java (-2 / +2 lines)
Lines 85-91 Link Here
85
        ResultModel rm = SearchTestUtils.createResultModelWithOneMatch();
85
        ResultModel rm = SearchTestUtils.createResultModelWithOneMatch();
86
        MatchingObject mo = rm.getMatchingObjects().get(0);
86
        MatchingObject mo = rm.getMatchingObjects().get(0);
87
        MatchingObjectNode mon = new MatchingObjectNode(n, Children.LEAF, mo,
87
        MatchingObjectNode mon = new MatchingObjectNode(n, Children.LEAF, mo,
88
                false);
88
                false, rm);
89
        mon.addNodeListener(new DisplayNameChangeListener(s));
89
        mon.addNodeListener(new DisplayNameChangeListener(s));
90
        mon.getDisplayName();
90
        mon.getDisplayName();
91
        mo.getFileObject().delete();
91
        mo.getFileObject().delete();
Lines 105-111 Link Here
105
        Node original = dob.getNodeDelegate();
105
        Node original = dob.getNodeDelegate();
106
        fob.delete();
106
        fob.delete();
107
        // No exception should be thrown from the constructor.
107
        // No exception should be thrown from the constructor.
108
        Node n = new MatchingObjectNode(original, Children.LEAF, mo, false);
108
        Node n = new MatchingObjectNode(original, Children.LEAF, mo, false, rm);
109
        assertEquals("test.txt", n.getDisplayName());
109
        assertEquals("test.txt", n.getDisplayName());
110
    }
110
    }
111
111

Return to bug 200020