Project

General

Profile

Download (2.85 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.Control;
14
import org.eclipse.swt.widgets.Shell;
15
import org.eclipse.swt.widgets.Text;
16

    
17
import eu.etaxonomy.cdm.api.service.IRightsService;
18
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
19
import eu.etaxonomy.cdm.model.media.Rights;
20
import eu.etaxonomy.taxeditor.model.MessagingUtils;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author k.luther
26
 * @date 15.02.2017
27
 *
28
 */
29
public class RightsSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Rights> {
30

    
31

    
32
    public static Rights select(Shell shell, //ConversationHolder conversation,
33
            Rights rights){
34
        RightsSelectionDialog dialog = new RightsSelectionDialog(shell, //conversation,
35
                "Choose Rights", false, RightsSelectionDialog.class.getCanonicalName(), rights);
36
        return getSelectionFromDialog(dialog);
37
    }
38

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

    
49
    /**
50
     * {@inheritDoc}
51
     */
52
    @Override
53
    protected Rights getPersistentObject(UUID uuid) {
54
        Object object = CdmStore.getService(IRightsService.class).load(uuid);
55

    
56
        Rights rights= (Rights) HibernateProxyHelper.deproxy(object);
57

    
58
        if(rights != null){
59
            return rights;
60
        }
61
        MessagingUtils.error(this.getClass(), "Selected element is not rights", null);
62
        return null;
63
    }
64

    
65
    /**
66
     * {@inheritDoc}
67
     */
68
    @Override
69
    protected String[] getNewWizardText() {
70

    
71
        return null;
72
    }
73

    
74
    /**
75
     * {@inheritDoc}
76
     */
77
    @Override
78
    protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
79
        // TODO Auto-generated method stub
80
        return null;
81
    }
82

    
83
    /**
84
     * {@inheritDoc}
85
     */
86
    @Override
87
    protected void search() {
88
        Control control =getSearchField();
89
        String pattern = null;
90
        if (control != null){
91
            pattern = ((Text)control).getText();
92
        }
93

    
94
        if (pattern == null || pattern.equals("?")){
95
            model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(null,null);
96

    
97
        }else{
98

    
99
                model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(limitOfInitialElements,pattern);
100

    
101
        }
102

    
103
    }
104

    
105
}
(30-30/39)