(boolean replacing)
| 616 | } |
| 617 | |
| 618 | boolean delete(boolean replacing) { |
| 619 | int count = getCount(); |
| 620 | if (count==0) |
| 621 | return error("The ROI Manager is empty."); |
| 622 | int index[] = getSelectedIndexes(); |
| 623 | if (index.length==0 || (replacing&&count>1)) { |
| 624 | String msg = "Delete all items on the list?"; |
| 625 | if (replacing) |
| 626 | msg = "Replace items on the list?"; |
| 627 | canceled = false; |
| 628 | if (!IJ.isMacro() && !macro) { |
| 629 | YesNoCancelDialog d = new YesNoCancelDialog(this, "ROI Manager", msg); |
| 630 | if (d.cancelPressed()) |
| 631 | {canceled = true; return false;} |
| 632 | if (!d.yesPressed()) return false; |
| 633 | } |
| 634 | index = getAllIndexes(); |
| 635 | } |
| 636 | if (count==index.length && !replacing) { |
| 637 | rois.clear(); |
| 638 | listModel.removeAllElements(); |
| 639 | } else { |
| 640 | for (int i=count-1; i>=0; i--) { |
| 641 | boolean delete = false; |
| 642 | for (int j=0; j<index.length; j++) { |
| 643 | if (index[j]==i) |
| 644 | delete = true; |
| 645 | } |
| 646 | if (delete) { |
| 647 | if (EventQueue.isDispatchThread()) { |
| 648 | rois.remove(i); |
| 649 | listModel.remove(i); |
| 650 | } else |
| 651 | deleteOnEDT(i); |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | updateShowAll(); |
| 656 | if (record()) |
| 657 | Recorder.record("roiManager", "Delete"); |
| 658 | return true; |
| 659 | } |
| 660 | |
| 661 | /** Deletes the ROI at 'index' and updates the display. */ |
| 662 | public void delete(int index) { |
no test coverage detected