use of com.intellij.vcs.log.VcsRefType in project intellij-community by JetBrains.
the class SimpleRefGroup method buildGroups.
public static void buildGroups(@NotNull MultiMap<VcsRefType, VcsRef> groupedRefs, boolean compact, boolean showTagNames, @NotNull List<RefGroup> result) {
if (groupedRefs.isEmpty())
return;
if (compact) {
VcsRef firstRef = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(groupedRefs.values()));
RefGroup group = ContainerUtil.getFirstItem(result);
if (group == null) {
result.add(new SimpleRefGroup(firstRef.getType().isBranch() || showTagNames ? firstRef.getName() : "", ContainerUtil.newArrayList(groupedRefs.values())));
} else {
group.getRefs().addAll(groupedRefs.values());
}
} else {
for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) {
if (entry.getKey().isBranch()) {
for (VcsRef ref : entry.getValue()) {
result.add(new SimpleRefGroup(ref.getName(), ContainerUtil.newArrayList(ref)));
}
} else {
result.add(new SimpleRefGroup(showTagNames ? ObjectUtils.notNull(ContainerUtil.getFirstItem(entry.getValue())).getName() : "", ContainerUtil.newArrayList(entry.getValue())));
}
}
}
}
use of com.intellij.vcs.log.VcsRefType in project intellij-community by JetBrains.
the class RefParser method createRef.
// example input: fb29c80 refs/tags/92.29
@Nullable
private VcsRef createRef(@NotNull Hash hash, @NotNull String longRefPath, @NotNull VirtualFile root) {
String name = getRefName(longRefPath);
VcsRefType type = GitRefManager.getRefType(name);
assert type != null;
return myFactory.createRef(hash, GitBranchUtil.stripRefsPrefix(name), type, root);
}
use of com.intellij.vcs.log.VcsRefType in project intellij-community by JetBrains.
the class SimpleRefGroup method getColors.
@NotNull
public static List<Color> getColors(@NotNull Collection<VcsRef> refs) {
MultiMap<VcsRefType, VcsRef> referencesByType = ContainerUtil.groupBy(refs, VcsRef::getType);
if (referencesByType.size() == 1) {
Map.Entry<VcsRefType, Collection<VcsRef>> firstItem = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(referencesByType.entrySet()));
boolean multiple = firstItem.getValue().size() > 1;
Color color = firstItem.getKey().getBackgroundColor();
return multiple ? Arrays.asList(color, color) : Collections.singletonList(color);
} else {
List<Color> colorsList = ContainerUtil.newArrayList();
for (VcsRefType type : referencesByType.keySet()) {
if (referencesByType.get(type).size() > 1) {
colorsList.add(type.getBackgroundColor());
}
colorsList.add(type.getBackgroundColor());
}
return colorsList;
}
}
use of com.intellij.vcs.log.VcsRefType in project intellij-community by JetBrains.
the class ReferencesPanel method update.
public void update() {
removeAll();
int height = getIconHeight();
JBLabel firstLabel = null;
for (Map.Entry<VcsRefType, Collection<VcsRef>> typeAndRefs : myGroupedVisibleReferences.entrySet()) {
VcsRefType type = typeAndRefs.getKey();
Collection<VcsRef> refs = typeAndRefs.getValue();
int refIndex = 0;
for (VcsRef reference : refs) {
Icon icon = createIcon(type, refs, refIndex, height);
String ending = (refIndex != refs.size() - 1) ? "," : "";
String text = reference.getName() + ending;
JBLabel label = createLabel(text, icon);
if (firstLabel == null) {
firstLabel = label;
add(label);
} else {
addWrapped(label, firstLabel);
}
refIndex++;
}
}
if (getHiddenReferencesSize() > 0) {
JBLabel label = createRestLabel(getHiddenReferencesSize());
addWrapped(label, ObjectUtils.assertNotNull(firstLabel));
}
setVisible(!myGroupedVisibleReferences.isEmpty());
revalidate();
repaint();
}
Aggregations