Project

General

Profile

« Previous | Next » 

Revision 16b736f1

Added by Katja Luther about 7 years ago

ref #1606: for inReferences use service methods filtering for the right referencetype

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
31 31
 */
32 32
public class ReferenceSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Reference> {
33 33

  
34
    protected static boolean isInReference = false;
35
    private Reference currentReference;
34 36
	/**
35 37
	 * <p>select</p>
36 38
	 *
......
39 41
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
40 42
	 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
41 43
	 */
42
	public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) {
44
	public static Reference select(Shell shell, ConversationHolder conversation, Reference reference, boolean isInReference) {
43 45
		ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, conversation,
44
				"Choose a reference", false, reference);
46
				"Choose a reference", false, reference, isInReference);
45 47
		return getSelectionFromDialog(dialog);
46 48
	}
47 49

  
50
	/**
51
     * <p>select</p>
52
     *
53
     * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
54
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
55
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
56
     * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
57
     */
58
    public static Reference select(Shell shell, ConversationHolder conversation, Reference reference) {
59
        ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, conversation,
60
                "Choose a reference", false, reference);
61
        return getSelectionFromDialog(dialog);
62
    }
63

  
64

  
48 65

  
49 66
	/**
50 67
	 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
......
57 74
	 */
58 75
	protected ReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, Reference reference) {
59 76
		super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
77
		this.currentReference = reference;
60 78
	}
61 79

  
62 80

  
81

  
82

  
83
	/**
84
     * <p>Constructor for FilteredReferenceSelectionDialog.</p>
85
     *
86
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
87
     * @param title a {@link java.lang.String} object.
88
     * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
89
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
90
     * @param multi a boolean.
91
     */
92
    protected ReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, Reference reference, boolean isInReference) {
93
        super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
94
        this.isInReference = isInReference;
95
        this.currentReference = reference;
96
    }
97

  
98

  
63 99
	/* (non-Javadoc)
64 100
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
65 101
	 */
......
82 118
        }
83 119

  
84 120
        if (pattern == null || pattern.equals("?")){
85
            model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(null,null);
121
            if (isInReference && currentReference != null){
122
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(null,null,currentReference.getType());
123
            }else{
124
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(null,null);
125
            }
86 126
        }else{
87
            model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
127
            if (isInReference && currentReference != null){
128
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern, currentReference.getType());
129
            }else{
130
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
131
            }
88 132
        }
89 133
	}
90 134

  

Also available in: Unified diff