/* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object other) { if (this == other) return true; if (!(other instanceof CVSCompareSubscriber)) return false; CVSCompareSubscriber s = (CVSCompareSubscriber) other; CVSResourceVariantTree tree1 = (CVSResourceVariantTree) getRemoteTree(); CVSResourceVariantTree tree2 = (CVSResourceVariantTree) s.getRemoteTree(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); CVSTag tag1 = tree1.getTag(root); CVSTag tag2 = tree2.getTag(root); if (tag1 == null || tag2 == null) return false; return tag1.equals(tag2) && rootsEqual(s); }
public CVSCompareSubscriber(IResource[] resources, CVSTag tag) { super( getUniqueId(), NLS.bind(CVSMessages.CVSCompareSubscriber_2, new String[] {tag.getName()})); // this.resources = resources; tree = new CVSResourceVariantTree( new SessionResourceVariantByteStore(), tag, getCacheFileContentsHint()); initialize(); }
/** * Given the current selection this method returns a text label that can be shown to the user that * reflects the tags in the current selection. These can be used in the <b>Compare With</b> and * <b>Replace With</b> actions. */ protected String calculateActionTagValue() { try { IResource[] resources = getSelectedResources(); CVSTag commonTag = null; boolean sameTagType = true; boolean multipleSameNames = true; for (int i = 0; i < resources.length; i++) { ICVSResource cvsResource = getCVSResourceFor(resources[i]); CVSTag tag = null; if (cvsResource.isFolder()) { FolderSyncInfo info = ((ICVSFolder) cvsResource).getFolderSyncInfo(); if (info != null) { tag = info.getTag(); } if (tag != null && tag.getType() == CVSTag.BRANCH) { tag = Util.getAccurateFolderTag(resources[i], tag); } } else { tag = Util.getAccurateFileTag(cvsResource); } if (tag == null) { tag = new CVSTag(); } if (commonTag == null) { commonTag = tag; } else if (!commonTag.equals(tag)) { if (commonTag.getType() != tag.getType()) { sameTagType = false; } if (!commonTag.getName().equals(tag.getName())) { multipleSameNames = false; } } } // set text to default String actionText = CVSUIMessages.ReplaceWithLatestAction_multipleTags; if (commonTag != null) { int tagType = commonTag.getType(); String tagName = commonTag.getName(); // multiple tag names but of the same type if (sameTagType && !multipleSameNames) { if (tagType == CVSTag.BRANCH) { actionText = CVSUIMessages.ReplaceWithLatestAction_multipleBranches; // } else { actionText = CVSUIMessages.ReplaceWithLatestAction_multipleVersions; } // same tag names and types } else if (sameTagType && multipleSameNames) { if (tagType == CVSTag.BRANCH) { actionText = NLS.bind( CVSUIMessages.ReplaceWithLatestAction_singleBranch, new String[] {tagName}); // } else if (tagType == CVSTag.VERSION) { actionText = NLS.bind( CVSUIMessages.ReplaceWithLatestAction_singleVersion, new String[] {tagName}); } else if (tagType == CVSTag.HEAD) { actionText = NLS.bind(CVSUIMessages.ReplaceWithLatestAction_singleHEAD, new String[] {tagName}); } } } return actionText; } catch (CVSException e) { // silently ignore return CVSUIMessages.ReplaceWithLatestAction_multipleTags; // } }