use of org.intellij.plugins.xpathView.XPathProjectComponent 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);
}
Aggregations