SmartPointer<IElementReference> CommandService::RegisterElementForCommand( const SmartPointer<ParameterizedCommand>& command, const SmartPointer<UIElement>& element) { if (!command->GetCommand()->IsDefined()) { throw NotDefinedException( "Cannot define a callback for undefined command " + command->GetCommand()->GetId()); } if (element.IsNull()) { throw NotDefinedException("No callback defined for command " + command->GetCommand()->GetId()); } QHash<QString, QString> paramMap = command->GetParameterMap(); QHash<QString, Object::Pointer> parms; for (QHash<QString, QString>::const_iterator i = paramMap.begin(); i != paramMap.end(); ++i) { Object::Pointer value(new ObjectString(i.value())); parms.insert(i.key(), value); } IElementReference::Pointer ref(new ElementReference(command->GetId(), element, parms)); RegisterElement(ref); return ref; }
SmartPointer<const ExecutionEvent> HandlerService::CreateExecutionEvent( const SmartPointer<const ParameterizedCommand>& command, const SmartPointer<const UIElement>& trigger) { ExecutionEvent::Pointer event( new ExecutionEvent(command->GetCommand(), command->GetParameterMap(), trigger, Object::Pointer(GetCurrentState()))); return event; }
void CommandManager::CommandListener::CommandChanged(const SmartPointer<const CommandEvent> commandEvent) { if (commandEvent->IsDefinedChanged()) { const Command::Pointer command(commandEvent->GetCommand()); const std::string commandId = command->GetId(); const bool commandIdAdded = command->IsDefined(); if (commandIdAdded) { commandManager->definedHandleObjects.insert(command); } else { commandManager->definedHandleObjects.erase(command); } CommandManagerEvent::Pointer event(new CommandManagerEvent(*commandManager, commandId, commandIdAdded, true, "", false, false)); commandManager->FireCommandManagerChanged(event); } }
void CommandContributionItem::UpdateCommandPropertiesInUI(const SmartPointer< const CommandEvent>& commandEvent) { if (commandEvent->GetCommand()->IsDefined()) { this->Update(); } if (commandEvent->IsEnabledChanged() || commandEvent->IsHandledChanged()) { if (visibleEnabled) { IContributionManager* parent = this->GetParent(); if (parent) { parent->Update(true); } } } }