branchPopup: remove prefix info rendering; add special icons instead

* add special label icons for current branch/bookmarks;
* remove ugly prefix info from popup rendering;
* cleanUp;
* IDEA-174360 hard to distinguish current branch label and branch label
 then the node is selected;
* IDEA-175167 current label and branch name are not aligned;
This commit is contained in:
Nadya Zabrodina
2017-08-18 19:29:10 +03:00
parent f3b17e7dcd
commit a7def4b8a9
10 changed files with 24 additions and 36 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

@@ -19,19 +19,29 @@ import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.LayeredIcon;
import com.intellij.util.ui.EmptyIcon;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import static icons.DvcsImplIcons.*;
public abstract class BranchActionGroup extends ActionGroup implements DumbAware {
private boolean myIsFavorite;
private final LayeredIcon myIcon;
private final LayeredIcon myHoveredIcon;
private LayeredIcon myIcon;
private LayeredIcon myHoveredIcon;
public BranchActionGroup() {
super("", true);
myIcon = new LayeredIcon(Favorite, EmptyIcon.ICON_16);
myHoveredIcon = new LayeredIcon(FavoriteOnHover, NotFavoriteOnHover);
setIcons(Favorite, EmptyIcon.ICON_16, FavoriteOnHover, NotFavoriteOnHover);
}
protected void setIcons(@NotNull Icon favorite,
@NotNull Icon notFavorite,
@NotNull Icon favoriteOnHover,
@NotNull Icon notFavoriteOnHover) {
myIcon = new LayeredIcon(favorite, notFavorite);
myHoveredIcon = new LayeredIcon(favoriteOnHover, notFavoriteOnHover);
getTemplatePresentation().setIcon(myIcon);
getTemplatePresentation().setHoveredIcon(myHoveredIcon);
updateIcons();
@@ -339,7 +339,6 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
private class MyPopupListElementRenderer extends PopupListElementRenderer<Object> implements IconListPopupRenderer {
private ErrorLabel myPrefixLabel;
private ErrorLabel myInfoLabel;
private IconComponent myIconLabel;
@@ -378,7 +377,6 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
}
myIconLabel.setIcon(myDescriptor.getIconFor(value));
PopupElementWithAdditionalInfo additionalInfoAction = getSpecificAction(value, PopupElementWithAdditionalInfo.class);
updateInfoComponent(myPrefixLabel, additionalInfoAction != null ? additionalInfoAction.getPrefixInfo() : null, isSelected);
updateInfoComponent(myInfoLabel, additionalInfoAction != null ? additionalInfoAction.getInfoText() : null, isSelected);
}
@@ -402,12 +400,6 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
@Override
protected JComponent createItemComponent() {
myPrefixLabel = new ErrorLabel();
myPrefixLabel.setOpaque(true);
myPrefixLabel.setBorder(JBUI.Borders.empty(1, 1, 1, DEFAULT_HGAP));
Font minusOneFont = FontUtil.minusOne(myPrefixLabel.getFont());
myPrefixLabel.setFont(minusOneFont);
myTextLabel = new ErrorLabel();
myTextLabel.setOpaque(true);
myTextLabel.setBorder(JBUI.Borders.empty(1));
@@ -415,7 +407,7 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
myInfoLabel = new ErrorLabel();
myInfoLabel.setOpaque(true);
myInfoLabel.setBorder(JBUI.Borders.empty(1, DEFAULT_HGAP, 1, 1));
myInfoLabel.setFont(minusOneFont);
myInfoLabel.setFont(FontUtil.minusOne(myInfoLabel.getFont()));
JPanel compoundPanel = new OpaquePanel(new BorderLayout(), JBColor.WHITE);
myIconLabel = new IconComponent();
@@ -425,7 +417,6 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
compoundPanel.add(myIconLabel, BorderLayout.WEST);
textPanel.add(myTextLabel, BorderLayout.WEST);
textPanel.add(myInfoLabel, BorderLayout.CENTER);
compoundTextPanel.add(myPrefixLabel, BorderLayout.WEST);
compoundTextPanel.add(textPanel, BorderLayout.CENTER);
compoundPanel.add(compoundTextPanel, BorderLayout.CENTER);
return layoutComponent(compoundPanel);
@@ -552,7 +543,7 @@ public class BranchActionGroupPopup extends FlatSpeedSearchPopup {
public MyToolbarButton(@NotNull String text, @NotNull Icon icon, @NotNull Icon rolloverIcon, @NotNull ActionListener buttonListener) {
super(icon);
setToolTipText(text);
setBorder(IdeBorderFactory.createEmptyBorder());
setBorder(JBUI.Borders.empty());
setBorderPainted(false);
setContentAreaFilled(false);
setOpaque(false);
@@ -20,7 +20,4 @@ import org.jetbrains.annotations.Nullable;
public interface PopupElementWithAdditionalInfo {
@Nullable
default String getInfoText() {return null;}
@Nullable
default String getPrefixInfo() {return null;}
}
@@ -14,6 +14,8 @@ public class DvcsImplIcons {
}
public static final Icon CherryPick = load("/icons/cherryPick.png"); // 16x16
public static final Icon CurrentBranchFavoriteLabel = load("/icons/currentBranchFavoriteLabel.png"); // 16x16
public static final Icon CurrentBranchLabel = load("/icons/currentBranchLabel.png"); // 16x16
public static final Icon Favorite = load("/icons/favorite.png"); // 16x16
public static final Icon FavoriteOnHover = load("/icons/favoriteOnHover.png"); // 16x16
public static final Icon NotFavoriteOnHover = load("/icons/notFavoriteOnHover.png"); // 16x16
@@ -37,6 +37,7 @@ import git4idea.branch.GitBranchesCollection;
import git4idea.branch.GitNewBranchOptions;
import git4idea.repo.GitRepository;
import git4idea.validators.GitNewBranchNameValidator;
import icons.DvcsImplIcons;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -337,6 +338,7 @@ class GitBranchPopupActions {
@NotNull String branchName,
@NotNull GitRepository selectedRepository) {
super(project, repositories, branchName, selectedRepository);
setIcons(DvcsImplIcons.CurrentBranchFavoriteLabel, DvcsImplIcons.CurrentBranchLabel, DvcsImplIcons.FavoriteOnHover, DvcsImplIcons.NotFavoriteOnHover);
}
@NotNull
@@ -344,12 +346,6 @@ class GitBranchPopupActions {
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return new AnAction[]{new LocalBranchActions.RenameBranchAction(myProject, myRepositories, myBranchName)};
}
@Nullable
@Override
public String getPrefixInfo() {
return "current";
}
}
/**
@@ -38,6 +38,7 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.impl.HashImpl;
import icons.DvcsImplIcons;
import one.util.streamex.StreamEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -289,6 +290,8 @@ public class HgBranchPopupActions {
public static class CurrentBranch extends BranchActions implements PopupElementWithAdditionalInfo {
public CurrentBranch(@NotNull Project project, @NotNull List<HgRepository> repositories, @NotNull String branchName) {
super(project, repositories, branchName);
setIcons(DvcsImplIcons.CurrentBranchFavoriteLabel, DvcsImplIcons.CurrentBranchLabel, DvcsImplIcons.FavoriteOnHover,
DvcsImplIcons.NotFavoriteOnHover);
}
@NotNull
@@ -296,12 +299,6 @@ public class HgBranchPopupActions {
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return AnAction.EMPTY_ARRAY;
}
@Nullable
@Override
public String getPrefixInfo() {
return "current";
}
}
/**
@@ -340,6 +337,7 @@ public class HgBranchPopupActions {
public CurrentActiveBookmark(@NotNull Project project, @NotNull List<HgRepository> repositories, @NotNull String branchName) {
super(project, repositories, branchName);
setIcons(DvcsImplIcons.CurrentBranchFavoriteLabel, DvcsImplIcons.CurrentBranchLabel, DvcsImplIcons.FavoriteOnHover, DvcsImplIcons.NotFavoriteOnHover);
}
@NotNull
@@ -347,11 +345,5 @@ public class HgBranchPopupActions {
public AnAction[] getChildren(@Nullable AnActionEvent e) {
return new AnAction[]{new BookmarkActions.DeleteBookmarkAction(myProject, myRepositories, myBranchName)};
}
@Nullable
@Override
public String getPrefixInfo() {
return "active";
}
}
}