Java Code Examples for com.intellij.openapi.wm.ToolWindow#getContentManager()
The following examples show how to use
com.intellij.openapi.wm.ToolWindow#getContentManager() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterPerformanceView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example 2
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) { final ContentManager contentManager = toolWindow.getContentManager(); contentManager.addContentManagerListener(new ContentManagerAdapter() { @Override public void selectionChanged(@NotNull ContentManagerEvent event) { final ContentManagerEvent.ContentOperation operation = event.getOperation(); if (operation == ContentManagerEvent.ContentOperation.add) { final String name = event.getContent().getTabName(); if (Objects.equals(name, RENDER_TAB_LABEL)) { FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected"); } else if (Objects.equals(name, WIDGET_TAB_LABEL)) { FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected"); } } } }); }
Example 3
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example 4
Source File: RestfulWindowToolWindowFactory.java From NutzCodeInsight with Apache License 2.0 | 6 votes |
@Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { final SimpleTree apiTree = new SimpleTree(); apiTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.toolWindowEx = (ToolWindowEx) toolWindow; RefreshAction refreshAction = new RefreshAction("刷新", "重新加载URL", AllIcons.Actions.Refresh, toolWindowEx, apiTree); toolWindowEx.setTitleActions(refreshAction, actionManager.getAction("GoToRequestMapping")); apiTree.addMouseListener(new ApiTreeMouseAdapter(apiTree)); ContentManager contentManager = toolWindow.getContentManager(); Content content = contentManager.getFactory().createContent(new RestServicesNavigatorPanel(apiTree), null, false); contentManager.addContent(content); contentManager.setSelectedContent(content); if (project.isInitialized()) { refreshAction.loadTree(project); } }
Example 5
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example 6
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) { final ContentManager contentManager = toolWindow.getContentManager(); contentManager.addContentManagerListener(new ContentManagerAdapter() { @Override public void selectionChanged(@NotNull ContentManagerEvent event) { final ContentManagerEvent.ContentOperation operation = event.getOperation(); if (operation == ContentManagerEvent.ContentOperation.add) { final String name = event.getContent().getTabName(); if (Objects.equals(name, RENDER_TAB_LABEL)) { FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected"); } else if (Objects.equals(name, WIDGET_TAB_LABEL)) { FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected"); } } } }); }
Example 7
Source File: FlutterPerformanceView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example 8
Source File: CoverageViewManager.java From consulo with Apache License 2.0 | 5 votes |
@Inject public CoverageViewManager(Project project, ToolWindowManager toolWindowManager, CoverageDataManager dataManager) { myProject = project; myDataManager = dataManager; ToolWindow toolWindow = toolWindowManager.registerToolWindow(TOOLWINDOW_ID, true, ToolWindowAnchor.RIGHT, myProject); toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowCoverage); toolWindow.setSplitMode(true, null); myContentManager = toolWindow.getContentManager(); new ContentManagerWatcher(toolWindow, myContentManager); }
Example 9
Source File: ConsoleLogToolWindowFactory.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
static void createContent(Project project, ToolWindow toolWindow, ConsoleLogConsole console, String title) { // update default Event Log tab title ContentManager contentManager = toolWindow.getContentManager(); Content generalContent = contentManager.getContent(0); if (generalContent != null && contentManager.getContentCount() == 1) { generalContent.setDisplayName("General"); } final Editor editor = console.getConsoleEditor(); SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) { @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.HELP_ID.is(dataId) ? ConsoleLog.HELP_ID : super.getData(dataId); } }; panel.setContent(editor.getComponent()); panel.addAncestorListener(new LogShownTracker(project)); ActionToolbar toolbar = createToolbar(project, editor, console); toolbar.setTargetComponent(editor.getContentComponent()); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false); contentManager.addContent(content); contentManager.setSelectedContent(content); }
Example 10
Source File: SlingPluginToolWindowFactory.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public void createToolWindowContent(final Project project, final ToolWindow toolWindow) { // Plugin is now placed into a Tabbed Pane to add additional views to it JBTabbedPane master = new JBTabbedPane(SwingConstants.BOTTOM); SlingPluginExplorer explorer = new SlingPluginExplorer(project); LOGGER.debug("CTWC: Explorer: '" + explorer + "'"); master.insertTab("Plugin", null, explorer, "Plugin Windows", 0); WebContentFXPanel info = new WebContentFXPanel(); master.insertTab("Info", null, info, "Plugin Info", 1); final AemdcPanel aemdcPanel = ComponentProvider.getComponent(project, AemdcPanel.class); LOGGER.debug("AEMDC Panel found: '{}'", aemdcPanel); aemdcPanel.setContainer(master); final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentManager.getFactory().createContent(master, null, false); contentManager.addContent(content); Disposer.register(project, explorer); final ToolWindowManagerAdapter listener = new ToolWindowManagerAdapter() { boolean wasVisible = false; @Override public void stateChanged() { if (toolWindow.isDisposed()) { return; } boolean visible = toolWindow.isVisible(); // If the Plugin became visible then we let the AEMDC Panel know to recrate the JFX Panel // to avoid the double buffering if(!wasVisible && visible) { aemdcPanel.reset(); } wasVisible = visible; } }; final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(project); manager.addToolWindowManagerListener(listener, project); }
Example 11
Source File: CompleteReviewAction.java From Crucible4IDEA with MIT License | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return; CrucibleManager.getInstance(project).completeReview(myReview.getPermaId()); final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CrucibleBundle.message("crucible.toolwindow.id")); final ContentManager contentManager = toolWindow.getContentManager(); final Content foundContent = contentManager.findContent("Details for " + myReview.getPermaId()); contentManager.removeContent(foundContent, true); final Content dash = contentManager.findContent("Dashboard"); if (dash.getComponent() instanceof CruciblePanel) { ((CruciblePanel)dash.getComponent()).getReviewModel().updateModel(CrucibleFilter.ToReview); } }
Example 12
Source File: RunContentManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess private void registerToolWindow(@Nonnull final Executor executor, @Nonnull ToolWindowManagerEx toolWindowManager) { final String toolWindowId = executor.getToolWindowId(); if (toolWindowManager.getToolWindow(toolWindowId) != null) { return; } final ToolWindow toolWindow = toolWindowManager.registerToolWindow(toolWindowId, true, ToolWindowAnchor.BOTTOM, this, true); final ContentManager contentManager = toolWindow.getContentManager(); contentManager.addDataProvider(new DataProvider() { private int myInsideGetData = 0; @Override public Object getData(@Nonnull Key<?> dataId) { myInsideGetData++; try { if (PlatformDataKeys.HELP_ID == dataId) { return executor.getHelpId(); } else { return myInsideGetData == 1 ? DataManager.getInstance().getDataContext(contentManager.getComponent()).getData(dataId) : null; } } finally { myInsideGetData--; } } }); toolWindow.setIcon(executor.getToolWindowIcon()); new ContentManagerWatcher(toolWindow, contentManager); initToolWindow(executor, toolWindowId, executor.getToolWindowIcon(), contentManager); }
Example 13
Source File: ExternalSystemUtil.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Nullable public static <T> T getToolWindowElement(@Nonnull Class<T> clazz, @Nonnull Project project, @Nonnull Key<T> key, @Nonnull ProjectSystemId externalSystemId) { if (project.isDisposed() || !project.isOpen()) { return null; } final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); if (toolWindowManager == null) { return null; } final ToolWindow toolWindow = ensureToolWindowContentInitialized(project, externalSystemId); if (toolWindow == null) { return null; } final ContentManager contentManager = toolWindow.getContentManager(); if (contentManager == null) { return null; } for (Content content : contentManager.getContents()) { final JComponent component = content.getComponent(); if (component instanceof DataProvider) { final Object data = ((DataProvider)component).getData(key); if (data != null && clazz.isInstance(data)) { return (T)data; } } } return null; }
Example 14
Source File: EventLogToolWindowFactory.java From consulo with Apache License 2.0 | 5 votes |
static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) { // update default Event Log tab title ContentManager contentManager = toolWindow.getContentManager(); Content generalContent = contentManager.getContent(0); if (generalContent != null && contentManager.getContentCount() == 1) { generalContent.setDisplayName("General"); } final Editor editor = console.getConsoleEditor(); SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) { @Override public Object getData(@Nonnull @NonNls Key dataId) { return PlatformDataKeys.HELP_ID == dataId ? EventLog.HELP_ID : super.getData(dataId); } }; panel.setContent(editor.getComponent()); panel.addAncestorListener(new LogShownTracker(project)); ActionToolbar toolbar = createToolbar(project, editor, console); toolbar.setTargetComponent(editor.getContentComponent()); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.getInstance().createContent(panel, title, false); contentManager.addContent(content); contentManager.setSelectedContent(content); }
Example 15
Source File: RefactoringsToolWindowFactory.java From IntelliJDeodorant with MIT License | 5 votes |
@Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { ContentManager contentManager = toolWindow.getContentManager(); AnalysisScope scope = new AnalysisScope(project); Content moveMethodPanel = contentManager.getFactory().createContent(new MoveMethodPanel(scope), IntelliJDeodorantBundle.message("feature.envy.smell.name"), false); Content extractMethodPanel = contentManager.getFactory().createContent(new ExtractMethodPanel(scope), IntelliJDeodorantBundle.message("long.method.smell.name"), false); Content godClassPanel = contentManager.getFactory().createContent(new GodClassPanel(scope), IntelliJDeodorantBundle.message("god.class.smell.name"), false); Content typeCheckPanel = contentManager.getFactory().createContent(new TypeCheckingPanel(scope), IntelliJDeodorantBundle.message("type.state.checking.smell.name"), false); contentManager.addContent(moveMethodPanel); contentManager.addContent(extractMethodPanel); contentManager.addContent(godClassPanel); contentManager.addContent(typeCheckPanel); }
Example 16
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void addInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) { final ContentManager contentManager = toolWindow.getContentManager(); final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true); final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), this); runnerTabs.setSelectionChangeHandler(this::onTabSelectionChange); final JPanel tabContainer = new JPanel(new BorderLayout()); final String tabName; final FlutterDevice device = app.device(); if (device == null) { tabName = app.getProject().getName(); } else { final List<FlutterDevice> existingDevices = new ArrayList<>(); for (FlutterApp otherApp : perAppViewState.keySet()) { existingDevices.add(otherApp.device()); } tabName = device.getUniqueName(existingDevices); } final Content content = contentManager.getFactory().createContent(null, tabName, false); tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER); content.setComponent(tabContainer); content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE); content.setIcon(FlutterIcons.Phone); contentManager.addContent(content); if (emptyContent != null) { contentManager.removeContent(emptyContent, true); emptyContent = null; } contentManager.setSelectedContent(content); final PerAppState state = getOrCreateStateForApp(app); assert (state.content == null); state.content = content; final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, inspectorService); toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent()); toolbarGroup.add(new OverflowAction(getOrCreateStateForApp(app), this, app)); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true); final JComponent toolbarComponent = toolbar.getComponent(); toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); tabContainer.add(toolbarComponent, BorderLayout.NORTH); final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection(); final boolean hasInspectorService = inspectorService != null; // If the inspector is available (non-release mode), then show it. if (debugConnectionAvailable) { if (hasInspectorService) { final boolean detailsSummaryViewSupported = inspectorService.isDetailsSummaryViewSupported(); addInspectorPanel(WIDGET_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow, toolbarGroup, true, detailsSummaryViewSupported); addInspectorPanel(RENDER_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService, toolWindow, toolbarGroup, false, false); } else { // If in profile mode, add disabled tabs for the inspector. addDisabledTab(WIDGET_TAB_LABEL, runnerTabs, toolbarGroup); addDisabledTab(RENDER_TAB_LABEL, runnerTabs, toolbarGroup); } } else { // Add a message about the inspector not being available in release mode. final JBLabel label = new JBLabel("Inspector not available in release mode", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); tabContainer.add(label, BorderLayout.CENTER); } }
Example 17
Source File: FlutterView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void addInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) { final ContentManager contentManager = toolWindow.getContentManager(); final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true); final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), this); runnerTabs.setSelectionChangeHandler(this::onTabSelectionChange); final JPanel tabContainer = new JPanel(new BorderLayout()); final String tabName; final FlutterDevice device = app.device(); if (device == null) { tabName = app.getProject().getName(); } else { final List<FlutterDevice> existingDevices = new ArrayList<>(); for (FlutterApp otherApp : perAppViewState.keySet()) { existingDevices.add(otherApp.device()); } tabName = device.getUniqueName(existingDevices); } final Content content = contentManager.getFactory().createContent(null, tabName, false); tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER); content.setComponent(tabContainer); content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE); content.setIcon(FlutterIcons.Phone); contentManager.addContent(content); if (emptyContent != null) { contentManager.removeContent(emptyContent, true); emptyContent = null; } contentManager.setSelectedContent(content); final PerAppState state = getOrCreateStateForApp(app); assert (state.content == null); state.content = content; final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, inspectorService); toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent()); toolbarGroup.add(new OverflowAction(getOrCreateStateForApp(app), this, app)); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true); final JComponent toolbarComponent = toolbar.getComponent(); toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); tabContainer.add(toolbarComponent, BorderLayout.NORTH); final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection(); final boolean hasInspectorService = inspectorService != null; // If the inspector is available (non-release mode), then show it. if (debugConnectionAvailable) { if (hasInspectorService) { final boolean detailsSummaryViewSupported = inspectorService.isDetailsSummaryViewSupported(); addInspectorPanel(WIDGET_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow, toolbarGroup, true, detailsSummaryViewSupported); addInspectorPanel(RENDER_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService, toolWindow, toolbarGroup, false, false); } else { // If in profile mode, add disabled tabs for the inspector. addDisabledTab(WIDGET_TAB_LABEL, runnerTabs, toolbarGroup); addDisabledTab(RENDER_TAB_LABEL, runnerTabs, toolbarGroup); } } else { // Add a message about the inspector not being available in release mode. final JBLabel label = new JBLabel("Inspector not available in release mode", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); tabContainer.add(label, BorderLayout.CENTER); } }
Example 18
Source File: LogviewFactory.java From logviewer with Apache License 2.0 | 4 votes |
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) { final File adb = AndroidSdkUtils.getAdb(project); ExecutionManager.getInstance(project).getContentManager(); RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project); toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON); toolWindow.setAvailable(true, null); toolWindow.setToHideOnEmptyContent(true); toolWindow.setTitle(TOOL_WINDOW_ID); DeviceContext deviceContext = new DeviceContext(); Content logcatContent = createLogcatContent(layoutUi, project, deviceContext); final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY); layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false); final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project); loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER); final ContentManager contentManager = toolWindow.getContentManager(); Content c = contentManager.getFactory().createContent(loadingPanel, "", true); c.putUserData(LOG_VIEW_KEY, logcatView); contentManager.addContent(c); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { logcatView.activate(); } }, project.getDisposed()); if (adb != null) { loadingPanel.setLoadingText("Initializing ADB"); loadingPanel.startLoading(); //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb); ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb); Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() { @Override public void onSuccess(@Nullable AndroidDebugBridge bridge) { Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge"); loadingPanel.stopLoading(); } @Override public void onFailure(@NotNull Throwable t) { loadingPanel.stopLoading(); Logger.getInstance(LogviewFactory.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", ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath()); } Messages.showErrorDialog(msg, "ADB Connection Error"); } }, EdtExecutor.INSTANCE); } else { logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them."); } }
Example 19
Source File: PreviewView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void initToolWindow(@NotNull ToolWindow toolWindow) { final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); final ContentManager contentManager = toolWindow.getContentManager(); final Content content = contentFactory.createContent(null, null, false); content.setCloseable(false); windowPanel = new OutlineComponent(this); content.setComponent(windowPanel); windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent()); final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); tree = new OutlineTree(rootNode); tree.setCellRenderer(new OutlineTreeCellRenderer()); tree.expandAll(); initTreePopup(); // Add collapse all, expand all, and show only widgets buttons. if (toolWindow instanceof ToolWindowEx) { final ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow; final CommonActionsManager actions = CommonActionsManager.getInstance(); final TreeExpander expander = new DefaultTreeExpander(tree); final AnAction expandAllAction = actions.createExpandAllAction(expander, tree); expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall); final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree); collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall); final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction(); toolWindowEx.setTitleActions(expandAllAction, collapseAllAction, showOnlyWidgetsAction); } new TreeSpeedSearch(tree) { @Override protected String getElementText(Object element) { final TreePath path = (TreePath)element; final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); final Object object = node.getUserObject(); if (object instanceof OutlineObject) { return ((OutlineObject)object).getSpeedSearchString(); } return null; } }; tree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { final TreePath selectionPath = tree.getSelectionPath(); if (selectionPath != null) { selectPath(selectionPath, true); } } } }); tree.addTreeSelectionListener(treeSelectionListener); scrollPane = ScrollPaneFactory.createScrollPane(tree); content.setPreferredFocusableComponent(tree); contentManager.addContent(content); contentManager.setSelectedContent(content); splitter = new Splitter(true); setSplitterProportion(getState().getSplitterProportion()); getState().addListener(e -> { final float newProportion = getState().getSplitterProportion(); if (splitter.getProportion() != newProportion) { setSplitterProportion(newProportion); } }); //noinspection Convert2Lambda splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isSettingSplitterProportion) { getState().setSplitterProportion(splitter.getProportion()); } } }); scrollPane.setMinimumSize(new Dimension(1, 1)); splitter.setFirstComponent(scrollPane); windowPanel.setContent(splitter); }
Example 20
Source File: RoutesView.java From railways with MIT License | 4 votes |
/** * Initializes tool window. * * @param toolWindow Tool window to initialize. */ synchronized void initToolWindow(final ToolWindow toolWindow) { myToolWindow = toolWindow; myContentManager = toolWindow.getContentManager(); if (!ApplicationManager.getApplication().isUnitTestMode()) { toolWindow.setContentUiType(ToolWindowContentUiType.getInstance("combo"), null); toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true"); } // Add all modules that are already added till this moment. Module[] modules = ModuleManager.getInstance(myProject).getModules(); for (Module m : modules) addModulePane(m); // Add listener to update mainPanel when a module is selected from // tool window header. myContentManager.addContentManagerListener(new ContentManagerAdapter() { @Override public void selectionChanged(@NotNull ContentManagerEvent event) { // When user selects a module from tool window combo, // selectionChanges is called twice: // 1. With 'remove' operation - for previously selected item, // 2. With 'add' operation - for newly selected item. if (event.getOperation() == ContentManagerEvent.ContentOperation.add) { viewSelectionChanged(); refreshRouteActionsStatus(); } } }); // Open tab that was active in previous IDE session Content savedContent = myContentManager.getContent(myState.selectedTabId); if (savedContent != null) myContentManager.setSelectedContent(savedContent); mainPanel.getRouteFilter().setMountedRoutesVisible(!myState.hideMountedRoutes); myConnection.subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() { /** * This method is called when ToolWindow changes its state, i.e. * expanded/collapsed, docked to another panel, etc. */ @Override public void stateChanged() { // We have to check if our tool window is still registered, as // otherwise it will raise an exception when project is closed. if (ToolWindowManagerEx.getInstanceEx(myProject).getToolWindow("Routes") == null) return; updateToolWindowOrientation(toolWindow); if (toolWindow.isVisible()) if (currentPane != null && currentPane.isRoutesInvalidated()) currentPane.updateRoutes(); refreshRouteActionsStatus(); } }); updateToolWindowOrientation(toolWindow); }