From ac6cf87132a2f1442a89d65583755dd99c2562bf Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Thu, 26 Sep 2019 18:45:40 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-21689=20=20=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E5=AF=86=E5=BA=A6=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=B0=8F=E5=80=BC?= =?UTF-8?q?=E9=99=90=E5=88=B6=E3=80=81=E6=A0=B9=E6=8D=AE=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=9A=84=E5=86=85=E5=AE=B9=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 4 + .../gui/ispinner/UnsignedIntUISpinner.java | 28 +---- .../com/fr/design/report/WatermarkPane.java | 108 ++++++++++++++++-- 3 files changed, 104 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 66a9a75755..825dddb4ec 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -93,6 +93,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return textField; } + public UIButton getNextButton() { + return nextButton; + } + public void setValue(double value) { setValue(value, true); } diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java index 1515477a3d..42a40cd79e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java @@ -3,8 +3,6 @@ package com.fr.design.gui.ispinner; import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; /** * Created by IntelliJ IDEA. @@ -31,7 +29,7 @@ public class UnsignedIntUISpinner extends UISpinner { @Override protected UINumberField initNumberField() { - final UIIntNumberField numberField = new UIIntNumberField() { + return new UIIntNumberField() { public boolean shouldResponseChangeListener() { return false; } @@ -44,29 +42,5 @@ public class UnsignedIntUISpinner extends UISpinner { }; } }; - numberField.addFocusListener(new FocusListener() { - @Override - public void focusGained(FocusEvent e) { - - } - - /** - * 失去焦点后再做范围限制、不然最小值为 100 时,输个 1 都不让.... - * @param e - */ - @Override - public void focusLost(FocusEvent e) { - double value = numberField.getValue(); - if (!isOverMaxOrMinValue(value)) { - return; - } - numberField.setValue(value < minValue ? minValue : maxValue); - } - - private boolean isOverMaxOrMinValue(double value) { - return value < minValue || value > maxValue; - } - }); - return numberField; } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index a7f78e1170..178479de8e 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -23,6 +23,9 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; import java.awt.Dimension; import java.awt.BorderLayout; import java.awt.Color; @@ -30,6 +33,12 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.MouseListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.Dialog; +import java.awt.FlowLayout; + /** * Created by plough on 2018/5/15. @@ -49,6 +58,13 @@ public class WatermarkPane extends BasicPane { private UISpinner verticalGapSpinner; // 文字颜色 private NewColorSelectPane colorPane; + //间距超过限制消息 + private UILabel message; + + //横向间距最小值 + public static final int HORIZONTAL_GAP_MIX = 100; + //纵向间距最小值 + public static final int VERTICAL_GAP_MIX = 50; private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20); @@ -57,6 +73,7 @@ public class WatermarkPane extends BasicPane { } private void initComponents() { + message = new UILabel(); this.setBorder(BorderFactory.createEmptyBorder(4, 4, -5, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -93,7 +110,7 @@ public class WatermarkPane extends BasicPane { public WatermarkAttr update() { WatermarkAttr watermark = new WatermarkAttr(); watermark.setText(formulaPane.getUITextField().getText()); - watermark.setFontSize((int)fontSizeComboBox.getSelectedItem()); + watermark.setFontSize((int) fontSizeComboBox.getSelectedItem()); watermark.setHorizontalGap((int) horizontalGapSpinner.getValue()); watermark.setVerticalGap((int) verticalGapSpinner.getValue()); watermark.setColor(colorPane.getColor()); @@ -109,7 +126,7 @@ public class WatermarkPane extends BasicPane { this.formulaPane = formulaPane; } - protected UIScrollPane initRightPane(){ + protected UIScrollPane initRightPane() { formulaPane = new TinyFormulaPane(); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox.setEditable(true); @@ -117,7 +134,17 @@ public class WatermarkPane extends BasicPane { verticalGapSpinner = new UnsignedIntUISpinner(50, Integer.MAX_VALUE, 1, 100); horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION); verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION); - JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); + message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); + //失去焦点时要判断是否要弹出提示 + horizontalGapSpinner.getTextField().addFocusListener( + createFocusListener4GapNumberField(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning"))); + verticalGapSpinner.getTextField().addFocusListener(createFocusListener4GapNumberField(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning"))); + + //next 按钮 释放时也要判断是否要弹出提示 + horizontalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(horizontalGapSpinner, HORIZONTAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Horizontal_Gap_Over_Warning"))); + verticalGapSpinner.getNextButton().addMouseListener(createMouseListener4GapNextButton(verticalGapSpinner, VERTICAL_GAP_MIX, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Vertical_Gap_Over_Warning"))); + + JPanel fontSizeTypePane = new JPanel(new BorderLayout(10, 0)); fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER); //水印间距面板 @@ -144,18 +171,18 @@ public class WatermarkPane extends BasicPane { JPanel rightContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Watermark_Text")), formulaPane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Font_Size")), fontSizeTypePane}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")),watermarkGapPane }, - {null,watermarkGapTipsPane }, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")), watermarkGapPane}, + {null, watermarkGapTipsPane}, {colorLabelPane, colorPane}, }, rowSize, columnSize, 10); rightContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12)); UIScrollPane configPane = new UIScrollPane(rightContentPane); - configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"),null)); + configPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Config"), null)); return configPane; } - protected void populateFontSize(int fontSize){ + protected void populateFontSize(int fontSize) { this.fontSizeComboBox.setSelectedItem(fontSize); this.fontSizeComboBox.addItemListener(new ItemListener() { @Override @@ -165,7 +192,7 @@ public class WatermarkPane extends BasicPane { }); } - protected void populateWatermarkGap(WatermarkAttr watermark){ + protected void populateWatermarkGap(WatermarkAttr watermark) { this.horizontalGapSpinner.setValue(watermark.getHorizontalGap()); this.horizontalGapSpinner.addUISpinnerFocusListenner(new FocusListener() { @@ -195,7 +222,7 @@ public class WatermarkPane extends BasicPane { }); } - protected void paintPreviewPane(){ + protected void paintPreviewPane() { watermarkPreviewPane.repaint(update()); } @@ -235,4 +262,67 @@ public class WatermarkPane extends BasicPane { protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark"); } + + /** + * 创建水印间距文本段焦点监听器 + * + * @return + */ + private FocusListener createFocusListener4GapNumberField(final UISpinner spinner, final int limitMinValue, final String messageStr) { + return new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + if (spinner.getValue() >= limitMinValue) { + return; + } + createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); + } + }; + } + + /** + * 创建水印间距微调器 NextButton 的鼠标释放监听器 + * + * @param messageStr 提示消息 + * @param limitMinValue 限制的最小值 + * @return + */ + private MouseListener createMouseListener4GapNextButton(final UISpinner spinner, final int limitMinValue, final String messageStr) { + MouseAdapter mouseAdapter = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (spinner.getValue() >= limitMinValue) { + return; + } + createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); + } + }; + return mouseAdapter; + } + + /** + * 创建超过水印间距限制的对话框 + * + * @param messageStr 提示消息 + */ + private void createGapDialog(String messageStr) { + JDialog dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(WatermarkPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), true); + dialog.setSize(new Dimension(268, 118)); + message.setText(messageStr); + JPanel upPane = new JPanel(); + UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); + upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); + upPane.add(uiLabel); + upPane.add(message); + dialog.add(upPane); + dialog.setResizable(false); + dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(WatermarkPane.this)); + dialog.setVisible(true); + dialog.dispose(); + } + } From 5ed6fa5919e4809c8fac5079f0117fa37352e795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 27 Sep 2019 16:03:50 +0800 Subject: [PATCH 2/6] =?UTF-8?q?CHART-10247=20=E7=83=AD=E5=8A=9B=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE-=E7=95=8C=E9=9D=A2=E5=9B=BE=E7=89=87=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9&=E6=89=A9=E5=B1=95=E5=9B=BE=E8=A1=A8=E5=8F=98?= =?UTF-8?q?=E6=88=90=E6=9D=A1=E5=BD=A2=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/chart/gui/ChartTypePane.java | 12 ++++++------ .../HeatMapIndependentVanChartInterface.java | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index e9dcbedce3..087efff893 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -20,15 +20,15 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * 图表 属性表, 类型选择 界面. @@ -125,7 +125,8 @@ public class ChartTypePane extends AbstractChartAttrPane{ String lastPlotID = chart.getID(); try{ - ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone(); + AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); + ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getChartTypes(selectedPane.getPlotID())[0].clone(); if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { //vanChart 和 chart 之间切换 //不同chart之间切换 @@ -136,7 +137,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ }catch (CloneNotSupportedException e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - //这一步会替换plot ((AbstractChartTypePane)getSelectedPane()).updateBean(chart); diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java index 2d07fda4df..b4e49606e3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java @@ -38,6 +38,13 @@ public class HeatMapIndependentVanChartInterface extends MapIndependentVanChartI return Toolkit.i18nText("Fine-Design_Chart_New_HeatMap"); } + @Override + public String[] getSubName() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_New_HeatMap"), + }; + } + @Override public String[] getDemoImagePath() { return new String[]{ From 87cadd7049ee6db85fff76b02e026f28c28354b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 27 Sep 2019 17:30:01 +0800 Subject: [PATCH 3/6] =?UTF-8?q?CHART-10247=20=E6=89=A9=E5=B1=95=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/ChartTypeInterfaceManager.java | 8 ++++---- .../src/main/java/com/fr/design/chart/ChartTypePane.java | 2 +- .../com/fr/design/mainframe/chart/gui/ChartTypePane.java | 2 +- .../main/java/com/fr/extended/chart/ExtendedTypePane.java | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index b9950256f3..f6f674ba95 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -165,7 +165,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; int index = 0; for (String chartID : chartIDs) { - ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(chartID); + ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { continue; } @@ -364,7 +364,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr try { //兼容 图表类型选择界面会调到这边 - ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID); + ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getCharts(chartID); result = new String[charts.length]; for (int i = 0; i < charts.length; i++) { //Chart && AbstractChart @@ -403,7 +403,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr //兼容 private String[] getCompatibleSubName(String chartID, ChartTypeUIProvider provider) { - ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID); + ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getCharts(chartID); if (chartProviders.length == 1) { return new String[]{getName(chartID)}; @@ -453,7 +453,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr try { - ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID)[0]; + ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getCharts(chartID)[0]; if (chartProvider instanceof Chart) { //AbstractExtendedChartUIProvider result = ((Chart) chartProvider).getChartName(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 0eb70fd129..8233e68e80 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -126,7 +126,7 @@ public class ChartTypePane extends ChartCommonWizardPane { ChartProvider chart4Update = cc.getSelectedChartProvider(); if (chart4Update == null) { String plotID = this.chartIDs[mainTypeList.getSelectedIndex()]; - ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + ChartProvider chart = ChartTypeManager.getInstance().getCharts(plotID)[iconViewList.getSelectedIndex()]; try { chart4Update = (ChartProvider) chart.clone(); cc.addChart(chart4Update); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index bb7d304106..77e75a69a1 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -125,7 +125,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ try{ AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); - ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getChartTypes(selectedPane.getPlotID())[0].clone(); + ChartProvider newDefaultChart =(ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { //vanChart 和 chart 之间切换 //不同chart之间切换 diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index 2d9ebb5dc1..d373eab4e8 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -67,7 +67,7 @@ public class ExtendedTypePane extends AbstractChartType @Override public ChartProvider getDefaultChart() { - return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; + return ChartTypeManager.getInstance().getCharts(getPlotID())[0]; } @Override From 525a3256a83fec67700402e0d762eae33d2d4c33 Mon Sep 17 00:00:00 2001 From: vito Date: Sun, 29 Sep 2019 15:29:44 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-22377=20=E6=94=B6=E9=9B=86jar?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF&release=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=A0feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/InformationCollector.java | 644 +++++++++--------- .../StartupMessageCollector.java | 9 +- 2 files changed, 345 insertions(+), 308 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 25c8a493e3..52440d9e3d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -30,6 +30,7 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; +import com.sun.management.OperatingSystemMXBean; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; @@ -43,11 +44,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import java.lang.management.ManagementFactory; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -58,309 +62,339 @@ import java.util.concurrent.TimeUnit; */ public class InformationCollector implements XMLReadable, XMLWriter { - // 24小时上传一次 - private static final long DELTA = 24 * 3600 * 1000L; - private static final long SEND_DELAY = 300 * 1000L; - private static final String FILE_NAME = "fr.info"; - private static final String XML_START_STOP_LIST = "StartStopList"; - private static final String XML_START_STOP = "StartStop"; - private static final String XML_LAST_TIME = "LastTime"; - private static final String ATTR_START = "start"; - private static final String ATTR_STOP = "stop"; - private static final String XML_JAR = "JarInfo"; - private static final String XML_VERSION = "Version"; - private static final String XML_USERNAME = "Username"; - private static final String XML_UUID = "UUID"; - private static final String XML_KEY = "ActiveKey"; - private static final String XML_OS = "OS"; - - private static InformationCollector collector; - - //启动时间与关闭时间列表 - private List startStop = new ArrayList(); - //上一次的发送时间 - private String lastTime; - private StartStopTime current = new StartStopTime(); - - public static InformationCollector getInstance() { - if (collector == null) { - collector = new InformationCollector(); - - readEncodeXMLFile(collector, collector.getInfoFile()); - } - - return collector; - } - - private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { - if (xmlFile == null || !xmlFile.exists()) { - return; - } - String charset = EncodeConstants.ENCODING_UTF_8; - try { - String decodeContent = getDecodeFileContent(xmlFile); - InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset)); - InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset); - - XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader); - - if (xmlReader != null) { - xmlReader.readXMLObject(xmlReadable); - } - xmlInputStream.close(); - } catch (FileNotFoundException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (XMLStreamException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - - } - - private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { - InputStream encodeInputStream = new FileInputStream(xmlFile); - String encodeContent = IOUtils.inputStream2String(encodeInputStream); - return DesUtils.getDecString(encodeContent); - } - - private long getLastTimeMillis() { - if (StringUtils.isEmpty(this.lastTime)) { - return 0; - } - - try { - return DateUtils.string2Date(this.lastTime, true).getTime(); - } catch (Exception e) { - return -1; - } - - } - - private JSONObject getJSONContentAsByte() { - JSONObject content = new JSONObject(); - - JSONArray startStopArray = new JSONArray(); - for (int i = 0; i < startStop.size(); i++) { - JSONObject jo = new JSONObject(); - jo.put(ATTR_START, startStop.get(i).getStartDate()); - jo.put(ATTR_STOP, startStop.get(i).getStopDate()); - startStopArray.put(jo); - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put(XML_START_STOP, startStopArray); - content.put(XML_UUID, envManager.getUUID()); - content.put(XML_JAR, GeneralUtils.readBuildNO()); - content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); - content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); - content.put(XML_KEY, envManager.getActivationKey()); - content.put(XML_OS, System.getProperty("os.name")); - } - return content; - } - - private void sendUserInfo() { - long currentTime = new Date().getTime(); - long lastTime = getLastTimeMillis(); - - if (currentTime - lastTime <= DELTA) { - return; - } - JSONObject content = getJSONContentAsByte(); - String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); - boolean success = false; - try { - HashMap para = new HashMap<>(); - para.put("token", SiteCenterToken.generateToken()); - para.put("content", content); - String res = HttpToolbox.post(url, para); - success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (success) { - this.reset(); - } - } - - /** - * 收集开始使用时间,发送信息 - */ - public void collectStartTime() { - this.current.setStartDate(dateToString()); - - sendUserInfoInOtherThread(); - } - - private void sendUserInfoInOtherThread() { - if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { - return; - } - - ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); - service.schedule(new Runnable() { - @Override - public void run() { - sendUserInfo(); - FocusPointMessageUploader.getInstance().sendToCloudCenter(); - TemplateInfoCollector.getInstance().sendTemplateInfo(); - ErrorInfoUploader.getInstance().sendErrorInfo(); - } - }, SEND_DELAY, TimeUnit.MILLISECONDS); - } - - /** - * 收集结束使用时间 - */ - public void collectStopTime() { - this.current.setStopDate(dateToString()); - } - - private String dateToString() { - DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); - return df.format(new Date()); - } - - private void reset() { - this.startStop.clear(); - this.lastTime = dateToString(); - } - - private File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); - } - - /** - * 保存xml文件 - */ - public void saveXMLFile() { - File xmlFile = this.getInfoFile(); - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - XMLTools.writeOutputStreamXML(this, out); - out.flush(); - out.close(); - String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); - String encodeCotent = DesUtils.getEncString(fileContent); - writeEncodeContentToFile(encodeCotent, xmlFile); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - - /** - * 将文件内容写到输出流中 - */ - private static void writeEncodeContentToFile(String fileContent, File file) { - try (FileOutputStream fos = new FileOutputStream(file); - OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); - BufferedWriter bw = new BufferedWriter(osw)) { - bw.write(fileContent); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - @Override - public void writeXML(XMLPrintWriter writer) { - startStop.add(current); - writer.startTAG("Info"); - //启停信息 - writeStartStopList(writer); - //上一次更新的时间 - writeTag(XML_LAST_TIME, this.lastTime, writer); - - writer.end(); - } - - private void writeStartStopList(XMLPrintWriter writer) { - //启停 - writer.startTAG(XML_START_STOP_LIST); - for (int i = 0; i < startStop.size(); i++) { - startStop.get(i).writeXML(writer); - } - writer.end(); - } - - private void writeTag(String tag, String content, XMLPrintWriter writer) { - if (StringUtils.isEmpty(content)) { - return; - } - - writer.startTAG(tag); - writer.textNode(content); - writer.end(); - } - - @Override - public void readXML(XMLableReader reader) { - if (reader.isChildNode()) { - String name = reader.getTagName(); - if (XML_START_STOP_LIST.equals(name)) { - readStartStopList(reader); - } else if (XML_LAST_TIME.equals(name)) { - readLastTime(reader); - } - } - } - - private void readLastTime(XMLableReader reader) { - String tmpVal; - if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { - this.lastTime = tmpVal; - } - } - - private void readStartStopList(XMLableReader reader) { - startStop.clear(); - - reader.readXMLObject(new XMLReadable() { - public void readXML(XMLableReader reader) { - if (XML_START_STOP.equals(reader.getTagName())) { - StartStopTime startStopTime = new StartStopTime(); - reader.readXMLObject(startStopTime); - startStop.add(startStopTime); - } - } - }); - } - - private class StartStopTime implements XMLReadable, XMLWriter { - - private String startDate; - private String stopDate; - - public String getStartDate() { - return startDate; - } - - public void setStartDate(String startDate) { - this.startDate = startDate; - } - - public String getStopDate() { - return stopDate; - } - - public void setStopDate(String endDate) { - this.stopDate = endDate; - } - - public void writeXML(XMLPrintWriter writer) { - writer.startTAG(XML_START_STOP); - if (StringUtils.isNotEmpty(startDate)) { - writer.attr(ATTR_START, this.startDate); - } - if (StringUtils.isNotEmpty(stopDate)) { - writer.attr(ATTR_STOP, this.stopDate); - } - writer.end(); - } - - public void readXML(XMLableReader reader) { - this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); - this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); - } - - } + /** + * 24小时上传一次 + */ + private static final long DELTA = 24 * 3600 * 1000L; + private static final long SEND_DELAY = 300 * 1000L; + private static final int BYTE_TO_MB = 1024 * 1024; + private static final String FILE_NAME = "fr.info"; + private static final String XML_START_STOP_LIST = "StartStopList"; + private static final String XML_START_STOP = "StartStop"; + private static final String XML_LAST_TIME = "LastTime"; + private static final String ATTR_START = "start"; + private static final String ATTR_STOP = "stop"; + private static final String XML_JAR = "JarInfo"; + private static final String XML_VERSION = "Version"; + private static final String XML_USERNAME = "Username"; + private static final String XML_UUID = "UUID"; + private static final String XML_KEY = "ActiveKey"; + private static final String XML_OS = "OS"; + private static final String XML_ARCH = "arch"; + private static final String XML_AVAILABLE_PROCESSORS = "cpu"; + private static final String XML_PHYSICAL_MEMORY = "systemMemory"; + + private static InformationCollector collector; + + /** + * 启动时间与关闭时间列表 + */ + private List startStop = new ArrayList(); + + /** + * 上一次的发送时间 + */ + private String lastTime; + private StartStopTime current = new StartStopTime(); + + public static InformationCollector getInstance() { + if (collector == null) { + collector = new InformationCollector(); + + readEncodeXMLFile(collector, collector.getInfoFile()); + } + + return collector; + } + + private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { + if (xmlFile == null || !xmlFile.exists()) { + return; + } + String charset = EncodeConstants.ENCODING_UTF_8; + try { + String decodeContent = getDecodeFileContent(xmlFile); + InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset)); + InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset); + + XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader); + + if (xmlReader != null) { + xmlReader.readXMLObject(xmlReadable); + } + xmlInputStream.close(); + } catch (FileNotFoundException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (XMLStreamException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + } + + private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { + InputStream encodeInputStream = new FileInputStream(xmlFile); + String encodeContent = IOUtils.inputStream2String(encodeInputStream); + return DesUtils.getDecString(encodeContent); + } + + private long getLastTimeMillis() { + if (StringUtils.isEmpty(this.lastTime)) { + return 0; + } + + try { + return Objects.requireNonNull(DateUtils.string2Date(this.lastTime, true)).getTime(); + } catch (Exception e) { + return -1; + } + + } + + private JSONObject getJSONContentAsByte() { + JSONObject content = new JSONObject(); + + JSONArray startStopArray = new JSONArray(); + for (StartStopTime startStopTime : startStop) { + JSONObject jo = new JSONObject(); + jo.put(ATTR_START, startStopTime.getStartDate()); + jo.put(ATTR_STOP, startStopTime.getStopDate()); + startStopArray.put(jo); + } + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + content.put(XML_START_STOP, startStopArray); + content.put(XML_UUID, envManager.getUUID()); + content.put(XML_JAR, GeneralUtils.readBuildNO()); + content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); + content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); + content.put(XML_KEY, envManager.getActivationKey()); + content.put(XML_OS, System.getProperty("os.name")); + content.put(XML_ARCH, System.getProperty("os.arch")); + content.put(XML_AVAILABLE_PROCESSORS, Runtime.getRuntime().availableProcessors()); + content.put(XML_PHYSICAL_MEMORY, getTotalPhysicalMemorySize()); + return content; + } + + /** + * 获取物理内存,单位GB + * + * @return 物理内存 + */ + private static long getTotalPhysicalMemorySize() { + OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + return bean.getTotalPhysicalMemorySize() / BYTE_TO_MB; + } + + + private void sendUserInfo() { + long currentTime = System.currentTimeMillis(); + long lastTime = getLastTimeMillis(); + + if (currentTime - lastTime <= DELTA) { + return; + } + JSONObject content = getJSONContentAsByte(); + String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); + boolean success = false; + try { + HashMap para = new HashMap<>(); + para.put("token", SiteCenterToken.generateToken()); + para.put("content", content); + String res = HttpToolbox.post(url, para); + success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (success) { + this.reset(); + } + } + + /** + * 收集开始使用时间,发送信息 + */ + public void collectStartTime() { + this.current.setStartDate(dateToString()); + + sendUserInfoInOtherThread(); + } + + private void sendUserInfoInOtherThread() { + if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { + return; + } + + ScheduledExecutorService service = Executors + .newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); + service.schedule(new Runnable() { + @Override + public void run() { + sendUserInfo(); + FocusPointMessageUploader.getInstance().sendToCloudCenter(); + TemplateInfoCollector.getInstance().sendTemplateInfo(); + ErrorInfoUploader.getInstance().sendErrorInfo(); + } + }, SEND_DELAY, TimeUnit.MILLISECONDS); + service.shutdown(); + } + + /** + * 收集结束使用时间 + */ + public void collectStopTime() { + this.current.setStopDate(dateToString()); + } + + private String dateToString() { + DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); + return df.format(new Date()); + } + + private void reset() { + this.startStop.clear(); + this.lastTime = dateToString(); + } + + private File getInfoFile() { + return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); + } + + /** + * 保存xml文件 + */ + public void saveXMLFile() { + File xmlFile = this.getInfoFile(); + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XMLTools.writeOutputStreamXML(this, out); + out.flush(); + out.close(); + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); + String encodeCotent = DesUtils.getEncString(fileContent); + writeEncodeContentToFile(encodeCotent, xmlFile); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + + /** + * 将文件内容写到输出流中 + */ + private static void writeEncodeContentToFile(String fileContent, File file) { + try (FileOutputStream fos = new FileOutputStream(file); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); + BufferedWriter bw = new BufferedWriter(osw)) { + bw.write(fileContent); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + startStop.add(current); + writer.startTAG("Info"); + //启停信息 + writeStartStopList(writer); + //上一次更新的时间 + writeTag(XML_LAST_TIME, this.lastTime, writer); + + writer.end(); + } + + private void writeStartStopList(XMLPrintWriter writer) { + //启停 + writer.startTAG(XML_START_STOP_LIST); + for (StartStopTime startStopTime : startStop) { + startStopTime.writeXML(writer); + } + writer.end(); + } + + private void writeTag(String tag, String content, XMLPrintWriter writer) { + if (StringUtils.isEmpty(content)) { + return; + } + + writer.startTAG(tag); + writer.textNode(content); + writer.end(); + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + String name = reader.getTagName(); + if (XML_START_STOP_LIST.equals(name)) { + readStartStopList(reader); + } else if (XML_LAST_TIME.equals(name)) { + readLastTime(reader); + } + } + } + + private void readLastTime(XMLableReader reader) { + String tmpVal; + if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { + this.lastTime = tmpVal; + } + } + + private void readStartStopList(XMLableReader reader) { + startStop.clear(); + + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + if (XML_START_STOP.equals(reader.getTagName())) { + StartStopTime startStopTime = new StartStopTime(); + reader.readXMLObject(startStopTime); + startStop.add(startStopTime); + } + } + }); + } + + private class StartStopTime implements XMLReadable, XMLWriter { + + private String startDate; + private String stopDate; + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getStopDate() { + return stopDate; + } + + public void setStopDate(String endDate) { + this.stopDate = endDate; + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_START_STOP); + if (StringUtils.isNotEmpty(startDate)) { + writer.attr(ATTR_START, this.startDate); + } + if (StringUtils.isNotEmpty(stopDate)) { + writer.attr(ATTR_STOP, this.stopDate); + } + writer.end(); + } + + @Override + public void readXML(XMLableReader reader) { + this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); + this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); + } + + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java index ac10724668..0ca2eb95ba 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java @@ -8,6 +8,7 @@ import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -30,14 +31,15 @@ public class StartupMessageCollector { private static final String XML_STARTUP_TIME = "t"; private static final String XML_STARTUP_LOG = "startupLog"; - private static final String XML_STARTUP_Memory = "designerMemory"; + private static final String XML_STARTUP_MEMORY = "designerMemory"; private static final String XML_STARTUP_COST = "cost"; private static final String XML_UUID = "UUID"; + private static final String XML_BUILD_NO = "buildNO"; private static final String STARTUP_URL_KEY = "user.info.v10.startup"; private static final String LOG_TYPE = "single"; private static final int BYTE_TO_MB = 1024 * 1024; - public static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); + private static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); private StartupMessageCollector() { } @@ -67,10 +69,11 @@ public class StartupMessageCollector { } JSONObject json = JSONObject.create() .put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID()) + .put(XML_BUILD_NO, GeneralUtils.readBuildNO()) .put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime()) .put(XML_STARTUP_COST, FineRuntime.getStartingTime()) .put(XML_STARTUP_LOG, profile) - .put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB); + .put(XML_STARTUP_MEMORY, Runtime.getRuntime().maxMemory() / BYTE_TO_MB); sendInfo(json, url + LOG_TYPE); } }); From d7b8ba9f3993239926e611ce7eb6d232af35e1c1 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Mon, 30 Sep 2019 14:04:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-21689=20=E6=B0=B4=E5=8D=B0=E5=AF=86?= =?UTF-8?q?=E5=BA=A6=E6=9C=80=E5=B0=8F=E5=80=BC=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BA=A4=E4=BA=92=E6=8F=90=E4=BE=9B=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/gui/ispinner/UISpinner.java | 11 +++++++++-- .../java/com/fr/design/report/WatermarkPane.java | 13 +++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 825dddb4ec..6a5f61cc92 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -39,6 +39,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver private String spinnerName = StringUtils.EMPTY; private UIObserverListener uiObserverListener; private GlobalNameListener globalNameListener = null; + private boolean lessMinValue = false; public UISpinner(double minValue, double maxValue, double dierta) { @@ -97,6 +98,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return nextButton; } + public boolean isLessMinValue() { + return lessMinValue; + } + public void setValue(double value) { setValue(value, true); } @@ -113,7 +118,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver if (globalNameListener != null && shouldResponseNameListener()) { globalNameListener.setGlobalName(spinnerName); } - value = value < minValue ? minValue : value; + lessMinValue = value < minValue; + value = lessMinValue ? minValue : value; value = value > maxValue ? maxValue : value; if (CommonUtils.equals(value, this.value)) { return; @@ -135,7 +141,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver if (globalNameListener != null && shouldResponseNameListener()) { globalNameListener.setGlobalName(spinnerName); } - value = value < minValue ? minValue : value; + lessMinValue = value < minValue; + value = lessMinValue ? minValue : value; value = value > maxValue ? maxValue : value; if (CommonUtils.equals(value, this.value)) { diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index 178479de8e..d5107d527b 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -36,6 +36,7 @@ import java.awt.event.ItemListener; import java.awt.event.MouseListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.FocusAdapter; import java.awt.Dialog; import java.awt.FlowLayout; @@ -269,14 +270,10 @@ public class WatermarkPane extends BasicPane { * @return */ private FocusListener createFocusListener4GapNumberField(final UISpinner spinner, final int limitMinValue, final String messageStr) { - return new FocusListener() { - @Override - public void focusGained(FocusEvent e) { - } - + return new FocusAdapter() { @Override public void focusLost(FocusEvent e) { - if (spinner.getValue() >= limitMinValue) { + if (!spinner.isLessMinValue()) { return; } createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); @@ -294,8 +291,8 @@ public class WatermarkPane extends BasicPane { private MouseListener createMouseListener4GapNextButton(final UISpinner spinner, final int limitMinValue, final String messageStr) { MouseAdapter mouseAdapter = new MouseAdapter() { @Override - public void mousePressed(MouseEvent e) { - if (spinner.getValue() >= limitMinValue) { + public void mouseReleased(MouseEvent e) { + if (!spinner.isLessMinValue()) { return; } createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); From a6487c2354fdc7b933242be3663d2d3816a2899d Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Mon, 30 Sep 2019 14:23:18 +0800 Subject: [PATCH 6/6] =?UTF-8?q?REPORT-21689=20=E6=B0=B4=E5=8D=B0=E5=AF=86?= =?UTF-8?q?=E5=BA=A6=E6=9C=80=E5=B0=8F=E5=80=BC=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BA=A4=E4=BA=92=E6=8F=90=E4=BE=9B=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/ispinner/UISpinner.java | 4 ++++ .../src/main/java/com/fr/design/report/WatermarkPane.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 6a5f61cc92..fb6752ac19 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -102,6 +102,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return lessMinValue; } + public void resetLessMinValue() { + lessMinValue = false; + } + public void setValue(double value) { setValue(value, true); } diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index d5107d527b..07ec40bfee 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -276,6 +276,7 @@ public class WatermarkPane extends BasicPane { if (!spinner.isLessMinValue()) { return; } + spinner.resetLessMinValue(); createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); } }; @@ -295,6 +296,7 @@ public class WatermarkPane extends BasicPane { if (!spinner.isLessMinValue()) { return; } + spinner.resetLessMinValue(); createGapDialog(new StringBuilder(messageStr).append(limitMinValue).toString()); } };