@Override protected boolean popupDecision(MouseEvent e) { if (filesTable.getSelectedRowCount() == 0) return false; int[] indices = filesTable.getSelectedRows(); long size = 0; for (int i : indices) { size += fs.getEntryForRow(filesTable.convertRowIndexToModel(i)).getSize(); } info.setText(Util.niceSize(size) + " in " + indices.length + " items"); return true; }
@Override protected boolean popupDecision(MouseEvent e) { int count = browseTree.getSelectionCount(); if (count == 0) return false; boolean canRemoveSearches = false; long totalSize = 0; ListableEntry lastSelected = null; for (TreePath path : browseTree.getSelectionPaths()) { lastSelected = (ListableEntry) path.getLastPathComponent(); totalSize += lastSelected.getSize(); canRemoveSearches |= ((lastSelected instanceof FileSystemEntry) && ((FileSystemEntry) lastSelected).isSearch()); } removeSearch.setEnabled(canRemoveSearches); infoItem.setText( (count == 1 ? lastSelected.getName() : "Multiple items") + ": " + Util.niceSize(totalSize)); return true; }
public TablePopup(final MainFrame frame) { super(frame); info = new EPopup("info", null, null, "Basic information about the selection"); info.setEnabled(false); addSeparator(); new EPopup( "Download", new PopupAction() { @Override public void doAction(ActionEvent e) { downloadToDirectory(getSelectedTableEntries(), null, null); } }, frame.gui.util.getImage("download"), "Downloads all of the one selected item to the default download directory"); new EPopup( "Download to...", new PopupAction() { @Override public void doAction(ActionEvent e) { JFileChooser fc = new JFileChooser( new File(frame.gui.conf.getString(CK.LAST_CUSTOM_DOWNLOAD_DIRECTORY))); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { frame.gui.conf.putString( CK.LAST_CUSTOM_DOWNLOAD_DIRECTORY, fc.getSelectedFile().getPath()); downloadToDirectory(getSelectedTableEntries(), null, fc.getSelectedFile()); } } }, frame.gui.util.getImage("downloadto"), "Downloads all of the one selected item to a directory of your choice"); }
public TreePopup(final MainFrame frame) { super(frame); infoItem = new EPopup("size?", null, null, "Basic information about the selection"); infoItem.setEnabled(false); this.addSeparator(); removeSearch = new EPopup( "Remove selected searches", new PopupAction() { @Override public void doAction(ActionEvent e) { for (TreePath path : browseTree.getSelectionPaths()) { ListableEntry selected = (ListableEntry) path.getLastPathComponent(); if ((selected instanceof FileSystemEntry) && ((FileSystemEntry) selected).isSearch()) { fs.removeSearch((FileSystemEntry) selected); } } } }, frame.gui.util.getImage("removesearch"), "Removes this search, reducing load on the indexnodes"); this.addSeparator(); new EPopup( "Download", new PopupAction() { @Override public void doAction(ActionEvent e) { for (TreePath path : browseTree.getSelectionPaths()) { ListableEntry selected = (ListableEntry) path.getLastPathComponent(); downloadListableToDirectory(selected, null); } } }, frame.gui.util.getImage("download"), "Downloads all of the one selected item to the default download directory"); new EPopup( "Download to...", new PopupAction() { @Override public void doAction(ActionEvent e) { JFileChooser fc = new JFileChooser( new File(frame.gui.conf.getString(CK.LAST_CUSTOM_DOWNLOAD_DIRECTORY))); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { frame.gui.conf.putString( CK.LAST_CUSTOM_DOWNLOAD_DIRECTORY, fc.getSelectedFile().getPath()); for (TreePath path : browseTree.getSelectionPaths()) { ListableEntry selected = (ListableEntry) path.getLastPathComponent(); downloadListableToDirectory(selected, fc.getSelectedFile()); } } } }, frame.gui.util.getImage("downloadto"), "Downloads all of the one selected item to a directory of your choice"); }