Browse Source

REPORT-58800 【主题切换】优化主题选择界面 应用主题的交互

【问题原因】
交互变更:
直接点击主题列表中的主题块就可以切换当前模版使用的主题

【改动思路】
同上
persist/11.0
Starryi 3 years ago
parent
commit
0c6391f2d9
  1. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java
  2. 65
      designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java

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

@ -126,6 +126,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
} }
private void setSelectedBlock(TemplateThemeBlock<T> block) { private void setSelectedBlock(TemplateThemeBlock<T> block) {
if (selectedBlock != block) {
if (selectedBlock != null) { if (selectedBlock != null) {
selectedBlock.setSelected(false); selectedBlock.setSelected(false);
} }
@ -137,6 +138,7 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
changeListener.fireChanged(new ChangeEvent(this)); changeListener.fireChanged(new ChangeEvent(this));
} }
} }
}
private void asyncFetchTheme(String themeName) { private void asyncFetchTheme(String themeName) {
asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName)); asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName));

65
designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java

@ -1,9 +1,8 @@
package com.fr.design.mainframe.theme.dialog; package com.fr.design.mainframe.theme.dialog;
import com.fr.base.theme.ThemedTemplate;
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.design.base.mode.DesignModeContext; import com.fr.base.theme.ThemedTemplate;
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.ibutton.UIButton; 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.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.TemplateThemeListPane;
import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.design.mainframe.theme.ui.BorderUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -43,54 +41,25 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
JPanel content = createContent(); JPanel content = createContent();
UIButton openThemeManagerButton = createOpenThemeManagerButton(); UIButton openThemeManagerButton = createOpenThemeManagerButton();
UIButton usingCurrentThemeButton = createUsingCurrentThemeButton();
UIButton completeButton = createCompleteButton(); UIButton completeButton = createCompleteButton();
setContentPane(createDialogContentPane(content, setContentPane(createDialogContentPane(content,
new UIButton[]{ openThemeManagerButton }, new UIButton[]{ openThemeManagerButton },
new UIButton[]{ usingCurrentThemeButton, completeButton } new UIButton[]{ completeButton }
)); ));
themeListPane.startListenThemeConfig(); themeListPane.startListenThemeConfig();
resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton);
themeListPane.setSelectedChangeListener(new ChangeListener() { themeListPane.setSelectedChangeListener(new ChangeListener() {
@Override @Override
public void fireChanged(ChangeEvent event) { 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() { private JPanel createContent() {
@ -123,17 +92,6 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
return null; 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() { private UIButton createCompleteButton() {
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete")); UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete"));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@ -150,13 +108,4 @@ TemplateThemeUsingDialog<T extends TemplateTheme> extends TemplateThemeDialog {
themeListPane.stopAsyncFetchTheme(); themeListPane.stopAsyncFetchTheme();
super.exit(); super.exit();
} }
private void apply2CurrentTemplate(UIButton usingCurrentThemeButton) {
TemplateTheme theme = themeListPane.getSelectedTheme();
if (theme != null) {
currentTemplate.setTemplateTheme(theme);
themeListPane.repaint();
usingCurrentThemeButton.setEnabled(false);
}
}
} }
Loading…
Cancel
Save