Java Code Examples for com.intellij.util.containers.ContainerUtil#reverse()

The following examples show how to use com.intellij.util.containers.ContainerUtil#reverse() . 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: MainFrame.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDetailsLoaded(@Nonnull List<VcsFullCommitDetails> detailsList) {
  List<Change> changes = ContainerUtil.newArrayList();
  List<VcsFullCommitDetails> detailsListReversed = ContainerUtil.reverse(detailsList);
  for (VcsFullCommitDetails details : detailsListReversed) {
    changes.addAll(details.getChanges());
  }
  changes = CommittedChangesTreeBrowser.zipChanges(changes);
  myChangesBrowser.setChangesToDisplay(changes);
}
 
Example 2
Source File: ProgressStripeIcon.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static AsyncProcessIcon generateIcon(@Nonnull JComponent component) {
  List<Icon> result = ContainerUtil.newArrayList();
  if (UIUtil.isUnderAquaBasedLookAndFeel() && !UIUtil.isUnderDarcula()) {
    for (int i = 0; i < 2 * JBUI.scale(GradientIcon.GRADIENT); i += JBUI.scale(TRANSLATE)) {
      result.add(new GradientIcon(component, i));
    }
  }
  else {
    for (int i = 0; i < JBUI.scale(StripeIcon.WIDTH); i += JBUI.scale(TRANSLATE)) {
      result.add(new StripeIcon(component, i));
    }
    result = ContainerUtil.reverse(result);
  }

  Icon passive = result.get(0);
  AsyncProcessIcon icon = new AsyncProcessIcon("ProgressWithStripes", result.toArray(new Icon[result.size()]), passive) {
    @Override
    public Dimension getPreferredSize() {
      return new Dimension(component.getWidth(), passive.getIconHeight());
    }
  };
  component.addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      super.componentResized(e);
      icon.revalidate();
    }
  });
  return icon;
}
 
Example 3
Source File: RecentLocationsDataModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private List<IdeDocumentHistoryImpl.PlaceInfo> getPlaces(Project project, boolean changed) {
  IdeDocumentHistory ideDocumentHistory = IdeDocumentHistory.getInstance(project);
  List<IdeDocumentHistoryImpl.PlaceInfo> infos = ContainerUtil.reverse(changed ? ideDocumentHistory.getChangePlaces() : ideDocumentHistory.getBackPlaces());

  List<IdeDocumentHistoryImpl.PlaceInfo> infosCopy = new ArrayList<>();
  for (IdeDocumentHistoryImpl.PlaceInfo info : infos) {
    if (infosCopy.stream().noneMatch(info1 -> IdeDocumentHistoryImpl.isSame(info, info1))) {
      infosCopy.add(info);
    }
  }
  return infosCopy;
}
 
Example 4
Source File: BekBranchMerger.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public List<Integer> getResult() {
  while (prepareLastPartsForBranches()) {
    step();
  }

  return ContainerUtil.reverse(myInverseResultList);
}
 
Example 5
Source File: TreeChangeImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(@Nonnull TreeChangeImpl o) {
  List<CompositeElement> thisParents = ContainerUtil.reverse(getSuperParents());
  List<CompositeElement> thatParents = ContainerUtil.reverse(o.getSuperParents());
  for (int i = 1; i <= thisParents.size() && i <= thatParents.size(); i++) {
    CompositeElement thisParent = i < thisParents.size() ? thisParents.get(i) : myParent;
    CompositeElement thatParent = i < thatParents.size() ? thatParents.get(i) : o.myParent;
    int result = compareNodePositions(thisParent, thatParent);
    if (result != 0) return result;
  }
  return 0;
}
 
Example 6
Source File: TableUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static List<Object[]> removeSelectedItems(@Nonnull JTable table, @Nullable ItemChecker applyable) {
  final TableModel model = table.getModel();
  if (!(model instanceof ItemRemovable)) {
    throw new RuntimeException("model must be instance of ItemRemovable");
  }

  if (table.getSelectionModel().isSelectionEmpty()) {
    return new ArrayList<Object[]>(0);
  }

  final List<Object[]> removedItems = new SmartList<Object[]>();
  final ItemRemovable itemRemovable = (ItemRemovable)model;
  final int columnCount = model.getColumnCount();
  doRemoveSelectedItems(table, new ItemRemovable() {
    @Override
    public void removeRow(int index) {
      Object[] row = new Object[columnCount];
      for (int column = 0; column < columnCount; column++) {
        row[column] = model.getValueAt(index, column);
      }
      removedItems.add(row);
      itemRemovable.removeRow(index);
    }
  }, applyable);
  return ContainerUtil.reverse(removedItems);
}
 
Example 7
Source File: ExpectedHighlightingData.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static <T> List<T> reverseCollection(Collection<T> infos) {
  return ContainerUtil.reverse(infos instanceof List ? (List<T>)infos : new ArrayList<T>(infos));
}