Java Code Examples for com.intellij.openapi.vcs.versionBrowser.CommittedChangeList#getNumber()

The following examples show how to use com.intellij.openapi.vcs.versionBrowser.CommittedChangeList#getNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChangeListColumn.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Comparator<CommittedChangeList> getComparator() {
  return new Comparator<CommittedChangeList>() {
    public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
      return (int)(o1.getNumber() - o2.getNumber());
    }
  };
}
 
Example 2
Source File: ChangesCacheFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateCachedRange(final CommittedChangeList list) {
  if (list.getCommitDate().getTime() > myLastCachedDate.getTime()) {
    myLastCachedDate = list.getCommitDate();
  }
  if (list.getCommitDate().getTime() < myFirstCachedDate.getTime()) {
    myFirstCachedDate = list.getCommitDate();
  }
  if (list.getNumber() < myFirstCachedChangelist) {
    myFirstCachedChangelist = list.getNumber();
  }
  if (list.getNumber() > myLastCachedChangelist) {
    myLastCachedChangelist = list.getNumber();
  }
}
 
Example 3
Source File: ChangesCacheFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void editChangelist(long number, String message) throws IOException {
  final List<CommittedChangeList> lists = new ArrayList<CommittedChangeList>();
  final List<Boolean> present = loadAllData(lists);
  for (CommittedChangeList list : lists) {
    if (list.getNumber() == number) {
      list.setDescription(message);
      break;
    }
  }
  delete();
  Collections.reverse(lists);
  Collections.reverse(present);
  writeChanges(lists, present);
}
 
Example 4
Source File: ReceivedChangeList.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ReceivedChangeList(@Nonnull CommittedChangeList baseList) {
  super(baseList.getName(), baseList.getComment(), baseList.getCommitterName(),
        baseList.getNumber(), baseList.getCommitDate(), Collections.<Change>emptyList());
  myBaseList = baseList;
  myBaseCount = baseList.getChanges().size();
  myForcePartial = false;
}
 
Example 5
Source File: ChangeListColumn.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Object getValue(final CommittedChangeList changeList) {
  return changeList.getNumber();
}
 
Example 6
Source File: VcsCommittedListsZipperAdapter.java    From consulo with Apache License 2.0 4 votes vote down vote up
public long getNumber(final CommittedChangeList list) {
  return list.getNumber();
}
 
Example 7
Source File: CommittedChangeListRenderer.java    From consulo with Apache License 2.0 4 votes vote down vote up
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;
  String date = ", " + getDateOfChangeList(changeList.getCommitDate());
  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 Image 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;
  if (partial) {
    final String partialMarker = VcsBundle.message("committed.changes.partial.list") + " ";
    append(partialMarker, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    descWidth += boldMetrics.stringWidth(partialMarker);
  }

  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);
    appendFixedTextFragmentWidth(descMaxWidth);
  }
  else if (descMaxWidth < 0) {
    myRenderer.appendTextWithLinks(description);
  }
  else if (descWidth < descMaxWidth && !truncated) {
    myRenderer.appendTextWithLinks(description);
    appendFixedTextFragmentWidth(descMaxWidth);
  }
  else {
    final String moreMarker = VcsBundle.message("changes.browser.details.marker");
    int moreWidth = fontMetrics.stringWidth(moreMarker);
    int remainingWidth = descMaxWidth - moreWidth - numberWidth - branchWidth;
    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
    appendFixedTextFragmentWidth(descMaxWidth);
  }

  append(changeList.getCommitterName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
  append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}