Project

General

Profile

Download (3.44 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.ui.dialog.selection;
12

    
13
import java.util.UUID;
14

    
15
import org.eclipse.swt.widgets.Shell;
16

    
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.api.service.IReferenceService;
19
import eu.etaxonomy.cdm.model.reference.Reference;
20
import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceDefaultCacheStrategy;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewReferenceWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * <p>FilteredReferenceSelectionDialog class.</p>
27
 *
28
 * @author n.hoffmann
29
 * @created 04.06.2009
30
 * @version 1.0
31
 */
32
public class ReferenceSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Reference> {
33

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

    
48

    
49
	/**
50
	 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
51
	 *
52
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
53
	 * @param title a {@link java.lang.String} object.
54
	 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
55
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
56
	 * @param multi a boolean.
57
	 */
58
	protected ReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, Reference reference) {
59
		super(shell, conversation, title, multi, ReferenceSelectionDialog.class.getCanonicalName(), null);
60
	}
61

    
62

    
63
	/* (non-Javadoc)
64
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
65
	 */
66
	/** {@inheritDoc} */
67
	@Override
68
	protected Reference getPersistentObject(UUID cdmUuid) {
69
		return CdmStore.getService(IReferenceService.class).load(cdmUuid);
70
	}
71

    
72
	/* (non-Javadoc)
73
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
74
	 */
75
	/** {@inheritDoc} */
76
	@Override
77
	protected void initModel() {
78
		model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache();
79
	}
80

    
81

    
82
	/** {@inheritDoc} */
83
	@Override
84
	protected String getTitle(Reference cdmObject) {
85
		if(cdmObject == null){
86
			return "";
87
		}else if(cdmObject.getAuthorship() == null){
88
			return super.getTitle(cdmObject);
89
		}else{
90
			return ReferenceDefaultCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
91
		}
92
	}
93

    
94
	/** {@inheritDoc} */
95
	@Override
96
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
97
		return new NewReferenceWizard();
98
	}
99

    
100
	/** {@inheritDoc} */
101
	@Override
102
	protected String getNewWizardLinkText() {
103
		return String.format("Create a new <a>%1s</a>", "Reference ");
104
	}
105

    
106
}
(22-22/30)