private static int compareGroups(ServiceGroupNode group1, ServiceGroupNode group2) {
    ServiceViewDescriptor groupDescriptor1 = group1.getViewDescriptor();
    WeighedItem weighedItem1 = ObjectUtils.tryCast(groupDescriptor1, WeighedItem.class);
    ServiceViewDescriptor groupDescriptor2 = group2.getViewDescriptor();
    WeighedItem weighedItem2 = ObjectUtils.tryCast(groupDescriptor2, WeighedItem.class);
    if (weighedItem1 != null) {
      if (weighedItem2 == null) return -1;

      int diff = weighedItem1.getWeight() - weighedItem2.getWeight();
      if (diff != 0) return diff;
    }
    else if (weighedItem2 != null) {
      return 1;
    }
    String name1 = ServiceViewDragHelper.getDisplayName(groupDescriptor1.getPresentation());
    String name2 = ServiceViewDragHelper.getDisplayName(groupDescriptor2.getPresentation());
    return StringUtil.naturalCompare(name1, name2);
  }
private static int compareGroups(ServiceGroupNode group1, ServiceGroupNode group2)