|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |