KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.genimen.djeneric.tools.specifier.dialogs;
2
3 import java.awt.BorderLayout JavaDoc;
4 import java.awt.Dimension JavaDoc;
5 import java.awt.Frame JavaDoc;
6 import java.awt.Toolkit JavaDoc;
7 import java.awt.event.ActionEvent JavaDoc;
8 import java.awt.event.ActionListener JavaDoc;
9 import java.util.HashMap JavaDoc;
10
11 import javax.swing.JButton JavaDoc;
12 import javax.swing.JDialog JavaDoc;
13 import javax.swing.JPanel JavaDoc;
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 JavaDoc implements ActionListener JavaDoc
22 {
23   private static final long serialVersionUID = 1L;
24   JPanel JavaDoc panel1 = new JPanel JavaDoc();
25   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
26   JPanel JavaDoc jPanel1 = new JPanel JavaDoc();
27   BorderLayout JavaDoc borderLayout2 = new BorderLayout JavaDoc();
28   UidResolverPanel uidResolverPanel = new UidResolverPanel();
29   JPanel JavaDoc _buttonPanel = new JPanel JavaDoc();
30   BorderLayout JavaDoc borderLayout3 = new BorderLayout JavaDoc();
31   JPanel JavaDoc jPanel3 = new JPanel JavaDoc();
32   JButton JavaDoc _butOk = new JButton JavaDoc();
33   JButton JavaDoc _butCancel = new JButton JavaDoc();
34   boolean _wasCancelled = true;
35
36   public UidResolverDialog(Frame JavaDoc 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 JavaDoc screenSize = Toolkit.getDefaultToolkit().getScreenSize();
54       Dimension JavaDoc 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 JavaDoc x)
60     {
61       DjLogger.log(x);
62     }
63   }
64
65   private void jbInit() throws Exception JavaDoc
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 JavaDoc getMappings()
86   {
87     return uidResolverPanel.getMappings();
88   }
89
90   public boolean wasCancelled()
91   {
92     return _wasCancelled;
93   }
94
95   public void _butOk_actionPerformed(ActionEvent JavaDoc e)
96   {
97     _wasCancelled = false;
98     setVisible(false);
99   }
100
101   public void _butCancel_actionPerformed(ActionEvent JavaDoc e)
102   {
103     setVisible(false);
104   }
105
106   public void actionPerformed(ActionEvent JavaDoc e)
107   {
108     _butOk.setEnabled(uidResolverPanel.isAllMapped());
109   }
110
111 }
112
113 class UidResolverDialog__butCancel_actionAdapter implements ActionListener JavaDoc
114 {
115   private UidResolverDialog adaptee;
116
117   UidResolverDialog__butCancel_actionAdapter(UidResolverDialog adaptee)
118   {
119     this.adaptee = adaptee;
120   }
121
122   public void actionPerformed(ActionEvent JavaDoc e)
123   {
124     adaptee._butCancel_actionPerformed(e);
125   }
126 }
127
128 class UidResolverDialog__butOk_actionAdapter implements ActionListener JavaDoc
129 {
130   private UidResolverDialog adaptee;
131
132   UidResolverDialog__butOk_actionAdapter(UidResolverDialog adaptee)
133   {
134     this.adaptee = adaptee;
135   }
136
137   public void actionPerformed(ActionEvent JavaDoc e)
138   {
139     adaptee._butOk_actionPerformed(e);
140   }
141 }
142
Popular Tags