Project

General

Profile

Download (2.86 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2014 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
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

    
12
import java.util.UUID;
13

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

    
16
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
18
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
19
import eu.etaxonomy.cdm.model.molecular.Primer;
20
import eu.etaxonomy.taxeditor.model.MessagingUtils;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewPrimerWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author pplitzner
27
 * @date 11.03.2014
28
 *
29
 */
30
public class PrimerSelectionDialog extends
31
AbstractFilteredCdmResourceSelectionDialog<Primer> {
32

    
33
    public static Primer select(Shell shell, ConversationHolder conversation, Primer primer){
34
        PrimerSelectionDialog dialog = new PrimerSelectionDialog(shell, conversation,
35
                "Choose Primer", false, PrimerSelectionDialog.class.getCanonicalName(), primer);
36
        return getSelectionFromDialog(dialog);
37
    }
38

    
39
    /**
40
     * <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
41
     */
42
    protected PrimerSelectionDialog(Shell shell, ConversationHolder conversation, String title,
43
            boolean multi, String settings, Primer cdmObject) {
44
        super(shell, conversation, title, multi, settings, cdmObject);
45
    }
46

    
47
    /** {@inheritDoc} */
48
    @Override
49
    protected Primer getPersistentObject(UUID uuid) {
50
        Object object = CdmStore.getService(IPrimerService.class).load(uuid);
51

    
52
        Primer primer = (Primer) HibernateProxyHelper.deproxy(object);
53

    
54
        if(primer != null){
55
            return primer;
56
        }
57
        MessagingUtils.error(this.getClass(), "Selected element is not a primer", null);
58
        return null;
59
    }
60

    
61
    /** {@inheritDoc} */
62
    @Override
63
    protected void initModel() {
64
        model = CdmStore.getService(IPrimerService.class).getPrimerUuidAndTitleCache();
65
    }
66

    
67
    /* (non-Javadoc)
68
     * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#getTitle(eu.etaxonomy.cdm.model.common.ICdmBase)
69
     */
70
    @Override
71
    protected String getTitle(Primer cdmObject) {
72
        if(cdmObject!=null){
73
            return cdmObject.getLabel();
74
        }
75
        return super.getTitle(cdmObject);
76
    }
77

    
78
    /** {@inheritDoc} */
79
    @Override
80
    protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
81
        return new NewPrimerWizard();
82
    }
83

    
84
    /** {@inheritDoc} */
85
    @Override
86
    protected String getNewWizardLinkText() {
87
        return String.format("Create a new <a>%1s</a>", "Primer ");
88
    }
89
}
(25-25/34)