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 119818
Collapse All | Expand All

(-)src/org/netbeans/modules/search/Bundle.properties (+4 lines)
Lines 71-76 Link Here
71
TEXT_BUTTON_FILL=Show A&ll Details
71
TEXT_BUTTON_FILL=Show A&ll Details
72
ACS_TEXT_BUTTON_FILL=Displays links to all found occurences of the pattern to the Output Window
72
ACS_TEXT_BUTTON_FILL=Displays links to all found occurences of the pattern to the Output Window
73
TEXT_ACTION_SEARCH_RESULTS=&Search Results
73
TEXT_ACTION_SEARCH_RESULTS=&Search Results
74
TEXT_BUTTON_SORT=\ Sort b&y Name
75
ACS_TEXT_BUTTON_SORT=Sorts found files by name
76
TEXT_BUTTON_UNSORT=\ Do &Not Sort
77
ACS_TEXT_BUTTON_UNSORT=Displays found files in a random order
74
78
75
ACSN_Tabs=Each tab contains different search criterion
79
ACSN_Tabs=Each tab contains different search criterion
76
ACSD_Tabs=N/A
80
ACSD_Tabs=N/A
(-)src/org/netbeans/modules/search/ResultTreeModel.java (-3 / +56 lines)
Lines 43-48 Link Here
43
43
44
import java.awt.EventQueue;
44
import java.awt.EventQueue;
45
import java.util.ArrayList;
45
import java.util.ArrayList;
46
import java.util.Collections;
47
import java.util.Comparator;
46
import java.util.List;
48
import java.util.List;
47
import javax.swing.event.TreeModelEvent;
49
import javax.swing.event.TreeModelEvent;
48
import javax.swing.event.TreeModelListener;
50
import javax.swing.event.TreeModelListener;
Lines 71-76 Link Here
71
    private int selectedObjectsCount;
73
    private int selectedObjectsCount;
72
    /** */
74
    /** */
73
    private List<TreeModelListener> treeModelListeners;
75
    private List<TreeModelListener> treeModelListeners;
76
    /** */
77
    private boolean sorted;
78
    /** */
79
    private List<MatchingObject> sortedMatchingObjects = new ArrayList<MatchingObject>();
74
    
80
    
75
    /**
81
    /**
76
     * 
82
     * 
Lines 103-109 Link Here
103
            } else {
109
            } else {
104
                try {
110
                try {
105
                    //PENDING - threading:
111
                    //PENDING - threading:
106
                    ret = resultModel.matchingObjects.get(index);
112
                    ret = getSortedMatchingObjects().get(index);
107
                } catch (ArrayIndexOutOfBoundsException ex) {
113
                } catch (ArrayIndexOutOfBoundsException ex) {
108
                    assert false;
114
                    assert false;
109
                    ret = null;
115
                    ret = null;
Lines 190-196 Link Here
190
        int ret;
196
        int ret;
191
        if (parent == getRoot()) {
197
        if (parent == getRoot()) {
192
            ret = (child.getClass() == MatchingObject.class)
198
            ret = (child.getClass() == MatchingObject.class)
193
                  ? resultModel.matchingObjects.indexOf(child)
199
                  ? getSortedMatchingObjects().indexOf(child)
194
                  : -1;
200
                  : -1;
195
        } else {
201
        } else {
196
            ret = -1;
202
            ret = -1;
Lines 273-278 Link Here
273
        UPDATE_NAME_TASK.run();                   //fireRootNodeChanged();
279
        UPDATE_NAME_TASK.run();                   //fireRootNodeChanged();
274
    }
280
    }
275
    
281
    
282
    void setSorted(boolean sorted) {
283
        this.sorted = sorted;
284
        final List<MatchingObject> matchingObjects = resultModel.matchingObjects;
285
        if (sorted && !sortedMatchingObjects.containsAll(matchingObjects)) {
286
            sortedMatchingObjects.clear();
287
            sortedMatchingObjects.addAll(matchingObjects);
288
            Collections.sort(sortedMatchingObjects, new Comparator<MatchingObject>() {
289
                public int compare(MatchingObject o1, MatchingObject o2) {
290
                    return o1.getName().compareToIgnoreCase(o2.getName());
291
                }
292
            });
293
        }
294
        UPDATE_SORTED_CHILDREN_TASK.run();
295
    }
296
297
    private List<MatchingObject> getSortedMatchingObjects() {
298
        return sorted ? sortedMatchingObjects : resultModel.matchingObjects;
299
    }
300
276
    /**
301
    /**
277
     */
