private void properties() { int[] selected = overlayService.getOverlayInfo().selectedIndices(); if (selected.length == 0) { JOptionPane.showMessageDialog(this, "This command requires one or more selections"); return; } // else one or more selections exist runPropertiesPlugin(); }
private void rename() { final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices(); if (selectedIndices.length < 1) { JOptionPane.showMessageDialog(this, "Must select an overlay to rename"); return; } if (selectedIndices.length > 1) { JOptionPane.showMessageDialog(this, "Cannot rename multiple overlays simultaneously"); return; } final OverlayInfo info = overlayService.getOverlayInfo().getOverlayInfo(selectedIndices[0]); if (info == null) return; // TODO - UI agnostic way here final String name = JOptionPane.showInputDialog(this, "Enter new name for overlay"); if ((name == null) || (name.length() == 0)) info.getOverlay().setName(null); else info.getOverlay().setName(name); jlist.updateUI(); }
private void sort() { overlayService.getOverlayInfo().sort(); int[] newSelections = overlayService.getOverlayInfo().selectedIndices(); jlist.setSelectedIndices(newSelections); jlist.updateUI(); }
private void delete() { if (overlayService.getOverlayInfo().getOverlayInfoCount() == 0) return; List<Overlay> overlaysToDelete = new LinkedList<>(); final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices(); if (selectedIndices.length == 0) { final int result = JOptionPane.showConfirmDialog( this, "Delete all overlays?", "Delete All", JOptionPane.YES_NO_OPTION); if (result != JOptionPane.YES_OPTION) return; for (int i = 0; i < overlayService.getOverlayInfo().getOverlayInfoCount(); i++) { overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(i).getOverlay()); } } else { for (int i = 0; i < selectedIndices.length; i++) { int index = selectedIndices[i]; overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(index).getOverlay()); } } for (Overlay overlay : overlaysToDelete) { // NB - removeOverlay() can indirectly change our infoList contents. // Thus we first collect overlays from the infoList and then delete // them all afterwards to avoid interactions. overlayService.removeOverlay(overlay); } }
@EventHandler protected void onEvent(final OverlayDeletedEvent event) { //System.out.println("\tDELETED: " + event.toString()); Overlay overlay = event.getObject(); overlayService.getOverlayInfo().deleteOverlay(overlay); int[] newSelectedIndices = overlayService.getOverlayInfo().selectedIndices(); jlist.setSelectedIndices(newSelectedIndices); jlist.updateUI(); }
int[] selections = overlayService.getOverlayInfo().selectedIndices(); jlist.setSelectedIndices(selections); selecting = false;