Doing other things…

February 15th, 2010 admin 2 comments

Hello,

Since Potomac framework hasn’t seen a release in 3 months, it’s not to hard to imagine I have been doing other things for the last 2 months.

Don’t get me wrong, I really like this framework but, Flex 4 is nearing and Teoti Graphix, LLC has a lot of commercial components comming out.

Hopefully this bundle paradigm gains traction in 2010. I think the fact it relies on a closed source Flash Builder plug-in is going to hurt it as well.

http://www.teotigraphix.com

Mike

Categories: Potomac Tags:

Dialog implementation :: Take 1

January 7th, 2010 admin 1 comment

Hello,

This blog post will show the first type of Dialog implementation; a subclass of Dialog.

In the image below there is a simple dialog with the following additions;

  • A custom title from the Fxface_Window.id metadata
  • A custom Label added to the dialogArea in createDialogArea()
  • The OK button has focus and is emphasized.

When the contentCreated() method is called all sub controls can be configured. We also have overridden the okClick() button handler. This calls cancelClick() which by default will close the dialog. So clicking on the OK button will close the dialog (see class below).

dialog_one

Requirements;

The view control trigger:

  • Inject the DialogManager injecatble
  • Create a button click handler to create the dialog
  • Call the DialogManager.openDialog() method passing the id of the Fxface_Window.id we created in the DialogTwo class
import org.teotigraphix.potomac.fxface.dialog.DialogManager;
 
import potomac.inject.InjectionEvent;
 
[Inject]
public var _dialogManager:DialogManager;
 
protected function dialogOne_clickHandler(event:MouseEvent):void
{
	_dialogManager.openDialog("dialogOne", onInstanceReady);
}

The Dialog subclass:

The Dialog subclass below features:

  • Fxface_Window Extension metadata (set title)
  • Create a Label in createDialogArea()
  • Configure the OK button
  • Implement the okClick() button handler
/*******************************************************************************
 *  Copyright (c) 2009 Teoti Graphix, LLC.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *     Teoti Graphix, LLC. - initial API and implementation
 *******************************************************************************/
package fxface.dialog.restricted
{
 
import mx.core.UIComponent;
 
import org.teotigraphix.potomac.fxface.dialog.Dialog;
 
import spark.components.Group;
import spark.components.Label;
import spark.layouts.BasicLayout;
 
/**
 * Creates an abstract model of a dialog id'd as "dialogOne".
 */
[Fxface_Window(
	id="dialogOne",
	title="Dialog One Example"
)]
 
/**
 * A very simple Dialog subclass implementation.
 *
 * @author Michael Schmalle
 * @copyright Teoti Graphix, LLC
 * @productversion 1.0
 *
 * @see org.teotigraphix.potomac.fxface.FxfaceExentionPoint#WINDOW
 */
public class DialogOne extends Dialog
{
	//--------------------------------------------------------------------------
	//
	//  Public :: Constants
	//
	//--------------------------------------------------------------------------
 
	/**
	 * @private
	 */
	public static const ID:String = "dialogOne";
 
	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------
 
	/**
	 * Constructor.
	 */
	public function DialogOne()
	{
		super();
	}
 
	/**
	 * @inheritDoc
	 */
	override protected function createDialogArea(parent:UIComponent):UIComponent
	{
		var area:UIComponent = super.createDialogArea(parent);
		// override the superclasses vbox layout
		Group(area).layout = new BasicLayout();
 
		//var border:Border = _componentFactory.createBorderBox(area);
		//border.setStyle("backgroundColor", 0xFFFFFF);
		//border.minHeight = 0;
 
		// add content to the content area here
		var label:Label = _componentFactory.createLabel(area);
		label.text = "Some default content in the dialog";
		label.top = 10;
		label.right = 10;
		label.bottom = 10;
		label.left = 10;
 
		// you could also use this instead of the factory
		// the factory automatically adds the component to the parent
		// addElement(area, text);
 
		return area;
	}
 
	/**
	 * @inheritDoc
	 */
	override protected function contentCreated():void
	{
		// set the OK button as the default dialog button
		okButton.emphasized = true;
		okButton.setFocus();
	}
 
	/**
	 * @inheritDoc
	 */
	override protected function okClick():void
	{
		// let the OK button close the dialog
		cancelClick();
	}
}
}

This is the MOST simple use case of the Window framework. A lot more fun stuff next.

Mike

Categories: fxface Tags: , , ,