302
     */
278
    boolean isSelected() {
303
    boolean isSelected() {
Lines 293-316 Link Here
293
    }
318
    }
294
    
319
    
295
    private final Task UPDATE_NAME_TASK = new Task();
320
    private final Task UPDATE_NAME_TASK = new Task();
321
    private final Task UPDATE_SORTED_CHILDREN_TASK = new Task(true);
322
296
    /**
323
    /**
297
     * Single class for sending various asynchronous tasks to the event queue.
324
     * Single class for sending various asynchronous tasks to the event queue.
298
     */
325
     */
299
    private final class Task implements Runnable {
326
    private final class Task implements Runnable {
300
        private final MatchingObject foundObject;
327
        private final MatchingObject foundObject;
301
        private final int foundObjectIndex;
328
        private final int foundObjectIndex;
329
        private final boolean refreshChildren;
302
        private Task() {
330
        private Task() {
303
            this.foundObject = null;
331
            this.foundObject = null;
304
            this.foundObjectIndex = -1;
332
            this.foundObjectIndex = -1;
333
            this.refreshChildren = false;
305
        }
334
        }
335
        private Task(final boolean refreshChildren) {
336
            this.foundObject = null;
337
            this.foundObjectIndex = -1;
338
            this.refreshChildren = refreshChildren;
339
        }
306
        private Task(MatchingObject object) {
340
        private Task(MatchingObject object) {
307
            this.foundObject = object;
341
            this.foundObject = object;
308
            this.foundObjectIndex = -1;
342
            this.foundObjectIndex = -1;
343
            this.refreshChildren = false;
309
        }
344
        }
310
        private Task(MatchingObject foundObject, int foundObjectIndex) {
345
        private Task(MatchingObject foundObject, int foundObjectIndex) {
311
            assert (foundObject != null) && (foundObjectIndex >= 0);
346
            assert (foundObject != null) && (foundObjectIndex >= 0);
312
            this.foundObject = foundObject;
347
            this.foundObject = foundObject;
313
            this.foundObjectIndex = foundObjectIndex;
348
            this.foundObjectIndex = foundObjectIndex;
349
            this.refreshChildren = false;
314
        }
350
        }
315
        public void run() {
351
        public void run() {
316
            if (!EventQueue.isDispatchThread()) {
352
            if (!EventQueue.isDispatchThread()) {
Lines 334-339 Link Here
334
                        updateRootNodeSelection(false);
370
                        updateRootNodeSelection(false);
335
                    }
371
                    }
336
                }
372
                }
373
            } else if (refreshChildren) {
374
                fireNodesChanged();
337
            } else {
375
            } else {
338
                fireRootNodeChanged();
376
                fireRootNodeChanged();
339
            }
377
            }
Lines 420-425 Link Here
420
458
421
    /**
459
    /**
422
     */
460
     */
461
    private void fireNodesChanged() {
462
        assert EventQueue.isDispatchThread();
463
464
        if ((treeModelListeners == null) || treeModelListeners.isEmpty()) {
465
            return;
466
        }
467
468
        TreeModelEvent event = new TreeModelEvent(this, rootPath);
469
        for (TreeModelListener l : treeModelListeners) {
470
            l.treeStructureChanged(event);
471
        }
472
    }
473
474
    /**
475
     */
423
    void fireRootNodeChanged() {
476
    void fireRootNodeChanged() {
424
        assert EventQueue.isDispatchThread();
477
        assert EventQueue.isDispatchThread();
425
        
478
        
Lines 475-481 Link Here
475
            return;
528
            return;
476
        }
529
        }
477
530
478
        final int index = resultModel.matchingObjects.indexOf(matchingObj);
531
        final int index = getSortedMatchingObjects().indexOf(matchingObj);
479
        
532
        
480
        /* Notify that the file node itself has changed... */
533
        /* Notify that the file node itself has changed... */
