From 3f50b251e6f42be2c2a4d1ac080d1a7a181ccccd Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 20 May 2010 10:46:02 +0000 Subject: [PATCH] Modified fix for focus problems git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15790 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/dependencies/DependencyView.java | 13 ++++-------- .../sysdyn/ui/editor/SysdynDiagramEditor.java | 21 +++++++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/dependencies/DependencyView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/dependencies/DependencyView.java index eb347f41..4027061f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/dependencies/DependencyView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/dependencies/DependencyView.java @@ -167,15 +167,10 @@ public class DependencyView extends ViewPart { @Override public void setFocus() { - if(component == null || (!component.isDisposed() && !component.forceFocus())) { - getBaseComposite().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if(!getBaseComposite().isDisposed()) { - getBaseComposite().setFocus(); - } - } - }); + Composite c = getBaseComposite(); + if(c != null && !c.isDisposed()) { + getBaseComposite().setFocus(); + component.setFocus(); } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java index ae757994..50575fc5 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java @@ -231,7 +231,13 @@ public class SysdynDiagramEditor extends ResourceEditorPart { canvas = new EditorCanvas(editor); frame.add(canvas); - setFocus(); + getFrameComposite().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + setFocus(); + } + }); + editor.getSelection().addSelectionListener(new ISelectionListener() { @@ -259,14 +265,11 @@ public class SysdynDiagramEditor extends ResourceEditorPart { @Override public void setFocus() { - if(canvas == null || !canvas.requestFocusInWindow()) { - getFrameComposite().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if(!getFrameComposite().isDisposed()) - getFrameComposite().setFocus(); - } - }); + Composite c = getFrameComposite(); + if(c != null && !c.isDisposed()) { + getFrameComposite().setFocus(); + if(canvas!=null) + canvas.requestFocus(); } } -- 2.47.1