home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.util.EResourceUtil;
- import asp.util.ResourceUtil;
- import asp.util.ResourceUtilOwner;
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.BorderFactory;
- import com.sun.java.swing.JPanel;
- import com.sun.java.swing.JTextPane;
- import com.sun.java.swing.UIManager;
- import com.sun.java.swing.text.BadLocationException;
- import com.sun.java.swing.text.DefaultStyledDocument;
- import com.sun.java.swing.text.MutableAttributeSet;
- import com.sun.java.swing.text.SimpleAttributeSet;
- import com.sun.java.swing.text.StyleConstants;
- import com.sun.java.swing.text.StyledDocument;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.awt.Insets;
-
- public class WVPanelBase extends JPanel implements ResourceUtilOwner {
- protected static final int OUTER_TOP_MARGIN = 0;
- protected static final int OUTER_LEFT_MARGIN = 0;
- protected static final int OUTER_BOTTOM_MARGIN = 0;
- protected static final int OUTER_RIGHT_MARGIN = 0;
- protected static final String ID_FRM_TITLE = "frame.title";
- protected static final String ID_TXA_INTRO = "label.intro";
- protected static final String ID_TXA_INTROHEAD = "label.introhead";
- protected static final int SPACE_BELOW_INTRO = 5;
- protected JPanel _pnlDecorative;
- protected JPanel _pnlImage;
- protected JPanel _pnlContent;
- protected boolean _showImage;
- protected String _introHeading;
- protected String _introBody;
- protected StyledDocument _introText;
- protected JTextPane _txpIntro;
-
- public WVPanelBase() {
- this(false);
- }
-
- public WVPanelBase(boolean showImage) {
- this._showImage = false;
- this._showImage = showImage;
- this.initResourceUtil();
- this.initModels();
- this.initComponents();
- this.initLayout();
- this.initListeners();
- }
-
- protected void initResourceUtil() {
- }
-
- void setIntroText(String introhead, String introbody) {
- MutableAttributeSet plainText = new SimpleAttributeSet();
- StyleConstants.setFontFamily(plainText, "Dialog");
- StyleConstants.setFontSize(plainText, 11);
- StyleConstants.setForeground(plainText, Color.black);
- MutableAttributeSet boldText = new SimpleAttributeSet();
- boldText.setResolveParent(plainText);
- StyleConstants.setBold(boldText, true);
- StyleConstants.setForeground(boldText, Color.black);
- ResourceUtil ru = this.getResourceUtil();
-
- try {
- introbody = introhead != null && !introhead.equals("") ? " - " + introbody : introbody;
- this._introText = new DefaultStyledDocument();
- this._introText.insertString(0, introhead, boldText);
- this._introText.insertString(this._introText.getLength(), introbody, plainText);
- if (this._txpIntro != null) {
- this._txpIntro.setStyledDocument(this._introText);
- }
- } catch (BadLocationException e) {
- System.err.println(((Throwable)e).getMessage());
- }
-
- }
-
- void initIntroText() {
- ResourceUtil ru = this.getResourceUtil();
- this.setIntroText(ru.getString("label.introhead"), ru.getString("label.intro"));
- }
-
- protected void initModels() {
- this.initIntroText();
- }
-
- protected void initComponents() {
- if (this._showImage) {
- this._pnlDecorative = new JPanel();
- this._pnlImage = new JPanel();
- }
-
- this._pnlContent = new JPanel();
- this._txpIntro = new JTextPane();
- this._txpIntro.setStyledDocument(this._introText);
- this._txpIntro.setEditable(false);
- this._txpIntro.setBackground(UIManager.getColor("control"));
- this._txpIntro.setBorder(BorderFactory.createEmptyBorder());
- }
-
- protected void initLayout() {
- if (this._showImage) {
- GridBagLayout gbl = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- this._pnlDecorative.setLayout(gbl);
- this._pnlImage.setBackground(Color.blue);
- this._pnlImage.setBorder(BorderFactory.createLoweredBevelBorder());
- gbc.insets = new Insets(0, 0, 0, 10);
- gbc.fill = 1;
- gbc.ipadx = 70;
- UiUtil.addComponent(this._pnlDecorative, this._pnlImage, gbl, gbc, 0, 0, 1, 1, (double)1.0F, (double)1.0F);
- gbl = new GridBagLayout();
- gbc = new GridBagConstraints();
- ((Container)this).setLayout(gbl);
- gbc.fill = 1;
- UiUtil.addComponent(this, this._pnlDecorative, gbl, gbc, 0, 0, 1, 1, (double)0.0F, (double)1.0F);
- UiUtil.addComponent(this, this._pnlContent, gbl, gbc, 1, 0, 1, 1, (double)1.0F, (double)1.0F);
- } else {
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add(this._pnlContent, "Center");
- }
-
- }
-
- protected void initListeners() {
- }
-
- public JPanel getContentPanel() {
- return this._pnlContent;
- }
-
- public ResourceUtil getResourceUtil() {
- ResourceUtil result = null;
-
- try {
- result = ResourceUtil.getResourceUtil("asp.wizard.res", this.getClass());
- } catch (EResourceUtil e) {
- System.err.println(((Throwable)e).getMessage());
- }
-
- return result;
- }
-
- public String getIntroHeading() {
- if (this._introHeading == null) {
- ResourceUtil ru = this.getResourceUtil();
- this._introHeading = ru.getString("label.introhead");
- }
-
- return this._introHeading;
- }
-
- public String getIntroBody() {
- if (this._introBody == null) {
- ResourceUtil ru = this.getResourceUtil();
- this._introBody = ru.getString("label.intro");
- }
-
- return this._introBody;
- }
- }
-