1 19 20 package org.netbeans.modules.versioning.system.cvss; 21 22 import org.netbeans.lib.cvsclient.admin.Entry; 23 import org.openide.util.NbBundle; 24 25 import java.util.*; 26 import java.io.Serializable ; 27 import java.io.File ; 28 import java.io.IOException ; 29 30 35 public class FileInformation implements Serializable { 36 37 private static final long serialVersionUID = 1L; 38 39 42 public static final int STATUS_UNKNOWN = 0; 43 44 48 public static final int STATUS_NOTVERSIONED_NOTMANAGED = 1; 49 50 54 public static final int STATUS_NOTVERSIONED_EXCLUDED = 2; 55 56 60 public static final int STATUS_NOTVERSIONED_NEWLOCALLY = 4; 61 62 65 public static final int STATUS_VERSIONED_UPTODATE = 8; 66 67 70 public static final int STATUS_VERSIONED_MODIFIEDLOCALLY = 16; 71 72 75 public static final int STATUS_VERSIONED_MODIFIEDINREPOSITORY = 32; 76 77 81 public static final int STATUS_VERSIONED_CONFLICT = 64; 82 83 87 public static final int STATUS_VERSIONED_MERGE = 128; 88 89 93 public static final int STATUS_VERSIONED_REMOVEDLOCALLY = 256; 94 95 98 public static final int STATUS_VERSIONED_NEWINREPOSITORY = 512; 99 100 103 public static final int STATUS_VERSIONED_REMOVEDINREPOSITORY = 1024; 104 105 108 public static final int STATUS_VERSIONED_DELETEDLOCALLY = 2048; 109 110 114 public static final int STATUS_VERSIONED_ADDEDLOCALLY = 4096; 115 116 public static final int STATUS_ALL = ~0; 117 118 public static final int STATUS_MANAGED = STATUS_ALL & ~STATUS_NOTVERSIONED_NOTMANAGED; 119 120 public static final int STATUS_IN_REPOSITORY = STATUS_VERSIONED_UPTODATE | STATUS_VERSIONED_MODIFIEDLOCALLY | 121 STATUS_VERSIONED_MODIFIEDINREPOSITORY | STATUS_VERSIONED_CONFLICT | STATUS_VERSIONED_MERGE | 122 STATUS_VERSIONED_REMOVEDLOCALLY | STATUS_VERSIONED_NEWINREPOSITORY | STATUS_VERSIONED_REMOVEDINREPOSITORY | 123 STATUS_VERSIONED_DELETEDLOCALLY; 124 125 public static final int STATUS_LOCAL_CHANGE = 126 FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY | 127 FileInformation.STATUS_VERSIONED_ADDEDLOCALLY | 128 FileInformation.STATUS_VERSIONED_CONFLICT | 129 FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | 130 FileInformation.STATUS_VERSIONED_MERGE | 131 FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY | 132 FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY; 133 134 public static final int STATUS_REMOTE_CHANGE = 135 FileInformation.STATUS_VERSIONED_MERGE | 136 FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY | 137 FileInformation.STATUS_VERSIONED_NEWINREPOSITORY | 138 FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY; 139 140 141 144 private final int status; 145 146 149 private final boolean isDirectory; 150 151 154 private transient Entry cvsEntry; 155 156 159 public FileInformation() { 160 status = 0; 161 isDirectory = false; 162 } 163 164 FileInformation(int status, Entry cvsEntry, boolean isDirectory) { 165 this.status = status; 166 this.cvsEntry = cvsEntry; 167 this.isDirectory = isDirectory; 168 } 169 170 FileInformation(int status, boolean isDirectory) { 171 this(status, null, isDirectory); 172 } 173 174 179 public int getStatus() { 180 return status; 181 } 182 183 public boolean isDirectory() { 184 return isDirectory; 185 } 186 187 195 public Entry getEntry(File file) { 196 if (cvsEntry == null && file != null) readEntry(file); 197 return cvsEntry; 198 } 199 200 private void readEntry(File file) { 201 try { 202 cvsEntry = CvsVersioningSystem.getInstance().getAdminHandler().getEntry(file); 203 } catch (IOException e) { 204 } 206 } 207 208 213 public String getStatusText() { 214 ResourceBundle loc = NbBundle.getBundle(FileInformation.class); 215 if (status == FileInformation.STATUS_UNKNOWN) { 216 return loc.getString("CTL_FileInfoStatus_Unknown"); 217 } else if (status == FileInformation.STATUS_NOTVERSIONED_EXCLUDED) { 218 return loc.getString("CTL_FileInfoStatus_Excluded"); 219 } else if (status == FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY) { 220 return loc.getString("CTL_FileInfoStatus_NewLocally"); 221 } else if (status == FileInformation.STATUS_VERSIONED_ADDEDLOCALLY) { 222 return loc.getString("CTL_FileInfoStatus_AddedLocally"); 223 } else if (status == FileInformation.STATUS_VERSIONED_UPTODATE) { 224 return loc.getString("CTL_FileInfoStatus_UpToDate"); 225 } else if (status == FileInformation.STATUS_VERSIONED_NEWINREPOSITORY) { 226 return loc.getString("CTL_FileInfoStatus_NewInRepository"); 227 } else if (status == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) { 228 return loc.getString("CTL_FileInfoStatus_RemovedLocally"); 229 } else if (status == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY) { 230 return loc.getString("CTL_FileInfoStatus_DeletedLocally"); 231 } else if (status == FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY) { 232 return loc.getString("CTL_FileInfoStatus_ModifiedLocally"); 233 } else if (status == FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY) { 234 return loc.getString("CTL_FileInfoStatus_ModifiedInRepository"); 235 } else if (status == FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY) { 236 return loc.getString("CTL_FileInfoStatus_RemovedInRepository"); 237 } else if (status == FileInformation.STATUS_VERSIONED_CONFLICT) { 238 return loc.getString("CTL_FileInfoStatus_Conflict"); 239 } else if (status == FileInformation.STATUS_VERSIONED_MERGE) { 240 return loc.getString("CTL_FileInfoStatus_Merge"); 241 } else { 242 return ""; } 244 } 245 246 public String getShortStatusText() { 247 ResourceBundle loc = NbBundle.getBundle(FileInformation.class); 248 if (status == FileInformation.STATUS_NOTVERSIONED_EXCLUDED) { 249 return loc.getString("CTL_FileInfoStatus_Excluded_Short"); 250 } else if (status == FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY) { 251 return loc.getString("CTL_FileInfoStatus_NewLocally_Short"); 252 } else if (status == FileInformation.STATUS_VERSIONED_ADDEDLOCALLY) { 253 return loc.getString("CTL_FileInfoStatus_AddedLocally_Short"); 254 } else if (status == FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY) { 255 return loc.getString("CTL_FileInfoStatus_RemovedLocally_Short"); 256 } else if (status == FileInformation.STATUS_VERSIONED_DELETEDLOCALLY) { 257 return loc.getString("CTL_FileInfoStatus_DeletedLocally_Short"); 258 } else if (status == FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY) { 259 return loc.getString("CTL_FileInfoStatus_ModifiedLocally_Short"); 260 } else if (status == FileInformation.STATUS_VERSIONED_CONFLICT) { 261 return loc.getString("CTL_FileInfoStatus_Conflict_Short"); 262 } else if (status == FileInformation.STATUS_VERSIONED_MERGE) { 263 return loc.getString("CTL_FileInfoStatus_ModifiedLocally_Short"); 264 } else { 265 return ""; } 267 } 268 } 269 270 | Popular Tags |