KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > tools > specifier > dialogs > UidResolverPanel


1 package com.genimen.djeneric.tools.specifier.dialogs;
2
3 import java.awt.BorderLayout JavaDoc;
4 import java.awt.event.ActionEvent JavaDoc;
5 import java.awt.event.ActionListener JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.HashMap JavaDoc;
8
9 import javax.swing.JPanel JavaDoc;
10 import javax.swing.JScrollPane JavaDoc;
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 JavaDoc implements ActionListener JavaDoc
18 {
19   private static final long serialVersionUID = 1L;
20   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
21   JScrollPane JavaDoc _scroller = new JScrollPane JavaDoc();
22   JPanel JavaDoc _contentPanel = new JPanel JavaDoc();
23   DjVerticalFlowLayout flowLayout1 = new DjVerticalFlowLayout();
24   DjSession _session;
25   ArrayList JavaDoc _lines = new ArrayList JavaDoc();
26   ActionListener JavaDoc _listener;
27
28   public UidResolverPanel()
29   {
30     try
31     {
32       jbInit();
33     }
34     catch (Exception JavaDoc x)
35     {
36       DjLogger.log(x);
37     }
38   }
39
40   private void jbInit() throws Exception JavaDoc
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 JavaDoc getMappings()
70   {
71     HashMap JavaDoc result = new HashMap JavaDoc();
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 JavaDoc e)
91   {
92     if (_listener != null) _listener.actionPerformed(e);
93   }
94
95   public void addActionListener(ActionListener JavaDoc listener)
96   {
97     _listener = listener;
98   }
99
100 }
101
Popular Tags