| 147 | } |
| 148 | |
| 149 | Object::Pointer Command::ExecuteWithChecks(const ExecutionEvent::ConstPointer event) |
| 150 | { |
| 151 | this->FirePreExecute(event); |
| 152 | const IHandler::Pointer handler(this->handler); |
| 153 | |
| 154 | if (!this->IsDefined()) |
| 155 | { |
| 156 | const NotDefinedException exception( |
| 157 | "Trying to execute a command that is not defined. " + this->GetId()); |
| 158 | this->FireNotDefined(&exception); |
| 159 | throw exception; |
| 160 | } |
| 161 | |
| 162 | // Perform the execution, if there is a handler. |
| 163 | if (handler && handler->IsHandled()) |
| 164 | { |
| 165 | this->SetEnabled(event->GetApplicationContext()); |
| 166 | if (!this->IsEnabled()) { |
| 167 | const NotEnabledException exception( |
| 168 | "Trying to execute the disabled command " + this->GetId()); |
| 169 | this->FireNotEnabled(&exception); |
| 170 | throw exception; |
| 171 | } |
| 172 | |
| 173 | try |
| 174 | { |
| 175 | const Object::Pointer returnValue(handler->Execute(event)); |
| 176 | this->FirePostExecuteSuccess(returnValue); |
| 177 | return returnValue; |
| 178 | } |
| 179 | catch (const ExecutionException* e) |
| 180 | { |
| 181 | this->FirePostExecuteFailure(e); |
| 182 | throw e; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | const NotHandledException e( |
| 187 | "There is no handler to execute for command " + this->GetId()); |
| 188 | this->FireNotHandled(&e); |
| 189 | throw e; |
| 190 | } |
| 191 | |
| 192 | void Command::FireCommandChanged(const CommandEvent::ConstPointer commandEvent) |
| 193 | { |
no test coverage detected