import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
import java.util.UUID;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
/**
* @author p.ciardelli
- * @version $Id: $
*/
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{
public static TaxonNode select(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
//conversation,
title,
excludeTaxa,
false,
node,
- classificationUUID);
+ classificationUUID, allowSelectClassification);
return getSelectionFromDialog(dialog);
}
+ public static TaxonNode select(Shell shell, //ConversationHolder conversation,
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
+ TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
+ //conversation,
+ title,
+ excludeTaxa,
+ false,
+ node,
+ classificationUUID);
+ return getSelectionFromDialog(dialog);
+ }
public static UuidAndTitleCache<TaxonNode> selectUuidAndTitleCache(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, TaxonNode node, UUID classificationUUID) {
TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
//conversation,
title,
excludeTaxa,
false,
node,
- classificationUUID);
+ classificationUUID, false);
return getUuidAndTitleCacheSelectionFromDialog(dialog);
}
private Classification selectedClassification;
private UUID selectedUuid;
- private final List<UUID> excludeTaxa;
+// private final Set<UUID> excludeTaxa;
+ private boolean allowClassificationSelection = false;
protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
- String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID) {
+ String title, Set<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID, boolean allowSelectClassification) {
super(shell, //conversation,
title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
setListLabelProvider(labelProvider);
// setDetailsLabelProvider(labelProvider);
- this.excludeTaxa = excludeTaxa;
+ this.cdmBaseToBeFiltered = excludeTaxa;
if(classificationUUID != null){
selectedUuid = classificationUUID;
}
fillClassifications();
+ this.allowClassificationSelection = allowSelectClassification;
- createClassificationSelectionCombo(shell);
+ //createClassificationSelectionCombo(shell);
+ }
+ protected TaxonNodeSelectionDialog(Shell shell, //ConversationHolder conversation,
+ String title, Set<UUID> excludeTaxa, boolean multi, TaxonNode node, UUID classificationUUID) {
+ this(shell, title, excludeTaxa, multi, node, classificationUUID, false);
}
/** {@inheritDoc} */
return classificationSelection;
}
- /** {@inheritDoc} */
@Override
protected String getTitle(TaxonNode taxonNode) {
if(taxonNode != null && taxonNode.getTaxon() != null){
return "";
}
- /** {@inheritDoc} */
+ @Override
+ protected SelectionListener getNewWizardButtonSelectionListener(){
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Classification tree = selectedClassification;
+ setPattern(tree.getRootNode());
+
+ }
+ };
+ }
+
@Override
protected TaxonNode getPersistentObject(UUID uuid) {
- return CdmStore.getService(IClassificationService.class).getTaxonNodeByUuid(uuid);
+ return CdmStore.getService(ITaxonNodeService.class).find(uuid);
}
- /** {@inheritDoc} */
@Override
protected void callService(String pattern) {
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedUuid, limitOfInitialElements, pattern);
+ model = CdmStore.getService(IClassificationService.class)
+ .getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
+ selectedClassification.getUuid(), limitOfInitialElements, pattern, allowClassificationSelection, true);
}
+
@Override
protected void sort() {
if(!PreferencesUtil.isSortTaxaByRankAndName()){
}
});
if (selectedClassification == null){
- if (this.cdmBaseToBeFiltered == null){
+// if (this.cdmBaseToBeFiltered.isEmpty()){
selectedClassification = classifications.iterator().next();
- } else {
- selectedClassification = this.cdmBaseToBeFiltered.getClassification();
- }
+
+// } else {
+// selectedClassification = this.cdmBaseToBeFiltered.getClassification();
+// }
}
}
}
- /** {@inheritDoc} */
@Override
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
return null;
}
- /** {@inheritDoc} */
@Override
protected String[] getNewWizardText() {
return null;
}
- /** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
}
}
- /** {@inheritDoc} */
@Override
public void widgetDefaultSelected(SelectionEvent e) {}
-
-
}