From richfaces-svn-commits at lists.jboss.org Wed Nov 3 10:24:40 2010 Content-Type: multipart/mixed; boundary="===============4576239482275616775==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r19911 - in modules/tests/metamer/trunk/application/src/main: java/org/richfaces/tests/metamer/model and 2 other directories. Date: Wed, 03 Nov 2010 10:24:40 -0400 Message-ID: <201011031424.oA3EOeav028424@svn01.web.mwc.hst.phx2.redhat.com> --===============4576239482275616775== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: lfryc(a)redhat.com Date: 2010-11-03 10:24:39 -0400 (Wed, 03 Nov 2010) New Revision: 19911 Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/CompactDisc.java modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/CompactDiscXmlDescriptor.java modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/Company.java modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/Country.java modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/model/tree/NamedNode.java modules/tests/metamer/trunk/application/src/main/resources/org/richfaces= /tests/metamer/model/compact-discs.xml Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/test= s/metamer/bean/Model.java Log: added model for CompactDisc (suitable for tree structure testing) - refacto= red Model class to be more generic Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfac= es/tests/metamer/bean/Model.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/bean/Model.java 2010-11-03 13:42:19 UTC (rev 19910) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/bean/Model.java 2010-11-03 14:24:39 UTC (rev 19911) @@ -22,14 +22,11 @@ = package org.richfaces.tests.metamer.bean; = -import org.richfaces.tests.metamer.model.*; - import java.net.URL; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.annotation.PostConstruct; = import javax.faces.FacesException; import javax.faces.bean.ApplicationScoped; @@ -39,13 +36,17 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; = +import org.richfaces.tests.metamer.model.Capital; +import org.richfaces.tests.metamer.model.Employee; +import org.richfaces.tests.metamer.model.tree.CompactDiscXmlDescriptor; + /** * Application scoped managed bean holding models usable e.g. in iteration= components. - * - * @author Exadel, Pavol Pitonak<= /a> + * = + * @author Exadel + * @author Pavol Pitonak + * @author Lukas Fryc * @version $Revision$ */ @ManagedBean @@ -56,58 +57,57 @@ private List employeesList; private Set jobTitles; private List jobTitlesSelectItems; - private Logger logger; + private List compactDiscList; = - @PostConstruct - public void init() { - logger =3D LoggerFactory.getLogger(getClass()); - } - - @XmlRootElement(name =3D "capitals") - private static final class CapitalsHolder { - - private List capitals; - - @XmlElement(name =3D "capital") - public List getCapitals() { - return capitals; + /** + * Model containing US states, their capitals and timezones. + * = + * @return list of US states and their capitals + */ + public synchronized List getCapitals() { + if (capitalsList =3D=3D null) { + try { + capitalsList =3D unmarshallCapitals(); + } catch (JAXBException e) { + throw new FacesException(e.getMessage(), e); + } } = - public void setCapitals(List capitals) { - this.capitals =3D capitals; - } + return capitalsList; } = - @XmlRootElement(name =3D "employees") - private static final class EmployeesHolder { - - private List employees; - - @XmlElement(name =3D "employee") - public List getEmployees() { - return employees; + /** + * Model containing employees. Can be used to test various components = inside iteration components. + * = + * @return list of employees + */ + public synchronized List getEmployees() { + if (employeesList =3D=3D null) { + try { + employeesList =3D unmarshallEmployees(); + } catch (JAXBException e) { + throw new FacesException(e.getMessage(), e); + } } = - public void setEmployees(List employees) { - this.employees =3D employees; - } + return employeesList; } = /** - * Model containing US states, their capitals and timezones. + * Model containing compact discs. Suitable to be used in Tree-structu= red components. * = - * @return list of US states and their capitals + * @return list of compact discs */ - public synchronized List getCapitals() { - if (capitalsList =3D=3D null) { + public synchronized List getCompactDiscs() { + if (compactDiscList =3D=3D null) { try { - capitalsList =3D unmarshallCapitals(); + compactDiscList =3D unmarshallCompactDiscs(); } catch (JAXBException e) { throw new FacesException(e.getMessage(), e); } } = - return capitalsList; + return compactDiscList; } = /** @@ -117,41 +117,83 @@ * @throws JAXBException * if any unexpected errors occurs during unmarshalling */ - @SuppressWarnings("restriction") public static final List unmarshallCapitals() throws JAXBExce= ption { + return unmarshall(CapitalsHolder.class, "org/richfaces/tests/metam= er/model/capitals.xml"); + } + + public static final List unmarshallEmployees() throws JAXBEx= ception { + return unmarshall(EmployeesHolder.class, "org/richfaces/tests/meta= mer/model/employees.xml"); + } + + public static final List unmarshallCompactDi= scs() throws JAXBException { + return unmarshall(CompactDiscsHolder.class, "org/richfaces/tests/m= etamer/model/compact-discs.xml"); + } + + @SuppressWarnings("unchecked") + static final > List unmarshall(Class = rootElementType, String resourceURL) + throws JAXBException { ClassLoader ccl =3D Thread.currentThread().getContextClassLoader(); - URL resource =3D ccl.getResource("org/richfaces/tests/metamer/mode= l/capitals.xml"); - JAXBContext context =3D JAXBContext.newInstance(CapitalsHolder.cla= ss); - CapitalsHolder capitalsHolder =3D (CapitalsHolder) context.createU= nmarshaller().unmarshal(resource); - return capitalsHolder.getCapitals(); + URL resource =3D ccl.getResource(resourceURL); + JAXBContext context =3D JAXBContext.newInstance(rootElementType); + T holder =3D (T) context.createUnmarshaller().unmarshal(resource); + return holder.getList(); } = - /** - * Model containing employees. Can be used to test various components = inside iteration components. - * = - * @return list of employees - */ - public synchronized List getEmployees() { - if (employeesList =3D=3D null) { - ClassLoader ccl =3D Thread.currentThread().getContextClassLoad= er(); - URL resource =3D ccl.getResource("org/richfaces/tests/metamer/= model/employees.xml"); + private static interface ListHolder { = - JAXBContext context; - try { - context =3D JAXBContext.newInstance(EmployeesHolder.class); - EmployeesHolder employeesHolder =3D (EmployeesHolder) cont= ext.createUnmarshaller().unmarshal(resource); - employeesList =3D employeesHolder.getEmployees(); - } catch (JAXBException e) { - throw new FacesException(e.getMessage(), e); - } + public List getList(); + + public void setList(List list); + } + + @XmlRootElement(name =3D "capitals") + private static final class CapitalsHolder implements ListHolder { + + private List list; + + @XmlElement(name =3D "capital") + public List getList() { + return list; } = - return employeesList; + public void setList(List list) { + this.list =3D list; + } } = + @XmlRootElement(name =3D "employees") + private static final class EmployeesHolder implements ListHolder { + + private List list; + + @XmlElement(name =3D "employee") + public List getList() { + return list; + } + + public void setList(List list) { + this.list =3D list; + } + } + + @XmlRootElement(name =3D "CATALOG") + private static final class CompactDiscsHolder implements ListHolder { + + private List list; + + @XmlElement(name =3D "CD") + public List getList() { + return list; + } + + public void setList(List list) { + this.list =3D list; + } + } + /** * Model containing various job titles, e.g. CEO, President, Director. - * + * = * @return set of job titles */ public synchronized Set getJobTitles() { @@ -167,7 +209,7 @@ = /** * Model containing select items with various job titles. - * + * = * @return set of job titles */ public synchronized List getJobTitlesSelectItems() { Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/= tests/metamer/model/tree/CompactDisc.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/CompactDisc.java (rev 0) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/CompactDisc.java 2010-11-03 14:24:39 UTC (rev 19911) @@ -0,0 +1,96 @@ +package org.richfaces.tests.metamer.model.tree; + +import java.util.Enumeration; + +import javax.swing.tree.TreeNode; + +public class CompactDisc extends NamedNode implements TreeNode { + private Company company; + private String artist; + private String title; + private float price; + private int year; + + public CompactDisc() { + this.setType("cd"); + } + = + public CompactDisc(String title, String artist, Company company, float= price, int year) { + super(); + this.setType("cd"); + this.company =3D company; + this.artist =3D artist; + this.title =3D title; + this.price =3D price; + this.year =3D year; + } + + public TreeNode getChildAt(int childIndex) { + return null; + } + + public int getChildCount() { + return 0; + } + + public TreeNode getParent() { + return company; + } + + public int getIndex(TreeNode node) { + return 0; + } + + public boolean getAllowsChildren() { + return false; + } + + public boolean isLeaf() { + return true; + } + + public Enumeration children() { + return new Enumeration() { + + public boolean hasMoreElements() { + return false; + } + + public TreeNode nextElement() { + return null; + } + }; + } + + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist =3D artist; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } + + public float getPrice() { + return price; + } + + public void setPrice(float price) { + this.price =3D price; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year =3D year; + } +} Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/= tests/metamer/model/tree/CompactDiscXmlDescriptor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/CompactDiscXmlDescriptor.java = (rev 0) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/CompactDiscXmlDescriptor.java 2010-11-03 14:24:39 UTC= (rev 19911) @@ -0,0 +1,69 @@ +package org.richfaces.tests.metamer.model.tree; + +import java.io.Serializable; + +import javax.xml.bind.annotation.XmlElement; + +public class CompactDiscXmlDescriptor implements Serializable { + private String artist; + private String title; + private String country; + private String company; + private float price; + private int year; + + @XmlElement(name =3D "ARTIST") + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist =3D artist; + } + + @XmlElement(name =3D "TITLE") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title =3D title; + } + + @XmlElement(name =3D "COUNTRY") + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country =3D country; + } + + @XmlElement(name =3D "COMPANY") + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company =3D company; + } + + @XmlElement(name =3D "PRICE") + public float getPrice() { + return price; + } + + public void setPrice(float price) { + this.price =3D price; + } + + @XmlElement(name =3D "YEAR") + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year =3D year; + } + +} Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/= tests/metamer/model/tree/Company.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/Company.java (rev 0) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/Company.java 2010-11-03 14:24:39 UTC (rev 19911) @@ -0,0 +1,73 @@ +package org.richfaces.tests.metamer.model.tree; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import javax.swing.tree.TreeNode; + +import com.google.common.collect.Iterators; + +public class Company extends NamedNode implements TreeNode { + private String name; + private List compactDiscs =3D new ArrayList(= ); + = + private Country country; + = + public Company() { + this.setType("company"); + } + + public TreeNode getChildAt(int childIndex) { + return compactDiscs.get(childIndex); + } + + public int getChildCount() { + return compactDiscs.size(); + } + + public TreeNode getParent() { + return country; + } + + public void setParent(Country country) { + this.country =3D country; + } + + public int getIndex(TreeNode node) { + return compactDiscs.indexOf(node); + } + + public boolean getAllowsChildren() { + return true; + } + + public boolean isLeaf() { + return compactDiscs.isEmpty(); + } + + public Enumeration children() { + return Iterators.asEnumeration(compactDiscs.iterator()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public Country getCountry() { + return country; + } + + public void setCountry(Country country) { + this.country =3D country; + } + + public List getCds() { + return compactDiscs; + } + +} Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/= tests/metamer/model/tree/Country.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/Country.java (rev 0) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/Country.java 2010-11-03 14:24:39 UTC (rev 19911) @@ -0,0 +1,60 @@ +package org.richfaces.tests.metamer.model.tree; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import javax.swing.tree.TreeNode; + +import com.google.common.collect.Iterators; + +public class Country extends NamedNode implements TreeNode { + + private String name; + private List companies =3D new ArrayList(); + + public Country() { + this.setType("country"); + } + + public TreeNode getChildAt(int childIndex) { + return companies.get(childIndex); + } + + public int getChildCount() { + return companies.size(); + } + + public TreeNode getParent() { + return null; + } + + public int getIndex(TreeNode node) { + return companies.indexOf(node); + } + + public boolean getAllowsChildren() { + return true; + } + + public boolean isLeaf() { + return companies.isEmpty(); + } + + public Enumeration children() { + return Iterators.asEnumeration(companies.iterator()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name =3D name; + } + + public List getCompanies() { + return companies; + } + +} Added: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/= tests/metamer/model/tree/NamedNode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/NamedNode.java (rev 0) +++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tes= ts/metamer/model/tree/NamedNode.java 2010-11-03 14:24:39 UTC (rev 19911) @@ -0,0 +1,13 @@ +package org.richfaces.tests.metamer.model.tree; + +public class NamedNode { + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type =3D type; + } +} Added: modules/tests/metamer/trunk/application/src/main/resources/org/richf= aces/tests/metamer/model/compact-discs.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/application/src/main/resources/org/richface= s/tests/metamer/model/compact-discs.xml (rev 0) +++ modules/tests/metamer/trunk/application/src/main/resources/org/richface= s/tests/metamer/model/compact-discs.xml 2010-11-03 14:24:39 UTC (rev 19911) @@ -0,0 +1,211 @@ + + + + Empire Burlesque + Bob Dylan + USA + Columbia + 10.90 + 1985 + + + Hide your heart + Bonnie Tylor + United Kingdom + CBS Records + 9.90 + 1988 + + + Greatest Hits + Dolly Parton + USA + RCA + 9.90 + 1982 + + + Still got the blues + Gary More + United Kingdom + Virgin redords + 10.20 + 1990 + + + Eros + Eros Ramazzotti + Europe + BMG + 9.90 + 1997 + + + One night only + Bee Gees + United Kingdom + Polydor + 10.90 + 1998 + + + Sylvias Mother + Dr.Hook + United Kingdom + CBS + 8.10 + 1973 + + + Maggie May + Rod Stewart + United Kingdom + Pickwick + 8.50 + 1990 + + + Romanza + Andrea Bocelli + Europe + Polydor + 10.80 + 1996 + + + When a man loves a woman + Percy Sledge + USA + Atlantic + 8.70 + 1987 + + + Black angel + Savage Rose + Europe + Mega + 10.90 + 1995 + + + 1999 Grammy Nominees + Many + USA + Grammy + 10.20 + 1999 + + + For the good times + Kenny Rogers + United Kingdom + Mucik Master + 8.70 + 1995 + + + Big Willie style + Will Smith + USA + Columbia + 9.90 + 1997 + + + Tupelo Honey + Van Morrison + United Kingdom + Polydor + 8.20 + 1971 + + + Soulsville + Jorn Hoel + Norway + WEA + 7.90 + 1996 + + + The very best of + Cat Stevens + United Kingdom + Island + 8.90 + 1990 + + + Stop + Sam Brown + United Kingdom + A and M + 8.90 + 1988 + + + Bridge of Spies + T`Pau + United Kingdom + Siren + 7.90 + 1987 + + + Private Dancer + Tina Turner + United Kingdom + Capitol + 8.90 + 1983 + + + Midt om natten + Kim Larsen + Europe + Medley + 7.80 + 1983 + + + Pavarotti Gala Concert + Luciano Pavarotti + United Kingdom + DECCA + 9.90 + 1991 + + + The dock of the bay + Otis Redding + USA + Atlantic + 7.90 + 1987 + + + Picture book + Simply Red + Europe + Elektra + 7.20 + 1985 + + + Red + The Communards + United Kingdom + London + 7.80 + 1987 + + + Unchain my heart + Joe Cocker + USA + EMI + 8.20 + 1987 + + = --===============4576239482275616775==--