blob: 6f094ce9e2c1d4f4a9e7c05fd9f182be0d6387ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.event.dnd;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.ui.Component;
/**
* Server side dragend event. Fired when an HTML5 dragend happens.
*
* @see DragSourceExtension#addDragEndListener(DragEndListener)
*/
public class DragEndEvent extends Component.Event {
private final Map<String, String> data;
private final EffectAllowed effectAllowed;
/**
* Creates a new server side dragend event.
*
* @param source
* Draggable component.
* @param types
* List of data types from {@code DataTransfer.types}.
* @param data
* Map of all data from {@code DataTransfer}.
* @param effectAllowed
* Parameter from {@code DataTransfer.effectAllowed}.
*/
public DragEndEvent(Component source, List<String> types,
Map<String, String> data, EffectAllowed effectAllowed) {
super(source);
// Create a linked map that preserves the order of types
this.data = new LinkedHashMap<>();
types.forEach(type -> this.data.put(type, data.get(type)));
this.effectAllowed = effectAllowed;
}
/**
* Get data from the client side {@code DataTransfer} object.
*
* @param format
* Data format, e.g. {@code text/plain} or {@code text/uri-list}.
* @return Data for the given format if exists in the client side {@code
* DataTransfer}, otherwise {@code null}.
*/
public String getTransferData(String format) {
return data != null ? data.get(format) : null;
}
/**
* Returns the {@code effectAllowed} parameter of this event.
*
* @return This event's {@code effectAllowed} parameter.
*/
public EffectAllowed getEffectAllowed() {
return effectAllowed;
}
}
|