From daa73d3cd69e6eba6e5a4212629cee368924f917 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Wed, 13 Jul 2022 09:53:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-70746=20=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加更新日志链接按钮 修改url --- .../update/actions/NewFeatureAction.java | 28 +++++ .../update/ui/dialog/UpdateMainDialog.java | 111 +++++++++++------- 2 files changed, 94 insertions(+), 45 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java new file mode 100644 index 0000000000..65d5baebc9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -0,0 +1,28 @@ +package com.fr.design.update.actions; + + +import com.fr.design.utils.BrowseUtils; +import com.fr.general.CloudCenter; +import com.fr.log.FineLoggerFactory; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * 帮助-更新升级 + * 点击查看新特性 + * */ +public class NewFeatureAction implements ActionListener { + + private String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detail", "https://help.fanruan.com/finereport/doc-view-4699.html"); + + @Override + public void actionPerformed(ActionEvent e) { + try { + BrowseUtils.browser(url); + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage()); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index deda005c36..2ac320aff7 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; @@ -16,6 +17,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.FileProcess; +import com.fr.design.update.actions.NewFeatureAction; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; import com.fr.design.update.utils.UpdateFileUtils; import com.fr.design.update.ui.widget.LoadingLabel; @@ -86,6 +88,7 @@ public class UpdateMainDialog extends UIDialog { private static final String HYPHEN = "-"; private final SimpleDateFormat CHANGELOG_FORMAT = new SimpleDateFormat("M/d/y, h:m:s a", Locale.ENGLISH); + private final SimpleDateFormat UPDATELOG_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); private final SimpleDateFormat UPDATE_INFO_TABLE_FORMAT = new SimpleDateFormat("yyyy.MM.dd"); private JSONObject downloadFileConfig; @@ -185,7 +188,7 @@ public class UpdateMainDialog extends UIDialog { double[] rowUpdateContentPaneSize = {TableLayout.PREFERRED}; double[] columnUpdateContentPaneSize = {TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED}; double[] rowUpdateSubContentPaneSize = {UPDATE_CONTENT_PANE_ROW_SIZE, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, UPDATE_CONTENT_PANE_ROW_SIZE}; - double[] columnUpdateSubContentPaneSize = {UPDATE_CONTENT_PANE_COLUMN_SIZE, TableLayout.FILL, TableLayout.PREFERRED}; + double[] columnUpdateSubContentPaneSize = {UPDATE_CONTENT_PANE_COLUMN_SIZE, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnUpdateSubContentPaneLabelSize = {UPDATE_CONTENT_PANE_LABEL_COLUMN_SIZE, TableLayout.PREFERRED}; JPanel jarUpdateContentPane = new JPanel(); @@ -196,7 +199,8 @@ public class UpdateMainDialog extends UIDialog { new Component[]{new UILabel(), new UILabel(), new UILabel()}, new Component[]{new UILabel(), updateVersionReminderPane, new UILabel()}, new Component[]{new UILabel(), initPaneContent(Color.WHITE, rowUpdateContentPaneSize, columnUpdateSubContentPaneLabelSize, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_JAR_Version")), jarCurrentLabel), new UILabel()}, - new Component[]{new UILabel(), initPaneContent(Color.WHITE, rowUpdateContentPaneSize, columnUpdateSubContentPaneLabelSize, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Latest_JAR")), loadingLabel), new UILabel()}, + new Component[]{new UILabel(), initPaneContent(Color.WHITE, rowUpdateContentPaneSize, columnUpdateSubContentPaneLabelSize, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Latest_JAR")), loadingLabel), + getNewFeatureActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Latest_Feature_Detail"))}, new Component[]{new UILabel(), new UILabel(), new UILabel()} }, rowUpdateSubContentPaneSize, columnUpdateSubContentPaneSize, LayoutConstants.VGAP_LARGE); jarUpdateContentPane2.setBackground(Color.WHITE); @@ -417,14 +421,21 @@ public class UpdateMainDialog extends UIDialog { if (downloadFileConfig == null) { throw new Exception("network error."); } - HttpGet get = new HttpGet(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); - httpClient = HttpToolbox.getHttpClient(CloudCenter.getInstance().acquireUrlByKind("changelog10") + "&start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); + + HttpGet get = new HttpGet(CloudCenter.getInstance().acquireUrlByKind("updatelog") + "?start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); + httpClient = HttpToolbox.getHttpClient(CloudCenter.getInstance().acquireUrlByKind("updatelog") + "?start=" + lastUpdateCacheTime + "&end=" + getLatestJARTimeStr()); + + response = httpClient.execute(get); String responseText = CommonIOUtils.inputStream2String(response.getEntity().getContent(),EncodeConstants.ENCODING_UTF_8).trim(); + JSONArray array = JSONArray.create(); //假如返回"-1",说明socket出错了 if (!ComparatorUtils.equals(responseText, "-1")) { - array = new JSONArray(responseText); + JSONObject respObject = new JSONObject(responseText); + if (respObject != null && "success".equals(respObject.get("status"))) { + array = respObject.getJSONArray("data"); + } } return array; } catch (Exception e) { @@ -483,7 +494,7 @@ public class UpdateMainDialog extends UIDialog { continue; } } - if (isValidLogInfo(updateInfo[1])) { + if (isValidLogInfo(updateInfo[1]) && curJarDate != null) { updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)}); } } @@ -531,9 +542,9 @@ public class UpdateMainDialog extends UIDialog { private ArrayList generateUpdateInfoList(JSONArray jsonArray, String keyword) throws Exception { for (int i = 0; i < jsonArray.length(); i++) { JSONObject jo = (JSONObject) jsonArray.get(i); - String updateTitle = (String) jo.get("title"); - String updateTimeStr = (String) jo.get("update"); - Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr); + String updateTitle = (String) jo.get("jiraId") + jo.get("info"); + String updateTimeStr = (String) jo.get("updateTime"); + Date updateTime = UPDATELOG_FORMAT.parse(updateTimeStr); //形如 Build#release-2018.07.31.03.03.52.80 String currentNO = GeneralUtils.readBuildNO(); Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); @@ -608,41 +619,7 @@ public class UpdateMainDialog extends UIDialog { * jar包更新按钮监听器 */ private void addActionListenerForUpdateBtn() { - updateButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; - int a = JOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"), - Toolkit.i18nText("Fine-Design_Update_Info_Title"),JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1); - if (a == 0) { - progressBar.setVisible(true); - progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); - UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); - updateButton.setEnabled(false); - updateLabel.setVisible(false); - RestoreResultDialog.deletePreviousPropertyFile(); - final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); - final JFrame frame = DesignerContext.getDesignerFrame(); - final RestartHelper helper = new RestartHelper(); - FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); - new FileProcess(callBack) { - @Override - public void onDownloadSuccess() { - progressBar.setVisible(false); - deleteForDesignerUpdate(installLib); - helper.restartForUpdate(frame); - } - @Override - public void onDownloadFailed() { - progressBar.setVisible(false); - deleteForDesignerUpdate(installLib); - FineJOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - helper.restartForUpdate(frame); - } - }.execute(); - } - } - }); + updateButton.addActionListener(new UpdateAction()); } private void deleteForDesignerUpdate(String installLib) { @@ -688,6 +665,12 @@ public class UpdateMainDialog extends UIDialog { return false; } + private ActionLabel getNewFeatureActionLabel(final String text){ + ActionLabel actionLabel = new ActionLabel(text); + actionLabel.addActionListener(new NewFeatureAction()); + return actionLabel; + } + /** * 显示窗口 */ @@ -705,4 +688,42 @@ public class UpdateMainDialog extends UIDialog { @Override public void checkValid() throws Exception { } -} \ No newline at end of file + + + private class UpdateAction implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")}; + int a = JOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"), + Toolkit.i18nText("Fine-Design_Update_Info_Title"),JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1); + if (a == 0) { + progressBar.setVisible(true); + progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); + UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); + updateButton.setEnabled(false); + updateLabel.setVisible(false); + RestoreResultDialog.deletePreviousPropertyFile(); + final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); + final JFrame frame = DesignerContext.getDesignerFrame(); + final RestartHelper helper = new RestartHelper(); + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + new FileProcess(callBack) { + @Override + public void onDownloadSuccess() { + progressBar.setVisible(false); + deleteForDesignerUpdate(installLib); + helper.restartForUpdate(frame); + } + @Override + public void onDownloadFailed() { + progressBar.setVisible(false); + deleteForDesignerUpdate(installLib); + FineJOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); + helper.restartForUpdate(frame); + } + }.execute(); + } + + } + } +} From ff8239ba70bd7015a30e1879e5557ed402eb1346 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Wed, 13 Jul 2022 11:09:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-70746=20=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 耗时操作放到action里,避免ui阻塞 --- .../java/com/fr/design/update/actions/NewFeatureAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java index 65d5baebc9..fdf0ed0533 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -15,11 +15,11 @@ import java.awt.event.ActionListener; * */ public class NewFeatureAction implements ActionListener { - private String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detail", "https://help.fanruan.com/finereport/doc-view-4699.html"); @Override public void actionPerformed(ActionEvent e) { try { + String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detail", "https://help.fanruan.com/finereport/doc-view-4699.html"); BrowseUtils.browser(url); } catch (Exception ex) { FineLoggerFactory.getLogger().error(ex.getMessage()); From eedccf740aafa0efb271520dd66e6567ac4af353 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Wed, 13 Jul 2022 19:02:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-70746=20=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit url不能用硬编码 --- .../com/fr/design/update/actions/NewFeatureAction.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java index fdf0ed0533..56db4cee9e 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/NewFeatureAction.java @@ -1,6 +1,7 @@ package com.fr.design.update.actions; +import com.fr.common.util.Strings; import com.fr.design.utils.BrowseUtils; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; @@ -16,10 +17,15 @@ import java.awt.event.ActionListener; public class NewFeatureAction implements ActionListener { + public static String DEFAULT_UPDATE_DETAIL_URL = "https://help.fanruan.com/finereport/doc-view-4699.html"; + @Override public void actionPerformed(ActionEvent e) { try { - String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detail", "https://help.fanruan.com/finereport/doc-view-4699.html"); + String url = CloudCenter.getInstance().acquireConf("fr.latest.update.detil"); + if (Strings.isEmpty(url)) { + url = DEFAULT_UPDATE_DETAIL_URL; + } BrowseUtils.browser(url); } catch (Exception ex) { FineLoggerFactory.getLogger().error(ex.getMessage());