From ed16a1919166926a9e65d6ccf952edf17956a571 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 10 Jan 2024 15:38:39 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-99485=20=E6=82=AC=E6=B5=AE=E5=85=83?= =?UTF-8?q?=E7=B4=A0FloatStringQuickEditor=E5=B8=83=E5=B1=80=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/menu/MenuDef.java | 31 ++++++++-- .../floatquick/FloatStringQuickEditor.java | 62 ++++++------------- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index 5b82786abd..1f5de9a2d1 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -137,12 +137,12 @@ public class MenuDef extends ShortCut { * 设置不可用图标时,注意传递路径问题,若路径为"view_normal.svg",请传递"view",不带后缀 * 读取disable图标的文件名应当为"xxx_disabled.svg",也是项目中的svg命名规范 * 注意必须是svg图标路径才能使用此函数设置正常和禁用状态 - * - * */ + */ public void setDisabledIcon(String iconPath, boolean needDisabled) { this.iconPath = iconPath; this.needDisabled = needDisabled; } + public int getShortCutCount() { return this.shortcutList.size(); } @@ -226,6 +226,29 @@ public class MenuDef extends ShortCut { return createdButton; } + /** + * 添加常规按钮 + * + * @return 按钮 + */ + public UIButton createNormalButton() { + if (createdButton == null) { + if (icon != null) { + createdButton = new UIButton(icon); + } else if (iconPath != null) { + createdButton = new UIButton(IconUtils.readIcon(iconPath)); + } else { + createdButton = new UIButton(name); + } + // 添加名字以作自动化测试 + createdButton.setName(name); + createdButton.setToolTipText(tooltip); + createdButton.addMouseListener(mouseListener); + } + + return createdButton; + } + public void setTooltip(String text) { this.tooltip = text; } @@ -260,7 +283,7 @@ public class MenuDef extends ShortCut { UIMenu createdJMenu; if (hasScrollSubMenu) { createdJMenu = new UIScrollMenu(this.getName()); - } else if (isHeadMenu){ + } else if (isHeadMenu) { createdJMenu = new UIHeadMenu(this.getName()); } else { createdJMenu = new UIMenu(this.getName()); @@ -349,8 +372,6 @@ public class MenuDef extends ShortCut { } - - public void updateEnable() { setEnabled(checkEnable()); } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java index 5dc4140883..cef5fa54ff 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/floatquick/FloatStringQuickEditor.java @@ -1,39 +1,34 @@ package com.fr.quickeditor.floatquick; +import com.fine.theme.icon.LazyIcon; import com.fr.base.BaseFormula; -import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.base.TextFormat; -import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.utils.DesignUtils; import com.fr.quickeditor.FloatQuickEditor; import com.fr.report.ReportHelper; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JTextArea; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; + +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.row; public class FloatStringQuickEditor extends FloatQuickEditor { - private JTextArea stringTextField; - private UIButton formulaButton; + private final UITextArea stringTextField; + private final UIButton formulaButton; // august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置 private boolean reserveInResult = false; private boolean reserveOnWriteOrAnaly = true; - private DocumentListener documentListener = new DocumentListener() { + private final DocumentListener documentListener = new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { @@ -54,36 +49,19 @@ public class FloatStringQuickEditor extends FloatQuickEditor { public FloatStringQuickEditor() { super(); - stringTextField = new JTextArea(); - initTextField(); + stringTextField = new UITextArea(); formulaButton = new UIButton(); - formulaButton.setPreferredSize(new Dimension(25, 23)); - formulaButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); - ActionListener getFormulaActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - ((ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane()).getGrid().startEditing(); - } - }; - formulaButton.addActionListener(getFormulaActionListener); - JPanel pane = new JPanel(new BorderLayout(5, 0)); - pane.add(stringTextField, BorderLayout.CENTER); - pane.add(formulaButton, BorderLayout.EAST); - pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); + formulaButton.setIcon(new LazyIcon("formula")); + formulaButton.addActionListener(e -> ((ElementCasePane) HistoryTemplateListPane.getInstance() + .getCurrentEditingTemplate().getCurrentElementCasePane()) + .getGrid().startEditing()); formulaButton.setVisible(false); this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - this.add(pane, BorderLayout.NORTH); - } - - private void initTextField() { - stringTextField.setFont(DesignUtils.getDefaultGUIFont()); - stringTextField.setOpaque(true); - stringTextField.setLineWrap(true); - stringTextField.setWrapStyleWord(true); - stringTextField.setMargin(new Insets(5, 5, 5, 5)); - stringTextField.setBorder(BorderFactory.createLineBorder(UIConstants.POP_DIALOG_BORDER)); - stringTextField.setBackground(Color.WHITE); + add(row(10, + cell(stringTextField).weight(1), + cell(formulaButton) + ).getComponent(), BorderLayout.NORTH); } @@ -92,19 +70,17 @@ public class FloatStringQuickEditor extends FloatQuickEditor { String str; Object value = null; //处理撤销时npe - if (floatElement != null){ + if (floatElement != null) { value = floatElement.getValue(); } if (value == null) { str = StringUtils.EMPTY; } else if (value instanceof BaseFormula) { - //MoMeak: 没拆文本框和公式所以需要这么个玩意 formulaButton.setVisible(true); BaseFormula formula = (BaseFormula) value; str = formula.getContent(); stringTextField.setLineWrap(false); - this.setBorder(BorderFactory.createEmptyBorder(10, 75, 10, 10)); reserveInResult = formula.isReserveInResult(); reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); } else { @@ -121,7 +97,7 @@ public class FloatStringQuickEditor extends FloatQuickEditor { private void changeReportPaneCell(String tmpText) { - if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { + if (tmpText != null && (!tmpText.isEmpty() && tmpText.charAt(0) == '=')) { BaseFormula textFormula = BaseFormula.createFormulaBuilder().build(tmpText); textFormula.setReserveInResult(reserveInResult); textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly);