| Home >> All >> com >> memoire >> [ dnd Javadoc ] |
Source code: com/memoire/dnd/DndRequestSelection.java
1 /** 2 * @modification $Date: 2002/12/16 18:56:25 $ 3 * @statut unstable 4 * @file DndRequestSelection.java 5 * @version 0.36 6 * @author Guillaume Desnoix 7 * @email guillaume@desnoix.com 8 * @license GNU General Public License 2 (GPL2) 9 * @copyright 1998-2001 Guillaume Desnoix 10 */ 11 12 package com.memoire.dnd; 13 import com.memoire.dnd.*; 14 15 16 import java.awt.*; 17 import javax.swing.*; 18 import javax.swing.tree.*; 19 20 public class DndRequestSelection 21 implements DndRequestData 22 { 23 public static final DndRequestSelection SINGLETON= 24 new DndRequestSelection(); 25 26 protected DndRequestSelection() { } 27 28 public Object[] request(JComponent _component,Point _location) 29 { 30 Object[] r=null; 31 32 if(_component instanceof JList) 33 { 34 JList list=(JList)_component; 35 r=list.getSelectedValues(); 36 } 37 else 38 if(_component instanceof JTree) 39 { 40 JTree tree=(JTree)_component; 41 TreePath[] path=tree.getSelectionPaths(); 42 43 if(path!=null) 44 { 45 int l =path.length; 46 r=new Object[l]; 47 for(int i=0;i<l;i++) 48 r[i]=path[i].getLastPathComponent(); 49 } 50 } 51 52 /* 53 if(r!=null) 54 System.err.println("VALUE[]="+r.length); 55 */ 56 57 if((r!=null)&&(r.length==0)) r=null; 58 return (r!=null ? new Object[] { r } : new Object[0]); 59 } 60 }