/*************************************************** * * cismet GmbH, Saarbruecken, Germany * * ... and it just works. * ****************************************************/ package de.cismet.cids.custom.switchon.gui; import org.apache.commons.lang.StringUtils; /** * A Panel which contains an info box. * * @author Gilles Baatz * @version $Revision$, $Date$ */ public class InfoBoxPanel extends javax.swing.JPanel implements InfoReceiver { //~ Static fields/initializers --------------------------------------------- private static final transient org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(InfoBoxPanel.class); //~ Instance fields -------------------------------------------------------- // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel lblInformation; // End of variables declaration//GEN-END:variables //~ Constructors ----------------------------------------------------------- /** * Creates new form InfoBoxPanel. */ public InfoBoxPanel() { initComponents(); } //~ Methods ---------------------------------------------------------------- /** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The * content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { final java.awt.GridBagConstraints gridBagConstraints; lblInformation = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); lblInformation.setForeground(new java.awt.Color(16, 76, 116)); lblInformation.setIcon(new javax.swing.ImageIcon( getClass().getResource("/de/cismet/cids/custom/switchon/search/info.png"))); // NOI18N lblInformation.setIconTextGap(5); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 5); add(lblInformation, gridBagConstraints); } // </editor-fold>//GEN-END:initComponents /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public String getInformation() { return lblInformation.getText(); } @Override public void setInformation(final String information) { if (StringUtils.isNotBlank(information)) { setLabelText(information); } else { setLabelText(""); } } /** * DOCUMENT ME! * * @param text DOCUMENT ME! */ private void setLabelText(final String text) { if (text.startsWith("<html>")) { lblInformation.setText(text); } else { lblInformation.setText("<html>" + text + "</html>"); } } @Override public void setError(final String error) { setInformation(error); } }