001 /* 002 * file FoldersFirstSorter.java 003 * 004 * Licensed Materials - Property of IBM 005 * Restricted Materials of IBM - you are allowed to copy, modify and 006 * redistribute this file as part of any program that interfaces with 007 * IBM Rational CM API. 008 * 009 * com.ibm.rational.teamapi.scout.FoldersFirstSorter 010 * 011 * © Copyright IBM Corporation 2004, 2008. All Rights Reserved. 012 * Note to U.S. Government Users Restricted Rights: Use, duplication or 013 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 014 */ 015 package com.ibm.rational.teamapi.scout; 016 017 import org.eclipse.jface.viewers.ViewerSorter; 018 019 /** 020 * A ViewSorter that shorts folders in front of non-folders reqardless of name. 021 */ 022 public class FoldersFirstSorter extends ViewerSorter { 023 /** Orders the items in such a way that Folders appear 024 * before non-folders. 025 * @see ViewerSorter#category(Object) 026 */ 027 public int category(Object element) { 028 return ((ProxyElement)element).isFolder()? 1: 2; 029 } 030 }