Package com.jetbrains.heroku.ui

Source Code of com.jetbrains.heroku.ui.CollaboratorTableModel

package com.jetbrains.heroku.ui;

import com.heroku.api.Collaborator;

import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.List;

/**
* @author mh
* @since 26.12.11
*/
public class CollaboratorTableModel extends AbstractTableModel {
    private final List<Collaborator> collaborators;

    public CollaboratorTableModel(List<Collaborator> collaborators) {
        this.collaborators = new ArrayList<Collaborator>(collaborators);
    }

    @Override
    public int getRowCount() {
        return collaborators.size();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    @Override
    public Object getValueAt(int row, int column) {
        final Collaborator collaborator = getCollaborator(row);
        return column == 0 ? collaborator.getEmail() : collaborator.getAccess();
    }

    public Collaborator getCollaborator(int row) {
        if (row == -1) return null;
        return collaborators.get(row);
    }

    @Override
    public String getColumnName(int column) {
        return column == 0 ? "Email" : "Access";
    }

    public void update(List<Collaborator> data) {
        this.collaborators.clear();
        this.collaborators.addAll(data);
        fireTableDataChanged();
    }
}
TOP

Related Classes of com.jetbrains.heroku.ui.CollaboratorTableModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.