KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* XMLDataTypesPanel.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
12 package org.enhydra.jawe.xml.elements.specialpanels;
13
14 import org.enhydra.jawe.xml.*;
15 import org.enhydra.jawe.xml.elements.*;
16 import org.enhydra.jawe.xml.panels.*;
17
18 import java.util.*;
19 import javax.swing.*;
20 import java.awt.*;
21 import java.awt.event.*;
22
23 /**
24 * Creates a combo panel and a panel which type is determined by the
25 * choosen element from combo panel.
26 */

27 public class XMLComplexContentPanel extends XMLMultiLineTextPanel {
28
29    public XMLComplexContentPanel (XMLElement myOwner,
30    final org.enhydra.jawe.xml.elements.Package pkg) {
31       super(myOwner,XMLPanel.BOX_LAYOUT,false,true,false);
32
33       String JavaDoc s=XMLUtil.getLanguageDependentString("NamespacesKey");
34       double w=0;
35       try {
36          w=getFontMetrics(getFont()).stringWidth(s);
37       } catch(Exception JavaDoc ex) {}
38       double h=getFontMetrics(getFont()).getHeight();
39       w+=25;
40       if (w<30) w=30;
41       Dimension dim=new Dimension((int)w,(int)h);
42
43       XMLButton buttonDefine=new XMLButton(s,"Define",dim);
44       buttonDefine.setAlignmentX(Component.LEFT_ALIGNMENT);
45       buttonDefine.setAlignmentY(Component.TOP_ALIGNMENT);
46       buttonDefine.setEnabled(!myOwner.isReadOnly());
47       buttonDefine.setToolTipText(XMLUtil.getLanguageDependentString("DefineAdditionalNamespacesKey"));
48       // action listener for defining new element
49
buttonDefine.addActionListener(new ActionListener(){
50          public void actionPerformed(ActionEvent ae){
51             if (pkg==null) return;
52             XMLPanel p=pkg.getPanel(10);
53             XMLElementDialog d=new XMLElementDialog(getDialog(),
54                   XMLUtil.getLanguageDependentString("PackageKey")+" '"+
55                   pkg.toString()+"' - "+
56                   XMLUtil.getLanguageDependentString("NamespacesKey"));
57             d.editXMLElement(p,false,false);
58          }
59
60       });
61
62       add(Box.createRigidArea(new Dimension(10,0)));
63       add(buttonDefine);
64
65    }
66
67 }
68
Popular Tags