Browse Source
* commit 'd5de76a1944dfda3185e416201d24aacccbb3ebd': REPORT-11520 超级链接对话框打开设置优化research/10.0
yaoh.wu
6 years ago
4 changed files with 559 additions and 203 deletions
@ -1,184 +0,0 @@ |
|||||||
package com.fr.design.hyperlink; |
|
||||||
|
|
||||||
import com.fr.design.actions.UpdateAction; |
|
||||||
import com.fr.design.dialog.BasicDialog; |
|
||||||
import com.fr.design.dialog.DialogActionAdapter; |
|
||||||
import com.fr.design.gui.ibutton.UIButton; |
|
||||||
import com.fr.design.gui.icheckbox.UICheckBox; |
|
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.itextfield.UITextField; |
|
||||||
import com.fr.design.gui.itree.filetree.ReportletPane; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayout; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
|
||||||
|
|
||||||
import com.fr.js.ReportletHyperlink; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.awt.*; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
|
|
||||||
/** |
|
||||||
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面. |
|
||||||
* |
|
||||||
* @author kunsnat |
|
||||||
*/ |
|
||||||
public class ReporletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> { |
|
||||||
private UITextField itemNameTextField; |
|
||||||
private boolean needRenamePane = false; |
|
||||||
private UITextField reportPathTextField; |
|
||||||
private UICheckBox showParameterInterface; |
|
||||||
private UIButton browserButton; |
|
||||||
|
|
||||||
// richer:参数传递方式
|
|
||||||
private UIComboBox postComboBox; |
|
||||||
|
|
||||||
public ReporletHyperNorthPane(boolean needRenamePane) { |
|
||||||
this.needRenamePane = needRenamePane; |
|
||||||
this.inits(); |
|
||||||
} |
|
||||||
|
|
||||||
public ReporletHyperNorthPane() { |
|
||||||
this.inits(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 初始化组件 |
|
||||||
*/ |
|
||||||
public void inits() { |
|
||||||
super.initComponents(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected JPanel setHeaderPanel() { |
|
||||||
JPanel headerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double[] rowSize = {p, p, p}; |
|
||||||
double[] columnSize = {p, TableLayout.FILL}; |
|
||||||
// Reportlet.
|
|
||||||
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
|
|
||||||
reportPathTextField = new UITextField(20); |
|
||||||
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
|
||||||
|
|
||||||
browserButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select")); |
|
||||||
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
|
||||||
reportletNamePane.add(browserButton, BorderLayout.EAST); |
|
||||||
browserButton.addActionListener(new ActionListener() { |
|
||||||
public void actionPerformed(ActionEvent evt) { |
|
||||||
final ReportletPane reportletPane = new ReportletPane(); |
|
||||||
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
|
||||||
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReporletHyperNorthPane.this)); |
|
||||||
|
|
||||||
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
|
||||||
public void doOk() { |
|
||||||
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
|
||||||
} |
|
||||||
}); |
|
||||||
reportletDialog.setVisible(true); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
Component[][] components; |
|
||||||
if (!this.needRenamePane) { |
|
||||||
components = new Component[][]{ |
|
||||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane}, |
|
||||||
}; |
|
||||||
} else { |
|
||||||
itemNameTextField = new UITextField(); |
|
||||||
components = new Component[][]{ |
|
||||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField}, |
|
||||||
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane}, |
|
||||||
}; |
|
||||||
} |
|
||||||
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
|
||||||
headerPane.add(northPane, BorderLayout.NORTH); |
|
||||||
return headerPane; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String title4PopupWindow() { |
|
||||||
return "reportlet"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void populateSubHyperlinkBean(ReportletHyperlink link) { |
|
||||||
if (itemNameTextField != null) { |
|
||||||
this.itemNameTextField.setText(link.getItemName()); |
|
||||||
} |
|
||||||
this.reportPathTextField.setText(link.getReportletPath()); |
|
||||||
this.showParameterInterface.setSelected(link.isShowParameterInterface()); |
|
||||||
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected ReportletHyperlink updateSubHyperlinkBean() { |
|
||||||
ReportletHyperlink reportletHyperlink = new ReportletHyperlink(); |
|
||||||
updateSubHyperlinkBean(reportletHyperlink); |
|
||||||
|
|
||||||
return reportletHyperlink; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) { |
|
||||||
if (itemNameTextField != null) { |
|
||||||
reportletHyperlink.setItemName(this.itemNameTextField.getText()); |
|
||||||
} |
|
||||||
reportletHyperlink.setReportletPath(this.reportPathTextField.getText()); |
|
||||||
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected()); |
|
||||||
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1 ? true : false); |
|
||||||
} |
|
||||||
|
|
||||||
public String getReportletName() { |
|
||||||
return StringUtils.isBlank(this.reportPathTextField.getText()) ? StringUtils.EMPTY : this.reportPathTextField.getText().substring(1); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 获取按钮焦点 |
|
||||||
*/ |
|
||||||
public void requestButtonFocus() { |
|
||||||
this.browserButton.requestFocus(); |
|
||||||
JPopupMenu popup = new JPopupMenu(); |
|
||||||
FakeTipAction tip = new FakeTipAction(); |
|
||||||
tip.setEnabled(false); |
|
||||||
popup.add(tip); |
|
||||||
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton); |
|
||||||
} |
|
||||||
|
|
||||||
private class FakeTipAction extends UpdateAction { |
|
||||||
public FakeTipAction() { |
|
||||||
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Select")); |
|
||||||
} |
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
//do nothing
|
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected JPanel setFootPanel() { |
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double[] rowSize = {p, p, p}; |
|
||||||
double[] columnSize = {p, TableLayout.FILL}; |
|
||||||
showParameterInterface = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display")); |
|
||||||
JPanel showParameterPanel = new JPanel(); |
|
||||||
showParameterPanel.add(new UILabel()); |
|
||||||
showParameterPanel.add(showParameterInterface); |
|
||||||
|
|
||||||
postComboBox = new UIComboBox(new String[]{"GET", "POST"}); |
|
||||||
JPanel postPanel = new JPanel(); |
|
||||||
postPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type"))); |
|
||||||
postPanel.add(postComboBox); |
|
||||||
Component[][] components = {{postPanel}, |
|
||||||
{showParameterPanel}, |
|
||||||
{new UILabel(" ")} |
|
||||||
}; |
|
||||||
|
|
||||||
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -0,0 +1,509 @@ |
|||||||
|
package com.fr.design.hyperlink; |
||||||
|
|
||||||
|
import com.fr.base.BaseFormula; |
||||||
|
import com.fr.design.actions.UpdateAction; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.formula.FormulaFactory; |
||||||
|
import com.fr.design.formula.UIFormula; |
||||||
|
import com.fr.design.formula.VariableResolver; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ibutton.UIRadioButton; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextfield.UINumberField; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.gui.itree.filetree.ReportletPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.js.ReportletHyperlink; |
||||||
|
import com.fr.js.ReportletHyperlinkDialogAttr; |
||||||
|
import com.fr.stable.FormulaProvider; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.ButtonGroup; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JPopupMenu; |
||||||
|
import javax.swing.SwingUtilities; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面. |
||||||
|
* |
||||||
|
* @author kunsnat |
||||||
|
*/ |
||||||
|
public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> { |
||||||
|
/** |
||||||
|
* item name text filed |
||||||
|
*/ |
||||||
|
private UITextField itemNameTextField; |
||||||
|
/** |
||||||
|
* 是否展示item name |
||||||
|
*/ |
||||||
|
private boolean needRenamePane = false; |
||||||
|
/** |
||||||
|
* 参数路径输入框 |
||||||
|
*/ |
||||||
|
private UITextField reportPathTextField; |
||||||
|
/** |
||||||
|
* 是否展示参数面板勾选框 |
||||||
|
*/ |
||||||
|
private UICheckBox showParameterInterface; |
||||||
|
/** |
||||||
|
* 选择文件按钮 |
||||||
|
*/ |
||||||
|
private UIButton browserButton; |
||||||
|
|
||||||
|
/** |
||||||
|
* 参数传递方式下拉选择框 |
||||||
|
*/ |
||||||
|
private UIComboBox postComboBox; |
||||||
|
/** |
||||||
|
* 对话框标题输入框 |
||||||
|
*/ |
||||||
|
private JFormulaField titleFiled; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 对话框居中按钮 |
||||||
|
*/ |
||||||
|
private UIRadioButton center; |
||||||
|
/** |
||||||
|
* 对话框位置自定义按钮 |
||||||
|
*/ |
||||||
|
private UIRadioButton custom; |
||||||
|
/** |
||||||
|
* 距左 |
||||||
|
*/ |
||||||
|
private UINumberField leftLocation; |
||||||
|
/** |
||||||
|
* 距上 |
||||||
|
*/ |
||||||
|
private UINumberField topLocation; |
||||||
|
|
||||||
|
|
||||||
|
public ReportletHyperNorthPane(boolean needRenamePane) { |
||||||
|
this.needRenamePane = needRenamePane; |
||||||
|
} |
||||||
|
|
||||||
|
public ReportletHyperNorthPane() { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化面板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected void initComponents() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||||
|
|
||||||
|
final List<Component[]> dialogComponents = new ArrayList<>(); |
||||||
|
final List<Component[]> othersComponents = new ArrayList<>(); |
||||||
|
|
||||||
|
initRenamePanel(dialogComponents, othersComponents); |
||||||
|
initHeaderPanel(dialogComponents, othersComponents); |
||||||
|
initTargetComboBoxPanel(dialogComponents, othersComponents); |
||||||
|
|
||||||
|
initTitlePanel(dialogComponents); |
||||||
|
initDialogSizePanel(dialogComponents); |
||||||
|
initDialogLocationPanel(dialogComponents); |
||||||
|
|
||||||
|
initFooterPanel(dialogComponents, othersComponents); |
||||||
|
|
||||||
|
initPlaceHolder(othersComponents); |
||||||
|
|
||||||
|
bindListener(dialogComponents, othersComponents); |
||||||
|
|
||||||
|
// 创建内容面板
|
||||||
|
JPanel content = TableLayoutHelper.createTableLayoutPane(dialogComponents.toArray(new Component[dialogComponents.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW); |
||||||
|
this.add(content, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 生成最上方的配置面板 |
||||||
|
* |
||||||
|
* @return JPanel |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected JPanel setHeaderPanel() { |
||||||
|
|
||||||
|
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
// 路径输入框
|
||||||
|
reportPathTextField = new UITextField(20); |
||||||
|
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); |
||||||
|
|
||||||
|
// 选择路径按钮
|
||||||
|
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); |
||||||
|
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); |
||||||
|
reportletNamePane.add(browserButton, BorderLayout.EAST); |
||||||
|
browserButton.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
final ReportletPane reportletPane = new ReportletPane(); |
||||||
|
reportletPane.setSelectedReportletPath(reportPathTextField.getText()); |
||||||
|
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReportletHyperNorthPane.this)); |
||||||
|
|
||||||
|
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
reportPathTextField.setText(reportletPane.getSelectedReportletPath()); |
||||||
|
} |
||||||
|
}); |
||||||
|
reportletDialog.setVisible(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
return reportletNamePane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "reportlet"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void populateSubHyperlinkBean(ReportletHyperlink link) { |
||||||
|
if (itemNameTextField != null) { |
||||||
|
this.itemNameTextField.setText(link.getItemName()); |
||||||
|
} |
||||||
|
this.reportPathTextField.setText(link.getReportletPath()); |
||||||
|
this.showParameterInterface.setSelected(link.isShowParameterInterface()); |
||||||
|
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0); |
||||||
|
|
||||||
|
ReportletHyperlinkDialogAttr attr = link.getAttr(); |
||||||
|
titleFiled.setFormulaText(StringUtils.EMPTY); |
||||||
|
leftLocation.setText(StringUtils.EMPTY); |
||||||
|
topLocation.setText(StringUtils.EMPTY); |
||||||
|
center.setSelected(true); |
||||||
|
if (attr != null) { |
||||||
|
FormulaProvider title = attr.getTitleFormula(); |
||||||
|
String titleContent = title == null ? StringUtils.EMPTY : title.getPureContent(); |
||||||
|
titleFiled.setFormulaText(titleContent); |
||||||
|
boolean isCenter = attr.isCenter(); |
||||||
|
if (!isCenter) { |
||||||
|
int left = attr.getLeft(), top = attr.getTop(); |
||||||
|
leftLocation.setText(Integer.toString(left)); |
||||||
|
topLocation.setText(Integer.toString(top)); |
||||||
|
} |
||||||
|
center.setSelected(isCenter); |
||||||
|
custom.setSelected(!isCenter); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected ReportletHyperlink updateSubHyperlinkBean() { |
||||||
|
ReportletHyperlink reportletHyperlink = new ReportletHyperlink(); |
||||||
|
updateSubHyperlinkBean(reportletHyperlink); |
||||||
|
return reportletHyperlink; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) { |
||||||
|
if (itemNameTextField != null) { |
||||||
|
reportletHyperlink.setItemName(this.itemNameTextField.getText()); |
||||||
|
} |
||||||
|
reportletHyperlink.setReportletPath(this.reportPathTextField.getText()); |
||||||
|
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected()); |
||||||
|
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1); |
||||||
|
|
||||||
|
ReportletHyperlinkDialogAttr attr = new ReportletHyperlinkDialogAttr(); |
||||||
|
attr.setTitleFormula(BaseFormula.createFormulaBuilder().build(titleFiled.getFormulaText())); |
||||||
|
attr.setCenter(center.isSelected()); |
||||||
|
if (!attr.isCenter()) { |
||||||
|
attr.setLeft((int) leftLocation.getValue()); |
||||||
|
attr.setTop((int) topLocation.getValue()); |
||||||
|
} |
||||||
|
reportletHyperlink.setAttr(attr); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public String getReportletName() { |
||||||
|
String text = this.reportPathTextField.getText(); |
||||||
|
return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取按钮焦点 |
||||||
|
*/ |
||||||
|
public void requestButtonFocus() { |
||||||
|
this.browserButton.requestFocus(); |
||||||
|
JPopupMenu popup = new JPopupMenu(); |
||||||
|
FakeTipAction tip = new FakeTipAction(); |
||||||
|
tip.setEnabled(false); |
||||||
|
popup.add(tip); |
||||||
|
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton); |
||||||
|
} |
||||||
|
|
||||||
|
private class FakeTipAction extends UpdateAction { |
||||||
|
public FakeTipAction() { |
||||||
|
this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Select")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
// do nothing
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 底部面板,参数传递方式 |
||||||
|
* |
||||||
|
* @return JPanel |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected JPanel setFootPanel() { |
||||||
|
JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
|
|
||||||
|
// 参数传递方式下拉框
|
||||||
|
postComboBox = new UIComboBox(new String[]{"GET", "POST"}); |
||||||
|
postComboBox.setPreferredSize(new Dimension(60, 20)); |
||||||
|
postComboBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
content.add(postComboBox); |
||||||
|
|
||||||
|
|
||||||
|
showParameterInterface = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display")); |
||||||
|
|
||||||
|
showParameterInterface.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||||
|
content.add(showParameterInterface); |
||||||
|
return content; |
||||||
|
} |
||||||
|
|
||||||
|
private void bindListener(final List<Component[]> dialogComponents, final List<Component[]> othersComponents) { |
||||||
|
final UIComboBox targetFrameComboBox = this.getTargetFrameComboBox(); |
||||||
|
targetFrameComboBox.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
boolean show = DIALOG == targetFrameComboBox.getSelectedIndex(); |
||||||
|
JPanel content; |
||||||
|
List<Component[]> cs = show ? dialogComponents : othersComponents; |
||||||
|
ReportletHyperNorthPane.this.removeAll(); |
||||||
|
content = TableLayoutHelper.createTableLayoutPane(cs.toArray(new Component[cs.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW); |
||||||
|
ReportletHyperNorthPane.this.add(content, BorderLayout.CENTER); |
||||||
|
ReportletHyperNorthPane.this.revalidate(); |
||||||
|
ReportletHyperNorthPane.this.repaint(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void initPlaceHolder(List<Component[]> othersComponents) { |
||||||
|
JPanel empty1 = new JPanel(); |
||||||
|
empty1.setPreferredSize(new Dimension(20, 20)); |
||||||
|
JPanel empty2 = new JPanel(); |
||||||
|
empty2.setPreferredSize(new Dimension(20, 20)); |
||||||
|
JPanel empty3 = new JPanel(); |
||||||
|
empty3.setPreferredSize(new Dimension(20, 23)); |
||||||
|
|
||||||
|
othersComponents.add(new Component[]{empty1, new JPanel()}); |
||||||
|
othersComponents.add(new Component[]{empty2, new JPanel()}); |
||||||
|
othersComponents.add(new Component[]{empty3, new JPanel()}); |
||||||
|
} |
||||||
|
|
||||||
|
private void initRenamePanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||||
|
// 是否有重命名属性
|
||||||
|
if (this.needRenamePane) { |
||||||
|
itemNameTextField = new UITextField(); |
||||||
|
Component[] renameComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField}; |
||||||
|
dialogComponents.add(renameComponents); |
||||||
|
othersComponents.add(renameComponents); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void initHeaderPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||||
|
//最上方位置的面板
|
||||||
|
JPanel headerPane = this.setHeaderPanel(); |
||||||
|
Component[] headerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), headerPane}; |
||||||
|
dialogComponents.add(headerComponents); |
||||||
|
othersComponents.add(headerComponents); |
||||||
|
} |
||||||
|
|
||||||
|
private void initTargetComboBoxPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||||
|
// 链接打开于
|
||||||
|
UIComboBox targetFrameComboBox = new UIComboBox(getTargetFrames()); |
||||||
|
this.setTargetFrameComboBox(targetFrameComboBox); |
||||||
|
targetFrameComboBox.setEditable(true); |
||||||
|
targetFrameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||||
|
JPanel targetFramePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
|
targetFramePanel.add(targetFrameComboBox); |
||||||
|
Component[] targetComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Link_Opened_In") + ":"), targetFramePanel}; |
||||||
|
dialogComponents.add(targetComponents); |
||||||
|
othersComponents.add(targetComponents); |
||||||
|
} |
||||||
|
|
||||||
|
private void initTitlePanel(List<Component[]> dialogComponents) { |
||||||
|
// 对话框标题
|
||||||
|
titleFiled = new JFormulaField(15); |
||||||
|
final JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
|
titlePanel.add(titleFiled); |
||||||
|
Component[] titleComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Title") + ":"), titlePanel}; |
||||||
|
dialogComponents.add(titleComponents); |
||||||
|
} |
||||||
|
|
||||||
|
private void initDialogSizePanel(List<Component[]> dialogComponents) {// 对话框大小
|
||||||
|
final JPanel sizeJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
|
UILabel heightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Height") + ":"); |
||||||
|
heightLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); |
||||||
|
sizeJPanel.add(heightLabel); |
||||||
|
UINumberField heightTextFiled = new UINumberField(); |
||||||
|
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); |
||||||
|
heightTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||||
|
sizeJPanel.add(heightTextFiled); |
||||||
|
this.setHeightTextFiled(heightTextFiled); |
||||||
|
UILabel widthLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Designer_Width") + ":"); |
||||||
|
widthLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
||||||
|
sizeJPanel.add(widthLabel); |
||||||
|
UINumberField widthTextFiled = new UINumberField(); |
||||||
|
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); |
||||||
|
widthTextFiled.setPreferredSize(new Dimension(40, 20)); |
||||||
|
sizeJPanel.add(widthTextFiled); |
||||||
|
this.setWidthTextFiled(widthTextFiled); |
||||||
|
sizeJPanel.setVisible(true); |
||||||
|
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Size") + ":"), sizeJPanel}); |
||||||
|
} |
||||||
|
|
||||||
|
private void initDialogLocationPanel(List<Component[]> dialogComponents) { |
||||||
|
// 显示位置
|
||||||
|
final JPanel locationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||||
|
// 居中
|
||||||
|
center = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Center")); |
||||||
|
// 自定义
|
||||||
|
custom = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Custom")); |
||||||
|
|
||||||
|
custom.setBorder(BorderFactory.createEmptyBorder(4, 20, 4, 5)); |
||||||
|
ButtonGroup group = new ButtonGroup(); |
||||||
|
group.setSelected(center.getModel(), true); |
||||||
|
group.add(center); |
||||||
|
group.add(custom); |
||||||
|
locationPanel.add(center); |
||||||
|
locationPanel.add(custom); |
||||||
|
|
||||||
|
// 位置 距左
|
||||||
|
final UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Left")); |
||||||
|
leftLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10)); |
||||||
|
leftLocation = new UINumberField(); |
||||||
|
leftLocation.setPreferredSize(new Dimension(40, 20)); |
||||||
|
// 位置 距上
|
||||||
|
final UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Top")); |
||||||
|
topLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
||||||
|
topLocation = new UINumberField(); |
||||||
|
topLocation.setPreferredSize(new Dimension(40, 20)); |
||||||
|
|
||||||
|
locationPanel.add(leftLabel); |
||||||
|
locationPanel.add(leftLocation); |
||||||
|
locationPanel.add(topLabel); |
||||||
|
locationPanel.add(topLocation); |
||||||
|
leftLabel.setVisible(false); |
||||||
|
leftLocation.setVisible(false); |
||||||
|
topLabel.setVisible(false); |
||||||
|
topLocation.setVisible(false); |
||||||
|
ChangeListener actionListener = new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
boolean visible = custom.isSelected(); |
||||||
|
leftLabel.setVisible(visible); |
||||||
|
leftLocation.setVisible(visible); |
||||||
|
topLabel.setVisible(visible); |
||||||
|
topLocation.setVisible(visible); |
||||||
|
} |
||||||
|
}; |
||||||
|
// 默认居中
|
||||||
|
center.setSelected(true); |
||||||
|
center.addChangeListener(actionListener); |
||||||
|
custom.addChangeListener(actionListener); |
||||||
|
|
||||||
|
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Show_Position") + ":"), locationPanel}); |
||||||
|
} |
||||||
|
|
||||||
|
private void initFooterPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) { |
||||||
|
// 最下方的配置面板
|
||||||
|
// 参数传递方式
|
||||||
|
Component[] footerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type") + ":"), this.setFootPanel()}; |
||||||
|
dialogComponents.add(footerComponents); |
||||||
|
othersComponents.add(footerComponents); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 公式输入框 |
||||||
|
*/ |
||||||
|
public class JFormulaField extends JPanel { |
||||||
|
private UITextField formulaTextField; |
||||||
|
|
||||||
|
public JFormulaField(int columns) { |
||||||
|
|
||||||
|
formulaTextField = new UITextField(columns); |
||||||
|
JPanel textFieldPane = new JPanel(new BorderLayout()); |
||||||
|
textFieldPane.add(formulaTextField, BorderLayout.CENTER); |
||||||
|
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); |
||||||
|
UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||||
|
formulaButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Formula") + "..."); |
||||||
|
formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height)); |
||||||
|
formulaButton.addActionListener(formulaButtonActionListener); |
||||||
|
|
||||||
|
JPanel pane = new JPanel(new BorderLayout()); |
||||||
|
pane.add(textFieldPane, BorderLayout.CENTER); |
||||||
|
pane.add(formulaButton, BorderLayout.EAST); |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(pane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
public void setFormulaText(String formulaContent) { |
||||||
|
this.formulaTextField.setText(formulaContent); |
||||||
|
} |
||||||
|
|
||||||
|
public String getFormulaText() { |
||||||
|
|
||||||
|
String text = formulaTextField.getText(); |
||||||
|
if (text == null) { |
||||||
|
text = StringUtils.EMPTY; |
||||||
|
} |
||||||
|
return text; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加事件监听器 |
||||||
|
* |
||||||
|
* @param listener 公式文本输入框改动事件监听器 |
||||||
|
*/ |
||||||
|
public void addListener(UIObserverListener listener) { |
||||||
|
this.formulaTextField.registerChangeListener(listener); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 取消事件监听器 |
||||||
|
*/ |
||||||
|
public void removeListener() { |
||||||
|
this.formulaTextField.registerChangeListener(null); |
||||||
|
} |
||||||
|
|
||||||
|
private ActionListener formulaButtonActionListener = new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); |
||||||
|
valueFormula.setContent(getFormulaText()); |
||||||
|
final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); |
||||||
|
formulaPane.populate(valueFormula, VariableResolver.DEFAULT); |
||||||
|
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(ReportletHyperNorthPane.this), new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
BaseFormula valueFormula = formulaPane.update(); |
||||||
|
setFormulaText(valueFormula.getContent()); |
||||||
|
} |
||||||
|
}).setVisible(true); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue