Java 类com.intellij.util.containers.ComparatorUtil 实例源码

项目:consulo    文件:ColumnResults.java   
private int compareSuites(final SMTestProxy suite1,
                          final SMTestProxy suite2) {
  // Compare errors
  final int errors1 = suite1.getChildren(ProxyFilters.FILTER_ERRORS).size();
  final int errors2 = suite2.getChildren(ProxyFilters.FILTER_ERRORS).size();
  final int errorsComparison = ComparatorUtil.compareInt(errors1, errors2);
  // If not equal return it
  if (errorsComparison != 0) {
    return errorsComparison;
  }

  // Compare failures
  final int failures1 = suite1.getChildren(ProxyFilters.FILTER_FAILURES).size();
  final int failures2 = suite2.getChildren(ProxyFilters.FILTER_FAILURES).size();
  final int failuresComparison = ComparatorUtil.compareInt(failures1, failures2);
  // If not equal return it
  if (failuresComparison != 0) {
    return failuresComparison;
  }

  // otherwise check passed count
  final int passed1 = suite1.getChildren(ProxyFilters.FILTER_PASSED).size();
  final int passed2 = suite2.getChildren(ProxyFilters.FILTER_PASSED).size();

  return ComparatorUtil.compareInt(passed1, passed2);
}
项目:consulo    文件:ContentEntryTreeEditor.java   
protected void updateMarkActions() {
  myEditingActionsGroup.removeAll();

  Set<ContentFolderTypeProvider> folders = ContentFoldersSupportUtil.getSupportedFolders(myState.getRootModel());
  ContentFolderTypeProvider[] supportedFolders = folders.toArray(new ContentFolderTypeProvider[folders.size()]);
  Arrays.sort(supportedFolders, new Comparator<ContentFolderTypeProvider>() {
    @Override
    public int compare(ContentFolderTypeProvider o1, ContentFolderTypeProvider o2) {
      return ComparatorUtil.compareInt(o1.getWeight(), o2.getWeight());
    }
  });
  for (ContentFolderTypeProvider contentFolderTypeProvider : supportedFolders) {
    ToggleFolderStateAction action = new ToggleFolderStateAction(myTree, this, contentFolderTypeProvider);
   /* CustomShortcutSet shortcutSet = editor.getMarkRootShortcutSet();
    if (shortcutSet != null) {
      action.registerCustomShortcutSet(shortcutSet, myTree);
    }     */
    myEditingActionsGroup.add(action);
  }
}
项目:intellij-ce-playground    文件:SwingHelper.java   
private static <T> boolean shouldUpdate(@NotNull JComboBox comboBox, @NotNull List<T> newItems) {
  int count = comboBox.getItemCount();
  if (newItems.size() != count) {
    return true;
  }
  for (int i = 0; i < count; i++) {
    Object oldItem = comboBox.getItemAt(i);
    T newItem = newItems.get(i);
    if (!ComparatorUtil.equalsNullable(oldItem, newItem)) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:DetailsTabForm.java   
private void updateSelectedDeveloper() {
  myProcessEvents = false;

  Integer index = null;
  for (int i = 0; i < myAssigneeComboBox.getItemCount(); i++) {
    Developer developer = (Developer) myAssigneeComboBox.getItemAt(i);
    if (ComparatorUtil.equalsNullable(developer.getId(), myAssigneeId)) {
      index = i;
      break;
    }
  }
  setSelectedAssigneeIndex(index);

  myProcessEvents = true;
}
项目:intellij-ce-playground    文件:PathUtilEx.java   
@Nullable
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> jdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (jdks.isEmpty()) {
    return null;
  }
  Collections.sort(jdks, ComparatorUtil.compareBy(JDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return jdks.get(jdks.size() - 1);
}
项目:intellij-ce-playground    文件:PyConsoleOptions.java   
public boolean isModified(AbstractPyCommonOptionsForm form) {
  return !ComparatorUtil.equalsNullable(mySdkHome, form.getSdkHome()) ||
         !myInterpreterOptions.equals(form.getInterpreterOptions()) ||
         !myEnvs.equals(form.getEnvs()) ||
         myUseModuleSdk != form.isUseModuleSdk() ||
         myAddContentRoots != form.shouldAddContentRoots() ||
         myAddSourceRoots != form.shouldAddSourceRoots()
         || !ComparatorUtil.equalsNullable(myModuleName, form.getModule() == null ? null : form.getModule().getName())
         || !myWorkingDirectory.equals(form.getWorkingDirectory())
         || !myMappings.equals(form.getMappingSettings());
}
项目:intellij-ce-playground    文件:PathUtilEx.java   
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> sdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (sdks.isEmpty()) {
    return null;
  }
  Collections.sort(sdks, ComparatorUtil.compareBy(SDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return sdks.get(sdks.size() - 1);
}
项目:intellij-ce-playground    文件:ExternalPSIChangeListener.java   
public void activate() {
  if (!myRunState) {
    start();
    if (!ComparatorUtil.equalsNullable(myContent, myDesigner.getEditorText()) || myDesigner.getRootComponent() == null) {
      myUpdateRenderer = false;
      addRequest();
    }
    myContent = null;
  }
}
项目:tools-idea    文件:DetailsTabForm.java   
private void updateSelectedDeveloper() {
  myProcessEvents = false;

  Integer index = null;
  for (int i = 0; i < myAssigneeComboBox.getItemCount(); i++) {
    Developer developer = (Developer) myAssigneeComboBox.getItemAt(i);
    if (ComparatorUtil.equalsNullable(developer.getId(), myAssigneeId)) {
      index = i;
      break;
    }
  }
  setSelectedAssigneeIndex(index);

  myProcessEvents = true;
}
项目:tools-idea    文件:WideSelectionTreeUI.java   
@Override
protected Color getHashColor() {
  if (invertLineColor && !ComparatorUtil.equalsNullable(UIUtil.getTreeSelectionForeground(), UIUtil.getTreeForeground())) {
    final Color c = UIUtil.getTreeSelectionForeground();
    if (c != null) {
      return c.darker();
    }
  }
  return super.getHashColor();
}
项目:tools-idea    文件:PathUtilEx.java   
@Nullable
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> jdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (jdks.isEmpty()) {
    return null;
  }
  Collections.sort(jdks, ComparatorUtil.compareBy(JDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return jdks.get(jdks.size() - 1);
}
项目:tools-idea    文件:PathUtilEx.java   
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> sdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (sdks.isEmpty()) {
    return null;
  }
  Collections.sort(sdks, ComparatorUtil.compareBy(SDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return sdks.get(sdks.size() - 1);
}
项目:tools-idea    文件:ExternalPSIChangeListener.java   
public void activate() {
  if (!myRunState) {
    start();
    if (!ComparatorUtil.equalsNullable(myContent, myDesigner.getEditorText()) || myDesigner.getRootComponent() == null) {
      myUpdateRenderer = false;
      addRequest();
    }
    myContent = null;
  }
}
项目:cordovastudio    文件:ExternalPSIChangeListener.java   
public void activate() {
    if (!myRunState) {
        start();
        if (!ComparatorUtil.equalsNullable(myContent, myDesigner.getEditorText()) || myDesigner.getRootComponent() == null) {
            myUpdateRenderer = false;
            addRequest();
        }
        myContent = null;
    }
}
项目:consulo-apache-ant    文件:PathUtilEx.java   
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> sdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (sdks.isEmpty()) {
    return null;
  }
  Collections.sort(sdks, ComparatorUtil.compareBy(SDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return sdks.get(sdks.size() - 1);
}
项目:consulo    文件:ColumnResults.java   
private int compareTests(final SMTestProxy test1, final SMTestProxy test2) {
  // Rule1. For tests: NotRun < Ignored, etc < Passed < Failure < Error < Progress < Terminated

  final int weight1 = test1.getMagnitudeInfo().getSortWeight();
  final int weight2 = test2.getMagnitudeInfo().getSortWeight();

  return ComparatorUtil.compareInt(weight1, weight2);
}
项目:consulo    文件:DetailsTabForm.java   
private void updateSelectedDeveloper() {
  myProcessEvents = false;

  Integer index = null;
  for (int i = 0; i < myAssigneeComboBox.getItemCount(); i++) {
    Developer developer = (Developer) myAssigneeComboBox.getItemAt(i);
    if (ComparatorUtil.equalsNullable(developer.getId(), myAssigneeId)) {
      index = i;
      break;
    }
  }
  setSelectedAssigneeIndex(index);

  myProcessEvents = true;
}
项目:consulo-java    文件:PathUtilEx.java   
@Nullable
public static Sdk chooseJdk(Collection<Module> modules) {
  List<Sdk> jdks = skipNulls(map(skipNulls(modules), MODULE_JDK));
  if (jdks.isEmpty()) {
    return null;
  }
  Collections.sort(jdks, ComparatorUtil.compareBy(JDK_VERSION, String.CASE_INSENSITIVE_ORDER));
  return jdks.get(jdks.size() - 1);
}
项目:intellij-tasks-navigate    文件:AnnotationConfig.java   
@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;

  AnnotationConfig that = (AnnotationConfig) o;

  if (!ComparatorUtil.equalsNullable(myAnnotation, that.myAnnotation)) return false;
  if (!ComparatorUtil.equalsNullable(myElement, that.myElement)) return false;

  return true;
}
项目:intellij-ce-playground    文件:TypesUtil.java   
@Nullable
public static PsiType getLeastUpperBound(@NotNull PsiType type1, @NotNull PsiType type2, PsiManager manager) {
  if (type1 instanceof GrTupleType && type2 instanceof GrTupleType) {
    GrTupleType tuple1 = (GrTupleType)type1;
    GrTupleType tuple2 = (GrTupleType)type2;
    PsiType[] components1 = tuple1.getComponentTypes();
    PsiType[] components2 = tuple2.getComponentTypes();

    if (components1.length == 0) return genNewListBy(type2, manager);
    if (components2.length == 0) return genNewListBy(type1, manager);

    PsiType[] components3 = PsiType.createArray(Math.min(components1.length, components2.length));
    for (int i = 0; i < components3.length; i++) {
      PsiType c1 = components1[i];
      PsiType c2 = components2[i];
      if (c1 == null || c2 == null) {
        components3[i] = null;
      }
      else {
        components3[i] = getLeastUpperBound(c1, c2, manager);
      }
    }
    return new GrImmediateTupleType(components3, JavaPsiFacade.getInstance(manager.getProject()), tuple1.getScope().intersectWith(tuple2.getResolveScope()));
  }
  else if (checkEmptyListAndList(type1, type2)) {
    return genNewListBy(type2, manager);
  }
  else if (checkEmptyListAndList(type2, type1)) {
    return genNewListBy(type1, manager);
  }
  else if (type1 instanceof GrMapType && type2 instanceof GrMapType) {
    return GrMapType.merge(((GrMapType)type1), ((GrMapType)type2));
  }
  else if (checkEmptyMapAndMap(type1, type2)) {
    return genNewMapBy(type2, manager);
  }
  else if (checkEmptyMapAndMap(type2, type1)) {
    return genNewMapBy(type1, manager);
  }
  else if (type1 instanceof GrClosureType && type2 instanceof GrClosureType) {
    GrClosureType clType1 = (GrClosureType)type1;
    GrClosureType clType2 = (GrClosureType)type2;
    GrSignature signature1 = clType1.getSignature();
    GrSignature signature2 = clType2.getSignature();

    if (signature1 instanceof GrClosureSignature && signature2 instanceof GrClosureSignature) {
      if (((GrClosureSignature)signature1).getParameterCount() == ((GrClosureSignature)signature2).getParameterCount()) {
        final GrClosureSignature signature = GrImmediateClosureSignatureImpl.getLeastUpperBound(((GrClosureSignature)signature1),
                                                                                                ((GrClosureSignature)signature2), manager);
        if (signature != null) {
          GlobalSearchScope scope = clType1.getResolveScope().intersectWith(clType2.getResolveScope());
          final LanguageLevel languageLevel = ComparatorUtil.max(clType1.getLanguageLevel(), clType2.getLanguageLevel());
          return GrClosureType.create(signature, scope, JavaPsiFacade.getInstance(manager.getProject()), languageLevel, true);
        }
      }
    }
  }
  else if (GroovyCommonClassNames.GROOVY_LANG_GSTRING.equals(getQualifiedName(type1)) &&
           CommonClassNames.JAVA_LANG_STRING.equals(getQualifiedName(type2))) {
    return type2;
  }
  else if (GroovyCommonClassNames.GROOVY_LANG_GSTRING.equals(getQualifiedName(type2)) &&
           CommonClassNames.JAVA_LANG_STRING.equals(getQualifiedName(type1))) {
    return type1;
  }
  return GenericsUtil.getLeastUpperBound(type1, type2, manager);
}
项目:tools-idea    文件:TypesUtil.java   
@Nullable
public static PsiType getLeastUpperBound(@NotNull PsiType type1, @NotNull PsiType type2, PsiManager manager) {
  if (type1 instanceof GrTupleType && type2 instanceof GrTupleType) {
    GrTupleType tuple1 = (GrTupleType)type1;
    GrTupleType tuple2 = (GrTupleType)type2;
    PsiType[] components1 = tuple1.getComponentTypes();
    PsiType[] components2 = tuple2.getComponentTypes();

    if (components1.length == 0) return genNewListBy(type2, manager);
    if (components2.length == 0) return genNewListBy(type1, manager);

    PsiType[] components3 = new PsiType[Math.min(components1.length, components2.length)];
    for (int i = 0; i < components3.length; i++) {
      PsiType c1 = components1[i];
      PsiType c2 = components2[i];
      if (c1 == null || c2 == null) {
        components3[i] = null;
      }
      else {
        components3[i] = getLeastUpperBound(c1, c2, manager);
      }
    }
    return new GrTupleType(components3, JavaPsiFacade.getInstance(manager.getProject()),
                           tuple1.getScope().intersectWith(tuple2.getResolveScope()));
  }
  else if (checkEmptyListAndList(type1, type2)) {
    return genNewListBy(type2, manager);
  }
  else if (checkEmptyListAndList(type2, type1)) {
    return genNewListBy(type1, manager);
  }
  else if (type1 instanceof GrMapType && type2 instanceof GrMapType) {
    return GrMapType.merge(((GrMapType)type1), ((GrMapType)type2));
  }
  else if (checkEmptyMapAndMap(type1, type2)) {
    return genNewMapBy(type2, manager);
  }
  else if (checkEmptyMapAndMap(type2, type1)) {
    return genNewMapBy(type1, manager);
  }
  else if (type1 instanceof GrClosureType && type2 instanceof GrClosureType) {
    GrClosureType clType1 = (GrClosureType)type1;
    GrClosureType clType2 = (GrClosureType)type2;
    GrSignature signature1 = clType1.getSignature();
    GrSignature signature2 = clType2.getSignature();

    if (signature1 instanceof GrClosureSignature && signature2 instanceof GrClosureSignature) {
      if (((GrClosureSignature)signature1).getParameterCount() == ((GrClosureSignature)signature2).getParameterCount()) {
        final GrClosureSignature signature = GrClosureSignatureImpl.getLeastUpperBound(((GrClosureSignature)signature1),
                                                                                       ((GrClosureSignature)signature2), manager);
        if (signature != null) {
          GlobalSearchScope scope = clType1.getResolveScope().intersectWith(clType2.getResolveScope());
          final LanguageLevel languageLevel = ComparatorUtil.max(clType1.getLanguageLevel(), clType2.getLanguageLevel());
          return GrClosureType.create(signature, scope, JavaPsiFacade.getInstance(manager.getProject()), languageLevel, true);
        }
      }
    }
  }
  else if (GroovyCommonClassNames.GROOVY_LANG_GSTRING.equals(type1.getCanonicalText()) &&
           CommonClassNames.JAVA_LANG_STRING.equals(type2.getInternalCanonicalText())) {
    return type2;
  }
  else if (GroovyCommonClassNames.GROOVY_LANG_GSTRING.equals(type2.getCanonicalText()) &&
           CommonClassNames.JAVA_LANG_STRING.equals(type1.getInternalCanonicalText())) {
    return type1;
  }
  final PsiType result = getLeastUpperBoundForNumericType(type1, type2);
  if (result != null) return result;
  return GenericsUtil.getLeastUpperBound(type1, type2, manager);
}