Project

General

Profile

Download (1.48 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 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.cdm.vaadin.util;
11

    
12
import com.vaadin.server.VaadinSession;
13

    
14
import eu.etaxonomy.cdm.vaadin.session.CdmDataChangeService;
15
import eu.etaxonomy.cdm.vaadin.session.SelectionService;
16

    
17
/**
18
 * @author cmathew
19
 * @date 7 Apr 2015
20
 *
21
 */
22
public class CdmVaadinSessionUtilities {
23

    
24
    public static void setCurrentAttribute(String name, Object value) {
25
        try {
26
            VaadinSession.getCurrent().getLockInstance().lock();
27
            VaadinSession.getCurrent().setAttribute(name, value);
28
        } finally {
29
            VaadinSession.getCurrent().getLockInstance().unlock();
30
        }
31
    }
32

    
33
    public static void initCdmDataChangeService() {
34
        setCurrentAttribute(CdmDataChangeService.KEY, new CdmDataChangeService());
35
    }
36

    
37
    public static CdmDataChangeService getCurrentCdmDataChangeService() {
38
        return (CdmDataChangeService) VaadinSession.getCurrent().getAttribute(CdmDataChangeService.KEY);
39
    }
40

    
41
    public static void initSelectionService() {
42
        setCurrentAttribute(SelectionService.KEY, new SelectionService());
43
    }
44

    
45
    public static SelectionService getCurrentSelectionService() {
46
        return (SelectionService) VaadinSession.getCurrent().getAttribute(SelectionService.KEY);
47
    }
48
}
(4-4/6)