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.
111 lines
3.5 KiB
111 lines
3.5 KiB
package com.fine.theme.utils; |
|
|
|
import com.finebi.cbb.utils.StringUtils; |
|
|
|
import javax.swing.JComponent; |
|
|
|
/** |
|
* UI样式工具 |
|
* |
|
* @author vito |
|
* @since 11.0 |
|
* Created on 2024/1/4 |
|
*/ |
|
public interface FineUIStyle { |
|
|
|
String IN_TOOLBAR_GROUP = "inToolbarGroup"; |
|
String STYLE_PRIMARY = "primary"; |
|
String STYLE_SECONDARY = "secondary"; |
|
String STYLE_TEXT = "text"; |
|
String STYLE_SIZE_MEDIUM = "mediumSize"; |
|
String STYLE_SIZE_SMALL = "smallSize"; |
|
String MENU_BAR = "menuBar"; |
|
String LIGHT_GREY = "lightGrey"; |
|
String IN_TOOLBAR_LEFT = "inToolbarLeft"; |
|
String IN_TOOLBAR_RIGHT = "inToolbarRight"; |
|
String NORMAL_COLOR = "normalColor"; |
|
String TOP_TOOLS = "topTools"; |
|
String BRAND_COLOR_LABEL = "brandColorLabel"; |
|
String BUTTON_TAB_ACTION = "tabAction"; |
|
String LABEL_BOLD = "boldLabel"; |
|
String LABEL_TIP = "tipLabel"; |
|
String LABEL_WARNING_TIP = "warningTipLabel"; |
|
String PLAIN_BUTTON = "plainButton"; |
|
String TOGGLE_GROUP = "inToggleGroup"; |
|
String COMPACT_BUTTON = "compactButton"; |
|
String MENU_TOOL_BAR = "menuToolBar"; |
|
String MENU_ITEM_TOOL_BAR = "menuItemToolBar"; |
|
String POPUP_MENU_TOOL_BAR = "popupMenuToolBar"; |
|
String POPUP_MENU_DROPDOWN = "dropdownPopupMenu"; |
|
String TRANSPARENT_TEXT_FIELD = "transparentTextField"; |
|
String PURE_LIST = "pureList"; |
|
String PURE_TREE = "pureTree"; |
|
String PASTEL_BUTTON = "pastelButton"; |
|
|
|
|
|
/** |
|
* 添加组件的样式类,类似css,该方法会接在原样式后方 |
|
* <code> |
|
* FineClientProperties.appendStyle("primary small") |
|
* </code> |
|
* |
|
* @param it 组件 |
|
* @param styleClass 样式字符串,支持连续添加类,用空格 |
|
*/ |
|
static void appendStyle(JComponent it, String styleClass) { |
|
Object oriProperty = it.getClientProperty(FineClientProperties.STYLE_CLASS); |
|
if (oriProperty instanceof String && StringUtils.isNotBlank((String) oriProperty)) { |
|
styleClass = oriProperty + " " + styleClass; |
|
} |
|
it.putClientProperty(FineClientProperties.STYLE_CLASS, styleClass); |
|
} |
|
|
|
/** |
|
* 设置组件的样式类,类似css,该方法会替换原样式 |
|
* <code> |
|
* FineClientProperties.setStyle("primary small") |
|
* </code> |
|
* |
|
* @param jComponent 组件 |
|
* @param styleClass 样式字符串,支持连续添加类,用空格 |
|
*/ |
|
static void setStyle(JComponent jComponent, String styleClass) { |
|
jComponent.putClientProperty(FineClientProperties.STYLE_CLASS, styleClass); |
|
} |
|
|
|
/** |
|
* 样式组合 |
|
* |
|
* @param styleClasses 所有样式 |
|
* @return 样式列表 |
|
*/ |
|
static String joinStyle(String... styleClasses) { |
|
final StringBuilder sb = new StringBuilder(); |
|
for (final String style : styleClasses) { |
|
if (style == null) { |
|
continue; |
|
} |
|
if (sb.length() > 0) { |
|
sb.append(" "); |
|
} |
|
sb.append(style); |
|
} |
|
return sb.toString(); |
|
} |
|
|
|
/** |
|
* 包含样式 |
|
* |
|
* @param jComponent 组件 |
|
* @param styleClass 样式 |
|
* @return 是否包含指定的样式 |
|
*/ |
|
static boolean hasStyle(JComponent jComponent, String styleClass) { |
|
Object style = jComponent.getClientProperty(FineClientProperties.STYLE_CLASS); |
|
if (style instanceof String && StringUtils.isNotBlank((String) style)) { |
|
return ((String) style).contains(styleClass); |
|
} |
|
return false; |
|
} |
|
|
|
}
|
|
|