I want to make better support for editor options writers, which take MIME type into account. For such options, there are typically 'all files' settings,
and per-language (filetype) overrides. Current pattern in NetBeans allows to edit both 'all files' defaults AND certain overrides, which makes the implementations little tricky and complicated.
The Preferences object based on MimePath (MimeLookup) is a view composed of Preferences found along the MimePath inheritance chain. The Preferences defined for the Mime type take precedence, but fallback on an inherited MIME type is also implemented as well as a fallback to the ultimate defaults defined for "" mime type.
It is however impossible to tell whether a Preference is defined for a Mimetype itself. The information is hacked out by working directly with the EditorSettingsStorage layer - see for example FormattingPanelController (options.editor module).
I propose that a mixing interface LocalPreferences is defined, and implemented on MIME PreferencesImpl as follows:
public interface OverridePreferences {
public boolean isOverriden(String key);
}
that will return true if and only if the PreferencesImpl itself, not its MIME parent delegate, defines (or marks as removed - non-existent) the key. The isOverriden() could be also
coded as a static helper method, but if provided in a mixin interface, the OverridePreferences interface may be also implemented on different Preferences implementation (e.g. memory-based),
which support similar override fallback (e.g. they delegate to Mime preferences).
------
The second change is inspired by an existing code in editor indentation settings, ProxyPreferences, which tracks changes in memory until flush() is called. In a newly developed code, I want to use the same behaviour, and I do not want to duplicate code. Therefore I would like to publish a factory for ProxyPreferences + add small enhancement, which allows to implement editing of Preferences with defaults inherited along MIME path.
Please see MemoryPreferences in the attached diff for exact details. The idea is that the code will create an instance of MemoryPreferences, which is a some sort of management API that serves and controls the actual Preferences object. The code will then use the Preferences (which is in fact ProxyPreferences delegating to the stored and optionally inherited settings). The MemoryPreferences controller interface is designed to handle special things, like dirtiness check or destruction.