import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.IClassificationService;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
*/
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{
- public static TaxonNode select(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
+ public static TaxonNode select(Shell shell, //ConversationHolder conversation,
+ String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
- conversation,
+ //conversation,
title,
excludeTaxa,
false,
private Classification selectedClassification;
private final List<UUID> excludeTaxa;
- protected TaxonNodeSelectionDialog(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
- super(shell, conversation, title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
+ protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
+ super(shell, //conversation,
+ title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
ILabelProvider labelProvider = new FilteredCdmResourceLabelProvider();
setListLabelProvider(labelProvider);
- setDetailsLabelProvider(labelProvider);
+// setDetailsLabelProvider(labelProvider);
this.excludeTaxa = excludeTaxa;
if(classification != null){
selectedClassification = classification;
}
- initModel();
+
+ fillClassifications();
+ createClassificationSelectionCombo(shell);
}
/** {@inheritDoc} */
@Override
- protected Control createExtendedContentArea(Composite parent) {
- return createClassificationSelectionCombo(parent);
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ return createClassificationSelectionCombo(container);
}
/*
/** {@inheritDoc} */
@Override
- protected void initModel() {
- // default to first tree
- // TODO this will be problematic and can only be seen as workaround
-
+ protected void callService(String pattern) {
+ model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
+ }
- if(classifications == null){
+ private void fillClassifications() {
+ if(classifications == null){
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
Collections.sort(classifications, new Comparator<Classification>() {
@Override
public int compare(Classification o1, Classification o2) {
- return o1.getTitleCache().compareTo(o2.getTitleCache());
+ if (o1.equals(o2)){
+ return 0;
+ }
+ int result = o1.getTitleCache().compareTo(o2.getTitleCache());
+ if (result == 0){
+ return o1.getUuid().compareTo(o2.getUuid());
+ }
+ return result;
}
});
- if (this.cdmBaseToBeFiltered == null){
- selectedClassification = classifications.iterator().next();
- } else {
+ if (selectedClassification == null){
+ if (this.cdmBaseToBeFiltered == null){
+ selectedClassification = classifications.iterator().next();
+ } else {
selectedClassification = this.cdmBaseToBeFiltered.getClassification();
+ }
}
}
-
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification, excludeTaxa);
- }
+ }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
// refresh();
- setPattern(null);
+ if (getSearchField().getText() != null){
+ search();
+ }
}
/** {@inheritDoc} */