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 144579 - Add support for child nodes to MimeLookup Preferences
Summary: Add support for child nodes to MimeLookup Preferences
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Settings (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Milutin Kristofic
URL:
Keywords: API
Depends on:
Blocks: 179566 186628
  Show dependency tree
 
Reported: 2008-08-20 12:55 UTC by Vitezslav Stejskal
Modified: 2013-07-18 13:49 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
keep proposal in the bug (12.66 KB, patch)
2013-02-22 06:37 UTC, Alexander Simon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vitezslav Stejskal 2008-08-20 12:55:31 UTC
Currently java.util.prefs.Preferences implementation available in MimeLookup does not support child node. For example
calling MimeLookup.getLookup("text/x-java").lookup(Preferences.class).node("xyz") will throw an exception. This is
limiting for features that have a lot of setting and that want to group them somehow. An example of such a feature are
formatting settings profiles.

We should allow creating child nodes in MimeLookup Preferences. Also, we should consider joining up the MimeLookup
preferences to a single preference tree and make it possible to do things like:

Preferences p = MimeLookup.getL("").lookup(Preferences.class);
Preferences javaPrefs = p.node("text/x-java");
Comment 1 Vladimir Voskresensky 2010-01-18 08:18:11 UTC
This is ENH needed by CDN team as well. C/C++ Formatting supports styling but we can not use MimeLookup preferences do to lack of this functionality.

Probably this issue is also the blocker, why we can not add "Formatting" into our project properties
Comment 2 David Strupl 2012-02-24 09:40:25 UTC
Do we plan to do this? Is it still needed?
Comment 3 Vladimir Voskresensky 2012-02-24 10:42:25 UTC
David, it's needed. We can not implement per-project formatting.
Comment 4 David Strupl 2012-07-02 14:54:21 UTC
The file where this should be implemented is here:

editor.settings.storage/src/org/netbeans/modules/editor/settings/storage/preferences/PreferencesImpl.java
Comment 5 Alexander Simon 2013-02-22 06:37:30 UTC
Created attachment 131712 [details]
keep proposal in the bug

Hi Vladimir,

I did a quick experiment to see what difficulties we will likely encounter while trying to fix #144579. I am attaching my current version (see below for the list of problems). I wonder if there is a way to quickly test it in your (C/C++ Formatting) usecase, to check if this is what you need. All I have is a unit test and a quick manual test inside the IDE.

The current patch piggy backs on the profile support (as there are no profiles for Preferences) - I am not sure if abusing profiles for nested Preferences nodes will really work, but works so far. The two biggest problems I see right now are:
1. cannot find out what are the sub-nodes of a Preferences node. To overcome this, each Preferences node keeps the list of its children in a property, but that is very ugly (and not 100% compatible).
2. related to that - when a preferences node is deleted, all its properties are deleted, but the .xml file with the settings remains on the disk.

Thanks,
   Jan
Comment 6 Alexander Simon 2013-03-01 13:01:56 UTC
(In reply to comment #5)
> I did a quick experiment to see what difficulties we will likely encounter
> while trying to fix #144579. I am attaching my current version (see below for
> the list of problems). I wonder if there is a way to quickly test it in your
> (C/C++ Formatting) usecase, to check if this is what you need. All I have is a
> unit test and a quick manual test inside the IDE.
I got an assertion:
SEVERE [global]
java.lang.AssertionError: The parameter profile must not be null
	at org.netbeans.modules.editor.settings.storage.StorageImpl.load(StorageImpl.java:107)
	at org.netbeans.modules.editor.settings.storage.api.EditorSettingsStorage.load(EditorSettingsStorage.java:95)
	at org.netbeans.modules.options.indentation.FormattingPanelController.applyChanges(FormattingPanelController.java:154)
	at org.netbeans.modules.options.TabbedController.applyChanges(TabbedController.java:130)
	at org.netbeans.modules.options.CategoryModel$Category.applyChanges(CategoryModel.java:396)
	at org.netbeans.modules.options.CategoryModel$Category.access$1000(CategoryModel.java:321)
	at org.netbeans.modules.options.CategoryModel.save(CategoryModel.java:219)
	at org.netbeans.modules.options.OptionsPanel.save(OptionsPanel.java:292)
	at org.netbeans.modules.options.OptionsDisplayerImpl$OptionsPanelListener.actionPerformed(OptionsDisplayerImpl.java:441)
	at org.netbeans.core.windows.services.NbPresenter$ButtonListener.actionPerformed(NbPresenter.java:1384)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2719)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:688)
	at java.awt.EventQueue$3.run(EventQueue.java:686)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:702)
	at java.awt.EventQueue$4.run(EventQueue.java:700)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Comment 7 Alexander Simon 2013-03-01 13:02:43 UTC
Please, fix assertion.