Search in sources :

Example 1 with NameHolder

use of com.limegroup.gnutella.gui.tables.NameHolder in project frostwire by frostwire.

the class LibraryPlaylistsTableDataLine method initialize.

/**
 * Sets up the DataLine for use with the playlist.
 */
public void initialize(PlaylistItem item) {
    super.initialize(item);
    sizeHolder = new SizeHolder(item.getFileSize());
    exists = new File(item.getFilePath()).exists();
    bitrate = initializer.getTrackBitrate();
    if (bitrate != null && bitrate.length() > 0 && !bitrate.endsWith(" kbps")) {
        bitrate = bitrate + " kbps";
    }
    this.nameCell = new NameHolder(initializer.getTrackTitle());
    this.actionsHolder = new LibraryActionsHolder(this, false);
}
Also used : NameHolder(com.limegroup.gnutella.gui.tables.NameHolder) SizeHolder(com.limegroup.gnutella.gui.tables.SizeHolder) File(java.io.File)

Example 2 with NameHolder

use of com.limegroup.gnutella.gui.tables.NameHolder in project frostwire by frostwire.

the class LibraryFilesTableDataLine method initialize.

/**
 * Initialize the object.
 * It will fail if not given a FileDesc or a File
 * (File is retained for compatibility with the Incomplete folder)
 */
public void initialize(File file) {
    super.initialize(file);
    String fullPath = file.getPath();
    try {
        fullPath = file.getCanonicalPath();
    } catch (IOException ignored) {
    }
    String _name = initializer.getName();
    _type = "";
    if (!file.isDirectory()) {
        // _isDirectory = false;
        int index = _name.lastIndexOf(".");
        int index2 = fullPath.lastIndexOf(File.separator);
        _path = fullPath.substring(0, index2);
        if (index != -1 && index != 0) {
            _type = _name.substring(index + 1);
            _name = _name.substring(0, index);
        }
    } else {
        _path = fullPath;
    // _isDirectory = true;
    }
    // directories implicitly set SizeHolder to null and display nothing
    if (initializer.isFile()) {
        long _size = initializer.length();
        _sizeHolder = new SizeHolder(_size);
    } else {
        _sizeHolder = ZERO_SIZED_HOLDER;
    }
    this.lastModified = new Date(initializer.lastModified());
    this.actionsHolder = new LibraryActionsHolder(this, false);
    this.nameCell = new NameHolder(_name);
    if (initializer != null && initializer.isFile() && FilenameUtils.getExtension(initializer.getName()) != null && FilenameUtils.getExtension(initializer.getName()).toLowerCase().endsWith("torrent")) {
        BTInfoAdditionalMetadataHolder additionalMetadataHolder = null;
        try {
            additionalMetadataHolder = new BTInfoAdditionalMetadataHolder(initializer, initializer.getName());
        } catch (Throwable t) {
            System.err.println("[InvalidTorrent] Can't create BTInfoAdditionalMetadataholder out of " + initializer.getAbsolutePath());
            t.printStackTrace();
        }
        boolean hasLicense = additionalMetadataHolder != null && additionalMetadataHolder.getLicenseBroker() != null;
        boolean hasPaymentOptions = additionalMetadataHolder != null && additionalMetadataHolder.getPaymentOptions() != null;
        if (hasLicense) {
            license = additionalMetadataHolder.getLicenseBroker().getLicenseName();
        }
        if (license == null) {
            license = "";
        }
        if (hasPaymentOptions) {
            paymentOptions = additionalMetadataHolder.getPaymentOptions();
        } else {
            paymentOptions = new PaymentOptions(null, null);
        }
        paymentOptions.setItemName(_name);
    }
}
Also used : NameHolder(com.limegroup.gnutella.gui.tables.NameHolder) BTInfoAdditionalMetadataHolder(com.frostwire.bittorrent.BTInfoAdditionalMetadataHolder) IOException(java.io.IOException) SizeHolder(com.limegroup.gnutella.gui.tables.SizeHolder) PaymentOptions(com.frostwire.bittorrent.PaymentOptions) Date(java.util.Date)

Aggregations

NameHolder (com.limegroup.gnutella.gui.tables.NameHolder)2 SizeHolder (com.limegroup.gnutella.gui.tables.SizeHolder)2 BTInfoAdditionalMetadataHolder (com.frostwire.bittorrent.BTInfoAdditionalMetadataHolder)1 PaymentOptions (com.frostwire.bittorrent.PaymentOptions)1 File (java.io.File)1 IOException (java.io.IOException)1 Date (java.util.Date)1