Browse Source

Pull request #7479: NoJira release10.0 to release11.0

Merge in DESIGN/design from zheng-1641779399395 to release/11.0

* commit '88eb9ffd00e43a87f4afce255a4b5759eac380a1':
  CHART-22259 feat:插件重新加载或者切换env fvs模板重新加载
bugfix/11.0
ju|剧浩宇 3 years ago
parent
commit
7ad187fc23
  1. 23
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 18
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

23
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -15,7 +15,6 @@ import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.StashedFILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.invoke.ClassHelper; import com.fr.invoke.ClassHelper;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -25,7 +24,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.io.ByteArrayOutputStream; import javax.swing.SwingWorker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -33,7 +32,6 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.swing.SwingWorker;
/** /**
* 历史模板缓存 * 历史模板缓存
@ -364,7 +362,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
int size = historyList.size(); int size = historyList.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
JTemplate<?, ?> template = historyList.get(i); JTemplate<?, ?> template = historyList.get(i);
FILE file = templateToStashFile(template); FILE file = template.templateToStashFile();
if (file != null) { if (file != null) {
stashFILEMap.put(i, file); stashFILEMap.put(i, file);
} }
@ -372,21 +370,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
FineLoggerFactory.getLogger().info("Env Change Template Stashed."); 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() { private boolean checkStash() {
try { try {
@ -469,7 +452,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
FILE file = template.getEditingFILE(); FILE file = template.getEditingFILE();
boolean needReload = context == null || needReloadTemplate(context, template); boolean needReload = context == null || needReloadTemplate(context, template);
if (needReload) { if (needReload) {
FILE stashFile = templateToStashFile(template); FILE stashFile = template.templateToStashFile();
if (stashFile != null) { if (stashFile != null) {
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName());
template.refreshResource(stashFile); template.refreshResource(stashFile);

18
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -65,6 +65,7 @@ import com.fr.event.EventDispatcher;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.file.StashedFILE;
import com.fr.form.ui.NoneWidget; import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -104,6 +105,7 @@ import javax.swing.JOptionPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.undo.UndoManager; import javax.swing.undo.UndoManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.io.ByteArrayOutputStream;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.util.Set; import java.util.Set;
@ -438,6 +440,22 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
stopListenThemeConfig(); stopListenThemeConfig();
} }
public FILE templateToStashFile() {
FILE file = this.getEditingFILE();
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = this.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;
}
/** /**
* 刷新内部资源 * 刷新内部资源

Loading…
Cancel
Save