This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 226111 - Public support for Preferences editing + flush, support to detect override in Mime prefrences
Summary: Public support for Preferences editing + flush, support to detect override in...
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Settings (show other bugs)
Version: 7.4
Hardware: PC Linux
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: API_REVIEW_FAST
Depends on:
Blocks: 226413
  Show dependency tree
 
Reported: 2013-02-14 11:54 UTC by Svata Dedic
Modified: 2013-03-04 01:46 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Proposed changes (88.76 KB, patch)
2013-02-14 12:01 UTC, Svata Dedic
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Svata Dedic 2013-02-14 11:54:35 UTC
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.
Comment 1 Svata Dedic 2013-02-14 12:01:28 UTC
Created attachment 131383 [details]
Proposed changes
Comment 2 Svata Dedic 2013-02-27 09:55:37 UTC
No objections or comments, going to push
Comment 3 Svata Dedic 2013-02-27 10:46:57 UTC
Changeset: fab1458b9bec
Author:    Svata Dedic <sdedic@netbeans.org>
Date:      2013-02-27 11:46
Message:   #226111: Implemented inheritable and transient Preferences
Comment 4 Quality Engineering 2013-03-04 01:46:18 UTC
Integrated into 'main-golden', will be available in build *201303032300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/fab1458b9bec
User: Svata Dedic <sdedic@netbeans.org>
Log: Issue #226111 - Public support for Preferences editing + flush, support to detect override in Mime prefrences: fixed
#226111: Implemented inheritable and transient Preferences