From a3630ea8717dc1c4d0238405e46cb656f9c79ffd Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 13:24:41 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-57934=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=96=B0=E5=BB=BA=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=9C=AA=E5=A1=AB=E5=86=99=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=B8=8D=E8=83=BD=E8=AE=BE=E7=BD=AE=E7=BB=86?= =?UTF-8?q?=E8=8A=82=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 自动聚焦导致其他控件设置项响应用户交互 【改动思路】 取消自动聚焦 --- .../fr/design/mainframe/theme/TemplateThemeProfilePane.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java index e0f5c06a2a..718469c065 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -563,9 +563,6 @@ public abstract class TemplateThemeProfilePane extends boolean valid = StringUtils.isEmpty(error); - if (!valid) { - textField.requestFocus(); - } errorLabel.setVisible(!valid); if (actionButtons != null && actionButtons.length > 0) { for (UIButton button : actionButtons) { From d3fc401e9e619a6970e59aff21eb7ca9648dee99 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 13:41:53 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-51919=20=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 新增模版主题功能: 从主题配置中获取主题名称和获取主题数据的开销不同, 在方法上要做区分,尽量使用主题名称完成业务逻辑 【改动思路】 同上 --- .../main/java/com/fr/design/mainframe/JTemplate.java | 3 +-- .../fr/design/mainframe/theme/TemplateThemeBlock.java | 3 +-- .../design/mainframe/theme/TemplateThemeListPane.java | 2 +- .../mainframe/theme/TemplateThemeManagePane.java | 10 ++++------ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 2567ab7b8b..1eebed739f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -92,7 +92,6 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.SwingConstants; -import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; import java.awt.BorderLayout; import java.util.Set; @@ -1715,7 +1714,7 @@ public abstract class JTemplate> } private void setUpTheme4NewTemplate() { - TemplateTheme theme = getUsingTemplateThemeConfig().getTheme4NewTemplate(); + TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate(); TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); if (themeAttrMark == null) { themeAttrMark = new TemplateThemeAttrMark(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java index 929b5ef9fb..a61c2721e0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java @@ -220,8 +220,7 @@ public class TemplateThemeBlock extends JPanel { } } - T theme4newTemplate = config.getTheme4NewTemplate(); - if (StringUtils.equals(theme4newTemplate.getName(), name)) { + if (StringUtils.equals(config.getThemeName4NewTemplate(), name)) { theme4NewTemplateMarkIcon.paintIcon(this, g, 0, 0); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java index 247c373700..403fde166f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -84,7 +84,7 @@ public class TemplateThemeListPane extends BasicPane { if (config.contains(name)) { TemplateThemeBlock block = createCachedTemplateThemeBlock(name); contentListPane.add(block); - if (StringUtils.equals(name, config.getTheme4NewTemplate().getName())) { + if (StringUtils.equals(name, config.getThemeName4NewTemplate())) { block4newTemplate = block; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index 5dab5b7f3a..cb0e4562de 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -22,8 +22,6 @@ import com.fr.design.menu.ToolBarDef; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import com.fr.third.checkerframework.checker.nullness.qual.Nullable; -import com.fr.third.guava.util.concurrent.FutureCallback; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; @@ -138,7 +136,7 @@ public class TemplateThemeManagePane extends BasicPane return; } - T currentTheme4NewTemplate = config.getTheme4NewTemplate(); + T currentTheme4NewTemplate = config.cachedFetchTheme4NewTemplate(); if (currentTheme4NewTemplate == null) { setTheme4NewTemplateButton.setEnabled(true); return; @@ -171,7 +169,7 @@ public class TemplateThemeManagePane extends BasicPane public void actionPerformed(ActionEvent e) { T style = themeListPane.getSelectedTheme(); if (style != null) { - config.setTheme4NewTemplate(style.getName()); + config.setThemeName4NewTemplate(style.getName()); } } }); @@ -190,8 +188,8 @@ public class TemplateThemeManagePane 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_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightTheme4New())); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkTheme4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Light_Theme"), config.cachedFetchLightTheme4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.cachedFetchDarkTheme4New())); return menuDef; } From 4118096815808014139943ccce7d0759a75c43f9 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 15:59:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?REPORT-51919=20=E4=B8=BB=E9=A2=98=E5=88=87?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 新增模版主题功能: 主题管理面板和主题使用面板中对主题的获取操作,全部异步化, 提高加载性能 【改动思路】 同上 --- .../mainframe/theme/AsyncThemeFetcher.java | 86 +++++++++++++++++++ .../mainframe/theme/TemplateThemeBlock.java | 66 ++++---------- .../theme/TemplateThemeListPane.java | 63 +++++++++++--- .../theme/TemplateThemeManagePane.java | 40 +++++++-- 4 files changed, 185 insertions(+), 70 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java new file mode 100644 index 0000000000..add47d6a0b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java @@ -0,0 +1,86 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.module.ModuleContext; + +import java.util.concurrent.ExecutorService; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/24 + */ +public class AsyncThemeFetcher { + + private final ExecutorService executorService; + private final TemplateThemeConfig config; + + public AsyncThemeFetcher(int threads, TemplateThemeConfig config) { + this.executorService = ModuleContext.getExecutor().newFixedThreadPool( + threads, + new NamedThreadFactory(this.getClass().getName()) + ); + this.config = config; + } + + public void shutdown() { + executorService.shutdown(); + } + + public boolean isShutdown() { + return executorService.isShutdown(); + } + + public void submit(String themeName, AsyncThemeFetchCallback callback) { + callback.beforeCachedFetch(); + executorService.submit(new Runnable() { + @Override + public void run() { + if (executorService.isShutdown()) { + return; + } + T theme = config.cachedFetch(themeName, new TemplateThemeConfig.CacheCondition() { + @Override + public boolean shouldCacheTheme(T theme) { + return callback.shouldCache(AsyncThemeFetcher.this, theme); + } + }); + if (executorService.isShutdown()) { + return; + } + callback.afterCachedFetch(theme); + } + }); + } + + public interface AsyncThemeFetchCallback { + void beforeCachedFetch(); + boolean shouldCache(AsyncThemeFetcher fetcher, T theme); + void afterCachedFetch(T theme); + } + + public static class AsyncThemeFetchCallbackAdapter implements AsyncThemeFetchCallback { + + @Override + public void beforeCachedFetch() { + + } + + @Override + public boolean shouldCache(AsyncThemeFetcher fetcher, T theme) { + // 如果Fetcher已经关闭就不放进缓存里了 + // 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个, + // 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存. + // TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个 + // TODO: 后续看情况再优化吧. + return !fetcher.isShutdown(); + } + + @Override + public void afterCachedFetch(T theme) { + + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java index a61c2721e0..b61cd97988 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java @@ -55,16 +55,13 @@ public class TemplateThemeBlock extends JPanel { private boolean hovering = false; private MouseAdapter clickListener; - private final ExecutorService asyncThemeFetcher; public TemplateThemeBlock(String name, TemplateThemeConfig config, - TemplateThemeProfilePane profilePane, - ExecutorService asyncThemeFetcher) { + TemplateThemeProfilePane profilePane) { this.name = name; this.config = config; this.profilePane = profilePane; - this.asyncThemeFetcher = asyncThemeFetcher; initializePane(); addMouseListener(new MouseAdapter() { @@ -91,8 +88,6 @@ public class TemplateThemeBlock extends JPanel { repaint(); } }); - - fetchTheme(); } private void initializePane() { @@ -119,6 +114,21 @@ public class TemplateThemeBlock extends JPanel { add(infoPane, BorderLayout.SOUTH); } + public void setTheme(T theme) { + this.theme = theme; + thumbnailLabel.setIcon(null); + if (theme != null) { + ThemeThumbnail thumbnail = theme.getThumbnail(); + if (thumbnail != null) { + Image image = thumbnail.getImage(); + if (image != null) { + thumbnailLabel.setIcon(new ImageIcon(image)); + } + } + } + repaint(); + } + public T getTheme() { return this.theme; } @@ -166,48 +176,6 @@ public class TemplateThemeBlock extends JPanel { profileDialog.setVisible(true); } - public void fetchTheme() { - if (asyncThemeFetcher.isShutdown()) { - return; - } - asyncThemeFetcher.submit(new Runnable() { - @Override - public void run() { - if (asyncThemeFetcher.isShutdown()) { - return; - } - - theme = null; - // 耗时的同步操作,如远程设计器场景 - theme = config.cachedFetch(name, new TemplateThemeConfig.CacheCondition() { - @Override - public boolean shouldCacheTheme(T theme) { - // 如果Fetcher已经关闭就不放进缓存里了 - // 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个, - // 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存. - // TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个 - // TODO: 后续看情况再优化吧. - return !asyncThemeFetcher.isShutdown(); - } - }); - - if (asyncThemeFetcher.isShutdown()) { - return; - } - if (theme != null) { - ThemeThumbnail thumbnail = theme.getThumbnail(); - if (thumbnail != null) { - Image image = thumbnail.getImage(); - if (image != null) { - thumbnailLabel.setIcon(new ImageIcon(image)); - } - } - } - repaint(); - } - }); - } - @Override public void paint(Graphics g) { super.paint(g); @@ -215,7 +183,7 @@ public class TemplateThemeBlock extends JPanel { if (template != null) { TemplateThemeConfig templateUsingConfig = template.getUsingTemplateThemeConfig(); TemplateTheme templateTheme = template.getTemplateTheme(); - if (templateUsingConfig == this.config && StringUtils.equals(templateTheme.getName(), theme.getName())) { + if (templateUsingConfig == this.config && StringUtils.equals(templateTheme.getName(), name)) { theme4currentTemplateMarkIcon.paintIcon(this, g, 176, 0); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java index 403fde166f..1b6eab40a2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -2,14 +2,12 @@ package com.fr.design.mainframe.theme; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; -import com.fr.concurrent.NamedThreadFactory; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.module.ModuleContext; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -22,7 +20,6 @@ import java.awt.event.MouseEvent; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutorService; /** * @author Starryi @@ -33,12 +30,9 @@ public class TemplateThemeListPane extends BasicPane { public static final int BLOCK_COUNT_ROW_LINE = 3; public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; public static final int CONTENT_WIDTH = 630; + public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10; - private final ExecutorService asyncThemeFetcher = - ModuleContext.getExecutor().newFixedThreadPool( - 10, - new NamedThreadFactory("TemplateThemeListPane") - ); + private final AsyncThemeFetcher asyncThemeFetcher; protected final TemplateThemeConfig config; private final TemplateThemeProfilePane profilePane; @@ -57,6 +51,7 @@ public class TemplateThemeListPane extends BasicPane { this.config = config; this.profilePane = profilePane; this.contentListPane = new JPanel(); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(ASYNC_FETCH_THEME_THREAD_COUNT, config); initializePane(); } @@ -100,7 +95,7 @@ public class TemplateThemeListPane extends BasicPane { } private TemplateThemeBlock createNewTemplateThemeBlock(String name) { - final TemplateThemeBlock block = new TemplateThemeBlock<>(name, config, profilePane, asyncThemeFetcher); + final TemplateThemeBlock block = new TemplateThemeBlock<>(name, config, profilePane); block.addClickListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -108,6 +103,19 @@ public class TemplateThemeListPane extends BasicPane { setSelectedBlock(block); } }); + asyncThemeFetcher.submit(name, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + block.setTheme(null); + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + block.setTheme(theme); + } + }); return block; } @@ -128,6 +136,10 @@ public class TemplateThemeListPane extends BasicPane { } } + private void asyncFetchTheme(String themeName) { + asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName)); + } + @Override protected String title4PopupWindow() { return null; @@ -142,21 +154,22 @@ public class TemplateThemeListPane extends BasicPane { themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() { @Override public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) { + String themeName = event.themName; TemplateThemeBlock existingBlock = blockCache.get(event.themName); switch (event.action) { case DEFAULT_THEME_4_NEW_TEMPLATE_UPDATE: { if (block4newTemplate != null) { - block4newTemplate.fetchTheme(); + block4newTemplate.repaint(); } if (existingBlock != null) { - existingBlock.fetchTheme(); + existingBlock.repaint(); } block4newTemplate = existingBlock; break; } case UPDATE: { if (existingBlock != null) { - existingBlock.fetchTheme(); + asyncFetchTheme(themeName); } break; } @@ -176,6 +189,7 @@ public class TemplateThemeListPane extends BasicPane { if (existingBlock == null) { // TODO 这里是否还能继续优化? fillContentListPane(); + asyncFetchTheme(themeName); validate(); repaint(); } @@ -198,4 +212,29 @@ public class TemplateThemeListPane extends BasicPane { public void stopAsyncFetchTheme() { asyncThemeFetcher.shutdown(); } + + private class AsyncThemeListItemFetchCallback extends AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter { + private final String themeName; + public AsyncThemeListItemFetchCallback(String themeName) { + this.themeName = themeName; + } + + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(null); + } + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(theme); + } + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index cb0e4562de..0363bd88d4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -58,6 +58,8 @@ public class TemplateThemeManagePane extends BasicPane private final TemplateThemeListPane themeListPane; private final TemplateThemeProfilePane profilePane; + private final AsyncThemeFetcher asyncThemeFetcher; + public static TemplateThemeManagePane createFormThemesManagerPane() { FormThemeConfig config = FormThemeConfig.getInstance(); FormThemeProfilePane editPane = new FormThemeProfilePane(config); @@ -76,6 +78,7 @@ public class TemplateThemeManagePane extends BasicPane this.themeListPane = new TemplateThemeListPane<>(config, profilePane); this.removeAction = new RemoveThemeAction(false); this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(1, config); initializePane(); } @@ -167,9 +170,9 @@ public class TemplateThemeManagePane extends BasicPane setTheme4NewTemplateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - T style = themeListPane.getSelectedTheme(); - if (style != null) { - config.setThemeName4NewTemplate(style.getName()); + T theme = themeListPane.getSelectedTheme(); + if (theme != null) { + config.setThemeName4NewTemplate(theme.getName()); } } }); @@ -188,8 +191,8 @@ public class TemplateThemeManagePane 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_Template_Theme_Manager_Pane_Create_Light_Theme"), config.cachedFetchLightTheme4New())); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.cachedFetchDarkTheme4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightThemeName4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkThemeName4New())); return menuDef; } @@ -211,6 +214,9 @@ public class TemplateThemeManagePane extends BasicPane @Override public void actionPerformed(ActionEvent e) { T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); + if (theme == null) { + return; + } int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); @@ -226,20 +232,35 @@ public class TemplateThemeManagePane extends BasicPane } private class AddThemeAction extends UpdateAction { - private final T theme4New; + private T prototypeTheme; - public AddThemeAction(String name, T theme4New) { + public AddThemeAction(String name, String prototypeThemeName) { setName(name); setMnemonic('R'); - this.theme4New = theme4New; + asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + prototypeTheme = null; + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + prototypeTheme = theme; + } + }); } @Override public void actionPerformed(ActionEvent e) { + if (prototypeTheme == null) { + return; + } Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); try { - T theme = (T) theme4New.clone(); + T theme = (T) prototypeTheme.clone(); theme.setName(StringUtils.EMPTY); theme.setMutable(true); theme.setRemovable(true); @@ -285,6 +306,7 @@ public class TemplateThemeManagePane extends BasicPane } public void stopAsyncFetchTheme() { + asyncThemeFetcher.shutdown(); themeListPane.stopAsyncFetchTheme(); } } \ No newline at end of file From 759c2b2e29a90261597b530e7ebe3ea1825b0dd6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 15:59:07 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-57943=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=9110.0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=9A=84=E9=A2=84=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=94=BE11.0=E4=B8=8A=EF=BC=8C=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 模版主题功能后,预定义单元格样式功能废弃,所有预定义单元格样式将被 统一放置到"兼容主题"中,对于本地不存在的预定义单元格样式,将会被设置为兼 主题中默认单元格样式,因此这里不需要再执行检查 【改动思路】 同上 --- .../src/main/java/com/fr/design/mainframe/app/CptApp.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index 431b401fc9..62134c1211 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -45,7 +45,12 @@ class CptApp extends AbstractWorkBookApp { @Override public WorkBook asIOFile(FILE file) { - return asIOFile(file, true); + // 11.beta.1 + // REPORT-51919 主题切换 + // REPORT-57943 【主题切换】10.0自定义的预定义样式,模板放11.0上,配置丢失 + // 11.beta.1 模版主题功能后,预定义单元格样式功能废弃,所有预定义单元格样式将被统一放置到"兼容主题"中, + // 对于本地不存在的预定义单元格样式,将会被设置为兼容主题中默认单元格样式,因此这里不需要再执行检查 + return asIOFile(file, false); } @Override From 8de0b44c6175289b0f604a869f0dc84fe67a3432 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 17:25:46 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-57952=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=96=B0=E5=BB=BA=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=A0=87=E9=A2=98=E6=98=BE=E7=A4=BA=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 按照主题详情面板的类型分别显示不同的对话框标题 【改动思路】 同上 --- .../com/fr/design/mainframe/theme/FormThemeProfilePane.java | 6 ++++++ .../fr/design/mainframe/theme/ReportThemeProfilePane.java | 5 +++++ .../fr/design/mainframe/theme/TemplateThemeProfilePane.java | 2 +- .../mainframe/theme/dialog/TemplateThemeProfileDialog.java | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java index b06119b6cf..8f3e3171f8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java @@ -5,6 +5,7 @@ import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.FormTheme; import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedFormBodyStyle; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.theme.edit.ComponentStyleEditPane; import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane; import com.fr.design.mainframe.theme.preview.FormThemePreviewPane; @@ -87,4 +88,9 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane { ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); theme.setComponentStyle(componentStyle); } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Form_Theme_Profile_Dialog_Title"); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java index bcc50a8d30..4373029431 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java @@ -66,4 +66,9 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane extends @Override public String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Predefined_Style_Edit"); + return Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"); } private JPanel createLeftPane() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java index 31d00043dd..84853943b1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -40,7 +40,7 @@ public class TemplateThemeProfileDialog extends Templat public static final int CONTENT_HEIGHT = 570; public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane profilePane) { - super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + super(parent, profilePane.getTitle(), CONTENT_WIDTH, CONTENT_HEIGHT); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); From 2d490cacb658cac0054e36e9db7871756cdf4309 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 24 Aug 2021 18:41:35 +0800 Subject: [PATCH 6/6] =?UTF-8?q?REPORT-57974=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E6=96=B0=E5=BB=BA=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B2=A1=E6=8C=89=E7=85=A7=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E6=9D=BF=E4=B8=BB=E9=A2=98=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 补充新建模版后根据主题修改数据模型的逻辑 【改动思路】 同上 --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 2 +- .../src/main/java/com/fr/design/mainframe/JForm.java | 7 ++++++- .../src/main/java/com/fr/design/mainframe/JWorkBook.java | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 1eebed739f..543a2c3ca8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1713,7 +1713,7 @@ public abstract class JTemplate> return runtimeId; } - private void setUpTheme4NewTemplate() { + protected void setUpTheme4NewTemplate() { TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate(); TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); if (themeAttrMark == null) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 09808b7bb8..60463b3122 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -140,7 +140,6 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm getUsingTemplateThemeConfig() { return getTarget().getUsingTemplateThemeConfig(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 333c7415bd..3359513ce7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1269,6 +1269,13 @@ public class JWorkBook extends JTemplate { } } + @Override + protected void setUpTheme4NewTemplate() { + super.setUpTheme4NewTemplate(); + getTarget().setTemplateTheme(getTarget().getTemplateTheme()); + } + + @Override public TemplateThemeConfig getUsingTemplateThemeConfig() { return getTarget().getUsingTemplateThemeConfig();