From 9ee14bb143098fd29d499d931345353c6e13ac0f Mon Sep 17 00:00:00 2001 From: Roman Nikitenko Date: Thu, 10 Aug 2017 16:57:53 +0300 Subject: [PATCH] CHE-5274. Do not skip setting focus on element when window was already displayed Signed-off-by: Roman Nikitenko --- .../org/eclipse/che/ide/ui/window/Window.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/window/Window.java b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/window/Window.java index 77e2e9ad164..32762e82270 100644 --- a/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/window/Window.java +++ b/ide/che-core-ide-ui/src/main/java/org/eclipse/che/ide/ui/window/Window.java @@ -224,6 +224,7 @@ public void show(@Nullable final Focusable selectAndFocusElement) { setBlocked(false); if (isShowing) { + setFocusOn(selectAndFocusElement);//the window is displayed but focus for the element may be lost return; } @@ -247,14 +248,22 @@ public void show(@Nullable final Focusable selectAndFocusElement) { public void execute() { // The popup may have been hidden before this timer executes. view.setShowing(true); - if (selectAndFocusElement != null) { - selectAndFocusElement.setFocus(true); - } + setFocusOn(selectAndFocusElement); } }); } } + /** + * Sets focus on the given element. + * If {@code elementToFocus} is {@code null}, no element will be given focus + */ + private void setFocusOn(@Nullable Focusable elementToFocus) { + if (elementToFocus != null) { + elementToFocus.setFocus(true); + } + } + private void handleViewEvents() { view.setDelegate(new ViewEvents() { @Override