Mark Drew (Redux)- cf_etc...

a compendium of railo, cfml, cfeclipse and technology topics

Mark Drew (Redux)- cf_etc...

CFEclipse and Generic Framework support

August 10, 2006 ·

I have been thinking on how to implement "generic" framework support in CFEclipse. I apologise if this post seems a bit rambling but its to get some opinions from people out there and to formalise my thinking a little before I go off and develop something. So, What do I mean by generic framework support? Well, making plugins for each framework is kind of hard. Yes, they all have their own way of doing things but way back when I was doing the Fusebox Plugin, I realised the problems, and also saw how much overlap of code there is. To overcome making plugins for each framework, I am thinking that we need to abstract a little what each framework does (with relation to coding and implementing it), the actions and the UI that each would need. Since each of the frameworks is likely to change in time, and maybe new ones come up, we need a way in CFEclipse to be able to modify (like the dictionary files) and add new framework definitions. I am breaking down the issues for implementing framework support and hopefully shake out a way of developing it as follows: Configuration Most frameworks (I am looking at Model-Glue, Fusebox and Mach II) are configured using an XML file, which has a number of nodes that say the flow of actions in your application, the files to include and the settings of your application. Fusebox also has a number of iterators and logic nodes in the XML. I know there are other frameworks out there, which are configured differently, but these are the main ones I am looking at the moment since I have some knowledge of them and they can be generalised. (I should also include Reactor and Coldspring in this) We need a way to say that, for example, "ModelGlue.xml" is a config file and we should open it and treat it differently or that Fusebox.cfm is also a framework file that we want to edit differently. When I was implementing the Fusebox plugin, I run into the problem that I had to create an object (a class) for each node type, now this isnt a problem if the lexicon of a framework is small, but for Fusebox the lexicon is rather large and in fact (correct me if I am wrong) I think you can add your own nodes. This would make it a nightmare of classes that are specific to a framework. Ok, so lets create a generic node that can have a name, a parent and a number of children. Then we name that node, and assign an image to it. Another part of a framework seems to be the base files required when you are creating an application. These files need to be dropped into your application, such as config files, index.cfm etc. I am not talking about the Core Framework Files that you would create a ColdFusion Mapping to, but the ones you will be working, such as the sample application templates for each framework. To address this and also kill another bird with the same sharpened stone, I have an idea of extending the "New File From Template" to creating a "New Project From Template" which would you, as a user would set up by setting a project that you keep all your project templates in and in each folder you can put a set of files that make up a baseline application,e,g a folder called "Normal CF Project" with Application.cfm and index.cfm or a folder called "CFC Project" with Application.cfc and index.cfm or a folder with the Model Glue application template. This would mean that when you are creating a project you can select from which of these folders you would copy the files into your new project. This is fine so far but lacks another part, all the replacements you have to do (for example the name of the application). I though this might be solved by using the snippet syntax in those files e.g <cfapplication name="${{applicationname}"> So a brute force attack would be to parse ALL of the files under that folder looking for snippet texts. Mike Nimer actually suggested something, which would be to copy the files using ANT. This is a very intelligent choice as I can use a generic ANT build file (I am talking in the background, Eclipse running it as part of its project creation script) that I can pass a list of replacements. At the root of each project we would have a xml file that CFEclipse can read, for you to put all the values to replace, then in each of the files you would have variables that are replaced. Views (or UI) What views would you need for your framework? I am thinking currently that we only need two views, one being the Framework File Editor, basically an XML editor that (in the background) knows what DTD to use for that particular framework file and what insight to provide, and a outline view of all the nodes in that file. Well, XML buddy already has a outline view of your xml. If we are re-creating an XML editor for the config files and we have outline view, maybe we could configure it to be filtered (show events for MG, fuse-actions for Fusebox etc) by a particular node. Each node type would then need to have its own action (when you double click etc) and ways to add new nodes (where applicable). Actions Now we can edit our framework files, we need to add actions, I would say that to start out with we have some simple "open" actions assigned to some nodes, so some examples: * For ModelGlue.xml - On node "include", use template, to open file by path * For ModelGlue.xml - On node "include", use template, to open file by path, using "ColdSpring/beans/bean:id=modelGlueConfiguration/property:name=viewMappings" value as the root *For ModelGlue.xml - On node "modelglue/controllers/controller:type" open file by package *For ModelGlue.xml - On node "modelglue/event-handlers/event-handler/broadcast/message:name" open file referenced in "modelglue/controllers/controller/message-listener".parent.type where message:name = message-listener:message These are just examples to get my head round how the actions would need to be worked out. But basically the actions here are open by path or open by package. Other actions would run in the background and they are custom validation, not just XML validation but for example * validate that all "modelglue/event-handlers/event-handler/broadcast/message:name" have a corresponding "modelglue/controllers/controller/message-listener:message" * validate that for "modelglue/controllers/controller/message-listener:function" there is a corresponding cffunction in the "open file by package" for "modelglue/controllers/controller/message-listener"_parent.type As you can see we are starting to get a syntax here of the type of language that we need to define for each framework. So to add framework support this would be done by creating a file for each framework file that we shall handle, it would define where to look for a DTD, define actions per named node, define validations and define nodes that will be displayed in the outline I don't have much experience in this area so I appreciate any comments on my logic so far.

