Can't activate tool window right now Follow
following is my code:
ToolWindow dbg = ToolWindowManager.getInstance(e.getProject()).getToolWindow("Debug");
dbg.activate(null, true, true);
int n = 0;
while (true) {
if (dbg.isActive()) {
break;
}
try {
Thread.sleep((long) 1000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
if (n > 5) {
throw new RuntimeException("Timeout");
}
n++;
}
ContentManager cm = (ContentManager) PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(e.getDataContext());
Content sc = cm.getSelectedContent();
if (sc.getTabName().equals("Console")) {
new NextTabAction().actionPerformed(e);
} else {
new PreviousTabAction().actionPerformed(e);
}
see my screencast, why i need wait 5s to Debug actived, i hope i can activate it right now and do below steps
this code is aimed to fix my old question https://devnet.jetbrains.com/thread/458848?tstart=0
i hope to know following:
- how to get "cm" directly whenever Debug is active or not
- or how to activate tool window right now and do "next tab"
Please sign in to leave a comment.
The first parameter of the activate() method is a Runnable. If you need to perform some activity after the toolwindow is activated, you need to perform it from that runnable.
Your current code simply blocks the event dispatch thread and does not allow the Swing events involved in the toolwindow activation to be processed.
I change my code and it raise new error "ellij.ide.impl.DataManagerImpl - cannot share data context between Swing events; initial event count = 7115; current event count = 7165
following is my code:
following is my err output:
[ 107331] ERROR - ellij.ide.impl.DataManagerImpl - cannot share data context between Swing events; initial event count = 7115; current event count = 7165
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)
at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:329)
at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:75)
at ro.idea.TryAct2$1.run(TryAct2.java:50)
at com.intellij.openapi.wm.impl.ToolWindowImpl$3$1.run(ToolWindowImpl.java:150)
at com.intellij.openapi.wm.impl.commands.InvokeLaterCmd.run(InvokeLaterCmd.java:33)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:318)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:748)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:577)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:384)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
[ 107332] ERROR - ellij.ide.impl.DataManagerImpl - IntelliJ IDEA 14.0.1 Build #IU-139.225.3
[ 107333] ERROR - ellij.ide.impl.DataManagerImpl - JDK: 1.8.0_05
[ 107333] ERROR - ellij.ide.impl.DataManagerImpl - VM: Java HotSpot(TM) 64-Bit Server VM
[ 107333] ERROR - ellij.ide.impl.DataManagerImpl - Vendor: Oracle Corporation
[ 107334] ERROR - ellij.ide.impl.DataManagerImpl - OS: Linux
[ 107334] ERROR - ellij.ide.impl.DataManagerImpl - Last Action: TryAct2
[ 112349] WARN - ateSettings.impl.UpdateChecker - Connection failed. Please check your network connection and try again.
[ 234515] WARN - ewvfs.persistent.RefreshWorker - [+] fs=LocalFileSystem dir=file:///home/roroco name=ruby -e Time.now\n}
Use DataManager.getDataContextFromFocus() instead of e.getDataContext() in your runnable.
see my screencast, it's not meaningful, when i first invoke this action this "cm" in "this.cm = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dc);" is always null, following is my code:
Attachment(s):
cannot-toggle-tab-at-first-invocation.ogv.zip
I've added a new API in 14.1 that will allow to solve this cleanly (RunContentDescriptor.getRunnerLayoutUi()).
Is there youtrack that i can follow?
For what? I have already added the API.
How should i use with "RunnerDescriptor.getRunnerLayoutui"
I try getRunnerLayoutUi(), but It return null, how to get not null value, here is my code and i use groovy 2.4.3, selectedDescriptor.getRunnerUi() is null
.