mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-145126 an option to hide 'tool window' buttons
Step 2: Restore sidebar button automatically when toolwindow is open
This commit is contained in:
@@ -68,7 +68,7 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
|
||||
private final ToggleWindowedModeAction myToggleWindowedModeAction;
|
||||
private final ToggleSideModeAction myToggleSideModeAction;
|
||||
private final ToggleContentUiTypeAction myToggleContentUiTypeAction;
|
||||
private final ToggleShowStripeButtonAction myToggleShowStipeButtonAction;
|
||||
private final RemoveStripeButtonAction myHideStripeButtonAction;
|
||||
|
||||
private ActionGroup myAdditionalGearActions;
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
|
||||
myToggleDockModeAction = new ToggleDockModeAction();
|
||||
myToggleAutoHideModeAction = new TogglePinnedModeAction();
|
||||
myToggleContentUiTypeAction = new ToggleContentUiTypeAction();
|
||||
myToggleShowStipeButtonAction = new ToggleShowStripeButtonAction();
|
||||
myHideStripeButtonAction = new RemoveStripeButtonAction();
|
||||
myToggleToolbarGroup = ToggleToolbarAction.createToggleToolbarGroup(myProject, myToolWindow);
|
||||
|
||||
myHeader = new ToolWindowHeader(toolWindow, info, new Producer<ActionGroup>() {
|
||||
@@ -173,7 +173,6 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
|
||||
else { // docked and floating windows don't have divider
|
||||
remove(myDivider);
|
||||
}
|
||||
myHeader.updateHideButton();
|
||||
|
||||
validate();
|
||||
repaint();
|
||||
@@ -458,7 +457,7 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
|
||||
group.add(myToggleWindowedModeAction);
|
||||
group.add(myToggleSideModeAction);
|
||||
}
|
||||
group.add(myToggleShowStipeButtonAction);
|
||||
group.add(myHideStripeButtonAction);
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -641,26 +640,22 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
|
||||
}
|
||||
}
|
||||
|
||||
private final class ToggleShowStripeButtonAction extends AnAction implements DumbAware {
|
||||
public ToggleShowStripeButtonAction() {
|
||||
private final class RemoveStripeButtonAction extends AnAction implements DumbAware {
|
||||
public RemoveStripeButtonAction() {
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
presentation.setText(ActionsBundle.message("action.ToggleShowStripeButton.text"));
|
||||
presentation.setDescription(ActionsBundle.message("action.ToggleShowStripeButton.description"));
|
||||
presentation.setText(ActionsBundle.message("action.RemoveStripeButton.text"));
|
||||
presentation.setDescription(ActionsBundle.message("action.RemoveStripeButton.description"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
e.getPresentation().setText(myInfo.isShowStripeButton()
|
||||
? ActionsBundle.message("action.ToggleShowStripeButton.text")
|
||||
: ActionsBundle.message("action.ToggleShowStripeButton.text2"));
|
||||
e.getPresentation().setEnabledAndVisible(!myInfo.isFloating() && !myInfo.isWindowed());
|
||||
e.getPresentation().setEnabledAndVisible(myInfo.isShowStripeButton());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
boolean newState = !myInfo.isShowStripeButton();
|
||||
fireVisibleOnPanelChanged(newState);
|
||||
if (!newState && getToolWindow().isActive()) {
|
||||
fireVisibleOnPanelChanged(false);
|
||||
if (getToolWindow().isActive()) {
|
||||
fireHidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,9 +301,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
}
|
||||
|
||||
private static Icon getHideToolWindowIcon(ToolWindow toolWindow) {
|
||||
if (!toolWindow.isShowStripeButton()) {
|
||||
return AllIcons.Actions.Close;
|
||||
}
|
||||
ToolWindowAnchor anchor = toolWindow.getAnchor();
|
||||
if (anchor == ToolWindowAnchor.BOTTOM) {
|
||||
return AllIcons.General.HideDownPart;
|
||||
@@ -316,9 +313,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
}
|
||||
|
||||
private static Icon getHideIcon(ToolWindow toolWindow) {
|
||||
if (!toolWindow.isShowStripeButton()) {
|
||||
return AllIcons.Actions.Close;
|
||||
}
|
||||
ToolWindowAnchor anchor = toolWindow.getAnchor();
|
||||
if (anchor == ToolWindowAnchor.BOTTOM) {
|
||||
return AllIcons.General.HideDown;
|
||||
@@ -331,9 +325,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
}
|
||||
|
||||
private static Icon getHideToolWindowHoveredIcon(ToolWindow toolWindow) {
|
||||
if (!toolWindow.isShowStripeButton()) {
|
||||
return AllIcons.Actions.CloseHovered;
|
||||
}
|
||||
ToolWindowAnchor anchor = toolWindow.getAnchor();
|
||||
if (anchor == ToolWindowAnchor.BOTTOM) {
|
||||
return AllIcons.General.HideDownPartHover;
|
||||
@@ -346,9 +337,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
}
|
||||
|
||||
private static Icon getHideHoveredIcon(ToolWindow toolWindow) {
|
||||
if (!toolWindow.isShowStripeButton()) {
|
||||
return AllIcons.Actions.CloseHovered;
|
||||
}
|
||||
ToolWindowAnchor anchor = toolWindow.getAnchor();
|
||||
if (anchor == ToolWindowAnchor.BOTTOM) {
|
||||
return AllIcons.General.HideDownHover;
|
||||
@@ -450,10 +438,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
return new Dimension(size.width, TabsUtil.getTabsHeight());
|
||||
}
|
||||
|
||||
public void updateHideButton() {
|
||||
myHideButton.updateIcon();
|
||||
}
|
||||
|
||||
private class ActionButton extends Wrapper implements ActionListener, AltStateManager.AltListener {
|
||||
private final InplaceButton myButton;
|
||||
private final AnAction myAction;
|
||||
@@ -487,7 +471,7 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
setContent(myButton);
|
||||
setOpaque(false);
|
||||
|
||||
updateIcon();
|
||||
setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(), getActiveHoveredIcon());
|
||||
|
||||
PropertyChangeListener listener = new PropertyChangeListener() {
|
||||
@Override
|
||||
@@ -508,10 +492,6 @@ public abstract class ToolWindowHeader extends JPanel implements Disposable, UIS
|
||||
addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
private void updateIcon() {
|
||||
setIcon(getActiveIcon(), getInactiveIcon() == null ? getActiveIcon() : getInactiveIcon(), getActiveHoveredIcon());
|
||||
}
|
||||
|
||||
public void updateTooltip() {
|
||||
myButton.setToolTipText(getToolTipTextByAction(myCurrentAction));
|
||||
}
|
||||
|
||||
@@ -1124,6 +1124,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
mySideStack.remove(id);
|
||||
}
|
||||
|
||||
if (!toBeShownInfo.isShowStripeButton()) {
|
||||
toBeShownInfo.setShowStripeButton(true);
|
||||
}
|
||||
|
||||
appendApplyWindowInfoCmd(toBeShownInfo, commandsList);
|
||||
}
|
||||
|
||||
|
||||
@@ -856,9 +856,8 @@ action.ToggleSideMode.text=Split Mode
|
||||
action.ToggleSideMode.description=Tool windows split mode on/off
|
||||
action.ToggleContentUiTypeMode.text=Group Tabs
|
||||
action.ToggleContentUiTypeMode.description=Toggle between tabbed/combo presentation of contents
|
||||
action.ToggleShowStripeButton.text=Remove from Sidebar
|
||||
action.ToggleShowStripeButton.text2=Keep in Sidebar
|
||||
action.ToggleShowStripeButton.description=Show/hide tool window button from panel
|
||||
action.RemoveStripeButton.text=Remove from Sidebar
|
||||
action.RemoveStripeButton.description=Remove tool window button from sidebar
|
||||
action.ShowContent.text=Show List of Tabs
|
||||
action.ShowContent.description=Show a popup with the list of toolwindow tabs
|
||||
group.ResizeToolWindowGroup.text=Resize
|
||||
|
||||
Reference in New Issue
Block a user