481
        TreeModelEvent event = new TreeModelEvent(this,
534
        TreeModelEvent event = new TreeModelEvent(this,
(-)src/org/netbeans/modules/search/ResultViewPanel.java (-1 / +49 lines)
Lines 39-45 Link Here
39
39
40
package org.netbeans.modules.search;
40
package org.netbeans.modules.search;
41
41
42
import java.awt.BorderLayout;
43
import java.awt.CardLayout;
42
import java.awt.CardLayout;
44
import java.awt.Color;
43
import java.awt.Color;
45
import java.awt.EventQueue;
44
import java.awt.EventQueue;
Lines 64-71 Link Here
64
import javax.swing.BorderFactory;
63
import javax.swing.BorderFactory;
65
import javax.swing.Box;
64
import javax.swing.Box;
66
import javax.swing.BoxLayout;
65
import javax.swing.BoxLayout;
66
import javax.swing.ButtonGroup;
67
import javax.swing.JButton;
67
import javax.swing.JButton;
68
import javax.swing.JPanel;
68
import javax.swing.JPanel;
69
import javax.swing.JRadioButton;
69
import javax.swing.JScrollPane;
70
import javax.swing.JScrollPane;
70
import javax.swing.JSeparator;
71
import javax.swing.JSeparator;
71
import javax.swing.JSplitPane;
72
import javax.swing.JSplitPane;
Lines 152-157 Link Here
152
    private JButton btnReplace = new JButton();
153
    private JButton btnReplace = new JButton();
153
    private JButton btnPrev;
154
    private JButton btnPrev;
154
    private JButton btnNext;
155
    private JButton btnNext;
156
    private ButtonGroup sortButtonGroup = new ButtonGroup();
157
    private JRadioButton sortButton = new JRadioButton();
158
    private JRadioButton unsortButton = new JRadioButton();
155
    private JToggleButton btnDisplayContext = new JToggleButton();
159
    private JToggleButton btnDisplayContext = new JToggleButton();
156
    private Separator sepDisplayContext;
160
    private Separator sepDisplayContext;
157
161
Lines 257-262 Link Here
257
            }
261
            }
258
        });
262
        });
259
263
264
        //Search sort buttons
265
        final ActionListener listener = new ActionListener() {
266
            public void actionPerformed(ActionEvent e) {
267
                treeModel.setSorted(e.getSource() == sortButton);
268
            }
269
        };
270
        unsortButton.setSelected(true);
271
        sortButtonGroup.add(sortButton);
272
        sortButtonGroup.add(unsortButton);
273
        sortButton.addActionListener(listener);
274
        unsortButton.addActionListener(listener);
