forked from fanruan/design
Browse Source
* commit '6d065e6fad0094fd9f9e7e89c0cdbc740bd67c0a': REPORT-64811 保持设计器商城下载reu文件名中的版本信息 REPORT-64741 【组件可更新提醒】组件复用-设计器端安装设计器版本高于当前设计器版本的组件的情况 REPORT-64609 磁盘空间满时 保存模板造成模板丢失feature/10.0
superman
3 years ago
4 changed files with 85 additions and 7 deletions
@ -0,0 +1,12 @@
|
||||
package com.fr.common.exception; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/27 |
||||
*/ |
||||
public interface ThrowableHandler { |
||||
|
||||
boolean process(Throwable e); |
||||
|
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fr.design.worker.save; |
||||
|
||||
import com.fr.common.exception.ThrowableHandler; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.workspace.exception.DiskSpaceFullException; |
||||
import java.awt.Frame; |
||||
import javax.swing.JOptionPane; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/12/7 |
||||
*/ |
||||
public class SaveFailureHandler implements ThrowableHandler { |
||||
|
||||
private static final SaveFailureHandler INSTANCE = new SaveFailureHandler(); |
||||
|
||||
public static SaveFailureHandler getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
for (Handler handler : Handler.values()) { |
||||
if (handler.process(e)) { |
||||
break; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public enum Handler implements ThrowableHandler { |
||||
|
||||
FullDisk { |
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
if (e.getCause() instanceof DiskSpaceFullException |
||||
|| e instanceof DiskSpaceFullException |
||||
|| e.getCause().getCause() instanceof DiskSpaceFullException) { |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Full_Disk"), |
||||
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
||||
JOptionPane.WARNING_MESSAGE, |
||||
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png")); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
}, |
||||
|
||||
Other { |
||||
@Override |
||||
public boolean process(Throwable e) { |
||||
boolean minimized = (DesignerContext.getDesignerFrame().getExtendedState() & Frame.ICONIFIED ) != 0; |
||||
FineJOptionPane.showMessageDialog( |
||||
minimized ? null : DesignerContext.getDesignerFrame(), |
||||
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), |
||||
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
||||
JOptionPane.ERROR_MESSAGE); |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue