public class LanguageSettingsSerializableProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsBroadcastingProvider
ILanguageSettingsEditableProvider
interface for that. There is a generic
implementation of this interface available to be used, see LanguageSettingsGenericProvider
.
For more on the suggested way of extending this class see the description of
ILanguageSettingsProvider
.Modifier and Type | Field and Description |
---|---|
protected static String |
ATTR_CLASS |
protected static String |
ATTR_ID |
protected static String |
ATTR_NAME |
protected static String |
ELEM_LANGUAGE_SCOPE |
protected static String |
ELEM_PROVIDER |
languageScope, properties
Constructor and Description |
---|
LanguageSettingsSerializableProvider()
Default constructor.
|
LanguageSettingsSerializableProvider(Element elementProvider)
Constructor which allows to instantiate provider defined via XML markup.
|
LanguageSettingsSerializableProvider(String id,
String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all the entries for all configurations, all resources and all languages.
|
protected LanguageSettingsSerializableProvider |
clone() |
protected LanguageSettingsSerializableProvider |
cloneShallow()
Shallow clone of the provider.
|
void |
configureProvider(String id,
String name,
List<String> languages,
List<ICLanguageSettingEntry> entries,
Map<String,String> properties)
A method to configure the provider.
|
LanguageSettingsStorage |
copyStorage()
Return a copy of internal storage.
|
boolean |
equals(Object obj) |
List<ICLanguageSettingEntry> |
getSettingEntries(ICConfigurationDescription cfgDescription,
org.eclipse.core.resources.IResource rc,
String languageId)
Returns the list of setting entries for the given configuration description,
resource and language.
|
int |
hashCode() |
boolean |
isEmpty() |
void |
load(Element providerNode)
Load provider from XML provider element.
|
void |
loadAttributes(Element providerNode)
Load attributes from XML provider element.
|
void |
loadEntries(Element providerNode)
Load provider entries from XML provider element.
|
Element |
serialize(Element parentElement)
Serialize the provider under parent XML element.
|
Element |
serializeAttributes(Element parentElement)
Serialize the provider attributes under parent XML element.
|
void |
serializeEntries(Element elementProvider)
Serialize the provider entries under parent XML element.
|
org.eclipse.core.runtime.IStatus |
serializeLanguageSettings(ICConfigurationDescription cfgDescription)
Convenience method to persist language settings entries for the project or
workspace as often-used operation.
|
void |
serializeLanguageSettingsInBackground(ICConfigurationDescription cfgDescription)
Convenience method to persist language settings entries in background for the project or
workspace as often-used operation.
|
void |
setLanguageScope(List<String> languages)
Sets the language scope of the provider.
|
void |
setProperty(String key,
String value)
Set a custom property of the provider.
|
void |
setPropertyBool(String key,
boolean value)
Set a custom boolean property of the provider.
|
void |
setSettingEntries(ICConfigurationDescription cfgDescription,
org.eclipse.core.resources.IResource rc,
String languageId,
List<? extends ICLanguageSettingEntry> entries)
Sets language settings entries for the provider.
|
getLanguageScope, getProperty, getPropertyBool
getId, getName, setId, setName, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getName
protected static final String ATTR_ID
protected static final String ATTR_NAME
protected static final String ATTR_CLASS
protected static final String ELEM_PROVIDER
protected static final String ELEM_LANGUAGE_SCOPE
public LanguageSettingsSerializableProvider()
public LanguageSettingsSerializableProvider(String id, String name)
id
- - id of the provider.name
- - name of the provider. Note that this name shows up in UI.public LanguageSettingsSerializableProvider(Element elementProvider)
elementProvider
- public void configureProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries, Map<String,String> properties)
LanguageSettingsBaseProvider
configureProvider
in class LanguageSettingsBaseProvider
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.public boolean isEmpty()
true
if the provider does not keep any settings yet or false
if there are some.public void setLanguageScope(List<String> languages)
languages
- - the list of languages this provider provides for.
If null
, the provider provides for any language.LanguageSettingsBaseProvider.getLanguageScope()
public void clear()
public void setSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId, List<? extends ICLanguageSettingEntry> entries)
serializeLanguageSettings(ICConfigurationDescription)
.
See for example AbstractBuildCommandParser
and AbstractBuiltinSpecsDetector
in build plugins.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.public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, org.eclipse.core.resources.IResource rc, String languageId)
ILanguageSettingsProvider.getSettingEntries(ICConfigurationDescription, IResource, String)
will
return cached entries when asked. You can also implement ICListenerAgent
interface to get registered and listen to arbitrary events.
setSettingEntries(ICConfigurationDescription, IResource, String, List)
.
getSettingEntries
in interface ILanguageSettingsBroadcastingProvider
getSettingEntries
in interface ILanguageSettingsProvider
getSettingEntries
in class LanguageSettingsBaseProvider
cfgDescription
- - configuration description.rc
- - resource such as file or folder.
If null
, the default entries for all resources are returned.languageId
- - language id. If null
, then entries defined for
the language scope are returned. See LanguageSettingsBaseProvider.getLanguageScope()
null
if no settings defined.
the list is internally pooled and guaranteed to be the same object for equal
lists.public final Element serialize(Element parentElement)
serializeAttributes(Element)
or
serializeEntries(Element)
instead.parentElement
- - element where to serialize.public Element serializeAttributes(Element parentElement)
parentElement
- - element where to serialize.public void serializeEntries(Element elementProvider)
elementProvider
- - element where to serialize the entries.public org.eclipse.core.runtime.IStatus serializeLanguageSettings(ICConfigurationDescription cfgDescription)
cfgDescription
- - configuration description.
If not null
, all providers of the project are serialized.
If null
, global workspace providers are serialized.public void serializeLanguageSettingsInBackground(ICConfigurationDescription cfgDescription)
cfgDescription
- - configuration description.
If not null
, all providers of the project are serialized.
If null
, global workspace providers are serialized.public final void load(Element providerNode)
loadAttributes(Element)
or
loadEntries(Element)
instead.providerNode
- - XML element "provider" to load provider from.public void loadAttributes(Element providerNode)
providerNode
- - XML element "provider" to load attributes from.public void loadEntries(Element providerNode)
providerNode
- - parent XML element "provider" where entries are defined.public void setProperty(String key, String value)
null
value. When providers are checked for equality
(during internal operations in core) the missing properties are evaluated as
empty ones.key
- - name of the property.value
- - value of the property.
If value is null
the property is removed from the list.LanguageSettingsBaseProvider.getProperty(String)
public void setPropertyBool(String key, boolean value)
false
.key
- - name of the property.value
- - boolean
value of the property.LanguageSettingsBaseProvider.getProperty(String)
protected LanguageSettingsSerializableProvider cloneShallow() throws CloneNotSupportedException
CloneNotSupportedException
- in case clone()
throws the exception.protected LanguageSettingsSerializableProvider clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public LanguageSettingsStorage copyStorage()
ILanguageSettingsBroadcastingProvider
copyStorage
in interface ILanguageSettingsBroadcastingProvider
public int hashCode()
hashCode
in class LanguageSettingsBaseProvider
public boolean equals(Object obj)
equals
in class LanguageSettingsBaseProvider
true
if the objects are equal, false
otherwise.Object.equals(java.lang.Object)
Copyright (c) IBM Corp. and others 2004, 2020. All Rights Reserved.