List of usage examples for com.intellij.openapi.wm ToolWindow setAvailable
void setAvailable(boolean available, @Nullable Runnable runnable);
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/*w w w . ja v a2 s.co 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.boxysystems.libraryfinder.view.intellij.actions.CloseWindowAction.java
License:Apache License
public void actionPerformed(AnActionEvent event) { Project project = (Project) event.getDataContext().getData(DataConstants.PROJECT); LibraryFinderPlugin plugin = LibraryFinderPlugin.instance(project); ToolWindow toolWindow = plugin.getToolWindow(); if (toolWindow != null) { toolWindow.hide(null);/* ww w.j a va 2 s . c om*/ toolWindow.setAvailable(false, null); } }
From source file:com.boxysystems.libraryfinder.view.intellij.IntelliJLibraryFinderView.java
License:Apache License
private void showResultsPanelInToolWindow() { ToolWindow toolWindow = ToolWindowManager.getInstance(plugin.getProject()) .getToolWindow(Constants.PLUGIN_ID); toolWindow.setAvailable(true, null); if (toolWindow.isActive()) { toolWindow.show(resultsPanel);//from w w w . j ava 2 s . c om } else { toolWindow.activate(resultsPanel); } }
From source file:com.dvd.intellijdea.materialcolorpalette.ToolWindowFactory.java
License:Apache License
@Override public void createToolWindowContent(@NotNull Project project, @NotNull com.intellij.openapi.wm.ToolWindow toolWindow) { ToolWindow newToolWindow = new ToolWindow(); Content content = ContentFactory.SERVICE.getInstance().createContent(newToolWindow, "", false); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setTitle("Material Palette"); toolWindow.getContentManager().addContent(content); }
From source file:com.facebook.buck.intellij.ideabuck.ui.BuckToolWindowFactory.java
License:Apache License
@Override public void createToolWindowContent(final Project project, ToolWindow toolWindow) { toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setIcon(BuckIcons.BUCK_TOOL_WINDOW_ICON); RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project); BuckSettingsProvider.State state = BuckSettingsProvider.getInstance().getState(); // Debug Console if (state.showDebug) { Content consoleContent = createConsoleContent(runnerLayoutUi, project); consoleContent.setCloseable(false); consoleContent.setPinnable(false); runnerLayoutUi.addContent(consoleContent, 0, PlaceInGrid.center, false); }/*from w w w . j a v a 2 s.co m*/ // Build Tree Events Content treeViewContent = runnerLayoutUi.createContent(BUILD_OUTPUT_PANEL, createBuildInfoPanel(project), "Build", null, null); treeViewContent.setCloseable(false); treeViewContent.setPinnable(false); runnerLayoutUi.addContent(treeViewContent, 0, PlaceInGrid.center, false); runnerLayoutUi.getOptions().setLeftToolbar(getLeftToolbarActions(project), ActionPlaces.UNKNOWN); runnerLayoutUi.updateActionsNow(); final ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent(runnerLayoutUi.getComponent(), "", true); contentManager.addContent(content); updateBuckToolWindowTitle(project); }
From source file:com.facebook.buck.intellij.plugin.ui.BuckToolWindowFactory.java
License:Apache License
@Override public void createToolWindowContent(final Project project, ToolWindow toolWindow) { toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project); Content consoleContent = createConsoleContent(runnerLayoutUi, project); JBTabs myTabs = new JBTabsImpl(project); // Debug Console myTabs.addTab(new TabInfo(consoleContent.getComponent())).setText("Debug"); // Build Tree Events Content treeViewContent = runnerLayoutUi.createContent(BUILD_OUTPUT_PANEL, createBuildInfoPanel(project), "Build Output", null, null); myTabs.addTab(new TabInfo(treeViewContent.getComponent()).setText("Build")); Content tabsContent = runnerLayoutUi.createContent(TABS_CONTENT_ID, myTabs.getComponent(), "Buck Tool Tabs", null, null);/* ww w . j av a 2 s. c o m*/ runnerLayoutUi.addContent(tabsContent, 0, PlaceInGrid.center, false); runnerLayoutUi.getOptions().setLeftToolbar(getLeftToolbarActions(project), ActionPlaces.UNKNOWN); runnerLayoutUi.updateActionsNow(); final ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent(runnerLayoutUi.getComponent(), "", true); contentManager.addContent(content); updateBuckToolWindowTitle(project); }
From source file:com.github.cssxfire.IncomingChangesComponent.java
License:Apache License
public void projectOpened() { if (!CssXFireConnector.getInstance().isInitialized()) { return;/*from w ww. j a v a 2 s . co m*/ } final ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM); final ContentFactory contentFactory = toolWindow.getContentManager().getFactory(); final Content content = contentFactory.createContent(cssToolWindow, "Incoming changes", true); Disposer.register(content, cssToolWindow); Disposer.register(project, content); content.setCloseable(false); toolWindow.getContentManager().addContent(content); toolWindow.setAutoHide(false); toolWindow.setAvailable(true, null); CssXFireConnector.getInstance().addProjectComponent(this); PsiManager.getInstance(project).addPsiTreeChangeListener(myListener); }
From source file:com.google.idea.blaze.plugin.ClwbProjectSpecificInitializer.java
License:Open Source License
@Override public void projectOpened() { // removes the CMake tool window for blaze projects ToolWindowManager manager = ToolWindowManager.getInstance(myProject); ToolWindow tw = manager.getToolWindow(CMakeWorkspace.TOOLWINDOW_ID); if (tw != null) { tw.setAvailable(false, null); }/* w w w .jav a 2 s . c o m*/ }
From source file:com.googlecode.cssxfire.IncomingChangesComponent.java
License:Apache License
public void projectOpened() { if (!CssXFireConnector.getInstance().isInitialized()) { return;/*from w ww. j a v a 2s . c o m*/ } final ToolWindow toolWindow = ToolWindowManager.getInstance(project).registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.BOTTOM); final ContentFactory contentFactory = toolWindow.getContentManager().getFactory(); final Content content = contentFactory.createContent(cssToolWindow, "Incoming changes", true); toolWindow.getContentManager().addContent(content); toolWindow.setAutoHide(false); toolWindow.setAvailable(true, null); CssXFireConnector.getInstance().addProjectComponent(this); PsiManager.getInstance(project).addPsiTreeChangeListener(myListener); }
From source file:com.kstenschke.copypastestack.ToolWindowFactory.java
License:Apache License
/** * Add icon and evoke creation of tool window content * * @param project/* ww w. ja v a2 s .c o m*/ * @param toolWindow */ @Override public void createToolWindowContent(Project project, final com.intellij.openapi.wm.ToolWindow toolWindow) { final ToolWindow newToolWindow = new ToolWindow(); Content content = ContentFactory.SERVICE.getInstance().createContent(newToolWindow, "", false); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setTitle(StaticTexts.TITLE_TOOL_WINDOW); loadAndSetToolWindowIcon(toolWindow); toolWindow.getContentManager().addContent(content); toolWindow.activate(new Runnable() { @Override public void run() { } }); }