1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }