Search in sources :

Example 1 with VcsRefType

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())));
            }
        }
    }
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) MultiMap(com.intellij.util.containers.MultiMap) RefGroup(com.intellij.vcs.log.RefGroup)

Example 2 with VcsRefType

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);
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with VcsRefType

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;
    }
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) MultiMap(com.intellij.util.containers.MultiMap) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with VcsRefType

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();
}
Also used : VcsRefType(com.intellij.vcs.log.VcsRefType) VcsRef(com.intellij.vcs.log.VcsRef) JBLabel(com.intellij.ui.components.JBLabel) Collection(java.util.Collection) LabelIcon(com.intellij.vcs.log.ui.render.LabelIcon) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap)

Aggregations

VcsRefType (com.intellij.vcs.log.VcsRefType)4 MultiMap (com.intellij.util.containers.MultiMap)3 VcsRef (com.intellij.vcs.log.VcsRef)3 JBLabel (com.intellij.ui.components.JBLabel)1 RefGroup (com.intellij.vcs.log.RefGroup)1 LabelIcon (com.intellij.vcs.log.ui.render.LabelIcon)1 Collection (java.util.Collection)1 Map (java.util.Map)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1