Project

General

Profile

Download (1.48 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.cdm.vaadin.event;
10

    
11
import org.vaadin.spring.events.Event;
12
import org.vaadin.spring.events.EventBusListenerMethodFilter;
13

    
14
import eu.etaxonomy.vaadin.event.EditorActionType;
15

    
16
/**
17
 * @author a.kohlbecker
18
 * @since Jan 31, 2018
19
 *
20
 */
21
public class EditorActionTypeFilter implements EventBusListenerMethodFilter {
22

    
23
    EditorActionType action;
24

    
25
    private EditorActionTypeFilter(EditorActionType action) {
26
        this.action = action;
27
    }
28

    
29
    /**
30
     * {@inheritDoc}
31
     */
32
    @Override
33
    public boolean filter(Event<?> event) {
34
        if (event.getPayload() instanceof AbstractEditorAction) {
35
            AbstractEditorAction editorAction = (AbstractEditorAction) event.getPayload();
36
            return this.action.equals(editorAction.type);
37
        }
38
        return false;
39
    }
40

    
41
    public static class Add extends EditorActionTypeFilter {
42

    
43
        public Add() {
44
            super(EditorActionType.ADD);
45
        }
46

    
47
    }
48

    
49
    public static class Edit extends EditorActionTypeFilter {
50

    
51
        public Edit() {
52
            super(EditorActionType.EDIT);
53
        }
54

    
55
    }
56

    
57
    public static class Remove extends EditorActionTypeFilter {
58

    
59
        public Remove() {
60
            super(EditorActionType.REMOVE);
61
        }
62

    
63
    }
64

    
65
}
(11-11/29)