don't hide switcher if specific UI option is set

This commit is contained in:
Konstantin Bulenkov
2012-02-23 14:15:38 +01:00
parent 09a9f593fc
commit b9373dafcd
4 changed files with 65 additions and 21 deletions
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.editor.EditorTabsConfigurable">
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="535"/>
<xy x="20" y="20" width="500" height="537"/>
</constraints>
<properties/>
<border type="none"/>
@@ -95,7 +95,7 @@
</grid>
<vspacer id="651b4">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="eb8d0" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="10">
@@ -220,6 +220,38 @@
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="62e6f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="10">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$BoldSmallWithIndent"/>
</clientProperties>
<border type="none" title="Other"/>
<children>
<grid id="21198" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="8131a" class="javax.swing.JCheckBox" binding="mySwitcherPolicy">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Hide Tab Switcher on button release"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
</grid>
<buttonGroups>
@@ -44,6 +44,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider {
private JCheckBox myShowCloseButtonOnCheckBox;
private JCheckBox myShowDirectoryInTabCheckBox;
private JRadioButton myActivateRightNeighbouringTabRadioButton;
private JCheckBox mySwitcherPolicy;
public EditorTabsConfigurable() {
myEditorTabPlacement.setModel(new DefaultComboBoxModel(new Object[]{
@@ -100,6 +101,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider {
myShowDirectoryInTabCheckBox.setSelected(uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES);
myEditorTabLimitField.setText(Integer.toString(uiSettings.EDITOR_TAB_LIMIT));
myShowCloseButtonOnCheckBox.setSelected(uiSettings.SHOW_CLOSE_BUTTON);
mySwitcherPolicy.setSelected(uiSettings.HIDE_SWITCHER_ON_CONTROL_RELEASE);
if (uiSettings.CLOSE_NON_MODIFIED_FILES_FIRST) {
myCloseNonModifiedFilesFirstRadio.setSelected(true);
@@ -130,6 +132,9 @@ public class EditorTabsConfigurable implements EditorOptionsProvider {
if (isModified(myShowCloseButtonOnCheckBox, uiSettings.SHOW_CLOSE_BUTTON)) uiSettingsChanged = true;
uiSettings.SHOW_CLOSE_BUTTON = myShowCloseButtonOnCheckBox.isSelected();
if (isModified(mySwitcherPolicy, uiSettings.HIDE_SWITCHER_ON_CONTROL_RELEASE)) uiSettingsChanged = true;
uiSettings.HIDE_SWITCHER_ON_CONTROL_RELEASE = mySwitcherPolicy.isSelected();
final int tabPlacement = ((Integer)myEditorTabPlacement.getSelectedItem()).intValue();
if (uiSettings.EDITOR_TAB_PLACEMENT != tabPlacement) uiSettingsChanged = true;
uiSettings.EDITOR_TAB_PLACEMENT = tabPlacement;
@@ -172,6 +177,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider {
isModified |= myScrollTabLayoutInEditorCheckBox.isSelected() != uiSettings.SCROLL_TAB_LAYOUT_IN_EDITOR;
isModified |= myShowCloseButtonOnCheckBox.isSelected() != uiSettings.SHOW_CLOSE_BUTTON;
isModified |= mySwitcherPolicy.isSelected() != uiSettings.HIDE_SWITCHER_ON_CONTROL_RELEASE;
isModified |= isModified(myCloseNonModifiedFilesFirstRadio, uiSettings.CLOSE_NON_MODIFIED_FILES_FIRST);
isModified |= isModified(myActivateMRUEditorOnCloseRadio, uiSettings.ACTIVATE_MRU_EDITOR_ON_CLOSE);
@@ -92,6 +92,7 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
public int MAX_LOOKUP_WIDTH = 500;
public int MAX_LOOKUP_LIST_HEIGHT = 11;
public boolean HIDE_NAVIGATION_ON_FOCUS_LOSS = true;
public boolean HIDE_SWITCHER_ON_CONTROL_RELEASE = true;
/**
* Defines whether asterisk is shown on modified editor tab or not
@@ -17,6 +17,7 @@ package com.intellij.ide.actions;
import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.markup.EffectType;
@@ -113,23 +114,25 @@ public class Switcher extends AnAction implements DumbAware {
}
TW_SHORTCUT = new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()]));
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
@Override
public boolean dispatch(AWTEvent event) {
ToolWindow tw;
if (SWITCHER != null && event instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent)event;
if (event.getID() == KEY_RELEASED && keyEvent.getKeyCode() == CTRL_KEY) {
SwingUtilities.invokeLater(CHECKER);
}
else if (event.getID() == KEY_PRESSED && (tw = SWITCHER.twShortcuts.get(String.valueOf((char)keyEvent.getKeyCode()))) != null) {
SWITCHER.myPopup.closeOk(null);
tw.activate(null, true, true);
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
@Override
public boolean dispatch(AWTEvent event) {
ToolWindow tw;
if (SWITCHER != null && event instanceof KeyEvent) {
final KeyEvent keyEvent = (KeyEvent)event;
if (event.getID() == KEY_RELEASED && keyEvent.getKeyCode() == CTRL_KEY && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) {
SwingUtilities.invokeLater(CHECKER);
}
else if (event.getID() == KEY_PRESSED && (tw = SWITCHER.twShortcuts.get(String.valueOf((char)keyEvent.getKeyCode()))) != null) {
SWITCHER.myPopup.closeOk(null);
tw.activate(null, true, true);
}
}
return false;
}
return false;
}
}, null);
}, null);
}
@NonNls private static final String SWITCHER_TITLE = "Switcher";
@@ -148,6 +151,7 @@ public class Switcher extends AnAction implements DumbAware {
}
}
assert SWITCHER != null;
if (e.getInputEvent().isShiftDown()) {
SWITCHER.goBack();
} else {
@@ -437,7 +441,8 @@ public class Switcher extends AnAction implements DumbAware {
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == CTRL_KEY || e.getKeyCode() == VK_ENTER) {
if ((e.getKeyCode() == CTRL_KEY && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE)
|| e.getKeyCode() == VK_ENTER) {
navigate();
} else
if (e.getKeyCode() == VK_LEFT) {
@@ -541,7 +546,7 @@ public class Switcher extends AnAction implements DumbAware {
}
private void goRight() {
if (isFilesSelected() || !isFilesVisible()) {
if ((isFilesSelected() || !isFilesVisible()) && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) {
cancel();
}
else {
@@ -557,7 +562,7 @@ public class Switcher extends AnAction implements DumbAware {
}
private void goLeft() {
if (isToolWindowsSelected()) {
if (isToolWindowsSelected() && UISettings.getInstance().HIDE_SWITCHER_ON_CONTROL_RELEASE) {
cancel();
}
else {