2 * Copyright 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client.dnd;
21 import gr.ebs.gss.client.GSS;
22 import gr.ebs.gss.client.rest.resource.FileResource;
23 import gr.ebs.gss.client.rest.resource.FolderResource;
25 import java.util.List;
27 import com.allen_sauer.gwt.dnd.client.DragContext;
28 import com.allen_sauer.gwt.dnd.client.drop.SimpleDropController;
33 public class DnDDropController extends SimpleDropController {
35 DnDFocusPanel nodeHolder;
40 public DnDDropController(DnDFocusPanel widget) {
46 * @see com.allen_sauer.gwt.dnd.client.drop.AbstractDropController#onDrop(com.allen_sauer.gwt.dnd.client.DragContext)
48 public void onDrop(DragContext context) {
49 super.onDrop(context);
50 DnDFocusPanel toDrop = (DnDFocusPanel) context.draggable;
51 if (toDrop.getItem() != null) {
52 if (toDrop.getItem().getUserObject() != null && toDrop.getItem().getUserObject() instanceof FolderResource) {
53 FolderResource folderToDrop = (FolderResource) toDrop.getItem().getUserObject();
54 FolderResource initialFolder = null;
55 if (GSS.get().getFolders().isTrash(nodeHolder.getItem())) {
56 } else if (nodeHolder.getItem().getUserObject() instanceof FolderResource)
57 initialFolder = (FolderResource) nodeHolder.getItem().getUserObject();
58 boolean othersShared = false;
59 if (GSS.get().getFolders().isOthersSharedItem(nodeHolder.getItem()))
61 DnDFolderPopupMenu popup = new DnDFolderPopupMenu(GSS.get().getFolders().getImages(), initialFolder, folderToDrop, othersShared);
62 int left = nodeHolder.getItem().getAbsoluteLeft() + 40;
63 int top = nodeHolder.getItem().getAbsoluteTop() + 20;
64 popup.setPopupPosition(left, top);
67 } else if (toDrop.getFiles() != null) {
68 List<FileResource> folderToDrop = toDrop.getFiles();
69 FolderResource initialFolder = null;
70 if (GSS.get().getFolders().isTrash(nodeHolder.getItem())) {
71 } else if (nodeHolder.getItem().getUserObject() instanceof FolderResource)
72 initialFolder = (FolderResource) nodeHolder.getItem().getUserObject();
73 boolean othersShared = false;
74 if (GSS.get().getFolders().isOthersSharedItem(nodeHolder.getItem()))
76 DnDFolderPopupMenu popup = new DnDFolderPopupMenu(GSS.get().getFolders().getImages(), initialFolder, folderToDrop, othersShared);
77 int left = nodeHolder.getItem().getAbsoluteLeft() + 40;
78 int top = nodeHolder.getItem().getAbsoluteTop() + 20;
79 popup.setPopupPosition(left, top);
85 public void onEnter(DragContext context) {
86 super.onEnter(context);
87 nodeHolder.getItem().getWidget().addStyleName("gss-SelectedRow");
88 nodeHolder.getItem().setState(true);
89 GSS.get().getDragController().resetCache();
93 public void onLeave(DragContext context) {
94 nodeHolder.getItem().getWidget().removeStyleName("gss-SelectedRow");
95 super.onLeave(context);