1 32 33 package it.businesslogic.ireport.gui.dnd; 34 35 39 import it.businesslogic.ireport.gui.*; 40 import javax.swing.*; 41 import java.awt.*; 42 import java.awt.datatransfer.*; 43 44 public class ListColumnTransferableHandler extends ColumnTransferableHandler { 45 private int[] indices = null; 46 private int addIndex = -1; private int addCount = 0; private JSQLTablesPane jSQLTablePane=null; 49 public void setSQLTablesPane(JSQLTablesPane jSQLTablePane) 50 { 51 this.jSQLTablePane = jSQLTablePane; 52 } 53 public JSQLTablesPane getSQLTablesPane() 54 { 55 return this.jSQLTablePane; 56 } 57 58 protected String exportString(JComponent c) { 61 JList list = (JList)c; 62 indices = list.getSelectedIndices(); 63 Object [] values = list.getSelectedValues(); 64 65 StringBuffer buff = new StringBuffer (); 66 67 for (int i = 0; i < values.length; i++) { 68 Object val = values[i]; 69 buff.append(val == null ? "" : val.toString()); 70 if (i != values.length - 1) { 71 buff.append("\n"); 72 } 73 } 74 75 return buff.toString(); 76 } 77 78 protected void importString(JComponent c, String str) { 81 JList target = (JList)c; 82 DefaultListModel listModel = (DefaultListModel)target.getModel(); 83 int index = target.getSelectedIndex(); 84 85 107 addIndex = index; 108 String [] values = str.split("\n"); 109 if (values.length > 0) 110 { 111 System.out.println("Link source."+values[0]+" <-> destination."+ target.getSelectedValue()); 112 } 113 119 120 121 } 122 123 protected void cleanup(JComponent c, boolean remove) { 129 if (remove && indices != null) { 130 JList source = (JList)c; 131 DefaultListModel model = (DefaultListModel)source.getModel(); 132 147 } 148 149 indices = null; 150 addCount = 0; 151 addIndex = -1; 152 153 } 154 } 155 | Popular Tags |