Browse Source

REPORT-22779 更新后无法重启

feature/big-screen
Bryant 5 years ago
parent
commit
1bca44b7c7
  1. 60
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  2. 11
      designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java
  3. 8
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  4. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

60
designer-base/src/main/java/com/fr/design/RestartHelper.java

@ -8,11 +8,10 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.*;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -20,8 +19,6 @@ import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.channels.FileLock; import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -34,7 +31,7 @@ public class RestartHelper {
public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties");
public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties");
private static OSBasedAction restartAction; private static final OSBasedAction restartAction = new RestartAction();
/** /**
* 把要删除的文件都记录到delete.properties中 * 把要删除的文件都记录到delete.properties中
@ -147,58 +144,19 @@ public class RestartHelper {
restart(ArrayUtils.EMPTY_STRING_ARRAY); restart(ArrayUtils.EMPTY_STRING_ARRAY);
} }
public static void restartForUpdate(String installHome) { public static void restartForUpdate(JFrame frame) {
try { try {
if (OperatingSystem.isMacos()) { restartAction.execute(ArrayUtils.EMPTY_STRING_ARRAY);
restartInMacOS(installHome, ArrayUtils.EMPTY_STRING_ARRAY);
} else if (OperatingSystem.isLinux()){
restartInLinux(installHome, ArrayUtils.EMPTY_STRING_ARRAY);
} else {
restartInWindows(installHome,ArrayUtils.EMPTY_STRING_ARRAY);
}
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
} finally { } finally {
WorkContext.getCurrent().close(); WorkContext.getCurrent().close();
frame.dispose();
System.exit(0); System.exit(0);
} }
} }
private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<>();
commands.add("open");
commands.add(installHome + File.separator + "bin" + File.separator + "restart.app");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add("--args");
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}
private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<>();
commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}
private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<>();
//现在先写的是restart.sh
commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}
/** /**
* 重启设计器并删除某些特定的文件 * 重启设计器并删除某些特定的文件
@ -239,12 +197,4 @@ public class RestartHelper {
DesignerContext.getDesignerFrame().exit(); DesignerContext.getDesignerFrame().exit();
} }
} }
/**
* 提前初始化重启动作
*/
public static void initRestartAction(){
restartAction = OSSupportCenter.getAction(RestartAction.class);
}
} }

11
designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java

@ -10,10 +10,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RestartAction implements OSBasedAction { public class RestartAction implements OSBasedAction {
private static String installHome;
public RestartAction() {
installHome = StableUtils.getInstallHome();
}
@Override @Override
public void execute(Object... objects) { public void execute(Object... objects) {
String[] filesToBeDelete = (String[])objects; String[] filesToBeDelete = (String[])objects;
String installHome = StableUtils.getInstallHome(); if (installHome == null) {
installHome = StableUtils.getInstallHome();
}
try{ try{
if (OperatingSystem.isMacos()) { if (OperatingSystem.isMacos()) {
restartInMacOS(installHome, filesToBeDelete); restartInMacOS(installHome, filesToBeDelete);

8
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -30,7 +30,6 @@ import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.*; 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.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
@ -594,20 +593,21 @@ public class UpdateMainDialog extends UIDialog {
updateButton.setEnabled(false); updateButton.setEnabled(false);
updateLabel.setVisible(false); updateLabel.setVisible(false);
RestoreResultDialog.deletePreviousPropertyFile(); RestoreResultDialog.deletePreviousPropertyFile();
final String installHome = StableUtils.getInstallHome(); final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper();
new FileProcess(callBack) { new FileProcess(callBack) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate();
RestartHelper.restartForUpdate(installHome); helper.restartForUpdate(frame);
} }
@Override @Override
public void onDownloadFailed() { public void onDownloadFailed() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate();
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restartForUpdate(installHome); helper.restartForUpdate(frame);
} }
}.execute(); }.execute();
} }

2
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -11,7 +11,6 @@ import com.fr.config.MarketConfig;
import com.fr.decision.update.backup.RecoverManager; import com.fr.decision.update.backup.RecoverManager;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.RestartHelper;
import com.fr.design.actions.NewFormAction; import com.fr.design.actions.NewFormAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.actions.insert.cell.BiasCellAction;
@ -140,7 +139,6 @@ public class DesignerActivator extends Activator {
storePassport(); storePassport();
AlphaFineHelper.switchConfig4Locale(); AlphaFineHelper.switchConfig4Locale();
RecoverManager.register(new RecoverForDesigner()); RecoverManager.register(new RecoverForDesigner());
RestartHelper.initRestartAction();
} }
@Override @Override

Loading…
Cancel
Save