Browse Source

Merge pull request #1497 in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit 'ac2fc4dda22fd6e6a33747ab504f78ed19e432d1':
  fix 封装调整
  fix 封装
  fix 调整
  fix restart
  REPORT-27937 && REPORT-28214
feature/big-screen
Hades 5 years ago
parent
commit
5325642539
  1. 1
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  2. 138
      designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java
  3. 50
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

1
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -737,6 +737,7 @@ public class FILEChooserPane extends BasicPane {
fileNameTextField.setText(""); fileNameTextField.setText("");
fileNameTextField.addDocumentListener(); fileNameTextField.addDocumentListener();
} }
dialog.setAlwaysOnTop(true);
dialog.setVisible(true); dialog.setVisible(true);
return option; return option;
} }

138
designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

@ -0,0 +1,138 @@
package com.fr.start;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.ErrorDialog;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.exit.DesignerExiter;
import com.fr.general.IOUtils;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.lifecycle.ErrorType;
import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/3/16
*/
public class LifecycleFatalErrorHandler {
private static final LifecycleFatalErrorHandler INSTANCE = new LifecycleFatalErrorHandler();
private Map<ErrorType, Handler> map = new HashMap<>();
private LifecycleFatalErrorHandler() {
for (ErrorType type : ErrorType.values()) {
if (ErrorType.FINEDB.equals(type)) {
map.put(type, FineDBHandler.SELF);
} else {
map.put(type, DefaultHandler.SELF);
}
}
}
public static LifecycleFatalErrorHandler getInstance() {
return INSTANCE;
}
public void handle(FineLifecycleFatalError fatal) {
SplashContext.getInstance().hide();
map.get(fatal.getErrorType()).handle(fatal);
}
interface Handler {
void handle(FineLifecycleFatalError error);
}
/**
* finedb处理
*/
enum FineDBHandler implements Handler {
SELF {
@Override
public void handle(FineLifecycleFatalError fatal) {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(),
DesignerErrorMessage.FINEDB_PROBLEM.getMessage(),
fatal.getMessage());
FineLoggerFactory.getLogger().error(DesignerErrorMessage.FINEDB_PROBLEM.getId() + ": " + DesignerErrorMessage.FINEDB_PROBLEM.getMessage());
int result = FineJOptionPane.showOptionDialog(null,
Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"),
Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
IOUtils.readIcon("com/fr/design/images/error/error2.png"),
new Object[] {Toolkit.i18nText("Fine-Design_Basic_Reset"), Toolkit.i18nText("Fine-Design_Basic_Cancel")},
null);
if (result == JOptionPane.YES_OPTION) {
boolean success = false;
try {
ResourceIOUtils.copy(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME),
StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_BAK_NAME));
success = ResourceIOUtils.delete(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
afterBackupFailed();
}
if (!success) {
afterBackupFailed();
} else {
RestartHelper.restart();
}
} else {
DesignerExiter.getInstance().execute();
}
}
private void afterBackupFailed() {
FineJOptionPane.showMessageDialog(null,
Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset_Result",
ResourceIOUtils.getRealPath(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME))),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE);
DesignerExiter.getInstance().execute();
}
}
}
/**
* 默认处理
*/
enum DefaultHandler implements Handler {
SELF {
@Override
public void handle(FineLifecycleFatalError fatal) {
FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal);
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(),
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(),
fatal.getMessage());
ErrorDialog dialog = new ErrorDialog(null, Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"),
Toolkit.i18nText("Fine-Design_Error_Start_Report"),
fatal.getMessage()) {
@Override
protected void okEvent() {
dispose();
DesignerExiter.getInstance().execute();
}
@Override
protected void restartEvent() {
dispose();
RestartHelper.restart();
}
};
dialog.setVisible(true);
}
}
}
}

50
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -3,7 +3,6 @@ package com.fr.start;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.newReport.NewPolyReportAction; import com.fr.design.actions.file.newReport.NewPolyReportAction;
@ -13,7 +12,6 @@ import com.fr.design.actions.server.StyleListAction;
import com.fr.design.actions.server.WidgetManagerAction; import com.fr.design.actions.server.WidgetManagerAction;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.ErrorDialog;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
@ -23,7 +21,6 @@ import com.fr.design.gui.ibutton.UIPreviewButton;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.InformationCollector;
@ -32,8 +29,6 @@ import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.alphafine.component.AlphaFinePane; import com.fr.design.mainframe.alphafine.component.AlphaFinePane;
import com.fr.design.mainframe.bbs.UserInfoLabel; import com.fr.design.mainframe.bbs.UserInfoLabel;
import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
@ -42,17 +37,19 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exit.DesignerExiter; import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.Module; import com.fr.module.Module;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.module.engine.event.LifecycleErrorEvent;
import com.fr.runtime.FineRuntime; import com.fr.runtime.FineRuntime;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.lifecycle.ErrorType; import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.lifecycle.LifecycleFatalError;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
@ -60,7 +57,6 @@ import com.fr.third.org.apache.commons.lang3.time.StopWatch;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.Component; import java.awt.Component;
@ -107,39 +103,19 @@ public class MainDesigner extends BaseDesigner {
//启动运行时 //启动运行时
FineRuntime.start(); FineRuntime.start();
DesignerSubListener.getInstance().start(); DesignerSubListener.getInstance().start();
EventDispatcher.listen(LifecycleErrorEvent.SELF, new Listener<FineLifecycleFatalError>() {
@Override
public void on(Event event, FineLifecycleFatalError param) {
LifecycleFatalErrorHandler.getInstance().handle(param);
}
});
Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml");
//传递启动参数 //传递启动参数
designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args));
try { try {
designerRoot.start(); designerRoot.start();
} catch (LifecycleFatalError fatal) { } catch (FineLifecycleFatalError fatal) {
SplashContext.getInstance().hide(); LifecycleFatalErrorHandler.getInstance().handle(fatal);
if (ErrorType.FINEDB.equals(fatal.getErrorType())) {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(),
DesignerErrorMessage.FINEDB_PROBLEM.getMessage(),
fatal.getMessage());
JOptionPane.showMessageDialog(null, fatal.getMessage(), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
}
FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal);
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(),
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(),
fatal.getMessage());
ErrorDialog dialog = new ErrorDialog(null, Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"),
Toolkit.i18nText("Fine-Design_Error_Start_Report"),
fatal.getMessage()) {
@Override
protected void okEvent() {
dispose();
DesignerExiter.getInstance().execute();
}
@Override
protected void restartEvent() {
dispose();
RestartHelper.restart();
}
};
dialog.setVisible(true);
} }
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {

Loading…
Cancel
Save