1 19 20 package org.netbeans.modules.subversion; 21 22 import org.netbeans.modules.subversion.ui.copy.*; 23 import org.netbeans.modules.subversion.ui.ignore.IgnoreAction; 24 import org.netbeans.modules.subversion.ui.status.StatusAction; 25 import org.netbeans.modules.subversion.ui.commit.CommitAction; 26 import org.netbeans.modules.subversion.ui.update.*; 27 import org.netbeans.modules.subversion.ui.diff.DiffAction; 28 import org.netbeans.modules.subversion.ui.diff.ExportDiffAction; 29 import org.netbeans.modules.subversion.ui.blame.BlameAction; 30 import org.netbeans.modules.subversion.ui.history.SearchHistoryAction; 31 import org.netbeans.modules.subversion.ui.project.ImportAction; 32 import org.netbeans.modules.subversion.ui.checkout.CheckoutAction; 33 import org.openide.util.actions.SystemAction; 34 import org.openide.util.NbBundle; 35 import org.openide.util.Utilities; 36 import org.openide.util.Lookup; 37 import org.openide.util.lookup.Lookups; 38 import org.openide.ErrorManager; 39 import org.openide.nodes.Node; 40 import org.netbeans.modules.subversion.util.SvnUtils; 41 import org.netbeans.modules.versioning.util.FlatFolder; 42 import org.netbeans.modules.versioning.util.Utils; 43 import org.netbeans.modules.versioning.spi.VCSContext; 44 import org.netbeans.modules.versioning.spi.VCSAnnotator; 45 import org.netbeans.api.project.Project; 46 import javax.swing.*; 47 import java.util.*; 48 import java.util.List ; 49 import java.util.regex.Pattern ; 50 import java.text.MessageFormat ; 51 import java.io.File ; 52 import java.awt.*; 53 import java.lang.reflect.Field ; 54 import org.netbeans.modules.subversion.client.SvnClient; 55 import org.netbeans.modules.subversion.ui.properties.SvnPropertiesAction; 56 import org.netbeans.modules.subversion.ui.relocate.RelocateAction; 57 import org.netbeans.modules.versioning.util.SystemActionBridge; 58 import org.tigris.subversion.svnclientadapter.*; 59 60 66 public class Annotator { 67 68 private static MessageFormat uptodateFormat = getFormat("uptodateFormat"); private static MessageFormat newLocallyFormat = getFormat("newLocallyFormat"); private static MessageFormat addedLocallyFormat = getFormat("addedLocallyFormat"); private static MessageFormat modifiedLocallyFormat = getFormat("modifiedLocallyFormat"); private static MessageFormat removedLocallyFormat = getFormat("removedLocallyFormat"); private static MessageFormat deletedLocallyFormat = getFormat("deletedLocallyFormat"); private static MessageFormat newInRepositoryFormat = getFormat("newInRepositoryFormat"); private static MessageFormat modifiedInRepositoryFormat = getFormat("modifiedInRepositoryFormat"); private static MessageFormat removedInRepositoryFormat = getFormat("removedInRepositoryFormat"); private static MessageFormat conflictFormat = getFormat("conflictFormat"); private static MessageFormat mergeableFormat = getFormat("mergeableFormat"); private static MessageFormat excludedFormat = getFormat("excludedFormat"); 81 private static final int STATUS_TEXT_ANNOTABLE = FileInformation.STATUS_NOTVERSIONED_EXCLUDED | 82 FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY | FileInformation.STATUS_VERSIONED_UPTODATE | 83 FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY | FileInformation.STATUS_VERSIONED_CONFLICT | 84 FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY | FileInformation.STATUS_VERSIONED_DELETEDLOCALLY | 85 FileInformation.STATUS_VERSIONED_ADDEDLOCALLY; 86 87 private static final Pattern lessThan = Pattern.compile("<"); 89 public static String ANNOTATION_REVISION = "revision"; 90 public static String ANNOTATION_STATUS = "status"; 91 public static String ANNOTATION_FOLDER = "folder"; 92 public static String ANNOTATION_MIME_TYPE = "mime_type"; 93 94 public static String [] LABELS = new String [] {ANNOTATION_REVISION, ANNOTATION_STATUS, ANNOTATION_FOLDER, ANNOTATION_MIME_TYPE}; 95 96 private final FileStatusCache cache; 97 private MessageFormat format; 98 private String emptyFormat; 99 100 private boolean mimeTypeFlag; 101 102 Annotator(Subversion svn) { 103 this.cache = svn.getStatusCache(); 104 initDefaults(); 105 } 106 107 private void initDefaults() { 108 Field [] fields = Annotator.class.getDeclaredFields(); 109 for (int i = 0; i < fields.length; i++) { 110 String name = fields[i].getName(); 111 if (name.endsWith("Format")) { initDefaultColor(name.substring(0, name.length() - 6)); 113 } 114 } 115 refresh(); 116 } 117 118 public void refresh() { 119 String string = SvnModuleConfig.getDefault().getAnnotationFormat(); if (string != null && !string.trim().equals("")) { 121 mimeTypeFlag = string.indexOf("{mime_type}") > -1; 122 string = string.replaceAll("\\{revision\\}", "\\{0\\}"); string = string.replaceAll("\\{status\\}", "\\{1\\}"); string = string.replaceAll("\\{folder\\}", "\\{2\\}"); string = string.replaceAll("\\{mime_type\\}", "\\{3\\}"); format = new MessageFormat (string); 127 emptyFormat = format.format(new String [] {"", "", "", ""} , new StringBuffer (), null).toString().trim(); 128 } 129 } 130 131 private void initDefaultColor(String name) { 132 String color = System.getProperty("svn.color." + name); if (color == null) return; 134 setAnnotationColor(name, color); 135 } 136 137 145 private void setAnnotationColor(String name, String colorString) { 146 try { 147 Field field = Annotator.class.getDeclaredField(name + "Format"); MessageFormat format = new MessageFormat ("<font color=\"" + colorString + "\">{0}</font><font color=\"#999999\">{1}</font>"); field.set(null, format); 150 } catch (Exception e) { 151 throw new IllegalArgumentException ("Invalid color name"); } 153 } 154 155 166 public String annotateNameHtml(String name, FileInformation info, File file) { 167 name = htmlEncode(name); 168 int status = info.getStatus(); 169 String textAnnotation; 170 String textAnnotationFormat = SvnModuleConfig.getDefault().getPreferences().get(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT, null); 171 if (textAnnotationFormat != null && file != null && (status & STATUS_TEXT_ANNOTABLE) != 0) { 172 if (format != null) { 173 textAnnotation = formatAnnotation(info, file); 174 } else { 175 String sticky = SvnUtils.getCopy(file); 176 if (status == FileInformation.STATUS_VERSIONED_UPTODATE && sticky == null) { 177 textAnnotation = ""; } else if (status == FileInformation.STATUS_VERSIONED_UPTODATE) { 179 textAnnotation = " [" + sticky + "]"; } else if (sticky == null) { 181 String statusText = info.getShortStatusText(); 182 if(!statusText.equals("")) { 183 textAnnotation = " [" + info.getShortStatusText() + "]"; } else { 185 textAnnotation = ""; 186 } 187 } else { 188 textAnnotation = " [" + info.getShortStatusText() + "; " + sticky + "]"; } 190 } 191 } else { 192 textAnnotation = ""; } 194 if (textAnnotation.length() > 0) { 195 textAnnotation = NbBundle.getMessage(Annotator.class, "textAnnotation", textAnnotation); 196 } 197 198 200 if (0 != (status & FileInformation.STATUS_VERSIONED_CONFLICT)) { 201 return conflictFormat.format(new Object [] { name, textAnnotation }); 202 } else if (0 != (status & FileInformation.STATUS_VERSIONED_MERGE)) { 203 return mergeableFormat.format(new Object [] { name, textAnnotation }); 204 } else if (0 != (status & FileInformation.STATUS_VERSIONED_DELETEDLOCALLY)) { 205 return deletedLocallyFormat.format(new Object [] { name, textAnnotation }); 206 } else if (0 != (status & FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) { 207 return removedLocallyFormat.format(new Object [] { name, textAnnotation }); 208 } else if (0 != (status & FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) { 209 return newLocallyFormat.format(new Object [] { name, textAnnotation }); 210 } else if (0 != (status & FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) { 211 return addedLocallyFormat.format(new Object [] { name, textAnnotation }); 212 } else if (0 != (status & FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) { 213 return modifiedLocallyFormat.format(new Object [] { name, textAnnotation }); 214 215 217 } else if (0 != (status & FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) { 218 return removedInRepositoryFormat.format(new Object [] { name, textAnnotation }); 219 } else if (0 != (status & FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) { 220 return newInRepositoryFormat.format(new Object [] { name, textAnnotation }); 221 } else if (0 != (status & FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY)) { 222 return modifiedInRepositoryFormat.format(new Object [] { name, textAnnotation }); 223 } else if (0 != (status & FileInformation.STATUS_VERSIONED_UPTODATE)) { 224 return uptodateFormat.format(new Object [] { name, textAnnotation }); 225 } else if (0 != (status & FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) { 226 return excludedFormat.format(new Object [] { name, textAnnotation }); 227 } else if (0 != (status & FileInformation.STATUS_NOTVERSIONED_NOTMANAGED)) { 228 return name; 229 } else if (status == FileInformation.STATUS_UNKNOWN) { 230 return name; 231 } else { 232 throw new IllegalArgumentException ("Uncomparable status: " + status); } 234 } 235 236 239 private String formatAnnotation(FileInformation info, File file) { 240 String statusString = ""; int status = info.getStatus(); 242 if (status != FileInformation.STATUS_VERSIONED_UPTODATE) { 243 statusString = info.getShortStatusText(); 244 } 245 246 String revisionString = ""; String binaryString = ""; 249 250 ISVNStatus snvStatus = info.getEntry(file); 251 if (snvStatus != null) { 252 revisionString = snvStatus.getRevision().toString(); 253 if(mimeTypeFlag) { 254 binaryString = getMimeType(file); 255 } 256 } 257 258 String stickyString = SvnUtils.getCopy(file); 259 if (stickyString == null) { 260 stickyString = ""; } 262 263 Object [] arguments = new Object [] { 264 revisionString, 265 statusString, 266 stickyString, 267 binaryString 268 }; 269 270 String annotation = format.format(arguments, new StringBuffer (), null).toString().trim(); 271 if(annotation.equals(emptyFormat)) { 272 return ""; 273 } else { 274 return " " + annotation; 275 } 276 } 277 278 private String getMimeType(File file) { 279 try { 280 SvnClient client = Subversion.getInstance().getClient(false); 281 ISVNProperty prop = client.propertyGet(file, ISVNProperty.MIME_TYPE); 282 if(prop != null) { 283 String mime = prop.getValue(); 284 return mime != null ? mime : ""; 285 } 286 } catch (SVNClientException ex) { 287 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); return ""; 289 } 290 return ""; 291 } 292 293 private String annotateFolderNameHtml(String name, FileInformation info, File file) { 294 name = htmlEncode(name); 295 int status = info.getStatus(); 296 String textAnnotation; 297 String textAnnotationFormat = SvnModuleConfig.getDefault().getPreferences().get(SvnModuleConfig.PROP_TEXT_ANNOTATIONS_FORMAT, null); 298 if (textAnnotationFormat != null && file != null && (status & FileInformation.STATUS_MANAGED) != 0) { 299 300 if (format != null) { 301 textAnnotation = formatAnnotation(info, file); 302 } else { 303 String sticky; 304 ISVNStatus lstatus = info.getEntry(file); 305 if (lstatus != null && lstatus.getUrl() != null) { 306 sticky = SvnUtils.getCopy(lstatus.getUrl()); 307 } else { 308 sticky = SvnUtils.getCopy(file); 310 } 311 312 if (status == FileInformation.STATUS_VERSIONED_UPTODATE && sticky == null) { 313 textAnnotation = ""; } else if (status == FileInformation.STATUS_VERSIONED_UPTODATE) { 315 textAnnotation = " [" + sticky + "]"; } else if (sticky == null) { 317 String statusText = info.getShortStatusText(); 318 if(!statusText.equals("")) { textAnnotation = " [" + info.getShortStatusText() + "]"; } else { 321 textAnnotation = ""; } 323 } else { 324 textAnnotation = " [" + info.getShortStatusText() + "; " + sticky + "]"; } 326 } 327 } else { 328 textAnnotation = ""; } 330 if (textAnnotation.length() > 0) { 331 textAnnotation = NbBundle.getMessage(Annotator.class, "textAnnotation", textAnnotation); } 333 334 if (status == FileInformation.STATUS_UNKNOWN) { 335 return name; 336 } else if (match(status, FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) { 337 return name; 338 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) { 339 return uptodateFormat.format(new Object [] { name, textAnnotation }); 340 } else if (match(status, FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) { 341 return uptodateFormat.format(new Object [] { name, textAnnotation }); 342 } else if (match(status, FileInformation.STATUS_VERSIONED_UPTODATE)) { 343 return uptodateFormat.format(new Object [] { name, textAnnotation }); 344 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_EXCLUDED)) { 345 return excludedFormat.format(new Object [] { name, textAnnotation }); 346 } else if (match(status, FileInformation.STATUS_VERSIONED_DELETEDLOCALLY)) { 347 return name; 348 } else if (match(status, FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) { 349 return name; 350 } else if (match(status, FileInformation.STATUS_VERSIONED_MODIFIEDINREPOSITORY)) { 351 return name; 352 } else if (match(status, FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) { 353 return name; 354 } else if (match(status, FileInformation.STATUS_NOTVERSIONED_NOTMANAGED)) { 355 return name; 356 } else if (match(status, FileInformation.STATUS_VERSIONED_MERGE)) { 357 return name; 358 } else if (match(status, FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY)) { 359 return name; 360 } else if (match(status, FileInformation.STATUS_VERSIONED_CONFLICT)) { 361 return name; 362 } else { 363 throw new IllegalArgumentException ("Unknown status: " + status); } 365 } 366 367 private static boolean match(int status, int mask) { 368 return (status & mask) != 0; 369 } 370 371 private String htmlEncode(String name) { 372 if (name.indexOf('<') == -1) return name; 373 return lessThan.matcher(name).replaceAll("<"); } 375 376 public String annotateNameHtml(File file, FileInformation info) { 377 return annotateNameHtml(file.getName(), info, file); 378 } 379 380 public String annotateNameHtml(String name, VCSContext context, int includeStatus) { 381 FileInformation mostImportantInfo = null; 382 File mostImportantFile = null; 383 boolean folderAnnotation = false; 384 385 for (File file : context.getRootFiles()) { 386 FileInformation info = cache.getStatus(file); 387 int status = info.getStatus(); 388 if ((status & includeStatus) == 0) continue; 389 390 if (isMoreImportant(info, mostImportantInfo)) { 391 mostImportantInfo = info; 392 mostImportantFile = file; 393 folderAnnotation = file.isDirectory(); 394 } 395 } 396 397 if (folderAnnotation == false && context.getRootFiles().size() > 1) { 398 folderAnnotation = !Utils.shareCommonDataObject(context.getRootFiles().toArray(new File [context.getRootFiles().size()])); 399 } 400 401 if (mostImportantInfo == null) return null; 402 return folderAnnotation ? 403 annotateFolderNameHtml(name, mostImportantInfo, mostImportantFile) : 404 annotateNameHtml(name, mostImportantInfo, mostImportantFile); 405 } 406 407 private boolean isMoreImportant(FileInformation a, FileInformation b) { 408 if (b == null) return true; 409 if (a == null) return false; 410 return SvnUtils.getComparableStatus(a.getStatus()) < SvnUtils.getComparableStatus(b.getStatus()); 411 } 412 413 String annotateName(String name, Set files) { 414 return null; 415 } 416 417 426 public static Action [] getActions(VCSContext ctx, VCSAnnotator.ActionDestination destination) { 427 ResourceBundle loc = NbBundle.getBundle(Annotator.class); 428 Node [] nodes = ctx.getNodes(); 429 File [] files = ctx.getRootFiles().toArray(new File [ctx.getRootFiles().size()]); 430 Lookup context = Lookups.fixed(ctx.getNodes()); 431 boolean noneVersioned = isNothingVersioned(files); 432 boolean onlyFolders = onlyFolders(files); 433 boolean onlyProjects = onlyProjects(ctx.getNodes()); 434 435 List <Action> actions = new ArrayList<Action>(20); 436 if (destination == VCSAnnotator.ActionDestination.MainMenu) { 437 actions.add(SystemAction.get(CheckoutAction.class)); 438 actions.add(SystemAction.get(ImportAction.class)); 439 actions.add(new RelocateAction(loc.getString("CTL_MenuItem_Relocate"), ctx)); 440 actions.add(null); 441 actions.add(SystemAction.get(UpdateWithDependenciesAction.class)); 442 actions.add(null); 443 actions.add(SystemAction.get(StatusAction.class)); 444 actions.add(SystemAction.get(DiffAction.class)); 445 actions.add(SystemAction.get(UpdateAction.class)); 446 actions.add(SystemAction.get(CommitAction.class)); 447 actions.add(null); 448 actions.add(SystemAction.get(ExportDiffAction.class)); 449 actions.add(null); 450 actions.add(SystemAction.get(CreateCopyAction.class)); 451 actions.add(SystemAction.get(SwitchToAction.class)); 452 actions.add(SystemAction.get(MergeAction.class)); 453 actions.add(null); 454 actions.add(SystemAction.get(BlameAction.class)); 455 actions.add(SystemAction.get(SearchHistoryAction.class)); 456 actions.add(null); 457 actions.add(SystemAction.get(RevertModificationsAction.class)); 458 actions.add(SystemAction.get(ResolveConflictsAction.class)); 459 actions.add(SystemAction.get(IgnoreAction.class)); 460 actions.add(null); 461 actions.add(SystemAction.get(SvnPropertiesAction.class)); 462 } else { 463 if (noneVersioned) { 464 actions.add(SystemActionBridge.createAction(SystemAction.get(ImportAction.class).createContextAwareInstance(context), loc.getString("CTL_PopupMenuItem_Import"), context)); 465 } else { 466 actions.add(SystemActionBridge.createAction(SystemAction.get(StatusAction.class), loc.getString("CTL_PopupMenuItem_Status"), context)); 467 actions.add(SystemActionBridge.createAction(SystemAction.get(DiffAction.class), loc.getString("CTL_PopupMenuItem_Diff"), context)); 468 actions.add(SystemActionBridge.createAction(SystemAction.get(UpdateAction.class), loc.getString("CTL_PopupMenuItem_Update"), context)); 469 if (onlyProjects) { 470 actions.add(new SystemActionBridge(SystemAction.get(UpdateWithDependenciesAction.class), loc.getString("CTL_PopupMenuItem_UpdateWithDeps"))); 471 } 472 actions.add(SystemActionBridge.createAction(SystemAction.get(CommitAction.class), loc.getString("CTL_PopupMenuItem_Commit"), context)); 473 actions.add(null); 474 actions.add(SystemActionBridge.createAction(SystemAction.get(CreateCopyAction.class), loc.getString("CTL_PopupMenuItem_Copy"), context)); 475 actions.add(SystemActionBridge.createAction(SystemAction.get(SwitchToAction.class), loc.getString("CTL_PopupMenuItem_Switch"), context)); 476 actions.add(SystemActionBridge.createAction(SystemAction.get(MergeAction.class), loc.getString("CTL_PopupMenuItem_Merge"), context)); 477 actions.add(null); 478 if (!onlyFolders) { 479 actions.add(SystemActionBridge.createAction(SystemAction.get(BlameAction.class), 480 ((BlameAction)SystemAction.get(BlameAction.class)).visible(nodes) ? 481 loc.getString("CTL_PopupMenuItem_HideAnnotations") : 482 loc.getString("CTL_PopupMenuItem_ShowAnnotations"), context)); 483 } 484 actions.add(SystemActionBridge.createAction(SystemAction.get(SearchHistoryAction.class), loc.getString("CTL_PopupMenuItem_SearchHistory"), context)); 485 actions.add(null); 486 actions.add(SystemActionBridge.createAction(SystemAction.get(RevertModificationsAction.class), loc.getString("CTL_PopupMenuItem_GetClean"), context)); 487 actions.add(SystemActionBridge.createAction(SystemAction.get(ResolveConflictsAction.class), loc.getString("CTL_PopupMenuItem_ResolveConflicts"), context)); 488 if (!onlyProjects) { 489 actions.add(SystemActionBridge.createAction(SystemAction.get(IgnoreAction.class), 490 ((IgnoreAction)SystemAction.get(IgnoreAction.class)).getActionStatus(nodes) == IgnoreAction.UNIGNORING ? 491 loc.getString("CTL_PopupMenuItem_Unignore") : 492 loc.getString("CTL_PopupMenuItem_Ignore"), context)); 493 } 494 actions.add(null); 495 actions.add(SystemActionBridge.createAction( 496 SystemAction.get(SvnPropertiesAction.class), 497 loc.getString("CTL_PopupMenuItem_Properties"), context)); 498 } 499 } 500 return actions.toArray(new Action[actions.size()]); 501 } 502 503 private static boolean isNothingVersioned(File [] files) { 504 FileStatusCache cache = Subversion.getInstance().getStatusCache(); 505 for (File file : files) { 506 if ((cache.getStatus(file).getStatus() & FileInformation.STATUS_MANAGED) != 0) return false; 507 } 508 return true; 509 } 510 511 private static boolean onlyProjects(Node[] nodes) { 512 if (nodes == null) return false; 513 for (Node node : nodes) { 514 if (node.getLookup().lookup(Project.class) == null) return false; 515 } 516 return true; 517 } 518 519 private static boolean onlyFolders(File [] files) { 520 FileStatusCache cache = Subversion.getInstance().getStatusCache(); 521 for (int i = 0; i < files.length; i++) { 522 if (files[i].isFile()) return false; 523 if (!files[i].exists() && !cache.getStatus(files[i]).isDirectory()) return false; 524 } 525 return true; 526 } 527 528 private static MessageFormat getFormat(String key) { 529 String format = NbBundle.getMessage(Annotator.class, key); 530 return new MessageFormat (format); 531 } 532 533 private static final int STATUS_BADGEABLE = FileInformation.STATUS_VERSIONED_UPTODATE | FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY | FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY; 534 535 public Image annotateIcon(Image icon, VCSContext context) { 536 boolean folderAnnotation = false; 537 for (File file : context.getRootFiles()) { 538 if (file.isDirectory()) { 539 folderAnnotation = true; 540 break; 541 } 542 } 543 544 if (folderAnnotation == false && context.getRootFiles().size() > 1) { 545 folderAnnotation = !Utils.shareCommonDataObject(context.getRootFiles().toArray(new File [context.getRootFiles().size()])); 546 } 547 548 if (folderAnnotation == false) { 549 return null; 550 } 551 552 FileStatusCache cache = Subversion.getInstance().getStatusCache(); 553 boolean isVersioned = false; 554 for (Iterator i = context.getRootFiles().iterator(); i.hasNext();) { 555 File file = (File ) i.next(); 556 if ((cache.getStatus(file).getStatus() & STATUS_BADGEABLE) != 0) { 557 isVersioned = true; 558 break; 559 } 560 } 561 if (!isVersioned) return null; 562 563 SvnModuleConfig config = SvnModuleConfig.getDefault(); 564 boolean allExcluded = true; 565 boolean modified = false; 566 567 Map map = cache.getAllModifiedFiles(); 568 Map<File , FileInformation> modifiedFiles = new HashMap<File , FileInformation>(); 569 for (Iterator i = map.keySet().iterator(); i.hasNext();) { 570 File file = (File ) i.next(); 571 FileInformation info = (FileInformation) map.get(file); 572 if ((info.getStatus() & FileInformation.STATUS_LOCAL_CHANGE) != 0) modifiedFiles.put(file, info); 573 } 574 575 for (Iterator i = context.getRootFiles().iterator(); i.hasNext();) { 576 File file = (File ) i.next(); 577 if (file instanceof FlatFolder) { 578 for (Iterator j = modifiedFiles.keySet().iterator(); j.hasNext();) { 579 File mf = (File ) j.next(); 580 if (mf.getParentFile().equals(file)) { 581 FileInformation info = (FileInformation) modifiedFiles.get(mf); 582 if (info.isDirectory()) continue; 583 int status = info.getStatus(); 584 if (status == FileInformation.STATUS_VERSIONED_CONFLICT) { 585 Image badge = Utilities.loadImage("org/netbeans/modules/versioning/system/cvss/resources/icons/conflicts-badge.png", true); return Utilities.mergeImages(icon, badge, 16, 9); 587 } 588 modified = true; 589 allExcluded &= config.isExcludedFromCommit(mf.getAbsolutePath()); 590 } 591 } 592 } else { 593 for (Iterator j = modifiedFiles.keySet().iterator(); j.hasNext();) { 594 File mf = (File ) j.next(); 595 if (Utils.isParentOrEqual(file, mf)) { 596 FileInformation info = (FileInformation) modifiedFiles.get(mf); 597 int status = info.getStatus(); 598 if ((status == FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY || status == FileInformation.STATUS_VERSIONED_ADDEDLOCALLY) && file.equals(mf)) { 599 continue; 600 } 601 if (status == FileInformation.STATUS_VERSIONED_CONFLICT) { 602 Image badge = Utilities.loadImage("org/netbeans/modules/versioning/system/cvss/resources/icons/conflicts-badge.png", true); return Utilities.mergeImages(icon, badge, 16, 9); 604 } 605 modified = true; 606 allExcluded &= config.isExcludedFromCommit(mf.getAbsolutePath()); 607 } 608 } 609 } 610 } 611 612 if (modified && !allExcluded) { 613 Image badge = Utilities.loadImage("org/netbeans/modules/versioning/system/cvss/resources/icons/modified-badge.png", true); return Utilities.mergeImages(icon, badge, 16, 9); 615 } else { 616 return null; 617 } 618 } 619 620 } 621 | Popular Tags |