A Swing-based interactive console for evaluating Groovy expressions and scripts with syntax highlighting, code completion, and an integrated AST browser.
—
The Groovy Console provides comprehensive system integration features including output capture, preferences management, platform-specific UI adaptations, and dependency management through Apache Ivy.
class SystemOutputInterceptor extends FilterOutputStream {
// Constructor
SystemOutputInterceptor(OutputStream out)
// Inherits all FilterOutputStream methods for output redirection
}Constructor Parameters:
out (OutputStream): Target output stream to redirect system output toThe SystemOutputInterceptor captures System.out and System.err output from executed scripts and redirects it to the console's output area.
class ConsolePreferences {
// Constructor
ConsolePreferences()
// Configuration methods for console settings
}The ConsolePreferences class manages persistent configuration settings for the console including:
abstract class ConsoleSupport {
// Abstract base class providing common console utilities
}ConsoleSupport provides foundational functionality shared across different console implementations.
class HistoryRecord {
// Manages console command and execution history
}The HistoryRecord class maintains:
class OutputTransforms {
// Output transformation and formatting utilities
}OutputTransforms provides utilities for:
// ConsoleActions.groovy - Defines all UI actions for menu items and toolbar buttons
// Contains action definitions including:
// - newFileAction, newWindowAction, openAction
// - saveAction, saveAsAction, printAction
// - undoAction, redoAction, cutAction, copyAction, pasteAction
// - runAction, runSelectionAction, stopAction
// - inspectLastAction, inspectVariablesAction, inspectAstAction
// - clearOutputAction, aboutAction, preferencesAction
// - And many more UI actions with their keyboard shortcuts and iconsConsoleActions defines all the Swing Actions used throughout the console interface, providing consistent behavior for menu items, toolbar buttons, and keyboard shortcuts.
// ConsoleView.groovy - Platform-aware UI view configuration
// Automatically detects system Look-and-Feel and applies appropriate defaults:
// - Windows: WindowsDefaults
// - macOS: MacOSXDefaults
// - GTK/Linux: GTKDefaults
// - Default: DefaultsConsoleView handles platform-specific UI configuration, automatically detecting the system's look-and-feel and applying the appropriate UI defaults for optimal native integration.
class BasicMenuBar {
// Cross-platform menu bar implementation
}
class BasicToolBar {
// Cross-platform toolbar implementation
}
class BasicStatusBar {
// Cross-platform status bar implementation
}
class BasicContentPane {
// Cross-platform content pane layout
}class Defaults {
// Base UI defaults and theming
}
class MacOSXDefaults {
// macOS-specific UI defaults and native integration
}
class WindowsDefaults {
// Windows-specific UI defaults and native integration
}
class GTKDefaults {
// GTK/Linux-specific UI defaults and native integration
}class MacOSXMenuBar {
// macOS-specific menu bar with native integration
}
class ConsoleMacOsSupport implements MRJQuitHandler, MRJAboutHandler, MRJPrefsHandler {
// macOS-specific handlers for system events
}class ConsoleIvyPlugin {
// Apache Ivy integration for dependency management
}The ConsoleIvyPlugin provides:
def outputStream = new ByteArrayOutputStream()
def interceptor = new groovy.console.ui.SystemOutputInterceptor(outputStream)
// Redirect system output
def originalOut = System.out
System.setOut(new PrintStream(interceptor))
// Execute script - output will be captured
println "This will be captured"
// Restore original output
System.setOut(originalOut)
// Get captured output
def capturedOutput = outputStream.toString()def preferences = new groovy.console.ui.ConsolePreferences()
// Configure console settings
// (Specific configuration methods depend on implementation)// The console automatically detects platform and applies appropriate defaults
def console = new groovy.console.ui.Console()
// Platform-specific defaults are applied automatically:
// - macOS: Native menu bar integration, Mac-specific shortcuts
// - Windows: Windows look-and-feel, Windows-specific behaviors
// - Linux/GTK: GTK theming and Linux conventions// History is managed automatically by the console
// Access through console UI or programmatically through HistoryRecord
def console = new groovy.console.ui.Console()
// History navigation available through UI (up/down arrows, etc.)All system integration components work together:
During script execution:
The same system integration functionality is available in the legacy groovy.ui package:
// Legacy imports (same API as groovy.console.ui)
import groovy.ui.SystemOutputInterceptor
import groovy.ui.ConsolePreferences
import groovy.ui.ConsoleSupport
import groovy.ui.HistoryRecord
import groovy.ui.OutputTransforms
import groovy.ui.ConsoleIvyPluginThe console provides native integration on:
Advanced output features:
Through the Ivy plugin:
Install with Tessl CLI
npx tessl i tessl/maven-org-codehaus-groovy--groovy-console