Skip to content

Commit 4f4876d

Browse files
committed
Avoid direct access to deprecated focusPart field in RulerComposite
If a "FocusIn" event is fired for the RulerComposite, the contents of the RulerViewer should be focused, unless any other part has already requested focus. Rather than checking whether the deprecated field is checked, we can check whether the FOCUS flag has been set for the focused edit part. This flag is only set when setFocus(...) is called on the EditPartViewer and should therefore be set exactly when the local variable is set. Conversely, the focus should be cleared by an "FocusOut" event, unless any other part has taken the focus. Contributes to eclipse-gef#778
1 parent 7d07057 commit 4f4876d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

org.eclipse.gef/src/org/eclipse/gef/ui/rulers/RulerComposite.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2003, 2010 IBM Corporation and others.
2+
* Copyright (c) 2003, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -512,7 +512,7 @@ public void reveal(EditPart part) {
512512
*/
513513
@Override
514514
protected void handleFocusGained(FocusEvent fe) {
515-
if (focusPart == null) {
515+
if (!getFocusEditPart().hasFocus()) {
516516
setFocus(getContents());
517517
}
518518
super.handleFocusGained(fe);
@@ -525,7 +525,7 @@ protected void handleFocusGained(FocusEvent fe) {
525525
@Override
526526
protected void handleFocusLost(FocusEvent fe) {
527527
super.handleFocusLost(fe);
528-
if (focusPart == getContents()) {
528+
if (getFocusEditPart() == getContents()) {
529529
setFocus(null);
530530
}
531531
}

0 commit comments

Comments
 (0)