fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
43 stars 41 forks source link

When adding a widget that doesn't have handlers, no error will be shown, it just wont work. #170

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Does the issue occur in "quirks mode", "standards mode" or both? If you
don't know, does your HTML page contains a DOCTYPE declaration?

What version of GWT are you using? 1.4.60? 2.0.4? Other?
2.5.1
What version of the gwt-dnd jar file or library file are you using?
3.1.2
What operating system(s) are you using? Windows? Linux? Mac?
windows
Does the issue occur in web mode, development mode (formerly "hosted
mode"), both or don't know?
both
What browser(s) do you use? Chrome, Firefox, IE, Safari, other?
chrome
What is the browser version (if you know) from Help->About?

What steps will reproduce the problem? Please attach sample code if you
can.
RegisterDraggable should be throwing expception when none of the handlers are 
implemented, instead it just does nothing:
RegisteredDraggable(Widget dragable, Widget dragHandle) {
      this.dragable = dragable;
      if (dragHandle instanceof HasTouchStartHandlers) {
        touchStartHandlerRegistration = ((HasTouchStartHandlers) dragHandle).addTouchStartHandler(MouseDragHandler.this);
      }
      if (dragHandle instanceof HasMouseDownHandlers) {
        mouseDownHandlerRegistration = ((HasMouseDownHandlers) dragHandle).addMouseDownHandler(MouseDragHandler.this);
      }
//SHOULD THROW EXCEPTION HERE, that would be cought level above.
    }

Do you have a workaround?
Yeah, throw an expection in place where I have commented.

Please provide any additional information below.

This part of code above is called from MouseDragHandler, line 205:
void makeDraggable(Widget draggable, Widget dragHandle) {
    if (draggable instanceof PopupPanel) {
      DOMUtil.reportFatalAndThrowRuntimeException("PopupPanel (and its subclasses) cannot be made draggable; See http://code.google.com/p/gwt-dnd/issues/detail?id=43");
    }
    try {
      RegisteredDraggable registeredDraggable = new RegisteredDraggable(draggable, dragHandle);
      dragHandleMap.put(dragHandle, registeredDraggable);
    } catch (Exception ex) {
      throw new RuntimeException("dragHandle must implement HasMouseDownHandlers to be draggable",
          ex);
    }
  }

But cus of not throwing exception, this catch wont be fired

Original issue reported on code.google.com by michal.k...@ocado.com on 2 May 2013 at 7:50