How to create own BranchActionGroupPopup?

Answered

Hi, This one is a little bit hard to explain and maybe much harder to solve. I have created my own GitBranchPopup-Menu which extends from MyDvcsBranchPopup. Why do i need this?: I need a branch-selector, but in my case i dont need multiple actions (Checkout, New branch from selected, ... Push, Rename, ect)

i need a flat menu instead. i was able to create this. but unfortunately if you collapse the list tho only show favs

it is not longer possible to search over the collapsed items (with visible items it works):

 

If you show all items in the list it works with all list items again:

 

I think the Problem is

HideableActionGroup

https://bitbucket.org/comodmw/git-scope/src/b4e3118c332e5ad4b8b7cf0f5a0e80fc10f42cf1/src/main/java/implementation/targetBranchWidget/MyBranchActionGroupPopup.java#lines-320

which needs to be implemented as a *group* action. i cannot use this as is, because i pass my own

myBranchAction

which is not compatible, so i need to write my own (this whole thing ended with 7 classes :-) https://bitbucket.org/comodmw/git-scope/src/TargetBranchPopup/src/main/java/implementation/targetBranchWidget/ )

who can help me to finish this method?

 

    private HideableActionGroup(@NotNull MyBranchAction myBranchAction, @NotNull MoreAction moreAction) {
super(new ActionGroup() {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
// return new AnAction[]{myBranchAction};
if (!moreAction.isExpanded()) {
// myBranchAction
// return new AnAction[]{myBranchAction};
// return new AnAction[]{new EmptyAction(myBranchAction)};
// @todo Searchable Actions
return new AnAction[]{new EmptyAction()};
} else {
return new AnAction[]{myBranchAction};
}
}
});
myMoreAction = moreAction;
}

Thanks!

0
4 comments

If you need to dramatically change this popup, it is easier not to extend it.

You can use `JBPopupFactory.getInstance().createActionGroupPopup()` and have full control over actions in it.
See also `GitRepositoryManager` and `GitRepository.getBranches`.

0

Everything fits, including the favorite and show / hide feature - that would be the only thing left :-) - but I'll take a closer look

0

For the record, you're doing it at your own risk.
These internals are not an API and might be changed without any notice.

0

Please sign in to leave a comment.