1 package com.genimen.djeneric.tools.specifier.dialogs; 2 3 import java.awt.BorderLayout ; 4 import java.awt.Dimension ; 5 import java.awt.Frame ; 6 import java.awt.Toolkit ; 7 import java.awt.event.ActionEvent ; 8 import java.awt.event.ActionListener ; 9 import java.util.HashMap ; 10 11 import javax.swing.JButton ; 12 import javax.swing.JDialog ; 13 import javax.swing.JPanel ; 14 15 import com.genimen.djeneric.language.Messages; 16 import com.genimen.djeneric.repository.DjSession; 17 import com.genimen.djeneric.repository.DjUid; 18 import com.genimen.djeneric.ui.Util; 19 import com.genimen.djeneric.util.DjLogger; 20 21 public class UidResolverDialog extends JDialog implements ActionListener 22 { 23 private static final long serialVersionUID = 1L; 24 JPanel panel1 = new JPanel (); 25 BorderLayout borderLayout1 = new BorderLayout (); 26 JPanel jPanel1 = new JPanel (); 27 BorderLayout borderLayout2 = new BorderLayout (); 28 UidResolverPanel uidResolverPanel = new UidResolverPanel(); 29 JPanel _buttonPanel = new JPanel (); 30 BorderLayout borderLayout3 = new BorderLayout (); 31 JPanel jPanel3 = new JPanel (); 32 JButton _butOk = new JButton (); 33 JButton _butCancel = new JButton (); 34 boolean _wasCancelled = true; 35 36 public UidResolverDialog(Frame owner, DjSession session, DjUid[] uids) 37 { 38 super(owner, "Resolve objects", true); 39 try 40 { 41 setDefaultCloseOperation(DISPOSE_ON_CLOSE); 42 uidResolverPanel.setSession(session); 43 uidResolverPanel.setupList(uids); 44 uidResolverPanel.addActionListener(this); 45 46 jbInit(); 47 pack(); 48 int height = getHeight(); 49 if (height > 500) height = 500; 50 51 setSize(500, height); 52 53 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 54 Dimension frameSize = getSize(); 55 setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); 56 uidResolverPanel.addActionListener(this); 57 setVisible(true); 58 } 59 catch (Exception x) 60 { 61 DjLogger.log(x); 62 } 63 } 64 65 private void jbInit() throws Exception 66 { 67 panel1.setLayout(borderLayout1); 68 jPanel1.setLayout(borderLayout2); 69 _buttonPanel.setLayout(borderLayout3); 70 _butOk.setEnabled(false); 71 _butOk.setText(Messages.getString("global.Ok")); 72 _butOk.addActionListener(new UidResolverDialog__butOk_actionAdapter(this)); 73 _butCancel.setText(Messages.getString("global.Cancel")); 74 _butCancel.addActionListener(new UidResolverDialog__butCancel_actionAdapter(this)); 75 getContentPane().add(panel1); 76 panel1.add(jPanel1, java.awt.BorderLayout.CENTER); 77 jPanel1.add(uidResolverPanel, java.awt.BorderLayout.CENTER); 78 jPanel1.add(_buttonPanel, java.awt.BorderLayout.SOUTH); 79 _buttonPanel.add(jPanel3, java.awt.BorderLayout.EAST); 80 jPanel3.add(_butCancel); 81 jPanel3.add(_butOk); 82 Util.sizeButtons(jPanel3); 83 } 84 85 public HashMap getMappings() 86 { 87 return uidResolverPanel.getMappings(); 88 } 89 90 public boolean wasCancelled() 91 { 92 return _wasCancelled; 93 } 94 95 public void _butOk_actionPerformed(ActionEvent e) 96 { 97 _wasCancelled = false; 98 setVisible(false); 99 } 100 101 public void _butCancel_actionPerformed(ActionEvent e) 102 { 103 setVisible(false); 104 } 105 106 public void actionPerformed(ActionEvent e) 107 { 108 _butOk.setEnabled(uidResolverPanel.isAllMapped()); 109 } 110 111 } 112 113 class UidResolverDialog__butCancel_actionAdapter implements ActionListener 114 { 115 private UidResolverDialog adaptee; 116 117 UidResolverDialog__butCancel_actionAdapter(UidResolverDialog adaptee) 118 { 119 this.adaptee = adaptee; 120 } 121 122 public void actionPerformed(ActionEvent e) 123 { 124 adaptee._butCancel_actionPerformed(e); 125 } 126 } 127 128 class UidResolverDialog__butOk_actionAdapter implements ActionListener 129 { 130 private UidResolverDialog adaptee; 131 132 UidResolverDialog__butOk_actionAdapter(UidResolverDialog adaptee) 133 { 134 this.adaptee = adaptee; 135 } 136 137 public void actionPerformed(ActionEvent e) 138 { 139 adaptee._butOk_actionPerformed(e); 140 } 141 } 142 | Popular Tags |