KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > changelog > LogPrinter_Output


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Ralph Krueger.
17  */

18
19 package org.netbeans.modules.changelog;
20
21
22 import java.util.*;
23 import org.openide.windows.*;
24 import org.openide.*;
25
26 /**
27  * prints the processed groups to output window..
28  * @author ralph
29  */

30 public class LogPrinter_Output implements LogPrinter {
31
32     private OutputWriter writer;
33     private boolean includeSummary;
34
35     public LogPrinter_Output() {
36          writer = TopManager.getDefault().getStdOut();
37     }
38
39     public void printHeader(ChangeLogProcessor processor) {
40         includeSummary = processor.isIncludeSummary();
41         if (processor.isIncludeQueryDescription()) {
42             writer.println("Query:");
43             if (processor.getDateRange() != null) {
44                 writer.println(" Date Range:" + processor.getDateRange());
45             }
46             if (processor.getRevisionRange() != null) {
47                 writer.println(" Revision Filter:" + processor.getRevisionRange());
48             }
49             if (processor.getMessageFilter() != null) {
50                 String JavaDoc messageType = "";
51                 if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_SUBSTRING) {
52                     messageType = "Substring";
53                 } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_SOME_WORDS) {
54                     messageType = "Any of words";
55                 } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_ALL_WORDS) {
56                     messageType = "All of words";
57                 } else if (processor.getMessageFilterType() == ChangeLogProcessor.MESSAGE_FILTER_REGEXP) {
58                     messageType = "Regular expression";
59                 }
60                 writer.println(" Message Filter (" + messageType + "):" + processor.getMessageFilter());
61             }
62             if (processor.getFileFilter() != null) {
63                 String JavaDoc fileType = "";
64                 if (processor.getFileFilterType() == ChangeLogProcessor.FILE_FILTER_SUBSTRING) {
65                     fileType = "Substring";
66                 } else if (processor.getFileFilterType() == ChangeLogProcessor.FILE_FILTER_REGEXP) {
67                     fileType = "Regular expression";
68                 }
69                 writer.println(" Contained Files Filter (" + fileType + "):" + processor.getFileFilter());
70             }
71             if (processor.getSortMode() == ChangeLogProcessor.SORT_BY_DATE) {
72                 writer.print(" Sort: by Date");
73             } else if (processor.getSortMode() == ChangeLogProcessor.SORT_BY_USER) {
74                 writer.print(" Sort: by User");
75             }
76             if (processor.isDescendingSort()) {
77                 writer.println(" (Descending)");
78             } else {
79                 writer.println(" (Ascending)");
80             }
81         }
82     }
83     
84     public void printGroupHeader(RevisionsGroup group) {
85           writer.println("--------------------------------------------------");
86           writer.println("User: " + group.getUser());
87           writer.println("Date: " + group.getStartingDate());
88           writer.println("Message:" + group.getMessage());
89     }
90     
91     public void printSingleRevision(LogInfoRevision revision) {
92         String JavaDoc repoFileName = revision.getLogInfoHeader().getRepositoryFilename();
93         repoFileName = repoFileName.substring(0, repoFileName.length() - 2);
94         writer.println(" " + revision.getNumber() + " " + repoFileName);
95     }
96     
97     public void printGroupFooter(RevisionsGroup group) {
98         //do nothing
99
}
100     
101     public void printSummary(SummaryProcessor processor) {
102         if (includeSummary) {
103             writer.println("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
104             writer.println("Summary:");
105             writer.println("Number of changes: " + processor.getCommitCount());
106             writer.print("Developers: ");
107             String JavaDoc[] users = processor.getUserList();
108             for (int i = 0; i < users.length; i++) {
109                 if (i < users.length) {
110                     writer.println(users[i] + ", ");
111                 } else {
112                     writer.println(users[i]);
113                 }
114             }
115             writer.println();
116             String JavaDoc[] mostChanged = processor.getMostChangedFiles();
117             writer.println("Most frequently changed files:");
118             for (int j = 0; j < mostChanged.length; j++) {
119                 writer.println(mostChanged[j]);
120             }
121             writer.println();
122             writer.println("Most active developers (based on number of commits):");
123             String JavaDoc[] mostActive= processor.getMostActiveUsers();
124             for (int k = 0; k < mostActive.length; k++) {
125                 writer.println(mostActive[k]);
126             }
127             writer.println();
128         }
129     }
130     
131     public void printFooter(ChangeLogProcessor processor) {
132         //do nothing
133
}
134     
135 }
136
Popular Tags