Add an UpdateCommandState method to the command maanger.

This commit is contained in:
sfraser%netscape.com 2000-05-01 01:33:22 +00:00
Родитель 79d35d4d27
Коммит 18e706dc0d
4 изменённых файлов: 82 добавлений и 2 удалений

Просмотреть файл

@ -131,6 +131,14 @@ interface nsIControllerCommandManager : nsISupports
*/
boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon);
/**
* Tell the command to udpate its state (if it is a state updating command)
*
* @param aCommandName the name of the command to update
* @param aCommandRefCon the command context data
*/
void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon);
/**
* Get whether the named command is supported.
*

Просмотреть файл

@ -118,7 +118,39 @@ nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsIS
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
}
/* boolean supportsCommand (in wstring command); */
NS_IMETHODIMP
nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, nsISupports *aCommandRefCon)
{
NS_ENSURE_ARG_POINTER(aCommandName);
// find the command
nsCOMPtr<nsIControllerCommand> commandHandler;
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
if (!commandHandler)
{
#if DEBUG
nsCAutoString msg("Controller command manager asked to update the state of a command that it does not handle -- ");
msg.AppendWithConversion(aCommandName);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command
}
nsCOMPtr<nsIStateUpdatingControllerCommand> stateCommand = do_QueryInterface(commandHandler);
if (!stateCommand)
{
#if DEBUG
nsCAutoString msg("Controller command manager asked to update the state of a command that doesn't do state updating -- ");
msg.AppendWithConversion(aCommandName);
NS_WARNING(msg);
#endif
return NS_ERROR_NO_INTERFACE;
}
return stateCommand->UpdateCommandState(aCommandName, aCommandRefCon);
}
NS_IMETHODIMP
nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult)
{

Просмотреть файл

@ -131,6 +131,14 @@ interface nsIControllerCommandManager : nsISupports
*/
boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon);
/**
* Tell the command to udpate its state (if it is a state updating command)
*
* @param aCommandName the name of the command to update
* @param aCommandRefCon the command context data
*/
void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon);
/**
* Get whether the named command is supported.
*

Просмотреть файл

@ -118,7 +118,39 @@ nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsIS
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
}
/* boolean supportsCommand (in wstring command); */
NS_IMETHODIMP
nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, nsISupports *aCommandRefCon)
{
NS_ENSURE_ARG_POINTER(aCommandName);
// find the command
nsCOMPtr<nsIControllerCommand> commandHandler;
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
if (!commandHandler)
{
#if DEBUG
nsCAutoString msg("Controller command manager asked to update the state of a command that it does not handle -- ");
msg.AppendWithConversion(aCommandName);
NS_WARNING(msg);
#endif
return NS_OK; // we don't handle this command
}
nsCOMPtr<nsIStateUpdatingControllerCommand> stateCommand = do_QueryInterface(commandHandler);
if (!stateCommand)
{
#if DEBUG
nsCAutoString msg("Controller command manager asked to update the state of a command that doesn't do state updating -- ");
msg.AppendWithConversion(aCommandName);
NS_WARNING(msg);
#endif
return NS_ERROR_NO_INTERFACE;
}
return stateCommand->UpdateCommandState(aCommandName, aCommandRefCon);
}
NS_IMETHODIMP
nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult)
{