|
|
|
@ -15,7 +15,6 @@ import com.fr.design.mainframe.JVirtualTemplate;
|
|
|
|
|
import com.fr.design.ui.util.UIUtil; |
|
|
|
|
import com.fr.file.FILE; |
|
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
|
|
import com.fr.file.StashedFILE; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.invoke.ClassHelper; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
@ -25,7 +24,7 @@ import com.fr.stable.CoreConstants;
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.third.org.apache.commons.io.FilenameUtils; |
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.HashMap; |
|
|
|
@ -33,7 +32,6 @@ import java.util.List;
|
|
|
|
|
import java.util.ListIterator; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 历史模板缓存 |
|
|
|
@ -364,7 +362,7 @@ 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); |
|
|
|
|
FILE file = template.templateToStashFile(); |
|
|
|
|
if (file != null) { |
|
|
|
|
stashFILEMap.put(i, file); |
|
|
|
|
} |
|
|
|
@ -372,21 +370,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
|
|
|
|
|
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); |
|
|
|
|
return new StashedFILE(file, outputStream.toByteArray(), template.suffix()); |
|
|
|
|
} |
|
|
|
|
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean checkStash() { |
|
|
|
|
try { |
|
|
|
@ -469,7 +452,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
|
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
boolean needReload = context == null || needReloadTemplate(context, template); |
|
|
|
|
if (needReload) { |
|
|
|
|
FILE stashFile = templateToStashFile(template); |
|
|
|
|
FILE stashFile = template.templateToStashFile(); |
|
|
|
|
if (stashFile != null) { |
|
|
|
|
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); |
|
|
|
|
template.refreshResource(stashFile); |
|
|
|
|