Author: dsvyatobatsko
Date: 2008-11-11 14:06:29 -0500 (Tue, 11 Nov 2008)
New Revision: 11091
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Album.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/AudioLibrary.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Performer.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Song.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/swing/
trunk/test-applications/seleniumTest/richfaces/src/main/resources/audio-library.xml
trunk/test-applications/seleniumTest/richfaces/src/main/resources/digester-rules.xml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
Log:
tree tests
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-11
18:41:36 UTC (rev 11090)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-11
19:06:29 UTC (rev 11091)
@@ -23,16 +23,21 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.Properties;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.bean.tree.rich.AudioLibrary;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.xmlrules.DigesterLoader;
import org.richfaces.component.UITree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;
+import org.xml.sax.SAXException;
/**
* Copied from demo
@@ -101,6 +106,29 @@
return rootNode;
}
+ private TreeNode<Object> richRootNode = null;
+
+ public TreeNode<Object> getRichTreeNode() {
+ if (null == richRootNode) {
+ URL rulesUrl =
TreeBuilder.class.getResource("/digester-rules.xml");
+ Digester digester = DigesterLoader.createDigester(rulesUrl);
+ AudioLibrary library = new AudioLibrary();
+ digester.push(library);
+ try {
+
digester.parse(TreeBuilder.class.getResourceAsStream("/audio-library.xml"));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ richRootNode = library;
+ }
+
+ return richRootNode;
+ }
+
public String getNodeTitle() {
return nodeTitle;
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Album.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Album.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Album.java 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,126 @@
+package org.ajax4jsf.bean.tree.rich;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.richfaces.model.TreeNode;
+
+public class Album implements TreeNode<Object> {
+
+ /**
+ * serial version ID
+ */
+ private static final long serialVersionUID = 443084062111349934L;
+
+ private long id;
+ private Map<Object, TreeNode<Object>> songs = new
LinkedHashMap<Object, TreeNode<Object>>();
+ private String title;
+ private Integer year;
+ private Performer performer;
+
+ public Album() {
+ setId(System.currentTimeMillis());
+ }
+
+//
+// TreeNode implementation
+//
+
+ public void addChild(Object identifier, TreeNode<Object> child) {
+ songs.put(identifier, child);
+ }
+
+ public TreeNode<Object> getChild(Object id) {
+ return songs.get(id);
+ }
+
+ public Iterator<Entry<Object, TreeNode<Object>>> getChildren() {
+ return songs.entrySet().iterator();
+ }
+
+ public Object getData() {
+ return this;
+ }
+
+ public TreeNode<Object> getParent() {
+ return performer;
+ }
+
+ public boolean isLeaf() {
+ return songs.isEmpty();
+ }
+
+ public void removeChild(Object id) {
+ songs.remove(id);
+ }
+
+ public void setData(Object data) {
+ }
+
+ public void setParent(TreeNode<Object> parent) {
+ performer = (Performer) parent;
+ }
+
+//
+// Album implementation
+//
+
+ /**
+ * Gets value of id field.
+ * @return value of id field
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Set a new value for id field.
+ * @param id a new value for id field
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets value of title field.
+ * @return value of title field
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Set a new value for title field.
+ * @param title a new value for title field
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Gets value of year field.
+ * @return value of year field
+ */
+ public Integer getYear() {
+ return year;
+ }
+
+ /**
+ * Set a new value for year field.
+ * @param year a new value for year field
+ */
+ public void setYear(Integer year) {
+ this.year = year;
+ }
+
+ public void addSong(Song song) {
+ addChild(song.getId(), song);
+ song.setParent(this);
+ }
+
+ public String getType() {
+ return "album";
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Album.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/AudioLibrary.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/AudioLibrary.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/AudioLibrary.java 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,68 @@
+package org.ajax4jsf.bean.tree.rich;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.richfaces.model.TreeNode;
+
+public class AudioLibrary implements TreeNode<Object> {
+
+ /**
+ * serial version ID
+ */
+ private static final long serialVersionUID = -1429183678508376974L;
+
+ private Map<Object, TreeNode<Object>> performers = new
LinkedHashMap<Object, TreeNode<Object>>();
+
+//
+// TreeNode implementation
+//
+ public void addChild(Object identifier, TreeNode<Object> child) {
+ performers.put(identifier, child);
+ }
+
+ public TreeNode<Object> getChild(Object id) {
+ return performers.get(id);
+ }
+
+ public Iterator<Entry<Object, TreeNode<Object>>> getChildren() {
+ return performers.entrySet().iterator();
+ }
+
+ public Object getData() {
+ return this;
+ }
+
+ public TreeNode<Object> getParent() {
+ return null;
+ }
+
+ public boolean isLeaf() {
+ return performers.isEmpty();
+ }
+
+ public void removeChild(Object id) {
+ performers.remove(id);
+ }
+
+ public void setData(Object data) {
+ }
+
+ public void setParent(TreeNode<Object> parent) {
+ }
+
+//
+// AudioLibrary implementation
+//
+
+ public void addPerformer(Performer performer) {
+ addChild(performer.getId(), performer);
+ }
+
+ public String getType() {
+ return "library";
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/AudioLibrary.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Performer.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Performer.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Performer.java 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,124 @@
+package org.ajax4jsf.bean.tree.rich;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.richfaces.model.TreeNode;
+
+public class Performer implements TreeNode<Object> {
+
+ /**
+ * serial version ID
+ */
+ private static final long serialVersionUID = -4258414186970822017L;
+
+ private long id;
+ private Map<Object, TreeNode<Object>> albums = new
LinkedHashMap<Object, TreeNode<Object>>();
+ private String name;
+ private AudioLibrary library;
+
+ public Performer() {
+ setId(System.currentTimeMillis());
+ }
+
+//
+// TreeNode implementation
+//
+ public void addChild(Object identifier, TreeNode<Object> child) {
+ albums.put(identifier, child);
+ }
+
+ public TreeNode<Object> getChild(Object id) {
+ return albums.get(id);
+ }
+
+ public Iterator<Entry<Object, TreeNode<Object>>> getChildren() {
+ return albums.entrySet().iterator();
+ }
+
+ public Object getData() {
+ return this;
+ }
+
+ public TreeNode<Object> getParent() {
+ return library;
+ }
+
+ public boolean isLeaf() {
+ return albums.isEmpty();
+ }
+
+ public void removeChild(Object id) {
+ albums.remove(id);
+ }
+
+ public void setData(Object data) {
+ }
+
+ public void setParent(TreeNode<Object> parent) {
+ library = (AudioLibrary) parent;
+ }
+
+//
+// Band implementation
+//
+
+ /**
+ * Gets value of id field.
+ * @return value of id field
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Set a new value for id field.
+ * @param id a new value for id field
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets value of albums field.
+ * @return value of albums field
+ */
+ public Map<Object, TreeNode<Object>> getAlbums() {
+ return albums;
+ }
+
+ /**
+ * Set a new value for albums field.
+ * @param albums a new value for albums field
+ */
+ public void setAlbums(Map<Object, TreeNode<Object>> albums) {
+ this.albums = albums;
+ }
+
+ /**
+ * Gets value of name field.
+ * @return value of name field
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set a new value for name field.
+ * @param name a new value for name field
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addAlbum(Album album) {
+ addChild(album.getId(), album);
+ album.setParent(this);
+ }
+
+ public String getType() {
+ return "performer";
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Performer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Song.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Song.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Song.java 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,102 @@
+package org.ajax4jsf.bean.tree.rich;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+
+import org.richfaces.model.TreeNode;
+
+public class Song implements TreeNode<Object> {
+
+ /**
+ * serial version ID
+ */
+ private static final long serialVersionUID = 3380513023368040508L;
+
+ private long id;
+ private String title;
+ private Album album;
+
+ public Song() {
+ setId(System.currentTimeMillis());
+ }
+
+//
+// TreeNode implementation
+//
+
+ public void addChild(Object identifier, TreeNode<Object> child) {
+ throw new UnsupportedOperationException("Songs do not have children");
+ }
+
+ public TreeNode<Object> getChild(Object id) {
+ throw new UnsupportedOperationException("Songs do not have children");
+ }
+
+ public Iterator<Entry<Object, TreeNode<Object>>> getChildren() {
+ return new LinkedHashMap<Object,
TreeNode<Object>>().entrySet().iterator();
+ }
+
+ public Object getData() {
+ return this;
+ }
+
+ public TreeNode<Object> getParent() {
+ return album;
+ }
+
+ public boolean isLeaf() {
+ return true;
+ }
+
+ public void removeChild(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setData(Object data) {
+ }
+
+ public void setParent(TreeNode<Object> parent) {
+ album = (Album) parent;
+ }
+
+//
+// Song implementation
+//
+ /**
+ * Gets value of id field.
+ * @return value of id field
+ */
+ public long getId() {
+ return id;
+ }
+
+ /**
+ * Set a new value for id field.
+ * @param id a new value for id field
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets value of title field.
+ * @return value of title field
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Set a new value for title field.
+ * @param title a new value for title field
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getType() {
+ return "song";
+ }
+}
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/rich/Song.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/audio-library.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/resources/audio-library.xml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/resources/audio-library.xml 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<audio-library>
+ <performer>
+ <name>Performer</name>
+ <album>
+ <title>Album</title>
+ <year>2008</year>
+ <song>
+ <title>Song1</title>
+ </song>
+ <song>
+ <title>Song2</title>
+ </song>
+ <song>
+ <title>Song3</title>
+ </song>
+ </album>
+ </performer>
+</audio-library>
\ No newline at end of file
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/audio-library.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/digester-rules.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/resources/digester-rules.xml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/resources/digester-rules.xml 2008-11-11
19:06:29 UTC (rev 11091)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE digester-rules
+ PUBLIC "-//Jakarta Apache //DTD digester-rules XML V1.0//EN"
+ "http://jakarta.apache.org/commons/digester/dtds/digester-rules.dtd">
+<digester-rules>
+ <pattern value="audio-library">
+ <pattern value="performer">
+ <object-create-rule
classname="org.ajax4jsf.bean.tree.rich.Performer"/>
+ <set-properties-rule/>
+ <set-next-rule methodname="addPerformer"/>
+ <pattern value="name">
+ <call-method-rule methodname="setName"
paramcount="0"/>
+ </pattern>
+ <pattern value="album">
+ <object-create-rule classname="org.ajax4jsf.bean.tree.rich.Album"/>
+ <set-properties-rule/>
+ <set-next-rule methodname="addAlbum"/>
+ <pattern value="title">
+ <call-method-rule methodname="setTitle"
paramcount="0"/>
+ </pattern>
+ <pattern value="year">
+ <call-method-rule methodname="setYear" paramcount="1"
paramtypes="java.lang.Integer"/>
+ </pattern>
+ <pattern value="song">
+ <object-create-rule
classname="org.ajax4jsf.bean.tree.rich.Song"/>
+ <set-properties-rule/>
+ <set-next-rule methodname="addSong"/>
+ <pattern value="title">
+ <call-method-rule methodname="setTitle"
paramcount="0"/>
+ </pattern>
+ </pattern>
+ </pattern>
+ </pattern>
+ </pattern>
+</digester-rules>
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/resources/digester-rules.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tree/treeTest.xhtml
===================================================================
(Binary files differ)