Debugging

Debuging Groups

GUI Commands provides a debug mode that makes it easy to identify group members that haven't been resolved by the group. To activate the debug mode simply set the the system property com.pietschy.command.debugGroups to true.

   # Setting the debug property from the command line
   -Dcom.pietschy.command.debugGroups=true

The following shows the debug example from the online demo. Missing commands are displayed in red for easy identification.

Activating Debug Mode Programatically

It is also possible to manually achieve the same result without setting the sytem property. To do this you need to configure the GroupMemberFactory to be an instance of DebugGroupMemberFactory. The following example demonstrates.

   // create install the debug version of the group member factory
   GroupMemberFactory factory = new DebugGroupMemberFactory();
   GuiCommands.defaults().setGroupMemberFactory(factory);

The factory must be configured before any groups are created.

Debugging CommandContainers

The debugState() method lists all the commands, groups, delegates and properties of a CommandContainer. The method repeats this information for all containers in the hierarchy. The following shows how to dump the contents of a CommandContainer.

   CommandContainer container = ...;
   container.debugState(System.out);

The following is an example of the output generated from the debug example in the online demo.

   CommandContainer@13627328(binding=DebugDemo@1828223)
   actionCommands[save, debug-container-state]
   delegates[]
   groups[debug.menu]
   properties[]
   parent---
     CommandContainer@11374012(binding=DemoFrame@2254042)
     actionCommands[paste-from-clipboard, command-four, 
                    SwingWorkerDemo.selector, UndoDemo.selector, 
                    command-three, exit, show-config, command-two, 
                    DebugDemo.selector, FaceDemo.selector, command-one, 
                    cut-to-clipboard, redo, print, ToggleDemo.selector, 
                    DelegateDemo.selector, undo, WelcomePanel.selector, 
                    copy-to-clipboard, GroupDemo.selector]
     delegates[]
     groups[help-menu, view-menu, main-menu, download-menu, 
            demo-selector-group, edit-menu, file-menu, main-toolbar]
     properties[glassPaneStrategy, delegateMediator, undoContext]
     parent---
       GlobalCommandContainer@3430385(binding=null)
       actionCommands[view-license, new-window, buy-now, download-library,
                      help-about]
       delegates[]
       groups[]
       properties[]