Line 1
Link Here
|
|
|
1 |
/* |
2 |
* Sun Public License Notice |
3 |
* |
4 |
* The contents of this file are subject to the Sun Public License |
5 |
* Version 1.0 (the "License"). You may not use this file except in |
6 |
* compliance with the License. A copy of the License is available at |
7 |
* http://www.sun.com/ |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
13 |
package org.netbeans.api.queries; |
14 |
import org.openide.filesystems.FileObject; |
15 |
import org.openide.util.Lookup; |
16 |
import org.netbeans.spi.queries.VisibilityQueryImplementation; |
17 |
import java.util.Iterator; |
18 |
/** |
19 |
* Determine whether files should be hidden in viewes |
20 |
* presented to the user. This query should be considered |
21 |
* only as a recommendation and there isn't necessary to obey it. |
22 |
* |
23 |
* @see org.netbeans.spi.queries.VisibilityQueryImplementation |
24 |
* @author Radek Matous |
25 |
*/ |
26 |
public class VisibilityQuery { |
27 |
private static final Lookup.Result/*<VisibilityQueryImplementation>*/ implementations = |
28 |
Lookup.getDefault().lookup(new Lookup.Template(VisibilityQueryImplementation.class)); |
29 |
/** |
30 |
* Check whether an file is recommended to be hidden. |
31 |
* @param file a file which should be checked |
32 |
* @return true if there is recommended to hide this file |
33 |
*/ |
34 |
public static boolean isHidden (FileObject file) { |
35 |
boolean isHidden = false; |
36 |
Iterator it = implementations.allInstances().iterator(); |
37 |
while (it.hasNext() && !isHidden) { |
38 |
VisibilityQueryImplementation vqi = (VisibilityQueryImplementation)it.next(); |
39 |
isHidden = vqi.isHidden(file); |
40 |
} |
41 |
return isHidden; |
42 |
} |
43 |
} |