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.
Summary: | Form Editor cannot load property editors registered globally | ||
---|---|---|---|
Product: | guibuilder | Reporter: | vieiro <vieiro> |
Component: | Code | Assignee: | issues@guibuilder <issues> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | ||
Priority: | P3 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
A simple NBM file (around 4Kb) that installs a custom property editor for colors
Source code for previous NBM file (around 7Kb) Source code for tests, with a working getCustomEditor |
Description
vieiro
2006-07-12 19:14:28 UTC
Created attachment 31789 [details]
A simple NBM file (around 4Kb) that installs a custom property editor for colors
Created attachment 31790 [details]
Source code for previous NBM file (around 7Kb)
I've attached a simple NBM that registers globally a PropertyEditor for Colors. You can reproduce the issue by opening a form, selecting the background color (use the text field for setting the color: I've not extended ExPropertyEditor, so the ColorChooser does not set the color). Then close the form and open it again: the PropertyEditor cannot be loaded. Updated version to current, as this happens in NB6.0M1 too. By the way, NB 6.0 M1 does not correctly report the exception, and the form editor is not properly initialized. Yes, we should fix this and load the globally registered property editors. However you can make it work already now (in 5.0/5.5). You need to include the following snippet in the layer.xml file (enter your concrete package name where your property editor resides): <folder name="org-netbeans-modules-form"> <folder name="classloader"> <folder name="system"> <file name="MyModuleClasses.txt"> com.me.mypackage.** </file> </folder> </folder> </folder> Note you should not register the property editor for common types like Color for which NetBeans have its own editors registered. You override the original property editor and break it for the whole IDE. Fixed in trunk. /cvs/form/src/org/netbeans/modules/form/GandalfPersistenceManager.java new revision: 1.168; previous revision: 1.167 Note if you wanted an _additional_ editor for Color or other common type, you could make it available via the editor search path (in PropertyEditorManager). Regarding... <folder name="org-netbeans-modules-form"> <folder name="classloader"> <folder name="system"> <file name="MyModuleClasses.txt"> com.me.mypackage.** </file> </folder> </folder> </folder> Seems to work correctly, but if I extend ExPropertyEditor then public void attachEnv(PropertyEnv propertyEnv) is never invoked :-(, so I think the change to GandalfPersistenceManager is the way to go. I'll try that as soon as possible (1/2 weeks) Regarding overriding NetBeans' property editors... I'm registering through FormPropertyEditorManager (I'm cheating, I know) so the user can choose which editor to use (from the combobox). That way I avoid overriding NetBeans' built-in editors. Thanks for the change, Antonio If you use FormPropertyEditorManager then you definitely need to register your name space in the xml. My fix is related only to use of java.beans.PropertyEditorManager (which is independent on form module). I see no reason why your ExPropertyEditor should not work. Please double-check, or send us a test case. We also use ExPropertyEditor impls and they work fine. If your class is correctly loaded and the property editor displayed, then attachEnv should be called. Just note that attachEnv might be called _after_ getCustumEditor, which might be confusing. Hi, My fault: attachEnv is being called, but if I invoke FormPropertyEditorManager.registerEditor then the property is not modified when using the custom editor. The solution seems to be registering the editor through the XML snippet in layer.xml. I don't seem to need to invoke neither FormPropertyEditorManager.registerEditor *nor* PropertyEditorManager.registerEditor. The XML snippet itself registers the editor properly. So, to summarize: - For common types just register the PropertyEditor using the XML snippet. Do not use either FormPropertyEditorManager *nor* PropertyEditorManager to register the Property Editor. The Form Editor will include the new PropertyEditor and will *not* override existing editors. The user may still use any other older (previously registered) editor. So I assume this is the preferred way to enhance the Form Editor with new PropertyEditors for common types. I may be able to attach some simple module with a custom color editor. Shall I do so? Just for the records? Thanks, Antonio Yes please - if you can. Thanks I was too fast stating that things were solved for me. The fact is that I was opening a pre-existing project, with a form file that was referencing the property editor. This is issue seems to be somewhat difficult to test. I suggest following the next steps: a) Clean & build the module. Cleaning is important! b) Run the module. c) Create a *new* Java project (do not open a previous one as I was doing, since the .form files may alter the test). d) Create a new Form, and change the background color by pressing the [...] button in the property. e) Select the MyCustomColorEditor from the drop down box. e.1.) If the module Installer registers the editor using PropertyEditorManager.registerEditor then a single MyCustomColorEditor is shown, that works, and all the rest of editors are gone. e.2.) If the module Installer register the editor using FormPropertyEditorManager.registerEditor then MyCustomColorEditor is shown *twice*, and all the rest of editors are still there. None of the MyCustomColorEditors (two of them) seems to work. The editor appears twice depending on the XML snippet in layer.xml f) Close the form. (The form is saved to a .form file) g) Open the form again. The form is read from the .form file. g.1) If the editor was registered from step e.1) then everything works. g.2.) If the editor was registered from step e.2) then the form may be loaded only if the XML snippet is in place in layer.xml I'll be attaching the source code for the test in a minute. Please contact me if I've not explained myself correctly. Cheers, Antonio Created attachment 32847 [details]
Source code for tests, with a working getCustomEditor
|