CommandParameter::CommandParameter(const QString& id, const QString& name, const SmartPointer<IConfigurationElement>& values, const SmartPointer<ParameterType>& parameterType, const bool optional) : name(name) , optional(optional) , parameterType(parameterType) , valuesConfigurationElement(values) , id(id) { if (id.isNull()) { throw ctkInvalidArgumentException("Cannot create a parameter with a null id"); } if (name.isNull()) { throw ctkInvalidArgumentException("The name of a parameter cannot be null."); } if (values.IsNull()) { throw ctkInvalidArgumentException("The values for a parameter cannot be null."); } }
void Preferences::AssertPath_unlocked(const QString& pathName) { if(pathName.indexOf("//") != -1) { throw ctkInvalidArgumentException(QString("Illegal // in m_Path m_Name '") + pathName + "'"); } int strLength = pathName.size(); if(strLength > 1 && pathName[strLength-1] == '/') { throw ctkInvalidArgumentException(QString("Trailing / in m_Path m_Name '") + pathName + "'"); } }
//---------------------------------------------------------------------------- ctkRequirePlugin::ctkRequirePlugin(ctkPluginPrivate* requestor, const QString& name, const QString& res, const QString& range) : name(name), resolution(res.isEmpty() ? ctkPluginConstants::RESOLUTION_MANDATORY : res), pluginRange(range.isEmpty() ? ctkVersionRange::defaultVersionRange() : range) { if (resolution != ctkPluginConstants::RESOLUTION_MANDATORY && resolution != ctkPluginConstants::RESOLUTION_OPTIONAL ) { QString what = QString("Invalid directive : '") + ctkPluginConstants::RESOLUTION_DIRECTIVE + ":=" + this->resolution + "' in manifest header '" + ctkPluginConstants::REQUIRE_PLUGIN + ": " + this->name + "' of plugin with id " + requestor->id + " (" + requestor->symbolicName + ")" + ". The value must be either '" + ctkPluginConstants::RESOLUTION_MANDATORY + "' or '" + ctkPluginConstants::RESOLUTION_OPTIONAL + "'."; throw ctkInvalidArgumentException(what); } }
void ServiceLocator::RegisterService(const QString& api, Object* service) const { if (api.isEmpty()) { throw ctkInvalidArgumentException("The service key cannot be empty"); } // if (!api.isInstance(service)) // { // throw new IllegalArgumentException("The service does not implement the given interface"); //$NON-NLS-1$ // } if (services.find(api) != services.end()) { Object* currentService = services[api]; services.remove(api); if (IDisposable* disposable = dynamic_cast<IDisposable*>(currentService)) { disposable->Dispose(); } } if (service) { services.insert(api, service); if (INestable* nestable = dynamic_cast<INestable*>(service)) { if (activated) { nestable->Activate(); } } } }
void Command::AddCommandListener(ICommandListener* commandListener) { if (!commandListener) { throw ctkInvalidArgumentException("Cannot add a null command listener"); } commandEvents.AddListener(commandListener); }
void Command::AddExecutionListener(IExecutionListener* executionListener) { if (!executionListener) { throw ctkInvalidArgumentException("Cannot add a null execution listener"); } executionEvents.AddListener(executionListener); }
IContributionItem::Pointer Create(IWorkbenchWindow* window) override { if (window == nullptr) { throw ctkInvalidArgumentException("window must not be null"); } IContributionItem::Pointer item(new ReopenEditorMenu(window, GetId(), true)); return item; }
IContributionItem::Pointer Create(IWorkbenchWindow* window) override { if (window == nullptr) { throw ctkInvalidArgumentException("window must not be null"); } IContributionItem::Pointer item(new ChangeToPerspectiveMenu(window, GetId())); return item; }
void Command::Define(const QString& name, const QString& description, const CommandCategory::Pointer category, const QList<IParameter::Pointer>& parameters, const ParameterType::Pointer& returnType, const QString& helpContextId) { if (name == "") { throw ctkInvalidArgumentException("The name of a command cannot be empty"); } if (!category) { throw ctkInvalidArgumentException("The category of a command cannot be null"); } const bool definedChanged = !this->defined; this->defined = true; const bool nameChanged = this->name != name; this->name = name; const bool descriptionChanged = this->description != description; this->description = description; const bool categoryChanged = this->category != category; this->category = category; const bool parametersChanged = !CommandUtils::Equals(this->parameters, parameters); this->parameters = parameters; const bool returnTypeChanged = this->returnType != returnType; this->returnType = returnType; const bool helpContextIdChanged = this->helpContextId != helpContextId; this->helpContextId = helpContextId; CommandEvent::Pointer event(new CommandEvent(Command::Pointer(this), categoryChanged, definedChanged, descriptionChanged, false, nameChanged, parametersChanged, returnTypeChanged, helpContextIdChanged)); this->FireCommandChanged(event); }
SlaveHandlerService::SlaveHandlerService(IHandlerService* parentHandlerService, const SmartPointer<Expression>& defaultExpression) : defaultExpression(defaultExpression) , parent(parentHandlerService) { if (parentHandlerService == nullptr) { throw ctkInvalidArgumentException("The parent handler service cannot be null"); } }
ctkEAAbstractAdapter::ctkEAAbstractAdapter(ctkEventAdmin* admin) : admin_(0) { if (admin == 0) { throw ctkInvalidArgumentException("EventAdmin must not be null"); } admin_.testAndSetOrdered(0, admin); }
void Command::RemoveCommandListener(ICommandListener *commandListener) { if (!commandListener) { throw ctkInvalidArgumentException( "Cannot remove a null command listener"); } commandEvents.RemoveListener(commandListener); }
void ParameterType::FireParameterTypeChanged(const SmartPointer< ParameterTypeEvent> event) { if (!event) { throw ctkInvalidArgumentException("Cannot send a null event to listeners."); } parameterTypeEvents.parameterTypeChanged(event); }
ParameterValueConverterProxy::ParameterValueConverterProxy( const SmartPointer<IConfigurationElement>& converterConfigurationElement) : converterConfigurationElement(converterConfigurationElement) { if (converterConfigurationElement.IsNull()) { throw ctkInvalidArgumentException( "converterConfigurationElement must not be null"); } }
void AbstractHandlerWithState::AddState(const QString& stateId, const SmartPointer<State>& state) { if (state.IsNull()) { throw ctkInvalidArgumentException("Cannot add a null state"); } states.insert(stateId, state); state->AddListener(this); HandleStateChange(state, Object::Pointer(0)); }
//---------------------------------------------------------------------------- QObject* ctkPluginContext::getService(const ctkServiceReference& reference) { Q_D(ctkPluginContext); d->isPluginContextValid(); if (!reference) { throw ctkInvalidArgumentException("Default constructed ctkServiceReference is not a valid input to getService()"); } ctkServiceReference internalRef(reference); return internalRef.d_func()->getService(d->plugin->q_func()); }
HandlerService::HandlerService(ICommandService* commandService, IEvaluationService* evaluationService, IServiceLocator* locator) : commandService(commandService) , handlerAuthority(new HandlerAuthority(commandService, locator)) , handlerPersistence(new HandlerPersistence(this, evaluationService)) { if (commandService == nullptr) { throw ctkInvalidArgumentException("A handler service requires a command service"); } }
//---------------------------------------------------------------------------- void ctkPluginPrivate::checkManifestHeaders() { symbolicName = archive->getAttribute(ctkPluginConstants::PLUGIN_SYMBOLICNAME); if (symbolicName.isEmpty()) { throw ctkInvalidArgumentException(QString("ctkPlugin has no symbolic name, location=") + location); } QString mpv = archive->getAttribute(ctkPluginConstants::PLUGIN_VERSION); if (!mpv.isEmpty()) { try { version = ctkVersion(mpv); } catch (const std::exception& e) { throw ctkInvalidArgumentException(QString("ctkPlugin does not specify a valid ") + ctkPluginConstants::PLUGIN_VERSION + " header. Got exception: " + e.what()); } } QSharedPointer<ctkPlugin> snp = fwCtx->plugins->getPlugin(symbolicName, version); // TBD! Should we allow update to same version? if (!snp.isNull() && snp->d_func() != this) { throw ctkInvalidArgumentException(QString("Plugin with same symbolic name and version is already installed (") + symbolicName + ", " + version.toString() + ")"); } QString ap = archive->getAttribute(ctkPluginConstants::PLUGIN_ACTIVATIONPOLICY); if (ctkPluginConstants::ACTIVATION_EAGER == ap) { eagerActivation = true; } }
void RegistryObjectReferenceMap::Put(int key, const SmartPointer<RegistryObject>& value) { if (value.IsNull()) throw ctkInvalidArgumentException("null values not allowed"); Purge(); ReferenceMapType::Iterator i = references.find(key); if (i != references.end()) { delete *i; } references.insert(key, NewEntry(value)); }
void AbstractHandlerWithState::RemoveState(const QString& stateId) { if (stateId.isNull()) { throw ctkInvalidArgumentException("Cannot remove a null state"); } QHash<QString,State::Pointer>::iterator i = states.find(stateId); if (i != states.end()) { (*i)->RemoveListener(this); states.erase(i); } }
void Command::FireCommandChanged(const CommandEvent::ConstPointer commandEvent) { if (!commandEvent) { throw ctkInvalidArgumentException("Cannot fire a null event"); } try { commandEvents.commandChanged(commandEvent); } catch (...) { //TODO log exceptions? } }
//---------------------------------------------------------------------------- bool ctkPluginContext::connectPluginListener(const QObject* receiver, const char* slot, Qt::ConnectionType type) { Q_D(ctkPluginContext); d->isPluginContextValid(); // TODO check permissions for a direct connection if (type == Qt::DirectConnection || type == Qt::BlockingQueuedConnection) { return receiver->connect(&(d->plugin->fwCtx->listeners), SIGNAL(pluginChangedDirect(ctkPluginEvent)), slot, type); } else if (type == Qt::QueuedConnection) { return receiver->connect(&(d->plugin->fwCtx->listeners), SIGNAL(pluginChangedQueued(ctkPluginEvent)), slot, type); } else { throw ctkInvalidArgumentException("Only Qt::DirectConnection, Qt::QueuedConnection, or Qt::BlockingQueuedConnection are allowed as type argument."); } }
bool ExtensionsParser::parseManifest(QXmlReader* reader, QXmlInputSource* in, const QString& manifestName, RegistryObjectManager* registryObjects, const SmartPointer<RegistryContribution>& currentNamespace, QTranslator* translator) { QTime start; this->resources = translator; this->objectManager = registryObjects; //initialize the parser with this object this->contribution = currentNamespace; if (registry->Debug()) start.start(); if (reader == nullptr) { cumulativeTime += start.elapsed(); throw ctkInvalidArgumentException("XML Reader not available"); } locationName = manifestName; reader->setContentHandler(this); reader->setDeclHandler(this); reader->setDTDHandler(this); reader->setEntityResolver(this); reader->setErrorHandler(this); reader->setLexicalHandler(this); bool success = reader->parse(in); if (registry->Debug()) { cumulativeTime += start.elapsed(); BERRY_INFO << "Cumulative parse time so far : " << cumulativeTime; } return success; }