1.1 --- a/remoting/ide/usages/src/org/netbeans/modules/jackpot30/ide/usages/RemoteWhereUsedQuery.java Wed Aug 15 20:06:51 2012 +0200
1.2 +++ b/remoting/ide/usages/src/org/netbeans/modules/jackpot30/ide/usages/RemoteWhereUsedQuery.java Fri Aug 24 17:24:50 2012 +0200
1.3 @@ -21,14 +21,16 @@
1.4 import org.netbeans.modules.refactoring.api.Problem;
1.5 import org.netbeans.modules.refactoring.api.RefactoringElement;
1.6 import org.netbeans.modules.refactoring.api.Scope;
1.7 -import org.netbeans.modules.refactoring.api.ScopeDescription;
1.8 -import org.netbeans.modules.refactoring.api.ScopeProvider;
1.9 import org.netbeans.modules.refactoring.api.WhereUsedQuery;
1.10 +import org.netbeans.modules.refactoring.java.api.WhereUsedQueryConstants;
1.11 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
1.12 import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
1.13 import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
1.14 import org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
1.15 import org.netbeans.modules.refactoring.spi.ui.ExpandableTreeElement;
1.16 +import org.netbeans.modules.refactoring.spi.ui.ScopeDescription;
1.17 +import org.netbeans.modules.refactoring.spi.ui.ScopeProvider;
1.18 +import org.netbeans.modules.refactoring.spi.ui.ScopeReference;
1.19 import org.netbeans.modules.refactoring.spi.ui.TreeElement;
1.20 import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory;
1.21 import org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation;
1.22 @@ -75,6 +77,15 @@
1.23 TreePathHandle handle = what.getRefactoringSource().lookup(TreePathHandle.class);
1.24 ElementHandle<?> toSearch = handle.getElementHandle();
1.25 Set<SearchOptions> searchOptions = EnumSet.noneOf(SearchOptions.class);
1.26 + if(what.getBooleanValue(WhereUsedQuery.FIND_REFERENCES)) {
1.27 + searchOptions.add(SearchOptions.USAGES);
1.28 + }
1.29 + if(what.getBooleanValue(WhereUsedQueryConstants.FIND_SUBCLASSES)) {
1.30 + searchOptions.add(SearchOptions.SUB);
1.31 + }
1.32 + if(what.getBooleanValue(WhereUsedQueryConstants.SEARCH_FROM_BASECLASS)) {
1.33 + searchOptions.add(SearchOptions.FROM_BASE);
1.34 + }
1.35
1.36 for (FileObject found : RemoteUsages.findUsages(toSearch, searchOptions, /*XXX*/new AtomicBoolean())) {
1.37 Impl i = new Impl(found, toSearch, searchOptions);
1.38 @@ -209,30 +220,31 @@
1.39 }
1.40
1.41 @Override
1.42 - public int estimateSubNodesCount() {
1.43 + public int estimateChildCount() {
1.44 return 1;
1.45 }
1.46 +
1.47 + @Override
1.48 + public boolean cancel() {
1.49 + // TODO: XXX
1.50 + return true;
1.51 + }
1.52 }
1.53
1.54 private static final Scope REMOTE_SCOPE = Scope.create(Collections.<FileObject>emptyList(), Collections.<NonRecursiveFolder>emptyList(), Collections.<FileObject>emptyList());
1.55 - private static final ScopeDescription REMOTE_SCOPE_DESCRIPTION = new ScopeDescription("remote-scope", "Remote Scope", null, "A") {
1.56 - @Override public Scope getScope() {
1.57 +
1.58 + @ScopeDescription(id="remote-scope", displayName="Remote Scope", position=-300)
1.59 + @ScopeReference(path="org-netbeans-modules-refactoring-java-ui-WhereUsedPanel")
1.60 + public static class RemoteScopeProvider extends ScopeProvider {
1.61 +
1.62 + @Override
1.63 + public boolean initialize(Lookup context, AtomicBoolean cancel) {
1.64 + return RemoteIndex.loadIndices().iterator().hasNext();
1.65 + }
1.66 +
1.67 + @Override
1.68 + public Scope getScope() {
1.69 return REMOTE_SCOPE;
1.70 }
1.71 - };
1.72 -
1.73 - @ServiceProvider(service=ScopeProvider.class)
1.74 - public static final class ScopeProviderImpl implements ScopeProvider {
1.75 -
1.76 - @Override
1.77 - public Iterable<ScopeDescription> scopesFor(Lookup source) {
1.78 - if (RemoteIndex.loadIndices().iterator().hasNext()) {
1.79 - return Collections.singletonList(REMOTE_SCOPE_DESCRIPTION);
1.80 - } else {
1.81 - return Collections.emptyList();
1.82 - }
1.83 - }
1.84 -
1.85 }
1.86 -
1.87 }