Browse Source

Pull request #5520: REPORT-57934 & REPORT-51919 & REPORT-57943 & REPORT-57952

Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x

* commit '2d490cacb658cac0054e36e9db7871756cdf4309':
  REPORT-57974 【主题切换】新建模板时,没按照设置的模板主题来
  REPORT-57952 【主题切换】新建模板主题标题显示有问题
  REPORT-57943 【主题切换】10.0自定义的预定义样式,模板放11.0上,配置丢失
  REPORT-51919 主题切换
  REPORT-51919 主题切换
  REPORT-57934 【主题切换】新建主题时,未填写主题名称不能设置细节配置
research/11.0
starryi 3 years ago
parent
commit
c6e3c38035
  1. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 86
      designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java
  3. 6
      designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java
  4. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java
  5. 69
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java
  6. 65
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java
  7. 44
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java
  8. 5
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java
  10. 7
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  11. 7
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  12. 7
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java

5
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.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager; import javax.swing.undo.UndoManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.Set; import java.util.Set;
@ -1714,8 +1713,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return runtimeId; return runtimeId;
} }
private void setUpTheme4NewTemplate() { protected void setUpTheme4NewTemplate() {
TemplateTheme theme = getUsingTemplateThemeConfig().getTheme4NewTemplate(); TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate();
TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG);
if (themeAttrMark == null) { if (themeAttrMark == null) {
themeAttrMark = new TemplateThemeAttrMark(); themeAttrMark = new TemplateThemeAttrMark();

86
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<T extends TemplateTheme> {
private final ExecutorService executorService;
private final TemplateThemeConfig<T> config;
public AsyncThemeFetcher(int threads, TemplateThemeConfig<T> 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<T> callback) {
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);
}
});
if (executorService.isShutdown()) {
return;
}
callback.afterCachedFetch(theme);
}
});
}
public interface AsyncThemeFetchCallback<T extends TemplateTheme> {
void beforeCachedFetch();
boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme);
void afterCachedFetch(T theme);
}
public static class AsyncThemeFetchCallbackAdapter<T extends TemplateTheme> implements AsyncThemeFetchCallback<T> {
@Override
public void beforeCachedFetch() {
}
@Override
public boolean shouldCache(AsyncThemeFetcher<T> fetcher, T theme) {
// 如果Fetcher已经关闭就不放进缓存里了
// 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个,
// 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存.
// TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个
// TODO: 后续看情况再优化吧.
return !fetcher.isShutdown();
}
@Override
public void afterCachedFetch(T theme) {
}
}
}

6
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.FormTheme;
import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.base.theme.settings.ThemedFormBodyStyle; 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.ComponentStyleEditPane;
import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane; import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane;
import com.fr.design.mainframe.theme.preview.FormThemePreviewPane; import com.fr.design.mainframe.theme.preview.FormThemePreviewPane;
@ -87,4 +88,9 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean();
theme.setComponentStyle(componentStyle); theme.setComponentStyle(componentStyle);
} }
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Form_Theme_Profile_Dialog_Title");
}
} }

5
designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java

@ -66,4 +66,9 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane<ReportTheme
public void updateBean(ReportTheme theme) { public void updateBean(ReportTheme theme) {
theme.setBodyStyle(this.reportBodyStyleSettingPane.updateBean()); theme.setBodyStyle(this.reportBodyStyleSettingPane.updateBean());
} }
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Theme_Profile_Dialog_Title");
}
} }

69
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java

