1 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 32 final class CatalogMounterPanel extends javax.swing.JPanel implements ChangeListener { 33 34 35 private static final long serialVersionUID =-1208422697106159058L; 36 37 private CatalogMounterModel model; 38 39 40 public CatalogMounterPanel(CatalogMounterModel model) { 41 this.model = model; 42 initComponents(); 43 initAccessibility(); 44 this.catalogLabel.setDisplayedMnemonic(Util.THIS.getChar("CatalogMounterPanel.catalogLabel.mne")); 46 catalogComboBox.setModel(model.getCatalogComboBoxModel()); 47 updateCatalogPanel(); 48 49 model.addChangeListener(this); 50 } 51 52 56 private Dimension comboSize(int columns) { 57 JTextField template = new JTextField(); 58 template.setColumns(columns); 59 return template.getPreferredSize(); 60 } 61 62 63 68 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 70 71 catalogLabel = new javax.swing.JLabel (); 72 catalogComboBox = new javax.swing.JComboBox (); 73 parentPanel = new javax.swing.JPanel (); 74 75 setLayout(new java.awt.GridBagLayout ()); 76 77 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (4, 4, 4, 4))); 78 setMinimumSize(new java.awt.Dimension (380, 100)); 79 catalogLabel.setText(Util.THIS.getString ("CatalogMounterPanel.catalogLabel.text")); 80 catalogLabel.setLabelFor(catalogComboBox); 81 gridBagConstraints = new java.awt.GridBagConstraints (); 82 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 83 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 84 add(catalogLabel, gridBagConstraints); 85 86 catalogComboBox.setPreferredSize(comboSize(40)); 87 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (12, 12, 0, 11); 93 add(catalogComboBox, gridBagConstraints); 94 95 parentPanel.setLayout(new java.awt.BorderLayout ()); 96 97 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (12, 12, 0, 11); 104 add(parentPanel, gridBagConstraints); 105 106 } 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 private javax.swing.JComboBox catalogComboBox; 124 private javax.swing.JLabel catalogLabel; 125 private javax.swing.JPanel parentPanel; 126 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 |