* Calling this method with an undefined command id will generate a log
* message.
*/
public final boolean isActive(final String commandId) {
if (commandId != null) {
final Command command = commandManager.getCommand(commandId);
if (!command.isDefined()
&& (!loggedCommandIds.contains(commandId))) {
// The command is not yet defined, so we should log this.
final String message = MessageFormat.format(Util
.translateString(RESOURCE_BUNDLE,
"undefinedCommand.WarningMessage", null), //$NON-NLS-1$
new String[] { command.getId() });
IStatus status = new Status(IStatus.ERROR,
"org.eclipse.jface", //$NON-NLS-1$
0, message, new Exception());
Policy.getLog().log(status);
// And remember this item so we don't log it again.
loggedCommandIds.add(commandId);
command.addCommandListener(new ICommandListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.commands.ICommandListener#commandChanged(org.eclipse.ui.commands.CommandEvent)
*/
public final void commandChanged(
final CommandEvent commandEvent) {
if (command.isDefined()) {
command.removeCommandListener(this);
loggedCommandIds.remove(commandId);
}
}
});