From 4d27b2b54e960cbb9cbd00848045fb65bd5e2984 Mon Sep 17 00:00:00 2001 From: nik Date: Fri, 14 Apr 2017 20:40:52 +0300 Subject: [PATCH] 'Project Structure' dialog: request focus in content entry editor only on explicit user action (IDEA-170432) --- .../CommonContentEntriesEditor.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java index 1560fd97ea6c..16fe5b9a40bc 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/CommonContentEntriesEditor.java @@ -208,7 +208,7 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { for (final ContentEntry contentEntry : contentEntries) { addContentEntryPanel(contentEntry.getUrl()); } - selectContentEntry(contentEntries[0].getUrl()); + selectContentEntry(contentEntries[0].getUrl(), false); } } @@ -261,8 +261,11 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { }; } - void selectContentEntry(final String contentEntryUrl) { + void selectContentEntry(final String contentEntryUrl, boolean requestFocus) { if (mySelectedEntryUrl != null && mySelectedEntryUrl.equals(contentEntryUrl)) { + if (requestFocus) { + myRootTreeEditor.requestFocus(); + } return; } try { @@ -281,7 +284,9 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { final JComponent scroller = (JComponent)component.getParent(); SwingUtilities.invokeLater(() -> scroller.scrollRectToVisible(component.getBounds())); myRootTreeEditor.setContentEntryEditor(editor); - myRootTreeEditor.requestFocus(); + if (requestFocus) { + myRootTreeEditor.requestFocus(); + } } } } @@ -346,13 +351,13 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { } myEditorsPanel.revalidate(); myEditorsPanel.repaint(); - selectContentEntry(contentEntriesArray[contentEntriesArray.length - 1].getUrl()); + selectContentEntry(contentEntriesArray[contentEntriesArray.length - 1].getUrl(), false); } private final class MyContentEntryEditorListener extends ContentEntryEditorListenerAdapter { @Override public void editingStarted(@NotNull ContentEntryEditor editor) { - selectContentEntry(editor.getContentEntryUrl()); + selectContentEntry(editor.getContentEntryUrl(), true); } @Override @@ -363,21 +368,14 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor { } final String nextContentEntryUrl = getNextContentEntry(entryUrl); removeContentEntryPanel(entryUrl); - selectContentEntry(nextContentEntryUrl); + selectContentEntry(nextContentEntryUrl, true); editor.removeContentEntryEditorListener(this); } @Override public void navigationRequested(@NotNull ContentEntryEditor editor, VirtualFile file) { - if (mySelectedEntryUrl != null && mySelectedEntryUrl.equals(editor.getContentEntryUrl())) { - myRootTreeEditor.requestFocus(); - myRootTreeEditor.select(file); - } - else { - selectContentEntry(editor.getContentEntryUrl()); - myRootTreeEditor.requestFocus(); - myRootTreeEditor.select(file); - } + selectContentEntry(editor.getContentEntryUrl(), true); + myRootTreeEditor.select(file); } private void removeContentEntryPanel(final String contentEntryUrl) {