diff options
Diffstat (limited to 'shared')
6 files changed, 292 insertions, 0 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceRpc.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceRpc.java new file mode 100644 index 0000000000..bbad423044 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceRpc.java @@ -0,0 +1,35 @@ +/* + * 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.shared.ui.dnd; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * RPC for firing server side event when client side dragstart event happens on + * drag source. + */ +public interface DragSourceRpc extends ServerRpc { + + /** + * Called when dragsource event happens on client side. + */ + public void dragStart(); + + /** + * Called when dragend event happens on client side. + */ + public void dragEnd(); +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java new file mode 100644 index 0000000000..aeb4dd816b --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DragSourceState.java @@ -0,0 +1,55 @@ +/* + * 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.shared.ui.dnd; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.vaadin.shared.communication.SharedState; + +/** + * State class containing parameters for DragSourceExtension. + */ +public class DragSourceState extends SharedState { + + /** + * Event identifier for dragend event. + */ + public static final String EVENT_DRAGEND = "dragend"; + + /** + * Event identifier for dragstart event. + */ + public static final String EVENT_DRAGSTART = "dragstart"; + + /** + * {@code DataTransfer.effectAllowed} parameter for the drag event. + */ + public EffectAllowed effectAllowed = EffectAllowed.UNINITIALIZED; + + /** + * {@code DataTransfer.types} parameter. Used to keep track of data formats + * set for the drag event. + */ + public List<String> types = new ArrayList<>(); + + /** + * Used to store data in the {@code DataTransfer} object for the drag event. + */ + public Map<String, String> data = new HashMap<>(); +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DropEffect.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropEffect.java new file mode 100644 index 0000000000..5056ecfd78 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropEffect.java @@ -0,0 +1,41 @@ +/* + * 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.shared.ui.dnd; + +/** + * Used to specify the drop effect to use on dragenter or dragover events. + */ +public enum DropEffect { + /** + * A copy of the source item is made at the new location. + */ + COPY, + + /** + * An item is moved to a new location. + */ + MOVE, + + /** + * A link is established to the source at the new location. + */ + LINK, + + /** + * The item may not be dropped. + */ + NONE +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java new file mode 100644 index 0000000000..dd21278277 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetRpc.java @@ -0,0 +1,42 @@ +/* + * 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.shared.ui.dnd; + +import java.util.List; +import java.util.Map; + +import com.vaadin.shared.communication.ServerRpc; + +/** + * RPC for firing server side drop event when client side drop event happens on + * drop target. + */ +public interface DropTargetRpc extends ServerRpc { + + /** + * Called when drop event happens on client side. + * + * @param types + * Data types that are present in {@code data} map in the same order + * as found in {@code DataTransfer.types}. + * @param data + * Contains data from {@code DataTransfer} object. + * @param dropEffect + * Drop effect set for the drop target where drop happened. + */ + public void drop(List<String> types, Map<String, String> data, + DropEffect dropEffect); +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetState.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetState.java new file mode 100644 index 0000000000..3021c0bd6b --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/DropTargetState.java @@ -0,0 +1,38 @@ +/* + * 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.shared.ui.dnd; + +import com.vaadin.shared.communication.SharedState; + +/** + * State class containing parameters for DropTargetExtension. + */ +public class DropTargetState extends SharedState { + /** + * {@code DataTransfer.dropEffect} parameter for the drag event + */ + public DropEffect dropEffect; + + /** + * Criteria script to allow dragOver event on the element + */ + public String dragOverCriteria; + + /** + * Criteria script to allow drop event on the element + */ + public String dropCriteria; +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/dnd/EffectAllowed.java b/shared/src/main/java/com/vaadin/shared/ui/dnd/EffectAllowed.java new file mode 100644 index 0000000000..2ff9f21980 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/dnd/EffectAllowed.java @@ -0,0 +1,81 @@ +/* + * 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.shared.ui.dnd; + +/** + * Used to specify the effect that is allowed for a drag operation. + */ +public enum EffectAllowed { + /** + * The item may not be dropped. + */ + NONE("none"), + + /** + * A copy of the source item may be made at the new location. + */ + COPY("copy"), + + /** + * An item may be moved to a new location. + */ + MOVE("move"), + + /** + * A link may be established to the source at the new location. + */ + LINK("link"), + + /** + * A copy or move operation is permitted. + */ + COPY_MOVE("copyMove"), + + /** + * A copy or link operation is permitted. + */ + COPY_LINK("copyLink"), + + /** + * A link or move operation is permitted. + */ + LINK_MOVE("linkMove"), + + /** + * All operations are permitted. + */ + ALL("all"), + + /** + * Default state, equivalent to ALL + */ + UNINITIALIZED("uninitialized"); + + private final String value; + + EffectAllowed(String value) { + this.value = value; + } + + /** + * Get the string value that is accepted by the client side drag event. + * + * @return String value accepted by the client side drag event. + */ + public String getValue() { + return value; + } +} |