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/nbproject/project.properties (+2 lines)
Lines 1-3 Link Here
1
auxiliary.org-zeroturnaround-jrebel-netbeans.remoting_2e_private=3082025c020100028181008aa7f7b908d077fb77a6d206d73a27f9ec2f105da2a59eca8219b56ae34c52f9690ceb2ef50148b54e4374027a2d385174a045921348bddbfe301eb38025dfbc60dc1db16b026201f43b1a64584412047848e6b6921d42c34aa76b60ccbba6e3b2e1be6d0f1d1f6bd1c2c511a79802363854ea5f694a40d22ffd24dd19631e13020301000102818063c0b5d2d4098ed8465ba8ec2cf974fb33b5245409089835dee57a043d2492e9466f79df9d7a6001b81d851fa720534d1ed79355a534070b7752cd339c7523018207110168e82df66c3e18eb0ae3975c63e5c7d7303c88f829ad9c3d798a4e7568dd461446ab9728726e6f5cff9ebcbbcdd9ae8f7d91c904b7dfe01b87930ea1024100e6d31751fe491a1699d7856793cc99d7d5d60c5cb6b48d2841457bbb8b5f181d5390d5beb3f65ca5894c574ce7613f82603eaef3f468b3aa86f3b1a9a4debd6302410099c76b3dbed24bb8e3a9a23d816c8c9594f1be76fb22b9e9b53dc94bbbbc26b3b2bcf282d6d69c2e4740a0c6fa209de30d1ed8bdc8e9d5711b65b2ed0bbe93910241009f40c4b62d5b0244d59f7ccb198df01699d2347543190ecad73db9408bc7f03b4b8c81ec30fda8ae0d2c3e8f309447dd0bca33aadcd5e01fa73c3b377028bd41024020e8ad498c71a2a4d18bb6dda4b9df280fb4e046c41dbd5d875cce9c3773df706b5ac6273be4b78dabcfe7d84d24f7c4e444eaab4ab8c7e5a9b04ce72fb13c1102404c316288f1a0de9526f6c50539728e313859b072673554866bdaecaf5049469116fbab26906da603895d6101be889dace3b4ed6a2f6c07e62b1afe999901d3c1
2
auxiliary.org-zeroturnaround-jrebel-netbeans.remoting_2e_public=308189028181008aa7f7b908d077fb77a6d206d73a27f9ec2f105da2a59eca8219b56ae34c52f9690ceb2ef50148b54e4374027a2d385174a045921348bddbfe301eb38025dfbc60dc1db16b026201f43b1a64584412047848e6b6921d42c34aa76b60ccbba6e3b2e1be6d0f1d1f6bd1c2c511a79802363854ea5f694a40d22ffd24dd19631e130203010001
1
is.autoload=true
3
is.autoload=true
2
javac.source=1.6
4
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
5
javac.compilerargs=-Xlint -Xlint:-serial
(-)a/api.search/src/org/netbeans/modules/search/MatchingObject.java (-4 / +6 lines)
Lines 538-551 Link Here
538
538
539
        List<Node> detailNodes = new ArrayList<Node>(textDetails.size());
539
        List<Node> detailNodes = new ArrayList<Node>(textDetails.size());
540
        for (TextDetail txtDetail : textDetails) {
540
        for (TextDetail txtDetail : textDetails) {
541
            detailNodes.add(new TextDetail.DetailNode(txtDetail, false));
541
            detailNodes.add(new TextDetail.DetailNode(txtDetail, false, resultModel));
542
        }
542
        }
543
543
544
        return detailNodes.toArray(new Node[detailNodes.size()]);
544
        return detailNodes.toArray(new Node[detailNodes.size()]);
545
    }
545
    }
546
546
547
    public Children getDetailsChildren(boolean replacing) {
547
    public Children getDetailsChildren(boolean replacing) {
548
        return new DetailsChildren(replacing);
548
        return new DetailsChildren(replacing, resultModel);
549
    }
549
    }
