1
|
/**
|
2
|
* Copyright (C) 2018 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.swt.widgets.Shell;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
16
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
17
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
18
|
|
19
|
/**
|
20
|
* @author k.luther
|
21
|
* @since 09.10.2018
|
22
|
*
|
23
|
*/
|
24
|
public class CommonNameNamedAreaSelectionDialog extends NamedAreaSelectionDialog {
|
25
|
|
26
|
/**
|
27
|
* @param shell
|
28
|
* @param title
|
29
|
* @param multi
|
30
|
* @param namedArea
|
31
|
* @param preferenceId
|
32
|
* @param preselectedVocabularyUuids
|
33
|
*/
|
34
|
protected CommonNameNamedAreaSelectionDialog(Shell shell, String title, boolean multi, NamedArea namedArea,
|
35
|
Object preferenceId) {
|
36
|
super(shell, title, multi, namedArea, preferenceId, createVocabularyUuidList());
|
37
|
|
38
|
|
39
|
}
|
40
|
|
41
|
private static UUID[] createVocabularyUuidList() {
|
42
|
String preselectedVocString = PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.COMMON_NAME_AREA_VOCABULARIES);
|
43
|
String[] preselectedVocArray = preselectedVocString.split(";");
|
44
|
UUID[] uuidList = new UUID[preselectedVocArray.length];
|
45
|
int i = 0;
|
46
|
for (String uuidString: preselectedVocArray){
|
47
|
uuidList[i]= UUID.fromString(uuidString);
|
48
|
i++;
|
49
|
}
|
50
|
return uuidList;
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* Creates a filtered selection dialog to select a named area.
|
55
|
*
|
56
|
* @param shell
|
57
|
* The shell for displaying this widget
|
58
|
* @param namedArea
|
59
|
* A namedArea that should be selected when the dialog opens
|
60
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
61
|
* @param preferenceId a class which is used for generating the preference key so that every
|
62
|
* dialogs can be grouped to have their own preferences depending on this id
|
63
|
* @param preselectedVocabularyUuids the {@link UUID}s of the pre-selected vocabularies
|
64
|
* @return a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
|
65
|
*/
|
66
|
public static NamedArea select(Shell shell, //ConversationHolder conversation,
|
67
|
NamedArea namedArea, String preferenceId) {
|
68
|
CommonNameNamedAreaSelectionDialog dialog = new CommonNameNamedAreaSelectionDialog(shell, //conversation,
|
69
|
"Choose an area", false, namedArea, preferenceId);
|
70
|
return getSelectionFromDialog(dialog);
|
71
|
}
|
72
|
}
|