Class LogUI

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, ChainsawViewer, SettingsListener

public class LogUI extends JFrame implements ChainsawViewer, SettingsListener
The main entry point for Chainsaw, this class represents the first frame that is used to display a Welcome panel, and any other panels that are generated because Logging Events are streamed via a Receiver, or other mechanism.

NOTE: Some of Chainsaw's application initialization should be performed prior to activating receivers and the logging framework used to perform self-logging.

DELAY as much as possible the logging framework initialization process, currently initialized by the creation of a ChainsawAppenderHandler.

See Also:
  • Field Details

    • MAIN_WINDOW_HEIGHT

      private static final String MAIN_WINDOW_HEIGHT
      See Also:
    • MAIN_WINDOW_WIDTH

      private static final String MAIN_WINDOW_WIDTH
      See Also:
    • MAIN_WINDOW_Y

      private static final String MAIN_WINDOW_Y
      See Also:
    • MAIN_WINDOW_X

      private static final String MAIN_WINDOW_X
      See Also:
    • splash

      private static ChainsawSplash splash
    • DEFAULT_MAIN_RECEIVER_SPLIT_LOCATION

      private static final double DEFAULT_MAIN_RECEIVER_SPLIT_LOCATION
      See Also:
    • preferencesFrame

      private final JFrame preferencesFrame
    • noReceiversDefined

      private boolean noReceiversDefined
    • receiversPanel

      private ReceiversPanel receiversPanel
    • tabbedPane

      private ChainsawTabbedPane tabbedPane
    • toolbar

      private JToolBar toolbar
    • statusBar

      private ChainsawStatusBar statusBar
    • applicationPreferenceModel

      private ApplicationPreferenceModel applicationPreferenceModel
    • applicationPreferenceModelPanel

      private ApplicationPreferenceModelPanel applicationPreferenceModelPanel
    • tableModelMap

      private final Map tableModelMap
    • tableMap

      private final Map tableMap
    • filterableColumns

      private final List<String> filterableColumns
    • panelMap

      private final Map<String,Component> panelMap
    • handler

    • tbms

    • aboutBox

      private ChainsawAbout aboutBox
    • sm

      private final SettingsManager sm
    • tutorialFrame

      private final JFrame tutorialFrame
    • mainReceiverSplitPane

      private JSplitPane mainReceiverSplitPane
    • lastMainReceiverSplitLocation

      private double lastMainReceiverSplitLocation
    • identifierPanels

      private final List<LogPanel> identifierPanels
    • dividerSize

      private int dividerSize
    • cyclicBufferSize

      private int cyclicBufferSize
    • logger

      private static org.apache.log4j.Logger logger
    • configurationURLAppArg

      private static String configurationURLAppArg
    • isGUIFullyInitialized

      private boolean isGUIFullyInitialized
      Set to true, if and only if the GUI has completed it's full initialization. Any logging events that come in must wait until this is true, and if it is false, should wait on the initializationLock object until notified.
    • initializationLock

      private final Object initializationLock
    • shutdownAction

      private Action shutdownAction
      The shutdownAction is called when the user requests to exit Chainsaw, and by default this exits the VM, but a developer may replace this action with something that better suits their needs
    • shutdownListenerList

      private EventListenerList shutdownListenerList
      Clients can register a ShutdownListener to be notified when the user has requested Chainsaw to exit.
    • welcomePanel

      private WelcomePanel welcomePanel
    • repositorySelectorGuard

      private static final Object repositorySelectorGuard
    • repositoryExImpl

      private static final LoggerRepositoryExImpl repositoryExImpl
    • pluginRegistry

      private PluginRegistry pluginRegistry
    • allColorizers

      private Map<String,RuleColorizer> allColorizers
    • receiverConfigurationPanel

      private ReceiverConfigurationPanel receiverConfigurationPanel
  • Constructor Details

    • LogUI

      public LogUI()
      Constructor which builds up all the visual elements of the frame including the Menu bar
  • Method Details

    • showSplash

      private static final void showSplash(Frame owner)
    • removeSplash

      private static final void removeSplash()
    • addShutdownListener

      public void addShutdownListener(ShutdownListener l)
      Registers a ShutdownListener with this calss so that it can be notified when the user has requested that Chainsaw exit.
      Parameters:
      l -
    • removeShutdownListener

      public void removeShutdownListener(ShutdownListener l)
      Removes the registered ShutdownListener so that the listener will not be notified on a shutdown.
      Parameters:
      l -
    • main

      public static void main(String[] args)
      Starts Chainsaw by attaching a new instance to the Log4J main root Logger via a ChainsawAppender, and activates itself
      Parameters:
      args -
    • createChainsawGUI

      public static void createChainsawGUI(ApplicationPreferenceModel model, Action newShutdownAction)
      Creates, activates, and then shows the Chainsaw GUI, optionally showing the splash screen, and using the passed shutdown action when the user requests to exit the application (if null, then Chainsaw will exit the vm)
      Parameters:
      model -
      newShutdownAction - DOCUMENT ME!
    • activateViewer

      public void activateViewer(ChainsawAppender appender)
      Allow Chainsaw v2 to be ran in-process (configured as a ChainsawAppender) NOTE: Closing Chainsaw will NOT stop the application generating the events.
      Specified by:
      activateViewer in interface ChainsawViewer
      Parameters:
      appender -
    • initGUI

      private void initGUI()
      Initialises the menu's and toolbars, but does not actually create any of the main panel components.
    • initPlugins

      private void initPlugins(PluginRegistry pluginRegistry)
    • setupReceiverPanel

      private void setupReceiverPanel()
    • setupHelpSystem

      private void setupHelpSystem()
      Initialises the Help system and the WelcomePanel
    • ensureWelcomePanelVisible

      private void ensureWelcomePanelVisible()
    • loadSettings

      public void loadSettings(LoadSettingsEvent event)
      Given the load event, configures the size/location of the main window etc etc.
      Specified by:
      loadSettings in interface SettingsListener
      Parameters:
      event - DOCUMENT ME!
    • saveSettings

      public void saveSettings(SaveSettingsEvent event)
      Ensures the location/size of the main window is stored with the settings
      Specified by:
      saveSettings in interface SettingsListener
      Parameters:
      event - DOCUMENT ME!
    • activateViewer

      public void activateViewer()
      Activates itself as a viewer by configuring Size, and location of itself, and configures the default Tabbed Pane elements with the correct layout, table columns, and sets itself viewable.
    • showReceiverPanel

      private void showReceiverPanel()
      Display the log tree pane, using the last known divider location
    • hideReceiverPanel

      private void hideReceiverPanel()
      Hide the log tree pane, holding the current divider location for later use
    • initSocketConnectionListener

      private void initSocketConnectionListener()
    • initPrefModelListeners

      private void initPrefModelListeners()
    • showReceiverConfigurationPanel

      private void showReceiverConfigurationPanel()
      Displays a dialog which will provide options for selecting a configuration
    • exit

      public boolean exit()
      Exits the application, ensuring Settings are saved.
    • addWelcomePanel

      void addWelcomePanel()
    • removeWelcomePanel

      void removeWelcomePanel()
    • getStatusBar

      ChainsawStatusBar getStatusBar()
    • showApplicationPreferences

      public void showApplicationPreferences()
    • showReceiverConfiguration

      public void showReceiverConfiguration()
    • showAboutBox

      public void showAboutBox()
    • getPanels

      Map getPanels()
    • displayPanel

      void displayPanel(String panelName, boolean display)
    • shutdown

      public boolean shutdown()
      Shutsdown by ensuring the Appender gets a chance to close.
    • fireShutdownEvent

      private void fireShutdownEvent()
      Ensures all the registered ShutdownListeners are notified.
    • setShutdownAction

      public final void setShutdownAction(Action shutdownAction)
      Configures LogUI's with an action to execute when the user requests to exit the application, the default action is to exit the VM. This Action is called AFTER all the ShutdownListeners have been notified
      Parameters:
      shutdownAction -
    • performShutdownAction

      private void performShutdownAction()
      Using the current thread, calls the registed Shutdown action's actionPerformed(...) method.
    • getCurrentLogPanel

      LogPanel getCurrentLogPanel()
      Returns the currently selected LogPanel, if there is one, otherwise null
      Returns:
      current log panel
    • setStatusBarVisible

      private void setStatusBarVisible(boolean visible)
      Parameters:
      visible -
    • isStatusBarVisible

      boolean isStatusBarVisible()
    • getActiveTabName

      public String getActiveTabName()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • showHelp

      public void showHelp(URL url)
      Causes the Welcome Panel to become visible, and shows the URL specified as it's contents
      Parameters:
      url - for content to show
    • getWelcomePanel

      private WelcomePanel getWelcomePanel()
      DOCUMENT ME!
      Returns:
      welcome panel
    • isLogTreePanelVisible

      public boolean isLogTreePanelVisible()
      DOCUMENT ME!
      Returns:
      log tree panel visible flag
    • getPanelMap

      public Map<String,Component> getPanelMap()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getSettingsManager

      public SettingsManager getSettingsManager()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getFilterableColumns

      public List<String> getFilterableColumns()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setToolBarAndMenus

      public void setToolBarAndMenus(ChainsawToolBarAndMenus tbms)
      DOCUMENT ME!
      Parameters:
      tbms - DOCUMENT ME!
    • getToolBarAndMenus

      public ChainsawToolBarAndMenus getToolBarAndMenus()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getTableMap

      public Map getTableMap()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getTableModelMap

      public Map getTableModelMap()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setTabbedPane

      public void setTabbedPane(ChainsawTabbedPane tabbedPane)
      DOCUMENT ME!
      Parameters:
      tabbedPane - DOCUMENT ME!
    • getTabbedPane

      public ChainsawTabbedPane getTabbedPane()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getApplicationPreferenceModel

      public final ApplicationPreferenceModel getApplicationPreferenceModel()
      Returns:
      Returns the applicationPreferenceModel.
    • setupTutorial

      public void setupTutorial()
      DOCUMENT ME!
    • buildLogPanel

      private void buildLogPanel(boolean customExpression, String ident, List<org.apache.log4j.spi.LoggingEvent> events) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • createCustomExpressionLogPanel

      public void createCustomExpressionLogPanel(String ident)
    • loadConfigurationUsingPluginClassLoader

      private void loadConfigurationUsingPluginClassLoader(URL url)
      Loads the log4j configuration file specified by the url, using the PluginClassLoader instance as a TCCL, but only replacing it temporarily, with the original TCCL being restored in a finally block to ensure consitency.
      Parameters:
      url -
    • loadLookAndFeelUsingPluginClassLoader

      private static void loadLookAndFeelUsingPluginClassLoader(String lookAndFeelClassName)
    • ensureChainsawAppenderHandlerAdded

      private void ensureChainsawAppenderHandlerAdded()
      Makes sure that the LoggerRepository has the ChainsawAppenderHandler added to the root logger so Chainsaw can receive all the events.