Add missing NetBeans *.form files.
[nbgit.git] / src / org / netbeans / modules / git / ui / log / RepositoryRevision.java
blobc4aae0aad2d6a8e9bf6f12c0d4fbf7dc1d8c34c4
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common
8 * Development and Distribution License("CDDL") (collectively, the
9 * "License"). You may not use this file except in compliance with the
10 * License. You can obtain a copy of the License at
11 * http://www.netbeans.org/cddl-gplv2.html
12 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13 * specific language governing permissions and limitations under the
14 * License. When distributing the software, include this License Header
15 * Notice in each file and include the License file at
16 * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17 * particular file as subject to the "Classpath" exception as provided
18 * by Sun in the GPL Version 2 section of the License file that
19 * accompanied this code. If applicable, add the following below the
20 * License Header, with the fields enclosed by brackets [] replaced by
21 * your own identifying information:
22 * "Portions Copyrighted [year] [name of copyright owner]"
24 * Contributor(s):
26 * The Original Software is NetBeans. The Initial Developer of the Original
27 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28 * Microsystems, Inc. All Rights Reserved.
29 * Portions Copyright 2008 Alexander Coles (Ikonoklastik Productions).
31 * If you wish your version of this file to be governed by only the CDDL
32 * or only the GPL Version 2, indicate your decision by adding
33 * "[Contributor] elects to include this software in this distribution
34 * under the [CDDL or GPL Version 2] license." If you do not indicate a
35 * single choice of license, a recipient has the option to distribute
36 * your version of this file under either the CDDL, the GPL Version 2 or
37 * to extend the choice of license to its licensees as provided above.
38 * However, if you add GPL Version 2 code and therefore, elected the GPL
39 * Version 2 license, then the option applies only if the new code is
40 * made subject to such option by the copyright holder.
42 package org.netbeans.modules.git.ui.log;
44 import java.io.File;
45 import java.util.ArrayList;
46 import java.util.List;
48 /**
49 * Describes log information for a file. This is the result of doing a
50 * cvs log command. The fields in instances of this object are populated
51 * by response handlers.
53 * @author Maros Sandor
55 public class RepositoryRevision {
57 private GitLogMessage message;
59 private String repositoryRootUrl;
61 /**
62 * List of events associated with the revision.
63 */
64 private final List<Event> events = new ArrayList<Event>(1);
66 public RepositoryRevision(GitLogMessage message, String rootUrl) {
67 this.message = message;
68 this.repositoryRootUrl = rootUrl;
69 initEvents();
72 public String getRepositoryRootUrl() {
73 return repositoryRootUrl;
76 private void initEvents() {
77 GitLogMessageChangedPath [] paths = message.getChangedPaths();
78 if (paths == null) return;
79 for (GitLogMessageChangedPath path : paths) {
80 events.add(new Event(path));
84 public List<Event> getEvents() {
85 return events;
88 public GitLogMessage getLog() {
89 return message;
92 @Override
93 public String toString() {
94 StringBuffer text = new StringBuffer();
95 text.append(getLog().getRevision());
96 text.append("\t");
97 text.append(getLog().getDate());
98 text.append("\t");
99 text.append(getLog().getAuthor()); // NOI18N
100 text.append("\n"); // NOI18N
101 text.append(getLog().getMessage());
102 return text.toString();
105 public class Event {
108 * The file or folder that this event is about. It may be null if the File cannot be computed.
110 private File file;
112 private GitLogMessageChangedPath changedPath;
114 private String name;
115 private String path;
117 public Event(GitLogMessageChangedPath changedPath) {
118 this.changedPath = changedPath;
119 name = changedPath.getPath().substring(changedPath.getPath().lastIndexOf('/') + 1);
121 int indexPath = changedPath.getPath().lastIndexOf('/');
122 if(indexPath > -1)
123 path = changedPath.getPath().substring(0, indexPath);
124 else
125 path = "";
128 public RepositoryRevision getLogInfoHeader() {
129 return RepositoryRevision.this;
132 public GitLogMessageChangedPath getChangedPath() {
133 return changedPath;
136 /** Getter for property file.
137 * @return Value of property file.
139 public File getFile() {
140 return file;
143 /** Setter for property file.
144 * @param file New value of property file.
146 public void setFile(File file) {
147 this.file = file;
150 public String getName() {
151 return name;
154 public String getPath() {
155 return path;
158 @Override
159 public String toString() {
160 StringBuffer text = new StringBuffer();
161 text.append("\t");
162 text.append(getPath());
163 return text.toString();