@@ -281,6 +281,8 @@ public void actionPerformed (ActionEvent e)
281281
282282 repoTable .setTransferHandler (new TransferHandler ()
283283 {
284+ String repoReorder = "N2A repo reorder:" ;
285+
284286 public boolean canImport (TransferSupport xfer )
285287 {
286288 return xfer .isDataFlavorSupported (DataFlavor .stringFlavor );
@@ -299,44 +301,45 @@ public boolean importData (TransferSupport xfer)
299301 return false ;
300302 }
301303
302- // Paste, or drop type other than MOVE --> Could be a Git remote URI
303- if (! xfer . isDrop () || xfer . getDropAction () != MOVE )
304+ // Could be reordering of repository precedence
305+ if (value . startsWith ( repoReorder ) )
304306 {
305- // Must have the form of a Git URI
307+ value = value .substring (repoReorder .length ());
308+ int sourceRow = -1 ;
306309 try
307310 {
308- new URIish (value );
311+ sourceRow = Integer . valueOf (value );
309312 }
310- catch (URISyntaxException e )
313+ catch (Exception e )
311314 {
312315 return false ;
313316 }
314-
315- // Must not already exist in list
316- for (GitWrapper w : repoModel .gitRepos ) if (value .equals (w .getURL ())) return false ;
317-
318- // Clone new repo
319- int row ;
320- if (xfer .isDrop ()) row = ((JTable .DropLocation ) xfer .getDropLocation ()).getRow ();
321- else row = repoTable .getSelectedRow ();
322- if (row < 0 ) row = repoModel .getRowCount ();
323- repoModel .create (row , value );
317+ if (sourceRow < 0 || sourceRow >= repoModel .repos .size ()) return false ;
318+ int destinationRow = ((JTable .DropLocation ) xfer .getDropLocation ()).getRow ();
319+ repoModel .move (sourceRow , destinationRow );
324320 return true ;
325321 }
326322
327- // Drop of type MOVE --> Reordering of repository precedence
328- int sourceRow = -1 ;
323+ // Could be a Git remote URI
329324 try
330325 {
331- sourceRow = Integer .valueOf (value );
326+ // Must have the form of a Git URI
327+ new URIish (value );
332328 }
333- catch (Exception e )
329+ catch (URISyntaxException e )
334330 {
335331 return false ;
336332 }
337- if (sourceRow < 0 || sourceRow >= repoModel .repos .size ()) return false ;
338- int destinationRow = ((JTable .DropLocation ) xfer .getDropLocation ()).getRow ();
339- repoModel .move (sourceRow , destinationRow );
333+
334+ // Must not already exist in list
335+ for (GitWrapper w : repoModel .gitRepos ) if (value .equals (w .getURL ())) return false ;
336+
337+ // Clone new repo
338+ int row ;
339+ if (xfer .isDrop ()) row = ((JTable .DropLocation ) xfer .getDropLocation ()).getRow ();
340+ else row = repoTable .getSelectedRow ();
341+ if (row < 0 ) row = repoModel .getRowCount ();
342+ repoModel .create (row , value );
340343 return true ;
341344 }
342345
@@ -347,7 +350,7 @@ public int getSourceActions (JComponent comp)
347350
348351 protected Transferable createTransferable (JComponent comp )
349352 {
350- return new StringSelection (String .valueOf (repoTable .getSelectedRow ()));
353+ return new StringSelection (repoReorder + String .valueOf (repoTable .getSelectedRow ()));
351354 }
352355 });
353356
0 commit comments