當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。