Browse Source

REPORT-22779 更新后无法重启

feature/big-screen
Bryant 5 years ago
parent
commit
ee1f910ccd
  1. 57
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  2. 64
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 4
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  4. 11
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

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

@ -6,11 +6,12 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.os.OperatingSystem;
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.stable.os.support.OSSupportCenter;
import com.fr.workspace.WorkContext;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -146,6 +147,59 @@ public class RestartHelper {
restart(ArrayUtils.EMPTY_STRING_ARRAY); restart(ArrayUtils.EMPTY_STRING_ARRAY);
} }
public static void restartForUpdate(String installHome) {
try {
if (OperatingSystem.isMacos()) {
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) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally {
WorkContext.getCurrent().close();
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();
}
/** /**
* 重启设计器并删除某些特定的文件 * 重启设计器并删除某些特定的文件
* *
@ -171,7 +225,6 @@ public class RestartHelper {
}catch (Exception e){ }catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
restartAction.execute(filesToBeDelete); restartAction.execute(filesToBeDelete);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

64
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -4,7 +4,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -113,9 +112,9 @@ import java.util.Set;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener {
public static final String DESIGNER_FRAME_NAME = "designer_frame"; private static final String DESIGNER_FRAME_NAME = "designer_frame";
public static final Dimension MIN_SIZE = new Dimension(100, 100); private static final Dimension MIN_SIZE = new Dimension(100, 100);
private static final long serialVersionUID = -8732559571067484460L; private static final long serialVersionUID = -8732559571067484460L;
@ -145,9 +144,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private UIToolbar combineUp; private UIToolbar combineUp;
private NewTemplatePane newWorkBookPane = null; private NewTemplatePane newWorkBookPane;
private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; private Icon closeMode;
private JLayeredPane layeredPane = this.getLayeredPane(); private JLayeredPane layeredPane = this.getLayeredPane();
@ -184,7 +183,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时 // 只有一个文件未保存时
if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) { if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate(); int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) { if (choose != JOptionPane.CANCEL_OPTION) {
DesignerFrame.this.exit(); DesignerFrame.this.exit();
@ -318,7 +317,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
reCalculateFrameSize(); reCalculateFrameSize();
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
doResize(); doResize();
} }
} }
@ -334,9 +333,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void resizeFrame() { public void resizeFrame() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize(); reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().doResize();
} }
public void closeAuthorityEditing() { public void closeAuthorityEditing() {
@ -416,8 +415,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
/** /**
* @param ad * @param ad 菜单栏
* @return * @return panel
*/ */
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成 //hugh: private修改为protected方便oem的时候修改右上的组件构成
@ -515,7 +514,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected ArrayList<WindowListener> getFrameListeners() { protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<WindowListener>(); ArrayList<WindowListener> arrayList = new ArrayList<>();
arrayList.add(windowAdapter); arrayList.add(windowAdapter);
return arrayList; return arrayList;
} }
@ -593,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void refreshDottedLine() { public void refreshDottedLine() {
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
populateAuthorityArea(); populateAuthorityArea();
populateCloseButton(); populateCloseButton();
addDottedLine(); addDottedLine();
@ -633,7 +632,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void fireAuthorityStateToNormal() { private void fireAuthorityStateToNormal() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListCache.getInstance().getHistoryList();
for (JTemplate<?, ?> jTemplate : opendedTemplate) { for (JTemplate<?, ?> jTemplate : opendedTemplate) {
// 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表
if (jTemplate.isDoSomethingInAuthority()) { if (jTemplate.isDoSomethingInAuthority()) {
@ -676,7 +675,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (UIButton fixButton : fixButtons) { for (UIButton fixButton : fixButtons) {
combineUp.add(fixButton); combineUp.add(fixButton);
} }
if (!DesignerMode.isAuthorityEditing()) { if (!DesignModeContext.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16)); combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) { if (toolbar4Form != null) {
for (JComponent jComponent : toolbar4Form) { for (JComponent jComponent : toolbar4Form) {
@ -692,7 +691,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private void addExtraButtons() { private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
} }
@ -709,7 +708,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private void addShareButton() { private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
} }
@ -784,13 +783,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing());
// 进入或退出权限编辑模式,通知插件 // 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { if (shortCut instanceof AbstractTemplateTreeShortCutProvider) {
shortCut.notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); shortCut.notifyFromAuhtorityChange(DesignModeContext.isAuthorityEditing());
} }
} }
} }
@ -811,7 +810,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void setTitle() { public void setTitle() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
StringBuilder defaultTitleSB = new StringBuilder(); StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" "); defaultTitleSB.append(" ");
@ -909,7 +908,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void saveCurrentEditingTemplate() { public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) { if (editingTemplate == null) {
return; return;
} }
@ -1092,7 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (inValidDesigner(jt)) { if (inValidDesigner(jt)) {
this.addAndActivateJTemplate(); this.addAndActivateJTemplate();
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} else { } else {
activeTemplate(jt); activeTemplate(jt);
} }
@ -1106,8 +1105,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void activeTemplate(JTemplate jt) { private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(jt); int index = HistoryTemplateListCache.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListCache.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);
} else { } else {
@ -1115,11 +1114,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
/** public void prepareForExit() {
* Exit退出
*/
public void exit() {
Thread thread = new Thread() { Thread thread = new Thread() {
@Override @Override
@ -1138,7 +1133,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath());
DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY(
WestRegionContainerPane.getInstance().getToolPaneY()); WestRegionContainerPane.getInstance().getToolPaneY());
@ -1150,6 +1145,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
EastRegionContainerPane.getInstance().getContainerWidth()); EastRegionContainerPane.getInstance().getContainerWidth());
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
}
/**
* Exit退出
*/
public void exit() {
prepareForExit();
//关闭当前环境 //关闭当前环境
WorkContext.getCurrent().close(); WorkContext.getCurrent().close();
@ -1251,7 +1253,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 更新进度框进度 * 更新进度框进度
* *
* @param progress * @param progress 进度值
*/ */
public void updateProgress(int progress) { public void updateProgress(int progress) {

4
designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java

@ -3,6 +3,7 @@ package com.fr.design.update.actions;
import com.fr.decision.update.backup.Recover; import com.fr.decision.update.backup.Recover;
import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.exception.UpdateException; import com.fr.decision.update.exception.UpdateException;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -46,8 +47,9 @@ public class RecoverForDesigner implements Recover {
CommonUtils.mkdirs(file); CommonUtils.mkdirs(file);
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH));
DesignerContext.getDesignerFrame().prepareForExit();
return true; return true;
}catch (IOException e) { } catch (IOException e) {
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage(),exception); FineLoggerFactory.getLogger().error(exception.getMessage(),exception);
return false; return false;

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

@ -30,6 +30,7 @@ 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;
@ -47,10 +48,8 @@ import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static java.nio.charset.StandardCharsets.*; import static java.nio.charset.StandardCharsets.*;
@ -594,19 +593,21 @@ public class UpdateMainDialog extends UIDialog {
UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
updateButton.setEnabled(false); updateButton.setEnabled(false);
updateLabel.setVisible(false); updateLabel.setVisible(false);
RestoreResultDialog.deletePreviousPropertyFile();
final String installHome = StableUtils.getInstallHome();
new FileProcess(callBack) { new FileProcess(callBack) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate();
RestartHelper.restart(); RestartHelper.restartForUpdate(installHome);
} }
@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.restart(); RestartHelper.restartForUpdate(installHome);
} }
}.execute(); }.execute();
} }

Loading…
Cancel
Save