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


Java GenerateEqualsWizard类代码示例

本文整理汇总了Java中com.intellij.codeInsight.generation.ui.GenerateEqualsWizard的典型用法代码示例。如果您正苦于以下问题:Java GenerateEqualsWizard类的具体用法?Java GenerateEqualsWizard怎么用?Java GenerateEqualsWizard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenerateEqualsWizard类属于com.intellij.codeInsight.generation.ui包,在下文中一共展示了GenerateEqualsWizard类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chooseOriginalMembers

import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor) {
  myEqualsFields = null;
  myHashCodeFields = null;
  myNonNullFields = PsiField.EMPTY_ARRAY;


  GlobalSearchScope scope = aClass.getResolveScope();
  final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
  final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());

  boolean needEquals = equalsMethod == null;
  boolean needHashCode = hashCodeMethod == null;
  if (!needEquals && !needHashCode) {
    String text = aClass instanceof PsiAnonymousClass
                  ? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
                  : CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());

    if (Messages.showYesNoDialog(project, text,
                                 CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
                                 Messages.getQuestionIcon()) == Messages.YES) {
      if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          try {
            equalsMethod.delete();
            hashCodeMethod.delete();
            return Boolean.TRUE;
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
            return Boolean.FALSE;
          }
        }
      }).booleanValue()) {
        return null;
      }
      else {
        needEquals = needHashCode = true;
      }
    }
    else {
      return null;
    }
  }
  boolean hasNonStaticFields = hasNonStaticFields(aClass);
  if (!hasNonStaticFields) {
    HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
    return null;
  }

  GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
  if (!wizard.showAndGet()) {
    return null;
  }
  myEqualsFields = wizard.getEqualsFields();
  myHashCodeFields = wizard.getHashCodeFields();
  myNonNullFields = wizard.getNonNullFields();
  return DUMMY_RESULT;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:61,代码来源:GenerateEqualsHandler.java

示例2: chooseOriginalMembers

import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入依赖的package包/类
@Override
@Nullable
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
  myEqualsFields = null;
  myHashCodeFields = null;
  myNonNullFields = PsiField.EMPTY_ARRAY;

  GlobalSearchScope scope = aClass.getResolveScope();
  final PsiMethod equalsMethod = GroovyGenerateEqualsHelper
    .findMethod(aClass, GroovyGenerateEqualsHelper.getEqualsSignature(project, scope));
  final PsiMethod hashCodeMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getHashCodeSignature());

  boolean needEquals = equalsMethod == null;
  boolean needHashCode = hashCodeMethod == null;
  if (!needEquals && !needHashCode) {
    String text = aClass instanceof PsiAnonymousClass
                  ? GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
                  : GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());

    if (Messages.showYesNoDialog(project, text,
                                 GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
                                 Messages.getQuestionIcon()) == Messages.YES) {
      if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          try {
            equalsMethod.delete();
            hashCodeMethod.delete();
            return Boolean.TRUE;
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
            return Boolean.FALSE;
          }
        }
      }).booleanValue()) {
        return null;
      }
      else {
        needEquals = needHashCode = true;
      }
    }
    else {
      return null;
    }
  }

  GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
  if (!wizard.showAndGet()) {
    return null;
  }
  myEqualsFields = wizard.getEqualsFields();
  myHashCodeFields = wizard.getHashCodeFields();
  myNonNullFields = wizard.getNonNullFields();
  return DUMMY_RESULT;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:57,代码来源:GroovyGenerateEqualsHandler.java

示例3: chooseOriginalMembers

import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor) {
  myEqualsFields = null;
  myHashCodeFields = null;
  myNonNullFields = PsiField.EMPTY_ARRAY;


  GlobalSearchScope scope = aClass.getResolveScope();
  final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
  final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());

  boolean needEquals = equalsMethod == null;
  boolean needHashCode = hashCodeMethod == null;
  if (!needEquals && !needHashCode) {
    String text = aClass instanceof PsiAnonymousClass
                  ? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
                  : CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());

    if (Messages.showYesNoDialog(project, text,
                                 CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
                                 Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
      if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
          @Override
          public Boolean compute() {
            try {
              equalsMethod.delete();
              hashCodeMethod.delete();
              return Boolean.TRUE;
            }
            catch (IncorrectOperationException e) {
              LOG.error(e);
              return Boolean.FALSE;
            }
          }
        }).booleanValue()) {
        return null;
      } else {
        needEquals = needHashCode = true;
      }
    } else {
      return null;
    }
  }
  boolean hasNonStaticFields = false;
  for (PsiField field : aClass.getFields()) {
    if (!field.hasModifierProperty(PsiModifier.STATIC)){
      hasNonStaticFields = true;
      break;
    }
  }
  if (!hasNonStaticFields) {
    HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
    return null;
  }

  GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
  wizard.show();
  if (!wizard.isOK()) return null;
  myEqualsFields = wizard.getEqualsFields();
  myHashCodeFields = wizard.getHashCodeFields();
  myNonNullFields = wizard.getNonNullFields();
  return DUMMY_RESULT;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:64,代码来源:GenerateEqualsHandler.java

