]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/actions/IActionCategory.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / actions / IActionCategory.java
1 /*******************************************************************************
2  * Copyright (c) 2010, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.model.actions;
13
14 import java.util.Comparator;
15
16 public interface IActionCategory {
17     String getLabel();
18     double getPriority();
19     boolean isSubmenu();
20     
21     public static final Comparator<IActionCategory> ACTION_CATEGORY_COMPARATOR = new Comparator<IActionCategory>() {
22         @Override
23         public int compare(IActionCategory o1, IActionCategory o2) {
24             if(o1 == null) {
25                 if(o2 == null)
26                     return 0;
27                 return -1;
28             }
29             if(o2 == null)
30                 return 1;
31             double p1 = o1.getPriority();
32             double p2 = o2.getPriority();
33             if(p1 < p2)
34                 return -1;
35             if(p1 > p2)
36                 return 1;
37             String label1 = o1.getLabel();
38             String label2 = o2.getLabel();
39             if(label1 == null) {
40                 if(label2 == null)
41                     return 0;
42                 else
43                     return -1;
44             }
45             else {
46                 if(label2 == null)
47                     return 1;
48                 else
49                     return label1.compareTo(label2);
50             } 
51         }
52     };
53 }