001: /*
002: * Gruntspud
003: *
004: * Copyright (C) 2002 Brett Smith.
005: *
006: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public License
010: * as published by the Free Software Foundation; either version 2 of
011: * the License, or (at your option) any later version.
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Library General Public License for more details.
016: *
017: * You should have received a copy of the GNU Library General Public
018: * License along with this program; if not, write to the Free Software
019: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020: */
021:
022: package gruntspud;
023:
024: import gruntspud.style.TextStyle;
025:
026: import java.awt.Color;
027: import java.util.Iterator;
028:
029: import org.netbeans.lib.cvsclient.command.commit.CommitInformation;
030:
031: /**
032: * Description of the Class
033: *
034: *@author magicthize
035: *@created 26 May 2002
036: */
037: public class CVSChangeStatus implements Comparable {
038: private final static java.util.List allTypes = new java.util.ArrayList();
039:
040: public final static String TAG_CHANGE_STATUS = "tag";
041: public final static String REMOVE_TAG_CHANGE_STATUS = "removeTag";
042: public final static String COMMIT_CHANGE_STATUS = "commit";
043: public final static String UPDATE_CHANGE_STATUS = "update";
044: public final static String IMPORT_CHANGE_STATUS = "import";
045:
046: // Tag
047:
048: public final static CVSChangeStatus CVS_TAG_TAGGED = new CVSChangeStatus(
049: TAG_CHANGE_STATUS, 'T', "Tagged", Color.blue.darker(),
050: "The file was tagged.", "Tag (file tagged)");
051:
052: // Remove Tag
053: public final static CVSChangeStatus CVS_REMOVE_TAG_TAG_REMOVED = new CVSChangeStatus(
054: REMOVE_TAG_CHANGE_STATUS, 'D', "Removed", Color.cyan
055: .darker(), "The tag was removed from the file.",
056: "Remove Tag (tag removed)");
057:
058: // Commit
059: public final static CVSChangeStatus CVS_COMMIT_STATUS_ADDED = new CVSChangeStatus(
060: COMMIT_CHANGE_STATUS, 'A', CommitInformation.ADDED,
061: Color.magenta.darker(),
062: "The file was permanently added to the repository.",
063: "Commit (file added)");
064: public final static CVSChangeStatus CVS_COMMIT_STATUS_REMOVED = new CVSChangeStatus(
065: COMMIT_CHANGE_STATUS, 'R', CommitInformation.REMOVED,
066: Color.cyan.darker(),
067: "The file was permanently removed from the repository.",
068: "Commit (file removed)");
069: public final static CVSChangeStatus CVS_COMMIT_STATUS_CHANGED = new CVSChangeStatus(
070: COMMIT_CHANGE_STATUS,
071: 'C',
072: CommitInformation.CHANGED,
073: Color.green.darker().darker(),
074: "Your changes have now been applied to the file in the repository.",
075: "Commit (file changed)");
076: public final static CVSChangeStatus CVS_COMMIT_STATUS_UNKNOWN = new CVSChangeStatus(
077: COMMIT_CHANGE_STATUS, 'U', CommitInformation.UNKNOWN,
078: Color.yellow.darker(), "The file is unknown.",
079: "Commit (file unknown)");
080: public final static CVSChangeStatus CVS_COMMIT_STATUS_TO_ADD = new CVSChangeStatus(
081: COMMIT_CHANGE_STATUS, 'T', CommitInformation.TO_ADD,
082: Color.blue, "To add.", "Commit (to be added)");
083:
084: // Update
085: public final static CVSChangeStatus CVS_UPDATE_STATUS_UPDATED = new CVSChangeStatus(
086: UPDATE_CHANGE_STATUS,
087: 'U',
088: "Updated",
089: Color.green.darker(),
090: "The file was brought up to date with respect to the repository. "
091: + "This is done for any file that exists in the repository but not in your source, "
092: + "and for files that you haven't changed but are not the most recent versions available "
093: + "in the repository.", "Update (file updated)");
094: public final static CVSChangeStatus CVS_UPDATE_STATUS_PATCHED = new CVSChangeStatus(
095: UPDATE_CHANGE_STATUS,
096: 'P',
097: "Patched",
098: Color.green.darker().darker(),
099: "The file was brought up to date with respect to the repository. "
100: + "This is done for any file that exists in the repository but not in your source, "
101: + "and for files that you haven't changed but are not the most recent versions available "
102: + "in the repository.", "Update (file patched)");
103: public final static CVSChangeStatus CVS_UPDATE_STATUS_ADDED = new CVSChangeStatus(
104: UPDATE_CHANGE_STATUS,
105: 'A',
106: "Added",
107: Color.magenta.darker(),
108: "The file has been added to your private copy of the sources, and will be added to "
109: + "the source repository when you run commit on the file. This is a reminder to you that "
110: + "the file needs to be committed.",
111: "Update (file added)");
112: public final static CVSChangeStatus CVS_UPDATE_STATUS_REMOVED = new CVSChangeStatus(
113: UPDATE_CHANGE_STATUS,
114: 'R',
115: "Removed",
116: Color.cyan.darker(),
117: "The file has been removed from your private copy of the sources, and will be removed "
118: + "from the source repository when you run commit on the file. This is a reminder to you "
119: + "that the file needs to be committed.",
120: "Update (file removed)");
121: public final static CVSChangeStatus CVS_UPDATE_STATUS_MODIFIED = new CVSChangeStatus(
122: UPDATE_CHANGE_STATUS,
123: 'M',
124: "Modified",
125: Color.blue.darker(),
126: "The file is modified in your working directory.\n\nThis can indicate one of two states for \n"
127: + "a file you re working on: either there were no modifications to the same file in the "
128: + "repository, so that your file remains as you last saw it, or there were modifications "
129: + "in the repository as well as in your copy, but they were merged successfully, "
130: + "without conflict, in your working directory.\n\ncvs will print some messages if it merges "
131: + "your work, and a backup copy of your working file (as it looked before you ran update) will "
132: + "be made. The exact name of that file is printed while update runs.",
133: "Update (file modified)");
134: public final static CVSChangeStatus CVS_UPDATE_STATUS_CONFLICT = new CVSChangeStatus(
135: UPDATE_CHANGE_STATUS,
136: 'C',
137: "Conflict",
138: Color.red,
139: "A conflict was detected while trying to merge your changes to file with changes from "
140: + "the source repository. The the copy in your working directory is now the result of "
141: + "attempting to merge the two revisions, an unmodified copy of your file is also in your "
142: + "working directory, with the name '.#file.revision' where revision is the revision that "
143: + "your modified file started from. Resolve the conflict.",
144: "Update (conflict during merge)");
145: public final static CVSChangeStatus CVS_UPDATE_STATUS_UNKNOWN = new CVSChangeStatus(
146: UPDATE_CHANGE_STATUS,
147: '?',
148: "Unknown",
149: Color.yellow.darker(),
150: "The file is in your working directory, but does not correspond to anything in the source "
151: + "repository, and is not in the list of files for cvs to ignore",
152: "Update (unknown status)");
153:
154: // Import
155: public final static CVSChangeStatus CVS_IMPORT_STATUS_UPDATED = new CVSChangeStatus(
156: IMPORT_CHANGE_STATUS,
157: 'U',
158: "Updated",
159: Color.green.darker(),
160: "The file already exists in the repository and has not been locally "
161: + "modified; a new revision has been created (if necessary).",
162: "Import (updated)");
163: public final static CVSChangeStatus CVS_IMPORT_STATUS_NEW = new CVSChangeStatus(
164: IMPORT_CHANGE_STATUS,
165: 'N',
166: "New",
167: Color.magenta.darker(),
168: "The file is a new file which has been added to the repository.",
169: "Import (new file)");
170: public final static CVSChangeStatus CVS_IMPORT_STATUS_CONFLICT = new CVSChangeStatus(
171: IMPORT_CHANGE_STATUS,
172: 'C',
173: "Conflict",
174: Color.red,
175: "The file already exists in the repository but has been "
176: + "locally modified; you will have to merge the changes.",
177: "Import (conflicts during merge)");
178: public final static CVSChangeStatus CVS_IMPORT_STATUS_IGNORED = new CVSChangeStatus(
179: IMPORT_CHANGE_STATUS, 'I', "Ignored", Color.black,
180: "The file is being ignored.", "Import (file ignored)");
181: public final static CVSChangeStatus CVS_IMPORT_STATUS_LINK = new CVSChangeStatus(
182: IMPORT_CHANGE_STATUS, 'L', "Link", Color.darkGray,
183: "The file is a symbolic link.", "Import (file is link)");
184:
185: private String name;
186: private String command;
187: private String description;
188: private char code;
189: private TextStyle defaultStyle;
190:
191: /**
192: * Constructor for the CVSSubstType object
193: *
194: *@param name Description of the Parameter
195: *@param icon Description of the Parameter
196: */
197: protected CVSChangeStatus(String command, char code, String name,
198: Color defaultColor, String description,
199: String shortDescription) {
200: this .code = code;
201: this .name = name;
202: this .command = command;
203: this .description = description;
204: defaultStyle = new TextStyle(command + "." + name,
205: shortDescription, defaultColor, false, false);
206: allTypes.add(this );
207: }
208:
209: /**
210: * Gets the name attribute of the CVSChangeStatus
211: *
212: *@return The name value
213: */
214: public String getName() {
215: return name;
216: }
217:
218: /**
219: * Gets the command attribute of the CVSChangeStatus object
220: *
221: *@return The command value
222: */
223: public String getCommand() {
224: return command;
225: }
226:
227: /**
228: * Gets the description attribute of the CVSChangeStatus object
229: *
230: *@return The description value
231: */
232: public String getDescription() {
233: return description;
234: }
235:
236: /**
237: * Gets the defaultColor attribute of the CVSChangeStatus object
238: *
239: *@return The defaultColor value
240: */
241: public TextStyle getDefaultStyle() {
242: return defaultStyle;
243: }
244:
245: public java.util.List getChangeStatusList() {
246: return allTypes;
247: }
248:
249: /**
250: * Gets the name attribute of the CVSChangeStatus object
251: *
252: *@return The name value
253: */
254: public char getCode() {
255: return code;
256: }
257:
258: /**
259: * Description of the Method
260: *
261: *@return Description of the Return Value
262: */
263: public String toString() {
264: return getName();
265: }
266:
267: /**
268: * DOCUMENT ME!
269: *
270: * @param code DOCUMENT ME!
271: *
272: * @return DOCUMENT ME!
273: */
274: public static CVSChangeStatus getStatusForCode(char code,
275: String command) {
276: CVSChangeStatus cs = null;
277: for (Iterator i = allTypes.iterator(); i.hasNext();) {
278: CVSChangeStatus s = (CVSChangeStatus) i.next();
279: if (s.getCode() == code && s.command.equals(command)) {
280: return s;
281: }
282: }
283: return null;
284: }
285:
286: public static Iterator changeStatus() {
287: return allTypes.iterator();
288: }
289:
290: public static TextStyle getStyleForStatus(GruntspudContext context,
291: CVSChangeStatus status) {
292: return context.getTextStyleModel().getStyle(
293: status.getCommand() + "." + status.getName());
294: }
295:
296: /**
297: * DOCUMENT ME!
298: *
299: * @param o DOCUMENT ME!
300: *
301: * @return DOCUMENT ME!
302: */
303: public int compareTo(Object o) {
304: /** @todo make this better */
305: return name.compareTo(((CVSChangeStatus) o).getName());
306: }
307: }
|