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.

Bug 121304 - Find action's state in toolbar is quite opposite if there is no open project
Summary: Find action's state in toolbar is quite opposite if there is no open project
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marian Petras
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2007-11-06 15:49 UTC by Marian Petras
Modified: 2008-03-31 10:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Petras 2007-11-06 15:49:48 UTC
If there is no project opened and the Find action is present on the toolbar, the state of the Find action is disabled
when it should be enabled and vice versa.

To reproduce:
1) Customize some of the toolbars - add action "Find in Projects..." to it.
2) Close all projects.
3) Open and activate window Favorites.
4) In the Favorites window, select and unselect the first node.

The Find action's button in the toolbar will be enabled if there is no node selected and it will be disabled if there is
a node selected. This is exactly opposite behaviour to the expected one.
Comment 1 Marian Petras 2007-11-06 16:01:22 UTC
This is caused by a trivial mistake in class SearchScopeNodeSelection. It listens on TopComponent.Registry for changes
in the set of _selected_ nodes but then it asks for _activated_ nodes. This, combined with the order of property change
events fired by TopComponent.Registry (see below) causes the bad behaviour.

It seems that when a first node is selected in a TopComponent, the following happens:

1) TopComponent.Registry's value of _selectedNodes_ is updated.
   (such that it contains a one-element array containing the just selected node).
   Value if _activatedNodes_ is not updated yet.
2) TopComponent.Registry notifies all registered PropertyChangeListeners (propertyName is "PROP_SELECTED_NODES").
3) TopComponent.Registry's value of _activatedNodes_ is updated.
   (such that it contains a one-element array containing the just selected node).
4) TopComponent.Registry notifies all registered PropertyChangeListeners (propertyName is "PROP_ACTIVATED_NODES").

SearchScopeNodeSelection asks for an array of _activatedNodes_ during step 2), i.e. just before the value is updated.
The consequence is that it always gets the previous value. If the user just toggles between empty selection and one-node
selection, the result is that state of SearchScopeNodeSelection is always quite opposite than it should be.
Comment 2 Marian Petras 2007-11-06 16:04:48 UTC
Fixed in the trunk.

Modified file:
    utilities/src/org/netbeans/modules/search/SearchScopeNodeSelection.java   (1.9)

Diff:
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/src/org/netbeans/modules/search/SearchScopeNodeSelection.java?r1=1.8&r2=1.9
Comment 3 Marian Petras 2008-03-31 10:40:01 UTC
Target milestone set to the actual milestone (6.1).