jstrachan 2003/01/31 04:54:02 Modified: jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt tree.jelly tableTree.jelly example.jelly jelly/jelly-tags/swt project.xml jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt WidgetTag.java Added: jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt parentDemo.jelly Log: Patched the demo so it works with the latest refactorings. Also patched the SWT tags so that widgets can be defined to be attached to a given parent, using a parent attribute. Added a simple example to the demo application (parentDemo.jelly) Revision Changes Path 1.2 +3 -3 jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/tree.jelly Index: tree.jelly =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/tree.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- tree.jelly 6 Jan 2003 16:40:35 -0000 1.1 +++ tree.jelly 31 Jan 2003 12:54:02 -0000 1.2 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log"> - <shell text="Tree Demo" var="shell" style="border, close, min, max, resize, title"> + <shell text="Tree Demo" var="subShell" style="border, close, min, max, resize, title"> <gridLayout/> @@ -31,6 +31,6 @@ </tree> </shell> - ${shell.pack()} - ${shell.open()} + ${subShell.pack()} + ${subShell.open()} </j:jelly> 1.2 +2 -2 jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/tableTree.jelly Index: tableTree.jelly =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/tableTree.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- tableTree.jelly 6 Jan 2003 16:40:35 -0000 1.1 +++ tableTree.jelly 31 Jan 2003 12:54:02 -0000 1.2 @@ -1,7 +1,7 @@ <?xml version="1.0"?> <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log"> - <shell text="TableTree Demo" var="shell" style="border, close, min, max, resize, title"> + <shell text="TableTree Demo" var="subShell" style="border, close, min, max, resize, title"> <gridLayout/> @@ -40,5 +40,5 @@ </tableTree> </shell> - ${shell.open()} + ${subShell.open()} </j:jelly> 1.2 +5 -0 jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/example.jelly Index: example.jelly =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/example.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- example.jelly 6 Jan 2003 16:40:35 -0000 1.1 +++ example.jelly 31 Jan 2003 12:54:02 -0000 1.2 @@ -71,6 +71,11 @@ <j:include uri="tableTree.jelly"/> </onEvent> </toolItem> + <toolItem text="Parent Demo" toolTipText="Starts the Parent Demo that shows how to start a component given a parent widget"> + <onEvent type="Selection"> + <j:include uri="parentDemo.jelly"/> + </onEvent> + </toolItem> </toolBar> </shell> 1.1 jakarta-commons-sandbox/jelly/jelly-tags/swt/src/test/org/apache/commons/jelly/tags/swt/parentDemo.jelly Index: parentDemo.jelly =================================================================== <?xml version="1.0"?> <j:jelly xmlns:j="jelly:core" xmlns="jelly:swt" xmlns:log="jelly:log"> <shell text="Parent Demo" var="subShell" style="border, close, min, max, resize, title"> <gridLayout/> </shell> <!-- || This demo shows how we can create a brand new widget which is added to a || given parent control (in this case the shell). || This widget can be defined as a variable using the var="foo" attribute just || like any other widget. --> <tree parent="${subShell}" toolTipText="This is a tree!" style="multi"> <gridData style="fill_both"/> <!-- we'd normally use some Java bean model to implement the next bit --> <treeItem text="A"> <treeItem text="A/A"/> <treeItem text="A/B"/> <treeItem text="A/C"/> </treeItem> <treeItem text="B"> <treeItem text="B/A"/> <treeItem text="B/B"/> <treeItem text="B/C"/> </treeItem> <menu style="pop_up"> <menuItem text="do something!"> <onEvent type="Selection"> <log:info>Clicked on ${event}</log:info> </onEvent> </menuItem> </menu> </tree> ${subShell.pack()} ${subShell.open()} </j:jelly> 1.7 +4 -0 jakarta-commons-sandbox/jelly/jelly-tags/swt/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/project.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- project.xml 27 Jan 2003 05:24:15 -0000 1.6 +++ project.xml 31 Jan 2003 12:54:02 -0000 1.7 @@ -46,6 +46,10 @@ <id>commons-cli</id> <version>SNAPSHOT</version> </dependency> + <dependency> + <id>commons-jelly+tags-log</id> + <version>SNAPSHOT</version> + </dependency> <!-- END for running demos --> </dependencies> 1.4 +26 -5 jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java Index: WidgetTag.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/swt/src/java/org/apache/commons/jelly/tags/swt/WidgetTag.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WidgetTag.java 24 Jan 2003 22:53:33 -0000 1.3 +++ WidgetTag.java 31 Jan 2003 12:54:02 -0000 1.4 @@ -84,7 +84,8 @@ /** The Log to which logging calls will be made. */ private static final Log log = LogFactory.getLog(WidgetTag.class); - + + private Widget parent; public WidgetTag(Class widgetClass) { super(widgetClass); @@ -113,13 +114,33 @@ * @return the parent widget which this widget will be added to. */ public Widget getParentWidget() { - WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); - if (tag != null) { - return tag.getWidget(); + if (parent == null) { + WidgetTag tag = (WidgetTag) findAncestorWithClass(WidgetTag.class); + if (tag != null) { + parent = tag.getWidget(); + } } - return null; + return parent; } + // Tag interface + //------------------------------------------------------------------------- + public void doTag(XMLOutput output) throws JellyTagException { + Map attributes = getAttributes(); + Object parent = attributes.remove("parent"); + if (parent != null) { + if (parent instanceof Widget) { + this.parent = (Widget) parent; + } + else { + throw new JellyTagException( + "The parent attribute is not a Widget, it is of type: " + + parent.getClass().getName() + " value: " + parent + ); + } + } + super.doTag(output); + } // Implementation methods //-------------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]