|
|
|
@ -4,10 +4,7 @@ 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.formula.TinyFormulaPane; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
import com.fr.design.gui.ibutton.UIRadioButton; |
|
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
@ -20,9 +17,9 @@ 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.CommonUtils; |
|
|
|
|
import com.fr.stable.FormulaProvider; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
@ -76,7 +73,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
/** |
|
|
|
|
* 对话框标题输入框 |
|
|
|
|
*/ |
|
|
|
|
private JFormulaField titleFiled; |
|
|
|
|
private TinyFormulaPane titleFiled; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -186,14 +183,19 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0); |
|
|
|
|
|
|
|
|
|
ReportletHyperlinkDialogAttr attr = link.getAttr(); |
|
|
|
|
titleFiled.setFormulaText(StringUtils.EMPTY); |
|
|
|
|
titleFiled.populateBean(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); |
|
|
|
|
Object title = attr.getTitle(); |
|
|
|
|
String titleContent; |
|
|
|
|
if (title instanceof FormulaProvider) { |
|
|
|
|
titleContent = ((FormulaProvider) title).getContent(); |
|
|
|
|
} else { |
|
|
|
|
titleContent = title == null ? StringUtils.EMPTY : title.toString(); |
|
|
|
|
} |
|
|
|
|
titleFiled.populateBean(titleContent); |
|
|
|
|
boolean isCenter = attr.isCenter(); |
|
|
|
|
if (!isCenter) { |
|
|
|
|
int left = attr.getLeft(), top = attr.getTop(); |
|
|
|
@ -222,7 +224,12 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1); |
|
|
|
|
|
|
|
|
|
ReportletHyperlinkDialogAttr attr = new ReportletHyperlinkDialogAttr(); |
|
|
|
|
attr.setTitleFormula(BaseFormula.createFormulaBuilder().build(titleFiled.getFormulaText())); |
|
|
|
|
String title = titleFiled.updateBean(); |
|
|
|
|
if (CommonUtils.maybeFormula(title)) { |
|
|
|
|
attr.setTitle(BaseFormula.createFormulaBuilder().build(titleFiled.updateBean())); |
|
|
|
|
} else { |
|
|
|
|
attr.setTitle(title); |
|
|
|
|
} |
|
|
|
|
attr.setCenter(center.isSelected()); |
|
|
|
|
if (!attr.isCenter()) { |
|
|
|
|
attr.setLeft((int) leftLocation.getValue()); |
|
|
|
@ -346,7 +353,8 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
|
|
|
|
|
private void initTitlePanel(List<Component[]> dialogComponents) { |
|
|
|
|
// 对话框标题
|
|
|
|
|
titleFiled = new JFormulaField(15); |
|
|
|
|
titleFiled = new TinyFormulaPane(); |
|
|
|
|
titleFiled.getUITextField().setColumns(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}; |
|
|
|
@ -359,6 +367,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
heightLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); |
|
|
|
|
sizeJPanel.add(heightLabel); |
|
|
|
|
UINumberField heightTextFiled = new UINumberField(); |
|
|
|
|
heightTextFiled.setMinValue(0); |
|
|
|
|
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE)); |
|
|
|
|
heightTextFiled.setPreferredSize(new Dimension(40, 20)); |
|
|
|
|
sizeJPanel.add(heightTextFiled); |
|
|
|
@ -367,6 +376,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
widthLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); |
|
|
|
|
sizeJPanel.add(widthLabel); |
|
|
|
|
UINumberField widthTextFiled = new UINumberField(); |
|
|
|
|
widthTextFiled.setMinValue(0); |
|
|
|
|
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE)); |
|
|
|
|
widthTextFiled.setPreferredSize(new Dimension(40, 20)); |
|
|
|
|
sizeJPanel.add(widthTextFiled); |
|
|
|
@ -395,11 +405,13 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
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.setMinValue(0); |
|
|
|
|
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.setMinValue(0); |
|
|
|
|
topLocation.setPreferredSize(new Dimension(40, 20)); |
|
|
|
|
|
|
|
|
|
locationPanel.add(leftLabel); |
|
|
|
@ -435,75 +447,4 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyp
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|