Tags: cfeclipse · coldfusion · fusebox · model-glue

7 responses

  • 1 Lola Lee Beno // Sep 22, 2008 at 4:13 PM

    I don't know how hard it would be to do this. But . . . how about if there was a way to somehow discover all the framework project templates (such as modelglueapplicationtemplates), generate a picklist and display in the dalog for creating a new framework-based project. Like so:

    Picklist:
    ModelGlue Template
    FuseBox5 Template
    etc.

    Path of New Project: [ textbox ]

    [submit box]

    There's a nice build script that Joe created, where you just fill in the value for your new MG application and the value gets written into the copy generated from the MG sample template. Perhaps you can work off this script.

    Of course, if this is impratical, just feel free to write it off.
  • 2 Sam Farmer // Sep 22, 2008 at 4:13 PM

    This would be a tremendous addition to CFEclipse and ColdFusion in general.
  • 3 Mark Drew // Sep 22, 2008 at 4:13 PM

    @Lola: this would be the idea of having a project that you define as a repository for all your framework templates. You would need to tell CFEclipse that this is the repository for them (you could for example connect each folder to the the svn repository for that project's template site) and keep it up to date. The pick list would be the directories under the root of that Project in CFEclipse.

    The ant file (similar to Joe's) would actually grab the files and do a replace on variables, same as joe's but you would just need to put another XML file in the root of that project to get a dialog with all the variables you want to change.
  • 4 Matt Williams // Sep 22, 2008 at 4:13 PM

    I would be careful not to make CFEclipse too smart and not do too much for me. I'm getting fears of the MS Word auto-spell correct happening. &quot;No, I don't want a capital T.&quot; I seem to work alright with XML Buddy giving insight. Maybe I'm an exception, but I'm not creating that many new applications that I need to have those initial parts automated. Actually, having to hand code some of those XML properties for each new app helps me get back into some of those basics of the framework I tend to forget when in the thick of the model.
  • 5 Kevin Roche // Sep 22, 2008 at 4:13 PM

    Mark, I think, for fusebox, if the editor could validate against the DTD or Schema and the ability to right click on an include and open the CFM file or on a do and open the CML file, that would be enough for me.
  • 6 Sandra Clark // Sep 22, 2008 at 4:13 PM

    Let the XML editors do what they do best, which is create the tag insights and validate the XML.

    Toolbars for some of the more common items (such as off the circuit.dtd in Fusebox) would be nice, as would the ability to create a project based on a framework, click on a &lt;do /&gt; or &lt;include /&gt; or function call and have it open the file. (probably reaching on the function call).

    XML Buddy and OXygen works well for me for Fusebox.xml and Circuit.xml with the DTDs. What doesn't work well is fusedocs since they live in .cfm files. So I'd like to see some things that aren't well covered by other plugins for eclipse rather than a &quot;stuff it in one plugin everything but the kitchen sink like Dreamweaver&quot; situation.

    Of course my two cents.
  • 7 Mark Drew // Sep 22, 2008 at 4:13 PM

    Well, I have been talking to Rob Rohan about this, and the problem with normal XML validation against a DTD is that the DTD is static. i.e. it wont check (in ModelGlue for example) that the attribute you put in a broadcasts/message:name is one of the ones you defined in your message-listeners. It wont validate that the function in a message-listener is one of the functions in the referenced CFC.

    A way round this (if you were using XML buddy or something) is to either externally (i.e. in the filesystem, instead of inside of Eclipse's head) to generate dynamic DTD's depending on what you are editing. So, you would say, validate this XML against this DTD file, which Eclipse would build in the background, thus providing content insight to external validating Editors.

    With regards to openning included files, that is the job of the XMl editor and I couldnt add functions to that (not easily at any rate) but I could create a view that would be tied to a file for example.. and not to the editor, that you could do that with.

    I am still thinking about how this could be implemented though

    MD