Java Code Examples for com.intellij.openapi.ui.SimpleToolWindowPanel#setToolbar()
The following examples show how to use
com.intellij.openapi.ui.SimpleToolWindowPanel#setToolbar() .
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: PreviewArea.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public PreviewArea(Project project, Set<FlutterOutline> outlinesWithWidgets, Disposable parent) { this.outlinesWithWidgets = outlinesWithWidgets; context = new WidgetEditingContext( project, FlutterDartAnalysisServer.getInstance(project), InspectorGroupManagerService.getInstance(project), EditorPositionService.getInstance(project) ); inspectorClient = new InspectorGroupManagerService.Client(parent); context.inspectorGroupManagerService.addListener(inspectorClient, parent); preview = new PreviewViewController(new WidgetViewModelData(context), false, layeredPanel, parent); deviceMirrorPanel = new PreviewViewModelPanel(preview); windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewArea", toolbarGroup, true); toolbarGroup.add(new TitleAction("Device Mirror")); window = new SimpleToolWindowPanel(true, true); window.setToolbar(windowToolbar.getComponent()); deviceMirrorPanel.setLayout(new BorderLayout()); // TODO(jacobr): reafactor to remove the layeredPanel as we aren't getting any benefit from it. window.setContent(layeredPanel); layeredPanel.add(deviceMirrorPanel, Integer.valueOf(0)); // Layers should cover the whole root panel. layeredPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { final Dimension renderSize = getRenderSize(); preview.setScreenshotBounds(new Rectangle(0, 0, renderSize.width, renderSize.height)); } }); }
Example 2
Source File: PreviewArea.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public PreviewArea(Project project, Set<FlutterOutline> outlinesWithWidgets, Disposable parent) { this.outlinesWithWidgets = outlinesWithWidgets; context = new WidgetEditingContext( project, FlutterDartAnalysisServer.getInstance(project), InspectorGroupManagerService.getInstance(project), EditorPositionService.getInstance(project) ); inspectorClient = new InspectorGroupManagerService.Client(parent); context.inspectorGroupManagerService.addListener(inspectorClient, parent); preview = new PreviewViewController(new WidgetViewModelData(context), false, layeredPanel, parent); deviceMirrorPanel = new PreviewViewModelPanel(preview); windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewArea", toolbarGroup, true); toolbarGroup.add(new TitleAction("Device Mirror")); window = new SimpleToolWindowPanel(true, true); window.setToolbar(windowToolbar.getComponent()); deviceMirrorPanel.setLayout(new BorderLayout()); // TODO(jacobr): reafactor to remove the layeredPanel as we aren't getting any benefit from it. window.setContent(layeredPanel); layeredPanel.add(deviceMirrorPanel, Integer.valueOf(0)); // Layers should cover the whole root panel. layeredPanel.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { final Dimension renderSize = getRenderSize(); preview.setScreenshotBounds(new Rectangle(0, 0, renderSize.width, renderSize.height)); } }); }
Example 3
Source File: FreelineTerminal.java From freeline with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 创建Terminal panel * * @param terminalRunner * @param toolWindow * @return */ private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false); content.setCloseable(true); myTerminalWidget = terminalRunner.createTerminalWidget(content); panel.setContent(myTerminalWidget.getComponent()); panel.addFocusListener(this); ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow); toolbar.setTargetComponent(panel); panel.setToolbar(toolbar.getComponent()); content.setPreferredFocusableComponent(myTerminalWidget.getComponent()); return content; }
Example 4
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 5
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 6
Source File: BsToolWindowFactory.java From reasonml-idea-plugin with MIT License | 4 votes |
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); BsConsole console = new BsConsole(project); panel.setContent(console.getComponent()); ActionToolbar toolbar = createToolbar(console); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true); window.getContentManager().addContent(content); Disposer.register(project, console); }
Example 7
Source File: DuneToolWindowFactory.java From reasonml-idea-plugin with MIT License | 4 votes |
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); BsConsole console = new BsConsole(project); panel.setContent(console.getComponent()); ActionToolbar toolbar = createToolbar(console); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true); window.getContentManager().addContent(content); Disposer.register(project, console); }
Example 8
Source File: EsyToolWindowFactory.java From reasonml-idea-plugin with MIT License | 4 votes |
@Override public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); BsConsole console = new BsConsole(project); panel.setContent(console.getComponent()); ActionToolbar toolbar = createToolbar(console); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true); window.getContentManager().addContent(content); Disposer.register(project, console); }
Example 9
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 10
Source File: PreviewView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void updateOutline(@NotNull FlutterOutline outline) { currentOutline = outline; final DefaultMutableTreeNode rootNode = getRootNode(); rootNode.removeAllChildren(); outlinesWithWidgets.clear(); outlineToNodeMap.clear(); if (outline.getChildren() != null) { computeOutlinesWithWidgets(outline); updateOutlineImpl(rootNode, outline.getChildren()); } getTreeModel().reload(rootNode); tree.expandAll(); if (currentEditor != null) { final Caret caret = currentEditor.getCaretModel().getPrimaryCaret(); applyEditorSelectionToTree(caret); } if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) { propertyEditSplitter = new Splitter(false, 0.75f); propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project); propertyEditPanel.initalize(null, activeOutlines, currentFile); propertyEditToolbarGroup = new DefaultActionGroup(); final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true); final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true); window.setToolbar(windowToolbar.getComponent()); final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel); window.setContent(propertyScrollPane); propertyEditSplitter.setFirstComponent(window.getComponent()); final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) { @Override public void onInspectorAvailabilityChanged() { super.onInspectorAvailabilityChanged(); // Only show the screen mirror if there is a running device and // the inspector supports the neccessary apis. if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) { // Wait to create the preview area until it is needed. if (previewArea == null) { previewArea = new PreviewArea(project, outlinesWithWidgets, project); } propertyEditSplitter.setSecondComponent(previewArea.getComponent()); } else { propertyEditSplitter.setSecondComponent(null); } } }; inspectorGroupManagerService.addListener(inspectorStateServiceClient, project); splitter.setSecondComponent(propertyEditSplitter); } // TODO(jacobr): this is the wrong spot. if (propertyEditToolbarGroup != null) { final TitleAction propertyTitleAction = new TitleAction("Properties"); propertyEditToolbarGroup.removeAll(); propertyEditToolbarGroup.add(propertyTitleAction); } }
Example 11
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 12
Source File: PreviewView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void updateOutline(@NotNull FlutterOutline outline) { currentOutline = outline; final DefaultMutableTreeNode rootNode = getRootNode(); rootNode.removeAllChildren(); outlinesWithWidgets.clear(); outlineToNodeMap.clear(); if (outline.getChildren() != null) { computeOutlinesWithWidgets(outline); updateOutlineImpl(rootNode, outline.getChildren()); } getTreeModel().reload(rootNode); tree.expandAll(); if (currentEditor != null) { final Caret caret = currentEditor.getCaretModel().getPrimaryCaret(); applyEditorSelectionToTree(caret); } if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) { propertyEditSplitter = new Splitter(false, 0.75f); propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project); propertyEditPanel.initalize(null, activeOutlines, currentFile); propertyEditToolbarGroup = new DefaultActionGroup(); final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true); final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true); window.setToolbar(windowToolbar.getComponent()); final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel); window.setContent(propertyScrollPane); propertyEditSplitter.setFirstComponent(window.getComponent()); final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) { @Override public void onInspectorAvailabilityChanged() { super.onInspectorAvailabilityChanged(); // Only show the screen mirror if there is a running device and // the inspector supports the neccessary apis. if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) { // Wait to create the preview area until it is needed. if (previewArea == null) { previewArea = new PreviewArea(project, outlinesWithWidgets, project); } propertyEditSplitter.setSecondComponent(previewArea.getComponent()); } else { propertyEditSplitter.setSecondComponent(null); } } }; inspectorGroupManagerService.addListener(inspectorStateServiceClient, project); splitter.setSecondComponent(propertyEditSplitter); } // TODO(jacobr): this is the wrong spot. if (propertyEditToolbarGroup != null) { final TitleAction propertyTitleAction = new TitleAction("Properties"); propertyEditToolbarGroup.removeAll(); propertyEditToolbarGroup.add(propertyTitleAction); } }
Example 13
Source File: ChangesViewManager.java From consulo with Apache License 2.0 | 4 votes |
private JComponent createChangeViewComponent() { SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true); EmptyAction.registerWithShortcutSet("ChangesView.Refresh", CommonShortcuts.getRerun(), panel); EmptyAction.registerWithShortcutSet("ChangesView.NewChangeList", CommonShortcuts.getNew(), panel); EmptyAction.registerWithShortcutSet("ChangesView.RemoveChangeList", CommonShortcuts.getDelete(), panel); EmptyAction.registerWithShortcutSet(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), panel); EmptyAction.registerWithShortcutSet("ChangesView.Rename", CommonShortcuts.getRename(), panel); EmptyAction.registerWithShortcutSet("ChangesView.SetDefault", new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_DOWN_MASK | ctrlMask())), panel); EmptyAction.registerWithShortcutSet("ChangesView.Diff", CommonShortcuts.getDiff(), panel); DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("ChangesViewToolbar"); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, group, false); toolbar.setTargetComponent(myView); JComponent toolbarComponent = toolbar.getComponent(); JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(toolbarComponent, BorderLayout.WEST); DefaultActionGroup visualActionsGroup = new DefaultActionGroup(); final Expander expander = new Expander(); visualActionsGroup.add(CommonActionsManager.getInstance().createExpandAllAction(expander, panel)); visualActionsGroup.add(CommonActionsManager.getInstance().createCollapseAllAction(expander, panel)); ToggleShowFlattenAction showFlattenAction = new ToggleShowFlattenAction(); showFlattenAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, ctrlMask())), panel); visualActionsGroup.add(showFlattenAction); visualActionsGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY)); visualActionsGroup.add(new ToggleShowIgnoredAction()); visualActionsGroup.add(new IgnoredSettingsAction()); visualActionsGroup.add(new ToggleDetailsAction()); visualActionsGroup.add(new ContextHelpAction(ChangesListView.HELP_ID)); toolbarPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, visualActionsGroup, false).getComponent(), BorderLayout.CENTER); myView.setMenuActions((DefaultActionGroup)ActionManager.getInstance().getAction("ChangesViewPopupMenu")); myView.setShowFlatten(myState.myShowFlatten); myProgressLabel = new JPanel(new BorderLayout()); panel.setToolbar(toolbarPanel); final JPanel content = new JPanel(new BorderLayout()); mySplitter = new JBSplitter(false, "ChangesViewManager.DETAILS_SPLITTER_PROPORTION", 0.5f); mySplitter.setHonorComponentsMinimumSize(false); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myView); final JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(scrollPane, BorderLayout.CENTER); mySplitter.setFirstComponent(wrapper); content.add(mySplitter, BorderLayout.CENTER); content.add(myProgressLabel, BorderLayout.SOUTH); panel.setContent(content); ChangesDnDSupport.install(myProject, myView); myView.addTreeSelectionListener(myTsl); return panel; }