Project

General

Profile

« Previous | Next » 

Revision 0caafa75

Added by Andreas Müller over 1 year ago

ref #10186 further remove ConversationHolder and cleanup

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11 10

  
12 11
import java.util.ArrayList;
......
41 40
import eu.etaxonomy.taxeditor.store.CdmStore;
42 41

  
43 42
/**
44
 * <p>FilteredReferenceSelectionDialog class.</p>
45
 *
46 43
 * @author n.hoffmann
47 44
 * @created 04.06.2009
48
 * @version 1.0
49 45
 */
50 46
public class ReferenceSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Reference> {
51 47

  
......
55 51
    Map<UUID, AlternativeIdentifier> identifierMap;
56 52
    Set<Reference> preSelectedReferences = new HashSet<>();
57 53

  
58
	/**
59
	 * <p>select</p>
60
	 *
61
	 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
62
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
63
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
64
	 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
65
	 */
66
	public static Reference select(Shell shell, //ConversationHolder conversation,
54
	public static Reference select(Shell shell,
67 55
	        Reference reference, boolean isInReference) {
68 56
		ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, //conversation,
69 57
				"Choose a reference", false, reference, isInReference);
70 58
		return getSelectionFromDialog(dialog);
71 59
	}
72 60

  
73
	/**
74
     * <p>select</p>
75
     *
76
     * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
77
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
78
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
79
     * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
80
     */
81
    public static Reference select(Shell shell, //ConversationHolder conversation,
61
    public static Reference select(Shell shell,
82 62
            Reference reference) {
83 63
        ReferenceSelectionDialog dialog = new ReferenceSelectionDialog(shell, //conversation,
84 64
                "Choose a reference", false, reference, null);
......
92 72
        return getSelectionFromDialog(dialog);
93 73
    }
94 74

  
95

  
96

  
97

  
98
	/**
99
	 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
100
	 *
101
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
102
	 * @param title a {@link java.lang.String} object.
103
	 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
104
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
105
	 * @param multi a boolean.
106
	 */
107
	protected ReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
75
    protected ReferenceSelectionDialog(Shell shell,
108 76
	        String title, boolean multi, Reference reference, Set<Reference> preSelectedReferences) {
109
		super(shell, //conversation,
77
		super(shell,
110 78
		        title, multi, ReferenceSelectionDialog.class.getCanonicalName(), reference);
111 79
		this.currentReference = reference;
112 80
		this.preSelectedReferences = preSelectedReferences;
113

  
114 81
	}
115

  
116

  
117

  
118

  
119
	/**
120
     * <p>Constructor for FilteredReferenceSelectionDialog.</p>
121
     *
122
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
123
     * @param title a {@link java.lang.String} object.
124
     * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
125
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
126
     * @param multi a boolean.
127
     */
128
    protected ReferenceSelectionDialog(Shell shell, //ConversationHolder conversation,
82
    protected ReferenceSelectionDialog(Shell shell,
129 83
            String title, boolean multi, Reference reference, boolean isInReference) {
130 84
        super(shell, //conversation,
131 85
                title, multi, ReferenceSelectionDialog.class.getCanonicalName());
132
        this.isInReference = isInReference;
86
        ReferenceSelectionDialog.isInReference = isInReference;
133 87
        this.currentReference = reference;
134

  
135 88
    }
136 89

  
137

  
138
	/* (non-Javadoc)
139
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
140
	 */
141
	/** {@inheritDoc} */
142 90
	@Override
143 91
	protected Reference getPersistentObject(UUID cdmUuid) {
144 92
	    if (lastSelectedReferences == null){
......
155 103
		return CdmStore.getService(IReferenceService.class).load(cdmUuid);
156 104
	}
157 105

  
158
	/* (non-Javadoc)
159
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#search
160
	 */
161
	/** {@inheritDoc} */
162 106
	@Override
163 107
	protected void callService(String pattern) {
164 108

  
......
186 130
	            }else{
187 131
	                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCacheForUUIDS(uuids);
188 132
	            }
189

  
190 133
	        }
191 134

  
192 135
	    } else if (isInReference && currentReference != null){
......
197 140
                    model.clear();
198 141
                }
199 142
                for (IdentifiedEntityDTO dto: list){
200

  
201 143
                    model.add(dto.getCdmEntity());
202 144
                }
203 145
            }else{
204

  
205 146
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern, currentReference.getType());
206 147
            }
207 148

  
......
211 152
                if (model!= null){
212 153
                    model.clear();
213 154
                }
214
                identifierMap = new HashMap();
155
                identifierMap = new HashMap<>();
215 156
                for (IdentifiedEntityDTO dto: list){
216 157
                    if (dto.getIdentifier() != null){
217 158
                        identifierMap.put(dto.getCdmEntity().getUuid(), dto.getIdentifier());
218 159
                    }
219 160
                    model.add(dto.getCdmEntity());
220

  
221 161
                }
222 162
            }else if (isUseIdentifier() ){
223 163
                List<IdentifiedEntityDTO<Reference>> list = CdmStore.getService(IReferenceService.class).listByIdentifierAbbrev(pattern, null, MatchMode.BEGINNING, limitOfInitialElements);
224 164
                if (model!= null){
225 165
                    model.clear();
226 166
                }
227
                identifierMap = new HashMap();
167
                identifierMap = new HashMap<>();
228 168
                for (IdentifiedEntityDTO dto: list){
229 169
                    identifierMap.put(dto.getCdmEntity().getUuid(), dto.getIdentifier());
230 170
                    model.add(dto.getCdmEntity());
231

  
232 171
                }
233 172
            }else {
234 173
                model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
235 174
            }
236

  
237 175
        }
238

  
239 176
	}
240 177

  
241 178
	@Override
......
254 191
            }
255 192
        });
256 193
    }
257
	/** {@inheritDoc} */
194

  
258 195
	@Override
259 196
	protected String getTitle(Reference cdmObject) {
260 197
		if(cdmObject == null){
......
262 199
		}else{
263 200
		    return super.getTitle(cdmObject);
264 201
		}
265
//		}else{
266
//			return DefaultReferenceCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
267
//		}
268 202
	}
269 203

  
270
	/** {@inheritDoc} */
271 204
	@Override
272 205
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
273 206
	    if (isInReference){
......
278 211
		return new NewReferenceWizard(null);
279 212
	}
280 213

  
281
	/** {@inheritDoc} */
282 214
	@Override
283 215
	protected String[] getNewWizardText() {
284 216
		return new String[]{"New Reference"};
285 217
	}
286 218

  
287
	/** {@inheritDoc} */
288 219
    @Override
289 220
    protected void search() {
290 221
        Control control =getSearchField();
......
321 252
                        titleCache += " (-)";
322 253
                    }
323 254
                }
324

  
325 255
            }
326 256

  
327 257
            return titleCache;
328 258
        }
329
    };
330

  
331
}
259
    }
260
}

Also available in: Unified diff