View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package net.sf.magicproject.ui.wizard;
20  
21  import java.awt.Color;
22  
23  import javax.swing.BoxLayout;
24  import javax.swing.ImageIcon;
25  import javax.swing.JLabel;
26  import javax.swing.JPanel;
27  import javax.swing.SwingConstants;
28  import javax.swing.border.EtchedBorder;
29  
30  import net.sf.magicproject.tools.MToolKit;
31  import net.sf.magicproject.ui.UIHelper;
32  
33  /***
34   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
35   * @since 0.85
36   */
37  public class WizardInfo extends JPanel {
38  
39  	/***
40  	 */
41  	public WizardInfo() {
42  		super();
43  		descrLabel = new JLabel();
44  		wizLabel = new JLabel();
45  		setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
46  		setBackground(Color.white);
47  		setBorder(new EtchedBorder());
48  		wizLabel.setHorizontalAlignment(SwingConstants.LEFT);
49  		add(wizLabel);
50  		descrLabel.setFont(MToolKit.defaultFont);
51  		descrLabel.setHorizontalAlignment(SwingConstants.LEFT);
52  		descrLabel.setVerticalTextPosition(SwingConstants.TOP);
53  		add(descrLabel);
54  	}
55  
56  	private void reset(ImageIcon icon, String description) {
57  		descrLabel.setText(description == null ? "" : " " + description);
58  		if (icon != null)
59  			noNewMessage = false;
60  		wizLabel.setIcon(icon);
61  	}
62  
63  	/***
64  	 * Reset the error state with the given description.
65  	 * 
66  	 * @param description
67  	 *          the description to display.
68  	 */
69  	protected void resetError(String description) {
70  		reset(ERROR_ICO, description);
71  	}
72  
73  	/***
74  	 * Reset the warning state with the given description.
75  	 * 
76  	 * @param description
77  	 *          the description to display.
78  	 */
79  	public void resetWarning(String description) {
80  		reset(WARNING_ICO, description);
81  	}
82  
83  	/***
84  	 * Reset the state.
85  	 */
86  	public void reset() {
87  		reset(null, null);
88  	}
89  
90  	private JLabel descrLabel;
91  
92  	private JLabel wizLabel;
93  
94  	/***
95  	 * Flag indicating a new posted message.
96  	 */
97  	protected boolean noNewMessage;
98  
99  	private static final ImageIcon WARNING_ICO = UIHelper
100 			.getIcon("wiz_warning.gif");
101 
102 	private static final ImageIcon ERROR_ICO = UIHelper.getIcon("wiz_error.gif");
103 }