Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

BackendTransferListener.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.console.gui.dnd.listeners;
00026 
00027 import java.awt.Component;
00028 import java.awt.datatransfer.DataFlavor;
00029 import java.awt.datatransfer.Transferable;
00030 import java.awt.dnd.DnDConstants;
00031 import java.awt.dnd.DropTarget;
00032 import java.awt.dnd.DropTargetDropEvent;
00033 
00034 import javax.swing.JButton;
00035 import javax.swing.JPanel;
00036 
00037 import org.objectweb.cjdbc.console.gui.CjdbcGui;
00038 
00039 /**
00040  * This class defines a BackendTransferListener. Listens for DnD on backends
00041  * 
00042  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00043  * @version 1.0
00044  */
00045 public class BackendTransferListener extends AbstractGuiDropListener
00046 {
00047 
00048   /**
00049    * Creates a new <code>BackendTransferListener.java</code> object
00050    * 
00051    * @param gui link to the main gui
00052    */
00053   public BackendTransferListener(CjdbcGui gui)
00054   {
00055     super(gui);
00056   }
00057 
00058   /**
00059    * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
00060    */
00061   public void drop(DropTargetDropEvent dtde)
00062   {
00063     dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
00064     DropTarget target = dtde.getDropTargetContext().getDropTarget();
00065     Transferable transfer = dtde.getTransferable();
00066     
00067     
00068     Component comp = target.getComponent();
00069     try
00070     {
00071       Object data = transfer.getTransferData(DataFlavor.stringFlavor);
00072       if (comp instanceof JButton)
00073         gui.publicActionExecuteBackendDrop((JButton) comp, data.toString());
00074       else if (comp instanceof JPanel)
00075         gui.publicActionExecuteBackendDrop((JPanel) comp, data.toString());
00076 
00077     }
00078     catch (Exception e)
00079     {
00080       gui.appendDebugText("Failed to execute Drag and drop for target:"
00081           + comp.getName(),e);
00082     }
00083     finally
00084     {
00085       dtde.getDropTargetContext().removeNotify();
00086       dtde.dropComplete(true);
00087       gui.publicActionRefreshCursorShape();
00088     }
00089     dtde.getDropTargetContext().removeNotify();
00090     
00091     dtde.dropComplete(true);
00092     
00093   }
00094 }

Generated on Mon Apr 11 22:01:29 2005 for C-JDBC by  doxygen 1.3.9.1