|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.appdep.ui.dialogs; |
|
19 |
|
20 import org.eclipse.jface.viewers.Viewer; |
|
21 |
|
22 import com.nokia.s60tools.appdep.resources.Messages; |
|
23 import com.nokia.s60tools.appdep.util.AppDepConsole; |
|
24 import com.nokia.s60tools.ui.S60ToolsViewerSorter; |
|
25 |
|
26 /** |
|
27 * Sorter implementation for SIS file entry data. |
|
28 */ |
|
29 public class SISFileEntryTableViewerSorter extends S60ToolsViewerSorter { |
|
30 |
|
31 // |
|
32 // Sorting criteria constants |
|
33 // |
|
34 public static final int CRITERIA_NAME = 1; |
|
35 public static final int CRITERIA_LOCATION = 2; |
|
36 |
|
37 public SISFileEntryTableViewerSorter() { |
|
38 super(); |
|
39 // By default we are not sorting the information |
|
40 setSortCriteria(CRITERIA_NO_SORT); |
|
41 } |
|
42 |
|
43 /* (non-Javadoc) |
|
44 * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
|
45 */ |
|
46 public int compare(Viewer viewer, Object e1, Object e2) { |
|
47 |
|
48 // By default comparison does not do any ordering |
|
49 int compRes = 0; |
|
50 |
|
51 SISFileEntry entry1 = (SISFileEntry) e1; |
|
52 SISFileEntry entry2 = (SISFileEntry) e2; |
|
53 |
|
54 switch (sortCriteria) { |
|
55 |
|
56 case CRITERIA_NAME: |
|
57 compRes = alphabeticSort(entry1.getFileName(), entry2.getFileName()); |
|
58 break; |
|
59 |
|
60 case CRITERIA_LOCATION: |
|
61 compRes = alphabeticSort(entry1.getLocation(), entry2.getLocation()); |
|
62 break; |
|
63 |
|
64 case CRITERIA_NO_SORT: |
|
65 // No sorting criteria defined. |
|
66 break; |
|
67 |
|
68 default: |
|
69 AppDepConsole.getInstance() |
|
70 .println( |
|
71 Messages.getString("SISFileEntryTableViewerSorter.Unexpected_Sort_Criteria_ErrMsg") + sortCriteria, //$NON-NLS-1$ |
|
72 AppDepConsole.MSG_ERROR); |
|
73 break; |
|
74 } |
|
75 |
|
76 return compRes; |
|
77 } |
|
78 |
|
79 } |