mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reduce debugger views flickering
This commit is contained in:
@@ -147,5 +147,13 @@ public class VariablesPanel extends DebuggerTreePanel implements DataProvider {
|
||||
buildTreeAndRestoreState(stackFrame);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSessionEvent(@NotNull SessionEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,36 @@
|
||||
package com.intellij.xdebugger.impl.frame;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.util.SingleAlarm;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface XDebugView extends Disposable {
|
||||
enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED}
|
||||
public abstract class XDebugView implements Disposable {
|
||||
public enum SessionEvent {PAUSED, BEFORE_RESUME, RESUMED, STOPPED, FRAME_CHANGED, SETTINGS_CHANGED}
|
||||
|
||||
void processSessionEvent(@NotNull SessionEvent event);
|
||||
private final SingleAlarm myClearAlarm;
|
||||
private static final int VIEW_CLEAR_DELAY = 100; //ms
|
||||
|
||||
public XDebugView(Disposable disposable) {
|
||||
myClearAlarm = new SingleAlarm(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clear();
|
||||
}
|
||||
}, VIEW_CLEAR_DELAY, disposable);
|
||||
}
|
||||
|
||||
protected final void requestClear() {
|
||||
myClearAlarm.cancelAndRequest();
|
||||
}
|
||||
|
||||
protected final void cancelClear() {
|
||||
myClearAlarm.cancel();
|
||||
}
|
||||
|
||||
protected abstract void clear();
|
||||
|
||||
public abstract void processSessionEvent(@NotNull SessionEvent event);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.frame.XExecutionStack;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
@@ -53,7 +54,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XFramesView implements XDebugView {
|
||||
public class XFramesView extends XDebugView {
|
||||
private final JPanel myMainPanel;
|
||||
private final XDebuggerFramesList myFramesList;
|
||||
private final ComboBox myThreadComboBox;
|
||||
@@ -65,8 +66,10 @@ public class XFramesView implements XDebugView {
|
||||
private final ActionToolbarImpl myToolbar;
|
||||
private final Wrapper myThreadsPanel;
|
||||
private boolean myThreadsCalculated = false;
|
||||
private final TransferToEDTQueue<Runnable> myLaterInvocator = TransferToEDTQueue.createRunnableMerger("XFramesView later invocator", 50);
|
||||
|
||||
public XFramesView(@NotNull final XDebugSession session) {
|
||||
super(session.getProject());
|
||||
mySession = session;
|
||||
|
||||
myMainPanel = new JPanel(new BorderLayout());
|
||||
@@ -197,14 +200,14 @@ public class XFramesView implements XDebugView {
|
||||
myBuilders.clear();
|
||||
mySelectedStack = null;
|
||||
XSuspendContext suspendContext = mySession.getSuspendContext();
|
||||
if (suspendContext == null || event == SessionEvent.PAUSED) {
|
||||
myThreadComboBox.removeAllItems();
|
||||
myFramesList.clear();
|
||||
myThreadsCalculated = false;
|
||||
myExecutionStacks.clear();
|
||||
if (suspendContext == null) {
|
||||
return;
|
||||
}
|
||||
if (suspendContext == null) {
|
||||
requestClear();
|
||||
return;
|
||||
}
|
||||
if (event == SessionEvent.PAUSED) {
|
||||
// clear immediately
|
||||
cancelClear();
|
||||
clear();
|
||||
}
|
||||
|
||||
XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
|
||||
@@ -223,6 +226,13 @@ public class XFramesView implements XDebugView {
|
||||
myListenersEnabled = true;
|
||||
}
|
||||
|
||||
protected void clear() {
|
||||
myThreadComboBox.removeAllItems();
|
||||
myFramesList.clear();
|
||||
myThreadsCalculated = false;
|
||||
myExecutionStacks.clear();
|
||||
}
|
||||
|
||||
private void addExecutionStacks(List<? extends XExecutionStack> executionStacks) {
|
||||
for (XExecutionStack executionStack : executionStacks) {
|
||||
if (!myExecutionStacks.contains(executionStack)) {
|
||||
@@ -315,7 +325,7 @@ public class XFramesView implements XDebugView {
|
||||
|
||||
@Override
|
||||
public void addStackFrames(@NotNull final List<? extends XStackFrame> stackFrames, final boolean last) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
myLaterInvocator.offer(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myStackFrames.addAll(stackFrames);
|
||||
@@ -331,7 +341,7 @@ public class XFramesView implements XDebugView {
|
||||
|
||||
@Override
|
||||
public void errorOccurred(@NotNull final String errorMessage) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
myLaterInvocator.offer(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myErrorMessage == null) {
|
||||
|
||||
+8
@@ -42,4 +42,12 @@ public class XStandaloneVariablesView extends XVariablesViewBase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSessionEvent(@NotNull SessionEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clear() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import static com.intellij.xdebugger.impl.ui.tree.nodes.MessageTreeNode.createIn
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XVariablesView extends XVariablesViewBase implements XDebugView {
|
||||
public class XVariablesView extends XVariablesViewBase {
|
||||
@NotNull private final XDebugSession mySession;
|
||||
|
||||
public XVariablesView(@NotNull XDebugSession session) {
|
||||
@@ -50,20 +50,26 @@ public class XVariablesView extends XVariablesViewBase implements XDebugView {
|
||||
|
||||
tree.markNodesObsolete();
|
||||
if (stackFrame != null) {
|
||||
cancelClear();
|
||||
buildTreeAndRestoreState(stackFrame);
|
||||
}
|
||||
else {
|
||||
tree.setSourcePosition(null);
|
||||
|
||||
XDebuggerTreeNode node;
|
||||
if (!mySession.isStopped() && mySession.isPaused()) {
|
||||
node = createInfoMessage(tree, "Frame is not available");
|
||||
}
|
||||
else {
|
||||
XDebugProcess debugProcess = mySession.getDebugProcess();
|
||||
node = createInfoMessage(tree, debugProcess.getCurrentStateMessage(), debugProcess.getCurrentStateHyperlinkListener());
|
||||
}
|
||||
tree.setRoot(node, true);
|
||||
requestClear();
|
||||
}
|
||||
}
|
||||
|
||||
protected void clear() {
|
||||
XDebuggerTree tree = getTree();
|
||||
tree.setSourcePosition(null);
|
||||
|
||||
XDebuggerTreeNode node;
|
||||
if (!mySession.isStopped() && mySession.isPaused()) {
|
||||
node = createInfoMessage(tree, "Frame is not available");
|
||||
}
|
||||
else {
|
||||
XDebugProcess debugProcess = mySession.getDebugProcess();
|
||||
node = createInfoMessage(tree, debugProcess.getCurrentStateMessage(), debugProcess.getCurrentStateHyperlinkListener());
|
||||
}
|
||||
tree.setRoot(node, true);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -35,13 +35,14 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class XVariablesViewBase implements Disposable {
|
||||
public abstract class XVariablesViewBase extends XDebugView {
|
||||
protected final XDebuggerTreePanel myDebuggerTreePanel;
|
||||
private XDebuggerTreeState myTreeState;
|
||||
private Object myFrameEqualityObject;
|
||||
private XDebuggerTreeRestorer myTreeRestorer;
|
||||
|
||||
protected XVariablesViewBase(@NotNull Project project, @NotNull XDebuggerEditorsProvider editorsProvider, @Nullable XValueMarkers<?, ?> markers) {
|
||||
super(project);
|
||||
myDebuggerTreePanel = new XDebuggerTreePanel(project, editorsProvider, this, null, XDebuggerActions.VARIABLES_TREE_POPUP_GROUP, markers);
|
||||
myDebuggerTreePanel.getTree().getEmptyText().setText(XDebuggerBundle.message("debugger.variables.not.available"));
|
||||
DnDManager.getInstance().registerSource(myDebuggerTreePanel, myDebuggerTreePanel.getTree());
|
||||
|
||||
@@ -64,7 +64,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugView {
|
||||
public class XWatchesViewImpl extends XDebugView implements DnDNativeTarget, XWatchesView {
|
||||
private final XDebuggerTreePanel myTreePanel;
|
||||
private XDebuggerTreeState myTreeState;
|
||||
private XDebuggerTreeRestorer myTreeRestorer;
|
||||
@@ -75,6 +75,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
|
||||
private boolean myRebuildNeeded;
|
||||
|
||||
public XWatchesViewImpl(@NotNull final XDebugSessionImpl session) {
|
||||
super(session.getProject());
|
||||
mySession = session;
|
||||
myTreePanel = new XDebuggerTreePanel(session.getProject(), session.getDebugProcess().getEditorsProvider(), this, null,
|
||||
XDebuggerActions.WATCHES_TREE_POPUP_GROUP, ((XDebugSessionImpl)session).getValueMarkers());
|
||||
@@ -269,6 +270,7 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
|
||||
}
|
||||
|
||||
if (stackFrame != null) {
|
||||
cancelClear();
|
||||
tree.setSourcePosition(stackFrame.getSourcePosition());
|
||||
myRootNode.updateWatches(stackFrame.getEvaluator());
|
||||
if (myTreeState != null) {
|
||||
@@ -276,11 +278,15 @@ public class XWatchesViewImpl implements DnDNativeTarget, XWatchesView, XDebugVi
|
||||
}
|
||||
}
|
||||
else {
|
||||
tree.setSourcePosition(null);
|
||||
myRootNode.updateWatches(null);
|
||||
requestClear();
|
||||
}
|
||||
}
|
||||
|
||||
protected void clear() {
|
||||
getTree().setSourcePosition(null);
|
||||
myRootNode.updateWatches(null);
|
||||
}
|
||||
|
||||
public XDebuggerTree getTree() {
|
||||
return myTreePanel.getTree();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user