001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * CommonMessagePanel.java
044: *
045: * Created on June 9, 2006, 4:59 PM
046: */
047:
048: package org.netbeans.modules.xml.wsdl.ui.view.common;
049:
050: import java.awt.Color;
051: import java.awt.Image;
052:
053: import javax.swing.ImageIcon;
054: import javax.swing.UIManager;
055:
056: import org.openide.util.Utilities;
057:
058: /**
059: *
060: * @author skini
061: */
062: public class CommonMessagePanel extends javax.swing.JPanel {
063: private static Color nbErrorForeground;
064: private static Color nbWarningForeground;
065: private boolean mValidState = true;
066:
067: static {//Got this from WizardDescriptor
068: nbErrorForeground = UIManager.getColor("nb.errorForeground"); //NOI18N
069: if (nbErrorForeground == null) {
070: nbErrorForeground = new Color(255, 0, 0); // RGB suggested by jdinga in #65358
071: }
072: nbWarningForeground = UIManager
073: .getColor("nb.warningForeground"); //NOI18N
074: if (nbWarningForeground == null) {
075: nbWarningForeground = new Color(51, 51, 51); // Label.foreground
076: }
077:
078: }
079:
080: /** Creates new form CommonMessagePanel */
081: public CommonMessagePanel() {
082: initComponents();
083: }
084:
085: /** This method is called from within the constructor to
086: * initialize the form.
087: * WARNING: Do NOT modify this code. The content of this method is
088: * always regenerated by the Form Editor.
089: */
090: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
091: private void initComponents() {
092:
093: jLabel1 = new javax.swing.JLabel();
094: jScrollPane2 = new javax.swing.JScrollPane();
095: jTextArea2 = new javax.swing.JTextArea();
096:
097: jScrollPane2.setBorder(null);
098:
099: jTextArea2.setEditable(false);
100: jTextArea2.setFont(getFont());
101: jTextArea2.setLineWrap(true);
102: jTextArea2.setRows(2);
103: jTextArea2.setWrapStyleWord(true);
104: jTextArea2.setFocusable(false);
105: jTextArea2.setOpaque(false);
106: jScrollPane2.setViewportView(jTextArea2);
107:
108: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
109: this );
110: this .setLayout(layout);
111: layout
112: .setHorizontalGroup(layout
113: .createParallelGroup(
114: org.jdesktop.layout.GroupLayout.LEADING)
115: .add(
116: layout
117: .createSequentialGroup()
118: .add(jLabel1)
119: .addPreferredGap(
120: org.jdesktop.layout.LayoutStyle.RELATED)
121: .add(jScrollPane2)));
122: layout.setVerticalGroup(layout.createParallelGroup(
123: org.jdesktop.layout.GroupLayout.LEADING).add(jLabel1)
124: .add(jScrollPane2,
125: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
126: 36, Short.MAX_VALUE));
127: }// </editor-fold>//GEN-END:initComponents
128:
129: public void setErrorMessage(String errorMsg) {
130: jTextArea2.setText(errorMsg);
131: jTextArea2.setToolTipText(errorMsg);
132: jTextArea2.setForeground(nbErrorForeground);
133: jTextArea2.repaint();
134: jLabel1
135: .setIcon(new ImageIcon(
136: Utilities
137: .loadImage("org/netbeans/modules/xml/wsdl/ui/view/common/resources/error.gif")));
138: jLabel1.setToolTipText(errorMsg);
139: mValidState = false;
140: }
141:
142: public void setWarningMessage(String warningMsg) {
143: jTextArea2.setText(warningMsg);
144: jTextArea2.setToolTipText(warningMsg);
145: jLabel1.setToolTipText(warningMsg);
146: jTextArea2.setForeground(nbWarningForeground);
147: jTextArea2.repaint();
148: Image image = Utilities
149: .loadImage("org/netbeans/modules/xml/wsdl/ui/view/common/resources/warning.gif");
150: jLabel1.setIcon(new ImageIcon(image));
151: mValidState = true;
152: }
153:
154: public void setMessage(String msg) {
155: jTextArea2.setText(msg);
156: jTextArea2.setToolTipText(msg);
157: jLabel1.setIcon(null);
158: jLabel1.setToolTipText(msg);
159: mValidState = true;
160: }
161:
162: public boolean isStateValid() {
163: return mValidState;
164: }
165:
166: // Variables declaration - do not modify//GEN-BEGIN:variables
167: private javax.swing.JLabel jLabel1;
168: private javax.swing.JScrollPane jScrollPane2;
169: private javax.swing.JTextArea jTextArea2;
170: // End of variables declaration//GEN-END:variables
171:
172: }
|