Re: Actor attributeChanged() methods and validating mutliple changes.
My suggestion doesn't require any work at all in the actor... Certainly I would not override NamedObject.executeChangeRequests(). It's just a change in when the edit parameters dialog issues the change request. Edward At 10:22 AM 2/16/2006, Kevin Ruland wrote: Then would I also override NamedObject.executeChangeRequests() or would I have to have the actor implement ChangeListener then register this as a change listener on this? class MyActor extends Source implements ChangeListener { public MyActor( CompositeEntity container, String name ) { super(container, name); addChangeListener(this); } public void changeExecuted( ChangeRequest change ) { // Do extra validation & d/l, etc. } public void changeFailed( ChangeRequest change ) { // nothing? return; } } I think I saw the NamedObj uses a list of WeakReferences for the listeners so I don't have to unregister in a finalizer, right? How would this work when reading in a moml which contains one of these actors already configured? Would it still get only one change request, or would it receive multiples? Kevin Edward A. Lee wrote: As I recall, the current dialog pane issues the change request for a parameter change when the parameter's editing widget loses the focus. I believe the reason for this was that there was because there are several ways that a dialog might get closed, and Swing is not rigorous about notifications (or, perhaps more likely, I found the documentation incomprehensible and couldn't get it to work). I'm open to a change in the dialog box that would issue the change request only when an Apply or OK button is pressed... This would probably solve the problem... Edward At 09:36 AM 2/16/2006, Kevin Ruland wrote: To make matters worse, the output ports available depend on the contents of this metadata. So the only way for the user to construct the workflow would be to configure, run & wait for failure, then construct the relationships and run again. If I write my own parameter dialog pane would I have notification of "commit"? Kevin Edward A. Lee wrote: At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
Hi Kevin, We tried to address this issue several times in the past, both for the WebService and OpenDBConnection actors, but still there doesn't seem to be a solution. In the org.geon.OpenDBConnection actor, I populate the schema parameter per attributes changes to be able to use it with the query builder prior to the workflow execution. For the mean time, I overcome this problem by trying to connect to the database and extract the schema per each attribute change (and the final change will be once the user commits). Perhaps the same solution may work for you? - Efrat Kevin Ruland wrote: To make matters worse, the output ports available depend on the contents of this metadata. So the only way for the user to construct the workflow would be to configure, run & wait for failure, then construct the relationships and run again. If I write my own parameter dialog pane would I have notification of "commit"? Kevin Edward A. Lee wrote: At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
Efrat, That's what would end up happening now - except the user could be presented with some ugly intermediate states. Kevin Efrat Frank wrote: Hi Kevin, We tried to address this issue several times in the past, both for the WebService and OpenDBConnection actors, but still there doesn't seem to be a solution. In the org.geon.OpenDBConnection actor, I populate the schema parameter per attributes changes to be able to use it with the query builder prior to the workflow execution. For the mean time, I overcome this problem by trying to connect to the database and extract the schema per each attribute change (and the final change will be once the user commits). Perhaps the same solution may work for you? - Efrat Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
Then would I also override NamedObject.executeChangeRequests() or would I have to have the actor implement ChangeListener then register this as a change listener on this? class MyActor extends Source implements ChangeListener { public MyActor( CompositeEntity container, String name ) { super(container, name); addChangeListener(this); } public void changeExecuted( ChangeRequest change ) { // Do extra validation & d/l, etc. } public void changeFailed( ChangeRequest change ) { // nothing? return; } } I think I saw the NamedObj uses a list of WeakReferences for the listeners so I don't have to unregister in a finalizer, right? How would this work when reading in a moml which contains one of these actors already configured? Would it still get only one change request, or would it receive multiples? Kevin Edward A. Lee wrote: As I recall, the current dialog pane issues the change request for a parameter change when the parameter's editing widget loses the focus. I believe the reason for this was that there was because there are several ways that a dialog might get closed, and Swing is not rigorous about notifications (or, perhaps more likely, I found the documentation incomprehensible and couldn't get it to work). I'm open to a change in the dialog box that would issue the change request only when an Apply or OK button is pressed... This would probably solve the problem... Edward At 09:36 AM 2/16/2006, Kevin Ruland wrote: To make matters worse, the output ports available depend on the contents of this metadata. So the only way for the user to construct the workflow would be to configure, run & wait for failure, then construct the relationships and run again. If I write my own parameter dialog pane would I have notification of "commit"? Kevin Edward A. Lee wrote: At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
As I recall, the current dialog pane issues the change request for a parameter change when the parameter's editing widget loses the focus. I believe the reason for this was that there was because there are several ways that a dialog might get closed, and Swing is not rigorous about notifications (or, perhaps more likely, I found the documentation incomprehensible and couldn't get it to work). I'm open to a change in the dialog box that would issue the change request only when an Apply or OK button is pressed... This would probably solve the problem... Edward At 09:36 AM 2/16/2006, Kevin Ruland wrote: To make matters worse, the output ports available depend on the contents of this metadata. So the only way for the user to construct the workflow would be to configure, run & wait for failure, then construct the relationships and run again. If I write my own parameter dialog pane would I have notification of "commit"? Kevin Edward A. Lee wrote: At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
To make matters worse, the output ports available depend on the contents of this metadata. So the only way for the user to construct the workflow would be to configure, run & wait for failure, then construct the relationships and run again. If I write my own parameter dialog pane would I have notification of "commit"? Kevin Edward A. Lee wrote: At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
At 07:24 AM 2/16/2006, Kevin Ruland wrote: Is there any way for the actor be notified when the user decides all the changes are complete? Not really... I'm not sure how one could do that... You could check the parameters in preinitialize(). Edward Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
I over simplified the example. In my particular case, there is no mathematical formula to use. I have an actor which loads metadata from local or remote sources. One way to specify the metadata location is to use a simple URL (file://, http://, or ftp://), the other is to specify a web service endpoint and a string parameter. There are two ways to hold this information: 1) Use a String for the w/s parameter, and a single String to hold either the URL or the endpoint (which is a url). 2) Use a String for the w/s parameter, a String for the endpoint, and a String for the URL. In the first case, it will be difficult to distinguish if the URL String represents a simple http request or an http end point. In the second case, it would be possible to have all three fields populated and not be able to distinguish if the user wants to use the URL or the Web Service. Since neither of these work, I'd like to have a simple drop down or check box to have the user specify which mechanism they want. That pretty much solves all the confusion. However, validation is still a problem particularly if I'd like to check if the URL location or web service parameters are valid. The user could start with the URL location parameter as empty string, then change the selector to use a location. Is there any way for the actor be notified when the user decides all the changes are complete? Kevin Edward A. Lee wrote: Why not set the parameter values as follows: This looks to me like a rather non-orthogonal design. Why not have: a1 = something a3 = 0 or 1 ortrue or false(depending on semantics) then calculate what you now call a2: a2 = 2*a1 + a3 Edward At 10:36 AM 2/15/2006, Kevin Ruland wrote: Hi all, We have a number of actors which require certain conditions to be satisfied by attributes as a collection. For sake of example, suppose we have two attributes a1, a2 which are integers. And the following conditions must hold: a1 = 1 <=> a2 = 1, 2 a1 = 2 <=> a2 = 3, 4 You get the idea. Now suppose the user selects configure actor and sees: a1: 1 a2: 2 And wants to configure the actor to be: a1: 2 a2: 4 If I do all the validation in the attributeChanged method such as this: public void attributeChanged(Attribute attribute) throws IllegalActionException { int a1val; int a2val; if ( attribute.equals(_a1) || attribute.equals(_a2) ) { try { a1val = Integer.parseInt( _a1.getExpression() ); a2val = Integer.parseInt( _a2.getExpression() ); } catch (NumberFormatException e ) { throw new IllegalActionException("Invalid Number"); } switch (a1val) { case 1: if ( a2val != 1 && a2val != 2 ) { throw new IllegalActionException("invalid values"); } break; case 2: if ( a2val != 3 && a2val != 4 ) { throw new IllegalActionException("invalid values"); } break; default: throw new IllegalActionException("invalid values"); } } super.attributeChanged(attribute); } With this code in place I was actually able to convince the actor to move to the proper state but only by judiciously "ok"-ing the error dialog. In fact, by abusing the error dialog I was even able to move the actor into a completely invalid configuration. Is there a better place to do this validation -- I'm hoping for notification from the "commit" button instead of in preinitialize/initialize. For this simple example, I could perhaps change the Thanks for the help. Kevin Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Re: Actor attributeChanged() methods and validating mutliple changes.
Why not set the parameter values as follows: This looks to me like a rather non-orthogonal design. Why not have: a1 = something a3 = 0 or 1 ortrue or false(depending on semantics) then calculate what you now call a2: a2 = 2*a1 + a3 Edward At 10:36 AM 2/15/2006, Kevin Ruland wrote: Hi all, We have a number of actors which require certain conditions to be satisfied by attributes as a collection. For sake of example, suppose we have two attributes a1, a2 which are integers. And the following conditions must hold: a1 = 1 <=> a2 = 1, 2 a1 = 2 <=> a2 = 3, 4 You get the idea. Now suppose the user selects configure actor and sees: a1: 1 a2: 2 And wants to configure the actor to be: a1: 2 a2: 4 If I do all the validation in the attributeChanged method such as this: public void attributeChanged(Attribute attribute) throws IllegalActionException { int a1val; int a2val; if ( attribute.equals(_a1) || attribute.equals(_a2) ) { try { a1val = Integer.parseInt( _a1.getExpression() ); a2val = Integer.parseInt( _a2.getExpression() ); } catch (NumberFormatException e ) { throw new IllegalActionException("Invalid Number"); } switch (a1val) { case 1: if ( a2val != 1 && a2val != 2 ) { throw new IllegalActionException("invalid values"); } break; case 2: if ( a2val != 3 && a2val != 4 ) { throw new IllegalActionException("invalid values"); } break; default: throw new IllegalActionException("invalid values"); } } super.attributeChanged(attribute); } With this code in place I was actually able to convince the actor to move to the proper state but only by judiciously "ok"-ing the error dialog. In fact, by abusing the error dialog I was even able to move the actor into a completely invalid configuration. Is there a better place to do this validation -- I'm hoping for notification from the "commit" button instead of in preinitialize/initialize. For this simple example, I could perhaps change the Thanks for the help. Kevin Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] Edward A. Lee Professor, Chair of the EE Division, Associate Chair of EECS 231 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]
Actor attributeChanged() methods and validating mutliple changes.
Hi all, We have a number of actors which require certain conditions to be satisfied by attributes as a collection. For sake of example, suppose we have two attributes a1, a2 which are integers. And the following conditions must hold: a1 = 1 <=> a2 = 1, 2 a1 = 2 <=> a2 = 3, 4 You get the idea. Now suppose the user selects configure actor and sees: a1: 1 a2: 2 And wants to configure the actor to be: a1: 2 a2: 4 If I do all the validation in the attributeChanged method such as this: public void attributeChanged(Attribute attribute) throws IllegalActionException { int a1val; int a2val; if ( attribute.equals(_a1) || attribute.equals(_a2) ) { try { a1val = Integer.parseInt( _a1.getExpression() ); a2val = Integer.parseInt( _a2.getExpression() ); } catch (NumberFormatException e ) { throw new IllegalActionException("Invalid Number"); } switch (a1val) { case 1: if ( a2val != 1 && a2val != 2 ) { throw new IllegalActionException("invalid values"); } break; case 2: if ( a2val != 3 && a2val != 4 ) { throw new IllegalActionException("invalid values"); } break; default: throw new IllegalActionException("invalid values"); } } super.attributeChanged(attribute); } With this code in place I was actually able to convince the actor to move to the proper state but only by judiciously "ok"-ing the error dialog. In fact, by abusing the error dialog I was even able to move the actor into a completely invalid configuration. Is there a better place to do this validation -- I'm hoping for notification from the "commit" button instead of in preinitialize/initialize. For this simple example, I could perhaps change the Thanks for the help. Kevin Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]