Permalink
Browse files

added cafe townsend example

  • Loading branch information...
1 parent ca2e9ca commit faa36a7879732675b5b20288267718f3151e3c3e @seanhess committed Oct 20, 2009
View
@@ -4,7 +4,9 @@
I've created the classic, Cafe Townsend, using Zero. Please note that although I use an MVC paradigm in this example, it is not a part of Zero itself, but merely a good design. Zero is the toolkit, MVC is the pattern.
-LINK!
+**Note:** This is shamelessly ripped off of Mate's implementation. I'm linking to mate's running application since this framework hasn't yet been fully implemented. Nahuel is the one who asked for this, anyway, so... tell me if I'm out of line, man.
+* [Try It](http://mate.asfusion.com/assets/content/examples/cafeTownsend/)
+* [View Source](http://github.com/seanhess/zero/tree/master/examples/CafeTownsend)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<employees>
+
+ <employee>
+ <emp_id>1</emp_id>
+ <firstname>Sue</firstname>
+ <lastname>Hove</lastname>
+ <email>shove@cafetownsend.com</email>
+ <startdate>01/07/2006</startdate>
+ </employee>
+
+ <employee>
+ <emp_id>2</emp_id>
+ <firstname>Matt</firstname>
+ <lastname>Boles</lastname>
+ <email>mboles@cafetownsend.com</email>
+ <startdate>02/17/2006</startdate>
+ </employee>
+
+ <employee>
+ <emp_id>3</emp_id>
+ <firstname>Mike</firstname>
+ <lastname>Kollen</lastname>
+ <email>mkollen@cafetownsend.com</email>
+ <startdate>03/01/2006</startdate>
+ </employee>
+
+ <employee>
+ <emp_id>4</emp_id>
+ <firstname>Jennifer</firstname>
+ <lastname>Jaegel</lastname>
+ <email>jjaegel@cafetownsend.com</email>
+ <startdate>04/01/2006</startdate>
+ </employee>
+
+ </employees>
+
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,65 @@
+/* CSS file */
+Application {
+ backgroundColor: #000000;
+ themeColor: #4E0E02;
+}
+
+Alert {
+ backgroundColor: #FFFFFF;
+ color: #000000;
+}
+
+
+Panel {
+ borderColor: #7A2828;
+ borderThicknessLeft: 1;
+ borderThicknessRight: 1;
+ borderThicknessBottom: 1;
+ borderAlpha: 1;
+
+ paddingTop: 10;
+ paddingLeft: 10;
+ paddingRight: 10;
+ paddingBottom: 10;
+
+ highlightAlphas: 0.67, 0;
+ headerColors: #000000, #993333;
+
+ titleStyleName: "myPanelStyle";
+}
+
+MainUI {
+ horizontalAlign : center;
+}
+
+.mainBody {
+ backgroundColor: #FFFFFF;
+ paddingTop: 20;
+ horizontalAlign : center;
+}
+
+
+Login {
+ horizontalAlign: center;
+}
+
+
+Form, Label, TextInput {
+ color: #000000;
+ font-weight: normal;
+}
+
+FormItem, List {
+ font-weight: bold;
+ text-align: left;
+}
+
+.myPanelStyle {
+ color: #FFFFFF;
+}
+
+.panelText {
+ color: #000000;
+ font-weight: none;
+ text-align: left;
+}
@@ -0,0 +1,68 @@
+package com.cafetownsend.control
+{
+ import com.cafetownsend.dep.DAuth;
+ import com.cafetownsend.dep.DEmployee;
+ import com.cafetownsend.dep.DPage;
+
+ import mx.collections.ArrayCollection;
+ import mx.collections.IList;
+
+ /**
+ * Putting everything in one to make it simple for this example.
+ * This is a bad idea, but you CAN do it. Consider this a really
+ * simple mock controller. I could easily change it or override it
+ * with something more complete.
+ */
+ [Bindable]
+ public class MockEverything
+ {
+ ///// AUTH IMPLEMENATION /////
+
+ public var authStatus:String = DAuth.NORMAL_STATE;
+
+ public function login(username:String, password:String):void
+ {
+ currentPage = DPage.LIST; // automatically pass
+ }
+
+
+
+
+
+ ///// EMPLOYEES IMPLEMENATION /////////
+ public var allEmployees:IList = new ArrayCollection();
+ public var current:DEmployee;
+
+ public function goToNewEmployee():void
+ {
+ current = new DEmployee(this);
+ currentPage = DPage.DETAIL;
+ }
+
+ public function goToUpdateEmployee(emp:DEmployee):void
+ {
+ current = emp;
+ currentPage = DPage.DETAIL;
+ }
+
+ public function cancelUpdate():void
+ {
+ currentPage = DPage.LIST;
+ }
+
+ public function remove(emp:DEmployee):void
+ {
+
+ }
+
+ public function save(emp:DEmployee):void
+ {
+
+ }
+
+
+ ///// PAGE IMPLEMENATION //////
+
+ public var currentPage:String = DPage.LOGIN;
+ }
+}
@@ -0,0 +1,17 @@
+package com.cafetownsend.dep
+{
+ [Event(name="clear", type="flash.events.Event")]
+ public class DAuth extends DependencyInterface
+ {
+ public static const MESSAGE_STATE:String = "message";
+ public static const NORMAL_STATE:String = "";
+
+ public function get status():String { return i.state }
+
+ public function login(username:String, password:String):void { i.login(arguments) }
+
+ public function logout():void { i.logout() }
+
+ public function DLogin(context:*) { super(context) }
+ }
+}
@@ -0,0 +1,26 @@
+package com.cafetownsend.dep
+{
+ public class DEmployee extends DependencyInterface
+ {
+ public function get firstname():String { return i.firstname }
+ public function set firstname(value:String):void { i.firstname = value }
+
+ public function get lastname():String { return i.lastname }
+ public function set lastname(value:String):void { i.lastname = value }
+
+ public function get email():String { return i.email }
+ public function set email(value:String):void { i.email = value }
+
+ public function get startdate():Date { return i.startdate }
+ public function set startdate(value:Date):void { i.startdate = value }
+
+ /**
+ * How I want names to display in the list. Normally I would use
+ * a formatter instead, but let's pretend we REALLY want this on
+ * our model so I can demonstrate proxies.
+ */
+ public function get properName():String { return i.properName }
+
+ public function DEmployee(context:*) { super(context) }
+ }
+}
@@ -0,0 +1,20 @@
+package com.cafetownsend.dep
+{
+ public class DEmployees extends DependencyInterface
+ {
+ [Bindable]
+ public function get allEmployees():IList { return i.allEmployees }
+
+ [Bindable]
+ public function get current():DEmployee { return i.current }
+
+ public function goToNewEmployee():void { i.goToNewEmployee() }
+ public function goToUpdateEmployee(emp:DEmployee):void { i.goToUpdateEmployee(arguments) }
+ public function cancelUpdate():void { i.cancelUpdate() }
+
+ public function remove(emp:DEmployee):void { i.remove(arguments) }
+ public function save(emp:DEmployee):void { i.save(arguments) }
+
+ public function DEmployees(context:*) { super(context) }
+ }
+}
@@ -0,0 +1,15 @@
+package com.cafetownsend.dep
+{
+ public class DPage extends DependencyInterface
+ {
+ public static const LOGIN:String = "login";
+ public static const LIST:String = "list";
+ public static const DETAIL:String = "detail";
+
+ [Bindable]
+ public function get currentPage():String { return i.currentPage };
+
+
+ public function DPage(context:*) { super(context) }
+ }
+}
@@ -0,0 +1,24 @@
+package net.seanhess.zero.dependency
+{
+ import flash.utils.Proxy;
+ import flash.utils.flash_proxy;
+
+ /**
+ * Anything not implemented will hit this. Do Nothing
+ */
+ public class IgnoreIfMissing extends Proxy
+ {
+ override flash_proxy function setProperty(name:*, value:*):void
+ {
+ }
+
+ override flash_proxy function getProperty(name:*):*
+ {
+ return null;
+ }
+
+ override flash_proxy function callProperty(name:*, ... args):* {
+ return null;
+ }
+ }
+}
@@ -0,0 +1,37 @@
+package net.seanhess.zero.dependency
+{
+ import flash.utils.flash_proxy;
+
+ import mx.logging.ILogger;
+ import mx.logging.Log;
+
+ /**
+ * Anything not implemented will hit this
+ */
+ public class LogEverything extends ObjectProxy
+ {
+ private var log:ILogger;
+
+ public function LogEverything()
+ {
+ log = Log.getLogger("test"); // you can attach it somewhere else.
+ }
+
+ override flash_proxy function setProperty(name:*, value:*):void
+ {
+ log.debug("set property " + name + " :: " + value);
+ super.setProperty(name, value);
+ }
+
+ override flash_proxy function getProperty(name:*):*
+ {
+ log.debug("get property " + name);
+ return super.setProperty(name, value);
+ }
+
+ override flash_proxy function callProperty(name:*, ... args):* {
+ log.debug("call property " + name);
+ return super.callProperty.apply(this, [name].concat(args)); // there's no easy way to call super
+ }
+ }
+}
@@ -0,0 +1,27 @@
+package net.seanhess.zero.dependency
+{
+ import flash.utils.Proxy;
+ import flash.utils.flash_proxy;
+
+ /**
+ * Anything not implemented will hit this. Just throw an error.
+ */
+ public class ThrowErrorIfMissing extends Proxy
+ {
+ override flash_proxy function setProperty(name:*, value:*):void
+ {
+ throw new Error("set property " + name + " to " + value);
+ }
+
+ override flash_proxy function getProperty(name:*):*
+ {
+ throw new Error("get property "+ name);
+ return null;
+ }
+
+ override flash_proxy function callProperty(name:*, ... args):* {
+ throw new Error("call property "+ name " with " + args.length + " arguments");
+ return null;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit faa36a7

Please sign in to comment.