| 1 19 20 package org.netbeans.modules.subversion; 21 22 import org.openide.util.NbBundle; 23 24 import java.util.*; 25 import java.io.Serializable ; 26 import java.io.File ; 27 import org.tigris.subversion.svnclientadapter.ISVNStatus; 28 import org.tigris.subversion.svnclientadapter.SVNClientException; 29 import org.tigris.subversion.svnclientadapter.SVNNodeKind; 30 31 36 public class FileInformation implements Serializable { 37 38 private static final long serialVersionUID = 1L; 39 40 43 public static final int STATUS_UNKNOWN = 0; 44 45 49 public static final int STATUS_NOTVERSIONED_NOTMANAGED = 1; 50 51 55 public static final int STATUS_NOTVERSIONED_EXCLUDED = 2; 56 57 61 public static final int STATUS_NOTVERSIONED_NEWLOCALLY = 4; 62 63 66 public static final int STATUS_VERSIONED_UPTODATE = 8; 67 68 71 public static final int STATUS_VERSIONED_MODIFIEDLOCALLY = 16; 72 73 76 public static final int STATUS_VERSIONED_MODIFIEDINREPOSITORY = 32; 77 78 82 public static final int STATUS_VERSIONED_CONFLICT = 64; 83 84 88 public static final int STATUS_VERSIONED_MERGE = 128; 89 90 94 public static final int STATUS_VERSIONED_REMOVEDLOCALLY = 256; 95 96 99 public static final int STATUS_VERSIONED_NEWINREPOSITORY = 512; 100 101 104 public static final int STATUS_VERSIONED_REMOVEDINREPOSITORY = 1024; 105 106 109 public static final int STATUS_VERSIONED_DELETEDLOCALLY = 2048; 110 111 115 public static final int STATUS_VERSIONED_ADDEDLOCALLY = 4096; 116 117 public static final int STATUS_ALL = ~0; 118 119 124 public static final int STATUS_MANAGED = STATUS_ALL & ~STATUS_NOTVERSIONED_NOTMANAGED; 125 126 127 128 public static final int STATUS_VERSIONED = STATUS_VERSIONED_UPTODATE | 129 STATUS_VERSIONED_MODIFIEDLOCALLY | 130 STATUS_VERSIONED_MODIFIEDINREPOSITORY | 131 STATUS_VERSIONED_CONFLICT | 132 STATUS_VERSIONED_MERGE | 133 STATUS_VERSIONED_REMOVEDLOCALLY | 134 STATUS_VERSIONED_REMOVEDINREPOSITORY | 135 STATUS_VERSIONED_DELETEDLOCALLY | 136 STATUS_VERSIONED_ADDEDLOCALLY; 137 138 public static final int STATUS_IN_REPOSITORY = STATUS_VERSIONED_UPTODATE | 139 STATUS_VERSIONED_MODIFIEDLOCALLY | 140 STATUS_VERSIONED_MODIFIEDINREPOSITORY | 141 STATUS_VERSIONED_CONFLICT | 142 STATUS_VERSIONED_MERGE | 143 STATUS_VERSIONED_REMOVEDLOCALLY | 144 STATUS_VERSIONED_NEWINREPOSITORY | 145 STATUS_VERSIONED_REMOVEDINREPOSITORY | 146 STATUS_VERSIONED_DELETEDLOCALLY; 147 148 public static final int STATUS_LOCAL_CHANGE = 149 FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY | 150 FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | 151 FileInformation.STATUS_VERSIONED_CONFLICT | 152 FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | 153 FileInformation.STATUS_VERSIONED_MERGE | 154 FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY | 155 FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY; 156 157 161 public static final int STATUS_REVERTIBLE_CHANGE = 162 FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | 163 FileInformation.STATUS_VERSIONED_CONFLICT | 164 FileInformation.STATUS_VERSIONED_MERGE | 165 FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY | 166 FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | 167 FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY; 168 169 170 public static final int STATUS_REMOTE_CHANGE = 171 FileInformation.STATUS_VERSIONED_MERGE | 172 FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY | 173 FileInformation.STATUS_VERSIONED_NEWINREPOSITORY | 174 FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY; 175 176 177 180 private final int status; 181 182 185 private final int propStatus; 186 187 190 private transient ISVNStatus entry; 191 192 195 private final boolean isDirectory; 196 197 private static final String STATUS_UNKNOWN_EXT = "W"; private static final String STATUS_NOTVERSIONED_NOTMANAGED_EXT = "Z"; private static final String STATUS_NOTVERSIONED_EXCLUDED_EXT = "I"; private static final String STATUS_NOTVERSIONED_NEWLOCALLY_EXT = "?"; private static final String STATUS_VERSIONED_UPTODATE_EXT = "S"; private static final String STATUS_VERSIONED_MODIFIEDLOCALLY_EXT = "M"; private static final String STATUS_VERSIONED_MODIFIEDINREPOSITORY_EXT = "G"; private static final String STATUS_VERSIONED_CONFLICT_EXT = "C"; private static final String STATUS_VERSIONED_MERGE_EXT = "P"; private static final String STATUS_VERSIONED_REMOVEDLOCALLY_EXT = "R"; private static final String STATUS_VERSIONED_NEWINREPOSITORY_EXT = "N"; private static final String STATUS_VERSIONED_REMOVEDINREPOSITORY_EXT = "D"; private static final String STATUS_VERSIONED_DELETEDLOCALLY_EXT = "E"; private static final String STATUS_VERSIONED_ADDEDLOCALLY_EXT = "A"; 212 private final Exception origin; 214 215 218 public FileInformation() { 219 status = 0; 220 propStatus = 0; 221 isDirectory = false; 222 origin = new RuntimeException ("allocated at:"); } 224 225 private FileInformation(int status, int propStatus, ISVNStatus entry, boolean isDirectory) { 226 this.status = status; 227 this.propStatus = propStatus; 228 this.entry = entry; 229 this.isDirectory = isDirectory; 230 origin = new RuntimeException ("allocated at:"); } 232 233 FileInformation(int status, ISVNStatus entry) { 234 this(status, 0, entry, entry.getNodeKind() == SVNNodeKind.DIR); 235 } 236 237 FileInformation(int status, boolean isDirectory) { 238 this(status, 0, null, isDirectory); 239 } 240 241 FileInformation(int status, int propStatus, boolean isDirectory) { 242 this(status, propStatus, null, isDirectory); 243 } 244 245 250 public int getStatus() { 251 return status; 252 } 253 254 public boolean isDirectory() { 255 return isDirectory; 256 } 257 258 266 public ISVNStatus getEntry(File file) { 267 if (entry == null && file != null) { 268 readEntry(file); 269 } 270 return entry; 271 } 272 273 private void readEntry(File file) { 274 try { 275 entry = Subversion.getInstance().getClient(true).getSingleStatus(file); 276 } catch (SVNClientException e) { 277 } 279 } 280 281 287 public String getStatusText() { 288 return getStatusText(~0); 289 } 290 291 299 public String getStatusText(int displayStatuses) { 300 int status = this.status & displayStatuses; 301 ResourceBundle loc = NbBundle.getBundle(FileInformation.class); 302 if (status == FileInformation.STATUS_UNKNOWN) { 303 return loc.getString("CTL_FileInfoStatus_Unknown"); 304 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) { 305 return loc.getString("CTL_FileInfoStatus_Excluded"); 306 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) { 307 return loc.getString("CTL_FileInfoStatus_NewLocally"); 308 } else if (match(status, FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) { 309 if (entry != null && entry.isCopied()) { 310 return loc.getString("CTL_FileInfoStatus_AddedLocallyCopied"); 311 } 312 return loc.getString("CTL_FileInfoStatus_AddedLocally"); 313 } else if (match(status, FileInformation.STATUS_VERSIONED_UPTODATE)) { 314 return loc.getString("CTL_FileInfoStatus_UpToDate"); 315 } else if (match(status, FileInformation.STATUS_VERSIONED_CONFLICT)) { 316 return loc.getString("CTL_FileInfoStatus_Conflict"); 317 } else if (match(status, FileInformation.STATUS_VERSIONED_MERGE)) { 318 return loc.getString("CTL_FileInfoStatus_Merge"); 319 } else if (match(status, FileInformation.STATUS_VERSIONED_DELETEDLOCALLY)) { 320 return loc.getString("CTL_FileInfoStatus_DeletedLocally"); 321 } else if (match(status, FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) { 322 return loc.getString("CTL_FileInfoStatus_RemovedLocally"); 323 } else if (match(status, FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) { 324 return loc.getString("CTL_FileInfoStatus_ModifiedLocally"); 325 326 } else if (match(status, FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) { 327 return loc.getString("CTL_FileInfoStatus_NewInRepository"); 328 } else if (match(status, FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY)) { 329 return loc.getString("CTL_FileInfoStatus_ModifiedInRepository"); 330 } else if (match(status, FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) { 331 return loc.getString("CTL_FileInfoStatus_RemovedInRepository"); 332 } else { 333 return ""; } 335 } 336 337 341 public String getShortStatusText() { 342 ResourceBundle loc = NbBundle.getBundle(FileInformation.class); 343 if (match(status, FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) { 344 return loc.getString("CTL_FileInfoStatus_Excluded_Short"); 345 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) { 346 return loc.getString("CTL_FileInfoStatus_NewLocally_Short"); 347 } else if (match(status, FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) { 348 if (entry != null && entry.isCopied()) { 349 return loc.getString("CTL_FileInfoStatus_AddedLocallyCopied_Short"); 350 } 351 return loc.getString("CTL_FileInfoStatus_AddedLocally_Short"); 352 } else if (status == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) { 353 return loc.getString("CTL_FileInfoStatus_RemovedLocally_Short"); 354 } else if (status == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY) { 355 return loc.getString("CTL_FileInfoStatus_DeletedLocally_Short"); 356 } else if (match(status, FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) { 357 return loc.getString("CTL_FileInfoStatus_ModifiedLocally_Short"); 358 } else if (match(status, FileInformation.STATUS_VERSIONED_CONFLICT)) { 359 return loc.getString("CTL_FileInfoStatus_Conflict_Short"); 360 } else { 361 return ""; } 363 } 364 365 private static boolean match(int status, int mask) { 366 return (status & mask) != 0; 367 } 368 369 public String toString() { 370 return "Text: " + status + " " + getStatusText(status) + "\nProp: " + propStatus + " " + getStatusText(propStatus); } 372 } 373 374 | Popular Tags |