Author: jerome
Date: 2009-02-12 00:18:00 +0100 (Thu, 12 Feb 2009)
New Revision: 3611

Modified:
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxDropTarget.java
Log:
* Cleanup TuxDropTarget class.
* Typo.

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxDropTarget.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxDropTarget.java
     2009-02-11 22:33:49 UTC (rev 3610)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/Utils/TuxDropTarget.java
     2009-02-11 23:18:00 UTC (rev 3611)
@@ -45,8 +45,8 @@
         * @param methodEnter  Triggered method name on drag enter.
         * @param methodExit   Triggered method name on drag exit.
         */
-       public TuxDropTarget(Object sender, String method, String methodEnter, 
-                       String methodExit){
+       public TuxDropTarget(Object sender, String method, String methodEnter, 
String methodExit)
+       {
                super();
                //Registering references.
                pSender = sender;
@@ -54,94 +54,68 @@
                pMethodEnter = methodEnter;
                pMethodExit = methodExit;
        }
+       
+       
+       /**
+        * Excecute a method given in arameters.
+        * @param method
+        */
+       private void execute(String method)
+       {
+               if(pSender == null)
+               {
+                       return;
+               }
+               
+               if(method != null)
+               {
+                       Class<?> targetClass = pSender.getClass();
+                       try
+                       {
+                               Method targetMethod = 
targetClass.getDeclaredMethod(method);
+                               targetMethod.invoke(pSender);
+                       }
+                       catch(Exception e)
+                       {
+                               CcCommons.logger.appendError(e.getStackTrace());
+                       }
+               }
+       }
+       
        
        /**
         * Drag enter received.
-        */
-       @SuppressWarnings("unchecked")
-       public void dragEnter(DropTargetDragEvent dtde) {
-               if(this.pMethodEnter != null){
-                       Class targetClass = pSender.getClass();
-                       try
-                       {
-                               Method targetMethod = 
targetClass.getDeclaredMethod(pMethodEnter);
-                               targetMethod.invoke(pSender);
-                       }
-                       catch(Exception e)
-                       {
-                               CcCommons.logger.appendError(e.getStackTrace());
-                               e.printStackTrace();
-                       }
-               }
-         }
+        */
+       public void dragEnter(DropTargetDragEvent dtde) 
+       {
+               this.execute(pMethodEnter);
+       }
 
        
-         /**
-          * Drag exit received
-          */
-         @SuppressWarnings("unchecked")
-       public void dragExit(DropTargetEvent dte) {
-                 if(this.pMethodExit != null){
-                         Class targetClass = pSender.getClass();
-                         try
-                               {
-                                       Method targetMethod = 
targetClass.getDeclaredMethod(pMethodExit);
-                                       targetMethod.invoke(pSender);
-                               }
-                               catch(Exception e)
-                               {
-                                       
CcCommons.logger.appendError(e.getStackTrace());
-                                       e.printStackTrace();
-                               }
-                 }
-         }
+       /**
+       * Drag exit received
+       */
+       public void dragExit(DropTargetEvent dte) 
+       {
+        this.execute(pMethodExit);
+       }
+         
+       
+       /**
+       * Drop received
+       */
+       public void drop(DropTargetDropEvent dtde) 
+       {
+               this.execute(pMethod);
+               this.execute(pMethodExit);
+       }
 
          
-         /**
-          * Drag over received
-          */
-         public void dragOver(DropTargetDragEvent dtde) {}
-         
-         /**
-          * Drop received
-          */
-         public void drop(DropTargetDropEvent dtde) {
-                 Class<?> targetClass = pSender.getClass();
-                                       
-               try
-               {       
-                       if(this.pMethod != null){
-                               Method targetMethod = 
targetClass.getDeclaredMethod(pMethod);
-                               targetMethod.invoke(pSender);
-                       }
-                       if(this.pMethodExit != null){
-                               Method targetMethod2 = 
targetClass.getDeclaredMethod(pMethodExit);
-                               targetMethod2.invoke(pSender);
-                       }
-               }
-               catch(Exception e)
-               {
-                       CcCommons.logger.appendError(e.getStackTrace());
-                       e.printStackTrace();
-               }
-
-         }
-
-         
-         /**
-          * Drop action changed received
-          */
-         public void dropActionChanged(DropTargetDragEvent dtde) {
-                 Class<?> targetClass = pSender.getClass();
-                 try
-                       {
-                               Method targetMethod = 
targetClass.getDeclaredMethod(pMethodExit);
-                               targetMethod.invoke(pSender);
-                       }
-                       catch(Exception e)
-                       {
-                               CcCommons.logger.appendError(e.getStackTrace());
-                               e.printStackTrace();
-                       }
-         }
+       /**
+       * Drop action changed received
+       */
+       public void dropActionChanged(DropTargetDragEvent dtde) 
+       {
+               this.execute(pMethodExit);
+       }
 }
\ No newline at end of file


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to