550
550
551
    /**
551
    /**
Lines 1053-1067 Link Here
1053
    private class DetailsChildren extends Children.Keys<TextDetail> {
1053
    private class DetailsChildren extends Children.Keys<TextDetail> {
1054
1054
1055
        private boolean replacing;
1055
        private boolean replacing;
1056
        private final ResultModel model;
1056
1057
1057
        public DetailsChildren(boolean replacing) {
1058
        public DetailsChildren(boolean replacing, ResultModel model) {
1058
            this.replacing = replacing;
1059
            this.replacing = replacing;
1059
            setKeys(getTextDetails());
1060
            setKeys(getTextDetails());
1061
            this.model = model;
1060
        }
1062
        }
1061
1063
1062
        @Override
1064
        @Override
1063
        protected Node[] createNodes(TextDetail key) {
1065
        protected Node[] createNodes(TextDetail key) {
1064
            return new Node[]{new TextDetail.DetailNode(key, replacing)};
1066
            return new Node[]{new TextDetail.DetailNode(key, replacing, model)};
1065
        }
1067
        }
1066
    }
1068
    }
1067
1069
(-)a/api.search/src/org/netbeans/modules/search/ResultModel.java (+77 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.*;
51
import java.util.List;
52
import java.util.List;
52
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.ChangeListener;
54
import javax.swing.event.ChangeListener;
54
import org.netbeans.modules.search.Constants.Limit;
55
import org.netbeans.modules.search.Constants.Limit;
56
import org.netbeans.modules.search.ui.*;
55
import org.openide.ErrorManager;
57
import org.openide.ErrorManager;
58
import org.openide.filesystems.*;
56
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileObject;
60
import org.openide.loaders.*;
57
import org.openide.nodes.Node;
61
import org.openide.nodes.Node;
58
62
59
63
Lines 65-70 Link Here
65
 */
69
 */
66
public final class ResultModel {
70
public final class ResultModel {
67
71
72
    public static final String PROP_REMOVED = "remove";            //NOI18N
73
    public static final String PROP_REMOVEDDETAIL = "removeDetail";            //NOI18N
68
    public static final String PROP_SELECTION = "selection";            //NOI18N
74
    public static final String PROP_SELECTION = "selection";            //NOI18N
69
    public static final String PROP_VALID = "valid";                    //NOI18N
75
    public static final String PROP_VALID = "valid";                    //NOI18N
70
    public static final String PROP_MATCHING_OBJECTS =
76
    public static final String PROP_MATCHING_OBJECTS =
Lines 118-123 Link Here
118
	isFullText = (basicCriteria != null) && basicCriteria.isFullText();        
124
	isFullText = (basicCriteria != null) && basicCriteria.isFullText();        
119
        startTime = -1;
125
        startTime = -1;
120
    }
126
    }
127
128
    /**
129
     * Remove the {@link MatchingObject} from the model and informs the listeners.
130
     * @param mo 
131
     */
132
    public void remove (MatchingObject mo) {
133
        
134
        matchingObjects.remove(mo);
135
        totalDetailsCount -= getDetailsCount(mo);
136
137
        mo.cleanup();
138
        // inform listeners, old object contains removed object
139
        propertyChangeSupport.firePropertyChange(PROP_REMOVED, Arrays.asList(mo), null);
140
    }
141
142
    public void removeDetailMatch (TextDetail txtDetail) {
143
        MatchingObject found = getMatchingObjectFor(txtDetail);
144
        System.out.println("found "+found);
145
        
146
        if (null != found ) {
147
            found.textDetails.remove(txtDetail);
148
            totalDetailsCount--;
149
                    
150
            if (found.textDetails.isEmpty()){
151
                remove(found);
152
            }else{
153
            propertyChangeSupport.firePropertyChange(PROP_REMOVEDDETAIL, Arrays.asList(), null);
154
                
155
            }
156
            // inform listeners, old object contains removed object
157
        }
158
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(folderToRemove, folderOfFile);
170
            if (isInFolder || isInSubFolder){
171
                list.add(mo);
172
            };
173
        }
