PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: gwinnem on November 11, 2009, 03:05:48



Title: Eclipse plugin for pureMVC
Post by: gwinnem on November 11, 2009, 03:05:48
Does anyone know about a good eclipse plugin for developing pureMVC apps ?


Title: Re: Eclipse plugin for pureMVC
Post by: Jason MacDonald on November 11, 2009, 07:07:09
Flex Builder (Flash Builder)? :)


Title: Re: Eclipse plugin for pureMVC
Post by: meekgeek on November 11, 2009, 11:07:19
I was actually hoping to see some custom project files that would help you start coding with puremvc.  Maybe a quick key for "create new Mediator"  My java is not so good right now, but I'm hoping to one day get to this if no one else does it first.


Title: Re: Eclipse plugin for pureMVC
Post by: Tekool on November 11, 2009, 12:43:47
Do you both have tried "PureMVC generator" http://www.dehats.com/drupal/?q=node/31 it's Air but can help a lot.


Title: Re: Eclipse plugin for pureMVC
Post by: gwinnem on November 12, 2009, 02:23:59
I have tried the FCG air app tool. But i was asking if there was a specific plugin like Log4Flex where you with easy shortcut keys in eclipse can generate new SimpleCommands, Mediators etc...
And yes :) i have offcourse the flexbuilder plugin... ;D Im not exactly a novice developer since i have been developing java apps for the last 10 years in eclipse...

The reason for asking was that i was abit annoyed with the repetitive tasks for all the classes and if there is no plugin i would look into creating my own eclipse plugin..

Geirr


Title: Re: Eclipse plugin for pureMVC
Post by: Jason MacDonald on November 12, 2009, 08:30:33
There isn't one, to my knowledge. Though it would be helpful.

I kind of cheat a bit and use templates I created in FlashDevelop. I generate them when needed and then pull them into FB. It's a bit clumsy but it works. A plugin for Exclipse would be awesome, but I'm not the right person to write one (not a java guy).


there is also this ruby/ant thing http://blog.smartlogicsolutions.com/2008/12/05/introducing-puremvcgen-an-ant-based-puremvc-flex-generator/


Title: Re: Eclipse plugin for pureMVC
Post by: puremvc on November 13, 2009, 01:08:20
I haven't done any eclipse plugin work so I don't know how difficult it would be, but being an a die-hard eclipse user for nearly 10 years now, I can certainly say eclipse plugin would be nice!

-=Cliff>


Title: Re: Eclipse plugin for pureMVC
Post by: gwinnem on November 14, 2009, 06:01:37
Hi Cliff.

I was planning adding the following to the plugin:
  • Add PureMvc Nature
  • Create New Facade
  • Create New Proxy
  • Create New Mediator
  • Create New Simple Command
  • Create New Macro Command

The PureMvc Nature will only add the puremvcmulticore swc to the project for now.
Will extend it to also handle pipes.

I prefer storing the notification constants in the classes which the notification triggers.
Any pro's con's on this approach ?

Also would like some feedback on what you consider as a minimum of functions to include in the different actors.

Geirr


Title: Re: Eclipse plugin for pureMVC
Post by: puremvc on November 14, 2009, 09:19:39
I prefer storing the notification constants in the classes which the notification triggers.
Not a good practice for two reasons:

1) It creates a 'forward-coupling' (knowing who you're sending the note to defeats the purpose of publish/subscribe)

2) When more than one actor responds to the note, this strategy isn't helpful because you only know one of the actors who is interested, and now unrelated actors must reference the actor who defined the constant in order to be interested in it.

If you don't like defining them on the facade, simply put them in an ApplicationConstants file. From there they can always be refactored easily should you want to break your model off into a separate package for use by another app.

-=Cliff>


Title: Re: Eclipse plugin for pureMVC
Post by: gwinnem on November 14, 2009, 11:54:09
Tnxs Cliff.
Do you have comments on the other question.

Geirr


Title: Re: Eclipse plugin for pureMVC
Post by: puremvc on November 15, 2009, 05:15:26
The first choice you have to make is Standard and MultiCore. This will lead you to two slightly different sets of templates. This will determine the library you put in the libs folder.

Then you'll need to find out what the package is (i.e. com.me.myapp). This will determine the structure under the src folder, and the package name in each class.

I'll have a go at some default templates for Standard and MultiCore actors here.

Standard Version Templates

A Standard Version app would have this packaging (minimally):

com.me.myapp.ApplicationFacade
com.me.myapp.ApplicationConstants
com.me.myapp.controller.StartupCommand
com.me.myapp.model.*
com.me.myapp.model.vo.*
com.me.myapp.view.*
com.me.myapp.view.components.*

Standard ApplicationFacade
:
package com.me.myapp
{
import com.me.myapp.controller.StartupCommand;

import org.puremvc.as3.patterns.facade.Facade;

        public static const STARTUP:String = "/note/startup";

        public function ApplicationFacade(  )
        {
                super();
        }

        public static function getInstance() : ApplicationFacade
        {
            if ( instance == null ) instance = new ApplicationFacade( );
            return instance as ApplicationFacade;
        }


        override protected function initializeController():void
        {
                super.initializeController();
registerCommand( STARTUP, StartupCommand );

// Register your initial commands here...

        }

        public function startup( app:Object ):void
        {
                sendNotification( STARTUP, app );
        }
}

