Example usage for com.vaadin.client VConsole log

List of usage examples for com.vaadin.client VConsole log

Introduction

In this page you can find the example usage for com.vaadin.client VConsole log.

Prototype

public static void log(Throwable e) 

Source Link

Usage

From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java

License:Apache License

/**
 * Called whenever an update is received from the server
 *///from w  w  w  .  j a v a 2 s .  c o  m
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    // This call should be made first.
    // It handles sizes, captions, tooltips, etc. automatically.
    if (client.updateComponent(this, uidl, true)) {
        // If client.updateComponent returns true there has been no changes and we
        // do not need to update anything.
        return;
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    this.gClient = client;

    // Save the client side identifier (paintable id) for the widget
    paintableId = uidl.getId();

    try {
        if (uidl.hasAttribute("escapeHTML")) {
            this.escapeHTML = uidl.getBooleanAttribute("escapeHTML");
        }

        UIDL rows = uidl.getChildByTagName("rows");
        if (rows != null) {
            // clear all old table cells
            table.removeAllRows();
            highlighted.clear();
            position2id.clear();

            for (int i = 0; i < rows.getChildCount(); i++) {
                UIDL row = rows.getChildUIDL(i);
                if ("row".equals(row.getTag())) {
                    addRow(row, i);
                }
            }
        } // end if rows not null

        // add end events if necessary to have a nicely aligned regular grid
        int maxCellCount = 0;
        for (int row = 0; row < table.getRowCount(); row++) {
            maxCellCount = Math.max(maxCellCount, getRealColumnCount(row));
        }

        for (int row = 0; row < table.getRowCount(); row++) {
            int isValue = getRealColumnCount(row);

            if (isValue < maxCellCount) {
                int diff = maxCellCount - isValue;
                table.setHTML(row, table.getCellCount(row) + diff - 1, "");
            }
        }

    } catch (Exception ex) {
        VConsole.log(ex);
    }
}

From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java

License:Apache License

public void onClick(int row, int col) {

    VConsole.log("clicked row " + row + " col " + col);
    VConsole.log("size of pdfPageNumbers: " + pdfPageNumbers.size());

    Position pos = new Position(row, col);
    if (startTimes.containsKey(pos)) {
        if (endTimes.containsKey(pos)) {
            gClient.updateVariable(paintableId, "play", "" + startTimes.get(pos) + "-" + endTimes.get(pos),
                    true);//  w  w w  . j  a va 2  s. c  om
        } else {
            gClient.updateVariable(paintableId, "play", "" + startTimes.get(pos), true);
        }

    }

    if (pdfPageNumbers.containsKey(pos)) {
        gClient.updateVariable(paintableId, "openPDF", pdfPageNumbers.get(pos), true);
    }
}

From source file:annis.gui.widgets.gwt.client.ui.VMediaPlayerBase.java

License:Apache License

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
        return;//  w  w  w.j a v a 2 s  .c  o m
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    this.gClient = client;

    // Save the client side identifier (paintable id) for the widget
    paintableId = uidl.getId();

    if (media == null) {
        VConsole.error("media not set!!!");
        return;
    }

    if (uidl.hasAttribute(SOURCE_URL)) {
        registerMetadataLoadedEvent(media);

        if (uidl.hasAttribute(MIME_TYPE)) {
            String mimeType = uidl.getStringAttribute(MIME_TYPE);
            VConsole.log(
                    "canPlayType for \"" + mimeType + "\"value is \"" + media.canPlayType(mimeType) + "\"");
            // check for correct mime type
            if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE)).equals(MediaElement.CANNOT_PLAY)) {
                VConsole.log("CANNOT PLAY!!!");

                gClient.updateVariable(paintableId, CANNOT_PLAY, true, true);
            } else if (media.canPlayType(uidl.getStringAttribute(MIME_TYPE))
                    .equals(MediaElement.CAN_PLAY_MAYBE)) {
                gClient.updateVariable(paintableId, MIGHT_NOT_PLAY, true, true);
            }
        }
        media.setSrc(uidl.getStringAttribute(SOURCE_URL));
    }

    if (uidl.hasAttribute(PLAY)) {
        String[] time = uidl.getStringArrayAttribute(PLAY);
        if (time != null && time.length > 0) {
            if (time.length == 1) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            } else if (time.length == 2) {
                try {
                    media.setCurrentTime(Double.parseDouble(time[0]));
                    setEndTimeOnce(media, Double.parseDouble(time[1]));
                } catch (NumberFormatException ex) {
                    VConsole.error(ex);
                }
            }
            media.play();
        }
    } else if (uidl.hasAttribute(PAUSE)) {
        media.pause();
    } else if (uidl.hasAttribute(STOP)) {
        media.pause();
        media.setSrc("");
    }
}

