Changing constrained bean properties

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

Changing constrained bean properties

Postby iduman » Thu Nov 27, 2008 12:47 pm

I am not sure but I need to ask.

I defined a bean property as a constrained and bound property. In design time while changing the property in default property editor I am throwing a PropertyVetoException and catching it (In run time I will throw another exception). In design time, when I catch the PropertyVetoException I am again calling setX method for setting the property value to the previous value and rejecting the new value. But the code is generated with the new value by the designer instead of the old value. I also tried making a new call to firePropertyChange with the old value in it, but it didn't work.

Is this a normal result ?

Another question is that; if I don't catch the exception, who catchs it at design time or what happens to the exception? Does designer catch an exception such as PropertyVetoException at design time?

pseudo code;

Code: Select all
public void setX ( value b ) 
    {     
        if bean.isDesignTime()
         try  { 
       
                fireVetoableChange ( "X", oldvalue, newValue ) ;
             }  catch  ( PropertyVetoException e )   { 
               //firePropertyChange ( "X", oldvalue, oldValue ) ;
              //firePropertyChange ( "X", " ", oldValue ) ;
              setX(oldValue);

            } 
}
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Changing constrained bean properties

Postby Eric Clayberg » Fri Nov 28, 2008 9:00 pm

That code is not run at design time as there is no live instance involved when a property is changed. Designer parses the class source to create an AST model of the entire class. Property assignments are just AST nodes that are updated to reflect property changes. PropertyVetoException is not thrown or caught in this case.

To create a constrained property, you would need to create a custom property editor.
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: Changing constrained bean properties

Postby iduman » Tue Dec 02, 2008 1:28 am

I created a simple custom property editor, how can I enable/disable the "OK" button on the property editor window ?
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Changing constrained bean properties

Postby Eric Clayberg » Tue Dec 02, 2008 5:26 am

iduman wrote:I created a simple custom property editor, how can I enable/disable the "OK" button on the property editor window ?

I am not aware of any way to do that.
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: Changing constrained bean properties

Postby iduman » Tue Dec 02, 2008 5:38 am

I want to validate input data (data consistency) before OK button pressed, what can I do?
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Changing constrained bean properties

Postby Konstantin.Scheglov » Tue Dec 02, 2008 9:05 am

Unfortunately, java.beans.PropertyEditor does not specify any standard way how custom editor Component can interact with enclosing dialog. So, we don't have any support for this.
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk

Re: Changing constrained bean properties

Postby iduman » Wed Dec 03, 2008 3:48 am

Are you planning to add this support to designer? Because according to my research on the internet NetBeans supports this control with an interface called as ExPropertyEditor.
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Changing constrained bean properties

Postby Konstantin.Scheglov » Wed Dec 03, 2008 9:46 am

We may add this in future, but don't have any specific plans.

BTW, ExPropertyEditor is part of own NetBeans API, not something standard.
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk


Return to Swing Designer

Who is online

Users browsing this forum: Google [Bot] and 1 guest