labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simo...@apache.org
Subject svn commit: r833033 [2/2] - in /labs/magma/trunk: foundation-beans-view/src/main/java/org/apache/magma/view/ foundation-beans-view/src/main/java/org/apache/magma/view/tree/ maps-google/src/main/java/org/apache/magma/maps/google/ website-administration/...
Date Thu, 05 Nov 2009 12:04:52 GMT
Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java?rev=833033&r1=833032&r2=833033&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartList.java
Thu Nov  5 12:02:43 2009
@@ -65,15 +65,14 @@
 	
 	private String link;
 	private String linkUrl;
-	private Class<?> myclass;
-	
-	private String caption;
-	private String summary;
+	private Class<? extends MagmaBeanSupport> myclass;
 
-	private ListHtmlEmitter emitter;
-	
+	// Delegate fields
+	private ListStyle listStyle;
+	private String summary;
+	private String caption;
 	
-	public SmartList(Class<?> beanClass, String query, Object... queryParams) {
+	public <T extends MagmaBeanSupport> SmartList(Class<T> beanClass, String query,
Object... queryParams) {
 		this.myclass = beanClass;
 		this.query = query;
 		this.queryParams = queryParams;
@@ -148,20 +147,22 @@
 				if (sessionReservedDesc) acquery.append(" DESC");
 			}
 		}
-		List list = db.query(myclass, start, len, acquery.toString(), this.queryParams);
+		List<? extends MagmaBeanSupport> list = db.query(myclass, start, len, acquery.toString(),
this.queryParams);
 		parametrize(prodHeader);
 		parametrize(prodFooter);
-		SmartListProducer producer = new SmartListProducer(myclass, list);
+		SmartListProducer producer = new SmartListProducer(myclass);
+		producer.setList(list);
 		producer.setLen(len);
 		producer.setStart(start);
 		producer.setCount(count);
 		producer.setSorting(sessionReservedSorting);
 		producer.setDesc(sessionReservedDesc);
 		producer.setSortables(sortables);
-		producer.setLink("../" + this.linkUrl);
+		producer.setCaption(caption);
+		producer.setSummary(summary);
+		producer.setListStyle(listStyle);
 		producer.setLayers(layers);
-		producer.setCaption(caption).setSummary(summary);
-		producer.setEmitter(emitter);
+		producer.setLink("../" + this.linkUrl);
 		producer.compoundWith(prodHeader, CompoundType.BEFORE);
 		producer.compoundWith(prodFooter, CompoundType.AFTER);
 		return producer;
@@ -243,48 +244,37 @@
 		this.len = len;
 		return this;
 	}
-
-	public String getCaption() {
-		return caption;
+	
+	public SmartList setLayers(String... layers) {
+		this.layers = layers;
+		return this;
 	}
 
+	// Delegate methods on the producer
+	
 	public SmartList setCaption(String caption) {
 		this.caption = caption;
 		return this;
 	}
 
-	public String getSummary() {
-		return summary;
+	public SmartList setListStyle(ListStyle listTemplate) {
+		this.listStyle = listTemplate;
+		return this;
 	}
 
 	public SmartList setSummary(String summary) {
 		this.summary = summary;
 		return this;
 	}
-	
-	public SmartList setLayers(String... layers) {
-		this.layers = layers;
-		return this;
-	}
-	
+
 	public SmartList useList() {
-		emitter = new UlListHtmlEmitter();
+		listStyle = new ListStyleUl();
 		return this;
 	}
 	
 	public SmartList useTable() {
-		emitter = new TableListHtmlEmitter();
-		return this;
-	}
-
-	public ListHtmlEmitter getEmitter() {
-		return emitter;
-	}
-
-	public SmartList setEmitter(ListHtmlEmitter emitter) {
-		if (emitter != null) this.emitter = emitter;
+		listStyle = new ListStyleTableWithSorting();
 		return this;
 	}
-			
 	
 }

Modified: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java?rev=833033&r1=833032&r2=833033&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
(original)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartListProducer.java
Thu Nov  5 12:02:43 2009
@@ -40,10 +40,15 @@
 	protected boolean desc = false;
 	protected Set<String> sortables = null;
 	protected int count = -1;
+	protected boolean useSorting = true;
 	
 	public <T extends MagmaBeanSupport> SmartListProducer(Class<T> myclass, Collection<?
extends T> list) {
 		super(myclass, list);
 	}
+	
+	protected <T extends MagmaBeanSupport> SmartListProducer(Class<T> myclass) {
+		super(myclass);
+	}
 
 
 	public int getStart() {
@@ -86,16 +91,6 @@
 	}
 
 
-	public String getLink() {
-		return linkUrl;
-	}
-
-
-	public void setLink(String next) {
-		this.linkUrl = next;
-	}
-
-
 	public Set<String> getSortables() {
 		return sortables;
 	}
@@ -106,6 +101,12 @@
 	}
 
 	@Override
