View Javadoc

1   
2   package org.xrn.gui;
3   
4   import java.awt.Color;
5   import java.awt.event.ActionEvent;
6   import java.awt.event.ActionListener;
7   
8   import javax.swing.JComponent;
9   import javax.swing.JLabel;
10  import javax.swing.JPanel;
11  import javax.swing.JTextField;
12  import javax.swing.border.TitledBorder;
13  
14  import org.xrn.xsd2java.ReleaseNotesType.ComponentsType.ComponentType;
15  import org.xrn.xsd2java.impl.ComponentImpl;
16  import org.xrn.xsd2java.impl.ReleaseNotesTypeImpl.ComponentsTypeImpl.ComponentTypeImpl;
17  
18  /*
19   * 
20   * The component panel - show one component
21   * @author Carsten Maneg
22   * Date Nov 12, 2004
23   * Time 11:10:59 PM
24   */
25  public class OneComponentPanel extends JPanel implements ActionListener{
26      
27      private JPanel panelOwner;
28      
29      private JLabel idLabel = new JLabel( "Name (ID)" );
30      private JTextField idField = new JTextField();
31      private JLabel hrefLabel = new JLabel( "HREF" );
32      private JTextField hrefField = new JTextField();
33      private JLabel xmlLabel = new JLabel( "XML" );
34      private JTextField xmlField = new JTextField();
35  //    private JLabel versionLabel = new JLabel( "Version" );
36  //    private JTextField versionField = new JTextField();
37      
38      private ComponentImpl featureComponent = null;
39      private ComponentType component = new ComponentTypeImpl();
40                     
41      /***
42       * Constructor
43       * @param owner - parent of the panel
44       */
45      public OneComponentPanel( JPanel owner ){
46    	
47          setBorder( new TitledBorder( " Component " ) );
48          setLayout( null );
49          
50          panelOwner = owner;
51          
52          idLabel.setFont( XRNConstants.FONT_BOLD );
53          
54          dlgObjHinzufuegen( idLabel, 20, 25, 60, 20 ); 
55          dlgObjHinzufuegen( idField, 80, 25, 200, 20 ); 
56          dlgObjHinzufuegen( hrefLabel, 20, 55, 50, 20 ); 
57          dlgObjHinzufuegen( hrefField, 80, 55, 200, 20 ); 
58          dlgObjHinzufuegen( xmlLabel, 20, 85, 50, 20 ); 
59          dlgObjHinzufuegen( xmlField, 80, 85, 200, 20 );        
60      }
61  
62      /***
63       * 
64       * @param c
65       * @param x0
66       * @param y0
67       * @param width
68       * @param height
69       */
70      public void dlgObjHinzufuegen( JComponent c, int x0, int y0, int width, int height ){
71          c.setBounds( x0, y0, width, height );
72          c.setForeground( Color.black );
73          add(c);
74      }
75      
76      /***
77       * 
78       */
79      public void actionPerformed( ActionEvent e ){
80    	
81      }
82      
83      /***
84       * Delete the input fields
85       *
86       */
87      public void resetFields( ){
88          idField.setText( "" );
89          hrefField.setText( "" );
90          xmlField.setText( "" );
91      }    
92      
93      /***
94       * 
95       * @return
96       */
97      public ComponentType getComponent(){
98          component = new ComponentTypeImpl();
99          component.setID( idField.getText() );
100         component.setHref( hrefField.getText() );
101         component.setXml( xmlField.getText() );
102         return component;        
103     }
104     
105     /***
106      * 
107      * @param comp
108      */
109     public void setComponent( ComponentType comp ){
110         this.component = comp;
111         if( component != null ){
112             idField.setText( component.getID() );
113             hrefField.setText( component.getHref() );
114             xmlField.setText( component.getXml() );
115         }        
116     }
117 }