Class LanguageSettingsSerializableProvider

    • Constructor Detail

      • LanguageSettingsSerializableProvider

        public LanguageSettingsSerializableProvider()
        Default constructor. This constructor has to be always followed with setting id and name of the provider. This constructor is necessary to instantiate the class via the extension point in plugin.xml.
      • LanguageSettingsSerializableProvider

        public LanguageSettingsSerializableProvider​(String id,
                                                    String name)
        Constructor.
        Parameters:
        id - - id of the provider.
        name - - name of the provider. Note that this name shows up in UI.
      • LanguageSettingsSerializableProvider

        public LanguageSettingsSerializableProvider​(Element elementProvider)
        Constructor which allows to instantiate provider defined via XML markup.
        Parameters:
        elementProvider -
    • Method Detail

      • configureProvider

        public void configureProvider​(String id,
                                      String name,
                                      List<String> languages,
                                      List<ICLanguageSettingEntry> entries,
                                      Map<String,​String> properties)
        Description copied from class: LanguageSettingsBaseProvider
        A method to configure the provider. The initialization of provider from the extension point is done in 2 steps. First, the class is created as an executable extension using the default provider. Then this method is used to configure the provider.

        It is not allowed to reconfigure the provider.
        Overrides:
        configureProvider in class LanguageSettingsBaseProvider
        Parameters:
        id - - id of the provider.
        name - - name of the provider to be presented to a user.
        languages - - list of languages the entries provided for. languages can be null, in this case the entries are provided for any language.
        entries - - the list of language settings entries this provider provides. If null is passed, the provider creates an empty list.
        properties - - custom properties as the means to customize providers.
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the provider does not keep any settings yet or false if there are some.
      • setLanguageScope

        public void setLanguageScope​(List<String> languages)
        Sets the language scope of the provider.
        Parameters:
        languages - - the list of languages this provider provides for. If null, the provider provides for any language.
        See Also:
        LanguageSettingsBaseProvider.getLanguageScope()
      • clear

        public void clear()
        Clears all the entries for all configurations, all resources and all languages.
      • setSettingEntries

        public void setSettingEntries​(ICConfigurationDescription cfgDescription,
                                      org.eclipse.core.resources.IResource rc,
                                      String languageId,
                                      List<? extends ICLanguageSettingEntry> entries)
        Sets language settings entries for the provider. Note that the entries are not persisted at that point. Use this method to set the entries for all resources one by one and after all done persist in one shot using serializeLanguageSettings(ICConfigurationDescription). See for example AbstractBuildCommandParser and AbstractBuiltinSpecsDetector in build plugins.
        Parameters:
        cfgDescription - - configuration description.
        rc - - resource such as file or folder. If null the entries are considered to be being defined as default entries for resources.
        languageId - - language id. If null, then entries are considered to be defined for the language scope. See LanguageSettingsBaseProvider.getLanguageScope()
        entries - - language settings entries to set.
      • serialize

        public final Element serialize​(Element parentElement)
        Serialize the provider under parent XML element. This is convenience method not intended to be overridden on purpose. Override serializeAttributes(Element) or serializeEntries(Element) instead.
        Parameters:
        parentElement - - element where to serialize.
        Returns:
        - newly created "provider" element. That element will already be attached to the parent element.
      • serializeAttributes

        public Element serializeAttributes​(Element parentElement)
        Serialize the provider attributes under parent XML element. That is equivalent to serializing everything (including language scope) except entries.
        Parameters:
        parentElement - - element where to serialize.
        Returns:
        - newly created "provider" element. That element will already be attached to the parent element.
      • serializeEntries

        public void serializeEntries​(Element elementProvider)
        Serialize the provider entries under parent XML element.
        Parameters:
        elementProvider - - element where to serialize the entries.
      • serializeLanguageSettings

        public org.eclipse.core.runtime.IStatus serializeLanguageSettings​(ICConfigurationDescription cfgDescription)
        Convenience method to persist language settings entries for the project or workspace as often-used operation. Note that configuration description is passed as an argument but the current implementation saves all configurations.
        Parameters:
        cfgDescription - - configuration description. If not null, all providers of the project are serialized. If null, global workspace providers are serialized.
        Returns:
        - status of operation.
      • serializeLanguageSettingsInBackground

        public void serializeLanguageSettingsInBackground​(ICConfigurationDescription cfgDescription)
        Convenience method to persist language settings entries in background for the project or workspace as often-used operation. Note that configuration description is passed as an argument but the current implementation saves all configurations.
        Parameters:
        cfgDescription - - configuration description. If not null, all providers of the project are serialized. If null, global workspace providers are serialized.
      • load

        public final void load​(Element providerNode)
        Load provider from XML provider element. This is convenience method not intended to be overridden on purpose. Override loadAttributes(Element) or loadEntries(Element) instead.
        Parameters:
        providerNode - - XML element "provider" to load provider from.
      • loadAttributes

        public void loadAttributes​(Element providerNode)
        Load attributes from XML provider element.
        Parameters:
        providerNode - - XML element "provider" to load attributes from.
      • loadEntries

        public void loadEntries​(Element providerNode)
        Load provider entries from XML provider element.
        Parameters:
        providerNode - - parent XML element "provider" where entries are defined.
      • setProperty

        public void setProperty​(String key,
                                String value)
        Set a custom property of the provider.

        A note of caution - do not use default values for a provider which are different from empty or null value. When providers are checked for equality (during internal operations in core) the missing properties are evaluated as empty ones.
        Parameters:
        key - - name of the property.
        value - - value of the property. If value is null the property is removed from the list.
        See Also:
        LanguageSettingsBaseProvider.getProperty(String)
      • setPropertyBool

        public void setPropertyBool​(String key,
                                    boolean value)
        Set a custom boolean property of the provider.
        Please, note that default value is always false.
        Parameters:
        key - - name of the property.
        value - - boolean value of the property.
        See Also:
        LanguageSettingsBaseProvider.getProperty(String)