KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > multiview > test > ChapterTreePanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * ChapterTreePanel.java
21  *
22  * Created on May 26, 2005, 6:00 PM
23  */

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 /**
31  *
32  * @author mkuchtiak
33  */

34 public class ChapterTreePanel extends javax.swing.JPanel JavaDoc implements TreePanel {
35     private javax.swing.JTextArea JavaDoc[] paragraphTA;
36     
37     /** Creates new form ChapterTreePanel */
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 JavaDoc[] paragraphs = chapter.getParagraph();
48         paragraphTA = new javax.swing.JTextArea JavaDoc[paragraphs.length];
49         paragraphsPanel.removeAll();
50         for (int i=0;i<paragraphs.length;i++) {
51             paragraphTA[i] = new javax.swing.JTextArea JavaDoc();
52             paragraphTA[i].setText(paragraphs[i]);
53             paragraphTA[i].setRows(10);
54             paragraphsPanel.add(new javax.swing.JScrollPane JavaDoc(paragraphTA[i]),String.valueOf(i+1));
55         }
56         lengthTF.setText(chapter.getAttributeValue("length"));
57     }
58     /** This method is called from within the constructor to
59      * initialize the form.
60      * WARNING: Do NOT modify this code. The content of this method is
61      * always regenerated by the Form Editor.
62      */

63     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
64
private void initComponents() {
65         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
66
67         titleLabel = new javax.swing.JLabel JavaDoc();
68         titleTF = new javax.swing.JTextField JavaDoc();
69         summaryLabel = new javax.swing.JLabel JavaDoc();
70         summaryTA = new javax.swing.JTextArea JavaDoc();
71         paragraphLabel = new javax.swing.JLabel JavaDoc();
72         paragraphsPanel = new javax.swing.JTabbedPane JavaDoc();
73         filler = new javax.swing.JPanel JavaDoc();
74         lengthLabel = new javax.swing.JLabel JavaDoc();
75         lengthTF = new javax.swing.JTextField JavaDoc();
76
77         setLayout(new java.awt.GridBagLayout JavaDoc());
78
79         titleLabel.setText("Title:");
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.gridx = 0;
82         gridBagConstraints.gridy = 0;
83         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
84         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
85         add(titleLabel, gridBagConstraints);
86
87         titleTF.setColumns(40);
88         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
89         gridBagConstraints.gridx = 1;
90         gridBagConstraints.gridy = 0;
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
93         add(titleTF, gridBagConstraints);
94
95         summaryLabel.setText("Summary:");
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.gridx = 0;
98         gridBagConstraints.gridy = 1;
99         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
101         add(summaryLabel, gridBagConstraints);
102
103         summaryTA.setRows(3);
104         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(5, 0, 0, 5);
110         add(summaryTA, gridBagConstraints);
111
112         paragraphLabel.setText("Paragraphs:");
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.gridx = 0;
115         gridBagConstraints.gridy = 2;
116         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
117         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 5, 0, 0);
118         add(paragraphLabel, gridBagConstraints);
119
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 5, 5);
126         add(paragraphsPanel, gridBagConstraints);
127
128         filler.setOpaque(false);
129         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc();
137         gridBagConstraints.gridx = 2;
138         gridBagConstraints.gridy = 2;
139         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
140         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 5);
141         add(lengthLabel, gridBagConstraints);
142
143         lengthTF.setColumns(5);
144         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
145         gridBagConstraints.gridx = 3;
146         gridBagConstraints.gridy = 2;
147         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 5);
149         add(lengthTF, gridBagConstraints);
150
151     }
152     // </editor-fold>//GEN-END:initComponents
153

154     
155     // Variables declaration - do not modify//GEN-BEGIN:variables
156
private javax.swing.JPanel JavaDoc filler;
157     private javax.swing.JLabel JavaDoc lengthLabel;
158     private javax.swing.JTextField JavaDoc lengthTF;
159     private javax.swing.JLabel JavaDoc paragraphLabel;
160     private javax.swing.JTabbedPane JavaDoc paragraphsPanel;
161     private javax.swing.JLabel JavaDoc summaryLabel;
162     private javax.swing.JTextArea JavaDoc summaryTA;
163     private javax.swing.JLabel JavaDoc titleLabel;
164     private javax.swing.JTextField JavaDoc titleTF;
165     // End of variables declaration//GEN-END:variables
166

167 }
168
Popular Tags