View Javadoc

1   /***
2   *
3   * The owl-s matcher software is subject to the GNU Lesser General
4   * Public License Version 2.1 (the "License"). You may not copy or use this
5   * file, in either source code or executable form, except in compliance
6   * with the License. You may obtain a copy of the License at
7   * http://www.fsf.org/licenses/lgpl.txt or http://www.opensource.org/.
8   *
9   * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied without
11  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this distribution; if not, write to the
17  *
18  * Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330,
20  * Boston, MA  02111-1307 USA
21  *
22  * Copyright (C) 2003-2004
23  * TU Berlin, FG IVS
24  * Stefan Tang,
25  * Christoph Liebetruth,
26  * Michael C. Jaeger, 
27  *
28  * More information available at http://ivs.tu-berlin.de/
29  *
30  * $Id$
31  *
32  */
33  package de.tuberlin.ivs.owl.gui;
34  
35  import java.awt.*;
36  import javax.swing.*;
37  import de.tuberlin.ivs.owl.service.Actor;
38  import java.util.Vector;
39  import java.awt.event.*;
40  
41  /***
42   * Dialog that displays contact information of a profile.
43   *
44   * @author Stefan Tang (steftang@stanford.edu), Christoph Liebetruth (christophl@voelcker.com)
45   * @version 1.1
46   */
47  
48  public class ShowActorDialog extends JDialog {
49  
50    // --------------------------------------
51    // ------- AUTO-GENERATED FIELDS --------
52    // --------------------------------------
53    JPanel panel1 = new JPanel();
54    JPanel jPanel1 = new JPanel();
55    JPanel jPanel2 = new JPanel();
56    JPanel jPanel3 = new JPanel();
57    JPanel jPanel4 = new JPanel();
58    JPanel jPanel5 = new JPanel();
59    JPanel jPanel6 = new JPanel();
60    JPanel jPanel7 = new JPanel();
61    JPanel jPanel8 = new JPanel();
62    JButton closeButton = new JButton();
63    JPanel jPanel9 = new JPanel();
64    BorderLayout borderLayout1 = new BorderLayout();
65    JLabel nameLabel = new JLabel();
66    JLabel jLabel2 = new JLabel();
67    JPanel jPanel10 = new JPanel();
68    JPanel jPanel11 = new JPanel();
69    GridLayout gridLayout1 = new GridLayout();
70    GridLayout gridLayout2 = new GridLayout();
71    GridLayout gridLayout3 = new GridLayout();
72    JPanel jPanel12 = new JPanel();
73    JPanel jPanel13 = new JPanel();
74    GridLayout gridLayout4 = new GridLayout();
75    JLabel jLabel1 = new JLabel();
76    JLabel titleLabel = new JLabel();
77    GridLayout gridLayout5 = new GridLayout();
78    GridLayout gridLayout6 = new GridLayout();
79    JPanel jPanel14 = new JPanel();
80    JPanel jPanel15 = new JPanel();
81    GridLayout gridLayout7 = new GridLayout();
82    JLabel jLabel3 = new JLabel();
83    JLabel phoneLabel = new JLabel();
84    GridLayout gridLayout8 = new GridLayout();
85    GridLayout gridLayout9 = new GridLayout();
86    JPanel jPanel16 = new JPanel();
87    JPanel jPanel17 = new JPanel();
88    JPanel jPanel18 = new JPanel();
89    JPanel jPanel19 = new JPanel();
90    JPanel jPanel20 = new JPanel();
91    JPanel jPanel21 = new JPanel();
92    JPanel jPanel22 = new JPanel();
93    JPanel jPanel23 = new JPanel();
94    JPanel jPanel24 = new JPanel();
95    GridLayout gridLayout10 = new GridLayout();
96    GridLayout gridLayout11 = new GridLayout();
97    GridLayout gridLayout12 = new GridLayout();
98    GridLayout gridLayout13 = new GridLayout();
99    JLabel jLabel4 = new JLabel();
100   JLabel faxLabel = new JLabel();
101   JLabel jLabel6 = new JLabel();
102   JLabel emailLabel = new JLabel();
103   JLabel jLabel8 = new JLabel();
104   JLabel physAdressLabel = new JLabel();
105   JLabel jLabel10 = new JLabel();
106   JLabel urlLabel = new JLabel();
107   GridLayout gridLayout14 = new GridLayout();
108   GridLayout gridLayout15 = new GridLayout();
109   GridLayout gridLayout16 = new GridLayout();
110   GridLayout gridLayout17 = new GridLayout();
111   GridLayout gridLayout18 = new GridLayout();
112   GridLayout gridLayout19 = new GridLayout();
113   GridLayout gridLayout20 = new GridLayout();
114   GridLayout gridLayout21 = new GridLayout();
115   GridLayout gridLayout22 = new GridLayout();
116   JComboBox actorBox = new JComboBox();
117   GridLayout gridLayout23 = new GridLayout();
118   Vector actors;
119 
120   /***
121    * Constructor.
122    * @param frame The parent frame of this dialog.
123    * @param title The title of this dialog.
124    * @param modal true if the parent frame should be disabled when this dialog
125    * is displayed, false otherwise.
126    * @param actor A vector containing all contacts for this profile.
127    */
128   public ShowActorDialog(Frame frame, String title, boolean modal,Vector actor) {
129     super(frame, title, modal);
130     try {
131       jbInit();
132       pack();
133     }
134     catch(Exception ex) {
135       ex.printStackTrace();
136     }
137     this.actors = actor;
138     if (actors!=null) {
139       for (int i=0; i<actors.size(); i++) {
140         Actor tempAct = (Actor) actors.elementAt(i);
141         actorBox.addItem(tempAct.getID());
142       }
143       actorBox.setSelectedIndex(0);
144     }
145   }
146 
147   // component initialization.
148   private void jbInit() throws Exception {
149     panel1.setLayout(borderLayout1);
150     this.setResizable(true);
151     jPanel2.setLayout(gridLayout1);
152     jPanel3.setLayout(gridLayout4);
153     jPanel5.setLayout(gridLayout10);
154     jPanel4.setBorder(null);
155     jPanel4.setDebugGraphicsOptions(0);
156     jPanel4.setLayout(gridLayout7);
157     jPanel6.setLayout(gridLayout11);
158     jPanel7.setLayout(gridLayout12);
159     closeButton.setText("Close");
160     closeButton.addActionListener(new ShowActorDialog_closeButton_actionAdapter(this));
161     jPanel9.setLayout(gridLayout13);
162     jPanel1.setBorder(BorderFactory.createEtchedBorder());
163     jPanel1.setMaximumSize(new Dimension(2147483647, 2147483647));
164     jPanel1.setLayout(gridLayout22);
165     nameLabel.setAlignmentX((float) 0.0);
166     nameLabel.setText("myName");
167     jLabel2.setFont(new java.awt.Font("Dialog", 1, 11));
168     jLabel2.setAlignmentX((float) 0.0);
169     jLabel2.setAlignmentY((float) 0.5);
170     jLabel2.setBorder(null);
171     jLabel2.setDoubleBuffered(false);
172     jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
173     jLabel2.setText("Name");
174     jPanel10.setLayout(gridLayout3);
175     jPanel11.setLayout(gridLayout2);
176     jPanel11.setBorder(null);
177     jPanel10.setBorder(null);
178     jLabel1.setFont(new java.awt.Font("Dialog", 1, 11));
179     jLabel1.setForeground(Color.black);
180     jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
181     jLabel1.setText("Title");
182     titleLabel.setText("mytitle");
183     jPanel13.setLayout(gridLayout5);
184     jPanel12.setLayout(gridLayout6);
185     gridLayout1.setHgap(10);
186     gridLayout6.setHgap(10);
187     gridLayout4.setColumns(0);
188     gridLayout4.setHgap(10);
189     gridLayout7.setColumns(0);
190     gridLayout7.setHgap(10);
191     jLabel3.setFont(new java.awt.Font("Dialog", 1, 11));
192     jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
193     jLabel3.setText("Phone");
194     jLabel3.setVerticalAlignment(SwingConstants.CENTER);
195     jLabel3.setVerticalTextPosition(SwingConstants.CENTER);
196     phoneLabel.setToolTipText("");
197     phoneLabel.setText("myPhone");
198     jPanel15.setLayout(gridLayout8);
199     jPanel14.setLayout(gridLayout9);
200     jLabel4.setFont(new java.awt.Font("Dialog", 1, 11));
201     jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
202     jLabel4.setText("Fax");
203     faxLabel.setToolTipText("");
204     faxLabel.setText("myFax");
205     jLabel6.setFont(new java.awt.Font("Dialog", 1, 11));
206     jLabel6.setHorizontalAlignment(SwingConstants.RIGHT);
207     jLabel6.setText("Email");
208     emailLabel.setText("myEmail");
209     jLabel8.setFont(new java.awt.Font("Dialog", 1, 11));
210     jLabel8.setHorizontalAlignment(SwingConstants.RIGHT);
211     jLabel8.setText("Physical Address");
212     physAdressLabel.setText("myAddress");
213     jLabel10.setFont(new java.awt.Font("Dialog", 1, 11));
214     jLabel10.setHorizontalAlignment(SwingConstants.RIGHT);
215     jLabel10.setText("webURL");
216     urlLabel.setVerifyInputWhenFocusTarget(true);
217     urlLabel.setText("myURL");
218     jPanel16.setLayout(gridLayout14);
219     jPanel17.setLayout(gridLayout15);
220     jPanel18.setLayout(gridLayout16);
221     jPanel19.setLayout(gridLayout17);
222     jPanel20.setLayout(gridLayout18);
223     jPanel21.setLayout(gridLayout19);
224     jPanel22.setLayout(gridLayout20);
225     jPanel23.setLayout(gridLayout21);
226     gridLayout10.setColumns(0);
227     gridLayout10.setHgap(10);
228     gridLayout11.setHgap(10);
229     gridLayout12.setHgap(10);
230     gridLayout13.setHgap(10);
231     gridLayout22.setColumns(1);
232     gridLayout22.setRows(7);
233     jPanel2.setBorder(null);
234     jPanel3.setBorder(null);
235     jPanel5.setBorder(null);
236     jPanel6.setBorder(null);
237     jPanel7.setBorder(null);
238     jPanel24.setLayout(gridLayout23);
239     actorBox.addItemListener(new ShowActorDialog_actorBox_itemAdapter(this));
240     getContentPane().add(panel1);
241     panel1.add(jPanel24,BorderLayout.NORTH);
242     jPanel24.add(actorBox, null);
243     panel1.add(jPanel1,  BorderLayout.CENTER);
244     panel1.add(jPanel8, BorderLayout.SOUTH);
245     jPanel8.add(closeButton, null);
246     jPanel1.add(jPanel2, null);
247     jPanel2.add(jPanel11, null);
248     jPanel11.add(jLabel2, null);
249     jPanel2.add(jPanel10, null);
250     jPanel10.add(nameLabel, null);
251     jPanel1.add(jPanel3, null);
252     jPanel1.add(jPanel4, null);
253     jPanel1.add(jPanel5, null);
254     jPanel1.add(jPanel6, null);
255     jPanel1.add(jPanel7, null);
256     jPanel1.add(jPanel9, null);
257     jPanel3.add(jPanel12, null);
258     jPanel12.add(jLabel1, null);
259     jPanel3.add(jPanel13, null);
260     jPanel13.add(titleLabel, null);
261     jPanel4.add(jPanel14, null);
262     jPanel14.add(jLabel3, null);
263     jPanel4.add(jPanel15, null);
264     jPanel15.add(phoneLabel, null);
265     jPanel5.add(jPanel16, null);
266     jPanel16.add(jLabel4, null);
267     jPanel5.add(jPanel17, null);
268     jPanel17.add(faxLabel, null);
269     jPanel6.add(jPanel18, null);
270     jPanel18.add(jLabel6, null);
271     jPanel6.add(jPanel19, null);
272     jPanel19.add(emailLabel, null);
273     jPanel7.add(jPanel20, null);
274     jPanel20.add(jLabel8, null);
275     jPanel7.add(jPanel21, null);
276     jPanel21.add(physAdressLabel, null);
277     jPanel9.add(jPanel22, null);
278     jPanel22.add(jLabel10, null);
279     jPanel9.add(jPanel23, null);
280     jPanel23.add(urlLabel, null);
281   }
282 
283   /***
284    * Displays the contact information.
285    */
286   private void initFields(Actor actor) {
287     if (actor==null) {
288       return;
289     }
290     if (actor.getEmail()!=null) {
291       emailLabel.setText(actor.getEmail());
292     } else {
293       emailLabel.setText("N/A");
294     }
295     if (actor.getFax()!=null) {
296       faxLabel.setText(actor.getFax());
297     } else {
298       faxLabel.setText("N/A");
299     }
300     if (actor.getName()!=null) {
301       nameLabel.setText(actor.getName());
302     } else {
303       nameLabel.setText("N/A");
304     }
305     if (actor.getPhone()!=null) {
306       phoneLabel.setText(actor.getPhone());
307     } else {
308       phoneLabel.setText("N/A");
309     }
310     if (actor.getPhysicalAddress()!=null) {
311       physAdressLabel.setText(actor.getPhysicalAddress());
312     } else {
313       physAdressLabel.setText("N/A");
314     }
315     if (actor.getTitle()!=null) {
316       titleLabel.setText(actor.getTitle());
317     } else {
318       titleLabel.setText("N/A");
319     }
320     if (actor.getWebURL()!=null) {
321       urlLabel.setText(actor.getWebURL());
322     } else {
323       urlLabel.setText("N/A");
324     }
325   }
326 
327   // Is called when the user clicks the 'close' button.
328   void closeButton_actionPerformed(ActionEvent e) {
329     this.hide();
330   }
331 
332   // is called when the user changes the contact information
333   void actorBox_itemStateChanged(ItemEvent e) {
334     String ID = actorBox.getSelectedItem().toString();
335     if (actors!=null) {
336       for (int i = 0; i < actors.size(); i++) {
337         Actor tempAct = (Actor) actors.elementAt(i);
338         if (ID.equals(tempAct.getID())) {
339           initFields(tempAct);
340           return;
341         }
342       }
343     }
344   }
345 
346 }
347 
348 // -----------------------------------------
349 // ------- AUTO GENERATED CLASSES ----------
350 // -----------------------------------------
351 class ShowActorDialog_closeButton_actionAdapter implements java.awt.event.ActionListener {
352   ShowActorDialog adaptee;
353   ShowActorDialog_closeButton_actionAdapter(ShowActorDialog adaptee) {
354     this.adaptee = adaptee;
355   }
356   public void actionPerformed(ActionEvent e) {
357     adaptee.closeButton_actionPerformed(e);
358   }
359 }
360 
361 class ShowActorDialog_actorBox_itemAdapter implements java.awt.event.ItemListener {
362   ShowActorDialog adaptee;
363 
364   ShowActorDialog_actorBox_itemAdapter(ShowActorDialog adaptee) {
365     this.adaptee = adaptee;
366   }
367   public void itemStateChanged(ItemEvent e) {
368     adaptee.actorBox_itemStateChanged(e);
369   }
370 }