Standard Mediator
:
package com.me.myapp.view
{
import com.me.myapp.ApplicationConstants;
import com.me.myapp.view.components.*;

import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

public class SomeMediator extends Mediator
{
public static const NAME:String = 'SomeMediator';

  public function SomeMediator( viewComponent:Object )
{
super( NAME, viewComponent );
}

override public function onRegister():void
{
   // Add your initialization activities here not in the constructor
                   // Add event listeners to your component, fetch references to
                   // frequently accessed proxies, etc.
}

override public function listNotificationInterests():Array
{

return [ //ApplicationConstants.SOME_NOTE
         ];
}

override public function handleNotification( note:INotification ):void
{
/*
switch ( note.getName() )
{
case ApplicationConstants.SOME_NOTE:
myComponent.someProp = note.getBody() as SomeClass;
break;
}
*/
}

override public function onRemove():void
{
   // Remove any listeners, null component references, etc.
}

protected function get myComponent():MyComponent
{
return viewComponent as MyComponent;
}
}
}

Standard Proxy
:
package com.me.myapp.model
{
import org.puremvc.as3.patterns.proxy.Proxy;

public class SomeProxy extends Proxy
{
public static const NAME:String = 'SomeProxy';

public function SomeProxy( )
{
super ( NAME );
}

override public function onRegister():void
{
   // Add your initialization activities here not in the constructor
                   // Add services or delegates and their event listeners, etc.
}

override public function onRemove():void
{
   // Remove any listeners, null references, etc.
}
}

Standard SimpleCommand
:
package com.me.myapp.controller
{
import com.me.myapp.ApplicationConstants;

import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.command.SimpleCommand;

public class StartupCommand extends SimpleCommand
{
override public function execute(note:INotification):void
{
// Prepare the Model
//facade.registerProxy( new SomeProxy() );

// Prepare the View
//var app:Shell = note.getBody() as Shell;
//facade.registerMediator( new ShellMediator( app ) );
}
}
}

Standard Command
:
package com.me.myapp.controller
{
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class SomeMacroCommand extends MacroCommand
    {
       
        override protected function initializeMacroCommand() :void
        {
            //Add your subcommands here
            //addSubCommand( SomeSubCommand );
        }
    }
}


MultiCore Templates

A MultiCore app with a Shell and two modules ModuleA and ModuleB would have a package like this (minimally):
com.me.myapp.common.ApplicationConstants
com.me.myapp.common.model.*
com.me.myapp.common.view.*

com.me.myapp.shell.ShellFacade
com.me.myapp.shell.controller.StartupCommand
com.me.myapp.shell.model.*
com.me.myapp.shell.view.*
com.me.myapp.shell.view.components.*

com.me.myapp.modulea.ModuleAFacade
com.me.myapp.modulea.controller.StartupCommand
com.me.myapp.modulea.model.*
com.me.myapp.modulea.view.*

com.me.myapp.moduleb.ModuleBFacade
com.me.myapp.moduleb.controller.StartupCommand
com.me.myapp.moduleb.model.*
com.me.myapp.moduleb.view.*

MultiCore ApplicationFacade
:
package com.me.myapp.shell
{
import com.me.myapp.shell.controller.StartupCommand;

import org.puremvc.as3.multicore.patterns.facade.Facade;

        public static const STARTUP:String = "/note/startup";

        public function ApplicationFacade( key:String )
        {
                super(key);
        }

        public static function getInstance( key:String ) : ApplicationFacade
        {
            if ( instanceMap[ key ] == null ) instanceMap[ key ]  = new ApplicationFacade( key );
            return instanceMap[ key ] as ApplicationFacade;
        }

        override protected function initializeController():void
        {
                super.initializeController();
registerCommand( STARTUP, StartupCommand );

// Register your initial commands here...

        }

        public function startup( app:Object ):void
        {
                sendNotification( STARTUP, app );
        }
}

MultiCore Mediator
:
package com.me.myapp.shell.view
{
import com.me.myapp.common.ApplicationConstants;
import com.me.myapp.view.components.*;

import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;

public class SomeMediator extends Mediator
{
public static const NAME:String = 'SomeMediator';

  public function SomeMediator( viewComponent:Object )
{
super( NAME, viewComponent );
}

override public function onRegister():void
{
   // Add your initialization activities here not in the constructor
                   // Add event listeners to your component, fetch references to
                   // frequently accessed proxies, etc.
}

override public function listNotificationInterests():Array
{

return [ //ApplicationConstants.SOME_NOTE
         ];
}

override public function handleNotification( note:INotification ):void
{
/*
switch ( note.getName() )
{
case ApplicationConstants.SOME_NOTE:
myComponent.someProp = note.getBody() as SomeClass;
break;
}
*/
}

override public function onRemove():void
{
   // Remove any listeners, null component references, etc.
}

protected function get myComponent():MyComponent
{
return viewComponent as MyComponent;
}
}
}

MultiCore Proxy
:
package com.me.myapp.shell.model
{
import org.puremvc.as3.multicore.patterns.proxy.Proxy;

public class SomeProxy extends Proxy
{
public static const NAME:String = 'SomeProxy';

public function SomeProxy( )
{
super ( NAME );
}

override public function onRegister():void
{
   // Add your initialization activities here not in the constructor
                   // Add services or delegates and their event listeners, etc.
}

override public function onRemove():void
{
   // Remove any listeners, null references, etc.
}
}

MultiCore SimpleCommand
:
package com.me.myapp.shell.controller
{
import com.me.myapp.common.ApplicationConstants;

import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.command.SimpleCommand;

public class StartupCommand extends SimpleCommand
{
override public function execute(note:INotification):void
{
// Prepare the Model
//facade.registerProxy( new SomeProxy() );

// Prepare the View
//var app:Shell = note.getBody() as Shell;
//facade.registerMediator( new ShellMediator( app ) );
}
}
}

MultiCore Command
:
package com.me.myapp.shell.controller
{
    import org.puremvc.as3.multicore.interfaces.*;
    import org.puremvc.as3.multicore.patterns.command.*;

    public class SomeMacroCommand extends MacroCommand
    {
       
        override protected function initializeMacroCommand() :void
        {
            //Add your subcommands here
            //addSubCommand( SomeSubCommand );
        }
    }
}

-=Cliff>


Title: Re: Eclipse plugin for pureMVC
Post by: Jason MacDonald on November 16, 2009, 07:36:15
If I could make one small request, please ensure the template are editable :) Or, if possible, allow for creation of custom templates in addition to the defaults :)


