Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jac/aspects/gui/web/CompactList.java


1   /*
2     Copyright (C) 2001-2003 Laurent Martelli <laurent@aopsys.com>
3     
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as
6     published by the Free Software Foundation; either version 2 of the
7     License, or (at your option) any later version.
8   
9     This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU Lesser General Public License for more details.
13  
14    You should have received a copy of the GNU Lesser General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
17  
18  package jac.aspects.gui.web;
19  
20  import jac.aspects.gui.*;
21  import jac.aspects.gui.FieldView;
22  import jac.core.Collaboration;
23  import jac.core.Wrappee;
24  import jac.core.rtti.ClassItem;
25  import jac.core.rtti.ClassRepository;
26  import jac.core.rtti.CollectionItem;
27  import jac.core.rtti.FieldItem;
28  import jac.core.rtti.MetaItem;
29  import jac.core.rtti.MethodItem;
30  import jac.util.Classes;
31  import jac.util.Log;
32  import java.io.PrintWriter;
33  import java.util.Collection;
34  import java.util.Iterator;
35  import java.util.Vector;
36  
37  public class CompactList extends AbstractCollection
38     implements HTMLViewer, CollectionListener
39  {
40     public CompactList(ViewFactory factory, DisplayContext context,
41                        CollectionItem collection, Object substance,
42                        CollectionModel model) {
43        super(factory,context,collection,substance,model);
44     }
45  
46     public CompactList() {
47     }
48  
49     public void sort() {
50     }
51  
52     public void updateModel(Object substance) {
53        if (model!=null)
54           model.close();
55        model = new ListModel(collection,substance);
56     }
57  
58     // HTMLViewer interface
59  
60     public void genHTML(PrintWriter out) {
61        sort();
62  
63        boolean ulOpened = false;
64        for (int index=startIndex; 
65             (!split || index<startIndex+rowsPerPage) && index<model.getRowCount(); 
66             index++) 
67        {
68           String row = (String)((ListModel)model).getElementAt(index);
69           if (!ulOpened) {
70              out.println("<ul class=\"list\">");
71              ulOpened = true;
72           }
73           out.print("    <li>"+row+"</li>");
74        }
75        if (ulOpened)
76           out.println("</ul>");
77     }
78  }