2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
12 import java
.util
.UUID
;
14 import org
.eclipse
.swt
.widgets
.Control
;
15 import org
.eclipse
.swt
.widgets
.Shell
;
16 import org
.eclipse
.swt
.widgets
.Text
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
21 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.DefaultReferenceCacheStrategy
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewReferenceWizard
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 * <p>FilteredReferenceSelectionDialog class.</p>
33 public class ReferenceSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<Reference
> {
38 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
39 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
40 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
41 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
43 public static Reference
select(Shell shell
, ConversationHolder conversation
, Reference reference
) {
44 ReferenceSelectionDialog dialog
= new ReferenceSelectionDialog(shell
, conversation
,
45 "Choose a reference", false, reference
);
46 return getSelectionFromDialog(dialog
);
51 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
53 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
54 * @param title a {@link java.lang.String} object.
55 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
56 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
57 * @param multi a boolean.
59 protected ReferenceSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, Reference reference
) {
60 super(shell
, conversation
, title
, multi
, ReferenceSelectionDialog
.class.getCanonicalName(), null);
65 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
69 protected Reference
getPersistentObject(UUID cdmUuid
) {
70 return CdmStore
.getService(IReferenceService
.class).load(cdmUuid
);
74 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
78 protected void initModel() {
79 Control control
= getPatternControl();
80 String pattern
= null;
82 pattern
= ((Text
)control
).getText();
86 model
= CdmStore
.getService(IReferenceService
.class).getUuidAndTitleCache(limitOfInitialElements
,pattern
);
92 protected String
getTitle(Reference cdmObject
) {
93 if(cdmObject
== null){
96 return super.getTitle(cdmObject
);
99 // return DefaultReferenceCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
105 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
106 return new NewReferenceWizard();
111 protected String
getNewWizardLinkText() {
112 return String
.format("Create a new <a>%1s</a>", "Reference ");