@ -55,16 +55,13 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
private boolean hovering = false; private boolean hovering = false;
private MouseAdapter clickListener; private MouseAdapter clickListener;
private final ExecutorService asyncThemeFetcher;
public TemplateThemeBlock(String name, public TemplateThemeBlock(String name,
TemplateThemeConfig<T> config, TemplateThemeConfig<T> config,
TemplateThemeProfilePane<T> profilePane, TemplateThemeProfilePane<T> profilePane) {
ExecutorService asyncThemeFetcher) {
this.name = name; this.name = name;
this.config = config; this.config = config;
this.profilePane = profilePane; this.profilePane = profilePane;
this.asyncThemeFetcher = asyncThemeFetcher;
initializePane(); initializePane();
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
@ -91,8 +88,6 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
repaint(); repaint();
} }
}); });
fetchTheme();
} }
private void initializePane() { private void initializePane() {
@ -119,6 +114,21 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
add(infoPane, BorderLayout.SOUTH); 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() { public T getTheme() {
return this.theme; return this.theme;
} }
@ -166,48 +176,6 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
profileDialog.setVisible(true); 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<T>() {
@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 @Override
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
@ -215,13 +183,12 @@ public class TemplateThemeBlock<T extends TemplateTheme> extends JPanel {
if (template != null) { if (template != null) {
TemplateThemeConfig<? extends TemplateTheme> templateUsingConfig = template.getUsingTemplateThemeConfig(); TemplateThemeConfig<? extends TemplateTheme> templateUsingConfig = template.getUsingTemplateThemeConfig();
TemplateTheme templateTheme = template.getTemplateTheme(); 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); theme4currentTemplateMarkIcon.paintIcon(this, g, 176, 0);
} }
} }
T theme4newTemplate = config.getTheme4NewTemplate(); if (StringUtils.equals(config.getThemeName4NewTemplate(), name)) {
if (StringUtils.equals(theme4newTemplate.getName(), name)) {
theme4NewTemplateMarkIcon.paintIcon(this, g, 0, 0); theme4NewTemplateMarkIcon.paintIcon(this, g, 0, 0);
} }

65
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.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.TemplateThemeConfig;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeEvent;
import com.fr.design.event.ChangeListener; import com.fr.design.event.ChangeListener;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -22,7 +20,6 @@ import java.awt.event.MouseEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutorService;
/** /**
* @author Starryi * @author Starryi
@ -33,12 +30,9 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
public static final int BLOCK_COUNT_ROW_LINE = 3; public static final int BLOCK_COUNT_ROW_LINE = 3;
public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1;
public static final int CONTENT_WIDTH = 630; public static final int CONTENT_WIDTH = 630;
public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10;
private final ExecutorService asyncThemeFetcher = private final AsyncThemeFetcher<T> asyncThemeFetcher;
ModuleContext.getExecutor().newFixedThreadPool(
10,
new NamedThreadFactory("TemplateThemeListPane")
);
protected final TemplateThemeConfig<T> config; protected final TemplateThemeConfig<T> config;
private final TemplateThemeProfilePane<T> profilePane; private final TemplateThemeProfilePane<T> profilePane;
@ -57,6 +51,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
this.config = config; this.config = config;
this.profilePane = profilePane; this.profilePane = profilePane;
this.contentListPane = new JPanel(); this.contentListPane = new JPanel();
this.asyncThemeFetcher = new AsyncThemeFetcher<>(ASYNC_FETCH_THEME_THREAD_COUNT, config);
initializePane(); initializePane();
} }
@ -84,7 +79,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
if (config.contains(name)) { if (config.contains(name)) {
TemplateThemeBlock<T> block = createCachedTemplateThemeBlock(name); TemplateThemeBlock<T> block = createCachedTemplateThemeBlock(name);
contentListPane.add(block); contentListPane.add(block);
if (StringUtils.equals(name, config.getTheme4NewTemplate().getName())) { if (StringUtils.equals(name, config.getThemeName4NewTemplate())) {
block4newTemplate = block; block4newTemplate = block;
} }
} }
@ -100,7 +95,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
} }
private TemplateThemeBlock<T> createNewTemplateThemeBlock(String name) { private TemplateThemeBlock<T> createNewTemplateThemeBlock(String name) {
final TemplateThemeBlock<T> block = new TemplateThemeBlock<>(name, config, profilePane, asyncThemeFetcher); final TemplateThemeBlock<T> block = new TemplateThemeBlock<>(name, config, profilePane);
block.addClickListener(new MouseAdapter() { block.addClickListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -108,6 +103,19 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
setSelectedBlock(block); setSelectedBlock(block);
} }
}); });
asyncThemeFetcher.submit(name, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() {
@Override
public void beforeCachedFetch() {
super.beforeCachedFetch();
block.setTheme(null);
}
@Override
public void afterCachedFetch(T theme) {
super.afterCachedFetch(theme);
block.setTheme(theme);
}
});
return block; return block;
} }
@ -128,6 +136,10 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
} }
} }
private void asyncFetchTheme(String themeName) {
asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName));
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return null; return null;
@ -142,21 +154,22 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() { themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() {
@Override @Override
public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) { public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) {
String themeName = event.themName;
TemplateThemeBlock<T> existingBlock = blockCache.get(event.themName); TemplateThemeBlock<T> existingBlock = blockCache.get(event.themName);
switch (event.action) { switch (event.action) {
case DEFAULT_THEME_4_NEW_TEMPLATE_UPDATE: { case DEFAULT_THEME_4_NEW_TEMPLATE_UPDATE: {
if (block4newTemplate != null) { if (block4newTemplate != null) {
block4newTemplate.fetchTheme(); block4newTemplate.repaint();
} }
if (existingBlock != null) { if (existingBlock != null) {
existingBlock.fetchTheme(); existingBlock.repaint();
} }
block4newTemplate = existingBlock; block4newTemplate = existingBlock;
break; break;
} }
case UPDATE: { case UPDATE: {
if (existingBlock != null) { if (existingBlock != null) {
existingBlock.fetchTheme(); asyncFetchTheme(themeName);
} }
break; break;
} }
@ -176,6 +189,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
if (existingBlock == null) { if (existingBlock == null) {
// TODO 这里是否还能继续优化? // TODO 这里是否还能继续优化?
fillContentListPane(); fillContentListPane();
asyncFetchTheme(themeName);
validate(); validate();
repaint(); repaint();
} }
@ -198,4 +212,29 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
public void stopAsyncFetchTheme() { public void stopAsyncFetchTheme() {
asyncThemeFetcher.shutdown(); asyncThemeFetcher.shutdown();
} }
private class AsyncThemeListItemFetchCallback extends AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T> {
private final String themeName;
public AsyncThemeListItemFetchCallback(String themeName) {
this.themeName = themeName;
}
@Override
public void beforeCachedFetch() {
super.beforeCachedFetch();
TemplateThemeBlock<T> block = blockCache.get(themeName);
if (block != null) {
block.setTheme(null);
}
}
@Override
public void afterCachedFetch(T theme) {
super.afterCachedFetch(theme);
TemplateThemeBlock<T> block = blockCache.get(themeName);
if (block != null) {
block.setTheme(theme);
}
}
}
} }

44
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.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; 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.Configurations;
import com.fr.transaction.WorkerFacade; import com.fr.transaction.WorkerFacade;
@ -60,6 +58,8 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
private final TemplateThemeListPane<T> themeListPane; private final TemplateThemeListPane<T> themeListPane;
private final TemplateThemeProfilePane<T> profilePane; private final TemplateThemeProfilePane<T> profilePane;
private final AsyncThemeFetcher<T> asyncThemeFetcher;
public static TemplateThemeManagePane<FormTheme> createFormThemesManagerPane() { public static TemplateThemeManagePane<FormTheme> createFormThemesManagerPane() {
FormThemeConfig config = FormThemeConfig.getInstance(); FormThemeConfig config = FormThemeConfig.getInstance();
FormThemeProfilePane editPane = new FormThemeProfilePane(config); FormThemeProfilePane editPane = new FormThemeProfilePane(config);
@ -78,6 +78,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
this.themeListPane = new TemplateThemeListPane<>(config, profilePane); this.themeListPane = new TemplateThemeListPane<>(config, profilePane);
this.removeAction = new RemoveThemeAction(false); this.removeAction = new RemoveThemeAction(false);
this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting"));
this.asyncThemeFetcher = new AsyncThemeFetcher<>(1, config);
initializePane(); initializePane();
} }
@ -138,7 +139,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
return; return;
} }
T currentTheme4NewTemplate = config.getTheme4NewTemplate(); T currentTheme4NewTemplate = config.cachedFetchTheme4NewTemplate();
if (currentTheme4NewTemplate == null) { if (currentTheme4NewTemplate == null) {
setTheme4NewTemplateButton.setEnabled(true); setTheme4NewTemplateButton.setEnabled(true);
return; return;
@ -169,9 +170,9 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
setTheme4NewTemplateButton.addActionListener(new ActionListener() { setTheme4NewTemplateButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
T style = themeListPane.getSelectedTheme(); T theme = themeListPane.getSelectedTheme();
if (style != null) { if (theme != null) {
config.setTheme4NewTemplate(style.getName()); config.setThemeName4NewTemplate(theme.getName());
} }
} }
}); });
@ -190,8 +191,8 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
menuDef.setRePaint(true); 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_Light_Theme"), config.getLightThemeName4New()));
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_Dark_Theme"), config.getDarkThemeName4New()));
return menuDef; return menuDef;
} }
@ -213,6 +214,9 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme();
if (theme == null) {
return;
}
int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this),
Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), 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); Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
@ -228,20 +232,35 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
} }
private class AddThemeAction extends UpdateAction { 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); setName(name);
setMnemonic('R'); setMnemonic('R');
this.theme4New = theme4New; asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<T>() {
@Override
public void beforeCachedFetch() {
super.beforeCachedFetch();
prototypeTheme = null;
}
@Override
public void afterCachedFetch(T theme) {
super.afterCachedFetch(theme);
prototypeTheme = theme;
}
});
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (prototypeTheme == null) {
return;
}
Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this);
TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); TemplateThemeProfileDialog<T> profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane);
try { try {
T theme = (T) theme4New.clone(); T theme = (T) prototypeTheme.clone();
theme.setName(StringUtils.EMPTY); theme.setName(StringUtils.EMPTY);
theme.setMutable(true); theme.setMutable(true);
theme.setRemovable(true); theme.setRemovable(true);
@ -287,6 +306,7 @@ public class TemplateThemeManagePane<T extends TemplateTheme> extends BasicPane
} }
public void stopAsyncFetchTheme() { public void stopAsyncFetchTheme() {
asyncThemeFetcher.shutdown();
themeListPane.stopAsyncFetchTheme(); themeListPane.stopAsyncFetchTheme();
} }
} }

5
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java

@ -122,7 +122,7 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Predefined_Style_Edit"); return Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title");
} }
private JPanel createLeftPane() { private JPanel createLeftPane() {
@ -563,9 +563,6 @@ public abstract class TemplateThemeProfilePane<T extends TemplateTheme> extends
boolean valid = StringUtils.isEmpty(error); boolean valid = StringUtils.isEmpty(error);
if (!valid) {
textField.requestFocus();
}
errorLabel.setVisible(!valid); errorLabel.setVisible(!valid);
if (actionButtons != null && actionButtons.length > 0) { if (actionButtons != null && actionButtons.length > 0) {
for (UIButton button : actionButtons) { for (UIButton button : actionButtons) {

2
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java

@ -40,7 +40,7 @@ public class TemplateThemeProfileDialog<T extends TemplateTheme> extends Templat
public static final int CONTENT_HEIGHT = 570; public static final int CONTENT_HEIGHT = 570;
public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane<T> profilePane) { public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane<T> 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(); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT));

7
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -140,7 +140,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public JForm() { public JForm() {
super(new Form(new WBorderLayout("form")), "Form"); super(new Form(new WBorderLayout("form")), "Form");
// setTemplateTheme(getUsingTemplateThemeConfig().getDefaultTheme4NewTemplate());
} }
public JForm(Form form, FILE file, Parameter[] parameters) { public JForm(Form form, FILE file, Parameter[] parameters) {
@ -1168,6 +1167,12 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
} }
@Override
protected void setUpTheme4NewTemplate() {
super.setUpTheme4NewTemplate();
getTarget().setTemplateTheme(getTarget().getTemplateTheme());
}
@Override @Override
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() { public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return getTarget().getUsingTemplateThemeConfig(); return getTarget().getUsingTemplateThemeConfig();

7
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -1269,6 +1269,13 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
} }
} }
@Override
protected void setUpTheme4NewTemplate() {
super.setUpTheme4NewTemplate();
getTarget().setTemplateTheme(getTarget().getTemplateTheme());
}
@Override @Override
public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() { public TemplateThemeConfig<? extends TemplateTheme> getUsingTemplateThemeConfig() {
return getTarget().getUsingTemplateThemeConfig(); return getTarget().getUsingTemplateThemeConfig();

7
designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java

@ -45,7 +45,12 @@ class CptApp extends AbstractWorkBookApp {
@Override @Override
public WorkBook asIOFile(FILE file) { 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 @Override

Loading…
Cancel
Save