Lines 44-58
Link Here
|
44 |
|
44 |
|
45 |
package org.netbeans.modules.search.project; |
45 |
package org.netbeans.modules.search.project; |
46 |
|
46 |
|
|
|
47 |
import java.awt.Image; |
48 |
import java.awt.image.BufferedImage; |
49 |
import java.beans.BeanInfo; |
47 |
import java.util.ArrayList; |
50 |
import java.util.ArrayList; |
48 |
import java.util.Collection; |
51 |
import java.util.Collection; |
49 |
import java.util.HashMap; |
52 |
import java.util.HashMap; |
50 |
import java.util.List; |
53 |
import java.util.List; |
51 |
import java.util.Map; |
54 |
import java.util.Map; |
|
|
55 |
import javax.swing.Icon; |
56 |
import org.netbeans.api.annotations.common.StaticResource; |
52 |
import org.netbeans.api.search.provider.SearchInfo; |
57 |
import org.netbeans.api.search.provider.SearchInfo; |
53 |
import org.netbeans.api.search.provider.SearchInfoUtils; |
58 |
import org.netbeans.api.search.provider.SearchInfoUtils; |
54 |
import org.netbeans.spi.search.SearchScopeDefinition; |
59 |
import org.netbeans.spi.search.SearchScopeDefinition; |
55 |
import org.openide.nodes.Node; |
60 |
import org.openide.nodes.Node; |
|
|
61 |
import org.openide.util.ImageUtilities; |
56 |
import org.openide.util.Lookup; |
62 |
import org.openide.util.Lookup; |
57 |
import org.openide.util.LookupEvent; |
63 |
import org.openide.util.LookupEvent; |
58 |
import org.openide.util.LookupListener; |
64 |
import org.openide.util.LookupListener; |
Lines 69-78
Link Here
|
69 |
*/ |
75 |
*/ |
70 |
final class SearchScopeNodeSelection extends SearchScopeDefinition |
76 |
final class SearchScopeNodeSelection extends SearchScopeDefinition |
71 |
implements LookupListener { |
77 |
implements LookupListener { |
72 |
|
78 |
@StaticResource |
|
|
79 |
private static final String MORE_ICON_ID = |
80 |
"org/netbeans/modules/search/project/resources/more.png"; //NOI18N |
81 |
|
82 |
@StaticResource |
83 |
private static final String MULTI_SELECTION_ID = |
84 |
"org/netbeans/modules/search/project/resources/pages_qualifier.png"; //NOI18N |
85 |
private static final Icon MULTI_SELECTION_ICON; |
86 |
|
73 |
private final Lookup.Result<Node> lookupResult; |
87 |
private final Lookup.Result<Node> lookupResult; |
74 |
private LookupListener lookupListener; |
88 |
private LookupListener lookupListener; |
75 |
|
89 |
|
|
|
90 |
static { |
91 |
MULTI_SELECTION_ICON = ImageUtilities.loadImageIcon( |
92 |
MULTI_SELECTION_ID, false); |
93 |
} |
94 |
|
76 |
public SearchScopeNodeSelection() { |
95 |
public SearchScopeNodeSelection() { |
77 |
Lookup lookup = Utilities.actionsGlobalContext(); |
96 |
Lookup lookup = Utilities.actionsGlobalContext(); |
78 |
lookupResult = lookup.lookupResult(Node.class); |
97 |
lookupResult = lookup.lookupResult(Node.class); |
Lines 324-327
Link Here
|
324 |
public void resultChanged(LookupEvent ev) { |
343 |
public void resultChanged(LookupEvent ev) { |
325 |
notifyListeners(); |
344 |
notifyListeners(); |
326 |
} |
345 |
} |
|
|
346 |
|
347 |
@Override |
348 |
public Icon getIcon() { |
349 |
Node[] nodes = getNodes(); |
350 |
if (nodes.length > 1) { |
351 |
return MULTI_SELECTION_ICON; |
352 |
} else if (nodes.length == 1 && nodes[0] != null) { |
353 |
Node n = nodes[0]; |
354 |
Image image = n.getIcon(BeanInfo.ICON_COLOR_16x16); |
355 |
if (image != null) { |
356 |
return ImageUtilities.image2Icon(image); |
357 |
} else { |
358 |
return null; |
359 |
} |
360 |
} else { |
361 |
return null; |
362 |
} |
363 |
} |
327 |
} |
364 |
} |