IterateExpression::IterateExpression( const IConfigurationElement::Pointer& configElement) { QString opValue = configElement->GetAttribute(ATT_OPERATOR); this->InitializeOperatorValue(opValue); this->InitializeEmptyResultValue(configElement->GetAttribute(ATT_IF_EMPTY)); }
SystemTestExpression::SystemTestExpression(const IConfigurationElement::Pointer& element) { fProperty = element->GetAttribute(ATT_PROPERTY); Expressions::CheckAttribute(ATT_PROPERTY, fProperty); fExpectedValue = element->GetAttribute(ATT_VALUE); Expressions::CheckAttribute(ATT_VALUE, fExpectedValue); }
SystemTestExpression::SystemTestExpression(IConfigurationElement::Pointer element) { bool result = element->GetAttribute(ATT_PROPERTY, fProperty); Expressions::CheckAttribute(ATT_PROPERTY, result); result = element->GetAttribute(ATT_VALUE, fExpectedValue); Expressions::CheckAttribute(ATT_VALUE, result); }
bool PerspectiveRegistryReader::ReadElement(const IConfigurationElement::Pointer &element) { if (element->GetName() == WorkbenchRegistryConstants::TAG_PERSPECTIVE) { try { QString id = element->GetAttribute(WorkbenchRegistryConstants::ATT_ID); PerspectiveDescriptor::Pointer desc( new PerspectiveDescriptor(id, element)); QList<berry::IConfigurationElement::Pointer> childs = element->GetChildren("description"); if (!childs.isEmpty()) { desc->SetDescription(childs[0]->GetValue()); } registry->AddPerspective(desc); } catch (const CoreException& e) { // log an error since its not safe to open a dialog here WorkbenchPlugin::Log("Unable to create layout descriptor.", e);//$NON-NLS-1$ } return true; } return false; }
Expression::Pointer StandardElementHandler::Create(ExpressionConverter* converter, IConfigurationElement::Pointer element) { std::string name = element->GetName(); if (ExpressionTagNames::INSTANCEOF == name) { Expression::Pointer result(new InstanceofExpression(element)); return result; } else if (ExpressionTagNames::TEST == name) { Expression::Pointer result(new TestExpression(element)); return result; } else if (ExpressionTagNames::OR == name) { CompositeExpression::Pointer result(new OrExpression()); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::AND == name) { CompositeExpression::Pointer result(new AndExpression()); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::NOT == name) { IConfigurationElement::vector children(element->GetChildren()); Expression::Pointer result(new NotExpression(converter->Perform(children[0]))); return result; } else if (ExpressionTagNames::WITH == name) { CompositeExpression::Pointer result(new WithExpression(element)); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::ADAPT == name) { CompositeExpression::Pointer result(new AdaptExpression(element)); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::ITERATE == name) { CompositeExpression::Pointer result(new IterateExpression(element)); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::COUNT == name) { Expression::Pointer result(new CountExpression(element)); return result; } else if (ExpressionTagNames::SYSTEM_TEST == name) { Expression::Pointer result(new SystemTestExpression(element)); return result; } else if (ExpressionTagNames::RESOLVE == name) { CompositeExpression::Pointer result(new ResolveExpression(element)); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::ENABLEMENT == name) { CompositeExpression::Pointer result(new EnablementExpression(element)); this->ProcessChildren(converter, element, result); return result; } else if (ExpressionTagNames::EQUALS == name) { Expression::Pointer result(new EqualsExpression(element)); return result; } else if (ExpressionTagNames::REFERENCE == name) { Expression::Pointer result(new ReferenceExpression(element)); return result; } return Expression::Pointer(); }
SmartPointer<Expression> RegistryPersistence::ReadWhenElement( const SmartPointer<IConfigurationElement>& parentElement, const QString& whenElementName, const QString& id, QList<SmartPointer<IStatus> >& warningsToLog) { // Check to see if we have an when expression. const QList<IConfigurationElement::Pointer> whenElements = parentElement ->GetChildren(whenElementName); Expression::Pointer whenExpression; if (!whenElements.isEmpty()) { // Check if we have too many when elements. if (whenElements.size() > 1) { // There should only be one when element AddWarning(warningsToLog, "There should only be one when element", parentElement, id, "whenElementName", whenElementName); return ERROR_EXPRESSION; } const IConfigurationElement::Pointer whenElement = whenElements.front(); const QList<IConfigurationElement::Pointer> expressionElements = whenElement->GetChildren(); if (!expressionElements.isEmpty()) { // Check if we have too many expression elements if (expressionElements.size() > 1) { // There should only be one expression element AddWarning(warningsToLog, "There should only be one expression element", parentElement, id, "whenElementName", whenElementName); return ERROR_EXPRESSION; } // Convert the activeWhen element into an expression. const ElementHandler::Pointer elementHandler = ElementHandler::GetDefault(); ExpressionConverter* const converter = ExpressionConverter::GetDefault(); const IConfigurationElement::Pointer expressionElement = expressionElements.front(); try { whenExpression = elementHandler->Create(converter, expressionElement); } catch (const CoreException& /*e*/) { // There when expression could not be created. AddWarning(warningsToLog, "Problem creating when element", parentElement, id, "whenElementName", whenElementName); return ERROR_EXPRESSION; } } } return whenExpression; }
QSharedPointer<ctkPlugin> WorkbenchPlugin::GetBundleForExecutableExtension( const IConfigurationElement::Pointer& element, const QString& extensionName) { // this code is derived heavily from // ConfigurationElement.createExecutableExtension. QString prop; QString executable; QString contributorName; int i = 0; if (!extensionName.isNull()) prop = element->GetAttribute(extensionName); else { // property not specified, try as element value prop = element->GetValue(); if (!prop.isNull()) { prop = prop.trimmed(); if (prop.isEmpty()) prop = QString(); } } if (prop.isNull()) { // property not defined, try as a child element QList<IConfigurationElement::Pointer> exec(element->GetChildren(extensionName)); if (!exec.isEmpty()) contributorName = exec[0]->GetAttribute("plugin"); } else { // simple property or element value, parse it into its components i = prop.indexOf(':'); if (i != -1) executable = prop.left(i).trimmed(); else executable = prop; i = executable.indexOf('/'); if (i != -1) contributorName = executable.left(i).trimmed(); } if (contributorName.isNull()) contributorName = element->GetContributor()->GetName(); return Platform::GetPlugin(contributorName); }
IBundle::Pointer WorkbenchPlugin::GetBundleForExecutableExtension( IConfigurationElement::Pointer element, const std::string& extensionName) { // this code is derived heavily from // ConfigurationElement.createExecutableExtension. std::string prop; std::string executable; std::string contributorName; std::string::size_type i; if (extensionName != "") element->GetAttribute(extensionName, prop); else { // property not specified, try as element value prop = element->GetValue(); if (prop != "") { Poco::trimInPlace(prop); } } if (prop == "") { // property not defined, try as a child element IConfigurationElement::vector exec(element->GetChildren(extensionName)); if (exec.size() != 0) exec[0]->GetAttribute("plugin", contributorName); //$NON-NLS-1$ } else { // simple property or element value, parse it into its components i = prop.find_first_of(':'); if (i != std::string::npos) executable = Poco::trim(prop.substr(0, i)); else executable = prop; i = executable.find_first_of('/'); if (i != std::string::npos) contributorName = Poco::trim(executable.substr(0, i)); } if (contributorName == "") contributorName = element->GetContributor(); return Platform::GetBundle(contributorName); }
void RegistryReader::LogError(IConfigurationElement::Pointer element, const std::string& text) { const IExtension* extension = element->GetDeclaringExtension(); std::string buf = "Plugin " + extension->GetNamespace() + ", extension " + extension->GetExtensionPointIdentifier(); // look for an ID if available - this should help debugging std::string id; if (element->GetAttribute("id", id)) { buf.append(", id "); buf.append(id); } buf.append(": " + text); WorkbenchPlugin::Log(buf); }
bool WorkbenchPlugin::HasExecutableExtension( const IConfigurationElement::Pointer& element, const QString& extensionName) { if (!element->GetAttribute(extensionName).isNull()) return true; QString elementText = element->GetValue(); if (!elementText.isEmpty()) return true; QList<IConfigurationElement::Pointer> children(element->GetChildren(extensionName)); if (children.size() == 1) { if (!(children[0]->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS).isNull())) return true; } return false; }
IntroDescriptor::IntroDescriptor(IConfigurationElement::Pointer configElement) throw (CoreException) : element(configElement) { std::string val; if (!configElement->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS, val)) { //TODO IStatus /* throw CoreException(new Status(IStatus.ERROR, configElement .getNamespace(), 0, "Invalid extension (Missing class name): " + getId(), //$NON-NLS-1$ null)); */ throw CoreException(configElement->GetContributor() + ": Invalid extension (Missing className): " + GetId()); } }
bool PerspectiveExtensionReader::ProcessExtension( IConfigurationElement::Pointer element) { IConfigurationElement::vector children = element->GetChildren(); for (unsigned int nX = 0; nX < children.size(); nX++) { IConfigurationElement::Pointer child = children[nX]; std::string type = child->GetName(); if (this->IncludeTag(type)) { bool result = false; if (type == WorkbenchRegistryConstants::TAG_ACTION_SET) { result = this->ProcessActionSet(child); } else if (type == WorkbenchRegistryConstants::TAG_VIEW) { result = this->ProcessView(child); } else if (type == WorkbenchRegistryConstants::TAG_VIEW_SHORTCUT) { result = this->ProcessViewShortcut(child); } // else if (type == IorkbenchRegistryConstants::TAG_NEW_WIZARD_SHORTCUT) // { // result = processWizardShortcut(child); // } else if (type == WorkbenchRegistryConstants::TAG_PERSP_SHORTCUT) { result = this->ProcessPerspectiveShortcut(child); } else if (type == WorkbenchRegistryConstants::TAG_SHOW_IN_PART) { result = this->ProcessShowInPart(child); } if (!result) { WorkbenchPlugin::Log("Unable to process element: " + //$NON-NLS-1$ type + " in perspective extension: " + //$NON-NLS-1$ element->GetDeclaringExtension()->GetUniqueIdentifier()); } } } return true; }
void PartSite::SetConfigurationElement( IConfigurationElement::Pointer configElement) { // Get extension ID. configElement->GetAttribute("id", extensionID); //$NON-NLS-1$ // Get plugin ID. pluginID = configElement->GetContributor(); // Get extension name. std::string name; configElement->GetAttribute("name", name); //$NON-NLS-1$ if (name != "") { extensionName = name; } }
bool Expressions::GetOptionalBooleanAttribute(IConfigurationElement::Pointer element, const std::string& attributeName) { std::string value; if (element->GetAttribute(attributeName, value)) return Poco::toLower<std::string>(value) == "true"; return false; }
std::string RegistryReader::GetDescription(IConfigurationElement::Pointer configElement) { IConfigurationElement::vector children(configElement->GetChildren(WorkbenchRegistryConstants::TAG_DESCRIPTION)); if (children.size() >= 1) { return children[0]->GetValue(); } return "";//$NON-NLS-1$ }
std::string RegistryReader::GetClassValue( IConfigurationElement::Pointer configElement, const std::string& classAttributeName) { std::string className; if (configElement->GetAttribute(classAttributeName, className)) { return className; } IConfigurationElement::vector candidateChildren(configElement->GetChildren(classAttributeName)); if (candidateChildren.size() == 0) { return ""; } candidateChildren[0]->GetAttribute(WorkbenchRegistryConstants::ATT_CLASS, className); return className; }
void Expressions::GetArguments(std::vector<Object::Pointer>& args, IConfigurationElement::Pointer element, const std::string& attributeName) { std::string value; if (element->GetAttribute(attributeName, value)) { ParseArguments(args, value); } }
TestExpression::TestExpression(const IConfigurationElement::Pointer& element) { QString property = element->GetAttribute(ATT_PROPERTY); int pos = property.lastIndexOf(PROP_SEP); if (pos == -1) { IStatus::Pointer status(new ExpressionStatus( ExpressionStatus::NO_NAMESPACE_PROVIDED, "The property attribute of the test expression must be qualified by a name space.", BERRY_STATUS_LOC)); throw CoreException(status); } fNamespace = property.left(pos); fProperty = property.mid(pos + 1); fArgs = Expressions::GetArguments(element, ATT_ARGS); fExpectedValue = Expressions::ConvertArgument(element->GetAttribute(ATT_VALUE)); fForcePluginActivation = Expressions::GetOptionalBooleanAttribute(element, ATT_FORCE_PLUGIN_ACTIVATION); }
bool PerspectiveExtensionReader::ProcessPerspectiveShortcut( IConfigurationElement::Pointer element) { std::string id; if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id)) { pageLayout->AddPerspectiveShortcut(id); } return true; }
bool PerspectiveExtensionReader::ReadElement( IConfigurationElement::Pointer element) { std::string type = element->GetName(); if (type == WorkbenchRegistryConstants::TAG_PERSPECTIVE_EXTENSION) { std::string id; element->GetAttribute(WorkbenchRegistryConstants::ATT_TARGET_ID, id); if (targetID == id || "*" == id) { //$NON-NLS-1$ // if (tracker != null) // { // tracker.registerObject(element.getDeclaringExtension(), // new DirtyPerspectiveMarker(id), IExtensionTracker.REF_STRONG); // } return this->ProcessExtension(element); } return true; } return false; }
bool PerspectiveRegistryReader::ReadElement(IConfigurationElement::Pointer element) { if (element->GetName() == WorkbenchRegistryConstants::TAG_PERSPECTIVE) { try { std::string id; element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id); PerspectiveDescriptor::Pointer desc( new PerspectiveDescriptor(id, element)); registry->AddPerspective(desc); } catch (CoreException e) { // log an error since its not safe to open a dialog here WorkbenchPlugin::Log("Unable to create layout descriptor.", e);//$NON-NLS-1$ } return true; } return false; }
void RegistryReader::ReadElementChildren( IConfigurationElement::Pointer element) { this->ReadElements(element->GetChildren()); }
void RegistryReader::LogUnknownElement( IConfigurationElement::Pointer element) { RegistryReader::LogError(element, "Unknown extension tag found: " + element->GetName());//$NON-NLS-1$ }
ResolveExpression::ResolveExpression(IConfigurationElement::Pointer configElement) { bool result = configElement->GetAttribute(ATT_VARIABLE, fVariable); Expressions::CheckAttribute(ATT_VARIABLE, result); Expressions::GetArguments(fArgs, configElement, ATT_ARGS); }
CountExpression::CountExpression(const IConfigurationElement::Pointer& configElement) { QString size = configElement->GetAttribute(ATT_VALUE); this->InitializeSize(size); }
WithExpression::WithExpression(const IConfigurationElement::Pointer& configElement) { fVariable = configElement->GetAttribute(ATT_VARIABLE); Expressions::CheckAttribute(ATT_VARIABLE, fVariable); }
bool PerspectiveExtensionReader::ProcessView( IConfigurationElement::Pointer element) { // Get id, relative, and relationship. std::string id; if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id)) { this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_ID); return false; } std::string relative; bool hasRelative = element->GetAttribute(WorkbenchRegistryConstants::ATT_RELATIVE, relative); std::string relationship; if (!element->GetAttribute(WorkbenchRegistryConstants::ATT_RELATIONSHIP, relationship)) { this->LogMissingAttribute(element, WorkbenchRegistryConstants::ATT_RELATIONSHIP); return false; } if (VAL_FAST != relationship && !hasRelative) { this->LogError(element, "Attribute '" + WorkbenchRegistryConstants::ATT_RELATIVE + "' not defined. This attribute is required when " + WorkbenchRegistryConstants::ATT_RELATIONSHIP + "=\"" + relationship + "\"."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ return false; } // Get relationship details. bool stack = false; bool fast = false; int intRelation = 0; if (relationship == VAL_LEFT) { intRelation = IPageLayout::LEFT; } else if (relationship == VAL_RIGHT) { intRelation = IPageLayout::RIGHT; } else if (relationship == VAL_TOP) { intRelation = IPageLayout::TOP; } else if (relationship == VAL_BOTTOM) { intRelation = IPageLayout::BOTTOM; } else if (relationship == VAL_STACK) { stack = true; } else if (relationship == VAL_FAST) { fast = true; } else { return false; } float ratio = 0.5f; std::string ratioString; if (element->GetAttribute(WorkbenchRegistryConstants::ATT_RATIO, ratioString)) { try { ratio = (float)Poco::NumberParser::parseFloat(ratioString); } catch (Poco::SyntaxException& /*e*/) { return false; } // If the ratio is outside the allowable range, mark it as invalid. if (ratio < IPageLayout::RATIO_MIN || ratio > IPageLayout::RATIO_MAX) { ratio = IPageLayout::INVALID_RATIO; } } else { // The ratio has not been specified. ratio = IPageLayout::NULL_RATIO; } std::string strVisible; element->GetAttribute(WorkbenchRegistryConstants::ATT_VISIBLE, strVisible); bool visible = (VAL_TRUE == strVisible); std::string closeable; bool hasCloseable = element->GetAttribute( WorkbenchRegistryConstants::ATT_CLOSEABLE, closeable); std::string moveable; bool hasMoveable = element->GetAttribute( WorkbenchRegistryConstants::ATT_MOVEABLE, moveable); std::string standalone; element->GetAttribute( WorkbenchRegistryConstants::ATT_STANDALONE, standalone); std::string showTitle; element->GetAttribute( WorkbenchRegistryConstants::ATT_SHOW_TITLE, showTitle); // Default to 'false' std::string minVal; bool minimized = false; if (element->GetAttribute(WorkbenchRegistryConstants::ATT_MINIMIZED, minVal)) minimized = VAL_TRUE == minVal; if (visible) { // If adding a view (not just a placeholder), remove any existing placeholder. // See bug 85948 [Perspectives] Adding register & expressions view by default to debug perspective fails pageLayout->RemovePlaceholder(id); } // If stack .. if (stack) { if (visible) { pageLayout->StackView(id, relative); } else { pageLayout->StackPlaceholder(id, relative); } } // // If the view is a fast view... // else if (fast) // { // if (ratio == IPageLayout::NULL_RATIO) // { // // The ratio has not been specified. // pageLayout->AddFastView(id); // } // else // { // pageLayout->AddFastView(id, ratio); // } // } else { // The view is a regular view. // If the ratio is not specified or is invalid, use the default ratio. if (ratio == IPageLayout::NULL_RATIO || ratio == IPageLayout::INVALID_RATIO) { ratio = IPageLayout::DEFAULT_VIEW_RATIO; } if (visible) { if (VAL_TRUE == standalone) { pageLayout->AddStandaloneView(id, VAL_TRUE == showTitle, intRelation, ratio, relative); } else { pageLayout->AddView(id, intRelation, ratio, relative, minimized); } } else { // Fix for 99155, CGross ([email protected]) // Adding standalone placeholder for standalone views if (VAL_TRUE == standalone) { pageLayout->AddStandaloneViewPlaceholder(id, intRelation, ratio, relative, VAL_TRUE == showTitle); } else { pageLayout->AddPlaceholder(id, intRelation, ratio, relative); } } } IViewLayout::Pointer viewLayout = pageLayout->GetViewLayout(id); // may be null if it's been filtered by activity if (viewLayout != 0) { if (hasCloseable) { viewLayout->SetCloseable(VAL_TRUE == closeable); } if (hasMoveable) { viewLayout->SetMoveable(VAL_TRUE == moveable); } } return true; }
AdaptExpression::AdaptExpression(IConfigurationElement::Pointer configElement) { fTypeName = configElement->GetAttribute(ATT_TYPE); Expressions::CheckAttribute(ATT_TYPE, fTypeName); }