From b9373dafcdb77dbe0f6dda9161684ddb978b5b7e Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 23 Feb 2012 14:13:19 +0100 Subject: [PATCH] don't hide switcher if specific UI option is set --- .../editor/EditorTabsConfigurable.form | 38 +++++++++++++++-- .../editor/EditorTabsConfigurable.java | 6 +++ .../src/com/intellij/ide/ui/UISettings.java | 1 + .../com/intellij/ide/actions/Switcher.java | 41 +++++++++++-------- 4 files changed, 65 insertions(+), 21 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form index fc88e11f7982..6b1ede8c1ed8 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.form @@ -1,9 +1,9 @@
- + - + @@ -95,7 +95,7 @@ - + @@ -220,6 +220,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java index 68a5ad08b39e..520abd9e2833 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java @@ -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); diff --git a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java b/platform/platform-api/src/com/intellij/ide/ui/UISettings.java index c8b8309a0652..01797fe0d95e 100644 --- a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java +++ b/platform/platform-api/src/com/intellij/ide/ui/UISettings.java @@ -92,6 +92,7 @@ public class UISettings implements PersistentStateComponent, 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 diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index 647c650201a0..63b0ae1525a1 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -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 {