ActionBar added to potomac ui bundle

December 20th, 2009 admin 2 comments

Hi,

The ActionBar class allows an abstraction between an mx.controls.NavBar subclass and the Potomac framework code.

This type of design pattern is used heavily in the fxface framework. The more I work with this pattern I am seeing it’s simply a Mediator. The ActionBar class mediates all traffic between the NavBar UIComponent and the calling framework (potomac). In a sense it is working like PureMVC mediators do, except without the notification framework.

What are the benefits?

  • Decoupled code from the actual UIComponent implementation.
  • Dynamic discovery and resolution of action bars.
  • Automatic Action extension execution.
  • Automatic busy cursor management.
  • Deffered instantiation; the control is not created until create() is called.
  • Public disposal via the dispose() method.
  • The control of the action bar is parented by the client.

How is the ActionBar implemented?

The ActionBar declares two new Extensions to the ui framework;

  • UI_ActionBar – place within an mxml/as class and specify a target parent container.
  • UI_ActionBarType – place within an as subclass of ActionBar to declare a new action bar type.

UI_ActionBar

The extension point uses three required attributes in the metadata declaration;

  • id – The string name of the action bar. This is important since all Action extensions with id of myActionbar/myAction will be added to this action bar.
  • actionBarType – The type of ActionBar class to use when the framework is creating the ActionBar class. (remember the class determines what NavBar subclass will be created, ButtonBar, LinkBar etc.)
  • target – The public UIComponent string reference that will act as the action bar’s control parent.

The code below shows a simple ActionBar implementation;

// my/templates/MyTemplate.mxml

<mx:Metadata>
[Template(
    id="my_template",
    properties="logo:image"
)]

// this could be declared in a Template mxml file where 'navigation'
// was a Box with it's id="navigation"
[UI_ActionBar(
	id="navigation",
	actionBarType="default",
	target="navigationBar"
)]
</mx:Metadata>
... 

// my/actions/MyAction.as

package my.actions {
// then define an Action extension within an Action subclass
// this way the Action class get's attached to this Action declaration
[Action(
	id="navigation/myAction",
	label="My Action",
	icon="myicon.png"
)]

...

public class MyAction extends Action
{
    override public function run():void {trace("You clicked MyAction!");}
}
}

The above code is all you need to have a working ActionBar applied to a parent container. The developer needs to do nothing else other than code the logic in the Action.run() method.

UI_ActionBarType

The UI_ActionBarType extension point allows you to extend the default implementation of the ActionBar which is a ButtonBar. The code below shows how simple it is to add another action bar type;

package org.teotigraphix.potomac.ui.templates.action
{

...

[UI_ActionBarType(id="linkbar")]

public class LinkActionBar extends ActionBar
{
   ...

   public static const ID:String = "linkbar";

   ...

   override protected function configure(control:UIComponent):void
   {
      super.configure(control);

      LinkBar(control).direction = "horizontal";
   }

   override protected function createControl():UIComponent
   {
      return new LinkBar();
   }
}
}

The above code will create a LinkBar instead of the default ButtonBar. When you want the link bar you just set the UI_ActionBar’s metadata attribute, actionBarType to “linkbar“.

[UI_ActionBar(
	id="navigation",
	actionBarType="linkbar",
	target="navigationBar"
)]

Hook methods

The ActionBar class allows for three main hook methods;

  • createControl() – required for a new type subclass.
  • configure() – Enables a subclass to further configure the control.
  • fillActions() - Allows a subclass to override the default fill Action behavior which is to put all Action extensions of the specific category into the dataProvider of the NavBar subclass.

The create() method

The create() method is passed and options Object. In the default behavior of fillActions(), the category property must be set, if the property is undefined, “global” will be used and all Action extensions that do not contain a forward slash “/”, will be added to the action bar.

Note: subclasses can easily override this default behavior.

Events

The ActionBar class by default listens to the ItemClickEvent.ITEM_CLICK event and executes the Action based on the current item selected.

Note: subclasses can easily override this default behavior.

Fill implementation

The TemplateBase class calls the ActionExtensionManager’s fillActionBars() method to dynamically discover and parent the action bars found in a [Template].

For other bars in Parts etc, the developer can use this same method.

  • fillActionBars(parent:UIComponent):void

Conclusion

I had fun with this one since it solidified the design pattern the potomac framework uses. This is the beginning of many abstractions like this. If you find this intriguing, wait until you check out the fxface ui framework.

