1 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 java.awt.Point ; 24 import javax.swing.JComponent ; 25 import javax.swing.JList ; 26 import javax.swing.ListSelectionModel ; 27 import javax.swing.event.ListSelectionListener ; 28 29 public class List extends AbstractCollection 30 implements ListSelectionListener 31 { 32 JList list; 34 35 public List(ViewFactory factory, DisplayContext context, 36 CollectionItem collection, Object substance, CollectionModel model, 37 org.objectweb.jac.aspects.gui.CollectionItemView itemView) { 38 super(factory,context,collection,substance,model,itemView); 39 } 40 41 protected JComponent getInnerComponent(Model model) { 42 if (list==null) { 43 list = new JList (); 44 list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 45 BetterListSelectionModel selModel = new BetterListSelectionModel(list); 46 list.setSelectionModel(selModel); 47 selModel.addListSelectionListener( this ); 48 list.setModel((ListModel)model); 49 } 50 return list; 51 } 52 53 protected void onRemove() { 54 list.clearSelection(); 55 } 56 57 61 protected int[] getSelectedIndices() { 62 return list.getSelectedIndices(); 63 } 64 65 protected CollectionUpdate getCollectionUpdate() { 66 return (CollectionUpdate)model; 67 } 68 69 int locationToIndex(Point location) { 70 return list.locationToIndex(location); 71 } 72 73 protected ListSelectionModel getSelectionModel() { 74 return list.getSelectionModel(); 75 } 76 77 79 public void setSelected(int index) { 80 list.setSelectedIndex(index); 81 } 82 83 } 84 | Popular Tags |