275
260
        Mnemonics.setLocalizedText(
276
        Mnemonics.setLocalizedText(
261
                btnStop,
277
                btnStop,
262
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_STOP"));   //NOI18N
278
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_STOP"));   //NOI18N
Lines 269-275 Link Here
269
        Mnemonics.setLocalizedText(
285
        Mnemonics.setLocalizedText(
270
                btnModifySearch,
286
                btnModifySearch,
271
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_CUSTOMIZE"));          //NOI18N
287
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_CUSTOMIZE"));          //NOI18N
288
        Mnemonics.setLocalizedText(
289
                sortButton,
290
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_SORT")); //NOI18N
291
        Mnemonics.setLocalizedText(
292
                unsortButton,
293
                NbBundle.getMessage(ResultView.class, "TEXT_BUTTON_UNSORT")); //NOI18N
272
294
295
        sortButton.setEnabled(false);
296
        unsortButton.setEnabled(false);
297
273
        btnStop.setEnabled(false);
298
        btnStop.setEnabled(false);
274
        btnShowDetails.setEnabled(false);
299
        btnShowDetails.setEnabled(false);
275
300
Lines 277-282 Link Here
277
302
278
        JPanel buttonsPanel = new JPanel();
303
        JPanel buttonsPanel = new JPanel();
279
        buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
304
        buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
305
        buttonsPanel.add(sortButton);
306
        buttonsPanel.add(unsortButton);
280
        buttonsPanel.add(btnReplace);
307
        buttonsPanel.add(btnReplace);
281
        buttonsPanel.add(Box.createHorizontalGlue());
308
        buttonsPanel.add(Box.createHorizontalGlue());
282
        buttonsPanel.add(btnShowDetails);
309
        buttonsPanel.add(btnShowDetails);
Lines 371-376 Link Here
371
        accessCtx.setAccessibleName(bundle.getString("ACSN_ResultTree"));                   //NOI18N
398
        accessCtx.setAccessibleName(bundle.getString("ACSN_ResultTree"));                   //NOI18N
372
        accessCtx.setAccessibleDescription(bundle.getString("ACSD_ResultTree"));                   //NOI18N
399
        accessCtx.setAccessibleDescription(bundle.getString("ACSD_ResultTree"));                   //NOI18N
373
400
401
        sortButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_SORT")); //NOI18N
402
        unsortButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_UNSORT")); //NOI18N
374
        btnReplace.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_REPLACE"));    //NOI18N
403
        btnReplace.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_REPLACE"));    //NOI18N
375
        btnModifySearch.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_CUSTOMIZE")); //NOI18N
404
        btnModifySearch.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_CUSTOMIZE")); //NOI18N
376
        btnShowDetails.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_FILL"));         //NOI18N
405
        btnShowDetails.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_TEXT_BUTTON_FILL"));         //NOI18N
Lines 603-608 Link Here
603
632
604
    /**
633
    /**
605
     */
634
     */
635
    void updateSortButtons() {
636
        assert EventQueue.isDispatchThread();
637
638
        if (searchInProgress) {
639
            unsortButton.setSelected(true);
640
        }
641
        setSortButtonsEnabled(hasResults && !searchInProgress);
642
    }
643
644
    /**
645
     */
606
    void updateShowAllDetailsBtn() {
646
    void updateShowAllDetailsBtn() {
607
        assert EventQueue.isDispatchThread();
647
        assert EventQueue.isDispatchThread();
608
648
Lines 624-629 Link Here
624
                                    "TXT_RootSearchedNodesFulltext"));  //NOI18N
664
                                    "TXT_RootSearchedNodesFulltext"));  //NOI18N
625
665
626
        searchInProgress = true;
666
        searchInProgress = true;
667
        updateSortButtons();
627
        updateShowAllDetailsBtn();
668
        updateShowAllDetailsBtn();
628
        setBtnModifyEnabled(true);
669
        setBtnModifyEnabled(true);
629
        setBtnStopEnabled(true);
670
        setBtnStopEnabled(true);
Lines 638-643 Link Here
638
679
639
        searchInProgress = false;
680
        searchInProgress = false;
640
        hasDetails = (resultModel != null) ? resultModel.hasDetails() : false;
681
        hasDetails = (resultModel != null) ? resultModel.hasDetails() : false;
682
        updateSortButtons();
641
        updateShowAllDetailsBtn();
683
        updateShowAllDetailsBtn();
642
        setBtnStopEnabled(false);
684
        setBtnStopEnabled(false);
643
        setBtnReplaceEnabled(true);
685
        setBtnReplaceEnabled(true);
Lines 655-660 Link Here
655
    void searchCancelled() {
697
    void searchCancelled() {
656
        setRootDisplayName(NbBundle.getMessage(ResultView.class, "TEXT_TASK_CANCELLED"));//NOI18N
698
        setRootDisplayName(NbBundle.getMessage(ResultView.class, "TEXT_TASK_CANCELLED"));//NOI18N
657
        searchInProgress = true;
699
        searchInProgress = true;
700
        updateSortButtons();
658
        updateShowAllDetailsBtn();
701
        updateShowAllDetailsBtn();
659
        setBtnStopEnabled(false);
702
        setBtnStopEnabled(false);
660
        setBtnReplaceEnabled(true);
703
        setBtnReplaceEnabled(true);
Lines 1136-1141 Link Here
1136
        Manager.getInstance().scheduleReplaceTask(taskReplace);
1179
        Manager.getInstance().scheduleReplaceTask(taskReplace);
1137
    }
1180
    }
1138
1181
1182
    void setSortButtonsEnabled(boolean enabled) {
1183
        sortButton.setEnabled(enabled);
1184
        unsortButton.setEnabled(enabled);
1185
    }
1186
1139
    void setBtnModifyEnabled(boolean enabled){
1187
    void setBtnModifyEnabled(boolean enabled){
1140
        btnModifySearch.setEnabled(enabled);
1188
        btnModifySearch.setEnabled(enabled);
1141
    }
1189
    }

Return to bug 119818