Search in sources :

Example 1 with FindProgressIndicator

use of com.intellij.find.FindProgressIndicator in project intellij-community by JetBrains.

the class SearchCommand method startSearching.

public void startSearching() {
    final UsageViewContext context = createUsageViewContext();
    final UsageViewPresentation presentation = new UsageViewPresentation();
    presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
    context.configure(presentation);
    final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
    processPresentation.setShowNotFoundMessage(true);
    processPresentation.setShowPanelIfOnlyOneUsage(true);
    processPresentation.setProgressIndicatorFactory(new Factory<ProgressIndicator>() {

        @Override
        public ProgressIndicator create() {
            FindProgressIndicator indicator = new FindProgressIndicator(mySearchContext.getProject(), presentation.getScopeText());
            indicator.addStateDelegate(new AbstractProgressIndicatorExBase() {

                @Override
                public void cancel() {
                    super.cancel();
                    stopAsyncSearch();
                }
            });
            return indicator;
        }
    });
    PsiDocumentManager.getInstance(mySearchContext.getProject()).commitAllDocuments();
    final ConfigurableUsageTarget target = context.getTarget();
    ((FindManagerImpl) FindManager.getInstance(mySearchContext.getProject())).getFindUsagesManager().addToHistory(target);
    UsageViewManager.getInstance(mySearchContext.getProject()).searchAndShowUsages(new UsageTarget[] { target }, () -> new UsageSearcher() {

        @Override
        public void generate(@NotNull final Processor<Usage> processor) {
            findUsages(processor);
        }
    }, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {

        @Override
        public void usageViewCreated(@NotNull UsageView usageView) {
            context.setUsageView(usageView);
            context.configureActions();
        }

        @Override
        public void findingUsagesFinished(final UsageView usageView) {
        }
    });
}
Also used : AbstractProgressIndicatorExBase(com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase) FindProgressIndicator(com.intellij.find.FindProgressIndicator) FindProgressIndicator(com.intellij.find.FindProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 2 with FindProgressIndicator

use of com.intellij.find.FindProgressIndicator in project intellij-community by JetBrains.

the class XPathEvalAction method showUsageView.

public static void showUsageView(@NotNull final Project project, MyUsageTarget usageTarget, Factory<UsageSearcher> searcherFactory, final EditExpressionAction editAction) {
    final UsageViewPresentation presentation = new UsageViewPresentation();
    presentation.setTargetsNodeText("XPath Expression");
    presentation.setCodeUsages(false);
    presentation.setCodeUsagesString("Found Matches");
    presentation.setNonCodeUsagesString("Result");
    presentation.setUsagesString("XPath Result");
    presentation.setUsagesWord("match");
    final ItemPresentation targetPresentation = usageTarget.getPresentation();
    if (targetPresentation != null) {
        presentation.setTabText(StringUtil.shortenTextWithEllipsis("XPath '" + targetPresentation.getPresentableText() + '\'', 60, 0, true));
    } else {
        presentation.setTabText("XPath");
    }
    presentation.setScopeText("XML Files");
    presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
    final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
    processPresentation.setProgressIndicatorFactory(() -> new FindProgressIndicator(project, "XML Document(s)"));
    processPresentation.setShowPanelIfOnlyOneUsage(true);
    processPresentation.setShowNotFoundMessage(true);
    final UsageTarget[] usageTargets = { usageTarget };
    UsageViewManager.getInstance(project).searchAndShowUsages(usageTargets, searcherFactory, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {

        @Override
        public void usageViewCreated(@NotNull UsageView usageView) {
            usageView.addButtonToLowerPane(editAction, "&Edit Expression");
        }

        @Override
        public void findingUsagesFinished(UsageView usageView) {
        }
    });
}
Also used : FindProgressIndicator(com.intellij.find.FindProgressIndicator) ItemPresentation(com.intellij.navigation.ItemPresentation)

Example 3 with FindProgressIndicator

use of com.intellij.find.FindProgressIndicator in project intellij-community by JetBrains.

the class FindByXPathAction method executeSearch.

private void executeSearch(@NotNull final Project project, final Module module) {
    final Config settings = XPathAppComponent.getInstance().getConfig();
    final XPathProjectComponent projectComponent = XPathProjectComponent.getInstance(project);
    final FindByExpressionDialog dlg = new FindByExpressionDialog(project, settings, projectComponent.getFindHistory(), module);
    if (!dlg.show(null)) {
        return;
    }
    final SearchScope scope = dlg.getScope();
    settings.MATCH_RECURSIVELY = dlg.isMatchRecursively();
    settings.SEARCH_SCOPE = dlg.getScope();
    final InputExpressionDialog.Context context = dlg.getContext();
    projectComponent.addFindHistory(context.input);
    final String expression = context.input.expression;
    if (!validateExpression(project, expression)) {
        return;
    }
    final UsageViewPresentation presentation = new UsageViewPresentation();
    presentation.setTargetsNodeText(settings.MATCH_RECURSIVELY ? "XPath Pattern" : "XPath Expression");
    presentation.setCodeUsages(false);
    presentation.setCodeUsagesString("Found Matches in " + scope.getName());
    presentation.setNonCodeUsagesString("Result");
    presentation.setUsagesString("results matching '" + expression + '\'');
    presentation.setUsagesWord("match");
    presentation.setTabText(StringUtil.shortenTextWithEllipsis("XPath '" + expression + '\'', 60, 0, true));
    presentation.setScopeText(scope.getName());
    presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
    final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
    processPresentation.setProgressIndicatorFactory(() -> new FindProgressIndicator(project, scope.getName()));
    processPresentation.setShowPanelIfOnlyOneUsage(true);
    processPresentation.setShowNotFoundMessage(true);
    final XPathEvalAction.MyUsageTarget usageTarget = new XPathEvalAction.MyUsageTarget(context.input.expression, null);
    final UsageTarget[] usageTargets = new UsageTarget[] { usageTarget };
    final Factory<UsageSearcher> searcherFactory = () -> new XPathUsageSearcher(project, context.input, scope, settings.MATCH_RECURSIVELY);
    final UsageViewManager.UsageViewStateListener stateListener = new UsageViewManager.UsageViewStateListener() {

        public void usageViewCreated(@NotNull UsageView usageView) {
            usageView.addButtonToLowerPane(new MyEditExpressionAction(project, module), "&Edit Expression");
        }

        public void findingUsagesFinished(UsageView usageView) {
        }
    };
    UsageViewManager.getInstance(project).searchAndShowUsages(usageTargets, searcherFactory, processPresentation, presentation, stateListener);
}
Also used : Config(org.intellij.plugins.xpathView.Config) XPathEvalAction(org.intellij.plugins.xpathView.XPathEvalAction) NotNull(org.jetbrains.annotations.NotNull) FindProgressIndicator(com.intellij.find.FindProgressIndicator) XPathProjectComponent(org.intellij.plugins.xpathView.XPathProjectComponent) InputExpressionDialog(org.intellij.plugins.xpathView.ui.InputExpressionDialog)

Aggregations

FindProgressIndicator (com.intellij.find.FindProgressIndicator)3 ItemPresentation (com.intellij.navigation.ItemPresentation)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 AbstractProgressIndicatorExBase (com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase)1 Config (org.intellij.plugins.xpathView.Config)1 XPathEvalAction (org.intellij.plugins.xpathView.XPathEvalAction)1 XPathProjectComponent (org.intellij.plugins.xpathView.XPathProjectComponent)1 InputExpressionDialog (org.intellij.plugins.xpathView.ui.InputExpressionDialog)1 NotNull (org.jetbrains.annotations.NotNull)1