KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.genimen.djeneric.tools.specifier.dialogs;
2
3 import java.awt.BorderLayout JavaDoc;
4 import java.awt.Color JavaDoc;
5 import java.awt.Dimension JavaDoc;
6 import java.awt.event.ActionEvent JavaDoc;
7 import java.awt.event.ActionListener JavaDoc;
8 import java.util.ArrayList JavaDoc;
9
10 import javax.swing.JButton JavaDoc;
11 import javax.swing.JLabel JavaDoc;
12 import javax.swing.JPanel JavaDoc;
13
14 import com.genimen.djeneric.language.Messages;
15 import com.genimen.djeneric.repository.DjObject;
16 import com.genimen.djeneric.repository.DjSession;
17 import com.genimen.djeneric.repository.DjUid;
18 import com.genimen.djeneric.tools.specifier.Specifier;
19 import com.genimen.djeneric.ui.Util;
20 import com.genimen.djeneric.util.DjLogger;
21
22 public class UidResolverLine extends JPanel JavaDoc
23 {
24   private static final long serialVersionUID = 1L;
25   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
26   JLabel JavaDoc _lblTitle = new JLabel JavaDoc();
27   JButton JavaDoc _butChoose = new JButton JavaDoc();
28   JPanel JavaDoc _mappingPanel = new JPanel JavaDoc();
29   JLabel JavaDoc _lblArrow = new JLabel JavaDoc();
30   JLabel JavaDoc _newMappingTitle = new JLabel JavaDoc();
31   DjSession _session;
32   DjUid _uid;
33   DjObject _newLink;
34   ActionListener JavaDoc _listener;
35   BorderLayout JavaDoc borderLayout2 = new BorderLayout JavaDoc();
36   JPanel JavaDoc jPanel1 = new JPanel JavaDoc();
37   BorderLayout JavaDoc borderLayout3 = new BorderLayout JavaDoc();
38   JPanel JavaDoc jPanel2 = new JPanel JavaDoc();
39   BorderLayout JavaDoc borderLayout4 = new BorderLayout JavaDoc();
40
41   public UidResolverLine(DjUid uid, DjSession session)
42   {
43     try
44     {
45       _session = session;
46       _uid = uid;
47       jbInit();
48       _lblTitle.setText(uid.getExtent().getNameSingular() + ": " + uid.getDescriptor());
49     }
50     catch (Exception JavaDoc x)
51     {
52       DjLogger.log(x);
53     }
54   }
55
56   public boolean isMapped()
57   {
58     return _newLink != null;
59   }
60
61   public DjObject getMapping()
62   {
63     return _newLink;
64   }
65
66   public DjUid getUid()
67   {
68     return _uid;
69   }
70
71   private void jbInit() throws Exception JavaDoc
72   {
73     this.setLayout(borderLayout1);
74     _lblTitle.setText("Descriptor");
75     _butChoose.setPreferredSize(new Dimension JavaDoc(24, 24));
76     _butChoose.setText("...");
77     _butChoose.addActionListener(new UidResolverLine_butChoose_actionAdapter(this));
78     this.setPreferredSize(new Dimension JavaDoc(91, 24));
79     _mappingPanel.setLayout(borderLayout2);
80     _lblArrow.setIcon(Specifier.getImageIcon("mapping.gif"));
81     _newMappingTitle.setText(Messages.getString("Specifier.UnresolvedMapping"));
82     jPanel1.setLayout(borderLayout3);
83     jPanel2.setLayout(borderLayout4);
84     this.add(_butChoose, java.awt.BorderLayout.EAST);
85     _newMappingTitle.setForeground(Color.RED);
86     this.add(_mappingPanel, java.awt.BorderLayout.CENTER);
87     _mappingPanel.add(jPanel1, java.awt.BorderLayout.WEST);
88     jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);
89     jPanel2.add(_lblArrow, java.awt.BorderLayout.WEST);
90     jPanel2.add(_newMappingTitle, java.awt.BorderLayout.CENTER);
91     jPanel1.add(_lblTitle, java.awt.BorderLayout.WEST);
92   }
93
94   public void butChoose_actionPerformed(ActionEvent JavaDoc e)
95   {
96     ChooserDialog dlg = new ChooserDialog(Util.findActiveFrame(), _session, _uid.getExtent(), new ArrayList JavaDoc(),
97         _lblTitle.getText(), true, 0, 0);
98     if (!dlg.wasCancelled()) _newLink = dlg.getSelectedObject();
99     _newMappingTitle.setText(_newLink.toString());
100     _newMappingTitle.setForeground(_lblTitle.getForeground());
101     if (_listener != null) _listener.actionPerformed(e);
102   }
103
104   public void addActionListener(ActionListener JavaDoc listener)
105   {
106     _listener = listener;
107   }
108 }
109
110 class UidResolverLine_butChoose_actionAdapter implements ActionListener JavaDoc
111 {
112   private UidResolverLine adaptee;
113
114   UidResolverLine_butChoose_actionAdapter(UidResolverLine adaptee)
115   {
116     this.adaptee = adaptee;
117   }
118
119   public void actionPerformed(ActionEvent JavaDoc e)
120   {
121     adaptee.butChoose_actionPerformed(e);
122   }
123 }
124
Popular Tags