当前位置: 首页>>代码示例>>Java>>正文


Java CommonRefactoringUtil.showErrorMessage方法代码示例

本文整理汇总了Java中com.intellij.refactoring.util.CommonRefactoringUtil.showErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CommonRefactoringUtil.showErrorMessage方法的具体用法?Java CommonRefactoringUtil.showErrorMessage怎么用?Java CommonRefactoringUtil.showErrorMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.refactoring.util.CommonRefactoringUtil的用法示例。


在下文中一共展示了CommonRefactoringUtil.showErrorMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  if (myTable.isEditing()) {
    TableCellEditor editor = myTable.getCellEditor();
    if (editor != null) {
      editor.stopCellEditing();
    }
  }
  String errorString = validateData();
  if (errorString != null) { // were errors
    CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, errorString, HelpID.ENCAPSULATE_FIELDS, myProject);
    return;
  }

  if (getCheckedRows().length == 0) {
    CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, "Nothing found to encapsulate", HelpID.ENCAPSULATE_FIELDS, myProject);
    return;
  }

  invokeRefactoring(new EncapsulateFieldsProcessor(myProject, this));
  JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
  settings.ENCAPSULATE_FIELDS_USE_ACCESSORS_WHEN_ACCESSIBLE = myCbUseAccessorsWhenAccessible.isSelected();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:EncapsulateFieldsDialog.java

