Пример #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
 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);
 }