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
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.NewReferenceWizard
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 * <p>FilteredReferenceSelectionDialog class.</p>
32 public class ReferenceSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<Reference
> {
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.
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
);
50 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
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.
58 protected ReferenceSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, Reference reference
) {
59 super(shell
, conversation
, title
, multi
, ReferenceSelectionDialog
.class.getCanonicalName(), null);
64 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
68 protected Reference
getPersistentObject(UUID cdmUuid
) {
69 return CdmStore
.getService(IReferenceService
.class).load(cdmUuid
);
73 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
77 protected void initModel() {
78 Control control
= getPatternControl();
79 String pattern
= null;
81 pattern
= ((Text
)control
).getText();
84 if (pattern
== null || pattern
.equals("?")){
85 model
= CdmStore
.getService(IReferenceService
.class).getUuidAndTitleCache(null,null);
87 model
= CdmStore
.getService(IReferenceService
.class).getUuidAndTitleCache(limitOfInitialElements
,pattern
);
94 protected String
getTitle(Reference cdmObject
) {
95 if(cdmObject
== null){
98 return super.getTitle(cdmObject
);
101 // return DefaultReferenceCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
107 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
108 return new NewReferenceWizard();
113 protected String
getNewWizardLinkText() {
114 return String
.format("Create a new <a>%1s</a>", "Reference ");