All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cz.abclinuxu.datoveschranky.AttachmentTableModel Maven / Gradle / Ivy

The newest version!
package cz.abclinuxu.datoveschranky;

import cz.abclinuxu.datoveschranky.common.entities.Attachment;
import java.util.Collections;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class AttachmentTableModel extends AbstractTableModel {

    private final List attachments;

    public AttachmentTableModel() {
        this.attachments = Collections.emptyList();
    }

    public AttachmentTableModel(List atts) {
        this.attachments = atts;
    }

    public int getColumnCount() {
        return 2;
    }

    public int getRowCount() {
        return attachments.size();
    }

    @Override
    public String getColumnName(int col) {
        switch (col) {
            case 0:
                return "MIME typ";
            case 1:
                return "jméno";
            default:
                throw new AssertionError("table has only two columns");
        }
    }

    public Object getValueAt(int row, int col) {
        Attachment attachment = attachments.get(row);
        switch (col) {
            case 0:
                return attachment.getMimeType();
            case 1:
                return attachment.getDescription();
            default:
                throw new AssertionError("table has only two columns");
        }
    }

    public List getData() {
        return attachments;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy