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;
}
Exemple #5
0
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);
}
Exemple #6
0
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;
  }
}
Exemple #7
0
 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);
   }
 }
Exemple #8
0
  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;
  }
bool PerspectiveExtensionReader::ProcessPerspectiveShortcut(
    IConfigurationElement::Pointer element)
{
  std::string id;
  if (element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id))
  {
    pageLayout->AddPerspectiveShortcut(id);
  }
  return true;
}
Exemple #10
0
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);
}
Exemple #12
0
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;
}
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);
}
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());
  }
}
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;
}
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;
}
Exemple #18
0
WithExpression::WithExpression(const IConfigurationElement::Pointer& configElement)
{
  fVariable = configElement->GetAttribute(ATT_VARIABLE);
  Expressions::CheckAttribute(ATT_VARIABLE, fVariable);
}
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);
 }
AdaptExpression::AdaptExpression(IConfigurationElement::Pointer configElement)
{
  fTypeName = configElement->GetAttribute(ATT_TYPE);
  Expressions::CheckAttribute(ATT_TYPE, fTypeName);
}
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;
}