Source:
<code>private static void handleTraceContentChanged(TmfTraceElement traceElement) { Display.getDefault().asyncExec(() -> { boolean opened = false; for (ITmfTrace openedTrace : TmfTraceManager.getInstance().getOpenedTraces()) { for (ITmfTrace trace : TmfTraceManager.getTraceSet(openedTrace)) { if (traceElement.getResource().equals(trace.getResource())) { opened = true; break; } } } if (!opened) { traceElement.deleteSupplementaryResources(); return; } if (!promptQueue.isEmpty()) { if (!promptQueue.contains(traceElement)) { promptQueue.add(traceElement); } return; } promptQueue.add(traceElement); while (!promptQueue.isEmpty()) { <START> TmfTraceElement prompting = promptQueue.poll(); <END> boolean always = Activator.getDefault().getPreferenceStore().getBoolean(ITmfUIPreferences.DELETE_RESOURCE_REFRESH); if (always) { prompting.closeEditors(); prompting.deleteSupplementaryResources(); } else { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog messageDialog = new MessageDialog(shell, Messages.TmfProjectRegistry_TraceChangedDialogTitle, null, NLS.bind(Messages.TmfProjectRegistry_TraceChangedDialogMessage, prompting.getName()), MessageDialog.QUESTION, 2, IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL); int returnCode = messageDialog.open(); if (returnCode >= 1) { prompting.closeEditors(); prompting.deleteSupplementaryResources(); } if (returnCode == 2) { Activator.getDefault().getPreferenceStore().setValue(ITmfUIPreferences.DELETE_RESOURCE_REFRESH, true); } } } }); }</code><technical_language>element remain in queue while prompting user, another element handled added queue instead of opening another dialog, prevent user prompted for element</technical_language>

Target:
private static void handleTraceContentChanged(TmfTraceElement traceElement) { Display.getDefault().asyncExec(() -> { boolean opened = false; for (ITmfTrace openedTrace : TmfTraceManager.getInstance().getOpenedTraces()) { for (ITmfTrace trace : TmfTraceManager.getTraceSet(openedTrace)) { if (traceElement.getResource().equals(trace.getResource())) { opened = true; break; } } } if (!opened) { traceElement.deleteSupplementaryResources(); return; } if (!promptQueue.isEmpty()) { if (!promptQueue.contains(traceElement)) { promptQueue.add(traceElement); } return; } promptQueue.add(traceElement); TmfTraceElement prompting = traceElement; while (prompting != null) { boolean always = Activator.getDefault().getPreferenceStore().getBoolean(ITmfUIPreferences.ALWAYS_CLOSE_ON_RESOURCE_CHANGE); if (always) { prompting.closeEditors(); prompting.deleteSupplementaryResources(); } else { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog messageDialog = new MessageDialog(shell, Messages.TmfProjectRegistry_TraceChangedDialogTitle, null, NLS.bind(Messages.TmfProjectRegistry_TraceChangedDialogMessage, prompting.getElementPath()), MessageDialog.QUESTION, 2, IDialogConstants.NO_LABEL, IDialogConstants.YES_LABEL, Messages.TmfProjectRegistry_Always); int returnCode = messageDialog.open(); if (returnCode >= 1) { prompting.closeEditors(); prompting.deleteSupplementaryResources(); } if (returnCode == 2) { Activator.getDefault().getPreferenceStore().setValue(ITmfUIPreferences.ALWAYS_CLOSE_ON_RESOURCE_CHANGE, true); } } prompting = promptQueue.poll(); } }); }