1
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
2
|
|
3
|
import org.eclipse.jface.viewers.LabelProvider;
|
4
|
import org.eclipse.swt.widgets.Shell;
|
5
|
|
6
|
import eu.etaxonomy.cdm.api.service.IIdentifiableEntityService;
|
7
|
import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
|
8
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
9
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
10
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
11
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
12
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
13
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
14
|
|
15
|
public abstract class AbstractFilteredIdentifierSelectionDialog<T extends ICdmBase> extends AbstractFilteredCdmResourceSelectionDialog {
|
16
|
|
17
|
DefinedTerm identifierType;
|
18
|
MatchMode matchMode;
|
19
|
Class<T> type;
|
20
|
|
21
|
|
22
|
/**
|
23
|
* @param shell
|
24
|
* @param title
|
25
|
* @param multi
|
26
|
* @param settings
|
27
|
* @param cdmObject
|
28
|
*/
|
29
|
protected AbstractFilteredIdentifierSelectionDialog(Shell shell, String title, boolean multi, String settings,
|
30
|
ICdmBase cdmObject) {
|
31
|
super(shell, title, multi, settings, cdmObject);
|
32
|
|
33
|
}
|
34
|
|
35
|
public class FilteredIdentifiedEntityLabelProvider extends LabelProvider {
|
36
|
@Override
|
37
|
public String getText(Object element) {
|
38
|
if (element == null) {
|
39
|
return null;
|
40
|
}
|
41
|
IdentifiedEntityDTO identifiedEntity = (IdentifiedEntityDTO) element;
|
42
|
String titleCache = identifiedEntity.getCdmEntity().getTitleCache();
|
43
|
if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){
|
44
|
titleCache += " ["+identifiedEntity.getCdmEntity().getUuid()+"]";
|
45
|
}
|
46
|
// add identifier
|
47
|
titleCache += " ["+identifiedEntity.getIdentifier().getIdentifier()+"]";
|
48
|
return titleCache;
|
49
|
}
|
50
|
};
|
51
|
|
52
|
@Override
|
53
|
void callService(String pattern){
|
54
|
|
55
|
model = CdmStore.getService(IIdentifiableEntityService.class).listByIdentifier(type, pattern, identifierType, matchMode, true, null, limitOfInitialElements);
|
56
|
}
|
57
|
|
58
|
|
59
|
|
60
|
|
61
|
|
62
|
|
63
|
}
|