KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > elements > specialpanels > XMLFormalParametersRelatedComboButtonPanel


1 /* XMLComboButtonPanel.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.xml.elements.specialpanels;
12
13 import java.awt.event.ActionEvent JavaDoc;
14 import java.awt.event.ActionListener JavaDoc;
15 import javax.swing.JComboBox JavaDoc;
16 import org.enhydra.jawe.xml.XMLChoice;
17 import org.enhydra.jawe.xml.XMLCollection;
18 import org.enhydra.jawe.xml.XMLComplexElement;
19 import org.enhydra.jawe.xml.XMLElement;
20 import org.enhydra.jawe.xml.elements.FormalParameters;
21 import org.enhydra.jawe.xml.panels.XMLComboButtonPanel;
22 import org.enhydra.jawe.xml.panels.XMLGroupPanel;
23
24 /**
25  * Creates panel with JLabel, JComboBox and shortcut button.
26  */

27 public class XMLFormalParametersRelatedComboButtonPanel extends XMLComboButtonPanel {
28
29    public XMLFormalParametersRelatedComboButtonPanel (
30       XMLElement myOwner,
31       XMLCollection c) {
32
33       super(myOwner,c);
34
35       final JComboBox JavaDoc jcb=getComboBox();
36
37       jcb.addActionListener(new ActionListener JavaDoc() {
38                public void actionPerformed(ActionEvent JavaDoc ae) {
39                   XMLComplexElement choosen=(XMLComplexElement)jcb.getSelectedItem();
40                   FormalParameters formalParams=(FormalParameters)choosen.get("FormalParameters");
41                   if (formalParams==null) { // 'selected' is instance of Application
42
Object JavaDoc tmp=choosen.get("Choice");
43                      tmp=((XMLChoice)tmp).getChoosen();
44                      if (tmp instanceof FormalParameters) {
45                         formalParams=(FormalParameters)tmp;
46                      }
47                   }
48
49                   XMLGroupPanel gp=(XMLGroupPanel)getParent();
50                   // if the position of ActualParameters' panel change on Tool
51
// or SubFlow panel, getComponent(2) should be also changed
52
XMLActualParametersPanel app=(XMLActualParametersPanel)
53                      ((XMLGroupPanel)gp.getComponent(2)).getComponent(0);
54
55                   app.setFormalParameters(formalParams);
56                }
57             });
58
59    }
60
61 }
62
63
Popular Tags