/*
 * 作成日: 2008/08/05
 * 著作権: Copyright (c) 2005 ZIGEN
 * ライセンス：Eclipse Public License - v 1.0
 * 原文：http://www.eclipse.org/legal/epl-v10.html
 */
package zigen.plugin.db.ext.s2jdbc.ui;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;

public class JavaProjectSorter extends ViewerSorter {

    public int compare(Viewer viewer, Object e1, Object e2) {
        if (e1 instanceof IJavaProject && e2 instanceof IJavaProject) {
            IJavaProject c1 = (IJavaProject) e1;
            IJavaProject c2 = (IJavaProject) e2;
            return c1.getElementName().toLowerCase().compareTo(c2.getElementName().toLowerCase());

        } else {

            // // 上記以外は名前でソート
            // String a = e1.toString();
            // String b = e2.toString();
            // return a.compareTo(b);

            return 0;

        }

    }
}
