Browse Source

REPORT-58212 【主题切换】远程10.0升上来的工程,特定操作下新建的模板预览500

【问题原因】
1. 删除无必要的本地缓存相关的代码
2. 字段数据更新后调用invalidateCache使远程服务器数据层面缓存失效,避免服务器使用了旧的错误数据

【改动思路】
同上
research/11.0
Starryi 3 years ago
parent
commit
8b25ab72c9
  1. 26
      designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java
  2. 26
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java

26
designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java

@ -34,30 +34,28 @@ public class AsyncThemeFetcher<T extends TemplateTheme> {
}
public void submit(String themeName, AsyncThemeFetchCallback<T> callback) {
callback.beforeCachedFetch();
if (callback != null) {
callback.beforeCachedFetch();
}
executorService.submit(new Runnable() {
@Override
public void run() {
if (executorService.isShutdown()) {
return;
}
T theme = config.cachedFetch(themeName, new TemplateThemeConfig.CacheCondition<T>() {
@Override
public boolean shouldCacheTheme(T theme) {
return callback.shouldCache(AsyncThemeFetcher.this, theme);
}
});
T theme = config.cachedFetch(themeName);
if (executorService.isShutdown()) {
return;
}
callback.afterCachedFetch(theme);
if (callback != null) {
callback.afterCachedFetch(theme);
}
}
});
}
public interface AsyncThemeFetchCallback<T extends TemplateTheme> {
void beforeCachedFetch();
boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme);
void afterCachedFetch(T theme);
}
@ -68,16 +66,6 @@ public class AsyncThemeFetcher<T extends TemplateTheme> {
}
@Override
public boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme) {
// 如果Fetcher已经关闭就不放进缓存里了
// 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个,
// 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存.
// TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个
// TODO: 后续看情况再优化吧.
return !fetcher.isShutdown();
}
@Override
public void afterCachedFetch(T theme) {

26
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java

@ -191,8 +191,8 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
menuDef.setRePaint(true);
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightThemeName4New()));
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkThemeName4New()));
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getDefaultLightThemeName()));
menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDefaultDarkThemeName()));
return menuDef;
}
@ -232,31 +232,27 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
}
private class AddThemeAction extends UpdateAction {
private T prototypeTheme;
private final String prototypeThemeName;
public AddThemeAction(String name, String prototypeThemeName) {
setName(name);
setMnemonic('R');
asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() {
@Override
public void beforeCachedFetch() {
super.beforeCachedFetch();
prototypeTheme = null;
}
this.prototypeThemeName = prototypeThemeName;
asyncThemeFetcher.submit(prototypeThemeName, null);
}
@Override
public void actionPerformed(ActionEvent e) {
asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() {
@Override
public void afterCachedFetch(T theme) {
super.afterCachedFetch(theme);
prototypeTheme = theme;
createNewTheme(theme);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
if (prototypeTheme == null) {
return;
}
private void createNewTheme(T prototypeTheme) {
Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this);
TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane);
try {

Loading…
Cancel
Save