Project

General

Profile

Download (2.86 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2014 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
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.
8
 */
9
package eu.etaxonomy.taxeditor.ui.dialog.selection;
10

    
11
import java.util.UUID;
12

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

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

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

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

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

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

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

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

    
62
    /** {@inheritDoc} */
63
    @Override
64
    protected void callService(String pattern) {
65
        model = CdmStore.getService(IPrimerService.class).getPrimerUuidAndTitleCache(limitOfInitialElements, pattern);
66
    }
67

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

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

    
85
    /** {@inheritDoc} */
86
    @Override
87
    protected String[] getNewWizardText() {
88
        return new String[]{"New Primer"};
89
    }
90
}
(31-31/44)