Skip to content

Commit 29b692e

Browse files
committed
cafetownsend
1 parent 9929db9 commit 29b692e

File tree

22 files changed

+1476
-0
lines changed

22 files changed

+1476
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
* PureMVC Haxe Demo - Feathers UI CafeTownsend (Ported) - Copyright (c) 2022 Bowler Hat LLC
2+
* PureMVC AS3 Demo - Flex CafeTownsend (Ported) - Copyright (c) 2007-08 Michael Ramirez
3+
* Parts Copyright (c) 2005-07 Adobe Systems, Inc.
4+
* PureMVC - Copyright © 2007-2008 Futurescale, Inc.
5+
* All rights reserved.
6+
7+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11+
* Neither the name of Futurescale, Inc., PureMVC.org, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# PureMVC Haxe Feathers UI Cafe Townsend
2+
3+
This demo of [PureMVC](http://puremvc.org/) and [Feathers UI](https://feathersui.com/) was originally written for [Cairngorm](https://github.com/feathersui/feathersui-cairngorm), another framework for Feathers UI. It illustrates the handling of routine maintenance tasks on the client.
4+
5+
Based on [PureMVC ActionScript 3 Demo: Cafe Townsend (Flex)](https://github.com/PureMVC/puremvc-as3-demo-flex-cafetownsend)
6+
7+
## Live demo
8+
9+
A build of the [_puremvc-haxe-demo-feathersui-cafe-townsend_ sample](https://feathersui.com/samples/haxe-openfl/puremvc/puremvc-haxe-demo-feathersui-cafe-townsend/) is hosted on the Feathers UI website, and it may be viewed in any modern web browser.
10+
11+
## Run locally
12+
13+
This project includes an [_project.xml_](https://lime.software/docs/project-files/xml-format/) file that configures all options for [OpenFL](https://openfl.org/). This file makes it easy to build from the command line, and many IDEs can parse this file to configure a Haxe project to use OpenFL.
14+
15+
### Prerequisites
16+
17+
- [Install Haxe 4.0.0 or newer](https://haxe.org/download/)
18+
- [Install Feathers UI from Haxelib](https://feathersui.com/learn/haxe-openfl/installation/)
19+
20+
### Command Line
21+
22+
Run the [**openfl**](https://www.openfl.org/learn/haxelib/docs/tools/) tool in your terminal:
23+
24+
```sh
25+
haxelib run openfl test html5
26+
```
27+
28+
In addition to `html5`, other supported targets include `windows`, `mac`, `linux`, `android`, and `ios`. See [Lime Command Line Tools: Basic Commands](https://lime.software/docs/command-line-tools/basic-commands/) for complete details about the available commands.
29+
30+
### Editors and IDEs
31+
32+
Check out the following tutorials for creating Feathers UI projects in popular development environments:
33+
34+
- [HaxeDevelop](https://feathersui.com/learn/haxe-openfl/haxedevelop/)
35+
- [Moonshine IDE](https://feathersui.com/learn/haxe-openfl/moonshine-ide/)
36+
- [Visual Studio Code](https://feathersui.com/learn/haxe-openfl/visual-studio-code/)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<employees>
3+
<employee>
4+
<emp_id>1</emp_id>
5+
<firstname>Sue</firstname>
6+
<lastname>Hove</lastname>
7+
<email>shove@cafetownsend.com</email>
8+
<startdate>2006-01-07</startdate>
9+
</employee>
10+
<employee>
11+
<emp_id>2</emp_id>
12+
<firstname>Matt</firstname>
13+
<lastname>Boles</lastname>
14+
<email>mboles@cafetownsend.com</email>
15+
<startdate>2006-02-17</startdate>
16+
</employee>
17+
<employee>
18+
<emp_id>3</emp_id>
19+
<firstname>Mike</firstname>
20+
<lastname>Kollen</lastname>
21+
<email>mkollen@cafetownsend.com</email>
22+
<startdate>2006-03-01</startdate>
23+
</employee>
24+
<employee>
25+
<emp_id>4</emp_id>
26+
<firstname>Jennifer</firstname>
27+
<lastname>Jaegel</lastname>
28+
<email>jjaegel@cafetownsend.com</email>
29+
<startdate>2006-04-01</startdate>
30+
</employee>
31+
</employees>
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project>
3+
<meta title="Cafe Townsend" package="com.feathersui.samples.puremvc.CafeTownsend" version="1.0.0" company="Bowler Hat LLC"/>
4+
<meta title="PureMVC Haxe Feathers UI Cafe Townsend Demo — Feathers UI Samples" if="html5"/>
5+
<app main="CafeTownsend" file="CafeTownsend"/>
6+
7+
<window allow-high-dpi="true"/>
8+
<window fps="60"/>
9+
<window fps="0" if="html5"/>
10+
11+
<source path="src"/>
12+
13+
<haxelib name="openfl"/>
14+
<haxelib name="actuate"/>
15+
<haxelib name="feathersui"/>
16+
<haxelib name="feathersui-rpc-services"/>
17+
<haxelib name="puremvc-standard"/>
18+
19+
<icon path="assets/icons/feathersui-icon.svg"/>
20+
21+
<!-- copy the .xml files, but don't load them as assets -->
22+
<assets path="assets" include="*.xml" embed="false"/>
23+
</project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
PureMVC Haxe Demo - Feathers UI Cafe Townsend
3+
Copyright (c) 2022 Bowler Hat LLC
4+
Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
5+
Parts Copyright (c) 2005-07 Adobe Systems, Inc.
6+
Your reuse is governed by the Creative Commons Attribution 3.0 License
7+
*/
8+
9+
import feathers.controls.Application;
10+
import feathers.controls.navigators.StackItem;
11+
import feathers.controls.navigators.StackNavigator;
12+
import feathers.events.FeathersEvent;
13+
import feathers.motion.transitions.FadeTransitionBuilder;
14+
import org.puremvc.haxe.demos.feathersui.cafetownsend.ApplicationFacade;
15+
import org.puremvc.haxe.demos.feathersui.cafetownsend.view.components.EmployeeDetail;
16+
import org.puremvc.haxe.demos.feathersui.cafetownsend.view.components.EmployeeList;
17+
import org.puremvc.haxe.demos.feathersui.cafetownsend.view.components.EmployeeLogin;
18+
19+
class CafeTownsend extends Application {
20+
// available values for the main navigator
21+
// defined as contants to help uncover errors at compile time instead of run time
22+
public static final SCREEN_ID_EMPLOYEE_LOGIN = "employeeLogin";
23+
public static final SCREEN_ID_EMPLOYEE_LIST = "employeeList";
24+
public static final SCREEN_ID_EMPLOYEE_DETAIL = "employeeDetail";
25+
26+
public function new() {
27+
super();
28+
this.addEventListener(FeathersEvent.CREATION_COMPLETE, event -> facade.startup(this));
29+
}
30+
31+
private var facade = ApplicationFacade.getInstance();
32+
33+
public var navigator:StackNavigator;
34+
public var employeeLogin:EmployeeLogin;
35+
public var employeeList:EmployeeList;
36+
public var employeeDetail:EmployeeDetail;
37+
38+
override private function initialize():Void {
39+
super.initialize();
40+
41+
employeeLogin = new EmployeeLogin();
42+
employeeLogin.initializeNow();
43+
employeeList = new EmployeeList();
44+
employeeList.initializeNow();
45+
employeeDetail = new EmployeeDetail();
46+
employeeDetail.initializeNow();
47+
48+
navigator = new StackNavigator();
49+
navigator.addItem(StackItem.withDisplayObject(SCREEN_ID_EMPLOYEE_LOGIN, employeeLogin));
50+
navigator.addItem(StackItem.withDisplayObject(SCREEN_ID_EMPLOYEE_LIST, employeeList));
51+
navigator.addItem(StackItem.withDisplayObject(SCREEN_ID_EMPLOYEE_DETAIL, employeeDetail));
52+
navigator.pushTransition = null;
53+
navigator.popTransition = null;
54+
navigator.replaceTransition = new FadeTransitionBuilder().build();
55+
addChild(navigator);
56+
}
57+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
PureMVC Haxe Demo - Feathers UI Cafe Townsend
3+
Copyright (c) 2022 Bowler Hat LLC
4+
Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
5+
Parts Copyright (c) 2005-07 Adobe Systems, Inc.
6+
Your reuse is governed by the Creative Commons Attribution 3.0 License
7+
*/
8+
9+
package org.puremvc.haxe.demos.feathersui.cafetownsend;
10+
11+
import org.puremvc.haxe.demos.feathersui.cafetownsend.controller.ApplicationStartupCommand;
12+
import org.puremvc.haxe.patterns.facade.Facade;
13+
14+
/**
15+
A concrete `Facade` for the `CafeTownsend` application.
16+
17+
The main job of the `ApplicationFacade` is to act as a single
18+
place for mediators, proxies and commands to access and communicate
19+
with each other without having to interact with the Model, View, and
20+
Controller classes directly. All this capability it inherits from
21+
the PureMVC Facade class.
22+
23+
This concrete Facade subclass is also a central place to define
24+
notification constants which will be shared among commands, proxies and
25+
mediators, as well as initializing the controller with Command to
26+
Notification mappings.
27+
**/
28+
class ApplicationFacade extends Facade {
29+
// Notification name constants
30+
public static final STARTUP = "startup";
31+
public static final SHUTDOWN = "shutdown";
32+
public static final APP_LOGOUT = "appLogout";
33+
public static final APP_LOGIN = "appLogin";
34+
public static final LOAD_EMPLOYEES_SUCCESS = "loadEmployeesSuccess";
35+
public static final LOAD_EMPLOYEES_FAILED = "loadEmployeesFailed";
36+
public static final VIEW_EMPLOYEE_LOGIN = "viewEmployeeLogin";
37+
public static final VIEW_EMPLOYEE_LIST = "viewEmployeeList";
38+
public static final VIEW_EMPLOYEE_DETAIL = "viewEmployeeDetail";
39+
public static final ADD_EMPLOYEE = "addEmployee";
40+
public static final UPDATE_EMPLOYEE = "updateEmployee";
41+
public static final SAVE_EMPLOYEE = "saveEmployee";
42+
public static final DELETE_EMPLOYEE = "deleteEmployee";
43+
44+
public function new() {
45+
super();
46+
}
47+
48+
/**
49+
Singleton ApplicationFacade Factory Method
50+
**/
51+
public static function getInstance():ApplicationFacade {
52+
if (Facade.instance == null) {
53+
Facade.instance = new ApplicationFacade();
54+
}
55+
return cast(Facade.instance, ApplicationFacade);
56+
}
57+
58+
/**
59+
Register Commands with the Controller
60+
**/
61+
override private function initializeController():Void {
62+
super.initializeController();
63+
registerCommand(STARTUP, ApplicationStartupCommand);
64+
}
65+
66+
/**
67+
Start the application
68+
**/
69+
public function startup(app:CafeTownsend):Void {
70+
sendNotification(STARTUP, app);
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
PureMVC Haxe Demo - Feathers UI Cafe Townsend
3+
Copyright (c) 2022 Bowler Hat LLC
4+
Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
5+
Parts Copyright (c) 2005-07 Adobe Systems, Inc.
6+
Your reuse is governed by the Creative Commons Attribution 3.0 License
7+
*/
8+
9+
package org.puremvc.haxe.demos.feathersui.cafetownsend.controller;
10+
11+
import org.puremvc.haxe.patterns.command.MacroCommand;
12+
13+
/**
14+
A MacroCommand executed when the application starts.
15+
16+
@see org.puremvc.demos.feathersui.appskeleton.controller.ModelPrepCommand
17+
@see org.puremvc.demos.feathersui.appskeleton.controller.ViewPrepCommand
18+
*/
19+
class ApplicationStartupCommand extends MacroCommand {
20+
/**
21+
Initialize the MacroCommand by adding its SubCommands.
22+
23+
Since we built the UI using an MXML `Application` tag, those
24+
components are created first. The top level `Application`
25+
then initialized the `ApplicationFacade`, which in turn initialized
26+
the `Controller`, registering Commands. Then the
27+
`Application` sent the `APP_STARTUP`
28+
Notification, leading to this `MacroCommand`'s execution.
29+
30+
It is important for us to create and register Proxys with the Model
31+
prior to creating and registering Mediators with the View, since
32+
availability of Model data is often essential to the proper
33+
initialization of the View.
34+
35+
So, `ApplicationStartupCommand` first executes
36+
`ModelPrepCommand` followed by `ViewPrepCommand`
37+
**/
38+
override private function initializeMacroCommand():Void {
39+
addSubCommand(ModelPrepCommand);
40+
addSubCommand(ViewPrepCommand);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
PureMVC Haxe Demo - Feathers UI Cafe Townsend
3+
Copyright (c) 2022 Bowler Hat LLC
4+
Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
5+
Parts Copyright (c) 2005-07 Adobe Systems, Inc.
6+
Your reuse is governed by the Creative Commons Attribution 3.0 License
7+
*/
8+
9+
package org.puremvc.haxe.demos.feathersui.cafetownsend.controller;
10+
11+
import org.puremvc.haxe.demos.feathersui.cafetownsend.model.EmployeeProxy;
12+
import org.puremvc.haxe.demos.feathersui.cafetownsend.model.UserProxy;
13+
import org.puremvc.haxe.interfaces.INotification;
14+
import org.puremvc.haxe.patterns.command.SimpleCommand;
15+
16+
/**
17+
Create and register `Proxy`s with the `Model`.
18+
**/
19+
class ModelPrepCommand extends SimpleCommand {
20+
override public function execute(note:INotification):Void {
21+
facade.registerProxy(new EmployeeProxy());
22+
facade.registerProxy(new UserProxy());
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
PureMVC Haxe Demo - Feathers UI Cafe Townsend
3+
Copyright (c) 2022 Bowler Hat LLC
4+
Copyright (c) 2007-08 Michael Ramirez <michael.ramirez@puremvc.org>
5+
Parts Copyright (c) 2005-07 Adobe Systems, Inc.
6+
Your reuse is governed by the Creative Commons Attribution 3.0 License
7+
*/
8+
9+
package org.puremvc.haxe.demos.feathersui.cafetownsend.controller;
10+
11+
import org.puremvc.haxe.demos.feathersui.cafetownsend.model.EmployeeProxy;
12+
import org.puremvc.haxe.demos.feathersui.cafetownsend.view.ApplicationMediator;
13+
import org.puremvc.haxe.interfaces.INotification;
14+
import org.puremvc.haxe.patterns.command.SimpleCommand;
15+
16+
/**
17+
Prepare the View for use.
18+
19+
The `Notification` was sent by the `Application`,
20+
and a reference to that view component was passed on the note body.
21+
The `ApplicationMediator` will be created and registered using this
22+
reference. The `ApplicationMediator` will then register
23+
all the `Mediator`s for the components it created.
24+
**/
25+
class ViewPrepCommand extends SimpleCommand {
26+
override public function execute(note:INotification):Void {
27+
// Register the ApplicationMediator
28+
facade.registerMediator(new ApplicationMediator(cast(note.getBody(), CafeTownsend)));
29+
30+
// Get the EmployeeProxy
31+
var employeeProxy = cast(facade.retrieveProxy(EmployeeProxy.NAME), EmployeeProxy);
32+
employeeProxy.loadEmployees();
33+
34+
sendNotification(ApplicationFacade.VIEW_EMPLOYEE_LOGIN);
35+
}
36+
}

0 commit comments

Comments
 (0)