From source file:com.haulmont.cuba.web.widgets.client.addons.aceeditor.AceEditorConnector.java

License:Apache License

protected void sendToServer(SendCond send, boolean immediately) {
    VConsole.log("sendToServer: send=" + send + ", immediately=" + immediately);
    if (send == SendCond.NO) {
        return;//from   w  ww.  ja  v  a 2 s.  co m
    }

    AceDoc doc = getWidget().getDoc();
    ClientSideDocDiff diff = ClientSideDocDiff.diff(shadow, doc);
    if (send == SendCond.ALWAYS) {
        // Go on...
    } else if (send == SendCond.IF_CHANGED && !diff.isIdentity()) {
        // Go on...
    } else {
        return;
    }

    TransportDiff td = diff.asTransport();

    if (immediately) {
        serverRpc.changed(td, getWidget().getSelection().asTransport(), getWidget().isFocused());
    } else {
        serverRpc.changedDelayed(td, getWidget().getSelection().asTransport(), getWidget().isFocused());
    }

    shadow = doc;
    setOnRoundtrip(true); // What if delayed???
    sendAfterRoundtrip = SendCond.NO;
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.panel.VDDPanelDropHandler.java

License:Apache License

@Override
public boolean drop(VDragEvent drag) {
    VConsole.log("Drop!");

    // Un-emphasis any selections
    getLayout().deEmphasis();/*from w  w w  . j  av a 2 s . c om*/

    // Update the details
    getLayout().updateDragDetails(drag);

    return getLayout().postDropHook(drag) && super.drop(drag);
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.panel.VDDPanelDropHandler.java

License:Apache License

@Override
public void dragOver(VDragEvent drag) {

    VConsole.log("Drag over");

    getLayout().deEmphasis();//from   w  w w. ja  v  a 2 s.  c  o m

    getLayout().updateDragDetails(drag);

    getLayout().postOverHook(drag);

    // Validate the drop
    validate(new VAcceptCallback() {
        public void accepted(VDragEvent event) {
            getLayout().emphasis(event.getElementOver());
        }
    }, drag);
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VDragDropUtil.java

License:Apache License

/**
 * Creates a transferable from a mouse down event. Returns null if creation
 * was not successful.//from  www .  j a  va 2 s  . c  o m
 * 
 * @param event
 *            The mouse down event
 * @param root
 *            The root layout from where the component is dragged
 * @return A transferable or NULL if something failed
 */
public static VTransferable createLayoutTransferableFromMouseDown(NativeEvent event, Widget root,
        Widget target) {

    // NPE check
    if (target == null) {
        VConsole.error("Could not find widget");
        return null;
    }

    VConsole.log("Creating transferable for root:" + root.getElement() + "\t target:" + target.getElement());

    // Special treatment for Tabsheet
    if (root instanceof VDDTabSheet) {
        VDDTabSheet tabsheet = (VDDTabSheet) root;
        TabCaption tab = WidgetUtil.findWidget(target.getElement(), TabCaption.class);
        if (tab != null && tabsheet.getElement().isOrHasChild(tab.getElement())) {
            return createTabsheetTransferableFromMouseDown(tabsheet, tab, event);
        } else {
            // Not a tab
            VConsole.error("Not on tab");
            return null;
        }
    }

    // Special treatment for Accordion
    if (root instanceof VDDAccordion) {
        VDDAccordion accordion = (VDDAccordion) root;
        StackItem tab = WidgetUtil.findWidget(target.getElement(), StackItem.class);
        if (tab != null && accordion.getElement().isOrHasChild(tab.getElement())) {
            return createAccordionTransferableFromMouseDown(accordion, tab, event);
        } else {
            // Not on tab
            VConsole.error("Not on tab");
            return null;
        }
    }

    // Ensure we have the right widget
    target = getTransferableWidget(target);

    // Find the containing layout of the component
    ComponentConnector widgetConnector = Util.findConnectorFor(target);
    if (widgetConnector == null) {
        VConsole.error("No connector found for " + target);
        return null;
    }

    // Iterate until parent either is the root or a layout with drag and
    // drop enabled
    ComponentConnector layoutConnector = (ComponentConnector) widgetConnector.getParent();
    Widget layout = layoutConnector.getWidget();
    while (layout != root && layout != null && layoutConnector != null) {
        if (isDraggingEnabled(layoutConnector, target)) {
            // Found parent layout with support for drag and drop
            break;
        }
        target = layout;
        widgetConnector = layoutConnector;

        layoutConnector = (ComponentConnector) layoutConnector.getParent();
        if (layoutConnector == null) {
            break;
        }

        layout = layoutConnector.getWidget();
    }

    // Consistency check
    if (target == null) {
        VConsole.error("Target was null");
        return null;
    }
    if (root == target) {
        /*
         * Dispatch event again so parent layout can handle the drag of the
         * root
         */
        target.getElement().dispatchEvent(createMouseDownEvent(event));
        return null;
    }
    if (layoutConnector == null) {
        VConsole.error("No layout connector was found");
        return null;
    }

    return createTransferable(layoutConnector, widgetConnector, event);
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.VLayoutDragDropMouseHandler.java

License:Apache License

/**
 * Called when the dragging a component should be initiated by both a mouse
 * down event as well as a touch start event
 *
 * FIXME This method is a BIG hack to circumvent Vaadin's very poor client
 * side API's. This will break often. Refactor once Vaadin gets a grip.
 *
 * @param event//from   w w w . ja va  2s.  c o  m
 */
protected void initiateDrag(NativeEvent event) {
    // Check that dragging is enabled
    if (dragMode == LayoutDragMode.NONE) {
        return;
    }

    // Dragging can only be done with left mouse button and no modifier keys
    if (!isMouseDragEvent(event) && !Util.isTouchEvent(event)) {
        return;
    }

    // Get target widget
    EventTarget eventTarget = event.getEventTarget();
    Element targetElement = Element.as(eventTarget);
    Widget target = WidgetUtil.findWidget(targetElement, null);

    if (isEventOnScrollBar(event)) {
        return;
    }

    // do not drag close button of TabSheet tab
    if (isElementNotDraggable(targetElement)) {
        VDragAndDropManager.get().interruptDrag();
        return;
    }

    // Abort if drag mode is caption mode and widget is not a caption
    boolean isPanelCaption = target instanceof VPanel
            && targetElement.getParentElement().getClassName().contains("v-panel-caption");
    boolean isCaption = isPanelCaption || VDragDropUtil.isCaptionOrCaptionless(target);

    if (dragMode == LayoutDragMode.CAPTION && !isCaption) {
        /*
         * Ensure target is a caption in caption mode
         */
        return;
    }

    if (dragMode == LayoutDragMode.CAPTION && isCaption) {

        /*
         * Ensure that captions in nested layouts don't get accepted if in
         * caption mode
         */

        Widget w = VDragDropUtil.getTransferableWidget(target);
        ComponentConnector c = Util.findConnectorFor(w);
        ComponentConnector parent = (ComponentConnector) c.getParent();
        if (parent.getWidget() != root) {
            return;
        }
    }

    // Create the transfarable
    VTransferable transferable = VDragDropUtil.createLayoutTransferableFromMouseDown(event, root, target);

    // Are we trying to drag the root layout
    if (transferable == null) {
        VConsole.log("Creating transferable on mouse down returned null");
        return;
    }

    // Resolve the component
    final Widget w;
    ComponentConnector c = null, parent = null;

    if (target instanceof TabCaption) {
        TabCaption tabCaption = (TabCaption) target;
        Tab tab = tabCaption.getTab();
        int tabIndex = ((ComplexPanel) tab.getParent()).getWidgetIndex(tab);
        VTabsheet tabsheet = tab.getTabsheet();

        w = tab;
        c = tabsheet.getTab(tabIndex);
        parent = Util.findConnectorFor(tabsheet);

    } else if (root instanceof VDDAccordion) {
        w = target;
        parent = Util.findConnectorFor(root);

        StackItem tab = WidgetUtil.findWidget(targetElement, StackItem.class);
        if (tab != null && root.getElement().isOrHasChild(tab.getElement())) {
            c = ((VDDAccordion) root).getTab(((VDDAccordion) root).getTabPosition(tab));
        }

    } else if (transferable.getData(Constants.TRANSFERABLE_DETAIL_COMPONENT) != null) {

        ComponentConnector connector = (ComponentConnector) transferable
                .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);
        w = connector.getWidget();
        c = Util.findConnectorFor(w);
        parent = (ComponentConnector) c.getParent();

    } else {
        // Failsafe if no widget was found
        w = root;
        c = Util.findConnectorFor(w);
        parent = (ComponentConnector) c.getParent();
        VConsole.log("Could not resolve component, using root as component");
    }

    VConsole.log("Dragging widget: " + w);
    VConsole.log(" in parent: " + parent);

    // Ensure component is draggable
    if (!VDragDropUtil.isDraggingEnabled(parent, w)) {
        VConsole.log("Dragging disabled for " + w.getClass().getName() + " in "
                + parent.getWidget().getClass().getName());
        VDragAndDropManager.get().interruptDrag();
        return;
    }

    // Announce drag start to listeners
    for (DragStartListener dl : dragStartListeners) {
        if (!dl.dragStart(w, dragMode)) {
            VDragAndDropManager.get().interruptDrag();
            return;
        }
    }

    currentDraggedWidget = w;

    // Announce to handler that we are starting a drag operation
    VDragEvent currentDragEvent = VDragAndDropManager.get().startDrag(transferable, event, true);

    /*
     * Create the drag image
     */
    boolean hasDragCaption = false;

    com.google.gwt.dom.client.Element dragImageElement = null;
    if (root instanceof VHasDragCaptionProvider) {
        VDragCaptionProvider dragCaptionProvider = ((VHasDragCaptionProvider) root).getDragCaptionProvider();
        if (dragCaptionProvider != null) {
            hasDragCaption = true;
            dragImageElement = dragCaptionProvider.getDragCaptionElement(currentDraggedWidget);
        }
    }

    if (!hasDragCaption && dragImageProvider != null) {
        dragImageElement = dragImageProvider.getDragImageElement(w);
    }

    if (dragImageElement != null) {

        // Set stylename to proxy component as well
        if (hasDragCaption) {
            dragImageElement.addClassName(ACTIVE_DRAG_CUSTOM_IMAGE_STYLENAME);
        } else {
            dragImageElement.addClassName(ACTIVE_DRAG_SOURCE_STYLENAME);
        }

    } else if (root instanceof VCssLayout) {
        /*
         * CSS Layout does not have an enclosing div so we just use the
         * component div
         */
        dragImageElement = w.getElement();

    } else if (root instanceof VTabsheet) {
        /*
         * Tabsheet should use the dragged tab as a drag image
         */
        dragImageElement = targetElement;

    } else if (root instanceof VAccordion) {
        /*
         * Accordion should use the dragged tab as a drag image
         */
        dragImageElement = targetElement;

    } else if (root instanceof VFormLayout) {
        /*
         * Dragging a component in a form layout should include the caption
         * and error indicator as well
         */
        Element rowElement = (Element) VDDFormLayout
                .getRowFromChildElement((com.google.gwt.dom.client.Element) w.getElement().cast(),
                        (com.google.gwt.dom.client.Element) root.getElement().cast())
                .cast();

        dragImageElement = rowElement;

    } else {
        /*
         * For other layouts we just use the target element;
         */
        dragImageElement = w.getElement();
    }

    Element clone;
    if (hasDragCaption) {
        currentDragEvent.setDragImage(dragImageElement);
        clone = dragImageElement;
    } else {
        currentDragEvent.createDragImage(dragImageElement, true);
        clone = currentDragEvent.getDragImage();
    }

    assert (clone != null);

    // Lock drag image dimensions
    if (!hasDragCaption) {
        clone.getStyle().setWidth(dragImageElement.getOffsetWidth(), Style.Unit.PX);
        clone.getStyle().setHeight(dragImageElement.getOffsetHeight(), Style.Unit.PX);
    }

    if (c != null && c.delegateCaptionHandling() && !(root instanceof VTabsheet)
            && !(root instanceof VAccordion)) {
        /*
         * Captions are not being dragged with the widget since they are
         * separate. Manually add a clone of the caption to the drag image.
         */
        if (target instanceof VCaption) {
            clone.insertFirst(targetElement.cloneNode(true));
        }
    }

    if (BrowserInfo.get().isIE()) {
        // Fix IE not aligning the drag image correctly when dragging
        // layouts
        clone.getStyle().setPosition(Position.ABSOLUTE);
    }

    currentDraggedWidget.addStyleName(ACTIVE_DRAG_SOURCE_STYLENAME);

    // Listen to mouse up for cleanup
    mouseUpHandlerReg = Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(NativePreviewEvent event) {
            if (event.getTypeInt() == Event.ONMOUSEUP || event.getTypeInt() == Event.ONTOUCHEND
                    || event.getTypeInt() == Event.ONTOUCHCANCEL) {
                if (mouseUpHandlerReg != null) {
                    mouseUpHandlerReg.removeHandler();
                    if (currentDraggedWidget != null) {

                        currentDraggedWidget.removeStyleName(ACTIVE_DRAG_SOURCE_STYLENAME);

                        if (dragImageProvider != null) {
                            com.google.gwt.dom.client.Element dragImageElement = dragImageProvider
                                    .getDragImageElement(currentDraggedWidget);
                            if (dragImageElement != null) {
                                dragImageElement.removeClassName(ACTIVE_DRAG_SOURCE_STYLENAME);
                            }
                        }

                        currentDraggedWidget = null;
                    }
                }

                // Ensure capturing is turned off at mouse up
                Event.releaseCapture(RootPanel.getBodyElement());
            }
        }
    });

}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.client.VMultiUpload.java

License:Apache License

private void submit() {
    if (!enabled) {
        VConsole.log("Submit cancelled (disabled)");
        return;//from   www.j a v a2s .  co m
    }
    int files = getFileCount(fu.getElement());
    List<String> filedetails = new ArrayList<String>();
    StringBuilder errorMsg = new StringBuilder();
    for (int i = 0; i < files; i++) {
        VHtml5File file = getFile(fu.getElement(), i);
        if (!isValidFileSize(file, errorMsg) || !isValidMimeType(file, errorMsg)) {
            continue;
        }

        FileWrapper wrapper = queueFilePost(file);
        filedetails.add(wrapper.serialize());
    }
    client.updateVariable(paintableId, "filequeue", filedetails.toArray(new String[filedetails.size()]), true);

    if (!errorMsg.toString().isEmpty()) {
        VNotification.createNotification(1000, client.getUIConnector().getWidget()).show(errorMsg.toString(),
                VNotification.CENTERED, "warning");
    }
    disableUpload();
}

From source file:fi.jasoft.dragdroplayouts.client.ui.VLayoutDragDropMouseHandler.java

License:Apache License

/**
 * Called when the dragging a component should be initiated by both a mouse
 * down event as well as a touch start event
 * /*from  w ww.  j av a  2 s  . c o m*/
 * FIXME This method is a BIG hack to circumvent Vaadin's very poor client
 * side API's. This will break often. Refactor once Vaadin gets a grip.
 * 
 * @param event
 */
protected void initiateDrag(NativeEvent event) {
    // Check that dragging is enabled
    if (dragMode == LayoutDragMode.NONE) {
        return;
    }

    // Dragging can only be done with left mouse button and no modifier keys
    if (!isMouseDragEvent(event) && !Util.isTouchEvent(event)) {
        return;
    }

    // Get target widget
    EventTarget eventTarget = event.getEventTarget();
    Element targetElement = Element.as(eventTarget);
    Widget target = WidgetUtil.findWidget(targetElement, null);

    if (isEventOnScrollBar(event)) {
        return;
    }

    // do not drag close button of TabSheet tab
    if (isElementNotDraggable(targetElement)) {
        VDragAndDropManager.get().interruptDrag();
        return;
    }

    // Abort if drag mode is caption mode and widget is not a caption
    boolean isPanelCaption = target instanceof VPanel
            && targetElement.getParentElement().getClassName().contains("v-panel-caption");
    boolean isCaption = isPanelCaption || VDragDropUtil.isCaptionOrCaptionless(target);

    if (dragMode == LayoutDragMode.CAPTION && !isCaption) {
        /*
         * Ensure target is a caption in caption mode
         */
        return;
    }

    if (dragMode == LayoutDragMode.CAPTION && isCaption) {

        /*
         * Ensure that captions in nested layouts don't get accepted if in
         * caption mode
         */

        Widget w = VDragDropUtil.getTransferableWidget(target);
        ComponentConnector c = Util.findConnectorFor(w);
        ComponentConnector parent = (ComponentConnector) c.getParent();
        if (parent.getWidget() != root) {
            return;
        }
    }

    // Create the transfarable
    VTransferable transferable = VDragDropUtil.createLayoutTransferableFromMouseDown(event, root, target);

    // Are we trying to drag the root layout
    if (transferable == null) {
        VConsole.log("Creating transferable on mouse down returned null");
        return;
    }

    // Resolve the component
    final Widget w;
    ComponentConnector c = null, parent = null;

    if (target instanceof TabCaption) {
        TabCaption tabCaption = (TabCaption) target;
        Tab tab = tabCaption.getTab();
        int tabIndex = ((ComplexPanel) tab.getParent()).getWidgetIndex(tab);
        VTabsheet tabsheet = tab.getTabsheet();

        w = tab;
        c = tabsheet.getTab(tabIndex);
        parent = Util.findConnectorFor(tabsheet);

    } else if (root instanceof VDDAccordion) {
        w = target;
        parent = Util.findConnectorFor(root);

        StackItem tab = WidgetUtil.findWidget(targetElement, StackItem.class);
        if (tab != null && root.getElement().isOrHasChild(tab.getElement())) {
            c = ((VDDAccordion) root).getTab(((VDDAccordion) root).getTabPosition(tab));
        }

    } else if (transferable.getData(Constants.TRANSFERABLE_DETAIL_COMPONENT) != null) {

        ComponentConnector connector = (ComponentConnector) transferable
                .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);
        w = connector.getWidget();
        c = Util.findConnectorFor(w);
        parent = (ComponentConnector) c.getParent();

    } else {
        // Failsafe if no widget was found
        w = root;
        c = Util.findConnectorFor(w);
        parent = (ComponentConnector) c.getParent();
        VConsole.log("Could not resolve component, using root as component");
    }

    VConsole.log("Dragging widget: " + w);
    VConsole.log(" in parent: " + parent);

    // Ensure component is draggable
    if (!VDragDropUtil.isDraggingEnabled(parent, w)) {
        VConsole.log("Dragging disabled for " + w.getClass().getName() + " in "
                + parent.getWidget().getClass().getName());
        VDragAndDropManager.get().interruptDrag();
        return;
    }

    // Announce drag start to listeners
    for (DragStartListener dl : dragStartListeners) {
        if (!dl.dragStart(w, dragMode)) {
            VDragAndDropManager.get().interruptDrag();
            return;
        }
    }

    currentDraggedWidget = w;

    // Announce to handler that we are starting a drag operation
    VDragEvent currentDragEvent = VDragAndDropManager.get().startDrag(transferable, event, true);

    /*
     * Create the drag image
     */
    com.google.gwt.dom.client.Element dragImageElement = dragImageProvider == null ? null
            : dragImageProvider.getDragImageElement(w);

    if (dragImageElement != null) {

        // Set stylename to proxy component as well
        dragImageElement.addClassName(ACTIVE_DRAG_SOURCE_STYLENAME);

    } else if (root instanceof VCssLayout) {
        /*
         * CSS Layout does not have an enclosing div so we just use the
         * component div
         */
        dragImageElement = w.getElement();

    } else if (root instanceof VTabsheet) {
        /*
         * Tabsheet should use the dragged tab as a drag image
         */
        dragImageElement = targetElement;

    } else if (root instanceof VAccordion) {
        /*
         * Accordion should use the dragged tab as a drag image
         */
        dragImageElement = targetElement;

    } else if (root instanceof VFormLayout) {
        /*
         * Dragging a component in a form layout should include the caption
         * and error indicator as well
         */
        Element rowElement = (Element) VDDFormLayout
                .getRowFromChildElement((com.google.gwt.dom.client.Element) w.getElement().cast(),
                        (com.google.gwt.dom.client.Element) root.getElement().cast())
                .cast();

        dragImageElement = rowElement;

    } else {
        /*
         * For other layouts we just use the target element;
         */
        dragImageElement = w.getElement();
    }

    currentDragEvent.createDragImage(dragImageElement, true);
    Element clone = currentDragEvent.getDragImage();
    assert (clone != null);

    // Lock drag image dimensions
    clone.getStyle().setWidth(dragImageElement.getOffsetWidth(), Unit.PX);
    clone.getStyle().setHeight(dragImageElement.getOffsetHeight(), Unit.PX);

    if (c != null && c.delegateCaptionHandling() && !(root instanceof VTabsheet)
            && !(root instanceof VAccordion)) {
        /*
         * Captions are not being dragged with the widget since they are
         * separate. Manually add a clone of the caption to the drag image.
         */
        if (target instanceof VCaption) {
            clone.insertFirst(targetElement.cloneNode(true));
        }
    }

    if (BrowserInfo.get().isIE()) {
        // Fix IE not aligning the drag image correctly when dragging
        // layouts
        clone.getStyle().setPosition(Position.ABSOLUTE);
    }

    currentDraggedWidget.addStyleName(ACTIVE_DRAG_SOURCE_STYLENAME);

    // Listen to mouse up for cleanup
    mouseUpHandlerReg = Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
        @Override
        public void onPreviewNativeEvent(NativePreviewEvent event) {
            if (event.getTypeInt() == Event.ONMOUSEUP || event.getTypeInt() == Event.ONTOUCHEND
                    || event.getTypeInt() == Event.ONTOUCHCANCEL) {
                if (mouseUpHandlerReg != null) {
                    mouseUpHandlerReg.removeHandler();
                    if (currentDraggedWidget != null) {

                        currentDraggedWidget.removeStyleName(ACTIVE_DRAG_SOURCE_STYLENAME);

                        if (dragImageProvider != null) {
                            com.google.gwt.dom.client.Element dragImageElement = dragImageProvider
                                    .getDragImageElement(currentDraggedWidget);
                            if (dragImageElement != null) {
                                dragImageElement.removeClassName(ACTIVE_DRAG_SOURCE_STYLENAME);
                            }
                        }

                        currentDraggedWidget = null;
                    }
                }

                // Ensure capturing is turned off at mouse up
                Event.releaseCapture(RootPanel.getBodyElement());
            }
        }
    });

}