--- /dev/null
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IReferenceService;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsFilter;
+
+public class NomenclaturalReferenceSelectionDialog extends
+ ReferenceSelectionDialog {
+
+ protected NomenclaturalReferenceSelectionDialog(Shell shell,
+ ConversationHolder conversation, String title, boolean multi,
+ Reference reference) {
+ super(shell, conversation, title, multi, reference);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected void initModel() {
+ Control control = getPatternControl();
+ String pattern = null;
+ if (control != null){
+ pattern = ((Text)control).getText();
+ }
+
+
+ model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern);
+ }
+
+ /**
+ * <p>select</p>
+ *
+ * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
+ * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
+ */
+
+ public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) {
+ NomenclaturalReferenceSelectionDialog dialog = new NomenclaturalReferenceSelectionDialog(shell, conversation,
+ "Choose a reference", false, reference);
+ return getSelectionFromDialog(dialog);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
+ */
+ /** {@inheritDoc} */
+ @Override
+ protected ItemsFilter createFilter() {
+ return new ItemsFilter() {
+
+ /**
+ * Always returns false to enforce refiltering even if the pattern is equal
+ */
+ @Override
+ public boolean equalsFilter(ItemsFilter filter) {
+ return false;
+ }
+
+ @Override
+ public boolean isConsistentItem(Object item) {
+ return false;
+ }
+
+ @Override
+ public boolean matchItem(Object item) {
+ String text = null;
+ if(item instanceof UuidAndTitleCache){
+ text = ((UuidAndTitleCache) item).getAbbrevTitleCache();
+ }else if(item instanceof String){
+ text = (String) item;
+ }
+ return text != null ? matches(text) : false;
+ }
+
+ };
+ }
+
+
+}
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
+import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
/**
* @author n.hoffmann
if(clazz.equals(TaxonNode.class)){
return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification());
}
+ if(clazz.equals(Reference.class) && parentElement instanceof NomenclaturalReferenceDetailElement){
+ return (T) NomenclaturalReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
+ }
if(clazz.equals(Reference.class)){
return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
}
+
if(clazz.equals(TaxonNameBase.class)){
return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) currentSelection);
}