1 18 package org.netbeans.modules.changelog.html; 19 20 24 25 import org.openide.util.*; 26 import javax.swing.event.*; 27 import javax.swing.*; 28 import org.netbeans.modules.changelog.*; 29 30 31 public class HtmlPanelCustomizer extends javax.swing.JPanel implements java.beans.Customizer { 32 33 ChangeLogHTMLService service; 34 private boolean disableFiring = false; 35 36 public HtmlPanelCustomizer() { 37 initComponents(); 38 java.awt.event.ActionListener actionList = new java.awt.event.ActionListener () { 39 public void actionPerformed(java.awt.event.ActionEvent evt) { 40 setData(); 41 } 42 }; 43 txCVSROOT.addActionListener(actionList); 44 txDiffURL.addActionListener(actionList); 45 txRevisionURL.addActionListener(actionList); 46 javax.swing.event.DocumentListener docList = new javax.swing.event.DocumentListener () { 47 public void insertUpdate(javax.swing.event.DocumentEvent e) { 48 setData(); 49 } 50 public void removeUpdate(javax.swing.event.DocumentEvent e) { 51 setData(); 52 } 53 public void changedUpdate(javax.swing.event.DocumentEvent e) { 54 } 56 }; 57 txCVSROOT.getDocument().addDocumentListener(docList); 58 txDiffURL.getDocument().addDocumentListener(docList); 59 txRevisionURL.getDocument().addDocumentListener(docList); 60 taExplanation.setBackground(this.getBackground()); 62 } 63 64 69 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 71 72 lblDiffURL = new javax.swing.JLabel (); 73 txDiffURL = new javax.swing.JTextField (); 74 lblRevisionURL = new javax.swing.JLabel (); 75 txRevisionURL = new javax.swing.JTextField (); 76 spExplanation = new javax.swing.JScrollPane (); 77 taExplanation = new javax.swing.JTextArea (); 78 lblCVSROOT = new javax.swing.JLabel (); 79 txCVSROOT = new javax.swing.JTextField (); 80 81 setLayout(new java.awt.GridBagLayout ()); 82 83 setPreferredSize(new java.awt.Dimension (600, 300)); 84 setMinimumSize(new java.awt.Dimension (400, 200)); 85 lblDiffURL.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblDiffURL")); 86 gridBagConstraints = new java.awt.GridBagConstraints (); 87 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 88 gridBagConstraints.insets = new java.awt.Insets (12, 12, 6, 6); 89 add(lblDiffURL, gridBagConstraints); 90 91 txDiffURL.setText("jTextField1"); 92 gridBagConstraints = new java.awt.GridBagConstraints (); 93 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 94 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 95 gridBagConstraints.insets = new java.awt.Insets (12, 0, 6, 12); 96 add(txDiffURL, gridBagConstraints); 97 98 lblRevisionURL.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblRevisionURL.text")); 99 gridBagConstraints = new java.awt.GridBagConstraints (); 100 gridBagConstraints.gridx = 0; 101 gridBagConstraints.gridy = 1; 102 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 103 gridBagConstraints.insets = new java.awt.Insets (0, 12, 6, 6); 104 add(lblRevisionURL, gridBagConstraints); 105 106 txRevisionURL.setText("jTextField2"); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 1; 109 gridBagConstraints.gridy = 1; 110 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 111 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 112 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 12); 113 add(txRevisionURL, gridBagConstraints); 114 115 taExplanation.setEditable(false); 116 taExplanation.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.taExplanation.text")); 117 spExplanation.setViewportView(taExplanation); 118 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridx = 0; 121 gridBagConstraints.gridy = 2; 122 gridBagConstraints.gridwidth = 2; 123 gridBagConstraints.gridheight = 2; 124 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 125 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 126 gridBagConstraints.weightx = 0.5; 127 gridBagConstraints.weighty = 0.5; 128 gridBagConstraints.insets = new java.awt.Insets (0, 12, 6, 12); 129 add(spExplanation, gridBagConstraints); 130 131 lblCVSROOT.setLabelFor(txCVSROOT); 132 lblCVSROOT.setText(org.openide.util.NbBundle.getBundle(HtmlPanelCustomizer.class).getString("HtmlPanel.lblCVSROOT.text")); 133 gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.gridx = 0; 135 gridBagConstraints.gridy = 4; 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 137 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 6); 138 add(lblCVSROOT, gridBagConstraints); 139 140 txCVSROOT.setPreferredSize(new java.awt.Dimension (150, 20)); 141 txCVSROOT.setMinimumSize(new java.awt.Dimension (50, 22)); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 1; 144 gridBagConstraints.gridy = 4; 145 gridBagConstraints.ipadx = 45; 146 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 147 gridBagConstraints.insets = new java.awt.Insets (6, 6, 12, 12); 148 add(txCVSROOT, gridBagConstraints); 149 150 } 152 156 public void setObject(Object bean) { 157 if (bean instanceof ChangeLogHTMLService) { 158 service = (ChangeLogHTMLService)bean; 159 disableFiring = true; 160 if (service.getCvsRootPrefix() != null) { 161 txCVSROOT.setText(service.getCvsRootPrefix()); 162 } else { 163 txCVSROOT.setText(""); 164 } 165 if (service.getDiffURL() != null) { 166 txDiffURL.setText(service.getDiffURL()); 167 } else { 168 txDiffURL.setText(""); 169 } 170 if (service.getRevisionURL() != null) { 171 txRevisionURL.setText(service.getRevisionURL()); 172 } else { 173 txRevisionURL.setText(""); 174 } 175 disableFiring = false; 176 } 177 } 178 179 180 public void setData() { 181 if (service != null && !disableFiring) { 182 if (txCVSROOT.getText() != null && 183 txCVSROOT.getText().length() > 0) { 184 service.setCvsRootPrefix(txCVSROOT.getText()); 185 } else { 186 service.setCvsRootPrefix(null); 187 } 188 if (txDiffURL.getText() != null && 189 txDiffURL.getText().length() > 0) { 190 service.setDiffURL(txDiffURL.getText()); 191 } else { 192 service.setDiffURL(null); 193 } 194 if (txRevisionURL.getText() != null && 195 txRevisionURL.getText().length() > 0) { 196 service.setRevisionURL(txRevisionURL.getText()); 197 } else { 198 service.setRevisionURL(null); 199 } 200 } 201 } 202 203 public void disableEditing(boolean disable) { 204 txCVSROOT.setEnabled(!disable); 205 txDiffURL.setEnabled(!disable); 206 txRevisionURL.setEnabled(!disable); 207 } 208 209 private javax.swing.JTextField txDiffURL; 211 private javax.swing.JLabel lblCVSROOT; 212 private javax.swing.JTextField txRevisionURL; 213 private javax.swing.JLabel lblRevisionURL; 214 private javax.swing.JTextField txCVSROOT; 215 private javax.swing.JTextArea taExplanation; 216 private javax.swing.JScrollPane spExplanation; 217 private javax.swing.JLabel lblDiffURL; 218 220 } 221 | Popular Tags |