Set initial focus on options tree in configure code style on selected fragment dialog

This commit is contained in:
Yaroslav Lepenkin
2015-04-08 18:14:39 +03:00
parent f35e6e9045
commit 1012d92756
2 changed files with 17 additions and 1 deletions
@@ -39,6 +39,7 @@ class CodeFragmentCodeStyleSettingsPanel extends TabbedLanguageCodeStylePanel {
private final CodeStyleSettingsCodeFragmentFilter.CodeStyleSettingsToShow mySettingsToShow;
private final SelectedTextFormatter mySelectedTextFormatter;
private SpacesPanelWithoutPreview mySpacesPanel;
public CodeFragmentCodeStyleSettingsPanel(@NotNull CodeStyleSettings settings,
@NotNull CodeStyleSettingsCodeFragmentFilter.CodeStyleSettingsToShow settingsToShow,
@@ -63,11 +64,16 @@ class CodeFragmentCodeStyleSettingsPanel extends TabbedLanguageCodeStylePanel {
@Override
protected void initTabs(CodeStyleSettings settings) {
addTab(new SpacesPanelWithoutPreview(settings));
mySpacesPanel = new SpacesPanelWithoutPreview(settings);
addTab(mySpacesPanel);
addTab(new WrappingAndBracesPanelWithoutPreview(settings));
reset(getSettings());
}
public JComponent getPreferredFocusedComponent() {
return mySpacesPanel.getPreferredFocusedComponent();
}
public static CodeStyleSettingsCodeFragmentFilter.CodeStyleSettingsToShow calcSettingNamesToShow(CodeStyleSettingsCodeFragmentFilter filter) {
return filter.getFieldNamesAffectingCodeFragment(SPACING_SETTINGS, WRAPPING_AND_BRACES_SETTINGS);
}
@@ -129,6 +135,10 @@ class CodeFragmentCodeStyleSettingsPanel extends TabbedLanguageCodeStylePanel {
protected String getPreviewText() {
return null;
}
public JComponent getPreferredFocusedComponent() {
return myOptionsTree;
}
}
private class WrappingAndBracesPanelWithoutPreview extends MyWrappingAndBracesPanel {
@@ -121,6 +121,12 @@ public class ConfigureCodeStyleOnSelectedFragment implements IntentionAction {
init();
}
@Nullable
@Override
public JComponent getPreferredFocusedComponent() {
return myTabbedLanguagePanel.getPreferredFocusedComponent();
}
@Nullable
@Override
protected JComponent createCenterPanel() {