Exemplo n.º 1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   for (LocalFileItem localFileItem : localFileItems) {
     friendFileList.removeFile(localFileItem.getFile());
   }
   GuiUtils.getMainFrame().repaint();
 }
  @Override
  public void removeFiles(Filter<LocalFileItem> filter) {
    List<LocalFileItem> files = new ArrayList<LocalFileItem>();

    getModel().getReadWriteLock().readLock().lock();
    try {
      for (LocalFileItem localFileItem : getModel()) {
        if (filter.allow(localFileItem)) {
          files.add(localFileItem);
        }
      }
    } finally {
      getModel().getReadWriteLock().readLock().unlock();
    }

    for (LocalFileItem localFileItem : files) {
      removeFile(localFileItem.getFile());
    }
  }
Exemplo n.º 3
0
    public FriendShareCheckBox(LocalFileList friendFileList, LocalFileItem localFileItem) {
      super(I18n.tr("Share"));
      this.friendFileList = friendFileList;
      this.localFile = localFileItem;
      setSelected(friendFileList.contains(localFileItem.getFile()));

      addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              if (isSelected()) {
                FriendShareCheckBox.this.friendFileList.addFile(localFile.getFile());
              } else {
                FriendShareCheckBox.this.friendFileList.removeFile(localFile.getFile());
              }
            }
          });
    }
Exemplo n.º 4
0
  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);
  }