Project

General

Profile

Download (2.91 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.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.api.service.IRightsService;
19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20
import eu.etaxonomy.cdm.model.media.Rights;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
22
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

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

    
32

    
33
    public static Rights select(Shell shell, ConversationHolder conversation, 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, String title,
43
            boolean multi, String settings, Rights rights) {
44
        super(shell, conversation, title, multi, settings, rights);
45
    }
46

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

    
54
        Rights rights= (Rights) HibernateProxyHelper.deproxy(object);
55

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

    
63
    /**
64
     * {@inheritDoc}
65
     */
66
    @Override
67
    protected String getNewWizardLinkText() {
68
        // TODO Auto-generated method stub
69
        return null;
70
    }
71

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

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

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

    
95
        }else{
96

    
97
                model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(limitOfInitialElements,pattern);
98

    
99
        }
100

    
101
    }
102

    
103
}
(29-29/38)