performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / dialogs / filteredSelection / FilteredReferenceSelectionDialog.java
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.dialogs.filteredSelection;
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.model.reference.ReferenceBase;
19 import eu.etaxonomy.cdm.strategy.cache.reference.ReferenceBaseDefaultCacheStrategy;
20 import eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard;
21 import eu.etaxonomy.taxeditor.editor.newWizard.NewReferenceWizard;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23
24 /**
25 * <p>FilteredReferenceSelectionDialog class.</p>
26 *
27 * @author n.hoffmann
28 * @created 04.06.2009
29 * @version 1.0
30 */
31 public class FilteredReferenceSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<ReferenceBase> {
32
33 /**
34 * <p>select</p>
35 *
36 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
37 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
38 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
39 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
40 */
41 public static ReferenceBase select(Shell shell, ConversationHolder conversation, ReferenceBase reference) {
42 FilteredReferenceSelectionDialog dialog = new FilteredReferenceSelectionDialog(shell, conversation,
43 "Choose a reference", false, (ReferenceBase) reference);
44 return getSelectionFromDialog(dialog);
45 }
46
47
48 /**
49 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
50 *
51 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
52 * @param title a {@link java.lang.String} object.
53 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
54 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
55 * @param multi a boolean.
56 */
57 protected FilteredReferenceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, ReferenceBase reference) {
58 super(shell, conversation, title, multi, FilteredReferenceSelectionDialog.class.getCanonicalName(), null);
59 }
60
61
62 /* (non-Javadoc)
63 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
64 */
65 /** {@inheritDoc} */
66 @Override
67 protected ReferenceBase getPersistentObject(UUID cdmUuid) {
68 return CdmStore.getReferenceService().load(cdmUuid);
69 }
70
71 /* (non-Javadoc)
72 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
73 */
74 /** {@inheritDoc} */
75 @Override
76 protected void initModel() {
77 model = CdmStore.getReferenceService().getUuidAndTitleCache();
78 }
79
80
81 /** {@inheritDoc} */
82 @Override
83 protected String getTitle(ReferenceBase cdmObject) {
84 if(cdmObject.getAuthorTeam() == null){
85 return super.getTitle(cdmObject);
86 }else{
87 return ReferenceBaseDefaultCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorTeam().getTitleCache());
88 }
89 }
90
91 /** {@inheritDoc} */
92 @Override
93 protected AbstractNewEntityWizard getNewEntityWizard() {
94 return new NewReferenceWizard();
95 }
96
97 /** {@inheritDoc} */
98 @Override
99 protected String getNewWizardLinkText() {
100 return "Click <A>here</A> to create a new reference.";
101 }
102
103 }