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.
67 lines
2.2 KiB
67 lines
2.2 KiB
package com.fr.strongest; |
|
|
|
import com.finebi.cbb.utils.StringUtils; |
|
import com.fr.base.io.BaseBook; |
|
import com.fr.design.constants.DesignerLaunchStatus; |
|
import com.fr.design.mainframe.JForm; |
|
import com.fr.design.mainframe.JTemplate; |
|
import com.fr.design.mainframe.JTemplateEvent; |
|
import com.fr.design.mainframe.JWorkBook; |
|
import com.fr.event.Event; |
|
import com.fr.event.EventDispatcher; |
|
import com.fr.event.Listener; |
|
import com.fr.event.Null; |
|
import com.fr.module.ModuleContext; |
|
import com.fr.widgettheme.control.attr.WidgetDisplayEnhanceMarkAttr; |
|
|
|
/** |
|
* 控件属性增强监听器启动类 |
|
* |
|
* @author obo |
|
* @since 11.0 |
|
* Created on 2023/11/13 |
|
*/ |
|
public class WidgetThemeListenerStarter { |
|
private WidgetThemeListenerStarter(){} |
|
|
|
/** |
|
* 启动对模版控件主题显示的监听开关 |
|
*/ |
|
public static void start() { |
|
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { |
|
@Override |
|
public void on(Event event, Null param) { |
|
init(); |
|
} |
|
}); |
|
} |
|
|
|
private static void init() { |
|
Listener<JTemplate> attrListener = new Listener<JTemplate>() { |
|
@Override |
|
public void on(Event event, JTemplate temp) { |
|
dealWithJTemplate4Attr(temp); |
|
} |
|
}; |
|
if (ModuleContext.isDesignerStartup()) { |
|
EventDispatcher.listen(JTemplateEvent.BEFORE_TEMPLATE_INIT, attrListener); |
|
} |
|
} |
|
|
|
private static void dealWithJTemplate4Attr(JTemplate temp) { |
|
if (temp instanceof JWorkBook || temp instanceof JForm) { |
|
BaseBook workBook = (BaseBook) temp.getTarget(); |
|
if (isNeedAddAttr(temp, workBook)) { |
|
WidgetDisplayEnhanceMarkAttr attr = new WidgetDisplayEnhanceMarkAttr(); |
|
attr.setWidgetEnhance(false); |
|
workBook.addAttrMark(attr); |
|
} |
|
} |
|
} |
|
|
|
private static boolean isNeedAddAttr(JTemplate temp, BaseBook workBook) { |
|
// 模板为新建模板(temp.isNewCreateTpl没法用,此时还没赋值) |
|
return (StringUtils.isEmpty(workBook.getTemplateID()) || temp.isNewCreateTpl()) && |
|
workBook.getAttrMark(WidgetDisplayEnhanceMarkAttr.XML_TAG) == null; |
|
} |
|
}
|
|
|