KickJava   Java API By Example, From Geeks To Geeks.

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


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.XMLComboPanel;
22 import org.enhydra.jawe.xml.panels.XMLGroupPanel;
23 import org.enhydra.jawe.xml.panels.XMLPanel;
24
25 /**
26  * Creates panel with JLabel, JComboBox and shortcut button.
27  */

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