Title: Re: Eclipse plugin for pureMVC
Post by: gwinnem on November 16, 2009, 10:14:13
I was planning todo the templates in xml so its possible to edit them.
In eclipse it would be easy to edit them.

I posted a small blog post at http://gwinnem.wordpress.com/2009/11/14/building-a-puremvc-multicore-eclipse-plugin-creating-a-preference-page/

Just to give a small impression on what i plan for the plugin.

Feel free to give me some input regarding this.

In the next tutorial i plan to explain howto create the context menu items for this plugin

Rgds
Geirr


Title: Re: Eclipse plugin for pureMVC
Post by: swidnikk on January 08, 2010, 06:06:19
I wish it was easier as this would be immensely useful (especially in team environments). Here's a full blown tutorial from IBM

http://www.ibm.com/developerworks/edu/os-dw-os-eclipse-code-templates.html

http://www.ibm.com/developerworks/opensource/library/os-eclipse-plugin-templates/?S_TACT=105AGY82&S_CMP=GENSITE


Title: Re: Eclipse plugin for pureMVC
Post by: gwinnem on January 11, 2010, 04:35:01
I am sorry to inform you that the first final version of this plugin will not be opensource. I just got a contract with http://ahead.com and i will do the first verion for them.

Geirr


Title: Re: Eclipse plugin for pureMVC
Post by: swidnikk on February 12, 2010, 05:49:12
So update here... Flash Builder has support for templates in preferences (including import/export) and it looks relatively easy to implement by editing an XML file. Def not as easy as Flash Develop which just read the file system at startup. If I get a little extra time I'll post here, but below is the XML if anyone wants to take initiative. Pretty easy to follow.

Here's a preview of the structure

:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<templates>
<template autoinsert="true" context="new_actionscript_file" deleted="false" description="Newly created ActionScript file" enabled="true" id="com.adobe.flexide.as.core.filetemplates.new_actionscript_file" name="ActionScript File">// ActionScript file</template><template autoinsert="true" context="new_actionscript_class" deleted="false" description="Newly created ActionScript Class file" enabled="true" id="com.adobe.flexide.as.core.filetemplates.new_actionscript_class" name="ActionScript Class">
${package_declaration}
{
${import_declaration}
${class_declaration}
{
${class_body}
}
}
</template>
</templates>


Title: Re: Eclipse plugin for pureMVC
Post by: puremvc on February 12, 2010, 11:24:55
Cool. Do you know if Flex Builder 3 does this as well, or is it new?

-=Cliff>


Title: Re: Eclipse plugin for pureMVC
Post by: schneidi234 on April 19, 2010, 12:49:11
Hello Cliff,

you asked if it's possible to add code templates in Flex Builder 3?
No. You can only change the font style and the syntax code colors in the
menu
Window -> Preferences -> Flex -> Editor -> Syntax Coloring.

In the Flash Builder 4 you can only edit an existing template here
Window -> Preferences -> Flash Builder -> File Templates -> Syntax Coloring

You can export all templates and edit the xml file, like your needs. But you
can't add a new item to the context menu like 'New PureMVC Mediator'.


Title: Re: Eclipse plugin for pureMVC
Post by: mico on October 04, 2010, 08:17:14
Pureclipse is one of them: http://forums.puremvc.org/index.php?topic=1805.0