Beispiel #1
0
 private static void syncFindModels(FindModel to, FindModel from) {
   to.setCaseSensitive(from.isCaseSensitive());
   to.setWholeWordsOnly(from.isWholeWordsOnly());
   to.setRegularExpressions(from.isRegularExpressions());
   to.setSearchContext(from.getSearchContext());
   if (from.isReplaceState()) {
     to.setPreserveCase(from.isPreserveCase());
   }
 }
  @NotNull
  public static UsageViewPresentation setupViewPresentation(
      final boolean toOpenInNewTab, @NotNull FindModel findModel) {
    final UsageViewPresentation presentation = new UsageViewPresentation();

    final String scope = getTitleForScope(findModel);
    final String stringToFind = findModel.getStringToFind();
    presentation.setScopeText(scope);
    if (stringToFind.isEmpty()) {
      presentation.setTabText("Files");
      presentation.setToolwindowTitle(BundleBase.format("Files in {0}", scope));
      presentation.setUsagesString("files");
    } else {
      FindModel.SearchContext searchContext = findModel.getSearchContext();
      String contextText = "";
      if (searchContext != FindModel.SearchContext.ANY) {
        contextText =
            FindBundle.message(
                "find.context.presentation.scope.label",
                FindDialog.getPresentableName(searchContext));
      }
      presentation.setTabText(
          FindBundle.message("find.usage.view.tab.text", stringToFind, contextText));
      presentation.setToolwindowTitle(
          FindBundle.message("find.usage.view.toolwindow.title", stringToFind, scope, contextText));
      presentation.setUsagesString(FindBundle.message("find.usage.view.usages.text", stringToFind));
      presentation.setUsagesWord(FindBundle.message("occurrence"));
      presentation.setCodeUsagesString(FindBundle.message("found.occurrences"));
      presentation.setContextText(contextText);
    }
    presentation.setOpenInNewTab(toOpenInNewTab);
    presentation.setCodeUsages(false);
    presentation.setUsageTypeFilteringAvailable(true);

    return presentation;
  }