Ah, this sounds like an extremely useful capability...


Java has a hot-swap capability... This is used, for example,
by Eclipse when you modify and recompile a piece of code while
the debugger is running. So to some extent, you get this for
free if you use Eclipse as the development environment.

However, I suspect this hot-swap capability is tricky to use...
Sometimes Eclipse reports that a hot swap isn't
possible for some instances...  I'm not sure what the
criteria are for determining whether hot swap is possible.
Anybody out there know more about this?

BTW: The capabilities you are describing here would probably
be most useful if they were folded in to the main Ptolemy II tree...
However, keep in mind that we can't fold in GPL'd code, because
then the GPL terms spread to the entire system...

Edward



At 08:38 AM 11/24/2003 -0800, Chad Berkley wrote:
hi edward,

sorry, I should have told you what I was doing. I've already written a utility to create actor code, compile it and then put it into the actor library. Now, I'm trying to use the same GUI that I developed to open an existing actor, modify it, recompile it then update the relevant models (those being the actorLibrary and the model that the edit request came from). Is there an easier way to get the models to update with the new actor information?

thanks,
chad

Edward A Lee wrote:
Shouldn't removing the actor also be done in a ChangeRequest?
This seems like a very puzzling thing to do... What are you trying
to accomplish?
Edward
At 10:34 AM 11/21/2003 -0800, Chad Berkley wrote:

hi,

I'm trying to remove and actor from the actorLibrary model, change it, then re-add it. For some reason, when it re-adds, you don't see the changes that were made.

Here's the code that I'm using:

List l = actorLibrary.entityList();
for(int i=0; i<l.size(); i++)
{  //look for the actor in the container.if it's there, remove it
  ComponentEntity ce = (ComponentEntity)l.get(i);
  if(ce.getName().equals(actor.getName()))
  {
    try
    {
      ce.setContainer(null); //remove the found entity
      StringWriter buffer = new StringWriter();
      ce.exportMoML(buffer, 1);
      ChangeRequest request = new MoMLChangeRequest(ce, actorLibrary,
        buffer.toString());
      actorLibrary.requestChange(request);
      break;
    }
    catch(Exception e)
    {
      throw new RuntimeException("Error removing existing actor from " +
        "container: " + e.getMessage());
    }
  }
}

actor.setContainer(actorLibrary);
StringWriter buffer = new StringWriter();
actor.exportMoML(buffer, 1);
ChangeRequest request = new MoMLChangeRequest(actor, actorLibrary,
  buffer.toString());
actorLibrary.requestChange(request);


When the ChangeRequest is made within the loop, it seems to *add* the actor to the library instead of remove it, even though I set the container to null. Vergil gives me an error when it hits the 2nd ChangeRequest saying that there is already an Entity with the same name in the model. If I remove the ChangeRequest within the loop, it appears to work (i.e. it does not give any error when it leaves the loop and resets the container) but it does not, in fact, update the model.


Any ideas?

thanks,
chad
--
-----------------------
Chad Berkley
National Center for
Ecological Analysis
and Synthesis (NCEAS)
[EMAIL PROTECTED]
-----------------------


----------------------------------------------------------------------------


Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

------------ Edward A. Lee, Professor 518 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0455, fax: 510-642-2739 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal


--
-----------------------
Chad Berkley
National Center for
Ecological Analysis
and Synthesis (NCEAS)
[EMAIL PROTECTED]
-----------------------

------------ Edward A. Lee, Professor 518 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0455, fax: 510-642-2739 [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]

Reply via email to