How to get "Watches" ContentImpl without anActionEvent.getData?

here is my code https://github.com/roroco/ro-idea/blob/get-watch-wio-event-getData/src/main/groovy/ro/idea/ToggleConsoleContent.groovy 

this action will toggle between "Debug Console  > Console" and "Debug Console > Debugger > Watches", but the question is when debug console hide and I use

e.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER)

it return null, i can't get the contentManager contains "Watches", so is there any way to get "Watches" ContentImpl when debug console invisible?

3 comments

Hi, try using another approach:

get your XDebugSession, then find watches content

Content watchesContent = xSession.getUI().findContent(DebuggerContentInfo.WATCHES_CONTENT);

then you can select it right there using

xSession.getUI().selectAndFocus(watchesContent, ...)
1

I find XDebugSession is not good idea since when debug stop, i cannot get session, here is my solution

 

Runnable callback = getSelectedDescriptor("Debug").activationCallback
XDebugSessionTab t;
for (Field f : callback.class.declaredFields) {
f.setAccessible(true)
def r = f.get(callback)
if (r instanceof XDebugSessionTab) {
t = r
break
}
}

act.cm = t.ui.contentManager
public RunContentDescriptor getSelectedDescriptor(String twn) {
ToolWindow console = twm.getToolWindow(twn)
if (console) {
Content ctn = console.contentManager.selectedContent
RunContentDescriptor selectedDescriptor

for (d in getDescriptors(twn)) {
if (d.executionId == ctn.executionId) {
selectedDescriptor = d
break
}
}
selectedDescriptor
}
}
0

Fine if it works :) Also

e.getData(XDebugSessionTab.TAB_KEY)

may give you the XDebugSessionTab more quickly (if it is opened).

Once you have it, you can getUI and do find/select Content as before

0

Please sign in to leave a comment.