use of com.intellij.openapi.wm.ToolWindow in project intellij-plugins by JetBrains.
the class ActionScriptProfileRunner method startProfiling.
private static void startProfiling(final String runConfigurationName, final Module module) {
if (!initProfilingAgent(module)) {
return;
}
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(module.getProject());
if (toolWindowManager == null) {
return;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOLWINDOW_ID);
if (toolWindow == null) {
toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM, module.getProject());
final ContentManager contentManager = toolWindow.getContentManager();
contentManager.addContentManagerListener(new ContentManagerAdapter() {
@Override
public void contentRemoved(ContentManagerEvent event) {
super.contentRemoved(event);
if (contentManager.getContentCount() == 0) {
toolWindowManager.unregisterToolWindow(TOOLWINDOW_ID);
}
}
});
}
final ActionScriptProfileControlPanel profileControlPanel = new ActionScriptProfileControlPanel(runConfigurationName, module);
final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
toolWindowPanel.setContent(profileControlPanel.getMainPanel());
final Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel, runConfigurationName, false);
toolWindow.getContentManager().addContent(content);
toolWindow.getContentManager().setSelectedContent(content);
content.setDisposer(profileControlPanel);
final DefaultActionGroup actionGroup = profileControlPanel.createProfilerActionGroup();
actionGroup.addSeparator();
final AnAction closeTabAction = new TabbedContentAction.CloseAction(content);
closeTabAction.getTemplatePresentation().setIcon(AllIcons.Actions.Cancel);
actionGroup.add(closeTabAction);
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("FlexProfiler", actionGroup, false);
toolbar.setTargetComponent(toolWindowPanel);
toolWindowPanel.setToolbar(toolbar.getComponent());
final ToolWindow finalToolWindow = toolWindow;
profileControlPanel.setConnectionCallback(() -> {
finalToolWindow.show(null);
removePreloadingOfProfilerSwf();
});
toolWindow.hide(null);
profileControlPanel.startProfiling();
}
});
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-plugins by JetBrains.
the class BaseToolWindow method expandToolWindow.
public void expandToolWindow() {
final Semaphore semaphore = new Semaphore(1);
semaphore.tryAcquire();
UIUtil.invokeLater(() -> {
ToolWindow window = myToolWindowManager.getToolWindow(getToolWindowId());
if (window != null) {
window.show(() -> semaphore.release());
} else {
semaphore.release();
}
});
waitForOpen(semaphore);
}
use of com.intellij.openapi.wm.ToolWindow in project android by JetBrains.
the class EditorFixture method getThemePreview.
/**
* Returns a fixture around the theme preview window, <b>if</b> the currently edited file
* is a styles file and if the XML editor tab of the layout is currently showing.
*
* @param switchToTabIfNecessary if true, switch to the editor tab if it is not already showing
* @return the theme preview fixture
*/
@Nullable
public ThemePreviewFixture getThemePreview(boolean switchToTabIfNecessary) {
VirtualFile currentFile = getCurrentFile();
if (ResourceHelper.getFolderType(currentFile) != ResourceFolderType.VALUES) {
return null;
}
if (switchToTabIfNecessary) {
selectEditorTab(Tab.EDITOR);
}
boolean visible = GuiQuery.getNonNull(() -> ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview").isActive());
if (!visible) {
myFrame.invokeMenuPath("View", "Tool Windows", "Theme Preview");
}
Wait.seconds(1).expecting("Theme Preview window to be visible").until(() -> GuiQuery.getNonNull(() -> {
ToolWindow window = ToolWindowManager.getInstance(myFrame.getProject()).getToolWindow("Theme Preview");
return window != null && window.isVisible();
}));
// Wait for it to be fully opened
robot.waitForIdle();
return new ThemePreviewFixture(robot, myFrame.getProject());
}
use of com.intellij.openapi.wm.ToolWindow in project intellij-plugins by JetBrains.
the class DartPubActionBase method showPubOutputConsole.
private static void showPubOutputConsole(@NotNull final Module module, @NotNull final GeneralCommandLine command, @NotNull final OSProcessHandler processHandler, @NotNull final VirtualFile pubspecYamlFile, @NotNull final String actionTitle) {
final ConsoleView console;
PubToolWindowContentInfo info = findExistingInfoForCommand(module.getProject(), command);
if (info != null) {
// rerunning the same pub command in the same tool window tab (corresponding tool window action invoked)
console = info.console;
console.clear();
} else {
console = createConsole(module.getProject(), pubspecYamlFile);
info = new PubToolWindowContentInfo(module, pubspecYamlFile, command, actionTitle, console);
final ActionToolbar actionToolbar = createToolWindowActionsBar(info);
final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(false, true);
toolWindowPanel.setContent(console.getComponent());
toolWindowPanel.setToolbar(actionToolbar.getComponent());
final Content content = ContentFactory.SERVICE.getInstance().createContent(toolWindowPanel.getComponent(), actionTitle, true);
content.putUserData(PUB_TOOL_WINDOW_CONTENT_INFO_KEY, info);
Disposer.register(content, console);
final ContentManager contentManager = MessageView.SERVICE.getInstance(module.getProject()).getContentManager();
removeOldTabs(contentManager);
contentManager.addContent(content);
contentManager.setSelectedContent(content);
final ToolWindow toolWindow = ToolWindowManager.getInstance(module.getProject()).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
toolWindow.activate(null, true);
}
info.rerunPubCommandAction.setProcessHandler(processHandler);
info.stopProcessAction.setProcessHandler(processHandler);
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
console.print(IdeBundle.message("finished.with.exit.code.text.message", event.getExitCode()), ConsoleViewContentType.SYSTEM_OUTPUT);
}
});
console.print(DartBundle.message("working.dir.0", FileUtil.toSystemDependentName(pubspecYamlFile.getParent().getPath())) + "\n", ConsoleViewContentType.SYSTEM_OUTPUT);
console.attachToProcess(processHandler);
processHandler.startNotify();
}
use of com.intellij.openapi.wm.ToolWindow in project android by JetBrains.
the class AndroidDebuggerImplBase method activateDebugSessionWindow.
protected static boolean activateDebugSessionWindow(@NotNull Project project, @NotNull RunContentDescriptor descriptor) {
final ProcessHandler processHandler = descriptor.getProcessHandler();
final Content content = descriptor.getAttachedContent();
if (processHandler == null || content == null) {
return false;
}
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
if (processHandler.isProcessTerminated()) {
ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor);
return false;
}
content.getManager().setSelectedContent(content);
ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId());
window.activate(null, false, true);
return true;
}
Aggregations