3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.swt
.widgets
.Control
;
16 import org
.eclipse
.swt
.widgets
.Shell
;
17 import org
.eclipse
.swt
.widgets
.Text
;
19 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
20 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
22 import eu
.etaxonomy
.cdm
.strategy
.cache
.reference
.DefaultReferenceCacheStrategy
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
24 import eu
.etaxonomy
.taxeditor
.newWizard
.NewReferenceWizard
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * <p>FilteredReferenceSelectionDialog class.</p>
34 public class ReferenceSelectionDialog
extends AbstractFilteredCdmResourceSelectionDialog
<Reference
> {
39 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
40 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @return a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
44 public static Reference
select(Shell shell
, ConversationHolder conversation
, Reference reference
) {
45 ReferenceSelectionDialog dialog
= new ReferenceSelectionDialog(shell
, conversation
,
46 "Choose a reference", false, reference
);
47 return getSelectionFromDialog(dialog
);
52 * <p>Constructor for FilteredReferenceSelectionDialog.</p>
54 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
55 * @param title a {@link java.lang.String} object.
56 * @param reference a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase} object.
57 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
58 * @param multi a boolean.
60 protected ReferenceSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, Reference reference
) {
61 super(shell
, conversation
, title
, multi
, ReferenceSelectionDialog
.class.getCanonicalName(), null);
66 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
70 protected Reference
getPersistentObject(UUID cdmUuid
) {
71 return CdmStore
.getService(IReferenceService
.class).load(cdmUuid
);
75 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
79 protected void initModel() {
80 Control control
= getPatternControl();
81 String pattern
= null;
83 pattern
= ((Text
)control
).getText();
87 model
= CdmStore
.getService(IReferenceService
.class).getUuidAndTitleCache(limitOfInitialElements
,pattern
);
93 protected String
getTitle(Reference cdmObject
) {
94 if(cdmObject
== null){
97 return super.getTitle(cdmObject
);
100 // return DefaultReferenceCacheStrategy.putAuthorToEndOfString(cdmObject.getTitleCache(), cdmObject.getAuthorship().getTitleCache());
106 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
107 return new NewReferenceWizard();
112 protected String
getNewWizardLinkText() {
113 return String
.format("Create a new <a>%1s</a>", "Reference ");