예제 #1
0
  /**
   * Store the value of an option.
   *
   * @param id a string uniquely identifying the option
   * @param value a string to be assigned as option value; if null, the empty string is assigned
   */
  public void setOption(String id, String value) {

    assert (id != null);
    assert (fStorage != null);

    ICStorageElement option = null;
    for (ICStorageElement child : fStorage.getChildrenByName("option")) {

      if (id.equals(child.getAttribute("id"))) {
        if (option == null) {
          // Remember first occurrence
          option = child;
        } else {
          // remove possible duplicates
          fStorage.removeChild(child);
        }
      }
    }

    if (option == null) {
      option = fStorage.createChild("option");
      option.setAttribute("id", id);
    }
    if (value == null) {
      value = "";
    } else {
      value = value.trim();
    }
    option.setAttribute("value", value);
  }
예제 #2
0
  public void storeMappings(IProject project, ProjectLanguageConfiguration config)
      throws CoreException {
    ICProjectDescription descriptor = getProjectDescription(project, true);
    ICStorageElement rootElement = descriptor.getStorage(LANGUAGE_MAPPING_ID, true);
    // clear all children and settings
    rootElement.clear();

    ICStorageElement projectMappings = rootElement.createChild(PROJECT_MAPPINGS);

    addProjectContentTypeMappings(config.getContentTypeMappings(), projectMappings);
    addFileMappings(config.getFileMappings(), projectMappings);
    CCorePlugin.getDefault().setProjectDescription(project, descriptor);
  }
예제 #3
0
  private void addFileMappings(
      Map<String, Map<String, String>> mappings, ICStorageElement rootElement) {
    for (Map.Entry<String, Map<String, String>> entry : mappings.entrySet()) {
      ICStorageElement mapping = rootElement.createChild(FILE_MAPPING);
      String path = entry.getKey();
      for (Entry<String, String> configurationEntry : entry.getValue().entrySet()) {
        String configuration = configurationEntry.getKey();
        String language = configurationEntry.getValue();

        mapping.setAttribute(ATTRIBUTE_PATH, path);
        mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration);
        mapping.setAttribute(ATTRIBUTE_LANGUAGE, language);
      }
    }
  }
예제 #4
0
  private void addProjectContentTypeMappings(
      Map<String, Map<String, String>> contentTypeMappings, ICStorageElement rootElement) {
    Iterator<Entry<String, Map<String, String>>> entries =
        contentTypeMappings.entrySet().iterator();
    while (entries.hasNext()) {
      Entry<String, Map<String, String>> entry = entries.next();

      String configuration = entry.getKey();
      Iterator<Entry<String, String>> contentTypeEntries = entry.getValue().entrySet().iterator();
      while (contentTypeEntries.hasNext()) {
        Entry<String, String> configurationEntry = contentTypeEntries.next();
        String contentType = configurationEntry.getKey();
        String language = configurationEntry.getValue();

        ICStorageElement mapping = rootElement.createChild(CONTENT_TYPE_MAPPING);
        mapping.setAttribute(ATTRIBUTE_CONTENT_TYPE, contentType);
        mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration);
        mapping.setAttribute(ATTRIBUTE_LANGUAGE, language);
      }
    }
  }
예제 #5
0
  /** Persist the resource configuration to the project file. */
  @Override
  public void serialize(ICStorageElement element) {
    super.serialize(element);
    if (toolsToInvoke != null) {
      element.setAttribute(IResourceConfiguration.TOOLS_TO_INVOKE, toolsToInvoke);
    }

    if (rcbsApplicability != null) {
      String str;
      switch (getRcbsApplicability()) {
        case KIND_APPLY_RCBS_TOOL_BEFORE:
          str = APPLY_RCBS_TOOL_BEFORE;
          break;
        case KIND_APPLY_RCBS_TOOL_AFTER:
          str = APPLY_RCBS_TOOL_AFTER;
          break;
        case KIND_APPLY_RCBS_TOOL_AS_OVERRIDE:
          str = APPLY_RCBS_TOOL_AS_OVERRIDE;
          break;
        case KIND_DISABLE_RCBS_TOOL:
          str = DISABLE_RCBS_TOOL;
          break;
        default:
          str = DISABLE_RCBS_TOOL;
          break;
      }
      element.setAttribute(IResourceConfiguration.RCBS_APPLICABILITY, str);
    }

    // Serialize my children
    List<ITool> toolElements = getToolList();
    for (ITool tool : toolElements) {
      ICStorageElement toolElement = element.createChild(ITool.TOOL_ELEMENT_NAME);
      ((Tool) tool).serialize(toolElement);
    }

    // I am clean now
    setDirty(false);
  }
예제 #6
0
  /**
   * Store the description of a memory section.
   *
   * @param section a string with the section name, using the CMSIS convention (like IRAM1, IROM1)
   * @param start a string with the hex value of the start address
   * @param size a string with the hex value of the size, in bytes
   * @param startup a string with 1 if the section will be used for startup (to host the vectors
   *     table)
   */
  public void setMemory(String section, String start, String size, String startup) {

    ICStorageElement memory = null;
    for (ICStorageElement child : fStorage.getChildrenByName("memory")) {

      if (section.equals(child.getAttribute("section"))) {
        if (memory == null) {
          // Remember first occurrence
          memory = child;
        } else {
          // remove possible duplicates
          fStorage.removeChild(child);
        }
      }
    }

    if (memory == null) {
      memory = fStorage.createChild("memory");
      memory.setAttribute("section", section);
    }
    memory.setAttribute("start", start);
    memory.setAttribute("size", size);
    memory.setAttribute("startup", startup);
  }