1 19 package org.netbeans.modules.xml.catalog.impl; 20 21 import java.beans.*; 22 import java.io.File ; 23 import java.net.MalformedURLException ; 24 25 31 public class XCatalogCustomizer extends javax.swing.JPanel implements Customizer { 32 33 34 private static final long serialVersionUID =-1437233290256708363L; 35 36 XCatalog model = null; 37 38 39 public XCatalogCustomizer() { 40 initComponents (); 41 42 this.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_XCatalogCustomizer")); 43 locationLabel.setDisplayedMnemonic((Util.THIS.getString("XCatalogCustomizer.locationLabel.mne")).charAt(0)); 44 locationTextField.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_locationTextField")); 45 } 46 47 52 private void initComponents() { 54 java.awt.GridBagConstraints gridBagConstraints; 55 56 locationLabel = new javax.swing.JLabel (); 57 locationTextField = new javax.swing.JTextField (); 58 descTextArea = new javax.swing.JTextArea (); 59 selectButton = new javax.swing.JButton (); 60 61 setLayout(new java.awt.GridBagLayout ()); 62 63 locationLabel.setLabelFor(locationTextField); 64 locationLabel.setText(Util.THIS.getString ("XCatalogCustomizer.locationLabel.text")); 65 add(locationLabel, new java.awt.GridBagConstraints ()); 66 67 locationTextField.setColumns(20); 68 locationTextField.addActionListener(new java.awt.event.ActionListener () { 69 public void actionPerformed(java.awt.event.ActionEvent evt) { 70 locationTextFieldActionPerformed(evt); 71 } 72 }); 73 locationTextField.addFocusListener(new java.awt.event.FocusAdapter () { 74 public void focusLost(java.awt.event.FocusEvent evt) { 75 locationTextFieldFocusLost(evt); 76 } 77 }); 78 79 gridBagConstraints = new java.awt.GridBagConstraints (); 80 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 81 gridBagConstraints.weightx = 1.0; 82 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 83 add(locationTextField, gridBagConstraints); 84 85 descTextArea.setEditable(false); 86 descTextArea.setFont(javax.swing.UIManager.getFont ("Label.font")); 87 descTextArea.setForeground(new java.awt.Color (102, 102, 153)); 88 descTextArea.setLineWrap(true); 89 descTextArea.setText(Util.THIS.getString("DESC_xcatalog_fmts")); 90 descTextArea.setWrapStyleWord(true); 91 descTextArea.setDisabledTextColor(javax.swing.UIManager.getColor ("Label.foreground")); 92 descTextArea.setEnabled(false); 93 descTextArea.setOpaque(false); 94 gridBagConstraints = new java.awt.GridBagConstraints (); 95 gridBagConstraints.gridx = 0; 96 gridBagConstraints.gridy = 1; 97 gridBagConstraints.gridwidth = 3; 98 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 99 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 100 gridBagConstraints.weightx = 1.0; 101 gridBagConstraints.weighty = 1.0; 102 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 103 add(descTextArea, gridBagConstraints); 104 105 selectButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/catalog/impl/Bundle").getString("PROP_choose_file")); 106 selectButton.addActionListener(new java.awt.event.ActionListener () { 107 public void actionPerformed(java.awt.event.ActionEvent evt) { 108 selectButtonActionPerformed(evt); 109 } 110 }); 111 112 gridBagConstraints = new java.awt.GridBagConstraints (); 113 gridBagConstraints.gridx = 2; 114 gridBagConstraints.gridy = 0; 115 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 116 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 117 add(selectButton, gridBagConstraints); 118 119 } 121 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; 124 try { 125 String location = f.toURL().toExternalForm(); 126 locationTextField.setText(location); 127 model.setLocation(location); 128 } catch (MalformedURLException ex) { 129 } 131 } 133 135 private void locationTextFieldFocusLost(java.awt.event.FocusEvent evt) { if ( Util.THIS.isLoggable() ) Util.THIS.debug("FocusLost-setting location: " + locationTextField.getText()); model.setSource(locationTextField.getText()); 138 } 140 private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) { if ( Util.THIS.isLoggable() ) Util.THIS.debug("ActionPerformed-setting location: " + locationTextField.getText()); model.setSource(locationTextField.getText()); 143 } 145 148 public void setObject(java.lang.Object peer) { 149 if ((peer instanceof XCatalog) == false) { 150 throw new IllegalArgumentException ("XCatalog instance expected (" + peer.getClass() + ")."); } 152 153 model = (XCatalog) peer; 154 locationTextField.setText(model.getSource()); 155 } 156 157 public void addPropertyChangeListener(java.beans.PropertyChangeListener p1) { 158 } 159 160 public void removePropertyChangeListener(java.beans.PropertyChangeListener p1) { 161 } 162 163 private javax.swing.JTextArea descTextArea; 165 private javax.swing.JLabel locationLabel; 166 private javax.swing.JTextField locationTextField; 167 private javax.swing.JButton selectButton; 168 170 } 171 | Popular Tags |