Browse Source

优化代码,补充一些代码

feature/x
obo 10 months ago
parent
commit
05d416ed99
  1. 13
      designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java
  2. 2
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewCell.java
  3. 4
      designer-base/src/main/java/com/fr/widgettheme/util/WidgetThemeDesignerUtils.java
  4. 38
      designer-base/src/main/java/com/fr/widgettheme/widget/mobile/provider/WidgetThemeMobileStyleDefinePaneCreator.java
  5. 13
      designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java
  6. 1
      designer-form/src/main/java/com/fr/design/widgettheme/common/EditorSettingPane.java

13
designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java

@ -1,29 +1,16 @@
package com.fr.widgettheme.theme.edit.widget;
import com.fr.base.background.ColorBackground;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.gui.frpane.FontSizeComboPane;
import com.fr.design.utils.ColorUtils;
import com.fr.widgettheme.theme.widget.style.BorderStyle;
import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.widgettheme.theme.widget.style.StyleType;
import com.fr.widgettheme.theme.widget.style.ThemeTextStyle;
import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle;
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants;
import com.fr.widgettheme.util.WidgetThemeDesignerUtils;
import java.awt.Color;
import java.util.Arrays;
import java.util.Vector;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_00000000_HEX;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_00FFFFFF_HEX;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_26000000_HEX;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_26FFFFFF_HEX;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_CC000000_HEX;
import static com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants.COLOR_CCFFFFFF_HEX;
/**
* 移动端控件样式编辑面板
*

2
designer-base/src/main/java/com/fr/widgettheme/theme/panel/ControlPreviewCell.java

@ -7,6 +7,7 @@ import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants;
import javax.swing.Icon;
import javax.swing.ImageIcon;
@ -106,6 +107,7 @@ public class ControlPreviewCell extends JPanel {
*/
public void paintBgColor(Graphics g, ThemedWidgetStyle widgetStyle, int alpha) {
Color themeColor = widgetStyle.getWidgetBackground().getColor();
themeColor = themeColor == null ? WidgetThemeDisplayConstants.DEFAULT_TRANSPARENT_COLOR : themeColor;
g.setColor(new Color(themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue(), alpha));
g.fillRoundRect(0, 0, getSize().width - 1, getSize().height - 1, (int) widgetStyle.getBorderStyle().getRadius(), (int) widgetStyle.getBorderStyle().getRadius());
//需要重新绘制一遍字体,否则会被颜色填充给遮住

4
designer-base/src/main/java/com/fr/widgettheme/util/WidgetThemeDesignerUtils.java

@ -9,6 +9,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.stable.StringUtils;
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr;
import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingConstants;
import java.awt.Color;
@ -67,9 +68,10 @@ public class WidgetThemeDesignerUtils {
/**
* 创建垂直方向顶部对齐的label
*/
@NotNull
public static UILabel createTopAlignmentLabel(String labelName) {
if(StringUtils.isEmpty(labelName)) {
return null;
return new UILabel("");
}
UILabel label = new UILabel(labelName);
label.setVerticalAlignment(SwingConstants.TOP);

38
designer-base/src/main/java/com/fr/widgettheme/widget/mobile/provider/WidgetThemeMobileStyleDefinePaneCreator.java

@ -24,6 +24,9 @@ import com.fr.log.FineLoggerFactory;
import com.fr.widgettheme.widget.mobile.pane.IconColorMobileStyleDefinePane;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
/**
* 控件主题移动端样式窗口创建类
*
@ -36,6 +39,28 @@ public class WidgetThemeMobileStyleDefinePaneCreator {
private WidgetThemeMobileStyleDefinePaneCreator() {
}
/**
* 需要特殊处理的控件集合
*/
private static final Set<Class<? extends Widget>> SPECIAL_WIDGET_SET = new HashSet<>();
/**
* 带有图标颜色的控件集合
*/
private static final Set<Class<? extends Widget>> ICON_WIDGET_SET = new HashSet<>();
static {
SPECIAL_WIDGET_SET.add(FreeButton.class);
SPECIAL_WIDGET_SET.add(Label.class);
SPECIAL_WIDGET_SET.add(MultiFileEditor.class);
SPECIAL_WIDGET_SET.add(TextArea.class);
ICON_WIDGET_SET.add(TextEditor.class);
ICON_WIDGET_SET.add(NumberEditor.class);
ICON_WIDGET_SET.add(Password.class);
ICON_WIDGET_SET.add(DateEditor.class);
ICON_WIDGET_SET.add(ComboBox.class);
ICON_WIDGET_SET.add(ComboCheckBox.class);
ICON_WIDGET_SET.add(TreeEditor.class);
}
/**
* 创建移动端控件样式属性窗口
*
@ -47,7 +72,7 @@ public class WidgetThemeMobileStyleDefinePaneCreator {
public static BasicBeanPane<MobileStyle> createBaseBeanPane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customDefinePane, Class<? extends MobileStyle> mobileStyle) {
try {
if (WidgetThemeDesignerUtils.enableWidgetEnhance()) {
if (specialCommonWidget(widget)) {
if (isSpecialWidget(widget)) {
return DisplayEnhanceMobileStyleFactory.createWidgetMobileStyleDefinePane(widget, customDefinePane, mobileStyle);
} else if (isIconWidget(widget)) {
return new IconColorMobileStyleDefinePane(widget, customDefinePane, mobileStyle);
@ -68,7 +93,7 @@ public class WidgetThemeMobileStyleDefinePaneCreator {
* @return class
*/
public static @NotNull Class<? extends MobileCommonExtraStyle> classForCommonExtraStyle(Widget widget) {
if (specialCommonWidget(widget)) {
if (isSpecialWidget(widget)) {
return DisplayEnhanceMobileStyleFactory.classForWidgetCommonExtraStyle(widget);
} else {
return WidgetThemeMobileCommonExtraStyle.class;
@ -82,8 +107,8 @@ public class WidgetThemeMobileStyleDefinePaneCreator {
* @param widget 控件
* @return /
*/
private static boolean specialCommonWidget(Widget widget) {
return widget instanceof FreeButton || widget instanceof Label || widget instanceof MultiFileEditor || widget instanceof TextArea;
private static boolean isSpecialWidget(Widget widget) {
return SPECIAL_WIDGET_SET.contains(widget.getClass());
}
/**
@ -93,9 +118,6 @@ public class WidgetThemeMobileStyleDefinePaneCreator {
* @return /
*/
private static boolean isIconWidget(Widget widget) {
return widget instanceof TextEditor || widget instanceof NumberEditor || widget instanceof Password ||
widget instanceof DateEditor || widget instanceof ComboBox || widget instanceof ComboCheckBox ||
widget instanceof TreeEditor ||
WidgetThemeServerUtils.isNewComboBoxTreeEditor(widget);
return ICON_WIDGET_SET.contains(widget.getClass()) || WidgetThemeServerUtils.isNewComboBoxTreeEditor(widget);
}
}

13
designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java

@ -8,7 +8,6 @@ import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import com.fr.util.ColorUtils;
import com.fr.widgettheme.theme.widget.style.BorderStyle;
import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle;
@ -38,7 +37,6 @@ import com.fr.widgettheme.util.WidgetThemeDesignerUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -135,9 +133,7 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
protected void initStyleEditor() {
colorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, false);
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
borderColorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true);
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
initBorderPane();
frFontPane = new FRFontPane();
buttonStyleDefinedPane = new ButtonStyleDefinedPane();
selectBgColorBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true);
@ -337,4 +333,11 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
labelMap.put(setting, WidgetThemeDesignerUtils.createTopAlignmentLabel(Toolkit.i18nText(setting.getLabelI18nKey())));
}
}
private void initBorderPane() {
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
borderColorSelectBox = new NewColorSelectBox(WidgetThemeDisplayConstants.THEME_WIDGET_COMPONENT_WIDTH, true);
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
lineComboBox.addItemListener(e -> borderColorSelectBox.setVisible(!Integer.valueOf(0).equals(e.getItem())));
}
}

1
designer-form/src/main/java/com/fr/design/widgettheme/common/EditorSettingPane.java

@ -28,6 +28,7 @@ public class EditorSettingPane<T extends Widget> extends BaseStyleSettingPane<T>
StyleSetting.THEME_COLOR,
StyleSetting.WIDGET_BACKGROUND,
StyleSetting.LINE_TYPE,
StyleSetting.LINE_COLOR,
StyleSetting.BORDER_RADIUS
));
}

Loading…
Cancel
Save