Project

General

Profile

« Previous | Next » 

Revision 752e8a12

Added by Katja Luther over 7 years ago

ref #5837 add new NomenclaturalReferenceSelectionDialog

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientReferenceService.java
771 771
		return defaultService.loadByIds(idSet, propertyPaths);
772 772
	}
773 773

  
774
	@Override
775
	public List<UuidAndTitleCache<Reference>> getUuidAndAbbrevTitleCache(
776
			Integer limit, String pattern) {
777
		
778
		return defaultService.getUuidAndAbbrevTitleCache(limit, pattern);
779
	}
780

  
774 781
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalReferenceSelectionDialog.java
1
package eu.etaxonomy.taxeditor.ui.dialog.selection;
2

  
3
import org.eclipse.swt.widgets.Control;
4
import org.eclipse.swt.widgets.Shell;
5
import org.eclipse.swt.widgets.Text;
6

  
7
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
8
import eu.etaxonomy.cdm.api.service.IReferenceService;
9
import eu.etaxonomy.cdm.model.reference.Reference;
10
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
11
import eu.etaxonomy.taxeditor.store.CdmStore;
12
import eu.etaxonomy.taxeditor.ui.dialog.selection.CdmFilteredItemsSelectionDialog.ItemsFilter;
13

  
14
public class NomenclaturalReferenceSelectionDialog extends
15
		ReferenceSelectionDialog {
16

  
17
	protected NomenclaturalReferenceSelectionDialog(Shell shell,
18
			ConversationHolder conversation, String title, boolean multi,
19
			Reference reference) {
20
		super(shell, conversation, title, multi, reference);
21
		// TODO Auto-generated constructor stub
22
	}
23
	
24
	/* (non-Javadoc)
25
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
26
	 */
27
	/** {@inheritDoc} */
28
	@Override
29
	protected void initModel() {
30
	    Control control = getPatternControl();
31
        String pattern = null;
32
        if (control != null){
33
            pattern = ((Text)control).getText();
34
        }
35

  
36

  
37
		model = CdmStore.getService(IReferenceService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern);
38
	}
39
	
40
	/**
41
	 * <p>select</p>
42
	 *
43
	 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
44
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
45
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
46
	 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
47
	 */
48
	
49
	public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) {
50
		NomenclaturalReferenceSelectionDialog dialog = new NomenclaturalReferenceSelectionDialog(shell, conversation,
51
				"Choose a reference", false, reference);
52
		return getSelectionFromDialog(dialog);
53
	}
54
	
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
57
	 */
58
	/** {@inheritDoc} */
59
	@Override
60
	protected ItemsFilter createFilter() {
61
		return new ItemsFilter() {
62

  
63
			/**
64
			 * Always returns false to enforce refiltering even if the pattern is equal
65
			 */
66
			@Override
67
			public boolean equalsFilter(ItemsFilter filter) {
68
				return false;
69
			}
70

  
71
			@Override
72
			public boolean isConsistentItem(Object item) {
73
				return false;
74
			}
75

  
76
			@Override
77
			public boolean matchItem(Object item) {
78
				String text = null;
79
				if(item instanceof UuidAndTitleCache){
80
					text = ((UuidAndTitleCache) item).getAbbrevTitleCache();
81
				}else if(item instanceof String){
82
					text = (String) item;
83
				}
84
				return text != null ? matches(text) : false;
85
			}
86

  
87
		};
88
	}
89

  
90

  
91
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
47 47
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
48 48
import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
49 49
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
50
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
50 51

  
51 52
/**
52 53
 * @author n.hoffmann
......
76 77
		if(clazz.equals(TaxonNode.class)){
77 78
			return (T) TaxonNodeSelectionDialog.select(shell, conversation, null, null, (TaxonNode) currentSelection, ((TaxonNode) currentSelection).getClassification());
78 79
		}
80
		if(clazz.equals(Reference.class) && parentElement instanceof NomenclaturalReferenceDetailElement){
81
			return (T) NomenclaturalReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
82
		}
79 83
		if(clazz.equals(Reference.class)){
80 84
			return (T) ReferenceSelectionDialog.select(shell, conversation, (Reference) currentSelection);
81 85
		}
86
		
82 87
		if(clazz.equals(TaxonNameBase.class)){
83 88
			return (T) NameSelectionDialog.select(shell, conversation, (TaxonNameBase) currentSelection);
84 89
		}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java
8 8
import java.util.Observer;
9 9

  
10 10
import org.eclipse.core.runtime.IStatus;
11
import org.eclipse.jface.dialogs.MessageDialog;
11

  
12 12
import org.eclipse.jface.wizard.WizardDialog;
13 13
import org.eclipse.swt.SWT;
14 14
import org.eclipse.swt.events.SelectionAdapter;

Also available in: Unified diff