From 0c6391f2d9831e22abe03a4950c6c807bbe888b8 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 2 Sep 2021 18:58:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58800=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91=E4=BC=98=E5=8C=96=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=95=8C=E9=9D=A2=20=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E7=9A=84=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 交互变更: 直接点击主题列表中的主题块就可以切换当前模版使用的主题 【改动思路】 同上 --- .../theme/TemplateThemeListPane.java | 20 +++--- .../dialog/TemplateThemeUsingDialog.java | 65 ++----------------- 2 files changed, 18 insertions(+), 67 deletions(-) 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 524c272ac9..4930335126 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 @@ -126,15 +126,17 @@ public class TemplateThemeListPane extends BasicPane { } private void setSelectedBlock(TemplateThemeBlock block) { - if (selectedBlock != null) { - selectedBlock.setSelected(false); - } - selectedBlock = block; - if (selectedBlock != null) { - selectedBlock.setSelected(true); - } - if (changeListener != null) { - changeListener.fireChanged(new ChangeEvent(this)); + if (selectedBlock != block) { + if (selectedBlock != null) { + selectedBlock.setSelected(false); + } + selectedBlock = block; + if (selectedBlock != null) { + selectedBlock.setSelected(true); + } + if (changeListener != null) { + changeListener.fireChanged(new ChangeEvent(this)); + } } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java index 1d17bb4eb2..e4f4b5fd27 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java @@ -1,9 +1,8 @@ package com.fr.design.mainframe.theme.dialog; -import com.fr.base.theme.ThemedTemplate; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; -import com.fr.design.base.mode.DesignModeContext; +import com.fr.base.theme.ThemedTemplate; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.ibutton.UIButton; @@ -11,7 +10,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.ui.BorderUtils; -import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; @@ -43,56 +41,27 @@ TemplateThemeUsingDialog extends TemplateThemeDialog { JPanel content = createContent(); UIButton openThemeManagerButton = createOpenThemeManagerButton(); - UIButton usingCurrentThemeButton = createUsingCurrentThemeButton(); UIButton completeButton = createCompleteButton(); setContentPane(createDialogContentPane(content, new UIButton[]{ openThemeManagerButton }, - new UIButton[]{ usingCurrentThemeButton, completeButton } + new UIButton[]{ completeButton } )); themeListPane.startListenThemeConfig(); - resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); themeListPane.setSelectedChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { - resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); + TemplateTheme theme = themeListPane.getSelectedTheme(); + if (theme != null) { + currentTemplate.setTemplateTheme(theme); + themeListPane.repaint(); + } } }); } - private void resetEnableCurrentThemeButton(T selectedTheme, UIButton usingCurrentThemeButton) { - if (selectedTheme == null) { - usingCurrentThemeButton.setEnabled(false); - return; - } - String selectedThemeName = selectedTheme.getName(); - if (StringUtils.isEmpty(selectedThemeName)) { - usingCurrentThemeButton.setEnabled(false); - return; - } - - if (currentTemplate == null) { - usingCurrentThemeButton.setEnabled(false); - return; - } - - TemplateTheme templateUsingTheme = currentTemplate.getTemplateTheme(); - if (templateUsingTheme == null) { - usingCurrentThemeButton.setEnabled(true); - return; - } - - String templateUsingThemeName = templateUsingTheme.getName(); - if (StringUtils.isEmpty(templateUsingThemeName)) { - usingCurrentThemeButton.setEnabled(true); - return; - } - - usingCurrentThemeButton.setEnabled(!StringUtils.equals(templateUsingThemeName, selectedTheme.getName())); - } - private JPanel createContent() { JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); @@ -123,17 +92,6 @@ TemplateThemeUsingDialog extends TemplateThemeDialog { return null; } - private UIButton createUsingCurrentThemeButton() { - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Use")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - apply2CurrentTemplate(button); - } - }); - return button; - } - private UIButton createCompleteButton() { UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete")); button.addActionListener(new ActionListener() { @@ -150,13 +108,4 @@ TemplateThemeUsingDialog extends TemplateThemeDialog { themeListPane.stopAsyncFetchTheme(); super.exit(); } - - private void apply2CurrentTemplate(UIButton usingCurrentThemeButton) { - TemplateTheme theme = themeListPane.getSelectedTheme(); - if (theme != null) { - currentTemplate.setTemplateTheme(theme); - themeListPane.repaint(); - usingCurrentThemeButton.setEnabled(false); - } - } } \ No newline at end of file