001    /*
002      Copyright (C) 2001-2003 Renaud Pawlak <renaud@aopsys.com>, 
003                              Laurent Martelli <laurent@aopsys.com>
004      
005      This program is free software; you can redistribute it and/or modify
006      it under the terms of the GNU Lesser General Public License as
007      published by the Free Software Foundation; either version 2 of the
008      License, or (at your option) any later version.
009    
010      This program is distributed in the hope that it will be useful,
011      but WITHOUT ANY WARRANTY; without even the implied warranty of
012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013      GNU Lesser General Public License for more details.
014    
015      You should have received a copy of the GNU Lesser General Public License
016      along with this program; if not, write to the Free Software
017      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
018    
019    package org.objectweb.jac.aspects.gui.swing;
020    
021    import org.objectweb.jac.aspects.gui.*;
022    import org.objectweb.jac.core.rtti.CollectionItem;
023    import org.objectweb.jac.core.rtti.FieldItem;
024    import javax.swing.JList;
025    
026    /**
027     * Base class to implement ListView and TableView
028     */
029    public class CompactList extends AbstractView
030        implements CollectionUpdate
031    {
032        CollectionItem collection;
033        Object substance;
034        CollectionModel model;
035    
036        JList list;
037    
038        public CollectionModel getCollectionModel() {
039            return model;
040        }
041    
042        public CompactList(ViewFactory factory, DisplayContext context,
043                           CollectionItem collection, Object substance,
044                           CollectionModel model) {
045            super(factory,context);
046            this.collection = collection;
047            this.substance = substance;
048            this.model = model;
049    
050            list = new JList();
051            list.setModel((ListModel)model);
052            add(list);
053          
054            Utils.registerCollection(substance,collection,this);
055        }
056    
057        public void close(boolean validate) {
058            closed = true;
059            model.close();
060        }
061    
062        protected void setNoRefresh(boolean norefresh) {
063            if (norefresh==false) {
064                repaint();
065            }
066        }
067    
068        public void setField(FieldItem field) {
069            collection = (CollectionItem)field;
070        }
071    
072        public void setSubstance(Object substance) {
073            this.substance = substance;
074        }
075    
076        public FieldItem getField() {
077            return collection;
078        }
079    
080        public void setValue(Object value) {
081        }
082    
083        public void updateModel(Object substance) {
084        }
085    
086        // CollectionUpdate interface
087    
088        public void onChange(Object substance, CollectionItem collection, 
089                             Object value, Object param) {
090        }
091    
092        public void onAdd(Object substance, CollectionItem collection, Object value,
093                          Object added, Object param) {
094        }
095    
096        public void onRemove(Object substance, CollectionItem collection, Object value,
097                             Object removed, Object param) {
098        }
099    
100    }