From 31f62863472d3ef4f76dc411a6a4aeb55028a1b9 Mon Sep 17 00:00:00 2001 From: Bryant Date: Wed, 9 Oct 2019 11:20:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?KERNEL-418=20=E6=9B=B4=E6=96=B0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/update/domain/UpdateConstants.java | 56 ------------ .../update/ui/dialog/RestoreDialog.java | 2 +- .../update/ui/dialog/RestoreResultDialog.java | 2 +- .../update/ui/dialog/UpdateMainDialog.java | 86 ++++++++++++------- .../java/com/fr/design/upm/UpmFinder.java | 2 +- 5 files changed, 59 insertions(+), 89 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java diff --git a/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java b/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java deleted file mode 100644 index 54522c5f74..0000000000 --- a/designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.fr.design.update.domain; - -/** - * Created by XINZAI on 2018/8/21. - */ - - -import java.awt.Color; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * 更新升级的常量 - */ -public interface UpdateConstants { - - String APPS_FOLDER_NAME = "webapps"; - - int CONNECTION_TIMEOUT = 1000 * 5; - Color BAR_COLOR = new Color(0x3384F0); - - String CHANGELOG_X_START = "2018-07-11"; - - String DEFAULT_APP_NAME = "FineReport"; - String DESIGNER_BACKUP_DIR = "designerbackup"; - - String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10"; - String UPDATE_CACHE_INFO_X = "updateCacheInfo10"; - - String JXBROWSER = "jxbrowser"; - - List JARS_FOR_SERVER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ - "fine-activator-10.0.jar", - "fine-core-10.0.jar", - "fine-report-engine-10.0.jar", - "fine-decision-10.0.jar", - "fine-decision-report-10.0.jar", - "fine-schedule-10.0.jar", - "fine-schedule-report-10.0.jar", - "fine-swift-log-adaptor-10.0.jar", - "fine-webui-10.0.jar", - "fine-datasource-10.0.jar", - "fine-third-10.0.jar", - "fine-accumulator-10.0.jar" - })); - - List JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{ - "fine-report-designer-10.0.jar", - "aspectjrt.jar" - })); - List LOG_TYPE = Collections.unmodifiableList(Arrays.asList(new String[]{ - "REPORT", "MOBILE", "CHART", "PFC", "BI" - })); - -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java index 402df06b8a..8ffe8d4a41 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java @@ -1,9 +1,9 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.utils.gui.GUICoreUtils; diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java index 5f325a1d98..76e256af58 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java @@ -1,10 +1,10 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; import com.fr.design.RestartHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.stable.ProductConstants; 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 17400a213d..6b9dc22e39 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 @@ -1,5 +1,7 @@ package com.fr.design.update.ui.dialog; +import com.fr.decision.update.data.UpdateConstants; +import com.fr.decision.update.exception.UpdateException; import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.design.RestartHelper; @@ -14,7 +16,6 @@ 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.domain.UpdateConstants; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.ui.widget.LoadingLabel; @@ -29,13 +30,8 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; +import com.fr.stable.*; import com.fr.stable.project.ProjectConstants; -import com.fr.third.org.apache.http.ProtocolException; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; @@ -590,43 +586,73 @@ public class UpdateMainDialog extends UIDialog { updateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - backup(); - int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); - 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); - new FileProcess(callBack) { - @Override - public void onDownloadSuccess() { - updateButton.setEnabled(true); - progressBar.setVisible(false); - RestartHelper.restart(); - } - @Override - public void onDownloadFailed() { - progressBar.setVisible(false); - JOptionPane.showMessageDialog(getParent(),Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - RestartHelper.restart(); - } - }.execute(); + if (backup()) { + int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); + 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); + new FileProcess(callBack) { + @Override + public void onDownloadSuccess() { + progressBar.setVisible(false); + deleteForDesignerUpdate(); + RestartHelper.restart(); + } + @Override + public void onDownloadFailed() { + progressBar.setVisible(false); + try { + IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH), + StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME)); + } catch (IOException e) { + UpdateException exception = new UpdateException(e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage() + "recover for design failed"); + } finally { + deleteForDesignerUpdate(); + } + JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); + RestartHelper.restart(); + } + }.execute(); + } + } else { + JOptionPane.showMessageDialog(getParent(),Toolkit.i18nText("Fine-Design_Update_Info_Backup_Message")); } } }); } + private void deleteForDesignerUpdate() { + File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH)); + CommonUtils.deleteFile(designerBackup); + File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH)); + CommonUtils.deleteFile(downloadForDesigner); + } + /** * Jar还原按钮兼容 */ - private void backup() { + private boolean backup() { String installHome = StableUtils.getInstallHome(); //jar包备份文件的目录为"backup/"+jar包当前版本号 String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO())); backupFilesFromInstallEnv(installHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir); jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); + try { + File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); + CommonUtils.mkdirs(file); + IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), + StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); + return true; + }catch (IOException e) { + UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage(),exception); + return false; + } } private void backupFilesFromInstallEnv(String installHome, String todayBackupDir) { diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 0b4d6c7206..0c1f7cd520 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -1,10 +1,10 @@ package com.fr.design.upm; import com.fr.base.FRContext; +import com.fr.decision.update.data.UpdateConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.domain.UpdateConstants; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.event.Event; import com.fr.event.EventDispatcher; From 7f84ec2d299fc6e9799e77420218485e32a6c19c Mon Sep 17 00:00:00 2001 From: Bryant Date: Wed, 9 Oct 2019 14:26:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?KERNEL-418=20=E6=9B=B4=E6=96=B0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../update/ui/dialog/RestoreResultDialog.java | 38 ++++--- .../update/ui/dialog/UpdateMainDialog.java | 106 ++++-------------- 2 files changed, 45 insertions(+), 99 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java index 76e256af58..83ffbe5fe2 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java @@ -7,10 +7,10 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; -import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import javax.swing.AbstractAction; import javax.swing.BorderFactory; @@ -45,7 +45,7 @@ public class RestoreResultDialog extends JDialog { initCommonComponents(); } - public RestoreResultDialog(Frame parent, boolean modal, String jarDir) { + RestoreResultDialog(Frame parent, boolean modal, String jarDir) { super(parent, modal); this.jarRestoreDir = jarDir; if (ComparatorUtils.equals(jarDir, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore_Old_Version"))) { @@ -100,7 +100,7 @@ public class RestoreResultDialog extends JDialog { this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore")); } - public static boolean deletePreviousPropertyFile() { + static boolean deletePreviousPropertyFile() { File moveFile = new File(RestartHelper.MOVE_FILE); File delFile = new File(RestartHelper.RECORD_FILE); if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) { @@ -159,7 +159,7 @@ public class RestoreResultDialog extends JDialog { private void putJarBackupFiles() { Map map = new HashMap<>(); - java.util.List list = new ArrayList<>(); + List list = new ArrayList<>(); String installHome = StableUtils.getInstallHome(); putJarBackupFilesToInstallLib(installHome, map, list); @@ -168,23 +168,29 @@ public class RestoreResultDialog extends JDialog { RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()])); } - private void putJarBackupFilesToInstallLib(String installHome, Map map, java.util.List list) { - List files = UpdateConstants.JARS_FOR_DESIGNER_X; + private void putJarBackupFilesToInstallLib(String installHome, Map map, List list) { String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; - for (String file : files) { - map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), - StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); + File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH)); + File[] files = installLib.listFiles(); + if (files != null) { + for (File file : files) { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName())); + } } } - private void putJarBackupFilesToInstallEnv(String installHome, Map map, java.util.List list) { - List files = UpdateConstants.JARS_FOR_SERVER_X; + private void putJarBackupFilesToInstallEnv(String installHome, Map map, List list) { String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; - for (String file : files) { - map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), - StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + File installEnv = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH)); + File[] files = installEnv.listFiles(); + if (files != null) { + for (File file : files) { + map.put(file.getAbsolutePath(), + StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName())); + list.add(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName())); + } } } } \ No newline at end of file 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 6b9dc22e39..50329a46fb 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 @@ -1,7 +1,6 @@ package com.fr.design.update.ui.dialog; import com.fr.decision.update.data.UpdateConstants; -import com.fr.decision.update.exception.UpdateException; import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.design.RestartHelper; @@ -31,7 +30,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.*; -import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; @@ -586,40 +584,29 @@ public class UpdateMainDialog extends UIDialog { updateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (backup()) { - int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); - 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); - new FileProcess(callBack) { - @Override - public void onDownloadSuccess() { - progressBar.setVisible(false); - deleteForDesignerUpdate(); - RestartHelper.restart(); - } - @Override - public void onDownloadFailed() { - progressBar.setVisible(false); - try { - IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH), - StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME)); - } catch (IOException e) { - UpdateException exception = new UpdateException(e.getMessage()); - FineLoggerFactory.getLogger().error(exception.getMessage() + "recover for design failed"); - } finally { - deleteForDesignerUpdate(); - } - JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - RestartHelper.restart(); - } - }.execute(); - } - } else { - JOptionPane.showMessageDialog(getParent(),Toolkit.i18nText("Fine-Design_Update_Info_Backup_Message")); + jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); + int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); + 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); + new FileProcess(callBack) { + @Override + public void onDownloadSuccess() { + progressBar.setVisible(false); + deleteForDesignerUpdate(); + RestartHelper.restart(); + } + @Override + public void onDownloadFailed() { + progressBar.setVisible(false); + deleteForDesignerUpdate(); + JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); + RestartHelper.restart(); + } + }.execute(); } } }); @@ -632,53 +619,6 @@ public class UpdateMainDialog extends UIDialog { CommonUtils.deleteFile(downloadForDesigner); } - /** - * Jar还原按钮兼容 - */ - private boolean backup() { - String installHome = StableUtils.getInstallHome(); - //jar包备份文件的目录为"backup/"+jar包当前版本号 - String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO())); - backupFilesFromInstallEnv(installHome, todayBackupDir); - backupFilesFromInstallLib(installHome, todayBackupDir); - jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); - try { - File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); - CommonUtils.mkdirs(file); - IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), - StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); - return true; - }catch (IOException e) { - UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); - FineLoggerFactory.getLogger().error(exception.getMessage(),exception); - return false; - } - } - - private void backupFilesFromInstallEnv(String installHome, String todayBackupDir) { - for (String file : UpdateConstants.JARS_FOR_SERVER_X) { - try { - IOUtils.copy( - new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)), - new File(StableUtils.pathJoin(todayBackupDir))); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - } - - private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { - for (String file : UpdateConstants.JARS_FOR_DESIGNER_X) { - try { - IOUtils.copy( - new File(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)), - new File(StableUtils.pathJoin(todayBackupDir))); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - } - //获取备份目录 private String getBackupDirectory() { return UpdateConstants.DESIGNER_BACKUP_DIR; From e353c546fce449e7948ed1213ab93c58a0d60567 Mon Sep 17 00:00:00 2001 From: Bryant Date: Wed, 9 Oct 2019 18:11:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?KERNEL-418=20=E6=9B=B4=E6=96=B0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../update/actions/RecoverForDesigner.java | 79 +++++++++++++++++++ .../update/ui/dialog/UpdateMainDialog.java | 1 - .../java/com/fr/design/upm/UpmFinder.java | 20 ++--- 3 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java new file mode 100644 index 0000000000..60decb8735 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -0,0 +1,79 @@ +package com.fr.design.update.actions; + +import com.fr.decision.update.backup.Recover; +import com.fr.decision.update.data.UpdateConstants; +import com.fr.decision.update.exception.UpdateException; +import com.fr.general.GeneralUtils; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.CommonUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; + +import java.io.File; +import java.io.IOException; + +/** + * @author Bryant + * @version 10.0 + * Created by Bryant on 2019-10-09 + */ +public class RecoverForDesigner implements Recover { + + @Override + public boolean recover() { + try{ + IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH), + StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); + return true; + } catch (IOException ignore) { + FineLoggerFactory.getLogger().error("Recover error for designer"); + return false; + } + } + + @Override + public boolean backup() { + String installHome = StableUtils.getInstallHome(); + //jar包备份文件的目录为"backup/"+jar包当前版本号 + String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); + backupFilesFromInstallEnv(todayBackupDir); + backupFilesFromInstallLib(installHome, todayBackupDir); + try { + File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); + CommonUtils.mkdirs(file); + IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), + StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); + return true; + }catch (IOException e) { + UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage(),exception); + return false; + } + } + + private void backupFilesFromInstallEnv(String todayBackupDir) { + try { + CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); + IOUtils.copyFilesInDirByPath( + StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME), + StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); + } catch (IOException e) { + UpdateException exception = new UpdateException(e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed"); + } + } + + private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { + try { + CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH))); + IOUtils.copyFilesInDirByPath( + StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), + StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); + } catch (IOException e) { + UpdateException exception = new UpdateException(e.getMessage()); + FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed"); + } + } +} 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 50329a46fb..a5504c894c 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 @@ -584,7 +584,6 @@ public class UpdateMainDialog extends UIDialog { updateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); if (a == 0) { progressBar.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 0c1f7cd520..cf7716aa37 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -1,7 +1,6 @@ package com.fr.design.upm; import com.fr.base.FRContext; -import com.fr.decision.update.data.UpdateConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -9,9 +8,7 @@ import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; -import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; -import com.fr.stable.project.ProjectConstants; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -56,18 +53,11 @@ public class UpmFinder { } public static void showUPMDialog() { - boolean flag = false; - File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); - File[] files = file.listFiles(); - if (files != null) { - for (File file1 : files) { - if (file1.getName().contains(UpdateConstants.JXBROWSER)) { - flag = true; - break; - } - } - }else { - FineLoggerFactory.getLogger().error("Designer lib can not be null"); + boolean flag = true; + try { + Class.forName("com.teamdev.jxbrowser.chromium.Browser"); + } catch (ClassNotFoundException e) { + flag = false; } if (flag) { UpmShowPane upmPane = new UpmShowPane(); From fdf29340a770451dd8bcb527a070a3facd6ed707 Mon Sep 17 00:00:00 2001 From: Bryant Date: Wed, 9 Oct 2019 18:11:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?KERNEL-418=20=E6=9B=B4=E6=96=B0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/start/module/DesignerActivator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 822a332f35..4cee65f25f 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -8,6 +8,7 @@ import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; import com.fr.config.MarketConfig; +import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; @@ -57,6 +58,7 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.WorkBookParameterReader; +import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.form.stable.ElementCaseThumbnailProcessor; import com.fr.general.xml.GeneralXMLTools; @@ -128,6 +130,7 @@ public class DesignerActivator extends Activator { UserInfoPane.getInstance().updateBBSUserInfo(); storePassport(); AlphaFineHelper.switchConfig4Locale(); + RecoverManager.register(new RecoverForDesigner()); } @Override