Xmi2As - ActionScript 2.0 Code Generator

| 8 Comments | 1 TrackBack

This tool will convert your UML Class Diagrams into ActionScript 2.0 code.

screenshot.jpg

Xmi2As is a pretty simple code generation framework written in Java and licensed under the GPL. Currently it supports ActionScript 2.0 code generation, but is easily extensible for your language of choice.

To add support for generation of a new language, take a look at AS2CodeGenerator.java, and model your MyLanguaugeCodeGenerator.java after it.

Usage is as follows:

Launch the .exe and browse for the .xmi file (exported from your favorite UML modeling program, like ArgoUML). Pick the directory to put the generated classes, and hit generate. You can also use it from the command line: > xmi2as model.xmi output_directory

There is a problem with the GUI on OSX. For some reason my layout code is busted on OSX, but seems to work fine on Windows. This is the first time I've ever had an issue like this with Java SWT. It could be related to the fixed size of the shell, but I don't have a Mac to test on. So... either someone else will need to fix it, or it will probably just always be broken.

However, you can still use the command line version from the Mac as well. Untested since I don't have a Mac, but you should be able to issue a command such as: java -classpath
"./jaxen-core.jar;./jaxen-jdom.jar;./jdom.jar;./saxpath.jar;./swt-
pi.jar;./swt.jar;./xerces.jar;./Xmi2As.jar;./xml-apis.jar"
com.darronschall.xmi2as.Xmi2As model.xmi output_dir

I've tested this against a few class diagrams and all seems to work well, but if you run into anything really weird let me know. There's still a piece of functionality missing, and that's generating all of the import statements for classes and interfaces. For now you'll have to add the imports by hand, but I'll probably fix that when I get a chance. I also want to add a command line switch for generating javadoc comments (currently its turned on, and the only way to turn it off is to recompile the code). I should probably add a switch for the desired output language as well... like, -as for ActionScript.

There are a bunch of "TODO"'s in the code. Thus, this isn't 100% complete but it works pretty well for me. Hopefully you'll find this useful too.

The home page for the project can be found at http://osflash.org/doku.php?id=xmi2as. Many thanks to OSFlash for hosting the SVN repository!

Enjoy!

1 TrackBack

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/56

FLASH/Tools from PukiWiki/TrackBack 0.2 on July 28, 2005 2:15 PM

TOOLS † Xmi2As - ActionScript 2.0 Code Generator This tool will convert your UML Class Diagrams into ActionScript 2.0 code. [via] mProjector FlashÀ½¤Î¥Ç¥¹¥¯¥È¥Ã¥×¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤òºîÀ®½Ã�Ã�è¤ë¥Ä¡¼¥ë Ripple Framework¡£FLASH¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Ã¤Æ¤¤¤í... Read More

8 Comments

  • Useful!

    It'd be really cool if you could do some sort of round-trip with this. Like: uml -> as -> uml -> as.
    I dunno if its possible to store your edited AS in the xml though so your code doesnt get lost.

     
  • I clicked the generate button the program closed and no files were created. Pretty sad.
    Windows system... ever had any trouble with that?
    Even console doesn't work.

     
  • What does your XMI file look like? I'm only supporting XMI version 1, and it's only been tested with the XMI files generated with ArgoUML. If it doesn't work for you, you're welcome to check out the code and modify it to your liking...

     
  • The XMI file was created using ArgoUML 0.19.3 with a sample zargo project file from Code Alloy - so the result is a version 1 XMI file.
    I really wonder why it is not working. What I am unsing now is a webbased parser. Works, but not comfortable at all.

     
  • If you don't mind, could you send me the .XMI file? I'm using ArgoUML 17.2, but I don't know that that would make that big of a difference. The problem with the .exe wrapper that I'm using is that it suppresses all of the error messages that are printed to the screen, so something else could be wrong, and it might not be the parsing at all. Check to make sure your output directory exists (it won't automatically create it for you, so it could be failing there).

    Either way, if I can get a hold of your .XMI file I can see if it's formatted differently than the ones I've been testing with. The file that I've been most of my testing with has been this one: http://svn.sourcesecure.co.uk/osflash/xmi2as/Xmi2As/example/example.xmi

     
  • Hi Darron,

    I've tried your file and it's working perfectly.
    You can download a zipfile containing the zargo file and the xmi file created with with 19.3 here: http://www.escapism.de/sampleDiagram.zip

     
  • Okay, I've just created my own diagram, exported it to XMI and generated Flash files from it. Worked fine.
    Something in the sample project I used must be responsible for the error then. Might have a closer look later.

     
  • All I can say is thank you! This cuts out the slowest part of starting an app, getting all of the Classes set up. I'm having no problems with ArgoUml v0.18.1 and the xmi2as app. ArgoUml does require Java 2 to be installed that might be causing a problem for some people.

     

Leave a comment

Flex.org - The Directory for Flex

Archives