public void setConsoleEditorEnabled(boolean consoleEditorEnabled) { if (isConsoleEditorEnabled() == consoleEditorEnabled) return; final FileEditorManagerEx fileManager = FileEditorManagerEx.getInstanceEx(getProject()); if (consoleEditorEnabled) { fileManager.closeFile(myVirtualFile); myPanel.removeAll(); myPanel.add(myHistoryViewer.getComponent()); myPanel.add(myConsoleEditor.getComponent()); myHistoryViewer.setHorizontalScrollbarVisible(false); myCurrentEditor = myConsoleEditor; } else { myPanel.removeAll(); myPanel.add(myHistoryViewer.getComponent(), BorderLayout.CENTER); myHistoryViewer.setHorizontalScrollbarVisible(true); } }
public void initComponents() { final EditorColorsScheme colorsScheme = myConsoleEditor.getColorsScheme(); final DelegateColorScheme scheme = new DelegateColorScheme(colorsScheme) { @NotNull @Override public Color getDefaultBackground() { final Color color = getColor(ConsoleViewContentType.CONSOLE_BACKGROUND_KEY); return color == null ? super.getDefaultBackground() : color; } }; myConsoleEditor.setColorsScheme(scheme); myHistoryViewer.setColorsScheme(scheme); myPanel.add(myHistoryViewer.getComponent()); myPanel.add(myConsoleEditor.getComponent()); setupComponents(); DataManager.registerDataProvider(myPanel, new TypeSafeDataProviderAdapter(this)); myHistoryViewer .getComponent() .addComponentListener( new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (myForceScrollToEnd.getAndSet(false)) { final JScrollBar scrollBar = myHistoryViewer.getScrollPane().getVerticalScrollBar(); scrollBar.setValue(scrollBar.getMaximum()); } } public void componentShown(ComponentEvent e) { componentResized(e); } }); setPromptInner(myPrompt); }
public boolean isConsoleEditorEnabled() { return myPanel.getComponentCount() > 1; }