blob: 7428f9215240b908ca2f76e43633da0cfc9174b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.scannerconfig;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
/**
* TODO Provide description
*
* @author vhirsl
*/
public class DiscoveredElementSorter extends ViewerSorter {
private static final int CONTAINER = 0;
private static final int PATHS_GROUP = 1;
private static final int SYMBOLS_GROUP = 2;
private static final int INCLUDE_FILE_GROUP = 3;
private static final int MACROS_FILE_GROUP = 4;
private static final int OTHER = 10;
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
*/
@Override
public int category(Object element) {
if (element instanceof DiscoveredElement) {
DiscoveredElement elem = (DiscoveredElement) element;
switch (elem.getEntryKind()) {
case DiscoveredElement.CONTAINER:
return CONTAINER;
case DiscoveredElement.PATHS_GROUP:
return PATHS_GROUP;
case DiscoveredElement.SYMBOLS_GROUP:
return SYMBOLS_GROUP;
case DiscoveredElement.INCLUDE_FILE_GROUP:
return INCLUDE_FILE_GROUP;
case DiscoveredElement.MACROS_FILE_GROUP:
return MACROS_FILE_GROUP;
}
}
return OTHER;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerSorter#sort(org.eclipse.jface.viewers.Viewer, java.lang.Object[])
*/
@Override
public void sort(Viewer viewer, Object[] elements) {
if (elements.length > 0 && elements[0] instanceof DiscoveredElement) {
DiscoveredElement firstElem = (DiscoveredElement) elements[0];
switch (firstElem.getEntryKind()) {
case DiscoveredElement.INCLUDE_PATH:
case DiscoveredElement.SYMBOL_DEFINITION:
case DiscoveredElement.INCLUDE_FILE:
case DiscoveredElement.MACROS_FILE:
return;
}
}
super.sort(viewer, elements);
}
}
|