| 249 | } |
| 250 | |
| 251 | IElementFactory* WorkbenchPlugin::GetElementFactory(const QString& targetID) const |
| 252 | { |
| 253 | // Get the extension point registry. |
| 254 | IExtensionPoint::Pointer extensionPoint = Platform::GetExtensionRegistry()->GetExtensionPoint( |
| 255 | PlatformUI::PLUGIN_ID(), |
| 256 | WorkbenchRegistryConstants::PL_ELEMENT_FACTORY); |
| 257 | |
| 258 | IElementFactory* factory = nullptr; |
| 259 | if (!extensionPoint) |
| 260 | { |
| 261 | WorkbenchPlugin::Log("Unable to find element factory. Extension point: " + |
| 262 | WorkbenchRegistryConstants::PL_ELEMENT_FACTORY + " not found"); |
| 263 | return factory; |
| 264 | } |
| 265 | |
| 266 | // Loop through the config elements. |
| 267 | IConfigurationElement::Pointer targetElement; |
| 268 | QList<IConfigurationElement::Pointer> configElements = |
| 269 | extensionPoint->GetConfigurationElements(); |
| 270 | for (int j = 0; j < configElements.size(); j++) |
| 271 | { |
| 272 | QString strID = configElements[j]->GetAttribute("id"); |
| 273 | if (targetID == strID) |
| 274 | { |
| 275 | targetElement = configElements[j]; |
| 276 | break; |
| 277 | } |
| 278 | } |
| 279 | if (!targetElement) |
| 280 | { |
| 281 | // log it since we cannot safely display a dialog. |
| 282 | WorkbenchPlugin::Log("Unable to find element factory: " + targetID); |
| 283 | return factory; |
| 284 | } |
| 285 | |
| 286 | // Create the extension. |
| 287 | try |
| 288 | { |
| 289 | factory = targetElement->CreateExecutableExtension<IElementFactory>("class"); |
| 290 | } |
| 291 | catch (const CoreException& e) |
| 292 | { |
| 293 | // log it since we cannot safely display a dialog. |
| 294 | WorkbenchPlugin::Log("Unable to create element factory.", e.GetStatus()); |
| 295 | factory = nullptr; |
| 296 | } |
| 297 | return factory; |
| 298 | } |
| 299 | |
| 300 | IPresentationFactory* WorkbenchPlugin::GetPresentationFactory() { |
| 301 | if (presentationFactory != nullptr) return presentationFactory; |
nothing calls this directly
no test coverage detected