1 package com.genimen.djeneric.tools.specifier.dialogs; 2 3 import java.awt.BorderLayout ; 4 import java.awt.event.ActionEvent ; 5 import java.awt.event.ActionListener ; 6 import java.util.ArrayList ; 7 import java.util.HashMap ; 8 9 import javax.swing.JPanel ; 10 import javax.swing.JScrollPane ; 11 12 import com.genimen.djeneric.repository.DjSession; 13 import com.genimen.djeneric.repository.DjUid; 14 import com.genimen.djeneric.ui.DjVerticalFlowLayout; 15 import com.genimen.djeneric.util.DjLogger; 16 17 public class UidResolverPanel extends JPanel implements ActionListener 18 { 19 private static final long serialVersionUID = 1L; 20 BorderLayout borderLayout1 = new BorderLayout (); 21 JScrollPane _scroller = new JScrollPane (); 22 JPanel _contentPanel = new JPanel (); 23 DjVerticalFlowLayout flowLayout1 = new DjVerticalFlowLayout(); 24 DjSession _session; 25 ArrayList _lines = new ArrayList (); 26 ActionListener _listener; 27 28 public UidResolverPanel() 29 { 30 try 31 { 32 jbInit(); 33 } 34 catch (Exception x) 35 { 36 DjLogger.log(x); 37 } 38 } 39 40 private void jbInit() throws Exception 41 { 42 this.setLayout(borderLayout1); 43 _contentPanel.setLayout(flowLayout1); 44 this.add(_scroller, java.awt.BorderLayout.CENTER); 45 _scroller.getViewport().add(_contentPanel); 46 } 47 48 public void setupList(DjUid[] uids) 49 { 50 for (int i = 0; i < uids.length; i++) 51 { 52 UidResolverLine line = new UidResolverLine(uids[i], _session); 53 line.addActionListener(this); 54 _lines.add(line); 55 _contentPanel.add(line); 56 } 57 } 58 59 public boolean isAllMapped() 60 { 61 for (int i = 0; i < _lines.size(); i++) 62 { 63 UidResolverLine line = (UidResolverLine) _lines.get(i); 64 if (!line.isMapped()) return false; 65 } 66 return true; 67 } 68 69 public HashMap getMappings() 70 { 71 HashMap result = new HashMap (); 72 for (int i = 0; i < _lines.size(); i++) 73 { 74 UidResolverLine line = (UidResolverLine) _lines.get(i); 75 result.put(line.getUid(), line.getMapping()); 76 } 77 return result; 78 } 79 80 public DjSession getSession() 81 { 82 return _session; 83 } 84 85 public void setSession(DjSession session) 86 { 87 _session = session; 88 } 89 90 public void actionPerformed(ActionEvent e) 91 { 92 if (_listener != null) _listener.actionPerformed(e); 93 } 94 95 public void addActionListener(ActionListener listener) 96 { 97 _listener = listener; 98 } 99 100 } 101 | Popular Tags |