Peace,
Mike

Categories: Potomac Tags: ,

SplashManager added to the ui framework bundle

December 17th, 2009 admin No comments

Hi,

Well, I have added a nice SplashManager to the ui bundle. This injectable manager was originally in the DesktopTemplate I created 2 months ago (I never released it).

This is the PERFECT example of how Potomac bundles will change the face of flex development. The power of injection and extension points are perfectly illustrated with this extension point.

SplashManager

First I created an interface ISplashManager.

createAndShowSplash(
		splash:String,
		duration:int = 0,
		title:String = null,
		icon:DisplayObject = null ):void;

Then, I created an [Injectable] ISplashManager implementation with the SplashManager class. This injectable implements IProvider and ISplashManager, the provider declaring getInstance() and splash giving the class the public splash creation method.

UIPopUpManager

There was another class created as a result of the splash impl. The UIPopUpManager class is another injectable manager the puts popup creation in ONE spot that can EASILY be overridden. It has the methods of;

  • addPopUp()
  • addPopUpCentered()
  • removePopUp()
  • bringToFront()

The splash manager class will use the popup manager to create and show the popup.

The splash manager impl will automatically show and hide the splash based on the duration. The nice thing about this is the Template can declare appManifest.xml params that set these values before runtime.

SplashBase

The default implementation of the splash. This class declares the UI_Splash extension point. Now whenever you want a splash to choose from, all you do is create an mxml component and put;

/**
 * The default splash.
 */
[UI_Splash(id="default")]

in the class metadata! Bam, you set the “splash” app parameter to default and the splash automatically appears with text, icon and duration.

All of this is taken car of through the template implementation. The SplashManager can be extended to.

Mike

Categories: Potomac, Template Tags: , ,

TemplateBase :: abstract

December 17th, 2009 admin No comments

Hi,

What I’m doing is subtly documenting these classes and functionality before I have released code. Same as the fxface classes I talked about a month ago. It’s nice to keep a dialog with your mind as well as design tools. I really think by next week I will have this template part of the ui framework up in google code.

TemplateBase

The TemplateBase class holds all of the UICompositionManager’s required implementation. There are a couple things to note about classes that need to be used as a template.

  • Templates must extend mx.core.Container
  • Templates must declare [Template(id="myTemplate")] in the class metadata.
  • Templates can be either MXML or AS files.
  • Templates should digest the appManifest.xml parameters.
  • Templates should allow themselves to initialize before Page creation.
  • Templates must implement a way to open a Page and show the Page’s control in the user interface.
  • Templates must implement a way to close a Page’s control in the user interface.
  • Templates must implement a way to select a Page’s control in the user interface.
  • Template’s must implement a way to keep track of dirty pages.
  • Templates need to listen to the following events;

Events

  • TemplateEvent.INITIALIZE
  • TemplateEvent.OPEN_PAGE
  • TemplateEvent.SHOW_PAGE
  • TemplateEvent.CLOSE_PAGE
  • TemplateEvent.PAGE_DIRTY

The TemplateBase class takes care of all the above and more. This class is still very abstract in the fact it does not require anything related to user interface controls.

The AdvancedTemplateBase class implements a ViewStack (thus requiring a pageStack:ViewStack mxml/as component  implementation in the concrete template file) for pages. The AdvancedTemplateBase also has the ability to save it’s children’s ui state in an XML IMemento stored on the client using the StorageService’s SharedObject support. The class has the ability to save and restore all Page state.

The AdvancedPageBase and AdvancedFolderBase has the same above functionality. So you see this ui state storage and restoration is recursive all the way down to the Part’s control, if that control implements IPersistable.

[Template_Bootstrap]

The Template_Bootstrap extension point allows classes to startup during the INITIALIZE event. Any class that declares;

[Template_Bootstrap(id="myBootstrap")]
public class MyBootstrap {
    public function initialize():void{}
}

will be created and the initialize() method called. The good thing about this is when the instance of the bootstrap is created, the class is created through the injector. This allows the Bootstrap class to declare injections.

The dataProvider

As you can see in the diagram, the PageItem wraps the Page instance. Consider the PageItem the ultimate descriptor that can be extended when needed. The dataProvider holds these page items. Using the composition framework, all code dealing with page item management has been delegated to the UICompositionManager.

The Container

The container reference holds the root container containing all of the Page controls/containers.

template-design

That’s all for now;

