GUI Commands README

Version 2.1
Copyright (c) 2006 - 2007 Andrew Pietsch
All rights reserved.

Quick Start

Commands

The following is a quick example of the configuration for a typical command defined using a property file resource bundle. Lets put the following in the file Commands.properties.

  copy-command@face.text=_Copy@default C
  copy-command@face.icon=classpath:images/copy.png
  copy-command@face.description=\
     Copies the current selection to the clipboard ($accelerator)

The configuration is loaded using GuiCommands.load(bundle) methods.

  // load the file 'Commands.properties' from the classpath.
  GuiCommands.load("Commands");

Once loaded you can create the command as follows.

  ActionCommand copyCommand = new ActionCommand("copy-command")
  {
     public void handleExecute()
     {
        // perform the copy opertation.
     }
  }

You can now use the command to create buttons.

  AbstractButton button = copyCommand.createButton();

Using Groups

Groups are a powerful feature of GuiCommands that allow you to create dynamic menus and toolbars quickly and easily. Groups use CommandContainers to locate and find their members.

First lets define some group configuration.

  group!edit-group@face.text=_Edit
  group!edit-group@members=cut-command, copy-command, paste-command

Then we simple create the group.

  CommandGroup editGroup = new CommandGroup("edit-group");

At this stage the group can create buttons and menu's, but it won't yet have any content. To populate the group we need to create it's commands and bind everything to a CommandContainer.

  // create a container
  CommandContainer container = new CommandContainer();

  // create and bind the commands.
  CopyCommand cutCommand = new CutCommand();
  CopyCommand copyCommand = new CopyCommand();
  CopyCommand pasteCommand = new PasteCommand();

  cutCommand.bind(container);
  copyCommand.bind(container);
  pasteCommand.bind(container);

  // bind the group.
  editGroup.bind(container);

Once the group is bound it will update all its buttons and menus with the members discovered in the container. Order is not important, the group monitors the container and updates as commands are added and removed.

Documentation

For more detailed documentation please refer to the User Guide and Javadoc.

Support

You can participate on the user forums or contact me directly at support@pietschy.com.

Copyright and License

You must agree to the terms of the License Agreement before using GUI Commands.
Copyright (c) 2006 - 2007 Andrew Pietsch. All rights reserved.

Build 1077