1 package com.genimen.djeneric.tools.specifier.dialogs; 2 3 import java.awt.BorderLayout ; 4 import java.awt.Color ; 5 import java.awt.Dimension ; 6 import java.awt.event.ActionEvent ; 7 import java.awt.event.ActionListener ; 8 import java.util.ArrayList ; 9 10 import javax.swing.JButton ; 11 import javax.swing.JLabel ; 12 import javax.swing.JPanel ; 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 23 { 24 private static final long serialVersionUID = 1L; 25 BorderLayout borderLayout1 = new BorderLayout (); 26 JLabel _lblTitle = new JLabel (); 27 JButton _butChoose = new JButton (); 28 JPanel _mappingPanel = new JPanel (); 29 JLabel _lblArrow = new JLabel (); 30 JLabel _newMappingTitle = new JLabel (); 31 DjSession _session; 32 DjUid _uid; 33 DjObject _newLink; 34 ActionListener _listener; 35 BorderLayout borderLayout2 = new BorderLayout (); 36 JPanel jPanel1 = new JPanel (); 37 BorderLayout borderLayout3 = new BorderLayout (); 38 JPanel jPanel2 = new JPanel (); 39 BorderLayout borderLayout4 = new BorderLayout (); 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 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 72 { 73 this.setLayout(borderLayout1); 74 _lblTitle.setText("Descriptor"); 75 _butChoose.setPreferredSize(new Dimension (24, 24)); 76 _butChoose.setText("..."); 77 _butChoose.addActionListener(new UidResolverLine_butChoose_actionAdapter(this)); 78 this.setPreferredSize(new Dimension (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 e) 95 { 96 ChooserDialog dlg = new ChooserDialog(Util.findActiveFrame(), _session, _uid.getExtent(), new ArrayList (), 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 listener) 105 { 106 _listener = listener; 107 } 108 } 109 110 class UidResolverLine_butChoose_actionAdapter implements ActionListener 111 { 112 private UidResolverLine adaptee; 113 114 UidResolverLine_butChoose_actionAdapter(UidResolverLine adaptee) 115 { 116 this.adaptee = adaptee; 117 } 118 119 public void actionPerformed(ActionEvent e) 120 { 121 adaptee.butChoose_actionPerformed(e); 122 } 123 } 124 | Popular Tags |