|
|
|
@ -22,6 +22,7 @@ import javax.swing.JOptionPane;
|
|
|
|
|
* @version 11.0 |
|
|
|
|
* Created by hades on 2021/12/7 |
|
|
|
|
*/ |
|
|
|
|
@SuppressWarnings("all") |
|
|
|
|
public class SaveFailureHandler implements ThrowableHandler { |
|
|
|
|
|
|
|
|
|
private static final SaveFailureHandler INSTANCE = new SaveFailureHandler(); |
|
|
|
@ -70,7 +71,7 @@ public class SaveFailureHandler implements ThrowableHandler {
|
|
|
|
|
@Override |
|
|
|
|
public boolean process(Throwable e) { |
|
|
|
|
if (e.getCause() instanceof UnLockedException || e instanceof UnLockedException) { |
|
|
|
|
processByBack(Toolkit.i18nText("Fine_Design_Template_Has_Been_UnLocked")); |
|
|
|
|
processUnLocked(Toolkit.i18nText("Fine_Design_Template_Has_Been_UnLocked")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -81,7 +82,7 @@ public class SaveFailureHandler implements ThrowableHandler {
|
|
|
|
|
@Override |
|
|
|
|
public boolean process(Throwable e) { |
|
|
|
|
if (e.getCause() instanceof InconsistentLockException || e instanceof InconsistentLockException) { |
|
|
|
|
processByBack(Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Lock_Inconsistency")); |
|
|
|
|
processInconsistentLock(Toolkit.i18nText("Fine_Design_Template_Save_Failed_By_Lock_Inconsistency")); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -102,7 +103,7 @@ public class SaveFailureHandler implements ThrowableHandler {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void processByBack(String tip) { |
|
|
|
|
protected void processUnLocked(String tip) { |
|
|
|
|
int option = FineJOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
tip, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
|
|
|
@ -113,7 +114,33 @@ public class SaveFailureHandler implements ThrowableHandler {
|
|
|
|
|
if (option == JOptionPane.YES_OPTION) { |
|
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (template != null) { |
|
|
|
|
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Backup"), new FileNodeFILE(new FileNode(template.getPath(), false)), false); |
|
|
|
|
TemplateUtils.createAndOpenTemplate( |
|
|
|
|
Toolkit.i18nText("Fine_Design_Template_Backup"), |
|
|
|
|
new FileNodeFILE(new FileNode(template.getPath(), false)), |
|
|
|
|
true, |
|
|
|
|
false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void processInconsistentLock(String tip) { |
|
|
|
|
int option = FineJOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
tip, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Alert"), |
|
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
|
JOptionPane.WARNING_MESSAGE, |
|
|
|
|
IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png"), |
|
|
|
|
new Object[] {Toolkit.i18nText("Fine_Design_Template_SaveAs_Backup"), Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")}, null); |
|
|
|
|
if (option == JOptionPane.YES_OPTION) { |
|
|
|
|
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (template != null) { |
|
|
|
|
TemplateUtils.createAndOpenTemplate( |
|
|
|
|
Toolkit.i18nText("Fine_Design_Template_Backup"), |
|
|
|
|
new FileNodeFILE(new FileNode(template.getPath(), false)), |
|
|
|
|
true, |
|
|
|
|
true); |
|
|
|
|
// 创建并打开备份模板后,关闭原模板
|
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(template); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|