@Override public void actionPerformed(ActionEvent arg0) { File selectedFile = DATA_MODEL.getFile(TABLE.getSelectedRow()); // can't create torrents out of empty folders. if (selectedFile.isDirectory() && selectedFile.listFiles().length == 0) { JOptionPane.showMessageDialog( null, I18n.tr("The folder you selected is empty."), I18n.tr("Invalid Folder"), JOptionPane.ERROR_MESSAGE); return; } // can't create torrents if the folder/file can't be read if (!selectedFile.canRead()) { JOptionPane.showMessageDialog( null, I18n.tr("Error: You can't read on that file/folder."), I18n.tr("Error"), JOptionPane.ERROR_MESSAGE); return; } CreateTorrentDialog dlg = new CreateTorrentDialog(GUIMediator.getAppFrame()); dlg.setChosenContent( selectedFile, selectedFile.isFile() ? JFileChooser.FILES_ONLY : JFileChooser.DIRECTORIES_ONLY); dlg.setVisible(true); }
public LaunchOSAction() { String os = "OS"; if (OSUtils.isWindows()) { os = "Windows"; } else if (OSUtils.isMacOSX()) { os = "Mac"; } else if (OSUtils.isLinux()) { os = "Linux"; } putValue(Action.NAME, I18n.tr("Launch in") + " " + os); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Launch Selected Files in") + " " + os); putValue(LimeAction.ICON_NAME, "LIBRARY_LAUNCH"); }
@Override public void actionPerformed(ActionEvent e) { final short videoCount = (short) TABLE.getSelectedRows().length; // can't happen, but just in case. if (videoCount < 1) { return; } // get selected files before we switch to audio and loose the selection final List<File> selectedFiles = getSelectedFiles(); selectAudio(); String status = I18n.tr("Extracting audio from " + videoCount + " selected videos..."); if (videoCount == 1) { status = I18n.tr("Extracting audio from selected video..."); } LibraryMediator.instance().getLibrarySearch().pushStatus(status); SwingWorker<Void, Void> demuxWorker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { isDemuxing = true; demuxFiles(selectedFiles); isDemuxing = false; return null; } @Override protected void done() { int failed = videoCount - demuxedFiles.size(); String failedStr = (failed > 0) ? " (" + failed + " " + I18n.tr("failed") + ")" : ""; LibraryMediator.instance() .getLibrarySearch() .pushStatus(I18n.tr("Done extracting audio.") + failedStr); } }; demuxWorker.execute(); }
private JMenu createSearchSubMenu(LibraryFilesTableDataLine dl) { SkinMenu menu = new SkinMenu(I18n.tr("Search")); if (dl != null) { File f = dl.getInitializeObject(); String keywords = QueryUtils.createQueryString(f.getName()); if (keywords.length() > 0) menu.add(new SkinMenuItem(new SearchAction(keywords))); } if (menu.getItemCount() == 0) menu.setEnabled(false); return menu; }
/** * Returns the options offered to the user when removing files. * * <p>Depending on the platform these can be a subset of MOVE_TO_TRASH, DELETE, CANCEL. */ private static Object[] createRemoveOptions() { if (OSUtils.supportsTrash()) { String trashLabel = OSUtils.isWindows() ? I18n.tr("Move to Recycle Bin") : I18n.tr("Move to Trash"); return new Object[] {trashLabel, I18n.tr("Delete"), I18n.tr("Cancel")}; } else { return new Object[] {I18n.tr("Delete"), I18n.tr("Cancel")}; } }
protected void drawGuiContainerForegroundLayer(int par1, int par2) { GL11.glDisable(GL11.GL_LIGHTING); int xSize = this.xSize; int ySize = this.ySize; if (!inverted) { fontRendererObj.drawString( blockName, xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1, 5, 4210752); fontRendererObj.drawString(I18n.format("container.inventory"), 6, ySize - 96 + 2, 4210752); Color darkGreen = new Color(75, 245, 75); String string1 = I18n.format("uncrafting.compute") + ":"; fontRendererObj.drawString( EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET, 24 - fontRendererObj.getStringWidth(string1) / 2 + 1, 22, 0); fontRendererObj.drawString( EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET, 24 - fontRendererObj.getStringWidth(string1) / 2, 21, 0); fontRendererObj.drawString( EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.UNDERLINE + "" + (ModUncrafting.standardLevel + container.xp) + " levels" + EnumChatFormatting.RESET, xSize / 2 - fontRendererObj.getStringWidth( (ModUncrafting.standardLevel + container.xp) + " levels") / 2 + 1, ySize - 126 - 10, 0); fontRendererObj.drawString( EnumChatFormatting.UNDERLINE + "" + (ModUncrafting.standardLevel + container.xp) + " levels" + EnumChatFormatting.RESET, xSize / 2 - fontRendererObj.getStringWidth( (ModUncrafting.standardLevel + container.xp) + " levels") / 2, ySize - 127 - 10, darkGreen.getRGB()); String string = container.result; if (string != null) { State msgType = container.type; EnumChatFormatting format = EnumChatFormatting.GREEN; EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY; if (msgType == ContainerUncraftingTable.State.ERROR) { format = EnumChatFormatting.WHITE; shadowFormat = EnumChatFormatting.DARK_RED; } fontRendererObj.drawString( shadowFormat + string + EnumChatFormatting.RESET, 6 + 1, ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT, 0); fontRendererObj.drawString( format + string + EnumChatFormatting.RESET, 6, ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT, 0); } } else { int height = 166 - 8; fontRendererObj.drawString( blockName, xSize / 2 - fontRendererObj.getStringWidth(blockName) / 2 + 1, height - 5, 4210752); fontRendererObj.drawString( I18n.format("container.inventory"), 6, height - ySize - 96 + 2, 4210752); Color darkGreen = new Color(75, 245, 75); String string1 = "Calculs:"; fontRendererObj.drawString( EnumChatFormatting.DARK_GRAY + string1 + EnumChatFormatting.RESET, 24 - fontRendererObj.getStringWidth(string1) / 2 + 1, height - 22, 0); fontRendererObj.drawString( EnumChatFormatting.GRAY + string1 + EnumChatFormatting.RESET, 24 - fontRendererObj.getStringWidth(string1) / 2, height - 21, 0); fontRendererObj.drawString( EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.UNDERLINE + "" + (ModUncrafting.standardLevel + container.xp) + " levels" + EnumChatFormatting.RESET, xSize / 2 - fontRendererObj.getStringWidth( (ModUncrafting.standardLevel + container.xp) + " levels") / 2 + 1, height - (ySize - 126 - 10), 0); fontRendererObj.drawString( EnumChatFormatting.UNDERLINE + "" + (ModUncrafting.standardLevel + container.xp) + " levels" + EnumChatFormatting.RESET, xSize / 2 - fontRendererObj.getStringWidth( (ModUncrafting.standardLevel + container.xp) + " levels") / 2, height - (ySize - 127 - 10), darkGreen.getRGB()); String string = container.result; if (string != null) { State msgType = container.type; EnumChatFormatting format = EnumChatFormatting.GREEN; EnumChatFormatting shadowFormat = EnumChatFormatting.DARK_GRAY; if (msgType == ContainerUncraftingTable.State.ERROR) { format = EnumChatFormatting.WHITE; shadowFormat = EnumChatFormatting.DARK_RED; } fontRendererObj.drawString( shadowFormat + string + EnumChatFormatting.RESET, 6 + 1, height - (ySize - 95 + 2 - fontRendererObj.FONT_HEIGHT), 0); fontRendererObj.drawString( format + string + EnumChatFormatting.RESET, 6, height - (ySize - 96 + 2 - fontRendererObj.FONT_HEIGHT), 0); } } boolean op = false; // TODO: Check if user is OP String optionsText = I18n.format("uncrafting.options.hit"); if (op) fontRendererObj.drawString( EnumChatFormatting.UNDERLINE + optionsText, xSize - fontRendererObj.getStringWidth(optionsText) - 4, ySize - 96 + 2, 0); GL11.glEnable(GL11.GL_LIGHTING); }
public DemuxMP4AudioAction() { putValue(Action.NAME, I18n.tr("Extract Audio")); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Extract .m4a Audio from this .mp4 video")); demuxedFiles = new ArrayList<File>(); }
public SendAudioFilesToiTunes() { if (!OSUtils.isLinux()) { putValue(Action.NAME, I18n.tr("Send to iTunes")); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Send audio files to iTunes")); } }
public RemoveAction() { putValue(Action.NAME, I18n.tr("Delete")); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Delete Selected Files")); putValue(LimeAction.ICON_NAME, "LIBRARY_DELETE"); }
public CreateTorrentAction() { super(I18n.tr("Create New Torrent")); putValue(Action.LONG_DESCRIPTION, I18n.tr("Create a new .torrent file")); }
public OpenInFolderAction() { putValue(Action.NAME, I18n.tr("Explore")); putValue(LimeAction.SHORT_NAME, I18n.tr("Explore")); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Open Folder Containing the File")); putValue(LimeAction.ICON_NAME, "LIBRARY_EXPLORE"); }
public LaunchAction() { putValue(Action.NAME, I18n.tr("Launch")); putValue(Action.SHORT_DESCRIPTION, I18n.tr("Launch Selected Files")); putValue(LimeAction.ICON_NAME, "LIBRARY_LAUNCH"); }
/** * Override the default removal so we can actually stop sharing and delete the file. Deletes the * selected rows in the table. CAUTION: THIS WILL DELETE THE FILE FROM THE DISK. */ public void removeSelection() { int[] rows = TABLE.getSelectedRows(); if (rows.length == 0) return; if (TABLE.isEditing()) { TableCellEditor editor = TABLE.getCellEditor(); editor.cancelCellEditing(); } List<File> files = new ArrayList<File>(rows.length); // sort row indices and go backwards so list indices don't change when // removing the files from the model list Arrays.sort(rows); for (int i = rows.length - 1; i >= 0; i--) { File file = DATA_MODEL.getFile(rows[i]); files.add(file); } CheckBoxListPanel<File> listPanel = new CheckBoxListPanel<File>(files, new FileTextProvider(), true); listPanel.getList().setVisibleRowCount(4); // display list of files that should be deleted Object[] message = new Object[] { new MultiLineLabel( I18n.tr( "Are you sure you want to delete the selected file(s), thus removing it from your computer?"), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), listPanel, Box.createVerticalStrut(ButtonRow.BUTTON_SEP) }; // get platform dependent options which are displayed as buttons in the dialog Object[] removeOptions = createRemoveOptions(); int option = JOptionPane.showOptionDialog( MessageService.getParentComponent(), message, I18n.tr("Message"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, removeOptions, removeOptions[0] /* default option */); if (option == removeOptions.length - 1 /* "cancel" option index */ || option == JOptionPane.CLOSED_OPTION) { return; } // remove still selected files List<File> selected = listPanel.getSelectedElements(); List<String> undeletedFileNames = new ArrayList<String>(); boolean somethingWasRemoved = false; for (File file : selected) { // stop seeding if seeding BittorrentDownload dm = null; if ((dm = TorrentUtil.getDownloadManager(file)) != null) { dm.setDeleteDataWhenRemove(false); dm.setDeleteTorrentWhenRemove(false); BTDownloadMediator.instance().remove(dm); } // close media player if still playing if (MediaPlayer.instance().isThisBeingPlayed(file)) { MediaPlayer.instance().stop(); MPlayerMediator.instance().showPlayerWindow(false); } // removeOptions > 2 => OS offers trash options boolean removed = FileUtils.delete( file, removeOptions.length > 2 && option == 0 /* "move to trash" option index */); if (removed) { somethingWasRemoved = true; DATA_MODEL.remove(DATA_MODEL.getRow(file)); } else { undeletedFileNames.add(getCompleteFileName(file)); } } clearSelection(); if (somethingWasRemoved) { LibraryMediator.instance().getLibraryExplorer().refreshSelection(true); } if (undeletedFileNames.isEmpty()) { return; } // display list of files that could not be deleted message = new Object[] { new MultiLineLabel( I18n.tr( "The following files could not be deleted. They may be in use by another application or are currently being downloaded to."), 400), Box.createVerticalStrut(ButtonRow.BUTTON_SEP), new JScrollPane(createFileList(undeletedFileNames)) }; JOptionPane.showMessageDialog( MessageService.getParentComponent(), message, I18n.tr("Error"), JOptionPane.ERROR_MESSAGE); super.removeSelection(); }