* Listens to changes to one or more commands, and forwards them out through
* the property change event mechanism.
*/
private final class CommandListener implements ICommandListener {
public final void commandChanged(final CommandEvent commandEvent) {
final Command baseCommand = commandEvent.getCommand();
// Check if the name changed.
if (commandEvent.isNameChanged()) {
String newName = null;
if (baseCommand.isDefined()) {
try {
newName = baseCommand.getName();
} catch (final NotDefinedException e) {
// Not defined, so leave as null.
}
}
firePropertyChange(IAction.TEXT, null, newName);
}
// Check if the description changed.
if (commandEvent.isDescriptionChanged()) {
String newDescription = null;
if (baseCommand.isDefined()) {
try {
newDescription = baseCommand.getDescription();
} catch (final NotDefinedException e) {
// Not defined, so leave as null.
}
}
firePropertyChange(IAction.DESCRIPTION, null, newDescription);
firePropertyChange(IAction.TOOL_TIP_TEXT, null, newDescription);
}
// Check if the handled property changed.
if (commandEvent.isHandledChanged()) {
if (baseCommand.isHandled()) {
firePropertyChange(IAction.HANDLED, Boolean.FALSE,
Boolean.TRUE);
} else {
firePropertyChange(IAction.HANDLED, Boolean.TRUE,
Boolean.FALSE);