KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > catalog > CatalogMounterPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.catalog;
20
21 import java.awt.*;
22 import java.beans.*;
23
24 import javax.swing.*;
25 import javax.swing.event.*;
26
27 /**
28  * Panel for selecting catalog providers showing customizer for selected one.
29  *
30  * @author Petr Kuzel
31  */

32 final class CatalogMounterPanel extends javax.swing.JPanel JavaDoc implements ChangeListener {
33
34     /** Serial Version UID */
35     private static final long serialVersionUID =-1208422697106159058L;
36
37     private CatalogMounterModel model;
38
39     /** Creates new form CatalogMounterPanel */
40     public CatalogMounterPanel(CatalogMounterModel model) {
41         this.model = model;
42         initComponents();
43         initAccessibility();
44         this.catalogLabel.setDisplayedMnemonic(Util.THIS.getChar("CatalogMounterPanel.catalogLabel.mne")); // NOI18N
45

46         catalogComboBox.setModel(model.getCatalogComboBoxModel());
47         updateCatalogPanel();
48         
49         model.addChangeListener(this);
50     }
51
52     /**
53      * Compute preffered dimension for combo with
54      * particulal number of columns
55      */

56     private Dimension comboSize(int columns) {
57         JTextField template = new JTextField();
58         template.setColumns(columns);
59         return template.getPreferredSize();
60     }
61     
62     
63     /** This method is called from within the constructor to
64      * initialize the form.
65      * WARNING: Do NOT modify this code. The content of this method is
66      * always regenerated by the Form Editor.
67      */

68     private void initComponents() {//GEN-BEGIN:initComponents
69
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
70
71         catalogLabel = new javax.swing.JLabel JavaDoc();
72         catalogComboBox = new javax.swing.JComboBox JavaDoc();
73         parentPanel = new javax.swing.JPanel JavaDoc();
74
75         setLayout(new java.awt.GridBagLayout JavaDoc());
76
77         setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(4, 4, 4, 4)));
78         setMinimumSize(new java.awt.Dimension JavaDoc(380, 100));
79         catalogLabel.setText(Util.THIS.getString ("CatalogMounterPanel.catalogLabel.text"));
80         catalogLabel.setLabelFor(catalogComboBox);
81         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
82         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
83         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
84         add(catalogLabel, gridBagConstraints);
85
86         catalogComboBox.setPreferredSize(comboSize(40));
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
89         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
90         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
91         gridBagConstraints.weightx = 1.0;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
93         add(catalogComboBox, gridBagConstraints);
94
95         parentPanel.setLayout(new java.awt.BorderLayout JavaDoc());
96
97         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
98         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
99         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
100         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
101         gridBagConstraints.weightx = 1.0;
102         gridBagConstraints.weighty = 1.0;
103         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
104         add(parentPanel, gridBagConstraints);
105
106     }//GEN-END:initComponents
107

108     private void updateCatalogPanel() {
109         Customizer cust = model.getCatalogCustomizer();
110         cust.setObject(model.getCatalog());
111         invalidate();
112         parentPanel.removeAll();
113         Component catalogPanel = (Component) cust;
114         parentPanel.add(catalogPanel, BorderLayout.CENTER);
115         validate();
116     }
117     
118     public void stateChanged(ChangeEvent e) {
119         updateCatalogPanel();
120     }
121
122     // Variables declaration - do not modify//GEN-BEGIN:variables
123
private javax.swing.JComboBox JavaDoc catalogComboBox;
124     private javax.swing.JLabel JavaDoc catalogLabel;
125     private javax.swing.JPanel JavaDoc parentPanel;
126     // End of variables declaration//GEN-END:variables
127

128     private void initAccessibility(){
129         catalogComboBox.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_catalogComboBox"));
130         this.getAccessibleContext().setAccessibleName(Util.THIS.getString("ACSN_CatalogMounterPanel"));
131         this.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_CatalogMounterPanel"));
132         
133     }
134     
135 }
136
Popular Tags