Source Code Cross Referenced for FileInformation.java in  » IDE-Netbeans » mercurial » org » netbeans » modules » mercurial » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mercurial » org.netbeans.modules.mercurial 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.mercurial;
042:
043:        import org.openide.util.NbBundle;
044:
045:        import java.io.Serializable;
046:        import java.io.File;
047:        import java.util.*;
048:
049:        /**
050:         * Immutable class encapsulating status of a file.
051:         *
052:         * @author Maros Sandor
053:         */
054:        public class FileInformation implements  Serializable {
055:
056:            private static final long serialVersionUID = 1L;
057:
058:            /**
059:             * There is nothing known about the file, it may not even exist.
060:             */
061:            public static final int STATUS_UNKNOWN = 0;
062:
063:            /**
064:             * The file is not managed by the module, i.e. the user does not wish it to be under control of this
065:             * versioning system module. All files except files under versioned roots have this status.
066:             */
067:            public static final int STATUS_NOTVERSIONED_NOTMANAGED = 1;
068:
069:            /**
070:             * The file exists locally but is NOT under version control because it should not be (i.e. is has
071:             * the Ignore property set or resides under an excluded folder). The file itself IS under a versioned root.
072:             */
073:            public static final int STATUS_NOTVERSIONED_EXCLUDED = 2;
074:
075:            /**
076:             * The file exists locally but is NOT under version control, mostly because it has not been added
077:             * to the repository yet.
078:             */
079:            public static final int STATUS_NOTVERSIONED_NEWLOCALLY = 4;
080:
081:            /**
082:             * The file is under version control and is in sync with repository.
083:             */
084:            public static final int STATUS_VERSIONED_UPTODATE = 8;
085:
086:            /**
087:             * The file is modified locally and was not yet modified in repository.
088:             */
089:            public static final int STATUS_VERSIONED_MODIFIEDLOCALLY = 16;
090:
091:            /**
092:             * The file was not modified locally but an updated version exists in repository.
093:             */
094:            public static final int STATUS_VERSIONED_MODIFIEDINREPOSITORY = 32;
095:
096:            /**
097:             * Merging during update resulted in merge conflict. Conflicts in the local copy must be resolved before
098:             * the file can be commited.  
099:             */
100:            public static final int STATUS_VERSIONED_CONFLICT = 64;
101:
102:            /**
103:             * The file was modified both locally and remotely and these changes may or may not result in
104:             * merge conflict. 
105:             */
106:            public static final int STATUS_VERSIONED_MERGE = 128;
107:
108:            /**
109:             * The file does NOT exist locally and exists in repository, it has beed removed locally, waits
110:             * for commit.
111:             */
112:            public static final int STATUS_VERSIONED_REMOVEDLOCALLY = 256;
113:
114:            /**
115:             * The file does NOT exist locally but exists in repository and has not yet been downloaded. 
116:             */
117:            public static final int STATUS_VERSIONED_NEWINREPOSITORY = 512;
118:
119:            /**
120:             * The file has been removed from repository. 
121:             */
122:            public static final int STATUS_VERSIONED_REMOVEDINREPOSITORY = 1024;
123:
124:            /**
125:             * The file does NOT exist locally and exists in repository, it has beed removed locally.
126:             */
127:            public static final int STATUS_VERSIONED_DELETEDLOCALLY = 2048;
128:
129:            /**
130:             * The file exists locally and has beed scheduled for addition to repository. This status represents
131:             * state after the 'add' command.
132:             */
133:            public static final int STATUS_VERSIONED_ADDEDLOCALLY = 4096;
134:
135:            public static final int STATUS_ALL = ~0;
136:
137:            /**
138:             * All statuses except <tt>STATUS_NOTVERSIONED_NOTMANAGED</tt>
139:             *
140:             * <p>Note: it covers ignored files.
141:             */
142:            public static final int STATUS_MANAGED = FileInformation.STATUS_ALL
143:                    & ~FileInformation.STATUS_NOTVERSIONED_NOTMANAGED;
144:
145:            public static final int STATUS_VERSIONED = FileInformation.STATUS_VERSIONED_UPTODATE
146:                    | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY
147:                    | FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY
148:                    | FileInformation.STATUS_VERSIONED_CONFLICT
149:                    | FileInformation.STATUS_VERSIONED_MERGE
150:                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY
151:                    | FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY
152:                    | FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
153:                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY;
154:
155:            public static final int STATUS_IN_REPOSITORY = FileInformation.STATUS_VERSIONED_UPTODATE
156:                    | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY
157:                    | FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY
158:                    | FileInformation.STATUS_VERSIONED_CONFLICT
159:                    | FileInformation.STATUS_VERSIONED_MERGE
160:                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY
161:                    | FileInformation.STATUS_VERSIONED_NEWINREPOSITORY
162:                    | FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY
163:                    | FileInformation.STATUS_VERSIONED_DELETEDLOCALLY;
164:
165:            public static final int STATUS_LOCAL_CHANGE = FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY
166:                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY
167:                    | FileInformation.STATUS_VERSIONED_CONFLICT
168:                    | FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
169:                    | FileInformation.STATUS_VERSIONED_MERGE
170:                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY
171:                    | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY;
172:
173:            /**
174:             * Modified, in conflict, scheduled for removal or addition;
175:             * or deleted but with existing entry record.
176:             */
177:            public static final int STATUS_REVERTIBLE_CHANGE = FileInformation.STATUS_VERSIONED_ADDEDLOCALLY
178:                    | FileInformation.STATUS_VERSIONED_CONFLICT
179:                    | FileInformation.STATUS_VERSIONED_MERGE
180:                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY
181:                    | FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
182:                    | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY;
183:
184:            public static final int STATUS_REMOTE_CHANGE = FileInformation.STATUS_VERSIONED_MERGE
185:                    | FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY
186:                    | FileInformation.STATUS_VERSIONED_NEWINREPOSITORY
187:                    | FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY;
188:
189:            /**
190:             * Status constant.
191:             */
192:            private final int status;
193:
194:            /**
195:             * More detailed information about a file, you may disregard the field if not needed.
196:             */
197:            private transient FileStatus entry;
198:
199:            /**
200:             * Directory indicator, mainly because of files that may have been deleted so file.isDirectory() won't work.
201:             */
202:            private final boolean isDirectory;
203:
204:            /**
205:             * For deserialization purposes only.
206:             */
207:            public FileInformation() {
208:                status = 0;
209:                isDirectory = false;
210:            }
211:
212:            public FileInformation(int status, FileStatus entry,
213:                    boolean isDirectory) {
214:                this .status = status;
215:                this .entry = entry;
216:                this .isDirectory = isDirectory;
217:            }
218:
219:            FileInformation(int status, boolean isDirectory) {
220:                this (status, null, isDirectory);
221:            }
222:
223:            /**
224:             * Retrieves the status constant representing status of the file.
225:             * 
226:             * @return one of status constants
227:             */
228:            public int getStatus() {
229:                return status;
230:            }
231:
232:            public boolean isDirectory() {
233:                return isDirectory;
234:            }
235:
236:            /**
237:             * Retrieves file's Status.
238:             *
239:             * @param file file this information belongs to or null if you do not want the entry to be read from disk 
240:             * in case it is not loaded yet
241:             * @return Status parsed entry form the .svn/entries file or null if the file does not exist,
242:             * is not versioned or its entry is invalid
243:             */
244:            public FileStatus getStatus(File file) {
245:                if (entry == null && file != null) {
246:                    readEntry(file);
247:                }
248:                return entry;
249:            }
250:
251:            private void readEntry(File file) {
252:                // Fetches File info from .svn directory:
253:                // entry = Subversion.getInstance().getClient(true).getSingleStatus(file);
254:                entry = null; // TODO: read your detailed information about the file here, or disregard the entry field
255:            }
256:
257:            /**
258:             * Returns localized text representation of status.
259:             * 
260:             * @return status name, for multistatuses prefers local
261:             * status name.
262:             */
263:            public String getStatusText() {
264:                return getStatusText(~0);
265:            }
266:
267:            /**
268:             * Returns localized text representation of status.
269:             *
270:             * @param displayStatuses statuses bitmask
271:             *
272:             * @return status name, for multistatuses prefers local
273:             * status name, for masked <tt>""</tt>. // NOI18N
274:             */
275:            public String getStatusText(int displayStatuses) {
276:                int status = this .status & displayStatuses;
277:                ResourceBundle loc = NbBundle.getBundle(FileInformation.class);
278:                if (status == FileInformation.STATUS_UNKNOWN) {
279:                    return loc.getString("CTL_FileInfoStatus_Unknown"); // NOI18N         
280:                } else if (FileInformation.match(status,
281:                        FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) {
282:                    return loc.getString("CTL_FileInfoStatus_Excluded"); // NOI18N
283:                } else if (FileInformation.match(status,
284:                        FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) {
285:                    return loc.getString("CTL_FileInfoStatus_NewLocally"); // NOI18N
286:                } else if (FileInformation.match(status,
287:                        FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
288:                    if (entry != null && entry.isCopied()) {
289:                        return loc
290:                                .getString("CTL_FileInfoStatus_AddedLocallyCopied"); // NOI18N
291:                    }
292:                    return loc.getString("CTL_FileInfoStatus_AddedLocally"); // NOI18N
293:                } else if (FileInformation.match(status,
294:                        FileInformation.STATUS_VERSIONED_UPTODATE)) {
295:                    return loc.getString("CTL_FileInfoStatus_UpToDate"); // NOI18N
296:                } else if (FileInformation.match(status,
297:                        FileInformation.STATUS_VERSIONED_CONFLICT)) {
298:                    return loc.getString("CTL_FileInfoStatus_Conflict"); // NOI18N
299:                } else if (FileInformation.match(status,
300:                        FileInformation.STATUS_VERSIONED_MERGE)) {
301:                    return loc.getString("CTL_FileInfoStatus_Merge"); // NOI18N   
302:                } else if (FileInformation.match(status,
303:                        FileInformation.STATUS_VERSIONED_DELETEDLOCALLY)) {
304:                    return loc.getString("CTL_FileInfoStatus_DeletedLocally"); // NOI18N
305:                } else if (FileInformation.match(status,
306:                        FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) {
307:                    return loc.getString("CTL_FileInfoStatus_RemovedLocally"); // NOI18N
308:                } else if (FileInformation.match(status,
309:                        FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) {
310:                    return loc.getString("CTL_FileInfoStatus_ModifiedLocally"); // NOI18N
311:
312:                } else if (FileInformation.match(status,
313:                        FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) {
314:                    return loc.getString("CTL_FileInfoStatus_NewInRepository"); // NOI18N
315:                } else if (FileInformation.match(status,
316:                        FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY)) {
317:                    return loc
318:                            .getString("CTL_FileInfoStatus_ModifiedInRepository"); // NOI18N
319:                } else if (FileInformation.match(status,
320:                        FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) {
321:                    return loc
322:                            .getString("CTL_FileInfoStatus_RemovedInRepository"); // NOI18N
323:                } else {
324:                    return ""; // NOI18N                     
325:                }
326:            }
327:
328:            /**
329:             * @return short status name for local changes, for remote
330:             * changes returns <tt>""</tt> // NOI18N
331:             */
332:            public String getShortStatusText() {
333:                ResourceBundle loc = NbBundle.getBundle(FileInformation.class);
334:                if (FileInformation.match(status,
335:                        FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) {
336:                    return loc.getString("CTL_FileInfoStatus_Excluded_Short"); // NOI18N
337:                } else if (FileInformation.match(status,
338:                        FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) {
339:                    return loc.getString("CTL_FileInfoStatus_NewLocally_Short"); // NOI18N
340:                } else if (FileInformation.match(status,
341:                        FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
342:                    if (entry != null && entry.isCopied()) {
343:                        return loc
344:                                .getString("CTL_FileInfoStatus_AddedLocallyCopied_Short"); // NOI18N
345:                    }
346:                    return loc
347:                            .getString("CTL_FileInfoStatus_AddedLocally_Short"); // NOI18N
348:                } else if (status == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) {
349:                    return loc
350:                            .getString("CTL_FileInfoStatus_RemovedLocally_Short"); // NOI18N
351:                } else if (status == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY) {
352:                    return loc
353:                            .getString("CTL_FileInfoStatus_DeletedLocally_Short"); // NOI18N
354:                } else if (FileInformation.match(status,
355:                        FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) {
356:                    return loc
357:                            .getString("CTL_FileInfoStatus_ModifiedLocally_Short"); // NOI18N
358:                } else if (FileInformation.match(status,
359:                        FileInformation.STATUS_VERSIONED_CONFLICT)) {
360:                    return loc.getString("CTL_FileInfoStatus_Conflict_Short"); // NOI18N
361:                } else {
362:                    return ""; // NOI18N                  
363:                }
364:            }
365:
366:            private static boolean match(int status, int mask) {
367:                return (status & mask) != 0;
368:            }
369:
370:            public String toString() {
371:                return "Text: " + status + " " + getStatusText(status); // NOI18N
372:            }
373:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.