1 19 package org.netbeans.modules.xml.core.wizard; 20 21 25 public class DocumentPanel extends AbstractPanel { 26 27 private static final long serialVersionUID = 3793605846188902177L; 28 29 30 31 public DocumentPanel() { 32 initComponents(); 33 initAccessibility(); 34 35 otherRadioButton.setVisible(false); 37 otherComboBox.setVisible(false); 38 } 39 40 45 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 47 48 buttonGroup = new javax.swing.ButtonGroup (); 49 descTextArea = new javax.swing.JTextArea (); 50 wellformedRadioButton = new javax.swing.JRadioButton (); 51 dtdConstrainedRadioButton = new javax.swing.JRadioButton (); 52 schemaConstrainedRadioButton = new javax.swing.JRadioButton (); 53 otherRadioButton = new javax.swing.JRadioButton (); 54 otherComboBox = new javax.swing.JComboBox (); 55 fillPanel = new javax.swing.JPanel (); 56 57 setLayout(new java.awt.GridBagLayout ()); 58 59 setName(Util.THIS.getString("PROP_doc_panel_name")); 60 descTextArea.setEditable(false); 61 descTextArea.setLineWrap(true); 62 descTextArea.setText(Util.THIS.getString("MSG_document_panel_desc")); 63 descTextArea.setWrapStyleWord(true); 64 descTextArea.setDisabledTextColor(descTextArea.getForeground()); 65 descTextArea.setEnabled(false); 66 descTextArea.setOpaque(false); 67 gridBagConstraints = new java.awt.GridBagConstraints (); 68 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 69 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 70 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 71 add(descTextArea, gridBagConstraints); 72 73 wellformedRadioButton.setText(Util.THIS.getString("PROP_wellformed_name")); 74 wellformedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_wellformedRadioButton_desc")); 75 buttonGroup.add(wellformedRadioButton); 76 wellformedRadioButton.addActionListener(new java.awt.event.ActionListener () { 77 public void actionPerformed(java.awt.event.ActionEvent evt) { 78 wellformedRadioButtonActionPerformed(evt); 79 } 80 }); 81 82 gridBagConstraints = new java.awt.GridBagConstraints (); 83 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 84 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 85 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 86 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 87 add(wellformedRadioButton, gridBagConstraints); 88 89 dtdConstrainedRadioButton.setText(Util.THIS.getString("PROP_dtd_doc_name")); 90 dtdConstrainedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_dtdConstrainedRadioButton_desc")); 91 buttonGroup.add(dtdConstrainedRadioButton); 92 dtdConstrainedRadioButton.addActionListener(new java.awt.event.ActionListener () { 93 public void actionPerformed(java.awt.event.ActionEvent evt) { 94 dtdConstrainedRadioButtonActionPerformed(evt); 95 } 96 }); 97 98 gridBagConstraints = new java.awt.GridBagConstraints (); 99 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 100 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 101 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 102 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 103 add(dtdConstrainedRadioButton, gridBagConstraints); 104 105 schemaConstrainedRadioButton.setText(Util.THIS.getString("PROP_schema_doc_name")); 106 schemaConstrainedRadioButton.setToolTipText(Util.THIS.getString("PROP_doc_schemaConstrainedRadioButton_desc")); 107 buttonGroup.add(schemaConstrainedRadioButton); 108 schemaConstrainedRadioButton.addActionListener(new java.awt.event.ActionListener () { 109 public void actionPerformed(java.awt.event.ActionEvent evt) { 110 schemaConstrainedRadioButtonActionPerformed(evt); 111 } 112 }); 113 114 gridBagConstraints = new java.awt.GridBagConstraints (); 115 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 116 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 117 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 118 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 0); 119 add(schemaConstrainedRadioButton, gridBagConstraints); 120 121 otherRadioButton.setText(Util.THIS.getString("PROP_other_doc_name")); 122 buttonGroup.add(otherRadioButton); 123 otherRadioButton.setEnabled(false); 124 gridBagConstraints = new java.awt.GridBagConstraints (); 125 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 126 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 12); 127 add(otherRadioButton, gridBagConstraints); 128 129 otherComboBox.setEnabled(false); 130 gridBagConstraints = new java.awt.GridBagConstraints (); 131 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 132 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 133 gridBagConstraints.weightx = 1.0; 134 add(otherComboBox, gridBagConstraints); 135 136 fillPanel.setLayout(null); 137 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 140 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 141 gridBagConstraints.weightx = 1.0; 142 gridBagConstraints.weighty = 1.0; 143 add(fillPanel, gridBagConstraints); 144 145 } 147 private void initAccessibility() { 148 149 Util util = Util.THIS; 150 wellformedRadioButton.setMnemonic(util.getChar("PROP_doc_wellformedRadioButton_mne")); 151 schemaConstrainedRadioButton.setMnemonic(util.getChar("PROP_doc_schemaConstrainedRadioButton_mne")); 152 dtdConstrainedRadioButton.setMnemonic(util.getChar("PROP_doc_dtdConstrainedRadioButton_mne")); 153 getAccessibleContext().setAccessibleDescription(descTextArea.getText()); 154 } 155 156 private void schemaConstrainedRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { updateModel(); 158 } 160 private void dtdConstrainedRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { updateModel(); 162 } 164 private void wellformedRadioButtonActionPerformed(java.awt.event.ActionEvent evt) { updateModel(); 166 } 168 170 protected void initView() { 171 int type = model.getType(); 172 switch (type) { 173 case DocumentModel.NONE: 174 wellformedRadioButton.setSelected(true); 175 break; 176 case DocumentModel.DTD: 177 dtdConstrainedRadioButton.setSelected(true); 178 break; 179 case DocumentModel.SCHEMA: 180 schemaConstrainedRadioButton.setSelected(true); 181 break; 182 case DocumentModel.OTHER: 183 otherRadioButton.setSelected(true); 184 break; 185 default: 186 throw new IllegalStateException (); 187 } 188 } 189 190 192 protected void updateModel() { 193 if (wellformedRadioButton.isSelected()) { 194 model.setType(model.NONE); 195 } else if (dtdConstrainedRadioButton.isSelected()) { 196 model.setType(model.DTD); 197 } else if (schemaConstrainedRadioButton.isSelected()) { 198 model.setType(model.SCHEMA); 199 } else { 200 model.setType(model.OTHER); 201 } 202 } 203 204 206 protected void updateView() { 207 } 209 210 private javax.swing.ButtonGroup buttonGroup; 212 private javax.swing.JRadioButton otherRadioButton; 213 private javax.swing.JRadioButton wellformedRadioButton; 214 private javax.swing.JRadioButton schemaConstrainedRadioButton; 215 private javax.swing.JComboBox otherComboBox; 216 private javax.swing.JTextArea descTextArea; 217 private javax.swing.JRadioButton dtdConstrainedRadioButton; 218 private javax.swing.JPanel fillPanel; 219 221 } 222 | Popular Tags |