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

AbstractGuiDropListener.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.Cursor;
00028 import java.awt.datatransfer.Transferable;
00029 import java.awt.dnd.DragGestureEvent;
00030 import java.awt.dnd.DragGestureListener;
00031 import java.awt.dnd.DragGestureRecognizer;
00032 import java.awt.dnd.DragSourceContext;
00033 import java.awt.dnd.DragSourceDragEvent;
00034 import java.awt.dnd.DragSourceDropEvent;
00035 import java.awt.dnd.DragSourceEvent;
00036 import java.awt.dnd.DragSourceListener;
00037 import java.awt.dnd.DropTargetDragEvent;
00038 import java.awt.dnd.DropTargetEvent;
00039 import java.awt.dnd.DropTargetListener;
00040 import java.awt.event.MouseEvent;
00041 import java.awt.event.MouseListener;
00042 import java.awt.event.MouseMotionListener;
00043 
00044 import org.objectweb.cjdbc.console.gui.CjdbcGui;
00045 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00046 
00047 /**
00048  * This class defines a AbstractGuiDropListener. This is mainly to hide all the
00049  * method we don't need to implement for all of the drop listeners.
00050  * 
00051  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00052  * @version 1.0
00053  */
00054 public abstract class AbstractGuiDropListener implements DropTargetListener, // For
00055     // processing
00056     // drop
00057     // target
00058     // events
00059     DragSourceListener, // For processing drag source events
00060     MouseMotionListener, // For processing mouse drags
00061     MouseListener, // For processing mouse clicks
00062     DragGestureListener // For recognizing the start of drags
00063 {
00064 
00065   CjdbcGui              gui;
00066   DragGestureRecognizer dgr;
00067 
00068   /**
00069    * @see java.awt.dnd.DragGestureListener#dragGestureRecognized(java.awt.dnd.DragGestureEvent)
00070    */
00071   public void dragGestureRecognized(DragGestureEvent e)
00072   {
00073     //System.out.println("Gesture recognized");
00074     if(dgr!=null)
00075     {
00076       dgr.resetRecognizer();
00077     }
00078     dgr = e.getSourceAsDragGestureRecognizer();
00079     Transferable transfer = (Transferable) e.getComponent();
00080     
00081     try
00082     {
00083       e.getDragSource().startDrag(e, GuiConstants.customCursor, transfer, this);
00084     }
00085     catch (Exception error)
00086     {
00087       //System.out.println("Got error while dragging resetting listener...");
00088       dgr.resetRecognizer();
00089       e.getDragSource().startDrag(e, GuiConstants.customCursor, transfer, this);
00090     }
00091   }
00092 
00093   /**
00094    * Creates a new <code>AbstractGuiDropListener.java</code> object
00095    * 
00096    * @param gui the main interface
00097    */
00098   public AbstractGuiDropListener(CjdbcGui gui)
00099   {
00100     this.gui = gui;
00101   }
00102 
00103   /**
00104    * @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent)
00105    */
00106   public void dragEnter(DropTargetDragEvent dtde)
00107   {
00108     //System.out.println("Drag enter target");
00109   }
00110 
00111   /**
00112    * @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent)
00113    */
00114   public void dragExit(DropTargetEvent dte)
00115   {
00116     //System.out.println("Drag exit target");
00117   }
00118 
00119   /**
00120    * @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent)
00121    */
00122   public void dragOver(DropTargetDragEvent dtde)
00123   {
00124     //System.out.println("Drag over target");
00125   }
00126 
00127   /**
00128    * @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent)
00129    */
00130   public void dropActionChanged(DropTargetDragEvent dtde)
00131   {
00132     //System.out.println("Drop action changed target");
00133   }
00134 
00135   /**
00136    * @see java.awt.dnd.DragSourceListener#dragDropEnd(java.awt.dnd.DragSourceDropEvent)
00137    */
00138   public void dragDropEnd(DragSourceDropEvent dsde)
00139   {
00140     //System.out.println("Drag drop end source");
00141     dgr.resetRecognizer();
00142     dgr = null;
00143     
00144     DragSourceContext dsc = dsde.getDragSourceContext();
00145     dsc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
00146     gui.repaint();
00147     //gui.publicActionRefreshCursorShape();
00148   }
00149 
00150   /**
00151    * @see java.awt.dnd.DragSourceListener#dragEnter(java.awt.dnd.DragSourceDragEvent)
00152    */
00153   public void dragEnter(DragSourceDragEvent dsde)
00154   {
00155     //System.out.println("Drag enter source");
00156   }
00157 
00158   /**
00159    * @see java.awt.dnd.DragSourceListener#dragExit(java.awt.dnd.DragSourceEvent)
00160    */
00161   public void dragExit(DragSourceEvent dse)
00162   {
00163     //System.out.println("Drag exit source");
00164   }
00165 
00166   /**
00167    * @see java.awt.dnd.DragSourceListener#dragOver(java.awt.dnd.DragSourceDragEvent)
00168    */
00169   public void dragOver(DragSourceDragEvent dsde)
00170   {
00171     //System.out.println("Drag over source");
00172   }
00173 
00174   /**
00175    * @see java.awt.dnd.DragSourceListener#dropActionChanged(java.awt.dnd.DragSourceDragEvent)
00176    */
00177   public void dropActionChanged(DragSourceDragEvent dsde)
00178   {
00179     //System.out.println("Drop action changed source");
00180   }
00181 
00182   /**
00183    * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
00184    */
00185   public void mouseDragged(MouseEvent e)
00186   {
00187 
00188   }
00189 
00190   /**
00191    * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
00192    */
00193   public void mouseMoved(MouseEvent e)
00194   {
00195 
00196   }
00197 
00198   /**
00199    * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
00200    */
00201   public void mouseClicked(MouseEvent e)
00202   {
00203 
00204   }
00205 
00206   /**
00207    * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
00208    */
00209   public void mouseEntered(MouseEvent e)
00210   {
00211 
00212   }
00213 
00214   /**
00215    * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
00216    */
00217   public void mouseExited(MouseEvent e)
00218   {
00219 
00220   }
00221 
00222   /**
00223    * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
00224    */
00225   public void mousePressed(MouseEvent e)
00226   {
00227     
00228   }
00229 
00230   /**
00231    * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
00232    */
00233   public void mouseReleased(MouseEvent e)
00234   {
00235 
00236   }
00237 }

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