- dragController = new PickupDragController(RootPanel.get(), false) {
-
- @Override
- public void previewDragStart() throws VetoDragException {
- super.previewDragStart();
- if (context.selectedWidgets.isEmpty())
- throw new VetoDragException();
-
- if (context.draggable != null)
- if (context.draggable instanceof DnDFocusPanel) {
- DnDFocusPanel toDrop = (DnDFocusPanel) context.draggable;
- // prevent drag and drop for trashed files and for
- // unselected tree items
- if (toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent()))
- throw new VetoDragException();
- else if (toDrop.getItem() != null && !toDrop.getItem().equals(folders.getCurrent()))
- throw new VetoDragException();
- else if (toDrop.getItem() != null && !toDrop.getItem().isDraggable())
- throw new VetoDragException();
-
- } else if (context.draggable instanceof DnDSimpleFocusPanel) {
- DnDSimpleFocusPanel toDrop = (DnDSimpleFocusPanel) context.draggable;
- // prevent drag and drop for trashed files and for
- // unselected tree items
- if (toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent()))
- throw new VetoDragException();
- }
- }
-
- @Override
- protected Widget newDragProxy(DragContext aContext) {
- AbsolutePanel container = new AbsolutePanel();
- DOM.setStyleAttribute(container.getElement(), "overflow", "visible");
- for (Iterator iterator = aContext.selectedWidgets.iterator(); iterator.hasNext();) {
- HTML html = null;
- Widget widget = (Widget) iterator.next();
- if (widget instanceof DnDFocusPanel) {
- DnDFocusPanel book = (DnDFocusPanel) widget;
- if(book.getFiles().size()>1)
- html=new HTML(book.getFiles().size()+ " files");
- else
- html = book.cloneHTML();
- } else if (widget instanceof DnDSimpleFocusPanel) {
- DnDSimpleFocusPanel book = (DnDSimpleFocusPanel) widget;
- if(book.getFiles().size()>1)
- html=new HTML(book.getFiles().size()+ " files");
- else
- html = book.cloneHTML();
- }
- if (html == null)
- container.add(new Label("Drag ME"));
- else
- container.add(html);
- }
- return container;
- }
- };
- dragController.setBehaviorDragProxy(true);
- dragController.setBehaviorMultipleSelection(false);