[seam-commits] Seam SVN: r11137 - in sandbox/trunk/modules: xwidgets and 10 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Fri Jun 12 05:00:42 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-06-12 05:00:42 -0400 (Fri, 12 Jun 2009)
New Revision: 11137
Added:
sandbox/trunk/modules/xwidgets/
sandbox/trunk/modules/xwidgets/examples/
sandbox/trunk/modules/xwidgets/examples/helloworld/
sandbox/trunk/modules/xwidgets/examples/helloworld/index.html
sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw
sandbox/trunk/modules/xwidgets/src/
sandbox/trunk/modules/xwidgets/src/main/
sandbox/trunk/modules/xwidgets/src/main/java/
sandbox/trunk/modules/xwidgets/src/main/java/org/
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/View.java
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Button.java
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Image.java
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/InputText.java
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Label.java
sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Panel.java
sandbox/trunk/modules/xwidgets/src/main/javascript/
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Label.js
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
Log:
new sandbox project
Added: sandbox/trunk/modules/xwidgets/examples/helloworld/index.html
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/index.html (rev 0)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/index.html 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,15 @@
+<html>
+ <body>
+ <h1>Hello World Example</h1>
+
+ <div id="container"></div>
+
+ <script src="../../src/main/javascript/xw.js"></script>
+ <script src="../../src/main/javascript/xw.Panel.js"></script>
+ <script src="../../src/main/javascript/xw.Label.js"></script>
+
+ <script type="text/javascript">
+ xw.openView("test.xw", "container");
+ </script>
+ </body>
+</html>
Added: sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw
===================================================================
--- sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw (rev 0)
+++ sandbox/trunk/modules/xwidgets/examples/helloworld/test.xw 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<view xmlns="http://jboss.com/products/xwidgets">
+ <panel>
+ <label value="Hello World!"/>
+
+
+ </panel>
+</view>
\ No newline at end of file
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/View.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/View.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/View.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,6 @@
+package org.jboss.xwidgets;
+
+public class View
+{
+
+}
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Button.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Button.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Button.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,6 @@
+package org.jboss.xwidgets.controls;
+
+public class Button
+{
+
+}
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Image.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Image.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Image.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,6 @@
+package org.jboss.xwidgets.controls;
+
+public class Image
+{
+
+}
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/InputText.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/InputText.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/InputText.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,6 @@
+package org.jboss.xwidgets.controls;
+
+public class InputText
+{
+
+}
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Label.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Label.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Label.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,20 @@
+package org.jboss.xwidgets.controls;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+public class Label
+{
+ private String value;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+}
Added: sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Panel.java
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Panel.java (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/java/org/jboss/xwidgets/controls/Panel.java 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,10 @@
+package org.jboss.xwidgets.controls;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+public class Panel
+{
+
+}
Added: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Label.js
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Label.js (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Label.js 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,23 @@
+Package("xw.controls");
+
+xw.controls.Label = function()
+{
+ this.value = "";
+ this.parent = null;
+ this.control = null;
+
+ xw.controls.Label.prototype.setParent = function(parent)
+ {
+ this.parent = parent;
+ }
+
+ xw.controls.Label.prototype.paint = function()
+ {
+ if (this.control == null)
+ {
+ this.control = document.createTextNode(this.value);
+ this.control.widget = this;
+ this.parent.control.appendChild(this.control);
+ }
+ }
+}
Added: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.Panel.js 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,29 @@
+Package("xw.controls");
+
+xw.controls.Panel = function()
+{
+ this.width = 200;
+ this.height = 100;
+ this.parent = null;
+ this.control = null;
+
+ xw.controls.Panel.prototype.setParent = function(parent)
+ {
+ this.parent = parent;
+ }
+
+ xw.controls.Panel.prototype.paint = function()
+ {
+ if (this.control == null)
+ {
+ this.control = document.createElement("div");
+ this.control.widget = this;
+ this.parent.control.appendChild(this.control);
+
+ this.control.style.width = "100%";
+ this.control.style.height = "100%";
+
+ this.control.style.border = "1px solid black";
+ }
+ }
+}
Added: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
===================================================================
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js (rev 0)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js 2009-06-12 09:00:42 UTC (rev 11137)
@@ -0,0 +1,170 @@
+function Package(fullName)
+{
+ var pkg = window;
+ var parts = fullName.split(".");
+ for (var i = 0; i < parts.length; i++)
+ {
+ if (typeof pkg[parts[i]] == "undefined")
+ pkg[parts[i]] = {};
+ pkg = pkg[parts[i]];
+ }
+}
+
+Package("xw");
+
+/**
+ * System Utils
+ */
+xw.Sys = {};
+xw.Sys.getObject = function(id)
+{
+ if (document.getElementById && document.getElementById(id))
+ return document.getElementById(id);
+ else if (document.all && document.all(id))
+ return document.all(id);
+ else if (document.layers && document.layers[id])
+ return document.layers[id];
+ else
+ return false;
+}
+
+/**
+ * View Loader - loads view definitions from a URL
+ */
+xw.ViewLoader = {};
+xw.ViewLoader.load = function(viewName, callback)
+{
+ if (window.XMLHttpRequest)
+ {
+ asyncReq = new XMLHttpRequest();
+ if (asyncReq.overrideMimeType)
+ asyncReq.overrideMimeType("text/xml");
+ }
+ else
+ {
+ asyncReq = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+
+ asyncReq.onreadystatechange = function() { callback(asyncReq) };
+ asyncReq.open("GET", viewName, true);
+ asyncReq.send(null);
+ return asyncReq;
+}
+
+/**
+ * View manager - responsible for caching views
+ */
+xw.ViewManager = {};
+xw.ViewManager.views = {};
+xw.ViewManager.loadViewCallback = function(req, container)
+{
+ if (req.readyState == 4)
+ {
+ if (req.status == 200 || req.status == 0)
+ {
+ xw.renderView(req.responseXML.documentElement, container);
+ }
+ else
+ {
+ alert("There was an error processing your request. Error code: " + req.status);
+ }
+ }
+}
+
+xw.ViewManager.openView = function(viewName, container)
+{
+ var callback = function(req) {
+ xw.ViewManager.loadViewCallback(req, container);
+ };
+ xw.ViewLoader.load(viewName, callback);
+}
+
+/**
+ * Base class for controls
+ */
+xw.Control = function()
+{
+ this.parent = null;
+ xw.Control.prototype.setParent = function(parent)
+ {
+ this.parent = parent;
+ }
+}
+
+/**
+ * A single instance of a view
+ */
+xw.View = function(viewRoot, container)
+{
+ this.viewRoot = viewRoot;
+ this.container = container;
+ this.control = xw.Sys.getObject(container);
+
+ xw.View.prototype.render = function()
+ {
+ this.element =
+ this.renderChildren(this.viewRoot.childNodes, this);
+ }
+
+ xw.View.prototype.renderChildren = function(children, parentControl)
+ {
+ for (var i = 0; i < children.length; i++)
+ {
+ if (children.item(i) instanceof Element)
+ {
+ this.renderControl(children.item(i), parentControl);
+ }
+ }
+ }
+
+ xw.View.prototype.renderControl = function(element, parent)
+ {
+ var tag = element.tagName;
+ var controlName = tag.substring(0,1).toUpperCase() +
+ tag.substring(1, tag.length);
+
+ var control = eval("new xw.controls." + controlName + "()");
+
+ control.setParent(parent);
+
+ if (element.hasAttributes())
+ {
+ // Set control properties
+ for (var i = 0; i < element.attributes.length; i++)
+ {
+ var name = element.attributes[i].name;
+ var value = element.getAttribute(name);
+ control[name] = value;
+ }
+ }
+
+ control.paint();
+
+ var children = element.childNodes;
+ if (children.length > 0)
+ {
+ this.renderChildren(children, control);
+ }
+ }
+}
+
+/**
+ * General methods
+ */
+xw.openView = function(viewName, container)
+{
+ xw.ViewManager.openView(viewName, container);
+}
+
+xw.renderView = function(viewRoot, container)
+{
+ if (viewRoot.tagName == "view")
+ {
+ var view = new xw.View(viewRoot, container);
+ view.render();
+ }
+ else
+ {
+ alert("Invalid view definition - document root is not 'view' element");
+ }
+}
\ No newline at end of file
More information about the seam-commits
mailing list