示例2: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  final Project project = getProject();
  final PsiManager manager = PsiManager.getInstance(project);
  final String targetClassName = getTargetClassName();
  final PsiClass targetClass =
    JavaPsiFacade.getInstance(manager.getProject()).findClass(targetClassName, GlobalSearchScope.allScope(project));
  if (targetClass == null) {
    String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("class.0.not.found", targetClassName));
    CommonRefactoringUtil.showErrorMessage(ReplaceConstructorWithFactoryHandler.REFACTORING_NAME,
                                            message, HelpID.REPLACE_CONSTRUCTOR_WITH_FACTORY, project);
    return;
  }

  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, targetClass)) return;

  invokeRefactoring(new ReplaceConstructorWithFactoryProcessor(project, myConstructor, myContainingClass,
                                                               targetClass, getName()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ReplaceConstructorWithFactoryDialog.java

示例3: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@Override
protected void doAction() {
  if (myParametersTable != null) {
    TableUtil.stopEditing(myParametersTable);
  }
  String message = validateAndCommitData();
  if (message != null) {
    if (message != EXIT_SILENTLY) {
      CommonRefactoringUtil.showErrorMessage(getTitle(), message, getHelpId(), myProject);
    }
    return;
  }
  if (myMethodsToPropagateParameters != null && !mayPropagateParameters()) {
    Messages.showWarningDialog(myProject, RefactoringBundle.message("changeSignature.parameters.wont.propagate"),
                               ChangeSignatureHandler.REFACTORING_NAME);
    myMethodsToPropagateParameters = null;
  }

  myDisposed = true;
  invokeRefactoring(createRefactoringProcessor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ChangeSignatureDialogBase.java

示例4: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  TableUtil.stopEditing(myTable);
  String message = validateAndCommitData();
  if (message != null) {
    CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.incorrect.data"), message, HelpID.CHANGE_SIGNATURE, myClass.getProject());
    return;
  }
  ChangeClassSignatureProcessor processor =
    new ChangeClassSignatureProcessor(myClass.getProject(), myClass,
                                      myTypeParameterInfos.toArray(new TypeParameterInfo[myTypeParameterInfos.size()]));
  invokeRefactoring(processor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ChangeClassSignatureDialog.java

示例5: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  String message = validateInputData();

  if (message != null) {
    if (message.length() != 0) {
      CommonRefactoringUtil.showErrorMessage(
              MoveMembersImpl.REFACTORING_NAME,
              message,
              HelpID.MOVE_MEMBERS,
              myProject);
    }
    return;
  }

  invokeRefactoring(new MoveMembersProcessor(getProject(), myMoveCallback, new MoveMembersOptions() {
    public String getMemberVisibility() {
      return MoveMembersDialog.this.getMemberVisibility();
    }

    public boolean makeEnumConstant() {
      return MoveMembersDialog.this.makeEnumConstant();
    }

    public PsiMember[] getSelectedMembers() {
      return MoveMembersDialog.this.getSelectedMembers();
    }

    public String getTargetClassName() {
      return MoveMembersDialog.this.getTargetClassName();
    }
  }, isOpenInEditor()));

  saveOpenInEditorOption();
  JavaRefactoringSettings.getInstance().MOVE_PREVIEW_USAGES = isPreviewUsages();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:MoveMembersDialog.java

示例6: doRun

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
public void doRun() {
  if (myMembersToMove.isEmpty()){
    String message = RefactoringBundle.message("no.members.selected");
    CommonRefactoringUtil.showErrorMessage(MoveMembersImpl.REFACTORING_NAME, message, HelpID.MOVE_MEMBERS, myProject);
    return;
  }
  super.doRun();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MoveMembersProcessor.java

示例7: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  Project project = myElement.getProject();
  final String name = myNameField.getText().trim();
  if (name.length() == 0) {
    CommonRefactoringUtil.showErrorMessage(InvertBooleanHandler.REFACTORING_NAME,
                                           RefactoringBundle.message("please.enter.a.valid.name.for.inverted.element",
                                                                     UsageViewUtil.getType(myElement)),
                                           InvertBooleanHandler.INVERT_BOOLEAN_HELP_ID, project);
    return;
  }

  invokeRefactoring(new InvertBooleanProcessor(myElement, name));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:InvertBooleanDialog.java

示例8: showFileExistsErrorMessage

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
/**
 * Show standard error dialog containing message about unexpected presense of given file or directory.
 *
 * @param file    file or directory to warn about
 * @param id      ID of refactoring as {@link CommonRefactoringUtil#showErrorMessage} requires
 * @param project active project
 */
protected final void showFileExistsErrorMessage(@NotNull VirtualFile file, @NotNull String id, @NotNull Project project) {
  final String message;
  if (file.isDirectory()) {
    message = PyBundle.message("refactoring.error.directory.exists", file.getName());
  }
  else {
    message = PyBundle.message("refactoring.error.file.exists", file.getName());
  }
  CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"), message, id, project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyBaseConvertModulePackageAction.java

示例9: createModuleFromPackage

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
@VisibleForTesting
public void createModuleFromPackage(@NotNull final PsiDirectory pyPackage) {
  if (pyPackage.getParent() == null) {
    return;
  }

  final String packageName = pyPackage.getName();
  if (!isEmptyPackage(pyPackage)) {
    CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("error.title"),
                                           PyBundle.message("refactoring.convert.package.to.module.error.not.empty.package", packageName),
                                           ID, pyPackage.getProject());
    return;
  }
  final VirtualFile parentDirVFile = pyPackage.getParent().getVirtualFile();
  final String moduleName = packageName + PyNames.DOT_PY;
  final VirtualFile existing = parentDirVFile.findChild(moduleName);
  if (existing != null) {
    showFileExistsErrorMessage(existing, ID, pyPackage.getProject());
    return;
  }
  final PsiFile initPy = pyPackage.findFile(PyNames.INIT_DOT_PY);
  WriteCommandAction.runWriteCommandAction(pyPackage.getProject(), new Runnable() {
    public void run() {
      try {
        if (initPy != null) {
          final VirtualFile initPyVFile = initPy.getVirtualFile();
          initPyVFile.rename(PyConvertPackageToModuleAction.this, moduleName);
          initPyVFile.move(PyConvertPackageToModuleAction.this, parentDirVFile);
        }
        else {
          PyUtil.getOrCreateFile(parentDirVFile.getPath() + "/" + moduleName, pyPackage.getProject());
        }
        pyPackage.getVirtualFile().delete(PyConvertPackageToModuleAction.this);
      }
      catch (IOException e) {
        LOG.error(e);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:PyConvertPackageToModuleAction.java

示例10: doAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doAction() {
  String message = null;
  final String className = getClassName();
  final String parameterName = getParameterName();
  PsiManager manager = PsiManager.getInstance(myProject);
  if ("".equals(className)) {
    message = RefactoringBundle.message("no.class.name.specified");
  }
  else {
    if (!PsiNameHelper.getInstance(manager.getProject()).isIdentifier(className)) {
      message = RefactoringMessageUtil.getIncorrectIdentifierMessage(className);
    }
    else {
      if (myCbPassOuterClass.isSelected()) {
        if ("".equals(parameterName)) {
          message = RefactoringBundle.message("no.parameter.name.specified");
        }
        else {
          if (!PsiNameHelper.getInstance(manager.getProject()).isIdentifier(parameterName)) {
            message = RefactoringMessageUtil.getIncorrectIdentifierMessage(parameterName);
          }
        }
      }
      if (message == null) {
        if (myTargetContainer instanceof PsiClass) {
          PsiClass targetClass = (PsiClass)myTargetContainer;
          PsiClass[] classes = targetClass.getInnerClasses();
          for (PsiClass aClass : classes) {
            if (className.equals(aClass.getName())) {
              message = RefactoringBundle.message("inner.class.exists", className, targetClass.getName());
              break;
            }
          }
        }
        else if (myTargetContainer instanceof PsiDirectory) {
          message = RefactoringMessageUtil.checkCanCreateClass((PsiDirectory)myTargetContainer, className);
        }
      }
    }
  }

  if (message != null) {
    CommonRefactoringUtil.showErrorMessage(
      MoveInnerImpl.REFACTORING_NAME,
      message,
      HelpID.MOVE_INNER_UPPER,
      myProject);
    return;
  }

  JavaRefactoringSettings.getInstance().MOVE_INNER_PREVIEW_USAGES = isPreviewUsages();
  if (myCbPassOuterClass.isSelected() && mySuggestedNameInfo != null) {
    mySuggestedNameInfo.nameChosen(getParameterName());
  }

  final PsiElement target = getTargetContainer();
  if (target == null) return;
  myProcessor.setup(getInnerClass(), className, isPassOuterClass(), parameterName,
                    isSearchInComments(), isSearchInNonJavaFiles(), target);

  final boolean openInEditor = isOpenInEditor();
  saveOpenInEditorOption();
  myProcessor.setOpenInEditor(openInEditor);
  invokeRefactoring(myProcessor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:66,代码来源:MoveInnerDialog.java

示例11: doOKAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doOKAction(){
  String errorString = null;
  final String innerClassName = getClassName();
  final PsiManager manager = PsiManager.getInstance(myProject);
  if ("".equals(innerClassName)) {
    errorString = RefactoringBundle.message("anonymousToInner.no.inner.class.name");
  }
  else {
    if (!PsiNameHelper.getInstance(manager.getProject()).isIdentifier(innerClassName)) {
      errorString = RefactoringMessageUtil.getIncorrectIdentifierMessage(innerClassName);
    }
    else{
      PsiElement targetContainer = AnonymousToInnerHandler.findTargetContainer(myAnonClass);
      if (targetContainer instanceof PsiClass) {
        PsiClass targetClass = (PsiClass)targetContainer;
        PsiClass[] innerClasses = targetClass.getInnerClasses();
        for (PsiClass innerClass : innerClasses) {
          if (innerClassName.equals(innerClass.getName())) {
            errorString = RefactoringBundle.message("inner.class.exists", innerClassName, targetClass.getName());
            break;
          }
        }
      }
      else {
        LOG.assertTrue(false);
      }
    }
  }

  if (errorString != null) {
    CommonRefactoringUtil.showErrorMessage(
      AnonymousToInnerHandler.REFACTORING_NAME,
      errorString,
      HelpID.ANONYMOUS_TO_INNER,
      myProject);
    myNameField.requestFocusInWindow();
    return;
  }
  super.doOKAction();
  myNameField.requestFocusInWindow();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:AnonymousToInnerDialog.java

示例12: doOKAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doOKAction() {
  final String targetClassName = getTargetClassName();
  PsiClass newClass = myParentClass;

  if (!"".equals (targetClassName) && !Comparing.strEqual(targetClassName, myParentClass.getQualifiedName())) {
    newClass = JavaPsiFacade.getInstance(myProject).findClass(targetClassName, GlobalSearchScope.projectScope(myProject));
    if (newClass == null) {
      if (Messages.showOkCancelDialog(myProject, RefactoringBundle.message("class.does.not.exist.in.the.project"), IntroduceConstantHandler.REFACTORING_NAME, Messages.getErrorIcon()) != Messages.OK) {
        return;
      }
      myDestinationClass = new BaseExpressionToFieldHandler.TargetDestination(targetClassName, myParentClass);
    } else {
      myDestinationClass = new BaseExpressionToFieldHandler.TargetDestination(newClass);
    }
  }

  String fieldName = getEnteredName();
  String errorString = null;
  if ("".equals(fieldName)) {
    errorString = RefactoringBundle.message("no.field.name.specified");
  } else if (!PsiNameHelper.getInstance(myProject).isIdentifier(fieldName)) {
    errorString = RefactoringMessageUtil.getIncorrectIdentifierMessage(fieldName);
  } else if (newClass != null && !myParentClass.getLanguage().equals(newClass.getLanguage())) {
    errorString = RefactoringBundle.message("move.to.different.language", UsageViewUtil.getType(myParentClass),
                                            myParentClass.getQualifiedName(), newClass.getQualifiedName());
  }
  if (errorString != null) {
    CommonRefactoringUtil.showErrorMessage(
            IntroduceFieldHandler.REFACTORING_NAME,
            errorString,
            HelpID.INTRODUCE_FIELD,
            myProject);
    return;
  }
  if (newClass != null) {
    PsiField oldField = newClass.findFieldByName(fieldName, true);

    if (oldField != null) {
      int answer = Messages.showYesNoDialog(
              myProject,
              RefactoringBundle.message("field.exists", fieldName, oldField.getContainingClass().getQualifiedName()),
              IntroduceFieldHandler.REFACTORING_NAME,
              Messages.getWarningIcon()
      );
      if (answer != Messages.YES) {
        return;
      }
    }
  }

  JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = getFieldVisibility();

  RecentsManager.getInstance(myProject).registerRecentEntry(RECENTS_KEY, targetClassName);
  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:IntroduceConstantDialog.java

示例13: doOKAction

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
protected void doOKAction() {
  String fieldName = getEnteredName();
  String errorString = null;
  if ("".equals(fieldName)) {
    errorString = RefactoringBundle.message("no.field.name.specified");
  } else if (!PsiNameHelper.getInstance(myProject).isIdentifier(fieldName)) {
    errorString = RefactoringMessageUtil.getIncorrectIdentifierMessage(fieldName);
  }
  if (errorString != null) {
    CommonRefactoringUtil.showErrorMessage(
            IntroduceFieldHandler.REFACTORING_NAME,
            errorString,
            HelpID.INTRODUCE_FIELD,
            myProject
    );
    return;
  }

  PsiField oldField = myParentClass.findFieldByName(fieldName, true);

  if (oldField != null) {
    int answer = Messages.showYesNoDialog(
            myProject,
            RefactoringBundle.message("field.exists", fieldName,
                                 oldField.getContainingClass().getQualifiedName()),
            IntroduceFieldHandler.REFACTORING_NAME,
            Messages.getWarningIcon()
    );
    if (answer != Messages.YES) {
      return;
    }
  }

  myCentralPanel.saveFinalState();
  ourLastInitializerPlace = myCentralPanel.getInitializerPlace();
  JavaRefactoringSettings.getInstance().INTRODUCE_FIELD_VISIBILITY = getFieldVisibility();

  myNameSuggestionsManager.nameSelected();
  myTypeSelectorManager.typeSelected(getFieldType());
  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:IntroduceFieldDialog.java

示例14: showErrorMessage

import com.intellij.refactoring.util.CommonRefactoringUtil; //导入方法依赖的package包/类
private static void showErrorMessage(String message, final Project project) {
  CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, message, null, project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ConvertParameterToMapEntryIntention.java


注:本文中的com.intellij.refactoring.util.CommonRefactoringUtil.showErrorMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。