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.ICdmBase;
|
9
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
10
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
11
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
12
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
13
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
14
|
|
15
|
public abstract class AbstractFilteredIdentifierSelectionDialog<T extends ICdmBase>
|
16
|
extends AbstractFilteredCdmResourceSelectionDialog<T> {
|
17
|
|
18
|
private DefinedTerm identifierType;
|
19
|
private MatchMode matchMode;
|
20
|
private Class<T> type;
|
21
|
|
22
|
protected AbstractFilteredIdentifierSelectionDialog(Shell shell, String title, boolean multi,
|
23
|
String settings, T cdmObject) {
|
24
|
super(shell, title, multi, settings, cdmObject);
|
25
|
}
|
26
|
|
27
|
public class FilteredIdentifiedEntityLabelProvider extends LabelProvider {
|
28
|
@Override
|
29
|
public String getText(Object element) {
|
30
|
if (element == null) {
|
31
|
return null;
|
32
|
}
|
33
|
IdentifiedEntityDTO identifiedEntity = (IdentifiedEntityDTO) element;
|
34
|
String titleCache = identifiedEntity.getCdmEntity().getTitleCache();
|
35
|
if(PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSelectionDialog.getKey())){
|
36
|
titleCache += " ["+identifiedEntity.getCdmEntity().getUuid()+"]";
|
37
|
}
|
38
|
// add identifier
|
39
|
titleCache += " ["+identifiedEntity.getIdentifier().getIdentifier()+"]";
|
40
|
return titleCache;
|
41
|
}
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
protected void callService(String pattern){
|
46
|
model = CdmStore.getService(IIdentifiableEntityService.class).listByIdentifier(type, pattern, identifierType, matchMode, true, null, limitOfInitialElements);
|
47
|
}
|
48
|
}
|