Revision 0f7ee425
Added by Cherian Mathew over 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.editor.definedterm; |
12 | 12 |
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.Collections; |
|
15 |
import java.util.Comparator; |
|
13 | 16 |
import java.util.EnumSet; |
14 | 17 |
import java.util.HashMap; |
18 |
import java.util.List; |
|
15 | 19 |
import java.util.Map; |
16 | 20 |
import java.util.Set; |
17 | 21 |
|
18 | 22 |
import org.eclipse.jface.action.IContributionItem; |
19 | 23 |
import org.eclipse.jface.action.MenuManager; |
24 |
import org.eclipse.jface.action.Separator; |
|
20 | 25 |
import org.eclipse.swt.SWT; |
21 | 26 |
import org.eclipse.ui.menus.CommandContributionItem; |
22 | 27 |
import org.eclipse.ui.menus.CommandContributionItemParameter; |
... | ... | |
47 | 52 |
dtMenuManager.setVisible(true); |
48 | 53 |
|
49 | 54 |
additions.addContributionItem(dtMenuManager, null); |
50 |
|
|
51 |
for (TermType tt : EnumSet.allOf(TermType.class)) |
|
55 |
List<TermType> ttList = new ArrayList<TermType>(EnumSet.allOf(TermType.class)); |
|
56 |
Collections.sort(ttList,new SortByTermTypeMessage()); |
|
57 |
for (TermType tt : ttList) |
|
52 | 58 |
{ |
53 | 59 |
// if term type has a parent, do not add it |
54 | 60 |
// it will be added in the recursive call |
... | ... | |
73 | 79 |
new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu"); |
74 | 80 |
dtMenuManager.setVisible(true); |
75 | 81 |
dtMenuManager.add(createDefaultMenuItem(termType, serviceLocator)); |
82 |
|
|
83 |
Separator sep = new Separator(); |
|
84 |
dtMenuManager.add(sep); |
|
76 | 85 |
// add child items to the sub menu |
77 | 86 |
for(TermType tt : children) { |
78 | 87 |
IContributionItem item = addChildTermsToMenuManager(tt,serviceLocator); |
... | ... | |
124 | 133 |
null, |
125 | 134 |
null, |
126 | 135 |
null, |
127 |
"All " + termType.getMessage() + "s",
|
|
136 |
"Other " + termType.getMessage() + "s",
|
|
128 | 137 |
"", |
129 | 138 |
"", |
130 | 139 |
SWT.PUSH, |
131 | 140 |
"", |
132 | 141 |
true); |
142 |
|
|
143 |
|
|
133 | 144 |
|
134 | 145 |
CommandContributionItem item = new CommandContributionItem(p); |
135 | 146 |
return item; |
136 | 147 |
|
137 | 148 |
} |
138 | 149 |
|
150 |
private class SortByTermTypeMessage implements Comparator<TermType> { |
|
151 |
public int compare(TermType t1, TermType t2) { |
|
152 |
return t1.getMessage().compareTo(t2.getMessage()); |
|
153 |
} |
|
154 |
} |
|
139 | 155 |
|
140 | 156 |
|
141 | 157 |
} |
Also available in: Unified diff
added sorting for the TermType Enum list and added separators between 'Other' vocabularies and known vocabularies