| | |
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.swing.table.AbstractTableModel;
|
| | |
|
| | | import com.gitblit.models.RepositoryModel;
|
| | |
|
| | | /**
|
| | | * Table model of a list of repositories.
|
| | | * |
| | | * @author James Moger
|
| | | * |
| | | */
|
| | | public class RepositoriesModel extends AbstractTableModel {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | Map<String, RepositoryModel> repositories;
|
| | |
|
| | | List<RepositoryModel> list;
|
| | |
|
| | | enum Columns {
|
| | | Name, Description, Owner, Last_Change, Size;
|
| | | Name, Description, Owner, Indicators, Last_Change, Size;
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public RepositoriesModel(Map<String, RepositoryModel> repositories) {
|
| | | this.repositories = repositories;
|
| | | list = new ArrayList<RepositoryModel>(repositories.values());
|
| | | Collections.sort(list);
|
| | | public RepositoriesModel() {
|
| | | this(new ArrayList<RepositoryModel>());
|
| | | }
|
| | |
|
| | | public RepositoriesModel(List<RepositoryModel> repositories) {
|
| | | this.list = repositories;
|
| | | Collections.sort(this.list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int getRowCount() {
|
| | | return repositories.size();
|
| | | return list.size();
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | @Override
|
| | | public String getColumnName(int column) {
|
| | | Columns col = Columns.values()[column];
|
| | | return col.toString();
|
| | | switch (col) {
|
| | | case Name:
|
| | | return Translation.get("gb.name");
|
| | | case Description:
|
| | | return Translation.get("gb.description");
|
| | | case Owner:
|
| | | return Translation.get("gb.owner");
|
| | | case Last_Change:
|
| | | return Translation.get("gb.lastChange");
|
| | | case Size:
|
| | | return Translation.get("gb.size");
|
| | | }
|
| | | return "";
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | public Class<?> getColumnClass(int columnIndex) {
|
| | | Columns col = Columns.values()[columnIndex];
|
| | | switch (col) {
|
| | | case Name:
|
| | | case Indicators:
|
| | | return RepositoryModel.class;
|
| | | case Last_Change:
|
| | | return Date.class;
|
| | | }
|
| | |
| | | Columns col = Columns.values()[columnIndex];
|
| | | switch (col) {
|
| | | case Name:
|
| | | return model.name;
|
| | | return model;
|
| | | case Description:
|
| | | return model.description;
|
| | | case Owner:
|
| | | return model.owner;
|
| | | case Indicators:
|
| | | return model;
|
| | | case Last_Change:
|
| | | return model.lastChange;
|
| | | case Size:
|