@Override public void actionPerformed(ActionEvent e) { for (LocalFileItem localFileItem : localFileItems) { if (localFileItem.isShareable()) { friendFileList.addFile(localFileItem.getFile()); } } GuiUtils.getMainFrame().repaint(); }
private void initialize() { boolean singleFile = fileItems.size() == 1; boolean multiFile = fileItems.size() > 1; LocalFileItem firstItem = fileItems.get(0); boolean playActionEnabled = singleFile; boolean launchActionEnabled = singleFile; boolean locateActionEnabled = singleFile && !firstItem.isIncomplete(); boolean viewFileInfoEnabled = singleFile; boolean shareActionEnabled = false; boolean removeActionEnabled = false; boolean deleteActionEnabled = false; for (LocalFileItem localFileItem : fileItems) { if (localFileItem.isShareable()) { shareActionEnabled = true; break; } } for (LocalFileItem localFileItem : fileItems) { if (!localFileItem.isIncomplete()) { removeActionEnabled = true; deleteActionEnabled = true; break; } } removeAll(); switch (category) { case AUDIO: case VIDEO: add(new PlayAction(libraryNavigator, new Catalog(category), firstItem)) .setEnabled(playActionEnabled); break; case IMAGE: case DOCUMENT: add(new LaunchFileAction(I18n.tr("View"), firstItem)).setEnabled(launchActionEnabled); break; case PROGRAM: case OTHER: add(new LocateFileAction(firstItem)).setEnabled(locateActionEnabled); } if (multiFile) { add(new FriendShareAction(friendFileList, createFileItemArray())) .setEnabled(shareActionEnabled); add(new FriendUnshareAction(friendFileList, createFileItemArray())) .setEnabled(shareActionEnabled); } else { add(new FriendShareCheckBox(friendFileList, firstItem)).setEnabled(shareActionEnabled); } addSeparator(); if (category != Category.PROGRAM && category != Category.OTHER) { add(new LocateFileAction(firstItem)).setEnabled(locateActionEnabled); } add(new RemoveAction(createFileItemArray(), libraryManager)).setEnabled(removeActionEnabled); add(new DeleteAction(createFileItemArray(), libraryManager)).setEnabled(deleteActionEnabled); addSeparator(); add(new ViewFileInfoAction(firstItem, propertiesFactory)).setEnabled(viewFileInfoEnabled); }