KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > swing > CompactList


1 /*
2   Copyright (C) 2001-2003 Renaud Pawlak <renaud@aopsys.com>,
3                           Laurent Martelli <laurent@aopsys.com>
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU Lesser General Public License as
7   published by the Free Software Foundation; either version 2 of the
8   License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

18
19 package org.objectweb.jac.aspects.gui.swing;
20
21 import org.objectweb.jac.aspects.gui.*;
22 import org.objectweb.jac.core.rtti.CollectionItem;
23 import org.objectweb.jac.core.rtti.FieldItem;
24 import javax.swing.JList JavaDoc;
25
26 /**
27  * Base class to implement ListView and TableView
28  */

29 public class CompactList extends AbstractView
30     implements CollectionUpdate
31 {
32     CollectionItem collection;
33     Object JavaDoc substance;
34     CollectionModel model;
35
36     JList JavaDoc list;
37
38     public CollectionModel getCollectionModel() {
39         return model;
40     }
41
42     public CompactList(ViewFactory factory, DisplayContext context,
43                        CollectionItem collection, Object JavaDoc substance,
44                        CollectionModel model) {
45         super(factory,context);
46         this.collection = collection;
47         this.substance = substance;
48         this.model = model;
49
50         list = new JList JavaDoc();
51         list.setModel((ListModel)model);
52         add(list);
53       
54         Utils.registerCollection(substance,collection,this);
55     }
56
57     public void close(boolean validate) {
58         closed = true;
59         model.close();
60     }
61
62     protected void setNoRefresh(boolean norefresh) {
63         if (norefresh==false) {
64             repaint();
65         }
66     }
67
68     public void setField(FieldItem field) {
69         collection = (CollectionItem)field;
70     }
71
72     public void setSubstance(Object JavaDoc substance) {
73         this.substance = substance;
74     }
75
76     public FieldItem getField() {
77         return collection;
78     }
79
80     public void setValue(Object JavaDoc value) {
81     }
82
83     public void updateModel(Object JavaDoc substance) {
84     }
85
86     // CollectionUpdate interface
87

88     public void onChange(Object JavaDoc substance, CollectionItem collection,
89                          Object JavaDoc value, Object JavaDoc param) {
90     }
91
92     public void onAdd(Object JavaDoc substance, CollectionItem collection, Object JavaDoc value,
93                       Object JavaDoc added, Object JavaDoc param) {
94     }
95
96     public void onRemove(Object JavaDoc substance, CollectionItem collection, Object JavaDoc value,
97                          Object JavaDoc removed, Object JavaDoc param) {
98     }
99
100 }
101
Popular Tags