tmf: add sorter to put analysis in a more user-friendly order
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / project / model / TmfViewerSorter.java
1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.ui.project.model;
14
15 import org.eclipse.jface.viewers.ViewerSorter;
16
17 /**
18 * Viewer sorter for TMF project model elements
19 */
20 // TODO: Follow-up with Bug 484248
21 public class TmfViewerSorter extends ViewerSorter {
22
23 private static int UNSET_PRIO = Integer.MAX_VALUE;
24 private static int EXPERIMENT_FOLDER_PRIO = 0;
25 private static int TRACE_FOLDER_PRIO = 1;
26 private static int EXPERIMENT_ELEMENT_PRIO = 2;
27 private static int TRACE_ELEMENT_PRIO = 3;
28 private static int VIEWS_PRIO = 4;
29 private static int ON_DEMAND_ANALYSIS_PRIO = 5;
30 private static int REPORTS_PRIO = 6;
31
32 @Override
33 public int category(Object element) {
34 int prio = UNSET_PRIO;
35 if (element instanceof TmfExperimentFolder) {
36 prio = EXPERIMENT_FOLDER_PRIO;
37 } else if (element instanceof TmfTraceFolder) {
38 prio = TRACE_FOLDER_PRIO;
39 } else if (element instanceof TmfTraceElement) {
40 prio = TRACE_ELEMENT_PRIO;
41 } else if (element instanceof TmfExperimentElement) {
42 prio = EXPERIMENT_ELEMENT_PRIO;
43 } else if (element instanceof TmfViewsElement) {
44 prio = VIEWS_PRIO;
45 } else if (element instanceof TmfOnDemandAnalysesElement) {
46 prio = ON_DEMAND_ANALYSIS_PRIO;
47 } else if (element instanceof TmfReportsElement) {
48 prio = REPORTS_PRIO;
49 }
50 return prio;
51 }
52 }
This page took 0.032103 seconds and 5 git commands to generate.