174
        
175
        matchingObjects.removeAll(list);
176
        for (MatchingObject mo : list) {
177
            
178
            totalDetailsCount -= getDetailsCount(mo);
179
            mo.cleanup();
180
        }
181
        
182
183
        // inform listeners, old object contains removed objects
184
        propertyChangeSupport.firePropertyChange(PROP_REMOVED, list, null);
185
    }
186
187
    private MatchingObject getMatchingObjectFor (TextDetail txtDetail) {
188
        for (MatchingObject mo : matchingObjects) {
189
            for (TextDetail textDetail : mo.getTextDetails()) {
190
                if (textDetail == txtDetail) {
191
                    return mo;
192
                }
193
            }
194
        }
195
        return null;
196
    }
121
    
197
    
122
    /**
198
    /**
123
     */
199
     */
Lines 450-455 Link Here
450
        }
526
        }
451
    }
527
    }
452
528
529
453
    private class MatchSelectionListener implements ChangeListener {
530
    private class MatchSelectionListener implements ChangeListener {
454
531
455
        @Override
532
        @Override
(-)a/api.search/src/org/netbeans/modules/search/TextDetail.java (-2 / +18 lines)
Lines 49-55 Link Here
49
import java.awt.Toolkit;
49
import java.awt.Toolkit;
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.*;
53
import java.util.List;
53
import java.util.List;
54
import java.util.logging.Level;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
55
import java.util.logging.Logger;
Lines 451-456 Link Here
451
        /** Cached toString value. */
451
        /** Cached toString value. */
452
        private String name;
452
        private String name;
453
        private String htmlDisplayName;
453
        private String htmlDisplayName;
454
        private final ResultModel model;
454
        
455
        
455
        /**
456
        /**
456
         * Constructs a node representing the specified information about
457
         * Constructs a node representing the specified information about
Lines 458-468 Link Here
458
         *
459
         *
459
         * @param txtDetail  information to be represented by this node
460
         * @param txtDetail  information to be represented by this node
460
         */
461
         */
461
        public DetailNode(TextDetail txtDetail, boolean replacing) {
462
        public DetailNode(TextDetail txtDetail, boolean replacing, ResultModel model) {
462
            super(Children.LEAF, Lookups.fixed(txtDetail,
463
            super(Children.LEAF, Lookups.fixed(txtDetail,
463
                    new ReplaceCheckableNode(txtDetail, replacing)));
464
                    new ReplaceCheckableNode(txtDetail, replacing)));
464
            
465
            
465
            this.txtDetail = txtDetail;
466
            this.txtDetail = txtDetail;
467
            this.model = model;
466
            
468
            
467
            setShortDescription(DetailNode.getShortDesc(txtDetail));
469
            setShortDescription(DetailNode.getShortDesc(txtDetail));
468
            setValue(SearchDisplayer.ATTR_OUTPUT_LINE,
470
            setValue(SearchDisplayer.ATTR_OUTPUT_LINE,
Lines 823-828 Link Here
823
        @Override
825
        @Override
824
        protected void createPasteTypes(Transferable t, List<PasteType> s) {
826
        protected void createPasteTypes(Transferable t, List<PasteType> s) {
825
        }
827
        }
828
829
        @Override
830
        public boolean canDestroy () {
831
            return true;
832
        }
833
834
        @Override
835
        public void destroy () throws IOException {
836
            this.model.removeDetailMatch(txtDetail);
837
//            super.destroy(); //To change body of generated methods, choose Tools | Templates.
838
        }
839
        
840
        
841
        
826
        
842
        
827
    } // End of DetailNode class.
843
    } // End of DetailNode class.
828
844
(-)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
        
131
        ActionMap map = this.getActionMap();
132
        // map delete key to delete action 
133
        map.put("delete", 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 / +8 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.*;
48
import java.beans.PropertyVetoException;
49
import java.beans.PropertyVetoException;
49
import java.util.List;
50
import java.util.List;
50
import java.util.ResourceBundle;
51
import java.util.ResourceBundle;
Lines 76-82 Link Here
76
 * @author jhavlin
77
 * @author jhavlin
77
 */
78
 */
78
public abstract class BasicAbstractResultsPanel
79
public abstract class BasicAbstractResultsPanel
79
        extends AbstractSearchResultsPanel {
80
        extends AbstractSearchResultsPanel implements PropertyChangeListener {
80
81
81
    @StaticResource
82
    @StaticResource
82
    private static final String SHOW_DETAILS_ICON =
83
    private static final String SHOW_DETAILS_ICON =
Lines 123-130 Link Here
123
        setRootDisplayName(NbBundle.getMessage(ResultView.class,
124
        setRootDisplayName(NbBundle.getMessage(ResultView.class,
124
                "TEXT_SEARCHING___"));                                  //NOI18N
125
                "TEXT_SEARCHING___"));                                  //NOI18N
125
        initAccessibility();
126
        initAccessibility();
127
        this.resultModel.addPropertyChangeListener(ResultModel.PROP_REMOVED, this);
126
    }
128
    }
127
129
130
    @Override
131
    public void propertyChange (PropertyChangeEvent evt) {
132
        // update the root node after change in model
133
        setFinalRootNodeText();
134
    }
128
135
129
    public void update() {
136
    public void update() {
130
        if (details && btnExpand.isVisible() && !btnExpand.isEnabled()) {
137
        if (details && btnExpand.isVisible() && !btnExpand.isEnabled()) {
(-)a/api.search/src/org/netbeans/modules/search/ui/MatchingObjectNode.java (-5 / +17 lines)
Lines 54-64 Link Here
54
import java.io.IOException;
54
import java.io.IOException;
55
import java.lang.reflect.InvocationTargetException;
55
import java.lang.reflect.InvocationTargetException;
56
import java.util.List;
56
import java.util.List;
57
import javax.swing.*;
57
import javax.swing.AbstractAction;
58
import javax.swing.AbstractAction;
58
import javax.swing.Action;
59
import javax.swing.Action;
59
import org.netbeans.api.annotations.common.StaticResource;
60
import org.netbeans.api.annotations.common.StaticResource;
61
import org.netbeans.modules.search.*;
60
import org.netbeans.modules.search.MatchingObject;
62
import org.netbeans.modules.search.MatchingObject;
61
import org.netbeans.modules.search.MatchingObject.InvalidityStatus;
63
import org.netbeans.modules.search.MatchingObject.InvalidityStatus;
64
import org.openide.actions.*;
62
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.FileUtil;
64
import org.openide.loaders.DataObject;
67
import org.openide.loaders.DataObject;
Lines 100-121 Link Here
100
    private boolean valid = true;
103
    private boolean valid = true;
101
    private PropertyChangeListener validityListener;
104
    private PropertyChangeListener validityListener;
102
    private PropertyChangeListener selectionListener;
105
    private PropertyChangeListener selectionListener;
106
    private ResultModel resultModel;
103
    PropertySet[] propertySets;
107
    PropertySet[] propertySets;
104
108
105
    public MatchingObjectNode(Node original,
109
    public MatchingObjectNode(Node original,
106
            org.openide.nodes.Children children,
110
            org.openide.nodes.Children children,
107
            MatchingObject matchingObject, final boolean replacing) {
111
            MatchingObject matchingObject, final boolean replacing, ResultModel model) {
108
        this(original, children, matchingObject,
112
        this(original, children, matchingObject,
109
                new ReplaceCheckableNode(matchingObject, replacing));
113
                new ReplaceCheckableNode(matchingObject, replacing), model);
110
    }
114
    }
111
115
112
    private MatchingObjectNode(Node original,
116
    private MatchingObjectNode(Node original,
113
            org.openide.nodes.Children children,
117
            org.openide.nodes.Children children,
114
            final MatchingObject matchingObject,
118
            final MatchingObject matchingObject,
115
            ReplaceCheckableNode checkableNode) {
119
            ReplaceCheckableNode checkableNode, ResultModel model) {
116
        super(children, Lookups.fixed(matchingObject, checkableNode,
120
        super(children, Lookups.fixed(matchingObject, checkableNode,
117
                matchingObject.getFileObject()));
121
                matchingObject.getFileObject()));
118
        Parameters.notNull("original", original);                       //NOI18N
122
        Parameters.notNull("original", original);                       //NOI18N
123
        this.resultModel = model;
119
        this.matchingObject = matchingObject;
124
        this.matchingObject = matchingObject;
120
        if (matchingObject.isObjectValid()) {
125
        if (matchingObject.isObjectValid()) {
121
            this.original = original;
126
            this.original = original;
Lines 165-171 Link Here
165
        if (!context) {
170
        if (!context) {
166
            return new Action[]{
171
            return new Action[]{
167
                        SystemAction.get(OpenMatchingObjectsAction.class),
172
                        SystemAction.get(OpenMatchingObjectsAction.class),
168
                        new CopyPathAction()
173
                        new CopyPathAction(),
174
                        SystemAction.get(DeleteAction.class)
169
                    };
175
                    };
170
        } else {
176
        } else {
171
            return new Action[0];
177
            return new Action[0];
Lines 234-240 Link Here
234
240
235
    @Override
241
    @Override
236
    public boolean canDestroy() {
242
    public boolean canDestroy() {
237
        return false;
243
        return true;
238
    }
244
    }
239
245
240
    public void clean() {
246
    public void clean() {
Lines 274-279 Link Here
274
        return propertySets;
280
        return propertySets;
275
    }
281
    }
276
282
283
    @Override
284
    public void destroy () throws IOException {
285
        // when removing the node, the node's content is removed from model
286
        resultModel.remove(this.matchingObject);
287
    }
288
277
    /**
289
    /**
278
     * Check whether the file object is valid and a valid data object can be
290
     * 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
291
     * found for it. It should be checked after original node is destroyed. It
(-)a/api.search/src/org/netbeans/modules/search/ui/ResultsOutlineSupport.java (-14 / +104 lines)
Lines 52-62 Link Here
52
import java.beans.PropertyChangeListener;
52
import java.beans.PropertyChangeListener;
53
import java.beans.PropertyChangeSupport;
53
import java.beans.PropertyChangeSupport;
54
import java.io.IOException;
54
import java.io.IOException;
55
import java.util.*;
55
import java.util.ArrayList;
56
import java.util.ArrayList;
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;
59
import java.util.List;
60
import java.util.List;
61
import javax.swing.*;
60
import javax.swing.Action;
62
import javax.swing.Action;
61
import javax.swing.JScrollPane;
63
import javax.swing.JScrollPane;
62
import javax.swing.KeyStroke;
64
import javax.swing.KeyStroke;
Lines 68-77 Link Here
68
import javax.swing.event.TreeExpansionListener;
70
import javax.swing.event.TreeExpansionListener;
69
import javax.swing.table.TableColumn;
71
import javax.swing.table.TableColumn;
70
import org.netbeans.api.annotations.common.StaticResource;
72
import org.netbeans.api.annotations.common.StaticResource;
71
import org.netbeans.modules.search.FindDialogMemory;
73
import org.netbeans.modules.search.*;
72
import org.netbeans.modules.search.MatchingObject;
73
import org.netbeans.modules.search.ResultModel;
74
import org.netbeans.modules.search.Selectable;
75
import org.netbeans.modules.search.ui.AbstractSearchResultsPanel.RootNode;
74
import org.netbeans.modules.search.ui.AbstractSearchResultsPanel.RootNode;
76
import org.netbeans.swing.etable.ETableColumnModel;
75
import org.netbeans.swing.etable.ETableColumnModel;
77
import org.netbeans.swing.outline.Outline;
76
import org.netbeans.swing.outline.Outline;
Lines 81-86 Link Here
81
import org.openide.filesystems.FileUtil;
80
import org.openide.filesystems.FileUtil;
82
import org.openide.loaders.DataObject;
81
import org.openide.loaders.DataObject;
83
import org.openide.loaders.DataObjectNotFoundException;
82
import org.openide.loaders.DataObjectNotFoundException;
83
import org.openide.nodes.*;
84
import org.openide.nodes.AbstractNode;
84
import org.openide.nodes.AbstractNode;
85
import org.openide.nodes.Children;
85
import org.openide.nodes.Children;
86
import org.openide.nodes.FilterNode;
86
import org.openide.nodes.FilterNode;
Lines 94-100 Link Here
94
 *
94
 *
95
 * @author jhavlin
95
 * @author jhavlin
96
 */
96
 */
97
public class ResultsOutlineSupport {
97
public class ResultsOutlineSupport implements PropertyChangeListener {
98
98
99
    @StaticResource
99
    @StaticResource
100
    private static final String ROOT_NODE_ICON =
100
    private static final String ROOT_NODE_ICON =
Lines 123-133 Link Here
123
        this.details = details;
123
        this.details = details;
124
        this.resultModel = resultModel;
124
        this.resultModel = resultModel;
125
        this.rootFiles = rootFiles;
125
        this.rootFiles = rootFiles;
126
        this.resultsNode = new ResultsNode();
126
        this.resultsNode = new ResultsNode(resultModel);
127
        this.infoNode = infoNode;
127
        this.infoNode = infoNode;
128
        this.invisibleRoot = new RootNode(resultsNode, infoNode);
128
        this.invisibleRoot = new RootNode(resultsNode, infoNode);
129
        this.matchingObjectNodes = new LinkedList<MatchingObjectNode>();
129
        this.matchingObjectNodes = new LinkedList<MatchingObjectNode>();
130
        createOutlineView();
130
        createOutlineView();
131
        this.resultModel.addPropertyChangeListener(ResultModel.PROP_REMOVED, this);
132
    }
133
134
135
    @Override
136
    public void propertyChange (PropertyChangeEvent evt) {
137
        List<MatchingObject> items = (List<MatchingObject>) evt.getOldValue();
138
        
139
        //support folders (multiple matching objects) or single matching objects
140
        for (MatchingObject mo : items) {
141
            removedMatchingObject(mo);
142
        }
143
        
144
        // rebuild the tree from the modified model
145
        this.update();
131
    }
146
    }
132
147
133
    private void createOutlineView() {
148
    private void createOutlineView() {
Lines 301-310 Link Here
301
        private FolderTreeChildren folderTreeChildren;
316
        private FolderTreeChildren folderTreeChildren;
302
        private String htmlDisplayName = null;
317
        private String htmlDisplayName = null;
303
318
304
        public ResultsNode() {
319
        public ResultsNode(ResultModel model) {
305
            super(new FlatChildren());
320
            super(new FlatChildren());
306
            this.flatChildren = (FlatChildren) this.getChildren();
321
            this.flatChildren = (FlatChildren) this.getChildren();
307
            this.folderTreeChildren = new FolderTreeChildren(rootPathItem);
322
            this.folderTreeChildren = new FolderTreeChildren(rootPathItem, model);
308
        }
323
        }
309
324
310
        void update() {
325
        void update() {
Lines 402-408 Link Here
402
            children = key.getDetailsChildren(replacing);
417
            children = key.getDetailsChildren(replacing);
403
        }
418
        }
404
        MatchingObjectNode mon =
419
        MatchingObjectNode mon =
405
                new MatchingObjectNode(delegate, children, key, replacing);
420
                new MatchingObjectNode(delegate, children, key, replacing, resultModel);
406
        matchingObjectNodes.add(mon);
421
        matchingObjectNodes.add(mon);
407
        return mon;
422
        return mon;
408
    }
423
    }
Lines 422-427 Link Here
422
        addToTreeView(rootPathItem,
437
        addToTreeView(rootPathItem,
423
                Collections.singletonList(mo.getFileObject()), mo);
438
                Collections.singletonList(mo.getFileObject()), mo);
424
    }
439
    }
440
    public synchronized void removedMatchingObject(MatchingObject mo) {
441
        if (closed) {
442
            return;
443
        }
444
        removeFilesFromTreeView(rootPathItem,  mo);
445
        removeEmptyFoldersFromTreeView(rootPathItem);
446
    }
447
    public synchronized void removedTextDetail(TextDetail detail) {
448
        if (closed) {
449
            return;
450
        }
451
//        removeFilesFromTreeView(rootPathItem,  mo);
452
        removeEmptyFoldersFromTreeView(rootPathItem);
453
    }
425
454
426
    private List<FileObject> getRelativePath(FileObject parent, FileObject fo) {
455
    private List<FileObject> getRelativePath(FileObject parent, FileObject fo) {
427
        List<FileObject> l = new LinkedList<FileObject>();
456
        List<FileObject> l = new LinkedList<FileObject>();
Lines 436-441 Link Here
436
        return l;
465
        return l;
437
    }
466
    }
438
467
468
    private void removeFilesFromTreeView (FolderTreeItem parentItem, MatchingObject matchingObject) {
469
        List<FolderTreeItem> removeableItems = new ArrayList<FolderTreeItem>();
470
471
        for (FolderTreeItem pi : parentItem.getChildren()) {
472
            if (!pi.isPathLeaf()) {
473
                //start recursion for folders
474
                removeFilesFromTreeView(pi, matchingObject);
475
            } else {
476
                if (pi.getMatchingObject().equals(matchingObject)) {
477
                    // collect all the files which have to be removed
478
                    removeableItems.add(pi);
479
                }
480
            }
481
        }
482
        parentItem.removeChildren(removeableItems);
483
    }
484
485
    private void removeEmptyFoldersFromTreeView (FolderTreeItem parentItem) {
486
        List<FolderTreeItem> emptyFolders = new ArrayList<FolderTreeItem>();
487
488
        for (FolderTreeItem pi : parentItem.getChildren()) {
489
            {
490
                // start recursion
491
                removeEmptyFoldersFromTreeView(pi);
492
493
                if (pi.getChildren().isEmpty() && null == pi.getMatchingObject()) {
494
                    // collect all the empty folders which have to be removed
495
                    emptyFolders.add(pi);
496
                }
497
            }
498
        }
499
        // remove empty folders
500
        parentItem.removeChildren(emptyFolders);
501
    }
502
    
439
    private void addToTreeView(FolderTreeItem parentItem, List<FileObject> path,
503
    private void addToTreeView(FolderTreeItem parentItem, List<FileObject> path,
440
            MatchingObject matchingObject) {
504
            MatchingObject matchingObject) {
441
        for (FolderTreeItem pi : parentItem.getChildren()) {
505
        for (FolderTreeItem pi : parentItem.getChildren()) {
Lines 508-513 Link Here
508
        public List<FolderTreeItem> getChildren() {
572
        public List<FolderTreeItem> getChildren() {
509
            return children;
573
            return children;
510
        }
574
        }
575
        
576
        public boolean removeChildren (Collection<FolderTreeItem> list) {
577
            boolean result = children.removeAll(list);
578
            firePropertyChange(PROP_CHILDREN, null, null);
579
            return result;
580
        }
511
581
512
        public MatchingObject getMatchingObject() {
582
        public MatchingObject getMatchingObject() {
513
            return matchingObject;
583
            return matchingObject;
Lines 563-575 Link Here
563
    }
633
    }
564
634
565
    private class FolderTreeNode extends FilterNode {
635
    private class FolderTreeNode extends FilterNode {
636
        private ResultModel model;
566
637
567
        public FolderTreeNode(FolderTreeItem pathItem) {
638
        public FolderTreeNode(FolderTreeItem pathItem, ResultModel model) {
568
            super(pathItem.getFolder().getNodeDelegate(),
639
            super(pathItem.getFolder().getNodeDelegate(),
569
                    new FolderTreeChildren(pathItem),
640
                    new FolderTreeChildren(pathItem, model),
570
                    Lookups.fixed(pathItem,
641
                    Lookups.fixed(pathItem,
571
                    new ReplaceCheckableNode(pathItem, replacing),
642
                    new ReplaceCheckableNode(pathItem, replacing),
572
                    pathItem.getFolder().getPrimaryFile()));
643
                    pathItem.getFolder().getPrimaryFile()));
644
            this.model=model;
573
            pathItem.addPropertyChangeListener(new PropertyChangeListener() {
645
            pathItem.addPropertyChangeListener(new PropertyChangeListener() {
574
                @Override
646
                @Override
575
                public void propertyChange(PropertyChangeEvent evt) {
647
                public void propertyChange(PropertyChangeEvent evt) {
Lines 582-588 Link Here
582
                        pathItem.getFolder().getPrimaryFile().getPath());
654
                        pathItem.getFolder().getPrimaryFile().getPath());
583
            }
655
            }
584
        }
656
        }
585
657
        
586
        @Override
658
        @Override
587
        public PasteType[] getPasteTypes(Transferable t) {
659
        public PasteType[] getPasteTypes(Transferable t) {
588
            return new PasteType[0];
660
            return new PasteType[0];
Lines 594-599 Link Here
594
        }
666
        }
595
667
596
        @Override
668
        @Override
669
        public boolean canDestroy () {
670
            return true;
671
        }
672
673
        @Override
674
        public void destroy () throws IOException {
675
            //FIXME alter the model
676
            FolderTreeItem folder = this.getLookup().lookup(FolderTreeItem.class);
677
            this.model.removeFolder(folder.getFolder());
678
//            this.resultModel.remove(this.getLookup().lookup(FolderTreeItem.class));
679
        }
680
681
        
682
        
683
        @Override
597
        public Transferable drag() throws IOException {
684
        public Transferable drag() throws IOException {
598
            return UiUtils.DISABLE_TRANSFER;
685
            return UiUtils.DISABLE_TRANSFER;
599
        }
686
        }
Lines 607-614 Link Here
607
    private class FolderTreeChildren extends Children.Keys<FolderTreeItem> {
694
    private class FolderTreeChildren extends Children.Keys<FolderTreeItem> {
608
695
609
        private FolderTreeItem item = null;
696
        private FolderTreeItem item = null;
697
        private final ResultModel model;
610
698
611
        public FolderTreeChildren(FolderTreeItem pathItem) {
699
        public FolderTreeChildren(FolderTreeItem pathItem, ResultModel model) {
612
            this.item = pathItem;
700
            this.item = pathItem;
613
            pathItem.addPropertyChangeListener(new PropertyChangeListener() {
701
            pathItem.addPropertyChangeListener(new PropertyChangeListener() {
614
                @Override
702
                @Override
Lines 619-624 Link Here
619
                    }
707
                    }
620
                }
708
                }
621
            });
709
            });
710
            this.model = model;
622
        }
711
        }
623
712
624
        @Override
713
        @Override
Lines 636-642 Link Here
636
            if (key.isPathLeaf()) {
725
            if (key.isPathLeaf()) {
637
                n = createNodeForMatchingObject(key.getMatchingObject());
726
                n = createNodeForMatchingObject(key.getMatchingObject());
638
            } else {
727
            } else {
639
                n = new FolderTreeNode(key);
728
                n = new FolderTreeNode(key, model);
729
                
640
            }
730
            }
641
            return new Node[]{n};
731
            return new Node[]{n};
642
        }
732
        }
(-)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