|
|
|
@ -12,7 +12,6 @@ import com.fr.design.mainframe.DesignerContext;
|
|
|
|
|
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.mainframe.JVirtualTemplate; |
|
|
|
|
import com.fr.design.module.DesignModuleFactory; |
|
|
|
|
import com.fr.design.ui.util.UIUtil; |
|
|
|
|
import com.fr.file.FILE; |
|
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
|
@ -361,20 +360,28 @@ public class HistoryTemplateListCache implements CallbackEvent {
|
|
|
|
|
int size = historyList.size(); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
JTemplate<?, ?> template = historyList.get(i); |
|
|
|
|
FILE file = templateToStashFile(template); |
|
|
|
|
if (file != null) { |
|
|
|
|
stashFILEMap.put(i, file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
FineLoggerFactory.getLogger().info("Env Change Template Stashed."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private FILE templateToStashFile(JTemplate<?, ?> template) { |
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
try { |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
BaseBook target = template.getTarget(); |
|
|
|
|
if (target != null) { |
|
|
|
|
target.export(outputStream); |
|
|
|
|
stashFILEMap.put(i, new StashedFILE(file, outputStream.toByteArray())); |
|
|
|
|
return new StashedFILE(file, outputStream.toByteArray(), template.suffix()); |
|
|
|
|
} |
|
|
|
|
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
FineLoggerFactory.getLogger().info("Env Change Template Stashed."); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean checkStash() { |
|
|
|
@ -458,18 +465,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
|
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
boolean needReload = context == null || needReloadTemplate(context, template); |
|
|
|
|
if (needReload) { |
|
|
|
|
try { |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
BaseBook target = template.getTarget(); |
|
|
|
|
if (target != null) { |
|
|
|
|
FILE stashFile = templateToStashFile(template); |
|
|
|
|
if (stashFile != null) { |
|
|
|
|
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); |
|
|
|
|
target.export(outputStream); |
|
|
|
|
FILE stashedFile = new StashedFILE(file, outputStream.toByteArray()); |
|
|
|
|
template.refreshResource(stashedFile); |
|
|
|
|
} |
|
|
|
|
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
template.refreshResource(stashFile); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|