帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.5 KiB

package com.fr.widgettheme.util;
import com.fr.base.io.AttrMark;
import com.fr.base.io.IOFile;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
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 javax.swing.SwingConstants;
import java.awt.Color;
/**
* 控件主题设计器部分工具类
*
* @author obo
* @since 11.0
* Created on 2023/11/13
*/
public class WidgetThemeDesignerUtils {
private WidgetThemeDesignerUtils() {
}
/**
* WorkBook 中加载 WatermarkAttr 属性对象
*
* @param template AttrMark 对象包括 WorkBook
* @return StrongestControlMarkAttr 对象
*/
public static WidgetDisplayEnhanceMarkAttr getStrongestControlAttrFromTemplate(AttrMark template) {
return template.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG);
}
/**
* 判断是否启用了控件显示增强
*
* @return 开启与否
*/
public static boolean enableWidgetEnhance() {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(jTemplate)) {
IOFile ioFile = (IOFile) jTemplate.getTarget();
WidgetDisplayEnhanceMarkAttr mark = ioFile.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG);
return mark != null && mark.isWidgetEnhance();
}
return false;
}
/**
* 返回当前编辑模版的主题深浅
*/
public static boolean isCurrentTemplateThemeDark() {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(jTemplate)) {
TemplateTheme theme = jTemplate.getTemplateTheme();
if (theme != null) {
return theme.isDark();
}
return false;
}
throw new IllegalArgumentException("The current template is not valid");
}
/**
* 创建垂直方向顶部对齐的label
*/
public static UILabel createTopAlignmentLabel(String labelName) {
if(StringUtils.isEmpty(labelName)) {
return null;
}
UILabel label = new UILabel(labelName);
label.setVerticalAlignment(SwingConstants.TOP);
return label;
}
}