+	public SmartListProducer useTable() {
+		listStyle = new ListStyleTableWithSorting();
+		return this;
+	}
+
+	@Override
 	public void produce(Writer tables) throws IOException {
 		String pagination = createPagination();
 		tables.append("<div class=\"MagmaPagination BeforeList\">");
@@ -161,7 +162,34 @@
 		ret.append("</div>");
 		return ret.toString();
 	}
+	
+	protected boolean isSortable(String nodeid) {
+		return (sortables != null && (sortables != null && sortables.contains(nodeid)));
	
+	}
+
+	protected boolean isSorted(String nodeid) {
+		return this.sorting != null && this.sorting.equals(nodeid);		
+	}
+	
+	
+	protected String sortLink(String nodeid) {
+		boolean sorted = this.sorting != null && this.sorting.equals(nodeid);
+		String link = "sort" + WebHandler.paramSeparator;
+		if (sorted) {
+			if (desc) {
+				link += "false" + WebHandler.paramSeparator;
+			} else {
+				link += "true" + WebHandler.paramSeparator;
+			}
+		} else {
+			link += "false" + WebHandler.paramSeparator;				
+		}
+		link += nodeid;
+		return link;
+	}
 
+	/*
+	 * TODO Rewrite inside specific list templates
 	@Override
 	protected void createHeader(Node root, Writer tables) throws IOException {
 		if (emitter.supportsHeader()) {
@@ -214,10 +242,18 @@
 			if (emitter.supportsHeader()) super.createFieldNodeHeader(fldn, tables);
 		}
 	}
-
+	*/
 
 	public void setCount(int count) {
 		this.count = count;
-	}	
+	}
+
+	public String getLink() {
+		return linkUrl;
+	}
+
+	public void setLink(String next) {
+		this.linkUrl = next;
+	}
 
 }

Modified: labs/magma/trunk/website-beansview/src/main/resources/org/apache/magma/website/beansview/magmaBeansview.css
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/resources/org/apache/magma/website/beansview/magmaBeansview.css?rev=833033&r1=833032&r2=833033&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/resources/org/apache/magma/website/beansview/magmaBeansview.css
(original)
+++ labs/magma/trunk/website-beansview/src/main/resources/org/apache/magma/website/beansview/magmaBeansview.css
Thu Nov  5 12:02:43 2009
@@ -176,13 +176,13 @@
 	border: none;	
 }
 
-table.MagmaList-HeaderCell {
+table .MagmaList-HeaderCell {
 	background-color: #C5E8FA;
 	border: 2px solid #D1D0D0;
 	text-align: center;		
 }
 
-table.MagmaList-Cell{
+table .MagmaList-Cell{
 	border: 1px solid #D1D0D0;
 	text-align: center;
 }

Modified: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java?rev=833033&r1=833032&r2=833033&view=diff
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java
(original)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java
Thu Nov  5 12:02:43 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.magma.website.beansview;
 
+import org.apache.magma.beans.BeanData;
 import org.apache.magma.website.beansview.stuff.Person;
 
 import java.io.ByteArrayOutputStream;
@@ -24,11 +25,23 @@
 
 import org.junit.Test;
 import static org.apache.magma.website.beansview.AssertStringStructure.assertStructure;
+import static org.junit.Assert.*;
 
 
 public class ShowListTest {
 
 	@Test
+	public void listTemplateTest() throws Exception {
+		ListStyleTable ltt = new ListStyleTable();
+		ltt.setMyclass(Person.class);
+		ltt.setRoot(BeanData.getFor(Person.class).getViewTree());
+		ltt.setWithLink(true);
+		ltt.generate();
+		String template = ltt.getTemplate();
+		System.out.println(template);
+	}
+	
+	@Test
 	public void simpleTest() throws Exception {
 		Person p = new Person();
 		p.setName("Simone");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message