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 ListPhaseTableDescriptor extends AbstractTableDescriptor {
24  
25      private static final int SEPARATOR_SIZE = ROW_START.length() + 2 * SEPARATOR.length();
26  
27      private int pluginSize;
28      private int executionIdSize;
29      private int goalSize;
30  
31      public static ListPhaseTableDescriptor of(
32              Collection<MojoExecution> executions, DefaultLifecycles defaultLifecycles) {
33  
34          Map<TableColumn, Integer> maxSize = findMaxSize(
35                  executions, defaultLifecycles, TableColumn.ARTIFACT_ID, TableColumn.EXECUTION_ID, TableColumn.GOAL);
36  
37          return new ListPhaseTableDescriptor()
38                  .setPluginSize(maxSize.get(TableColumn.ARTIFACT_ID))
39                  .setGoalSize(maxSize.get(TableColumn.GOAL))
40                  .setExecutionIdSize(maxSize.get(TableColumn.EXECUTION_ID));
41      }
42  
43      public String rowFormat() {
44          return new StringBuilder()
45                  .append(ROW_START)
46                  .append(FORMAT_LEFT_ALIGN)
47                  .append(getPluginSize())
48                  .append(FORMAT_STRING)
49                  .append(SEPARATOR)
50                  .append(FORMAT_LEFT_ALIGN)
51                  .append(getGoalSize())
52                  .append(FORMAT_STRING)
53                  .append(SEPARATOR)
54                  .append(FORMAT_LEFT_ALIGN)
55                  .append(getExecutionIdSize())
56                  .append(FORMAT_STRING)
57                  .toString();
58      }
59  
60      public int width() {
61          return getExecutionIdSize() + getGoalSize() + getPluginSize() + SEPARATOR_SIZE;
62      }
63  
64      public int getPluginSize() {
65          return pluginSize;
66      }
67  
68      public int getExecutionIdSize() {
69          return executionIdSize;
70      }
71  
72      public int getGoalSize() {
73          return goalSize;
74      }
75  
76      public ListPhaseTableDescriptor setPluginSize(int pluginSize) {
77          this.pluginSize = pluginSize;
78          return this;
79      }
80  
81      public ListPhaseTableDescriptor setExecutionIdSize(int executionIdSize) {
82          this.executionIdSize = executionIdSize;
83          return this;
84      }
85  
86      public ListPhaseTableDescriptor setGoalSize(int goalSize) {
87          this.goalSize = goalSize;
88          return this;
89      }
90  }