From 4e4e8faab9e5209b0fa98866ec3f1ea444efa96b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 16 Aug 2016 14:08:16 +0300 Subject: Move component drag'n'drop criteria to the correct packages Change-Id: I8c681fe89d8ce7cee067f07e6b4aecbfd5ac1970 --- .../client/ui/dd/VLazyInitItemIdentifiers.java | 25 ++------- .../com/vaadin/client/ui/dd/VTargetInSubtree.java | 56 -------------------- .../ui/table/VTableLazyInitItemIdentifiers.java | 26 ++++++++++ .../vaadin/client/ui/tree/VTargetInSubtree.java | 59 ++++++++++++++++++++++ .../ui/tree/VTreeLazyInitItemIdentifiers.java | 26 ++++++++++ 5 files changed, 116 insertions(+), 76 deletions(-) delete mode 100644 client/src/main/java/com/vaadin/client/ui/dd/VTargetInSubtree.java create mode 100644 client/src/main/java/com/vaadin/client/ui/table/VTableLazyInitItemIdentifiers.java create mode 100644 client/src/main/java/com/vaadin/client/ui/tree/VTargetInSubtree.java create mode 100644 client/src/main/java/com/vaadin/client/ui/tree/VTreeLazyInitItemIdentifiers.java (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java index f67174c1c1..b254df78dc 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VLazyInitItemIdentifiers.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2014 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 @@ -14,37 +14,22 @@ * the License. */ /** - * + * */ package com.vaadin.client.ui.dd; import java.util.HashSet; import com.vaadin.client.UIDL; -import com.vaadin.shared.ui.dd.AcceptCriterion; -import com.vaadin.ui.Table; -import com.vaadin.ui.Tree; /** - * + * */ public class VLazyInitItemIdentifiers extends VAcceptCriterion { private boolean loaded = false; private HashSet hashSet; private VDragEvent lastDragEvent; - @AcceptCriterion(Table.TableDropCriterion.class) - final public static class VTableLazyInitItemIdentifiers extends - VLazyInitItemIdentifiers { - // all logic in superclass - } - - @AcceptCriterion(Tree.TreeDropCriterion.class) - final public static class VTreeLazyInitItemIdentifiers extends - VLazyInitItemIdentifiers { - // all logic in superclass - } - @Override public void accept(final VDragEvent drag, UIDL configuration, final VAcceptCallback callback) { diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VTargetInSubtree.java b/client/src/main/java/com/vaadin/client/ui/dd/VTargetInSubtree.java deleted file mode 100644 index 1641eb30f1..0000000000 --- a/client/src/main/java/com/vaadin/client/ui/dd/VTargetInSubtree.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2014 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.client.ui.dd; - -import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.UIDL; -import com.vaadin.client.ui.VTree; -import com.vaadin.client.ui.VTree.TreeNode; -import com.vaadin.shared.ui.dd.AcceptCriterion; -import com.vaadin.ui.Tree; - -@AcceptCriterion(Tree.TargetInSubtree.class) -final public class VTargetInSubtree extends VAcceptCriterion { - - @Override - protected boolean accept(VDragEvent drag, UIDL configuration) { - - VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() - .getConnector().getWidget(); - TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() - .get("itemIdOver")); - if (treeNode != null) { - Widget parent2 = treeNode; - int depth = configuration.getIntAttribute("depth"); - if (depth < 0) { - depth = Integer.MAX_VALUE; - } - final String searchedKey = configuration.getStringAttribute("key"); - for (int i = 0; i <= depth && parent2 instanceof TreeNode; i++) { - if (searchedKey.equals(((TreeNode) parent2).key)) { - return true; - } - // panel -> next level node - parent2 = parent2.getParent().getParent(); - } - } - - return false; - } -} diff --git a/client/src/main/java/com/vaadin/client/ui/table/VTableLazyInitItemIdentifiers.java b/client/src/main/java/com/vaadin/client/ui/table/VTableLazyInitItemIdentifiers.java new file mode 100644 index 0000000000..e5f462ea6e --- /dev/null +++ b/client/src/main/java/com/vaadin/client/ui/table/VTableLazyInitItemIdentifiers.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 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.client.ui.table; + +import com.vaadin.client.ui.dd.VLazyInitItemIdentifiers; +import com.vaadin.shared.ui.dd.AcceptCriterion; +import com.vaadin.ui.Table; + +@AcceptCriterion(Table.TableDropCriterion.class) +public final class VTableLazyInitItemIdentifiers + extends VLazyInitItemIdentifiers { + // all logic in superclass +} diff --git a/client/src/main/java/com/vaadin/client/ui/tree/VTargetInSubtree.java b/client/src/main/java/com/vaadin/client/ui/tree/VTargetInSubtree.java new file mode 100644 index 0000000000..a9bddba65a --- /dev/null +++ b/client/src/main/java/com/vaadin/client/ui/tree/VTargetInSubtree.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2014 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.client.ui.tree; + +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.UIDL; +import com.vaadin.client.ui.VTree; +import com.vaadin.client.ui.VTree.TreeNode; +import com.vaadin.client.ui.dd.VAcceptCriterion; +import com.vaadin.client.ui.dd.VDragAndDropManager; +import com.vaadin.client.ui.dd.VDragEvent; +import com.vaadin.shared.ui.dd.AcceptCriterion; +import com.vaadin.ui.Tree; + +@AcceptCriterion(Tree.TargetInSubtree.class) +final public class VTargetInSubtree extends VAcceptCriterion { + + @Override + protected boolean accept(VDragEvent drag, UIDL configuration) { + + VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler() + .getConnector().getWidget(); + TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails() + .get("itemIdOver")); + if (treeNode != null) { + Widget parent2 = treeNode; + int depth = configuration.getIntAttribute("depth"); + if (depth < 0) { + depth = Integer.MAX_VALUE; + } + final String searchedKey = configuration.getStringAttribute("key"); + for (int i = 0; i <= depth && parent2 instanceof TreeNode; i++) { + if (searchedKey.equals(((TreeNode) parent2).key)) { + return true; + } + // panel -> next level node + parent2 = parent2.getParent().getParent(); + } + } + + return false; + } +} diff --git a/client/src/main/java/com/vaadin/client/ui/tree/VTreeLazyInitItemIdentifiers.java b/client/src/main/java/com/vaadin/client/ui/tree/VTreeLazyInitItemIdentifiers.java new file mode 100644 index 0000000000..e4d6ae02b0 --- /dev/null +++ b/client/src/main/java/com/vaadin/client/ui/tree/VTreeLazyInitItemIdentifiers.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 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.client.ui.tree; + +import com.vaadin.client.ui.dd.VLazyInitItemIdentifiers; +import com.vaadin.shared.ui.dd.AcceptCriterion; +import com.vaadin.ui.Tree; + +@AcceptCriterion(Tree.TreeDropCriterion.class) +public final class VTreeLazyInitItemIdentifiers + extends VLazyInitItemIdentifiers { + // all logic in superclass +} -- cgit v1.2.3