示例4: chooseOriginalMembers

import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入依赖的package包/类
@Nullable
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
  myEqualsFields = null;
  myHashCodeFields = null;
  myNonNullFields = PsiField.EMPTY_ARRAY;

  GlobalSearchScope scope = aClass.getResolveScope();
  final PsiMethod equalsMethod = GroovyGenerateEqualsHelper
    .findMethod(aClass, GroovyGenerateEqualsHelper.getEqualsSignature(project, scope));
  final PsiMethod hashCodeMethod = GroovyGenerateEqualsHelper.findMethod(aClass, GroovyGenerateEqualsHelper.getHashCodeSignature());

  boolean needEquals = equalsMethod == null;
  boolean needHashCode = hashCodeMethod == null;
  if (!needEquals && !needHashCode) {
    String text = aClass instanceof PsiAnonymousClass
        ? GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous")
        : GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());

    if (Messages.showYesNoDialog(project, text,
        GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
        Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
      if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
        public Boolean compute() {
          try {
            equalsMethod.delete();
            hashCodeMethod.delete();
            return Boolean.TRUE;
          }
          catch (IncorrectOperationException e) {
            LOG.error(e);
            return Boolean.FALSE;
          }
        }
      }).booleanValue()) {
        return null;
      } else {
        needEquals = needHashCode = true;
      }
    } else {
      return null;
    }
  }

  GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
  wizard.show();
  if (!wizard.isOK()) return null;
  myEqualsFields = wizard.getEqualsFields();
  myHashCodeFields = wizard.getHashCodeFields();
  myNonNullFields = wizard.getNonNullFields();
  return DUMMY_RESULT;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:52,代码来源:GroovyGenerateEqualsHandler.java

示例5: chooseOriginalMembers

import com.intellij.codeInsight.generation.ui.GenerateEqualsWizard; //导入依赖的package包/类
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project, Editor editor)
{
	myEqualsFields = null;
	myHashCodeFields = null;
	myNonNullFields = PsiField.EMPTY_ARRAY;


	GlobalSearchScope scope = aClass.getResolveScope();
	final PsiMethod equalsMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getEqualsSignature(project, scope));
	final PsiMethod hashCodeMethod = GenerateEqualsHelper.findMethod(aClass, GenerateEqualsHelper.getHashCodeSignature());

	boolean needEquals = equalsMethod == null;
	boolean needHashCode = hashCodeMethod == null;
	if(!needEquals && !needHashCode)
	{
		String text = aClass instanceof PsiAnonymousClass ? CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.warning.anonymous") : CodeInsightBundle.message("generate" +
				".equals.and.hashcode.already.defined.warning", aClass.getQualifiedName());

		if(Messages.showYesNoDialog(project, text, CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"), Messages.getQuestionIcon()) == Messages.YES)
		{
			if(!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>()
			{
				@Override
				public Boolean compute()
				{
					try
					{
						equalsMethod.delete();
						hashCodeMethod.delete();
						return Boolean.TRUE;
					}
					catch(IncorrectOperationException e)
					{
						LOG.error(e);
						return Boolean.FALSE;
					}
				}
			}).booleanValue())
			{
				return null;
			}
			else
			{
				needEquals = needHashCode = true;
			}
		}
		else
		{
			return null;
		}
	}
	boolean hasNonStaticFields = hasNonStaticFields(aClass);
	if(!hasNonStaticFields)
	{
		HintManager.getInstance().showErrorHint(editor, "No fields to include in equals/hashCode have been found");
		return null;
	}

	GenerateEqualsWizard wizard = new GenerateEqualsWizard(project, aClass, needEquals, needHashCode);
	if(!wizard.showAndGet())
	{
		return null;
	}
	myEqualsFields = wizard.getEqualsFields();
	myHashCodeFields = wizard.getHashCodeFields();
	myNonNullFields = wizard.getNonNullFields();
	return DUMMY_RESULT;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:70,代码来源:GenerateEqualsHandler.java


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