Example for PropertyEditor

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Example for PropertyEditor

Postby mkornatzki » Wed Sep 02, 2009 2:55 am

Hello,

can you please give me an example of how to create an own propertyeditor like the insets-property-editor?

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Example for PropertyEditor

Postby Eric Clayberg » Wed Sep 02, 2009 5:40 am

mkornatzki wrote:can you please give me an example of how to create an own propertyeditor like the insets-property-editor?

Swing Designer is fully JavaBean compliant, so you can create custom property editors and widget customizers using standard JavaBean techniques.

Lots of examples for how to do this are available on the Web.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Example for PropertyEditor

Postby mkornatzki » Thu Sep 10, 2009 3:56 am

Thank's for the information.

I make a PropertyEditor and it works :)

For a bean i create a BeanInfo-Class and the method getPropertyDescriptors() returns only one propertyDescriptor.
As far as i understand the propertyeditor in the swingdesigner should only show this property but all properties of my bean are shown.
In the consoleLog of eclipse i can see that the method gets called.

Do you have a hint for me?

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Example for PropertyEditor

Postby Eric Clayberg » Thu Sep 10, 2009 11:27 am

mkornatzki wrote:As far as i understand the propertyeditor in the swingdesigner should only show this property but all properties of my bean are shown.

No. The list returned by getPropertyDescriptors() is not an exclusive list. It is used to tell the GUI builder about any special properties that you have that require special property editors or code generation. All of the standard, common properties of a widget are displayed without the need for any associated BeanInfo file. Even your custom properties don't require a special BeanInfo file, if your properties use common, standard data types. In those cases, your custom properties would just use the built-in data type editors provided by Swing Designer.

Note that you can use the Swing Designer Customization API to further customize the palette and properties...

http://download.instantiations.com/D2WB ... ionAPI.pdf
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Example for PropertyEditor

Postby mkornatzki » Fri Sep 18, 2009 12:25 am

Hello,

sorry (i am new in beans), but i guess you mean the "no" for the usage in SwingDesigner not in general?

PropertyDescriptor[] getPropertyDescriptors();
Gets the bean's PropertyDescriptors.
An array of PropertyDescriptors describing the editable properties supported by this bean. May return null if the information should be obtained by automatic analysis.
If not return null then only the properties in the array should be shown in the propertiesEditor in designer.

If i made a simple bean named "MyPanel" only extends a JPanel and the appropriate MyPanelBeanInfo that returns only "background" as the propertyDescriptor then the propertyEditor in
SwingDesigner shows all properties (even those i don't want to show)
Image Image

and NetBeans
Image

Please don't missunderstand me. I like the swingdesigner and i try to create a bean as i read in the documentation and at least i try how it works in netbeans because it didn't work as expected in swingdesigner.

Maybe this is a function that swingdesigner don't want to include (and that's the reason for the link of the customization api to create a bean with special annotations for swingdesigner) or i make a mistake.

hopefully you can help me,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Example for PropertyEditor

Postby Eric Clayberg » Fri Sep 18, 2009 1:57 pm

mkornatzki wrote:PropertyDescriptor[] getPropertyDescriptors();
Gets the bean's PropertyDescriptors.
An array of PropertyDescriptors describing the editable properties supported by this bean. May return null if the information should be obtained by automatic analysis.

If not return null then only the properties in the array should be shown in the propertiesEditor in designer.

I think where we differ in our interpretation is your inclusion of the word "only" in the above. You are reading an implicit "only" into the JavaDoc that we don't believe is there (or even should be there).

Currently, we treat the BeanInfo class as an override designed to either add additional special properties or customize specific existing properties. That is a much, much friendlier interpretation for most users (and custom component builders) than what you suggest. In fact, if you think about your interpretation, it means that even if all you want to do is add or customize a single property, you are now responsible for all of them. That is a lot of extra work and doesn't even address the issue of non-standard properties that are added via other means. Even your NetBeans screen shot shows additional properties listed beyond the single one that should be the only one listed according to you.

I would further suggest that our interpretation is the better one 99% of the time. We have dealt with hundreds of users thus far who have wanted to add or customize a property. Not one of them has asked us to only show that one property (until now).

mkornatzki wrote:Maybe this is a function that swingdesigner don't want to include (and that's the reason for the link of the customization api to create a bean with special annotations for swingdesigner) or i make a mistake.

The normal JavaBean API is actually quite limited in terms of what you can say about properties and only maps to a portion of the Customization API that we support. We offer our own API to give the developer much better control over properties and editors than is possible using standard JavaBean techniques. You can certainly use standard JavaBean customization techniques, but we also allow you to go well beyond those.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Example for PropertyEditor

Postby mkornatzki » Sun Sep 20, 2009 11:20 pm

thanks for your detailed response.

With your help i get the configuration of my bean with the configuration api to work (another post). With this i can hide properties and thats what i wanted to do.

regards,
michael
mkornatzki
 
Posts: 121
Joined: Wed Oct 15, 2008 3:57 am

Re: Example for PropertyEditor

Postby Eric Clayberg » Mon Sep 21, 2009 4:19 am

Good. I'm glad that worked for you.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest