From b7fc72d113b1d0a17cfe22e86f9bb0ec939838f9 Mon Sep 17 00:00:00 2001 From: "Jan S." Date: Sat, 23 Mar 2024 14:08:03 +0100 Subject: [PATCH] bugfix in isOpenClassEditor --- .../sf/feeling/decompiler/util/UIUtil.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java index b1412138..2be73a3c 100644 --- a/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java +++ b/org.sf.feeling.decompiler/src/org/sf/feeling/decompiler/util/UIUtil.java @@ -213,14 +213,9 @@ public static IWorkbenchPart getActiveEditor(boolean activePageOnly) { return activePart; } } else { - IWorkbenchPage[] pgs = window.getPages(); - - for (int i = 0; i < pgs.length; i++) { - IWorkbenchPage pg = pgs[i]; - + for (IWorkbenchPage pg : window.getPages()) { if (pg != null) { IWorkbenchPart part = pg.getActivePart(); - if (part != null) { return part; } @@ -238,16 +233,18 @@ public static boolean isOpenClassEditor() { if (windows != null) { for (int i = 0; i < windows.length; i++) { IWorkbenchWindow window = windows[i]; - IWorkbenchPage[] pgs = window.getPages(); - for (int j = 0; j < pgs.length; j++) { - IWorkbenchPage pg = pgs[j]; - if (pg != null) { - IEditorPart[] parts = pg.getEditors(); - if (parts != null) { - for (int k = 0; k < parts.length; k++) { - if (parts[i] instanceof JavaDecompilerClassFileEditor) - return true; - } + for (IWorkbenchPage pg : window.getPages()) { + if (pg == null) { + continue; + } + // Deprecated since ?? use getEditorReferences() instead + IEditorPart[] editorParts = pg.getEditors(); + if (editorParts == null) { + continue; + } + for (IEditorPart part : editorParts) { + if (part instanceof JavaDecompilerClassFileEditor) { + return true; } } }