KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > CommandReport


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 package org.netbeans.modules.versioning.system.cvss;
21
22 import java.util.*;
23 import javax.swing.JComponent JavaDoc;
24 import javax.swing.JLabel JavaDoc;
25 import javax.swing.JTextArea JavaDoc;
26
27 /**
28  * Small notification dialog similar to ErrorManager's one. The main purpose is to show (possibly long) list
29  * of warning and error messages.
30  *
31  * @author Maros Sandor
32  */

33 class CommandReport extends javax.swing.JPanel JavaDoc {
34
35     private final String JavaDoc text;
36
37     public CommandReport(String JavaDoc message, List messages) {
38         StringBuffer JavaDoc errorReport = new StringBuffer JavaDoc();
39         for (Iterator i = messages.iterator(); i.hasNext();) {
40             errorReport.append(i.next());
41             errorReport.append('\n'); // NOI18N
42
}
43         text = errorReport.toString();
44         
45         initComponents();
46         
47         JComponent JavaDoc msg = createCenterComponent();
48         jScrollPane1.setViewportView(msg);
49         jLabel1.setText(message);
50     }
51
52     private JComponent JavaDoc createCenterComponent() {
53         if (text.startsWith("<html") || text.startsWith("<HTML")) { // NOI18N
54
JLabel JavaDoc msg = new JLabel JavaDoc(text);
55             return msg;
56         } else {
57             JTextArea JavaDoc msg = new JTextArea JavaDoc();
58             msg.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.inactiveBackground")); // NOI18N
59
msg.setColumns(40);
60             msg.setEditable(false);
61             msg.setRows(10);
62             msg.setMargin(new java.awt.Insets JavaDoc(4, 4, 0, 0));
63             msg.setText(text);
64             return msg;
65         }
66     }
67     
68     /** This method is called from within the constructor to
69      * initialize the form.
70      * WARNING: Do NOT modify this code. The content of this method is
71      * always regenerated by the Form Editor.
72      */

73     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
74
private void initComponents() {
75         jLabel1 = new javax.swing.JLabel JavaDoc();
76         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
77
78         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
79         this.setLayout(layout);
80         layout.setHorizontalGroup(
81             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
82             .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
83                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
84                     .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
85                     .add(jLabel1))
86                 .addContainerGap())
87         );
88         layout.setVerticalGroup(
89             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
90             .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
91                 .addContainerGap()
92                 .add(jLabel1)
93                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
94                 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE))
95         );
96     }
97     // </editor-fold>//GEN-END:initComponents
98

99     
100     // Variables declaration - do not modify//GEN-BEGIN:variables
101
private javax.swing.JLabel JavaDoc jLabel1;
102     private javax.swing.JScrollPane JavaDoc jScrollPane1;
103     // End of variables declaration//GEN-END:variables
104

105 }
106
Popular Tags