IJPL-158442 cleanup

GitOrigin-RevId: de9a25c2a01e84aeef8bdac2eebdab34e56eaf5e
This commit is contained in:
Vladimir Krivosheev
2024-07-17 13:54:59 +02:00
committed by intellij-monorepo-bot
parent a3c6a2e2cb
commit 8d06affcc7
2 changed files with 13 additions and 17 deletions

View File

@@ -34,8 +34,7 @@ private val LOG: Logger = logger<SingleAlarm>()
* Alarm is deprecated.
* Allows scheduling a single `Runnable` instance ([task]) to be executed after a specific time interval on a specific thread.
* [request] adds a request if it's not scheduled yet, i.e., it does not delay execution of the request
* [cancelAndRequest] cancels the current request and schedules a new one instead, i.e., it delays execution of the request
*
* [cancelAndRequest] cancels the current request and schedules a new one instead, i.e., it delays execution of the request.
*/
class SingleAlarm @Internal constructor(
private val task: Runnable,

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xdebugger.impl.frame;
import com.intellij.execution.ui.layout.ViewContext;
@@ -20,50 +20,47 @@ import java.util.EventObject;
public abstract class XDebugView implements Disposable {
public enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED}
private final SingleAlarm myClearAlarm;
private final SingleAlarm clearAlarm;
private static final int VIEW_CLEAR_DELAY = 100; //ms
public XDebugView() {
myClearAlarm = new SingleAlarm(() -> clear(), VIEW_CLEAR_DELAY, this);
clearAlarm = SingleAlarm.Companion.singleEdtAlarm(VIEW_CLEAR_DELAY, this, () -> clear());
}
protected final void requestClear() {
if (ApplicationManager.getApplication().isUnitTestMode()) { // no delay in tests
if (!myClearAlarm.isDisposed()) {
// no delay in tests
if (ApplicationManager.getApplication().isUnitTestMode()) {
if (!clearAlarm.isDisposed()) {
clear();
}
}
else {
myClearAlarm.cancelAndRequest();
clearAlarm.cancelAndRequest();
}
}
@Nullable
public JComponent getMainComponent() {
public @Nullable JComponent getMainComponent() {
return null;
}
protected final void cancelClear() {
myClearAlarm.cancel();
clearAlarm.cancel();
}
protected abstract void clear();
public abstract void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session);
@Nullable
protected static XDebugSession getSession(@NotNull EventObject e) {
protected static @Nullable XDebugSession getSession(@NotNull EventObject e) {
Component component = e.getSource() instanceof Component ? (Component)e.getSource() : null;
return component == null ? null : getSession(component);
}
@Nullable
public static XDebugSession getSession(@NotNull Component component) {
public static @Nullable XDebugSession getSession(@NotNull Component component) {
return getData(XDebugSession.DATA_KEY, component);
}
@Nullable
public static <T> T getData(DataKey<T> key, @NotNull Component component) {
public static @Nullable <T> T getData(DataKey<T> key, @NotNull Component component) {
DataContext dataContext = DataManager.getInstance().getDataContext(component);
ViewContext viewContext = ViewContext.CONTEXT_KEY.getData(dataContext);
ContentManager contentManager = viewContext == null ? null : viewContext.getContentManager();