Peace, Mike

The UI composition framework

December 17th, 2009 admin No comments

Hi,

Sometimes in life you don’t see the sunset until the sun rises, get it? You need the sun rise to get the fact the sun set. ;-) This is about 2 months of work which has led me to this post.

I have thought very specifically about the Template, Folder and Page paradigm presented with Potomac and found some patterns between them. With patterns we get interfaces and template methods! With component development at any level this means you are on the right track to creating a powerful, reusable and decoupled framework.

To all those framework haters;  the next time you sit in your house or go to the 34th floor of a building, fly in that airplane… remember what is holding them together. The frameworks that bother me are the reinvent the wheel frameworks, like how many ways can I recreate the MVC pattern. This type of re-evolution (closed circuit of discovery) has been going on as long as there has been a middle man.

Note: In my opinion re-evolution is NOT the same as re-implementation (the later is good).

I’m not a middle man, I’m an innovator and someone that truly wants to make your life easier and make a little money at the same time. This is an architect in it’s purest abstract form.

So we get back to Potomac and it’s ui composition framework. Through my investigation there were a couple things that bothered me.

  • I found myself creating wrappers for descriptors of each type.
  • I found myself copying and pasting initialize methods.
  • I found myself re-implementing the child management (which is the same throughout all three tiers)
  • plus more, but the above 3 are the most important

That is a lot of code if you want to customize things.

What need to happen was the web 3.0 mantra; Composition. Composition is very powerful when it comes to things that truly reflect real life composition, IE Potomac UI Composition.

I found out that I could create 3 base interfaces that Template, Page and Folder bases could implement.

  • ICompositionManagerClient
  • ICompositeItem (this is not implemented by any tier, only CompositeItem)
  • IRootContainerAware

ICompositionManagerClient

ICompositionManagerClient interface adds the to composites the ability to hold a dataProvider, dataDescriptor, selectedItem and lastSelectedItem. Each of these properties can stand alone in the class but, more investigation lead me to the invent of the UICompositionManager.

UICompositionManager

The UICompositionManager makes use of polymorphism relating to the Template, Page and Folder. The manager treats all of them the same, as an ICompositionManagerClient. The manager also creates and manages the ICompositeItems that are found in the dataProvider at each level. The  selectedItem and lastSelectedItem are of type ICompositionItem.

ICompositeItem

The ICompositeItem interface is an abstraction of a child found in the dataProvider of a ICompositionManagerClient. This interface allows equal implementation within the manager. This interface is intended to be the defacto descriptor for a ICompositionManagerClient that is a child of another ICompositionManagerClient. There is one branch that is a leaf, the PartItem that is found as a child of a Folder.

Start to see the composition happening here?

IRootContainerAware

The IRootContainerAware interface allows the composition manager polymorphic access to all 3 tier’s root display list. This allows the composition manager the ability to manage not only the client’s composite model but also it’s display list.

Conclusion

By creating the UICompositionManager, I have saved myself 1000’s of repetitive coding lines. Also built a nice structure and ground work for the many cool things to come.

There are three abstract base classes of the composites;

  • TemplateBase extends Canavs
  • PageBase extends Page
  • FolderBase extends Folder

Up next is the TemplateBase and AdvancedTemplateBase classes in more detail.

Mike

The back-burner is now a bonfire

December 16th, 2009 admin No comments

Hello,

Now that the New Hampshire winter has turned me into a cold, determined winter developer (no grass to mow right now :) ), I’m getting close to getting this Potomac thing glowing.

As of now, the Potomac forum board is dead, well I think I know why, the people over at ElementRiver released their SourceMate Flash Builder plugin. Thus, they seem to be giving Potomac no love (or updates), I’m sure this will change.

Meanwhile in the bat cave TeotiGraphix (me), is wildly creating a couple of huge frameworks for Potomac. The fxface is one, the TwitterGalaxy is really now turning into a Potomac dashboard (I love how things mutate).

The nice thing about me diving into a twitter api is I found a new friend;

Tweetr API

Sandro over at swfjunkie [swizland], is a bad ass developer that codes like I do, precise and full bore.  I discovered his library and grabbed on.

So we also get some PureMVC dancing with Tweetr and Potomac. This will all be open source so we will see where it flows.

What’s the point Mike?

Basically, Chris (the founder of ElementRiver) is a very highly intelligent developer from well… read his bio on their site. He knows what he’s doing and I finally decided to really jump on board here. I have already spent hundreds of hours on this framework, I never give up, so check back once the dust has cleared.

