From cc5e5d9587c362d851d7f8a074fe58800838ddbf Mon Sep 17 00:00:00 2001 From: Yvan Date: Fri, 7 Aug 2020 14:25:56 +0800 Subject: [PATCH 01/11] =?UTF-8?q?REPORT-32317=20cpt=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E7=BC=A9=E6=94=BE=E9=97=AE=E9=A2=98=20=E5=9C=A8?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BA=86=E7=95=8C=E9=9D=A2=E7=9A=84=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E5=90=8E=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E7=9A=84=E5=AE=BD=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/JWorkBook.java | 11 +++++++++++ .../fr/design/mainframe/ReportComponentComposite.java | 2 ++ 2 files changed, 13 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index b68833f83f..a43623bd72 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1206,4 +1206,15 @@ public class JWorkBook extends JTemplate { super.whenClose(); reportComposite.doRemoveAction(); } + + /** + * 更新滚动条的值(主要是为了重置滚动条里的BoundedRangeModel的extent值),使滚动条的宽度随着界面缩放而变化 + */ + protected void updateScrollValue() { + ElementCasePane elementCasePane = reportComposite.centerCardPane.editingComponet.elementCasePane; + DynamicScrollBar verticalScrollBar = (DynamicScrollBar) elementCasePane.getVerticalScrollBar(); + DynamicScrollBar horizontalScrollBar = (DynamicScrollBar) elementCasePane.getHorizontalScrollBar(); + verticalScrollBar.setValue(verticalScrollBar.getValue()); + horizontalScrollBar.setValue(horizontalScrollBar.getValue()); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 0299899a06..6c527e0f86 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -88,6 +88,8 @@ public class ReportComponentComposite extends JComponent implements RemoveListen value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); + //更新滚动条值,使之随着界面缩放 + parent.updateScrollValue(); } }; From 52175cdf485c5f1e961e862c020a5c31a7f6f163 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 13 Aug 2020 19:29:04 +0800 Subject: [PATCH 02/11] =?UTF-8?q?REPORT-37398=20=E9=9D=9E=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E8=AE=BE=E8=AE=A1=E5=99=A8-=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E6=8A=A5=E8=A1=A8=E5=88=86=E6=A0=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=85=A8=20=E4=B8=BB=E8=A6=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9A=201.=20bug=E5=8E=9F=E5=9B=A0=E6=98=AF?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E7=8E=AF=E5=A2=83=E4=B8=8B=E4=B8=80=E8=A1=8C?= =?UTF-8?q?=E6=94=BE=E4=B8=8D=E4=B8=8B=E5=A4=AA=E5=A4=9A=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=89=80=E4=BB=A5=E8=A2=AB=E6=8C=A4=E6=8E=89=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=8A=9E=E6=B3=95=E6=98=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E5=BD=93=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E6=98=AF=E8=8B=B1=E6=96=87=EF=BC=8C=E5=B0=B1?= =?UTF-8?q?=E5=A2=9E=E5=A4=A7=E7=95=8C=E9=9D=A2=E7=9A=84=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=B0=86=E7=BB=84=E4=BB=B6=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=88=86=E5=9D=97=EF=BC=8C=E5=88=86=E5=88=AB?= =?UTF-8?q?=E7=94=A8JPanel=E8=A3=85=E8=B5=B7=E6=9D=A5=EF=BC=8C=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E5=BD=93=E7=AC=AC=E4=BA=8C=E4=B8=AAJPanel=E6=94=BE?= =?UTF-8?q?=E4=B8=8D=E4=B8=8B=E5=B0=B1=E4=BC=9A=E8=87=AA=E5=8A=A8=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E4=B8=8D=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE=E9=A2=98=202.=20?= =?UTF-8?q?=E7=94=B1=E4=BA=8E=E5=B0=86=E7=BB=84=E4=BB=B6=E5=88=86=E5=9D=97?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E6=89=80=E4=BB=A5=E5=85=B6=E4=BB=96=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E7=8E=AF=E5=A2=83=E4=B8=8B=EF=BC=8C=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E9=AB=98=E5=BA=A6=E4=B9=9F=E9=9C=80=E8=A6=81=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=BE=AE=E8=B0=83=203.=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 11 --- .../mainframe/ReportComponentComposite.java | 2 - .../fr/design/report/ReportColumnsPane.java | 79 +++++++++++-------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index a43623bd72..b68833f83f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1206,15 +1206,4 @@ public class JWorkBook extends JTemplate { super.whenClose(); reportComposite.doRemoveAction(); } - - /** - * 更新滚动条的值(主要是为了重置滚动条里的BoundedRangeModel的extent值),使滚动条的宽度随着界面缩放而变化 - */ - protected void updateScrollValue() { - ElementCasePane elementCasePane = reportComposite.centerCardPane.editingComponet.elementCasePane; - DynamicScrollBar verticalScrollBar = (DynamicScrollBar) elementCasePane.getVerticalScrollBar(); - DynamicScrollBar horizontalScrollBar = (DynamicScrollBar) elementCasePane.getHorizontalScrollBar(); - verticalScrollBar.setValue(verticalScrollBar.getValue()); - horizontalScrollBar.setValue(horizontalScrollBar.getValue()); - } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 6c527e0f86..0299899a06 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -88,8 +88,6 @@ public class ReportComponentComposite extends JComponent implements RemoveListen value = value < MIN ? MIN : value; int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution); - //更新滚动条值,使之随着界面缩放 - parent.updateScrollValue(); } }; diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java index 4062e0dbe5..3d36ecd06d 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; +import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.report.stable.WorkSheetAttr; import com.fr.report.worksheet.WorkSheet; @@ -41,6 +42,7 @@ import java.awt.event.ActionListener; public class ReportColumnsPane extends BasicPane{ public static final int ROW = 0; public static final int COLUMN = 1; + private static final String LOCALE_LANGUAGE_EN = "en"; private int rowOrColumn; private boolean isRepeate; @@ -58,7 +60,7 @@ public class ReportColumnsPane extends BasicPane{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Columns_Repeat_Row"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Columns_Repeat_Column") }; - + private static final String FONT_NAME = "simsun"; private static final int FONT_SIZE = 14; @@ -87,6 +89,7 @@ public class ReportColumnsPane extends BasicPane{ this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel north = new JPanel(new BorderLayout()) { + @Override public void paint(Graphics g) { super.paint(g); super.paintBorder(g); @@ -122,7 +125,7 @@ public class ReportColumnsPane extends BasicPane{ this.add(north, BorderLayout.NORTH); this.add(createRowColumnPane(), BorderLayout.CENTER); } - + private ActionListener onOffListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -220,7 +223,7 @@ public class ReportColumnsPane extends BasicPane{ sampleLablePane.add(cPane); return sampleLablePane; } - + private ActionListener rowChangeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -233,7 +236,7 @@ public class ReportColumnsPane extends BasicPane{ } } }; - + private ActionListener colChangeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -275,7 +278,7 @@ public class ReportColumnsPane extends BasicPane{ RowMaxOrSetPane.add(setRowRadioPane); return RowMaxOrSetPane; } - + private ActionListener toXBtnListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -288,7 +291,7 @@ public class ReportColumnsPane extends BasicPane{ } } }; - + private ActionListener maxBtnListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -310,27 +313,39 @@ public class ReportColumnsPane extends BasicPane{ UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Area")); rowPane.setBorder(explainBorder); rowPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5,13)); - rowPane.setPreferredSize(new Dimension(500,80)); - rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Data") + ":")); + // Yvan: REPORT-37398 判断设计器语言是否为英文 + if (StringUtils.equals(GeneralContext.getLocale().getLanguage(), LOCALE_LANGUAGE_EN)) { + // 如果是英文,需要为这个panel设置更大的height,否则显示不全 + rowPane.setPreferredSize(new Dimension(500,135)); + } else { + // 其它语言环境下也需要将height调高一点点,因为后面将组件分块了,如果不调整height会造成上下间距不等 + rowPane.setPreferredSize(new Dimension(500,90)); + } + // 将组件分成两块,分别装在各自的JPanel中,然后把两个JPanel添加到rowPane中,第二个JPanel放不下时会自动换行 + // 左边的JPanel:分栏数据 + JPanel multiData = new JPanel(); + multiData.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Data") + ":")); repeatColDataTextField = new UITextField(); repeatColDataTextField.setPreferredSize(new Dimension(107,24)); - rowPane.add(repeatColDataTextField); - rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": A2:D5 ")); + multiData.add(repeatColDataTextField); + multiData.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": A2:D5 ")); + // 右边的JPanel:复制行序列 + JPanel copyRowSequence = new JPanel(); copyLabel = new UILabel(REPORT_COLUMN_RAPEAT[rowOrColumn] + ":"); - rowPane.add(copyLabel); - + copyRowSequence.add(copyLabel); copyTitleTextField = new UITextField(); copyTitleTextField.setPreferredSize(new Dimension(107,24)); - rowPane.add(copyTitleTextField); - rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": 1,2-3,5,18")); - - + copyRowSequence.add(copyTitleTextField); + copyRowSequence.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": 1,2-3,5,18")); + // 添加JPanel + rowPane.add(multiData); + rowPane.add(copyRowSequence); return rowPane; } /** * 从worksheetAttr中populate数据给界面 - * + * * @param attr 当前ElementCase的worksheet属性 * @param rowCount 总行数 * @param colCount 总列数 @@ -355,7 +370,7 @@ public class ReportColumnsPane extends BasicPane{ colOrRowConvert(); checkEnable(); } - + /** * populate列分栏数据 */ @@ -376,7 +391,7 @@ public class ReportColumnsPane extends BasicPane{ this.maxNumberSpinner.setEnabled(true); } } - + /** * populate行分栏 */ @@ -400,7 +415,7 @@ public class ReportColumnsPane extends BasicPane{ /** * 从worksheet中populate数据 - * + * * @param worksheet 当前worksheet */ public void populate(WorkSheet worksheet) { @@ -422,11 +437,11 @@ public class ReportColumnsPane extends BasicPane{ private void setValueText(WorkSheetAttr attr, int rowCount, int colCount, UITextField repeatColDataTextField, UITextField copyTitleTextField, UICheckBox showBlankCheckBox) { int startRow,endRow = -1,startColumn,endColumn = -1; - + if(attr.getStartIndex() == -1 && attr.getEndIndex() == -1){ return; } - + if (attr.getDirection() == ROW) { startRow = attr.getStartIndex(); endRow = attr.getEndIndex() == -1 ? rowCount - 1 : attr.getEndIndex(); @@ -438,13 +453,13 @@ public class ReportColumnsPane extends BasicPane{ startColumn = attr.getStartIndex(); endColumn = attr.getEndIndex() == -1 ? colCount - 1 : attr.getEndIndex(); } - + repeatColDataTextField.setText(ColumnRow.valueOf(startColumn, startRow).toString() +":" + ColumnRow.valueOf(endColumn, endRow).toString()); copyTitleTextField.setText(attr.getIndexsToCopy()); showBlankCheckBox.setSelected(attr.isShowBlank()); } - + /** * update行数据 */ @@ -463,7 +478,7 @@ public class ReportColumnsPane extends BasicPane{ } } } - + /** * update列数据 */ @@ -482,7 +497,7 @@ public class ReportColumnsPane extends BasicPane{ } } } - + /** * update数据给WorksheetAttr * @@ -491,8 +506,8 @@ public class ReportColumnsPane extends BasicPane{ if (!isRepeate) { attr.setDirection(Constants.NONE); return; - } - + } + switch (rowOrColumn) { case ROW: updateRow(attr); @@ -510,7 +525,7 @@ public class ReportColumnsPane extends BasicPane{ /** * update数据给worksheet - * + * * @param worksheet 当前worksheet */ public void update(WorkSheet worksheet) { @@ -527,7 +542,7 @@ public class ReportColumnsPane extends BasicPane{ /** * 从界面中赋值给WorkSheetAttr - * + * * @param attr 报表分栏属性 * @param repeatColDataTextField 从哪行开始复制 * @param copyTitleTextField 复制列序列 @@ -560,7 +575,7 @@ public class ReportColumnsPane extends BasicPane{ attr.setIndexsToCopy(copyTitleTextField.getText()); attr.setShowBlank(showBlankCheckBox.isSelected()); } - + /** * 判断输入是否合法 @@ -571,7 +586,7 @@ public class ReportColumnsPane extends BasicPane{ if(StringUtils.isEmpty(repeatText)){ return; } - + boolean valid = true; if(!repeatText.matches("[a-zA-Z]+[0-9]+[:][a-zA-Z]+[0-9]+")){ valid = false; From 1c728c920e078041a53f794920527749dc4a55ad Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 13 Aug 2020 19:54:31 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=E9=87=8D=E5=A4=8D=E5=86=99=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/report/ReportColumnsPane.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java index 3d36ecd06d..108b61e651 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java @@ -18,6 +18,7 @@ import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.report.stable.WorkSheetAttr; import com.fr.report.worksheet.WorkSheet; +import com.fr.stable.ArrayUtils; import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.StringUtils; @@ -38,11 +39,12 @@ import java.awt.Graphics; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.List; public class ReportColumnsPane extends BasicPane{ public static final int ROW = 0; public static final int COLUMN = 1; - private static final String LOCALE_LANGUAGE_EN = "en"; + private static final List LOCALE_LANGUAGE = ArrayUtils.toList(new String[]{"en"}); private int rowOrColumn; private boolean isRepeate; @@ -314,7 +316,7 @@ public class ReportColumnsPane extends BasicPane{ rowPane.setBorder(explainBorder); rowPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5,13)); // Yvan: REPORT-37398 判断设计器语言是否为英文 - if (StringUtils.equals(GeneralContext.getLocale().getLanguage(), LOCALE_LANGUAGE_EN)) { + if (LOCALE_LANGUAGE.contains(GeneralContext.getLocale().getLanguage())) { // 如果是英文,需要为这个panel设置更大的height,否则显示不全 rowPane.setPreferredSize(new Dimension(500,135)); } else { From 89dd8f64626b85cb637cfc7a91f6b5a2eb5068e5 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 17 Aug 2020 14:17:13 +0800 Subject: [PATCH 04/11] =?UTF-8?q?REPORT-37588=E3=80=90frm=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E7=95=8C=E9=9D=A2=E6=94=AF=E6=8C=81=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E3=80=91=E5=A4=9Atab=E6=A8=A1=E7=89=88=EF=BC=8C=E5=8F=B3?= =?UTF-8?q?=E5=87=BBtab=E6=98=BE=E7=A4=BA=E6=8F=90=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/cardlayout/XCardSwitchButton.java | 5 +++-- .../com/fr/design/mainframe/EditingMouseListener.java | 2 +- .../main/java/com/fr/design/mainframe/FormDesigner.java | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index f0e23b977f..bce26eb3f3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -202,7 +202,8 @@ public class XCardSwitchButton extends XButton { jPopupMenu.add(prev); jPopupMenu.add(next); jPopupMenu.add(end); - GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), e.getX(), e.getY()); + FormDesigner designer = editingMouseListener.getDesigner(); + GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), designer.getOriginX(e.getX()), designer.getOriginY(e.getY())); } @Override @@ -251,7 +252,7 @@ public class XCardSwitchButton extends XButton { //是否进入点击关闭按钮区域 private boolean isSelectedClose(MouseEvent e, FormDesigner designer){ - int diff = designer.getArea().getHorScrollBar().getValue(); + int diff = designer.getHorizontalScaleValue(); // mouse position int ex = e.getX() + diff; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index d8234c2b1d..3754e5109e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -607,7 +607,7 @@ public class EditingMouseListener extends MouseInputAdapter { if (e.getButton() == MouseEvent.BUTTON3) { UIPopupMenu cellPopupMenu = creator.createPopupMenu(designer); if (cellPopupMenu != UIPopupMenu.EMPTY) { - GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY()); + GUICoreUtils.showPopupMenu(cellPopupMenu, designer, oldX, oldY); } } creator.doLayout(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index f9141ca997..e5ce0f726f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1611,6 +1611,14 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return (int) ((y - this.getPaintY()) / this.getScale()); } + public int getOriginX(int x) { + return (int) (x * this.getScale() + this.getPaintX()); + } + + public int getOriginY(int y) { + return (int) (y * this.getScale() + this.getPaintY()); + } + public int getHorizontalScaleValue() { return (int) (this.getArea().getHorizontalValue() / this.scale); From 4f06b426c09a5f6f4e666800f39b8a5f5f34f88a Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 17 Aug 2020 16:23:36 +0800 Subject: [PATCH 05/11] =?UTF-8?q?REPORT-37020=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=EF=BC=8C=E4=B8=80=E4=B8=AA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0=EF=BC=8C=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E4=B8=8D=E4=BC=9A=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?=EF=BC=8C=E6=92=A4=E9=94=80=E5=B0=B1=E4=BC=9A=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=98=BE=E7=A4=BA=E4=BA=86=201.=20=E4=B8=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E4=B8=AA=E5=8F=82=E6=95=B0=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=B8=AA=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6+=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E6=96=B9=E6=B3=95=E9=83=BD=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=BA=86=E8=AE=BE=E7=BD=AE=E4=B8=AD=E5=BF=83Panel?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/parameter/ParameterDefinitePane.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index 11ae412ece..66611d9a18 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -425,6 +425,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } + workBook.setAutoHeightForCenterPane(); } /** @@ -445,6 +446,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } + workBook.setAutoHeightForCenterPane(); } /** From 6dc4651462bedc9e93f4a35681250aaa45641538 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 17 Aug 2020 16:29:02 +0800 Subject: [PATCH 06/11] =?UTF-8?q?REPORT-37020=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=EF=BC=8C=E4=B8=80=E4=B8=AA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0=EF=BC=8C=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E4=B8=8D=E4=BC=9A=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?=EF=BC=8C=E6=92=A4=E9=94=80=E5=B0=B1=E4=BC=9A=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=98=BE=E7=A4=BA=E4=BA=86=201.=20=E4=B8=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E4=B8=AA=E5=8F=82=E6=95=B0=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=B8=AA=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6+=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E6=96=B9=E6=B3=95=E9=83=BD=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=BA=86=E8=AE=BE=E7=BD=AE=E4=B8=AD=E5=BF=83Panel?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/report/ReportColumnsPane.java | 81 ++++++++----------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java index 108b61e651..4062e0dbe5 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java @@ -14,11 +14,9 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; -import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.report.stable.WorkSheetAttr; import com.fr.report.worksheet.WorkSheet; -import com.fr.stable.ArrayUtils; import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.StringUtils; @@ -39,12 +37,10 @@ import java.awt.Graphics; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.List; public class ReportColumnsPane extends BasicPane{ public static final int ROW = 0; public static final int COLUMN = 1; - private static final List LOCALE_LANGUAGE = ArrayUtils.toList(new String[]{"en"}); private int rowOrColumn; private boolean isRepeate; @@ -62,7 +58,7 @@ public class ReportColumnsPane extends BasicPane{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Columns_Repeat_Row"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Columns_Repeat_Column") }; - + private static final String FONT_NAME = "simsun"; private static final int FONT_SIZE = 14; @@ -91,7 +87,6 @@ public class ReportColumnsPane extends BasicPane{ this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel north = new JPanel(new BorderLayout()) { - @Override public void paint(Graphics g) { super.paint(g); super.paintBorder(g); @@ -127,7 +122,7 @@ public class ReportColumnsPane extends BasicPane{ this.add(north, BorderLayout.NORTH); this.add(createRowColumnPane(), BorderLayout.CENTER); } - + private ActionListener onOffListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -225,7 +220,7 @@ public class ReportColumnsPane extends BasicPane{ sampleLablePane.add(cPane); return sampleLablePane; } - + private ActionListener rowChangeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -238,7 +233,7 @@ public class ReportColumnsPane extends BasicPane{ } } }; - + private ActionListener colChangeListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -280,7 +275,7 @@ public class ReportColumnsPane extends BasicPane{ RowMaxOrSetPane.add(setRowRadioPane); return RowMaxOrSetPane; } - + private ActionListener toXBtnListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -293,7 +288,7 @@ public class ReportColumnsPane extends BasicPane{ } } }; - + private ActionListener maxBtnListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -315,39 +310,27 @@ public class ReportColumnsPane extends BasicPane{ UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Area")); rowPane.setBorder(explainBorder); rowPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5,13)); - // Yvan: REPORT-37398 判断设计器语言是否为英文 - if (LOCALE_LANGUAGE.contains(GeneralContext.getLocale().getLanguage())) { - // 如果是英文,需要为这个panel设置更大的height,否则显示不全 - rowPane.setPreferredSize(new Dimension(500,135)); - } else { - // 其它语言环境下也需要将height调高一点点,因为后面将组件分块了,如果不调整height会造成上下间距不等 - rowPane.setPreferredSize(new Dimension(500,90)); - } - // 将组件分成两块,分别装在各自的JPanel中,然后把两个JPanel添加到rowPane中,第二个JPanel放不下时会自动换行 - // 左边的JPanel:分栏数据 - JPanel multiData = new JPanel(); - multiData.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Data") + ":")); + rowPane.setPreferredSize(new Dimension(500,80)); + rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Column_Data") + ":")); repeatColDataTextField = new UITextField(); repeatColDataTextField.setPreferredSize(new Dimension(107,24)); - multiData.add(repeatColDataTextField); - multiData.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": A2:D5 ")); - // 右边的JPanel:复制行序列 - JPanel copyRowSequence = new JPanel(); + rowPane.add(repeatColDataTextField); + rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": A2:D5 ")); copyLabel = new UILabel(REPORT_COLUMN_RAPEAT[rowOrColumn] + ":"); - copyRowSequence.add(copyLabel); + rowPane.add(copyLabel); + copyTitleTextField = new UITextField(); copyTitleTextField.setPreferredSize(new Dimension(107,24)); - copyRowSequence.add(copyTitleTextField); - copyRowSequence.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": 1,2-3,5,18")); - // 添加JPanel - rowPane.add(multiData); - rowPane.add(copyRowSequence); + rowPane.add(copyTitleTextField); + rowPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format") + ": 1,2-3,5,18")); + + return rowPane; } /** * 从worksheetAttr中populate数据给界面 - * + * * @param attr 当前ElementCase的worksheet属性 * @param rowCount 总行数 * @param colCount 总列数 @@ -372,7 +355,7 @@ public class ReportColumnsPane extends BasicPane{ colOrRowConvert(); checkEnable(); } - + /** * populate列分栏数据 */ @@ -393,7 +376,7 @@ public class ReportColumnsPane extends BasicPane{ this.maxNumberSpinner.setEnabled(true); } } - + /** * populate行分栏 */ @@ -417,7 +400,7 @@ public class ReportColumnsPane extends BasicPane{ /** * 从worksheet中populate数据 - * + * * @param worksheet 当前worksheet */ public void populate(WorkSheet worksheet) { @@ -439,11 +422,11 @@ public class ReportColumnsPane extends BasicPane{ private void setValueText(WorkSheetAttr attr, int rowCount, int colCount, UITextField repeatColDataTextField, UITextField copyTitleTextField, UICheckBox showBlankCheckBox) { int startRow,endRow = -1,startColumn,endColumn = -1; - + if(attr.getStartIndex() == -1 && attr.getEndIndex() == -1){ return; } - + if (attr.getDirection() == ROW) { startRow = attr.getStartIndex(); endRow = attr.getEndIndex() == -1 ? rowCount - 1 : attr.getEndIndex(); @@ -455,13 +438,13 @@ public class ReportColumnsPane extends BasicPane{ startColumn = attr.getStartIndex(); endColumn = attr.getEndIndex() == -1 ? colCount - 1 : attr.getEndIndex(); } - + repeatColDataTextField.setText(ColumnRow.valueOf(startColumn, startRow).toString() +":" + ColumnRow.valueOf(endColumn, endRow).toString()); copyTitleTextField.setText(attr.getIndexsToCopy()); showBlankCheckBox.setSelected(attr.isShowBlank()); } - + /** * update行数据 */ @@ -480,7 +463,7 @@ public class ReportColumnsPane extends BasicPane{ } } } - + /** * update列数据 */ @@ -499,7 +482,7 @@ public class ReportColumnsPane extends BasicPane{ } } } - + /** * update数据给WorksheetAttr * @@ -508,8 +491,8 @@ public class ReportColumnsPane extends BasicPane{ if (!isRepeate) { attr.setDirection(Constants.NONE); return; - } - + } + switch (rowOrColumn) { case ROW: updateRow(attr); @@ -527,7 +510,7 @@ public class ReportColumnsPane extends BasicPane{ /** * update数据给worksheet - * + * * @param worksheet 当前worksheet */ public void update(WorkSheet worksheet) { @@ -544,7 +527,7 @@ public class ReportColumnsPane extends BasicPane{ /** * 从界面中赋值给WorkSheetAttr - * + * * @param attr 报表分栏属性 * @param repeatColDataTextField 从哪行开始复制 * @param copyTitleTextField 复制列序列 @@ -577,7 +560,7 @@ public class ReportColumnsPane extends BasicPane{ attr.setIndexsToCopy(copyTitleTextField.getText()); attr.setShowBlank(showBlankCheckBox.isSelected()); } - + /** * 判断输入是否合法 @@ -588,7 +571,7 @@ public class ReportColumnsPane extends BasicPane{ if(StringUtils.isEmpty(repeatText)){ return; } - + boolean valid = true; if(!repeatText.matches("[a-zA-Z]+[0-9]+[:][a-zA-Z]+[0-9]+")){ valid = false; From 5b880961ad652c957f27ac6d696b1f8d10466060 Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 17 Aug 2020 17:04:42 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88=E5=BC=82=E5=B8=B8=E7=9A=84=E5=8F=AF=E8=83=BD=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/parameter/ParameterDefinitePane.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index 66611d9a18..e62a5772cd 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -425,7 +425,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** @@ -446,7 +448,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** @@ -469,7 +473,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** From c853e778a331f1d4095639d13bd5387ff9dbfe7f Mon Sep 17 00:00:00 2001 From: Yvan Date: Mon, 17 Aug 2020 17:35:17 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E7=BB=8F=E8=BF=87Hugh=E8=80=81=E5=93=A5?= =?UTF-8?q?=E6=8F=90=E9=86=92=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/parameter/ParameterDefinitePane.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index e62a5772cd..d1d5f5a961 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -41,6 +41,7 @@ import com.fr.main.parameter.TemplateParameterAttr; import com.fr.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.core.PropertyChangeAdapter; +import org.jetbrains.annotations.NotNull; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; @@ -236,7 +237,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus * * @param workBook */ - public void populate(final JWorkBook workBook) { + public void populate(@NotNull final JWorkBook workBook) { isEditing = false; this.workBook = workBook; ReportParameterAttr reportParameterAttr = workBook.getTarget().getReportParameterAttr(); @@ -425,9 +426,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - if (workBook != null) { - workBook.setAutoHeightForCenterPane(); - } + workBook.setAutoHeightForCenterPane(); } /** @@ -448,9 +447,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - if (workBook != null) { - workBook.setAutoHeightForCenterPane(); - } + workBook.setAutoHeightForCenterPane(); } /** @@ -473,9 +470,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - if (workBook != null) { - workBook.setAutoHeightForCenterPane(); - } + workBook.setAutoHeightForCenterPane(); } /** From f8dd77b91b52af28c73f1d72a6a7f129b1545c19 Mon Sep 17 00:00:00 2001 From: Yvan Date: Tue, 18 Aug 2020 08:58:12 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E8=A6=81=E5=8A=A0=E4=B8=8A=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=9C=A8?= =?UTF-8?q?JWorkBook=E5=AF=B9=E8=B1=A1=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=EF=BC=8C=E8=BF=99=E8=BE=B9=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B0=B1=E5=85=88=E5=BC=80=E5=A7=8B=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/parameter/ParameterDefinitePane.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index d1d5f5a961..3262129ca9 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -237,7 +237,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus * * @param workBook */ - public void populate(@NotNull final JWorkBook workBook) { + public void populate(final JWorkBook workBook) { isEditing = false; this.workBook = workBook; ReportParameterAttr reportParameterAttr = workBook.getTarget().getReportParameterAttr(); @@ -426,7 +426,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** @@ -447,7 +449,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** @@ -470,7 +474,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus if (propertyChangeListener != null) { propertyChangeListener.propertyChange(); } - workBook.setAutoHeightForCenterPane(); + if (workBook != null) { + workBook.setAutoHeightForCenterPane(); + } } /** From b9bce1cff6b0bba44078921724d4817e4bb52d0f Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 17 Aug 2020 20:45:42 +0800 Subject: [PATCH 10/11] =?UTF-8?q?REPORT-24268=20=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91=E5=99=A8=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=9B=9E=E6=BB=9A=E4=BB=A3=E7=A0=81,=20?= =?UTF-8?q?=E7=8E=B0=E6=9C=89=E9=80=BB=E8=BE=91=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/formula/FormulaTextField.java | 100 ------------------ .../fr/design/formula/SortFormulaPane.java | 25 ++--- .../gui/itextfield/DictionaryTextField.java | 45 -------- .../design/formula/FormulaTextFieldTest.java | 28 ----- .../design/dscolumn/DSColumnAdvancedPane.java | 86 +++++++-------- .../cellquick/CellDSColumnEditor.java | 72 ++++++------- 6 files changed, 81 insertions(+), 275 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java delete mode 100644 designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java delete mode 100644 designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java b/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java deleted file mode 100644 index 6294a7a3bd..0000000000 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.fr.design.formula; - -import com.fr.base.BaseFormula; -import com.fr.design.gui.itextfield.DictionaryTextField; -import com.fr.stable.StringUtils; - -import javax.swing.text.Document; - -/** - * 公式展示时使用。 - * 展示 String. - * 但实际保存的是 BaseFormula。 - * 从而保留公式的形态。 - * - * created by Harrison on 2020/08/03 - **/ -public class FormulaTextField extends DictionaryTextField { - - private static final String EMPTY_STRING = "="; - - private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build(EMPTY_STRING); - - public FormulaTextField() { - } - - public FormulaTextField(int columns) { - super(columns); - } - - public FormulaTextField(String text, int columns, BaseFormula value) { - super(text, columns, value); - } - - public FormulaTextField(String text, BaseFormula value) { - super(text, value); - } - - public FormulaTextField(Document doc, String text, int columns, BaseFormula value) { - super(doc, text, columns, value); - } - - @Override - public BaseFormula getValue() { - - if (this.value == null) { - this.value = createDefault(); - } - //保持联动 - linkValueByText(); - return value; - } - - private void linkValueByText() { - - String content = getText(); - this.value.setContent(content); - } - - /** - * 设置值时,会将展示的公式值一同设置进去 - * - * @param value 公式值 - */ - @Override - public void setValue(BaseFormula value) { - - this.value = value; - if (this.value == null) { - this.value = createDefault(); - } - } - - /** - * 是需要设置不带 = 号,还是带 = 号。 - * - * @param value 值 - * @param isPure 带不带 = 号, 是 = 不带, 否 = 带。 - */ - public void setValueAndText(BaseFormula value, boolean isPure) { - - setValue(value); - String content = null; - if (isPure) { - content = this.value.getPureContent(); - } else { - content = this.value.getContent(); - } - setText(content); - } - - private BaseFormula createDefault() { - - String text = getText(); - if (StringUtils.isNotEmpty(text)) { - return BaseFormula.createFormulaBuilder().build(text); - } else { - return EMPTY_FORMULA; - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java index 7b6e536fc2..222aa90fec 100644 --- a/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java @@ -7,13 +7,12 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.SortOrderComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import java.awt.Dimension; -import java.awt.FlowLayout; + +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -21,7 +20,7 @@ public abstract class SortFormulaPane extends JPanel { protected static final String InsetText = " "; protected SortOrderComboBox sortOrderComboBox; - protected FormulaTextField sortFormulaTextField; + protected UITextField sortFormulaTextField; // 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮 protected UIButton sortFormulaTextFieldButton; @@ -36,7 +35,7 @@ public abstract class SortFormulaPane extends JPanel { } }); - sortFormulaTextField = new FormulaTextField(16); + sortFormulaTextField = new UITextField(16); //Lance:添加一公式编辑器按钮 sortFormulaTextFieldButton = new UIButton("..."); sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "..."); @@ -56,15 +55,17 @@ public abstract class SortFormulaPane extends JPanel { public abstract void formulaAction(); public void showFormulaDialog(String[] displayNames) { - BaseFormula value = sortFormulaTextField.getValue(); - final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - formulaPane.populate(value, new CustomVariableResolver(displayNames, true)); + String text = sortFormulaTextField.getText(); + final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build(text), new CustomVariableResolver(displayNames, true)); formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this), new DialogActionAdapter() { public void doOk() { BaseFormula fm = formulaPane.update(); - if (fm != null) { - sortFormulaTextField.setValueAndText(fm, true); + if (fm.getContent().length() <= 1) { + sortFormulaTextField.setText(""); + } else { + sortFormulaTextField.setText(fm.getContent().substring(1)); } } }).setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java deleted file mode 100644 index b8805b61dd..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.fr.design.gui.itextfield; - -import javax.swing.text.Document; - -/** - * 文字 ui. - * 保存实际值,展示值。 - * 允许实际值和展示值不同。 - * - * created by Harrison on 2020/08/03 - **/ -public class DictionaryTextField extends UITextField { - - protected T value; - - public DictionaryTextField() { - } - - public DictionaryTextField(int columns) { - super(columns); - } - - public DictionaryTextField(String text, int columns, T value) { - super(text, columns); - this.value = value; - } - - public DictionaryTextField(String text, T value) { - super(text); - this.value = value; - } - - public DictionaryTextField(Document doc, String text, int columns, T value) { - super(doc, text, columns); - this.value = value; - } - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } -} diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java deleted file mode 100644 index 8c58f6023d..0000000000 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaTextFieldTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fr.design.formula; - -import com.fr.base.BaseFormula; -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class FormulaTextFieldTest { - - @Test - public void testSet() { - - FormulaTextField field = new FormulaTextField(); - BaseFormula aaaa = BaseFormula.createFormulaBuilder().build("aaaa"); - field.setValueAndText(aaaa, true); - - Assert.assertEquals("aaaa", field.getText()); - - field.setValueAndText(aaaa, false); - Assert.assertEquals("=aaaa", field.getText()); - - field.setText("bbbb"); - BaseFormula formula = field.getValue(); - Assert.assertEquals("bbbb", formula.getPureContent()); - } - -} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 58636917cd..0941b4b220 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -7,7 +7,6 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; -import com.fr.design.formula.FormulaTextField; import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; @@ -26,17 +25,8 @@ import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.SelectCount; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -231,7 +221,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (!(value instanceof DSColumn)) { + if (value == null || !(value instanceof DSColumn)) { return; } @@ -248,7 +238,7 @@ public class DSColumnAdvancedPane extends BasicPane { this.cellElement = cellElement; Object value = cellElement.getValue(); - if (!(value instanceof DSColumn)) { + if (value == null || !(value instanceof DSColumn)) { return; } DSColumn dSColumn = (DSColumn) value; @@ -256,8 +246,8 @@ public class DSColumnAdvancedPane extends BasicPane { int sort = dSColumn.getOrder(); this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - BaseFormula sortFormulaObject = dSColumn.getSortFormulaObject(); - sortFormulaTextField.setValueAndText(sortFormulaObject, true); + String sortFormula = dSColumn.getSortFormula(); + sortFormulaTextField.setText(sortFormula); } public void update(CellElement cellElement) { @@ -273,7 +263,15 @@ public class DSColumnAdvancedPane extends BasicPane { dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); //lance:sort formula - dSColumn.setSortFormulaObject(sortFormulaTextField.getValue()); + String sText = null; + if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { + sText = new String(sortFormulaTextField.getText()); + } + if (!(sText == null || sText.length() < 1)) { + dSColumn.setSortFormula(sText); + } else { + dSColumn.setSortFormula(null); + } } } @@ -369,9 +367,9 @@ public class DSColumnAdvancedPane extends BasicPane { int selectCountType = selectCount.getType(); this.selectCountComboBox.setSelectedIndex(selectCountType); if (selectCountType == TOP.getValue()) { - this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); + this.topFormulaPane.populate(selectCount.getFormulaCount()); } else if (selectCountType == BOTTOM.getValue()) { - this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); } else if (selectCountType == SPECIFY.getValue()) { this.serialTextField.setText(selectCount.getSerial()); } @@ -397,9 +395,9 @@ public class DSColumnAdvancedPane extends BasicPane { dSColumn.setSelectCount(selectCount); selectCount.setType(selectCountSelectIndex); if (selectCountSelectIndex == TOP.getValue()) { - selectCount.setFormulaObject(this.topFormulaPane.getFormula()); + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); } else if (selectCountSelectIndex == BOTTOM.getValue()) { - selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); } else if (selectCountSelectIndex == SPECIFY.getValue()) { selectCount.setSerial(this.serialTextField.getText()); } @@ -409,19 +407,19 @@ public class DSColumnAdvancedPane extends BasicPane { private static class JFormulaField extends JPanel { private CellElement cellElement; - private FormulaTextField formulaTextField; - private BaseFormula defaultFormula; + private UITextField formulaTextField; + private String defaultValue; public JFormulaField(String defaultValue) { - this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); + this.defaultValue = defaultValue; this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); UILabel bottomLabel = new UILabel("="); bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); this.add(bottomLabel); - formulaTextField = new FormulaTextField(24); + formulaTextField = new UITextField(24); this.add(formulaTextField); - formulaTextField.setValueAndText(defaultFormula, true); + formulaTextField.setText(defaultValue); UIButton bottomFrmulaButton = new UIButton("..."); this.add(bottomFrmulaButton); @@ -441,24 +439,16 @@ public class DSColumnAdvancedPane extends BasicPane { public String getFormulaText() { return this.formulaTextField.getText(); } - - public void populateFormula(BaseFormula baseFormula) { - - this.formulaTextField.setValueAndText(baseFormula, true); - } - - public BaseFormula getFormula() { - - return this.formulaTextField.getValue(); - } private ActionListener formulaButtonActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - - BaseFormula valueFormula = formulaTextField.getValue(); - if (valueFormula == null) { - valueFormula = BaseFormula.createFormulaBuilder().build(); + BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); + String text = formulaTextField.getText(); + if (text == null || text.length() <= 0) { + valueFormula.setContent(defaultValue); + } else { + valueFormula.setContent(text); } final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); @@ -467,7 +457,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (!(value instanceof DSColumn)) { + if (value == null || !(value instanceof DSColumn)) { return; } DSColumn dsColumn = (DSColumn) value; @@ -480,9 +470,9 @@ public class DSColumnAdvancedPane extends BasicPane { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { - formulaTextField.setValueAndText(defaultFormula, true); + formulaTextField.setText(defaultValue); } else { - formulaTextField.setValueAndText(valueFormula, true); + formulaTextField.setText(valueFormula.getContent().substring(1)); } } }).setVisible(true); @@ -513,12 +503,12 @@ public class DSColumnAdvancedPane extends BasicPane { DSColumn dSColumn = (DSColumn) value; //formula - BaseFormula valueFormula = dSColumn.getResultObject(); + String valueFormula = dSColumn.getResult(); if (valueFormula == null) { - valueFormula = BaseFormula.createFormulaBuilder().build("$$$"); + valueFormula = "$$$"; } formulaField.populateElement(cellElement); - formulaField.populateFormula(valueFormula); + formulaField.populate(valueFormula); } public void update(CellElement cellElement) { @@ -526,13 +516,13 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (!(value instanceof DSColumn)) { + if (value == null || !(value instanceof DSColumn)) { return; } DSColumn dSColumn = (DSColumn) (cellElement.getValue()); //formula - dSColumn.setResultObject(this.formulaField.getFormula()); + dSColumn.setResult(this.formulaField.getFormulaText()); } } diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index d9b8f1e7a0..fb80e8891d 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -12,7 +12,6 @@ import com.fr.design.dscolumn.SelectedDataColumnPane; import com.fr.design.event.UIObserverListener; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; -import com.fr.design.formula.FormulaTextField; import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -646,7 +645,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class ResultSetSortConfigPane extends JPanel { private static final String DEFAULT_VALUE = "="; - private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(); private JPanel contentPane; private UIButtonGroup sortTypePane; private JFormulaField formulaField; @@ -721,11 +719,11 @@ public class CellDSColumnEditor extends CellQuickEditor { centerPane.setPreferredSize(new Dimension(156, 20)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); } - BaseFormula baseFormula = dSColumn.getSortFormulaObject(); - if (baseFormula == null) { - this.formulaField.populateFormula(DEFAULT_FORMULA); + String sortFormula = dSColumn.getSortFormula(); + if (sortFormula != null && sortFormula.length() >= 1) { + this.formulaField.populate(sortFormula); } else { - this.formulaField.populateFormula(baseFormula); + this.formulaField.populate(DEFAULT_VALUE); } } } @@ -742,7 +740,7 @@ public class CellDSColumnEditor extends CellQuickEditor { if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); - dSColumn.setSortFormulaObject(this.formulaField.getFormula()); + dSColumn.setSortFormula(this.formulaField.getFormulaText()); } } } @@ -776,7 +774,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class ResultSetFilterConfigPane extends JPanel { private static final String DEFAULT_VALUE = "="; - private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); private JPanel contentPane; private UIComboBox rsComboBox; @@ -921,8 +918,8 @@ public class CellDSColumnEditor extends CellQuickEditor { CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); // 重置默认值 - this.topFormulaPane.populateFormula(DEFAULT_FORMULA); - this.bottomFormulaPane.populateFormula(DEFAULT_FORMULA); + this.topFormulaPane.populate(DEFAULT_VALUE); + this.bottomFormulaPane.populate(DEFAULT_VALUE); this.serialTextField.setText(StringUtils.EMPTY); if (selectCount != null) { @@ -930,7 +927,7 @@ public class CellDSColumnEditor extends CellQuickEditor { this.rsComboBox.setSelectedIndex(selectCountType); switch (FilterTypeEnum.getFilterByValue(selectCountType)) { case TOP: - this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); + this.topFormulaPane.populate(selectCount.getFormulaCount()); //前N个 setCardPaneLayout.show(setCardPane, TOP.name()); tipCardPaneLayout.show(tipCardPane, TOP.name()); @@ -941,7 +938,7 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); break; case BOTTOM: - this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); + this.bottomFormulaPane.populate(selectCount.getFormulaCount()); //后N个 setCardPaneLayout.show(setCardPane, BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); @@ -1022,9 +1019,9 @@ public class CellDSColumnEditor extends CellQuickEditor { dSColumn.setSelectCount(selectCount); //noinspection Duplicates if (selectedFilterIndex == TOP.getValue()) { - selectCount.setFormulaObject(this.topFormulaPane.getFormula()); + selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); } else if (selectedFilterIndex == BOTTOM.getValue()) { - selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); + selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); } else if (selectedFilterIndex == SPECIFY.getValue()) { selectCount.setSerial(this.serialTextField.getText()); } @@ -1063,15 +1060,14 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class JFormulaField extends JPanel { private CellElement cellElement; - private FormulaTextField formulaTextField; - private BaseFormula defaultFormula; + private UITextField formulaTextField; + private String defaultValue; public JFormulaField(String defaultValue) { - this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); - formulaTextField = new FormulaTextField(); - formulaTextField.setValueAndText(defaultFormula, false); - + this.defaultValue = defaultValue; + formulaTextField = new UITextField(); + formulaTextField.setText(defaultValue); JPanel textFieldPane = new JPanel(new BorderLayout()); textFieldPane.add(formulaTextField, BorderLayout.CENTER); textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); @@ -1098,16 +1094,6 @@ public class CellDSColumnEditor extends CellQuickEditor { public String getFormulaText() { return this.formulaTextField.getText().trim(); } - - public void populateFormula(BaseFormula baseFormula) { - - this.formulaTextField.setValueAndText(baseFormula, false); - } - - public BaseFormula getFormula() { - - return this.formulaTextField.getValue(); - } /** * 添加事件监听器 @@ -1128,14 +1114,16 @@ public class CellDSColumnEditor extends CellQuickEditor { private ActionListener formulaButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - - BaseFormula valueFormula = formulaTextField.getValue(); - if (valueFormula == null) { - valueFormula = BaseFormula.createFormulaBuilder().build(); + BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); + String text = formulaTextField.getText(); + if (text == null || text.length() <= 0) { + valueFormula.setContent(defaultValue); + } else { + valueFormula.setContent(text); } final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); if (cellElement != null) { - final Object value = cellElement.getValue(); + Object value = cellElement.getValue(); if (value instanceof DSColumn) { DSColumn dsColumn = (DSColumn) value; String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); @@ -1145,9 +1133,9 @@ public class CellDSColumnEditor extends CellQuickEditor { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { - formulaTextField.setValueAndText(defaultFormula, false); + formulaTextField.setText(defaultValue); } else { - formulaTextField.setValueAndText(valueFormula, false); + formulaTextField.setText(valueFormula.getContent()); } } }).setVisible(true); @@ -1164,7 +1152,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class CustomValuePane extends JPanel { private static final String DEFAULT_VALUE = "=$$$"; - private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); private JFormulaField formulaField; @@ -1184,11 +1171,11 @@ public class CellDSColumnEditor extends CellQuickEditor { if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; //formula - BaseFormula valueFormula = dSColumn.getResultObject(); + String valueFormula = dSColumn.getResult(); if (valueFormula != null) { - formulaField.populateFormula(valueFormula); + formulaField.populate(valueFormula); } else { - formulaField.populateFormula(DEFAULT_FORMULA); + formulaField.populate(DEFAULT_VALUE); } formulaField.populateElement(cellElement); @@ -1201,7 +1188,8 @@ public class CellDSColumnEditor extends CellQuickEditor { Object value = cellElement.getValue(); if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - dSColumn.setResultObject(this.formulaField.getFormula()); + dSColumn.setResult(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? + null : this.formulaField.getFormulaText()); } } } From 0bb446f45fc50d10790e89a9070c9bc25c501c22 Mon Sep 17 00:00:00 2001 From: Yvan Date: Tue, 18 Aug 2020 11:28:09 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E5=88=A0=E5=8E=BB=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E5=AF=BC=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/parameter/ParameterDefinitePane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index 3262129ca9..e62a5772cd 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -41,7 +41,6 @@ import com.fr.main.parameter.TemplateParameterAttr; import com.fr.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; import com.fr.stable.core.PropertyChangeAdapter; -import org.jetbrains.annotations.NotNull; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent;