예제 #1
0
  /**
   * Adds all of the component's recognized features and properties to the list of default
   * recognized features and properties, and sets default values on the configuration for features
   * and properties which were previously absent from the configuration.
   *
   * @param component The component whose recognized features and properties will be added to the
   *     configuration
   */
  protected void addRecognizedParamsAndSetDefaults(XMLComponent component) {

    // register component's recognized features
    String[] recognizedFeatures = component.getRecognizedFeatures();
    addRecognizedFeatures(recognizedFeatures);

    // register component's recognized properties
    String[] recognizedProperties = component.getRecognizedProperties();
    addRecognizedProperties(recognizedProperties);

    // set default values
    if (recognizedFeatures != null) {
      for (int i = 0; i < recognizedFeatures.length; ++i) {
        String featureId = recognizedFeatures[i];
        Boolean state = component.getFeatureDefault(featureId);
        if (state != null) {
          // Do not overwrite values already set on the configuration.
          if (!fFeatures.containsKey(featureId)) {
            fFeatures.put(featureId, state);
            // For newly added components who recognize this feature
            // but did not offer a default value, we need to make
            // sure these components will get an opportunity to read
            // the value before parsing begins.
            fConfigUpdated = true;
          }
        }
      }
    }
    if (recognizedProperties != null) {
      for (int i = 0; i < recognizedProperties.length; ++i) {
        String propertyId = recognizedProperties[i];
        Object value = component.getPropertyDefault(propertyId);
        if (value != null) {
          // Do not overwrite values already set on the configuration.
          if (!fProperties.containsKey(propertyId)) {
            fProperties.put(propertyId, value);
            // For newly added components who recognize this property
            // but did not offer a default value, we need to make
            // sure these components will get an opportunity to read
            // the value before parsing begins.
            fConfigUpdated = true;
          }
        }
      }
    }
  }