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) {