From 88cfa15c8411a1b4c5a2ad0f5d42c5b398d7c494 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 23 Nov 2021 15:59:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-63192=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8F=AF=E6=9B=B4=E6=96=B0=E6=8F=90=E9=86=92=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=AB=AF=E7=94=9F=E6=88=90=E7=BB=84=E4=BB=B6=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 整理下目前组件生成面板中必填项的校验规则 2. 将组件类型设置渐入到必填项的校验规则中 【改动思路】 同上 --- .../share/ui/generate/ShareGeneratePane.java | 68 +++--------------- .../share/ui/generate/ShareMainPane.java | 69 +++++++++++++++++-- 2 files changed, 74 insertions(+), 63 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java index f71a504c8..5969cb6c2 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java @@ -5,6 +5,8 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; @@ -33,15 +35,12 @@ import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.ui.Widget; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.border.Border; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; @@ -113,57 +112,17 @@ public class ShareGeneratePane extends BasicPane { this.mainPane.add(simplePane, ShareUIUtils.convertStateChange(ItemEvent.DESELECTED)); this.mainPane.add(uploadPane, ShareUIUtils.convertStateChange(ItemEvent.SELECTED)); - simplePane.getNameField().getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void changedUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validInput(); - } - + simplePane.addRequiredSettingChangeListener(new ChangeListener() { @Override - public void removeUpdate(DocumentEvent e) { - validInput(); + public void fireChanged(ChangeEvent event) { + checkRequiredSettings(); } }); - simplePane.getDesignerVersionField().getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void changedUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validInput(); - } - + uploadPane.addRequiredSettingChangeListener(new ChangeListener() { @Override - public void removeUpdate(DocumentEvent e) { - validInput(); - } - }); - - uploadPane.getNameField().getDocument().addDocumentListener(new DocumentListener() { - - @Override - public void changedUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - validInput(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - validInput(); + public void fireChanged(ChangeEvent event) { + checkRequiredSettings(); } }); @@ -176,14 +135,9 @@ public class ShareGeneratePane extends BasicPane { return pane; } - private void validInput() { - String name = getSelectMainPane().getNameField().getText().trim(); - boolean isValidName = StringUtils.isNotEmpty(name); - - boolean isValidDesignerVersion = getSelectMainPane().getDesignerVersionField().isValidVersion(); - - boolean isValidInput = isValidName && isValidDesignerVersion; - dialog.setButtonEnabled(isValidInput); + private void checkRequiredSettings() { + boolean isSettingsRequired = getSelectMainPane().checkRequiredSettings(); + dialog.setButtonEnabled(isSettingsRequired); } diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index b19dbd659..7bcad336f 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java @@ -5,6 +5,8 @@ import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; import com.fr.design.extra.LoginWebBridge; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -62,6 +64,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.MatteBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; @@ -142,6 +146,9 @@ public class ShareMainPane extends JPanel { private List effectItemGroups; private final boolean needContentTip; + // 监听必填项 + private ChangeListener requiredSettingChangeListener; + public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List effectItemGroups, boolean needContentTip) { this.shareCover = shareCover; @@ -410,11 +417,31 @@ public class ShareMainPane extends JPanel { pane.add(parentClassify); pane.add(childClassify); + + UILabel validSymbol = new UILabel(" *"); + pane.add(validSymbol); return pane; } private JPanel createDesignerVersionFiledPane() { designerVersionField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT)); + designerVersionField.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void changedUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(designerVersionField)); + } + + @Override + public void insertUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(designerVersionField)); + } + + @Override + public void removeUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(designerVersionField)); + } + }); JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane(); UILabel validSymbol = new UILabel(" *"); symbolTextFiled.add(designerVersionField, BorderLayout.CENTER); @@ -546,6 +573,23 @@ public class ShareMainPane extends JPanel { nameField.setPlaceholder(Toolkit.i18nText("Fine-Design_Share_Name_Placeholder")); nameField.setPreferredSize(new Dimension(TEXT_FIELD_WIDTH, TEXT_FIELD_HEIGHT)); nameField.setDocument(nameLimited); + nameField.getDocument().addDocumentListener(new DocumentListener() { + + @Override + public void changedUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(nameField)); + } + + @Override + public void insertUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(nameField)); + } + + @Override + public void removeUpdate(DocumentEvent e) { + notifyRequiredSettingChanged(new ChangeEvent(nameField)); + } + }); JPanel symbolTextFiled = FRGUIPaneFactory.createBorderLayout_S_Pane(); UILabel validSymbol = new UILabel(" *"); symbolTextFiled.add(nameField, BorderLayout.CENTER); @@ -672,16 +716,29 @@ public class ShareMainPane extends JPanel { return provider; } - public Group getSelectGroup() { - return (Group) localGroup.getSelectedItem(); + public boolean checkRequiredSettings() { + String name = nameField.getText().trim(); + boolean isNameRequired = StringUtils.isNotEmpty(name); + + boolean isDesignerVersionRequired = designerVersionField.isValidVersion(); + + boolean isClassifyRequired = parentClassify.getSelectedItem() != null && childClassify.getSelectedItem() != null; + + return isNameRequired && isDesignerVersionRequired && isClassifyRequired; + } + + public void addRequiredSettingChangeListener(ChangeListener changeListener) { + this.requiredSettingChangeListener = changeListener; } - public UITextField getNameField() { - return nameField; + private void notifyRequiredSettingChanged(ChangeEvent event) { + if (this.requiredSettingChangeListener != null) { + this.requiredSettingChangeListener.fireChanged(event); + } } - public VersionIntervalField getDesignerVersionField() { - return designerVersionField; + public Group getSelectGroup() { + return (Group) localGroup.getSelectedItem(); } private String classify(Object classify) { From fb67c0901c388166ee42b530c792ed3fb38ee769 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 23 Nov 2021 17:21:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-63194=20=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=8F=AF=E6=9B=B4=E6=96=B0=E6=8F=90=E9=86=92=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8-=E9=80=82=E9=85=8D=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E5=AD=97=E6=AE=B5=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=97=B6=E4=BC=9A=E5=87=BA=E7=8E=B0=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E6=B6=88=E5=A4=B1=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 合成文本,如中文等存在输入-删除-替换的机制,参考JTextComponent#replaceInputMethodText() 所以insertString中不能直接return,而应该抛出异常中断后续字符处理,否则在处理中文等合成文本时 会导致原有字符被删除 【改动思路】 同上 --- .../com/fr/design/share/ui/generate/ShareMainPane.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index 7bcad336f..5639b5957 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java @@ -818,14 +818,17 @@ public class ShareMainPane extends JPanel { @Override public void insertString(int offset, String str, AttributeSet attrSet) throws BadLocationException { if (str == null) { - return; + throw new BadLocationException(null, offset); } int count = str.length(); for (int i = 0; i < count; i++) { char c = str.charAt(i); if (allowCharAsString.indexOf(c) < 0) { java.awt.Toolkit.getDefaultToolkit().beep(); - return; + // REPORT-63194 + // 合成文本,如中文等存在输入-删除-替换的机制 JTextComponent#replaceInputMethodText() + // 所以这里不能直接return,而应该抛出异常中断后续字符处理,否则在处理中文等合成文本时会导致原有字符被删除 + throw new BadLocationException(str, offset); } } super.insertString(offset, str, attrSet); From 23ece8197e7460b3d0b94a774b8f391bdfafdf02 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 24 Nov 2021 15:00:35 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-63250=20=E7=BB=84=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=86=E8=A7=89=E9=AA=8C=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 修改设计器组件商城面板上一些控件的展示效果 【改动思路】 同上 --- .../design/mainframe/share/ui/local/LocalWidgetRepoPane.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java index fd050513b..0d0cff570 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java @@ -119,10 +119,12 @@ public class LocalWidgetRepoPane extends BasicPane { content.add(LabelUtils.createAutoWrapLabel(Toolkit.i18nText("Fine-Design_Share_Upgrade_Tip"), new Color(0x333334)), BorderLayout.CENTER); JPanel actionsPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); + actionsPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, -5)); actionsPane.setOpaque(false); actionsPane.setBackground(null); UIButton cancelUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_Cancel")); + cancelUpgradeButton.setRoundBorder(true); cancelUpgradeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -132,6 +134,8 @@ public class LocalWidgetRepoPane extends BasicPane { UIButton startUpgradeButton = new UIButton(Toolkit.i18nText("Fine-Design_Share_Upgrade_All")); startUpgradeButton.setSelected(true); + startUpgradeButton.setRoundBorder(true); + startUpgradeButton.setBorderPainted(false); startUpgradeButton.setForeground(Color.WHITE); startUpgradeButton.addActionListener(new ActionListener() { @Override From 0c77e8cdf3f2f8c0c9a84e7ad6ef2f409919e91c Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Wed, 24 Nov 2021 17:41:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-63196=20&&=20REPORT-63186=201.?= =?UTF-8?q?=E5=9C=A8=E5=8F=8C=E5=87=BB=E4=B9=8B=E5=90=8E=E4=BD=BF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A1=86=E6=B6=88=E5=A4=B1=EF=BC=9B=202.=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E8=AE=A1=E7=AE=97=E5=9C=A8=E8=AE=A1=E7=AE=97=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E6=97=B6=E5=80=99=E6=8F=90=E7=A4=BA=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index b11644e68..dc1e03027 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -46,6 +46,7 @@ import com.fr.parser.BlockIntervalLiteral; import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.NumberLiteral; import com.fr.parser.SheetIntervalLiteral; +import com.fr.record.analyzer.EnableMetrics; import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.script.Calculator; import com.fr.script.ScriptConstants; @@ -54,7 +55,6 @@ import com.fr.stable.EncodeConstants; import com.fr.stable.EssentialUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import com.fr.stable.UtilEvalError; import com.fr.stable.script.CRAddress; import com.fr.stable.script.ColumnRowRange; import com.fr.stable.script.Expression; @@ -122,6 +122,7 @@ import java.util.Set; * @editor zhou * @since 2012-3-29下午1:50:53 */ +@EnableMetrics public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public static final int DEFUAL_FOMULA_LENGTH = 103; public static final String ELLIPSIS = "..."; @@ -139,6 +140,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { protected static UICheckBox autoCompletionCheck; protected static UICheckBox checkBeforeColse; private JList tipsList; + private JPopupMenu popupMenu; protected DefaultListModel listModel = new DefaultListModel(); private int ifHasBeenWriten = 0; private DefaultListModel functionTypeListModel = new DefaultListModel(); @@ -457,6 +459,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { doubleClickActuator(doublePressContent); } + if (popupMenu != null) { + popupMenu.setVisible(false); + } } } } @@ -616,7 +621,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } private void popTips() { - JPopupMenu popupMenu = new JPopupMenu(); + popupMenu = new JPopupMenu(); JScrollPane tipsScrollPane = new JScrollPane(tipsList); popupMenu.add(tipsScrollPane); tipsScrollPane.setPreferredSize(new Dimension(240, 146)); @@ -792,6 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private final ActionListener calculateActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { String formulaText = formulaTextArea.getText().trim(); @@ -819,16 +825,20 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); + Object calResult; try { - Object value = calculator.evalValue(baseFormula); - String objectToString = EssentialUtils.objectToString(value); + calResult = calculator.evalValue(baseFormula); + String objectToString = EssentialUtils.objectToString(calResult); String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; - FineLoggerFactory.getLogger().info("value:{}", value); - } catch (UtilEvalError utilEvalError) { - FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); + } catch (Exception ce) { + //模拟计算如果出现错误,则抛出错误 + calResult = ce.getMessage(); + FineLoggerFactory.getLogger().error(ce.getMessage(), ce); + messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Error") + ":" + calResult; } + FineLoggerFactory.getLogger().info("value:{}", calResult); } else { messageTips = checkResult.getTips(); }