KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > wizards > StepProblemMessage


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 2004-2005 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit.wizards;
21
22 import java.awt.*;
23 import javax.accessibility.AccessibleContext JavaDoc;
24 import javax.swing.JComponent JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import javax.swing.JPanel JavaDoc;
27 import javax.swing.JTextField JavaDoc;
28 import javax.swing.event.ChangeListener JavaDoc;
29 import org.netbeans.api.project.Project;
30 import org.netbeans.api.project.ProjectUtils;
31 import org.netbeans.modules.junit.GuiUtils;
32 import org.openide.WizardDescriptor;
33 import org.openide.util.HelpCtx;
34 import org.openide.util.NbBundle;
35
36 /**
37  *
38  * @author Marian Petras
39  */

40 public class StepProblemMessage implements WizardDescriptor.Panel {
41     
42     private final String JavaDoc msg;
43     private final Project project;
44     private JPanel JavaDoc panel;
45     
46     /** Creates a new instance of StepProblemMessage */
47     public StepProblemMessage(Project project, String JavaDoc message) {
48         this.project = project;
49         this.msg = message;
50     }
51     
52     public void addChangeListener(ChangeListener JavaDoc l) {
53         //no need for listeners - this panel is always invalid
54
}
55     
56     public Component JavaDoc getComponent() {
57         if (panel == null) {
58             panel = new JPanel JavaDoc(new GridBagLayout());
59             JLabel JavaDoc lblProject = new JLabel JavaDoc(
60                     NbBundle.getMessage(StepProblemMessage.class,
61                                         "LBL_Project")); //NOI18N
62
JTextField JavaDoc tfProject = new JTextField JavaDoc(
63                     ProjectUtils.getInformation(project).getDisplayName());
64             JComponent JavaDoc message = GuiUtils.createMultilineLabel(msg);
65
66             lblProject.setLabelFor(tfProject);
67             tfProject.setEditable(false);
68             tfProject.setFocusable(false);
69
70             AccessibleContext JavaDoc accContext = tfProject.getAccessibleContext();
71             accContext.setAccessibleName(
72                     NbBundle.getMessage(StepProblemMessage.class,
73                                         "AD_Name_Project_name")); //NOI18N
74
accContext.setAccessibleDescription(
75                     NbBundle.getMessage(StepProblemMessage.class,
76                                         "AD_Descr_Project_name")); //NOI18N
77

78             GridBagConstraints gbc = new GridBagConstraints();
79
80             gbc.anchor = GridBagConstraints.WEST;
81             gbc.insets = new Insets(0, 0, 18, 12);
82             panel.add(lblProject, gbc);
83
84             gbc.gridwidth = GridBagConstraints.REMAINDER;
85             gbc.fill = GridBagConstraints.HORIZONTAL;
86             gbc.weightx = 1.0;
87             gbc.insets = new Insets(0, 0, 18, 0);
88             panel.add(tfProject, gbc);
89
90             gbc.weighty = 1.0;
91             gbc.insets = new Insets(0, 0, 0, 0);
92             panel.add(message, gbc);
93             
94             panel.setPreferredSize(new Dimension(500,0));
95         }
96         return panel;
97     }
98     
99     public HelpCtx getHelp() {
100         return new HelpCtx(StepProblemMessage.class);
101     }
102     
103     /**
104      * @return <code>false</code> - this panel is never valid
105      */

106     public boolean isValid() {
107         return false;
108     }
109     
110     public void readSettings(Object JavaDoc settings) {
111         //this panel has no settings
112
}
113     
114     public void removeChangeListener(ChangeListener JavaDoc l) {
115         //no need for listeners - this panel is always invalid
116
}
117     
118     public void storeSettings(Object JavaDoc settings) {
119         //this panel has no settings
120
}
121     
122 }
123
Popular Tags