List of usage examples for com.intellij.openapi.wm ToolWindow isVisible
boolean isVisible();
From source file:com.android.tools.idea.editors.theme.AndroidThemePreviewToolWindowManager.java
License:Apache License
private void initToolWindow() { myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT, myProject, false); myToolWindow.setIcon(AndroidIcons.ThemesPreview); myToolWindow.setAvailable(false, null); myToolWindow.setAutoHide(false);//ww w . j a v a 2 s.c o m // Add a listener so we only update the preview when it's visible ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)) .addToolWindowManagerListener(new ToolWindowManagerAdapter() { @Override public void stateChanged() { if (myProject.isDisposed()) { return; } final ToolWindow window = ToolWindowManager.getInstance(myProject) .getToolWindow(TOOL_WINDOW_ID); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible); if (visible && !myIsToolWindowVisible) { updatePreview(); } myIsToolWindowVisible = visible; } } }); }
From source file:com.android.tools.idea.monitor.AndroidToolWindowFactory.java
License:Apache License
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) { // In order to use the runner layout ui, the runner infrastructure needs to be initialized. // Otherwise it is not possible to for example drag one of the tabs out of the tool window. // The object that needs to be created is the content manager of the execution manager for this project. ExecutionManager.getInstance(project).getContentManager(); RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("Android", TOOL_WINDOW_ID, "Profiling Tools", project); toolWindow.setIcon(AndroidIcons.AndroidToolWindow); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setTitle(TOOL_WINDOW_ID); DeviceContext deviceContext = new DeviceContext(); // TODO Remove global handlers. These handlers are global, but are set per project. // if there are two projects opened, things go very wrong. ClientData.setMethodProfilingHandler(new OpenVmTraceHandler(project)); Content logcatContent = createLogcatContent(layoutUi, project, deviceContext); final AndroidLogcatView logcatView = logcatContent.getUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY); assert logcatView != null; logcatContent.setSearchComponent(logcatView.createSearchComponent()); layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false); MonitorContentFactory.createMonitorContent(project, deviceContext, layoutUi); layoutUi.getOptions().setLeftToolbar(getToolbarActions(project, deviceContext), ActionPlaces.UNKNOWN); layoutUi.addListener(new ContentManagerAdapter() { @Override// www. j ava 2 s . c o m public void selectionChanged(ContentManagerEvent event) { Content selectedContent = event.getContent(); BaseMonitorView view = selectedContent.getUserData(BaseMonitorView.MONITOR_VIEW_KEY); if (view != null && event.getOperation() == ContentManagerEvent.ContentOperation.add) { UsageTracker.getInstance() .log(AndroidStudioEvent.newBuilder() .setCategory(AndroidStudioEvent.EventCategory.PROFILING) .setKind(AndroidStudioEvent.EventKind.MONITOR_RUNNING) .setMonitorType(view.getMonitorType())); } } }, project); final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project); DevicePanel devicePanel = new DevicePanel(project, deviceContext); JPanel panel = devicePanel.getComponent(); panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); loadingPanel.add(panel, BorderLayout.NORTH); loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER); final ContentManager contentManager = toolWindow.getContentManager(); Content c = contentManager.getFactory().createContent(loadingPanel, "", true); // Store references to the logcat & device panel views, so that these views can be retrieved directly from // the DDMS tool window. (e.g. to clear logcat before a launch, select a particular device, etc) c.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView); c.putUserData(DEVICES_PANEL_KEY, devicePanel); contentManager.addContent(c); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { logcatView.activate(); final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); if (window != null && window.isVisible()) { ConsoleView console = logcatView.getLogConsole().getConsole(); if (console != null) { checkFacetAndSdk(project, console); } } } }, project.getDisposed()); final File adb = AndroidSdkUtils.getAdb(project); if (adb == null) { return; } loadingPanel.setLoadingText("Initializing ADB"); loadingPanel.startLoading(); ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb); Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() { @Override public void onSuccess(@Nullable AndroidDebugBridge bridge) { Logger.getInstance(AndroidToolWindowFactory.class).info("Successfully obtained debug bridge"); loadingPanel.stopLoading(); } @Override public void onFailure(@NotNull Throwable t) { loadingPanel.stopLoading(); // If we cannot connect to ADB in a reasonable amount of time (10 seconds timeout in AdbService), then something is seriously // wrong. The only identified reason so far is that some machines have incompatible versions of adb that were already running. // e.g. Genymotion, some HTC flashing software, Ubuntu's adb package may all conflict with the version of adb in the SDK. Logger.getInstance(AndroidToolWindowFactory.class).info("Unable to obtain debug bridge", t); String msg; if (t.getMessage() != null) { msg = t.getMessage(); } else { msg = String.format("Unable to establish a connection to adb.\n\n" + "Check the Event Log for possible issues.\n" + "This can happen if you have an incompatible version of adb running already.\n" + "Try re-opening %1$s after killing any existing adb daemons.\n\n" + "If this happens repeatedly, please file a bug at http://b.android.com including the following:\n" + " 1. Output of the command: '%2$s devices'\n" + " 2. Your idea.log file (Help | Show Log in Explorer)\n", ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath()); } Messages.showErrorDialog(msg, "ADB Connection Error"); } }, EdtExecutor.INSTANCE); }
From source file:com.android.tools.idea.monitor.AndroidToolWindowFactory.java
License:Apache License
private static Content createLogcatContent(RunnerLayoutUi layoutUi, final Project project, DeviceContext deviceContext) {// w ww. j av a 2 s . co m final AndroidLogcatView logcatView = new AndroidLogcatView(project, deviceContext) { @Override protected boolean isActive() { ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); return window.isVisible(); } }; ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(new ToolWindowManagerAdapter() { boolean myToolWindowVisible; @Override public void stateChanged() { ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID); if (window != null) { boolean visible = window.isVisible(); if (visible != myToolWindowVisible) { myToolWindowVisible = visible; logcatView.activate(); if (visible) { ConsoleView console = logcatView.getLogConsole().getConsole(); if (console != null) { checkFacetAndSdk(project, console); } } } } } }); final MessageBusConnection connection = project.getMessageBus().connect(project); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyAndroidPlatformListener(logcatView)); JPanel logcatContentPanel = logcatView.getContentPanel(); final Content logcatContent = layoutUi.createContent(ANDROID_LOGCAT_CONTENT_ID, logcatContentPanel, "logcat", AndroidIcons.Ddms.Logcat, null); logcatContent.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView); logcatContent.setDisposer(logcatView); logcatContent.setCloseable(false); logcatContent.setPreferredFocusableComponent(logcatContentPanel); return logcatContent; }
From source file:com.android.tools.idea.run.util.LaunchUtils.java
License:Apache License
public static void showNotification(@NotNull final Project project, @NotNull final Executor executor, @NotNull final String sessionName, @NotNull final String message, @NotNull final NotificationType type) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override/*from w ww.ja v a 2 s .com*/ public void run() { if (project.isDisposed()) { return; } String toolWindowId = executor.getToolWindowId(); final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(toolWindowId); if (toolWindow.isVisible()) { return; } final String notificationMessage = "Session <a href=''>'" + sessionName + "'</a>: " + message; NotificationGroup group = getNotificationGroup(toolWindowId); group.createNotification("", notificationMessage, type, new NotificationListener() { @Override public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final RunContentManager contentManager = ExecutionManager.getInstance(project) .getContentManager(); for (RunContentDescriptor d : contentManager.getAllDescriptors()) { if (sessionName.equals(d.getDisplayName())) { final Content content = d.getAttachedContent(); if (content != null) { content.getManager().setSelectedContent(content); } toolWindow.activate(null, true, true); break; } } } } }).notify(project); } @NotNull private NotificationGroup getNotificationGroup(@NotNull String toolWindowId) { String displayId = "Launch Notifications for " + toolWindowId; NotificationGroup group = NotificationGroup.findRegisteredGroup(displayId); if (group == null) { group = NotificationGroup.toolWindowGroup(displayId, toolWindowId); } return group; } }); }
From source file:com.android.tools.idea.tests.gui.framework.fixture.EditorFixture.java
License:Apache License
/** * 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/* w w w.j ava 2s. c om*/ */ @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()); }
From source file:com.android.tools.idea.uibuilder.editor.NlPreviewManager.java
License:Apache License
protected void initToolWindow() { myToolWindowForm = new NlPreviewForm(this); final String toolWindowId = getToolWindowId(); myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(toolWindowId, false, ToolWindowAnchor.RIGHT, myProject, true); myToolWindow.setIcon(AndroidIcons.AndroidPreview); ((ToolWindowManagerEx) ToolWindowManager.getInstance(myProject)) .addToolWindowManagerListener(new ToolWindowManagerAdapter() { @Override//ww w.j a v a 2 s. c o m public void stateChanged() { if (myProject.isDisposed()) { return; } final ToolWindow window = ToolWindowManager.getInstance(myProject) .getToolWindow(toolWindowId); if (window != null && window.isAvailable()) { final boolean visible = window.isVisible(); AndroidEditorSettings.getInstance().getGlobalState().setVisible(visible); if (myToolWindowForm != null) { if (visible) { myToolWindowForm.activate(); } else { myToolWindowForm.deactivate(); } } } } }); final JComponent contentPanel = myToolWindowForm.getComponent(); final ContentManager contentManager = myToolWindow.getContentManager(); @SuppressWarnings("ConstantConditions") final Content content = contentManager.getFactory().createContent(contentPanel, null, false); content.setDisposer(myToolWindowForm); content.setCloseable(false); content.setPreferredFocusableComponent(contentPanel); contentManager.addContent(content); contentManager.setSelectedContent(content, true); myToolWindow.setAvailable(false, null); myToolWindowForm.setUseInteractiveSelector(isUseInteractiveSelector()); }
From source file:com.atlassian.theplugin.idea.PluginToolWindow.java
License:Apache License
public static void showHidePluginWindow(AnActionEvent event) { ToolWindow tw = IdeaHelper.getToolWindow(IdeaHelper.getCurrentProject(event.getDataContext())); if (tw != null) { if (tw.isVisible()) { tw.hide(new Runnable() { public void run() { }/*from www. j ava 2s. co m*/ }); } else { tw.show(new Runnable() { public void run() { } }); } } }
From source file:com.eightbitmage.moonscript.util.MoonSystemUtil.java
License:Apache License
private static void activateConsoleToolWindow(@NotNull Project project) { final ToolWindowManager manager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = manager.getToolWindow(toolWindowId); if (toolWindow != null) { return;/*from w w w.ja v a 2 s . c om*/ } toolWindow = manager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM); final ConsoleView console = new ConsoleViewImpl(project, false); project.putUserData(CONSOLE_VIEW_KEY, console); toolWindow.getContentManager().addContent(new ContentImpl(console.getComponent(), "", false)); final ToolWindowManagerListener listener = new ToolWindowManagerListener() { @Override public void toolWindowRegistered(@NotNull String id) { } @Override public void stateChanged() { ToolWindow window = manager.getToolWindow(toolWindowId); if (window != null && !window.isVisible()) { manager.unregisterToolWindow(toolWindowId); ((ToolWindowManagerEx) manager).removeToolWindowManagerListener(this); } } }; toolWindow.show(new Runnable() { @Override public void run() { ((ToolWindowManagerEx) manager).addToolWindowManagerListener(listener); } }); }
From source file:com.facebook.buck.intellij.ideabuck.ui.BuckToolWindowFactory.java
License:Apache License
public static boolean isToolWindowVisible(Project project, String toolWindowId) { ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(toolWindowId); return toolWindow == null || toolWindow.isVisible(); }
From source file:com.facebook.buck.intellij.ideabuck.ui.components.BuckToolWindowImpl.java
License:Apache License
private boolean isToolWindowVisible(ToolWindow toolWindow) { return toolWindow != null && toolWindow.isVisible(); }