1 19 24 25 package org.netbeans.modules.xml.multiview.test; 26 27 import org.netbeans.modules.xml.multiview.test.bookmodel.Chapter; 28 import org.netbeans.modules.xml.multiview.ui.TreePanel; 29 import org.netbeans.modules.xml.multiview.ui.TreeNode; 30 34 public class ChapterTreePanel extends javax.swing.JPanel implements TreePanel { 35 private javax.swing.JTextArea [] paragraphTA; 36 37 38 public ChapterTreePanel() { 39 initComponents(); 40 } 41 42 public void setModel(TreeNode node) { 43 Chapter chapter = ((BookTreePanelMVElement.ChapterNode)node).getChapter(); 44 titleTF.setText(chapter.getTitle());; 45 summaryTA.setBorder(titleTF.getBorder()); 46 summaryTA.setText(chapter.getSummary()); 47 String [] paragraphs = chapter.getParagraph(); 48 paragraphTA = new javax.swing.JTextArea [paragraphs.length]; 49 paragraphsPanel.removeAll(); 50 for (int i=0;i<paragraphs.length;i++) { 51 paragraphTA[i] = new javax.swing.JTextArea (); 52 paragraphTA[i].setText(paragraphs[i]); 53 paragraphTA[i].setRows(10); 54 paragraphsPanel.add(new javax.swing.JScrollPane (paragraphTA[i]),String.valueOf(i+1)); 55 } 56 lengthTF.setText(chapter.getAttributeValue("length")); 57 } 58 63 private void initComponents() { 65 java.awt.GridBagConstraints gridBagConstraints; 66 67 titleLabel = new javax.swing.JLabel (); 68 titleTF = new javax.swing.JTextField (); 69 summaryLabel = new javax.swing.JLabel (); 70 summaryTA = new javax.swing.JTextArea (); 71 paragraphLabel = new javax.swing.JLabel (); 72 paragraphsPanel = new javax.swing.JTabbedPane (); 73 filler = new javax.swing.JPanel (); 74 lengthLabel = new javax.swing.JLabel (); 75 lengthTF = new javax.swing.JTextField (); 76 77 setLayout(new java.awt.GridBagLayout ()); 78 79 titleLabel.setText("Title:"); 80 gridBagConstraints = new java.awt.GridBagConstraints (); 81 gridBagConstraints.gridx = 0; 82 gridBagConstraints.gridy = 0; 83 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 84 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 85 add(titleLabel, gridBagConstraints); 86 87 titleTF.setColumns(40); 88 gridBagConstraints = new java.awt.GridBagConstraints (); 89 gridBagConstraints.gridx = 1; 90 gridBagConstraints.gridy = 0; 91 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 92 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 93 add(titleTF, gridBagConstraints); 94 95 summaryLabel.setText("Summary:"); 96 gridBagConstraints = new java.awt.GridBagConstraints (); 97 gridBagConstraints.gridx = 0; 98 gridBagConstraints.gridy = 1; 99 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 100 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 101 add(summaryLabel, gridBagConstraints); 102 103 summaryTA.setRows(3); 104 gridBagConstraints = new java.awt.GridBagConstraints (); 105 gridBagConstraints.gridx = 1; 106 gridBagConstraints.gridy = 1; 107 gridBagConstraints.gridwidth = 3; 108 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 109 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 5); 110 add(summaryTA, gridBagConstraints); 111 112 paragraphLabel.setText("Paragraphs:"); 113 gridBagConstraints = new java.awt.GridBagConstraints (); 114 gridBagConstraints.gridx = 0; 115 gridBagConstraints.gridy = 2; 116 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 117 gridBagConstraints.insets = new java.awt.Insets (10, 5, 0, 0); 118 add(paragraphLabel, gridBagConstraints); 119 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridx = 0; 122 gridBagConstraints.gridy = 3; 123 gridBagConstraints.gridwidth = 4; 124 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 125 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 5); 126 add(paragraphsPanel, gridBagConstraints); 127 128 filler.setOpaque(false); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.gridwidth = 2; 131 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 132 gridBagConstraints.weightx = 1.0; 133 add(filler, gridBagConstraints); 134 135 lengthLabel.setText("Length:"); 136 gridBagConstraints = new java.awt.GridBagConstraints (); 137 gridBagConstraints.gridx = 2; 138 gridBagConstraints.gridy = 2; 139 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 140 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 5); 141 add(lengthLabel, gridBagConstraints); 142 143 lengthTF.setColumns(5); 144 gridBagConstraints = new java.awt.GridBagConstraints (); 145 gridBagConstraints.gridx = 3; 146 gridBagConstraints.gridy = 2; 147 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 148 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 5); 149 add(lengthTF, gridBagConstraints); 150 151 } 152 154 155 private javax.swing.JPanel filler; 157 private javax.swing.JLabel lengthLabel; 158 private javax.swing.JTextField lengthTF; 159 private javax.swing.JLabel paragraphLabel; 160 private javax.swing.JTabbedPane paragraphsPanel; 161 private javax.swing.JLabel summaryLabel; 162 private javax.swing.JTextArea summaryTA; 163 private javax.swing.JLabel titleLabel; 164 private javax.swing.JTextField titleTF; 165 167 } 168 | Popular Tags |