Browse Source

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

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

【改动思路】
同上
persist/11.0
Starryi 3 years ago
parent
commit
0c6391f2d9
  1. 20
      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

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

@ -126,15 +126,17 @@ public class TemplateThemeListPane<T extends TemplateTheme> extends BasicPane {
}
private void setSelectedBlock(TemplateThemeBlock<T> 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));
}
}
}

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;
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<T extends TemplateTheme> 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<T extends TemplateTheme> 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<T extends TemplateTheme> 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);
}
}
}
Loading…
Cancel
Save