2 * Copyright (c) 2003-2004 Alex Fitzpatrick and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Alex Fitzpatrick - initial implementation
11 * $Id: JSNameSorter.java,v 1.1 2004-09-02 18:23:57 jsurfer Exp $
14 package net.sourceforge.phpeclipse.js.ui.model;
16 import net.sourceforge.phpeclipse.js.core.model.JSClassElement;
17 import net.sourceforge.phpeclipse.js.core.model.JSClassMethodElement;
18 import net.sourceforge.phpeclipse.js.core.model.JSClassVariableElement;
19 import net.sourceforge.phpeclipse.js.core.model.JSFunctionElement;
20 import net.sourceforge.phpeclipse.js.core.model.JSGlobalVariableElement;
21 import net.sourceforge.phpeclipse.js.core.model.JSInstanceMethodElement;
22 import net.sourceforge.phpeclipse.js.core.model.JSInstanceVariableElement;
24 import org.eclipse.jface.viewers.ViewerSorter;
29 public class JSNameSorter extends ViewerSorter {
31 // ViewerSorter Implementation ---------------------------------------------
34 * @see ViewerSorter#category(Object)
36 public int category(Object element) {
37 if (element instanceof JSClassElement) {
38 return JSElementCategories.CLASS;
39 } else if (element instanceof JSFunctionElement) {
40 return JSElementCategories.FUNCTION;
41 } else if (element instanceof JSGlobalVariableElement) {
42 return JSElementCategories.VARIABLE;
43 } else if (element instanceof JSClassVariableElement) {
44 return JSElementCategories.CLASS_VARIABLE;
45 } else if (element instanceof JSInstanceVariableElement) {
46 return JSElementCategories.INSTANCE_VARIABLE;
47 } else if (element instanceof JSClassMethodElement) {
48 return JSElementCategories.CLASS_METHOD;
49 } else if (element instanceof JSInstanceMethodElement) {
50 return JSElementCategories.INSTANCE_VARIABLE;
52 return super.category(element);