1 19 package org.netbeans.modules.xml.catalog.impl.sun; 20 21 import java.beans.*; 22 import java.io.File ; 23 import java.net.MalformedURLException ; 24 25 32 public class CatalogCustomizer extends javax.swing.JPanel implements Customizer { 33 34 35 private static final long serialVersionUID =-1437233290256708364L; 36 37 Catalog model = null; 38 39 40 public CatalogCustomizer() { 41 initComponents (); 42 43 this.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_CatalogCustomizer")); 45 46 locationLabel.setDisplayedMnemonic((Util.THIS.getString("CatalogCustomizer.locationLabel.mne")).charAt(0)); 47 locationTextField.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_locationTextField")); 48 49 preferCheckBox.setMnemonic(Util.THIS.getString("MNE_preference").charAt(0)); 50 preferCheckBox.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_preference")); 51 52 selectButton.setMnemonic(Util.THIS.getString("MNE_file").charAt(0)); 53 selectButton.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_file")); 54 } 55 56 61 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 63 64 locationLabel = new javax.swing.JLabel (); 65 locationTextField = new javax.swing.JTextField (); 66 selectButton = new javax.swing.JButton (); 67 preferCheckBox = new javax.swing.JCheckBox (); 68 descTextArea = new javax.swing.JTextArea (); 69 70 FormListener formListener = new FormListener(); 71 72 setLayout(new java.awt.GridBagLayout ()); 73 74 locationLabel.setLabelFor(locationTextField); 75 locationLabel.setText(Util.THIS.getString ("CatalogCustomizer.locationLabel.text")); 76 add(locationLabel, new java.awt.GridBagConstraints ()); 77 78 locationTextField.setColumns(40); 79 locationTextField.addActionListener(formListener); 80 locationTextField.addFocusListener(formListener); 81 82 gridBagConstraints = new java.awt.GridBagConstraints (); 83 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 84 gridBagConstraints.weightx = 1.0; 85 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 86 add(locationTextField, gridBagConstraints); 87 88 selectButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/catalog/impl/sun/Bundle").getString("PROP_choose_file")); 89 selectButton.addActionListener(formListener); 90 91 gridBagConstraints = new java.awt.GridBagConstraints (); 92 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 93 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 94 add(selectButton, gridBagConstraints); 95 96 preferCheckBox.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/catalog/impl/sun/Bundle").getString("LBL_preference")); 97 preferCheckBox.setToolTipText(Util.THIS.getString("HINT_pp")); 98 preferCheckBox.addChangeListener(formListener); 99 100 gridBagConstraints = new java.awt.GridBagConstraints (); 101 gridBagConstraints.gridx = 1; 102 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 103 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 104 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 105 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 106 add(preferCheckBox, gridBagConstraints); 107 108 descTextArea.setColumns(40); 109 descTextArea.setEditable(false); 110 descTextArea.setFont(javax.swing.UIManager.getFont ("Label.font")); 111 descTextArea.setForeground(new java.awt.Color (102, 102, 153)); 112 descTextArea.setLineWrap(true); 113 descTextArea.setRows(4); 114 descTextArea.setText(Util.THIS.getString("DESC_catalog_fmts")); 115 descTextArea.setWrapStyleWord(true); 116 descTextArea.setDisabledTextColor(javax.swing.UIManager.getColor ("Label.foreground")); 117 descTextArea.setEnabled(false); 118 descTextArea.setOpaque(false); 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 121 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 122 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 123 gridBagConstraints.weightx = 1.0; 124 gridBagConstraints.weighty = 1.0; 125 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 126 add(descTextArea, gridBagConstraints); 127 128 } 129 130 132 private class FormListener implements java.awt.event.ActionListener , java.awt.event.FocusListener , javax.swing.event.ChangeListener { 133 public void actionPerformed(java.awt.event.ActionEvent evt) { 134 if (evt.getSource() == locationTextField) { 135 CatalogCustomizer.this.locationTextFieldActionPerformed(evt); 136 } 137 else if (evt.getSource() == selectButton) { 138 CatalogCustomizer.this.selectButtonActionPerformed(evt); 139 } 140 } 141 142 public void focusGained(java.awt.event.FocusEvent evt) { 143 } 144 145 public void focusLost(java.awt.event.FocusEvent evt) { 146 if (evt.getSource() == locationTextField) { 147 CatalogCustomizer.this.locationTextFieldFocusLost(evt); 148 } 149 } 150 151 public void stateChanged(javax.swing.event.ChangeEvent evt) { 152 if (evt.getSource() == preferCheckBox) { 153 CatalogCustomizer.this.preferCheckBoxStateChanged(evt); 154 } 155 } 156 } 158 private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) { File f = org.netbeans.modules.xml.catalog.lib.Util.selectCatalogFile("txt xml cat catalog"); if (f == null) return; 161 try { 162 String location = f.toURL().toExternalForm(); 163 locationTextField.setText(location); 164 model.setLocation(location); 165 } catch (MalformedURLException ex) { 166 } 168 } 170 private void preferCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) { if (model != null) model.setPreferPublic(preferCheckBox.isSelected()); 172 } 174 176 private void locationTextFieldFocusLost(java.awt.event.FocusEvent evt) { if ( Util.THIS.isLoggable() ) Util.THIS.debug("FocusLost-setting location: " + locationTextField.getText()); model.setLocation(locationTextField.getText()); 179 } 181 private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) { if ( Util.THIS.isLoggable() ) Util.THIS.debug("ActionPerformed-setting location: " + locationTextField.getText()); model.setLocation(locationTextField.getText()); 184 } 186 189 public void setObject(java.lang.Object peer) { 190 if ((peer instanceof Catalog) == false) { 191 throw new IllegalArgumentException ("Catalog instance expected (" + peer.getClass() + ")."); } 193 194 model = (Catalog) peer; 195 locationTextField.setText(model.getLocation()); 196 preferCheckBox.setSelected(model.isPreferPublic()); 197 } 198 199 public void addPropertyChangeListener(java.beans.PropertyChangeListener p1) { 200 } 201 202 public void removePropertyChangeListener(java.beans.PropertyChangeListener p1) { 203 } 204 205 private javax.swing.JTextArea descTextArea; 207 private javax.swing.JLabel locationLabel; 208 private javax.swing.JTextField locationTextField; 209 private javax.swing.JCheckBox preferCheckBox; 210 private javax.swing.JButton selectButton; 211 213 } 214 | Popular Tags |