| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
package net.sf.statcvs.reports; |
| 24 | |
|
| 25 | |
import java.util.Iterator; |
| 26 | |
|
| 27 | |
import net.sf.statcvs.Messages; |
| 28 | |
import net.sf.statcvs.model.Directory; |
| 29 | |
import net.sf.statcvs.model.Repository; |
| 30 | |
import net.sf.statcvs.model.Revision; |
| 31 | |
import net.sf.statcvs.reportmodel.DirectoryColumn; |
| 32 | |
import net.sf.statcvs.reportmodel.IntegerColumn; |
| 33 | |
import net.sf.statcvs.reportmodel.Table; |
| 34 | |
import net.sf.statcvs.util.IntegerMap; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
public class DirectoriesTableReport implements TableReport { |
| 44 | |
private final Repository content; |
| 45 | 0 | private Table table = null; |
| 46 | 0 | private final IntegerMap changesMap = new IntegerMap(); |
| 47 | 0 | private final IntegerMap linesMap = new IntegerMap(); |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | 0 | public DirectoriesTableReport(final Repository content) { |
| 55 | 0 | this.content = content; |
| 56 | 0 | } |
| 57 | |
|
| 58 | |
public void calculate() { |
| 59 | 0 | Iterator it = this.content.getRevisions().iterator(); |
| 60 | 0 | while (it.hasNext()) { |
| 61 | 0 | final Revision rev = (Revision) it.next(); |
| 62 | 0 | final Directory dir = rev.getFile().getDirectory(); |
| 63 | 0 | changesMap.addInt(dir, 1); |
| 64 | 0 | if (rev.isBeginOfLog()) { |
| 65 | 0 | linesMap.addInt(dir, rev.getLines()); |
| 66 | |
} else { |
| 67 | 0 | linesMap.addInt(dir, rev.getLinesDelta()); |
| 68 | |
} |
| 69 | 0 | } |
| 70 | 0 | this.table = new Table(Messages.getString("DIRECTORIES_TABLE_SUMMARY")); |
| 71 | 0 | final IntegerColumn changes = new IntegerColumn(Messages.getString("COLUMN_CHANGES")); |
| 72 | 0 | final IntegerColumn linesOfCode = new IntegerColumn(Messages.getString("COLUMN_LOC")); |
| 73 | 0 | final DirectoryColumn keys = new DirectoryColumn(); |
| 74 | 0 | keys.setTotal(Messages.getString("TOTALS")); |
| 75 | 0 | changes.setShowPercentages(true); |
| 76 | 0 | linesOfCode.setShowPercentages(true); |
| 77 | 0 | this.table.addColumn(keys); |
| 78 | 0 | this.table.addColumn(changes); |
| 79 | 0 | this.table.addColumn(linesOfCode); |
| 80 | 0 | this.table.setKeysInFirstColumn(true); |
| 81 | |
|
| 82 | 0 | it = linesMap.iteratorSortedByValueReverse(); |
| 83 | 0 | while (it.hasNext()) { |
| 84 | 0 | final Object key = it.next(); |
| 85 | 0 | keys.addValue(key); |
| 86 | 0 | changes.addValue(changesMap.get(key)); |
| 87 | 0 | linesOfCode.addValue(linesMap.get(key)); |
| 88 | 0 | } |
| 89 | 0 | if (this.table.getRowCount() > 1) { |
| 90 | 0 | this.table.setShowTotals(true); |
| 91 | |
} |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
public Table getTable() { |
| 95 | 0 | return table; |
| 96 | |
} |
| 97 | |
} |