mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
additional actions for gear menu
This commit is contained in:
@@ -74,6 +74,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
private final ToggleSideModeAction myToggleSideModeAction;
|
||||
private final ToggleContentUiTypeAction myToggleContentUiTypeAction;
|
||||
|
||||
private ActionGroup myAdditionalGearActions;
|
||||
/**
|
||||
* Catches all event from tool window and modifies decorator's appearance.
|
||||
*/
|
||||
@@ -484,6 +485,10 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
private DefaultActionGroup createGearPopupGroup() {
|
||||
final DefaultActionGroup group = new DefaultActionGroup();
|
||||
|
||||
if (myAdditionalGearActions != null) {
|
||||
addSorted(group, myAdditionalGearActions);
|
||||
group.addSeparator();
|
||||
}
|
||||
if (myInfo.isDocked()) {
|
||||
group.add(myToggleAutoHideModeAction);
|
||||
group.add(myToggleDockModeAction);
|
||||
@@ -501,6 +506,26 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
return group;
|
||||
}
|
||||
|
||||
private static void addSorted(DefaultActionGroup main, ActionGroup group) {
|
||||
final AnAction[] children = group.getChildren(null);
|
||||
boolean hadSecondary = false;
|
||||
for (AnAction action : children) {
|
||||
if (group.isPrimary(action)) {
|
||||
main.add(action);
|
||||
} else {
|
||||
hadSecondary = true;
|
||||
}
|
||||
}
|
||||
if (hadSecondary) {
|
||||
main.addSeparator();
|
||||
for (AnAction action : children) {
|
||||
if (!group.isPrimary(action)) {
|
||||
main.addAction(action).setAsSecondary(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tool window associated with the decorator.
|
||||
*/
|
||||
@@ -834,4 +859,8 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
info.put("toolWindowTab", selection.getTabName());
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdditionalGearActions(ActionGroup additionalGearActions) {
|
||||
myAdditionalGearActions = additionalGearActions;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user