(JComponent c, Transferable t)
| 112 | return false; |
| 113 | } |
| 114 | @Override |
| 115 | public boolean importData(JComponent c, Transferable t) { |
| 116 | if (!canImport(c, t.getTransferDataFlavors())) { |
| 117 | return false; |
| 118 | } |
| 119 | try { |
| 120 | source = (String)t.getTransferData(DataFlavor.stringFlavor); |
| 121 | if (source.startsWith("ResourcesTree")) { |
| 122 | int insertion = docTable.getSelectedRow(); |
| 123 | List<Document> documents = new ArrayList<Document>(); |
| 124 | source = source.replaceFirst("^ResourcesTree\\[", ""); |
| 125 | source = source.replaceFirst("\\]$", ""); |
| 126 | final String documentsNames[] = source.split(", "); |
| 127 | List<Resource> loadedDocuments; |
| 128 | try { |
| 129 | loadedDocuments = |
| 130 | Gate.getCreoleRegister().getAllInstances("gate.Document"); |
| 131 | } catch(GateException e) { |
| 132 | e.printStackTrace(); |
| 133 | return false; |
| 134 | } |
| 135 | // get the list of documents selected when dragging started |
| 136 | for(String documentName : documentsNames) { |
| 137 | for (Resource loadedDocument : loadedDocuments) { |
| 138 | if (loadedDocument.getName().equals(documentName) |
| 139 | && !corpus.contains(loadedDocument)) { |
| 140 | documents.add((Document) loadedDocument); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | // add the documents at the insertion point |
| 145 | for (Document document : documents) { |
| 146 | if (insertion != -1) { |
| 147 | corpus.add(docTable.rowViewToModel(insertion), document); |
| 148 | if (insertion == docTable.getRowCount()) { insertion++; } |
| 149 | } else { |
| 150 | corpus.add(document); |
| 151 | } |
| 152 | } |
| 153 | // select the moved/already existing documents |
| 154 | SwingUtilities.invokeLater(new Runnable() { |
| 155 | @Override |
| 156 | public void run() { |
| 157 | docTable.clearSelection(); |
| 158 | for (String documentName : documentsNames) { |
| 159 | for (int row = 0; row < docTable.getRowCount(); row++) { |
| 160 | if (docTable.getValueAt( |
| 161 | row, docTable.convertColumnIndexToView(1)) |
| 162 | .equals(documentName)) { |
| 163 | docTable.addRowSelectionInterval(row, row); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | }); |
| 169 | changeMessage(); |
| 170 | return true; |
| 171 |
nothing calls this directly
no test coverage detected