You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
5.9 KiB
154 lines
5.9 KiB
package com.fr.design.javascript; |
|
|
|
import com.fr.config.EmailServerConfig; |
|
import com.fr.design.beans.FurtherBasicBeanPane; |
|
import com.fr.design.constants.UIConstants; |
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
import com.fr.design.gui.ilable.UILabel; |
|
import com.fr.design.gui.itextfield.UITextField; |
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
import com.fr.design.layout.TableLayout; |
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.js.EmailJavaScript; |
|
import com.fr.stable.StringUtils; |
|
|
|
import javax.swing.*; |
|
import javax.swing.text.JTextComponent; |
|
import java.awt.*; |
|
|
|
public class EmailPane extends FurtherBasicBeanPane<EmailJavaScript> { |
|
|
|
protected UILabel tipsPane1; |
|
protected UITextField maitoEditor; |
|
protected UITextField ccEditor; |
|
protected UITextField bccEditor; |
|
protected UITextField titleEditor; |
|
protected UILabel tipsPane2; |
|
protected JPanel centerPane; |
|
protected UICheckBox showTplContent; |
|
private JTextArea mainTextEditor; |
|
|
|
public EmailPane() { |
|
this.initComponents(); |
|
} |
|
|
|
private void initComponents() { |
|
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
|
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 10)); |
|
tipsPane1 = new UILabel(); |
|
tipsPane1.setHorizontalAlignment(SwingConstants.RIGHT); |
|
tipsPane1.setForeground(Color.pink); |
|
tipsPane2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_EmailPane_Tips")); |
|
|
|
UILabel mainTextLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_EmailPane_Mail_Content") + ":"); |
|
mainTextLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
|
mainTextLabel.setVerticalAlignment(SwingConstants.TOP); |
|
JScrollPane scrollPane = new JScrollPane(mainTextEditor = new JTextArea()); |
|
scrollPane.setBorder(null); |
|
double fill = TableLayout.FILL; |
|
double preferred = TableLayout.PREFERRED; |
|
initCenterPane(mainTextLabel, scrollPane, fill, preferred); |
|
this.add(centerPane, BorderLayout.CENTER); |
|
mainTextEditor.setAutoscrolls(true); |
|
checkEmailConfig(EmailServerConfig.getInstance().isEmailConfigValid()); |
|
} |
|
|
|
/** |
|
* 由于发邮件pane中的showTplContent单选框和图表超链itemNameTextField文本框 |
|
* 在一些情况下不使用,所以默认centerPane为都有,其他情况下子类实现 |
|
*/ |
|
protected void initCenterPane(UILabel mainTextLabel, JScrollPane scrollPane, double fill, double preferred) { |
|
double[] rowSize = { preferred, preferred, preferred, preferred, preferred, fill, preferred, preferred, preferred }; |
|
double[] columnSize = { preferred, fill}; |
|
showTplContent = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Email_Can_Preview_Report_Content")); |
|
centerPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ |
|
{new UILabel(), tipsPane1}, |
|
createLinePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_HJS_Mail_to"), maitoEditor = new UITextField()), |
|
createLinePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_HJS_CC_To"), ccEditor = new UITextField()), |
|
createLinePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_EmailPane_Bcc"), bccEditor = new UITextField()), |
|
createLinePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_EmailPane_Mail_Subject"), titleEditor = new UITextField()), |
|
{mainTextLabel, scrollPane}, |
|
{new UILabel(), showTplContent}, |
|
{new UILabel(), tipsPane2}},rowSize, columnSize, 8); |
|
} |
|
|
|
protected JComponent[] createLinePane(String string, JTextComponent textComp) { |
|
UILabel label = new UILabel(string + ":"); |
|
label.setPreferredSize(new Dimension(70, label.getPreferredSize().height)); |
|
label.setHorizontalAlignment(SwingConstants.RIGHT); |
|
return new JComponent[] { label, textComp }; |
|
} |
|
|
|
protected void checkEmailConfig(boolean valid) { |
|
tipsPane1.setText(valid ? StringUtils.BLANK : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_EmailPane_Warnings")); |
|
centerPane.setEnabled(valid); |
|
mainTextEditor.setEnabled(valid); |
|
mainTextEditor.setBackground(valid ? Color.WHITE : UIConstants.DEFAULT_BG_RULER); |
|
mainTextEditor.setBorder(BorderFactory.createLineBorder(valid ? new Color(128, 152, 186) : UIConstants.TITLED_BORDER_COLOR)); |
|
maitoEditor.setEnabled(valid); |
|
ccEditor.setEnabled(valid); |
|
bccEditor.setEnabled(valid); |
|
titleEditor.setEnabled(valid); |
|
if (showTplContent != null) { |
|
showTplContent.setEnabled(valid); |
|
} |
|
} |
|
|
|
|
|
/** |
|
* 重置各部分 |
|
*/ |
|
public void reset() { |
|
populateBean(null); |
|
} |
|
|
|
@Override |
|
public void populateBean(EmailJavaScript ob) { |
|
maitoEditor.setText(ob == null ? null : ob.getMailTo()); |
|
ccEditor.setText(ob == null ? null : ob.getCC()); |
|
bccEditor.setText(ob == null ? null : ob.getBCC()); |
|
titleEditor.setText(ob == null ? null : ob.getTitle()); |
|
mainTextEditor.setText(ob == null ? null : ob.getMainText()); |
|
if (showTplContent != null) { |
|
showTplContent.setSelected(ob ==null ? false: ob.isShowTplContent()); |
|
} |
|
checkEmailConfig(EmailServerConfig.getInstance().isEmailConfigValid()); |
|
} |
|
|
|
@Override |
|
public EmailJavaScript updateBean() { |
|
EmailJavaScript js = new EmailJavaScript(); |
|
updateBean(js); |
|
return js; |
|
} |
|
|
|
public void updateBean(EmailJavaScript email) { |
|
email.setMailTo(maitoEditor.getText()); |
|
email.setCC(ccEditor.getText()); |
|
email.setBCC(bccEditor.getText()); |
|
email.setTitle(titleEditor.getText()); |
|
email.setMainText(mainTextEditor.getText()); |
|
if (showTplContent != null) { |
|
email.setShowTplContent(showTplContent.isSelected()); |
|
} |
|
} |
|
|
|
/** |
|
* 界面的标题 |
|
* @return 标题字串 |
|
*/ |
|
public String title4PopupWindow() { |
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email"); |
|
} |
|
|
|
/** |
|
* 是否是本类对象 |
|
* @param ob 需要判断的对象 |
|
* @return 是否是本类对象 |
|
*/ |
|
public boolean accept(Object ob) { |
|
return ob instanceof EmailJavaScript; |
|
} |
|
|
|
}
|
|
|