Search in sources :

Example 1 with Draggable

use of org.magic.game.gui.components.Draggable in project MtgDesktopCompanion by nicho92.

the class CardTransfertHandler method importData.

@Override
public boolean importData(TransferSupport support) {
    if (!canImport(support))
        return false;
    try {
        Draggable target = (Draggable) support.getComponent();
        DisplayableCard src = (DisplayableCard) support.getTransferable().getTransferData(localObjectFlavor);
        if ((((Draggable) src.getParent()).getOrigine() != target.getOrigine())) {
            src.getParent().revalidate();
            target.updatePanel();
            src.getParent().repaint();
            GameManager.getInstance().getStack().put(new CardSpell(src.getName(), src.getText(), src));
            logger.debug("move " + src.getMagicCard().getName() + " from " + ((Draggable) src.getParent()).getOrigine() + " to " + target.getOrigine());
            ((Draggable) src.getParent()).moveCard(src, target.getOrigine());
            target.addComponent(src);
        } else {
            target.postTreatment(src);
        }
        return true;
    } catch (Exception ufe) {
        logger.error("Error transfert", ufe);
    }
    return false;
}
Also used : Draggable(org.magic.game.gui.components.Draggable) CardSpell(org.magic.game.model.CardSpell) DisplayableCard(org.magic.game.gui.components.DisplayableCard) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Aggregations

UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1 DisplayableCard (org.magic.game.gui.components.DisplayableCard)1 Draggable (org.magic.game.gui.components.Draggable)1 CardSpell (org.magic.game.model.CardSpell)1