示例#1
0
 @Override
 protected void previewRefactoring(@NotNull final UsageInfo[] usages) {
   MigrationPanel panel = new MigrationPanel(myRoot, myLabeler, myProject, isPreviewUsages());
   String name;
   if (myRoot.length == 1) {
     String fromType =
         assertNotNull(TypeMigrationLabeler.getElementType(myRoot[0])).getPresentableText();
     String toType = myRootTypes.fun(myRoot[0]).getPresentableText();
     String text;
     text = getPresentation(myRoot[0]);
     name = "Migrate Type of " + text + " from \'" + fromType + "\' to \'" + toType + "\'";
   } else {
     final int rootsInPresentationCount =
         myRoot.length > MAX_ROOT_IN_PREVIEW_PRESENTATION
             ? MAX_ROOT_IN_PREVIEW_PRESENTATION
             : myRoot.length;
     String[] rootsPresentation = new String[rootsInPresentationCount];
     for (int i = 0; i < rootsInPresentationCount; i++) {
       final PsiElement root = myRoot[i];
       rootsPresentation[i] =
           root instanceof PsiNamedElement ? ((PsiNamedElement) root).getName() : root.getText();
     }
     rootsPresentation = StringUtil.surround(rootsPresentation, "\'", "\'");
     name = "Migrate Type of " + StringUtil.join(rootsPresentation, ", ");
     if (myRoot.length > MAX_ROOT_IN_PREVIEW_PRESENTATION) {
       name += "...";
     }
   }
   Content content =
       UsageViewManager.getInstance(myProject).addContent(name, false, panel, true, true);
   panel.setContent(content);
   ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND).activate(null);
 }
 @Override
 public void showSettings() {
   Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true);
   JComponent component = selectedContent == null ? null : selectedContent.getComponent();
   FindInProjectManager findInProjectManager = FindInProjectManager.getInstance(myProject);
   findInProjectManager.findInProject(DataManager.getInstance().getDataContext(component));
 }
 @Override
 protected void previewRefactoring(final UsageInfo[] usages) {
   MigrationPanel panel = new MigrationPanel(myRoot[0], myLabeler, myProject, isPreviewUsages());
   String text;
   if (myRoot[0] instanceof PsiField) {
     text = "field \'" + ((PsiField) myRoot[0]).getName() + "\'";
   } else if (myRoot[0] instanceof PsiParameter) {
     text = "parameter \'" + ((PsiParameter) myRoot[0]).getName() + "\'";
   } else if (myRoot[0] instanceof PsiLocalVariable) {
     text = "variable \'" + ((PsiLocalVariable) myRoot[0]).getName() + "\'";
   } else if (myRoot[0] instanceof PsiMethod) {
     text = "method \'" + ((PsiMethod) myRoot[0]).getName() + "\' return";
   } else {
     text = Arrays.toString(myRoot);
   }
   Content content =
       UsageViewManager.getInstance(myProject)
           .addContent(
               "Migrate Type of "
                   + text
                   + " from \'"
                   + TypeMigrationLabeler.getElementType(myRoot[0]).getPresentableText()
                   + "\' to \'"
                   + myRules.getMigrationRootType().getPresentableText()
                   + "\'",
               false,
               panel,
               true,
               true);
   panel.setContent(content);
   ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.FIND).activate(null);
 }
示例#4
0
  public UsageView getSelectedUsageView() {
    final Content content =
        com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent();
    if (content != null) {
      return content.getUserData(USAGE_VIEW_KEY);
    }

    return null;
  }
示例#5
0
 private void addContent(UsageViewImpl usageView, UsageViewPresentation presentation) {
   Content content =
       com.intellij
           .usageView
           .UsageViewManager
           .getInstance(myProject)
           .addContent(
               presentation.getTabText(),
               presentation.getTabName(),
               presentation.getToolwindowTitle(),
               true,
               usageView.getComponent(),
               presentation.isOpenInNewTab(),
               true);
   usageView.setContent(content);
   content.putUserData(USAGE_VIEW_KEY, usageView);
 }
 private boolean mustOpenInNewTab() {
   Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true);
   return selectedContent != null && selectedContent.isPinned();
 }
 @Override
 public void close() {
   // todo ? crazyness
   com.intellij.usages.UsageViewManager.getInstance(myProject).setCurrentSearchCancelled(true);
   UsageViewManager.getInstance(myProject).closeContent(myContent);
 }