use of com.intellij.openapi.vcs.CachingCommittedChangesProvider in project intellij-community by JetBrains.
the class CommittedChangeListRenderer method renderChangeList.
public void renderChangeList(JComponent tree, CommittedChangeList changeList) {
final Container parent = tree.getParent();
final int rowX = getRowX(myTree, 2);
int availableWidth = parent == null ? 100 : parent.getWidth() - rowX;
final FontMetrics fontMetrics = tree.getFontMetrics(tree.getFont());
final FontMetrics boldMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.BOLD));
final FontMetrics italicMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.ITALIC));
if (myDateWidth <= 0 || (fontMetrics.getFont().getSize() != myFontSize)) {
myDateWidth = Math.max(fontMetrics.stringWidth(", Yesterday 00:00 PM "), fontMetrics.stringWidth(", 00/00/00 00:00 PM "));
myDateWidth = Math.max(myDateWidth, fontMetrics.stringWidth(getDateOfChangeList(new Date(2000, 11, 31))));
myFontSize = fontMetrics.getFont().getSize();
}
int dateCommitterSize = myDateWidth + boldMetrics.stringWidth(changeList.getCommitterName());
final Pair<String, Boolean> descriptionInfo = getDescriptionOfChangeList(changeList.getName().trim());
boolean truncated = descriptionInfo.getSecond().booleanValue();
String description = descriptionInfo.getFirst();
for (CommittedChangeListDecorator decorator : myDecorators) {
final Icon icon = decorator.decorate(changeList);
if (icon != null) {
setIcon(icon);
}
}
int descMaxWidth = availableWidth - dateCommitterSize - 8;
boolean partial = (changeList instanceof ReceivedChangeList) && ((ReceivedChangeList) changeList).isPartial();
int descWidth = 0;
int partialMarkerWidth = 0;
if (partial) {
final String partialMarker = VcsBundle.message("committed.changes.partial.list") + " ";
append(partialMarker, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
partialMarkerWidth = boldMetrics.stringWidth(partialMarker);
descWidth += partialMarkerWidth;
}
descWidth += fontMetrics.stringWidth(description);
int numberWidth = 0;
final AbstractVcs vcs = changeList.getVcs();
if (vcs != null) {
final CachingCommittedChangesProvider provider = vcs.getCachingCommittedChangesProvider();
if (provider != null && provider.getChangelistTitle() != null) {
String number = "#" + changeList.getNumber() + " ";
numberWidth = fontMetrics.stringWidth(number);
descWidth += numberWidth;
append(number, SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
int branchWidth = 0;
String branch = changeList.getBranch();
if (branch != null) {
branch += " ";
branchWidth = italicMetrics.stringWidth(branch);
descWidth += branchWidth;
append(branch, SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
}
if (description.isEmpty() && !truncated) {
append(VcsBundle.message("committed.changes.empty.comment"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
appendTextPadding(descMaxWidth);
} else if (descMaxWidth < 0) {
myRenderer.appendTextWithLinks(description);
} else if (descWidth < descMaxWidth && !truncated) {
myRenderer.appendTextWithLinks(description);
appendTextPadding(descMaxWidth);
} else {
final String moreMarker = VcsBundle.message("changes.browser.details.marker");
int moreWidth = fontMetrics.stringWidth(moreMarker);
int remainingWidth = descMaxWidth - moreWidth - numberWidth - branchWidth - partialMarkerWidth;
description = truncateDescription(description, fontMetrics, remainingWidth);
myRenderer.appendTextWithLinks(description);
if (!StringUtil.isEmpty(description)) {
append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
append(moreMarker, SimpleTextAttributes.LINK_ATTRIBUTES, new CommittedChangesTreeBrowser.MoreLauncher(myProject, changeList));
} else if (remainingWidth > 0) {
append(moreMarker, SimpleTextAttributes.LINK_ATTRIBUTES, new CommittedChangesTreeBrowser.MoreLauncher(myProject, changeList));
}
// align value is for the latest added piece
appendTextPadding(descMaxWidth);
}
append(changeList.getCommitterName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
if (changeList.getCommitDate() != null) {
String date = ", " + getDateOfChangeList(changeList.getCommitDate());
append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
use of com.intellij.openapi.vcs.CachingCommittedChangesProvider in project intellij-community by JetBrains.
the class HgBrowseChangesTest method doTest.
private void doTest() throws HgCommandException, VcsException {
CachingCommittedChangesProvider provider = myVcs.getCachingCommittedChangesProvider();
assert provider != null;
//noinspection unchecked
List<CommittedChangeList> revisions = provider.getCommittedChanges(mySettings, new HgRepositoryLocation(myRepository.getUrl(), myRepository), -1);
assertTrue(!revisions.isEmpty());
}
Aggregations