Browse Source

KERNEL-418 更新升级重构

persist/11.0
Bryant 5 years ago
parent
commit
e353c546fc
  1. 79
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  2. 1
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  3. 20
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

79
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");
}
}
}

1
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() { updateButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { 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); 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) { if (a == 0) {
progressBar.setVisible(true); progressBar.setVisible(true);

20
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -1,7 +1,6 @@
package com.fr.design.upm; package com.fr.design.upm;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; 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.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
@ -56,18 +53,11 @@ public class UpmFinder {
} }
public static void showUPMDialog() { public static void showUPMDialog() {
boolean flag = false; boolean flag = true;
File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); try {
File[] files = file.listFiles(); Class.forName("com.teamdev.jxbrowser.chromium.Browser");
if (files != null) { } catch (ClassNotFoundException e) {
for (File file1 : files) { flag = false;
if (file1.getName().contains(UpdateConstants.JXBROWSER)) {
flag = true;
break;
}
}
}else {
FineLoggerFactory.getLogger().error("Designer lib can not be null");
} }
if (flag) { if (flag) {
UpmShowPane upmPane = new UpmShowPane(); UpmShowPane upmPane = new UpmShowPane();

Loading…
Cancel
Save