/*
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 */

package com.sun.javafx.tk.quantum;

import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;

import com.sun.glass.ui.Clipboard;
import com.sun.glass.ui.ClipboardAssistance;
import com.sun.javafx.tk.TKClipboard;
import com.sun.javafx.tk.TKDropEvent;

/*
 * GlassDragEvent
 * 
 * @author Morris Meyer
 */
public class GlassDragEvent extends TKDropEvent {

    public static final int START = 1;
    public static final int END = 2;
    public static final int ENTER = 3;
    public static final int OVER = 4;
    public static final int LEAVE = 5;
    
    private Dragboard dragboard;
    private int x, y, xAbs, yAbs;
    int button;

    GlassScene glassScene;

    int type;
    int recommendedDropAction;

    int getType() {
        return type;
    }
    int getX() {
        return x;
    }
    int getY() {
        return y;
    }
    int getXAbs() {
        return xAbs;
    }
    int getYAbs() {
        return yAbs;
    }
    GlassScene getGlassScene() {
        return glassScene;
    }
    public int getRecommendedDropAction() {
        return recommendedDropAction;
    }


    GlassDragEvent(int type, int x, int y, int xAbs, int yAbs, Dragboard db, int button, GlassScene glassScene,
            int recommendedDropAction) {
        this.type = type;

        /*
         * pretty ugly - we're basically discerning between a DND operation
         * that has originated internally (and thus has a dragboard with content),
         * versus one that originated externally (and thus the content is in
         * the dragboard.
         */
        //this.dragboard = db != null && db.hasAnyContent() ? db : null;
        this.dragboard = db;

        this.x = x;
        this.y = y;
        this.xAbs = xAbs;
        this.yAbs = yAbs;
        this.button = button;
        this.glassScene = glassScene;
        this.recommendedDropAction = recommendedDropAction;
    }

    @Override
    public void accept(TransferMode tm) {
    }

    @Override
    public void reject() {
    }

    @Override
    public Dragboard getDragboard() {
       if (dragboard == null) {
           // final Transferable t = dtde.getTransferable();
           TKClipboard peer = QuantumClipboard.getDragboardInstance(
                   new ClipboardAssistance(Clipboard.DND));
           dragboard = Dragboard.impl_create(peer);
       }
       return dragboard;
    }

    @Override
    public void dropComplete(boolean isComplete) {
        // dtde.dropComplete(isComplete);
    }
}