Note

I’m pretty much done with FlexBuilder 3, so all of my examples will use Spark components and Flash Builder 4 projects.

Peace,

Mike

PS, I also have a development wiki that when I’m ready I’ll make public.

Categories: Potomac, fxface Tags: , , ,

Update for those

December 14th, 2009 admin No comments

Hi,

Just a quick update, this blog is not dead… Between the NH winter starting, snow plows, a documentor, potomac projects and flex 4 components, I am developing let’s just say my head almost hit the key board.

There are 3 major things I am creating that will be released in early 2010 dealing with potomac.

Chris just released a really nice Flash Builder plugin for refactoring and code generation. It’s definitely professional grade quality as I have been using the beta version for my dev.

Check out;

SourceMate

I’ll be around,

Mike

Categories: Uncategorized Tags:

PotomacDashboard :: twitter

November 20th, 2009 admin 2 comments

Hi,

For those that read this blog, … silence, I’m am going back to the laboratory and going to prove this framework belongs in the big leagues.

The current project that is open source and a great example will be the PotomacDashboard with default twitter modules.

This will be a FULLY functional example of an application built on top of PureMVC in  separate Library Project (no Potomac metadata or dependencies).

The application will utilize the Twitter API in as3. The actual Potomac application will use a bootstrap that was defined in the PureMVC application to start up the twitter dashboard.

The Potomac application will use adapter classes to add metadata to the already defined views and editors of the PureMVC application.

Look at my twitters, I already have a hello world from inside the dashboard. Today was a good day for me, I definitely proved that Potomac is an outer layer to the application process and if so desired can and an even more robust injection/ uicomposition system to the PureMVC application (or any other framework/application).

I have a ways to go, but naysayers will see that Potomac can be an extension to an already existing application.

The purpose of this expedition is to prove the following;

  • The Potomac framework creates reusable bundles of sharable code.
  • The Potomac framework does NOT IMPOSE any limitations on current application code.
  • The Potomac framework does NOT  bind the developer/company to the Potomac framework, thus making future forks possible since the application doesn’t depend on the Potomac plug-in

potomac_dashboard_system

Mike

Categories: Potomac Tags: ,

The [Template] startup

November 12th, 2009 admin No comments

The [Template] extension point is declared in the PotomacUI class.

Required metadata attributes of 0.8 release;

  • Declared on subclasses of mx.core.Container
  • id
  • properties

The Launcher

The Launcher class is responsible for getting the correct Template and calling the PotomacUI.initializeTemplate() method.

  1. Launcher.launch()
  2. Create the IBundleService
  3. Create the Injector
  4. For each bundle, create a BundleInstallDescriptor
  5. Add a BundleEvent.BUNDLES_INSTALLED listener to the IBundleService
  6. Call IBundleService.install()
  7. … after all bundles have loaded, the IBundleService dispatches the BundleEvent.BUNDLES_INSTALLED event
  8. The Launcher listens for the BundleEvent.BUNDLES_INSTALLED finds the application’s Template, creates an instance of the Template asynchronously
  9. Once the instance of the Template is instantiated, the Launcher then calls PotomacUI.initializeTemplate()

PotomacUI template initialization

During the initializeTemplate() method, a TemplateEvent.INITIALIZE event is sent to the template.

Next, PotomacUI calls openPage() on all pages that either have the open attribute set to true or not defined.

During initialization of the Template, pages have not  been created through the PageFactory, so a TemplateEvent.OPEN_PAGE event is sent to the Template informing it to open the page after the Page instance has been created.

When the page is created in the openPage() method, the following properties are set on the page;

  • id
  • input
  • pageDesc

The following properties are available on the TemplateEvent.OPEN_PAGE when the Template instance receives this event;

  • pageDescriptor
  • pageInput
  • pageOptions
  • page
  • setFocus

What’s happening now?

After this initialization process, the Template is parented by the Application, pages have been setup in the Template (abstractly). The template will now wait for the TemplateEvent.SHOW_PAGE event. When a SHOW_PAGE event is broadcast to the Template, it’s time for the template to create the Page’s folders and parts.

Conclusion

This article shows you the Potomac launch sequence at startup. Startup in a Potomac application “gets things ready”. As far as the next sequence, it’s up to how the folders and parts are presented in the UI.

Mike

Categories: Potomac Tags: , ,