1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codehaus.mojo.buildplan.display;
17
18 import java.util.Collection;
19 import java.util.Map;
20 import org.apache.maven.lifecycle.DefaultLifecycles;
21 import org.apache.maven.plugin.MojoExecution;
22
23 public class ListPluginTableDescriptor extends AbstractTableDescriptor {
24
25 private static final int SEPARATOR_SIZE = ROW_START.length() + 2 * SEPARATOR.length();
26
27 private int phaseSize;
28 private int executionIdSize;
29 private int goalSize;
30
31 public String rowFormat() {
32 StringBuilder builder = new StringBuilder();
33 builder.append(ROW_START)
34 .append(FORMAT_LEFT_ALIGN)
35 .append(getPhaseSize())
36 .append(FORMAT_STRING)
37 .append(SEPARATOR)
38 .append(FORMAT_LEFT_ALIGN)
39 .append(getGoalSize())
40 .append(FORMAT_STRING)
41 .append(SEPARATOR)
42 .append(FORMAT_LEFT_ALIGN)
43 .append(getExecutionIdSize())
44 .append(FORMAT_STRING);
45 return builder.toString();
46 }
47
48 public int width() {
49 return getExecutionIdSize() + getGoalSize() + getPhaseSize() + SEPARATOR_SIZE;
50 }
51
52 public int getPhaseSize() {
53 return phaseSize;
54 }
55
56 public int getExecutionIdSize() {
57 return executionIdSize;
58 }
59
60 public int getGoalSize() {
61 return goalSize;
62 }
63
64 public ListPluginTableDescriptor setPhaseSize(int phaseSize) {
65 this.phaseSize = phaseSize;
66 return this;
67 }
68
69 public ListPluginTableDescriptor setExecutionIdSize(int executionIdSize) {
70 this.executionIdSize = executionIdSize;
71 return this;
72 }
73
74 public ListPluginTableDescriptor setGoalSize(int goalSize) {
75 this.goalSize = goalSize;
76 return this;
77 }
78
79 public static ListPluginTableDescriptor of(
80 Collection<MojoExecution> executions, DefaultLifecycles defaultLifecycles) {
81
82 Map<TableColumn, Integer> maxSize = findMaxSize(
83 executions, defaultLifecycles, TableColumn.PHASE, TableColumn.EXECUTION_ID, TableColumn.GOAL);
84
85 return new ListPluginTableDescriptor()
86 .setPhaseSize(maxSize.get(TableColumn.PHASE))
87 .setGoalSize(maxSize.get(TableColumn.GOAL))
88 .setExecutionIdSize(maxSize.get(TableColumn.EXECUTION_ID));
89 }
90 }