|
|
|
package com.fr.design.mainframe.share;
|
|
|
|
|
|
|
|
import com.fr.design.DesignerEnvManager;
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache;
|
|
|
|
import com.fr.design.locale.impl.ShowOnlineWidgetMark;
|
|
|
|
import com.fr.design.mainframe.JTemplate;
|
|
|
|
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
|
|
|
|
import com.fr.form.share.constants.ComponentPath;
|
|
|
|
import com.fr.form.share.group.filter.ReuFilter;
|
|
|
|
import com.fr.design.DesignerCloudURLManager;
|
|
|
|
import com.fr.general.locale.LocaleCenter;
|
|
|
|
import com.fr.general.locale.LocaleMark;
|
|
|
|
import com.fr.workspace.WorkContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by kerry on 2021/10/27
|
|
|
|
*/
|
|
|
|
public class ComponentShareUtil {
|
|
|
|
private ComponentShareUtil() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断是否需要切换到在线组件库
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static boolean needSwitch2OnlineTab() {
|
|
|
|
return DesignerCloudURLManager.getInstance().isConnected() && !hasTouched() && isCurrentTplNewCreate() && isShowOnlineWidgetRepoPane();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isShowOnlineWidgetRepoPane() {
|
|
|
|
// 先读一下全局配置
|
|
|
|
if (!ComponentShareConfig.getInstance().isShowOnlineWidget()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
LocaleMark<Boolean> localeMark = LocaleCenter.getMark(ShowOnlineWidgetMark.class);
|
|
|
|
return localeMark.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isShowMiniShopWindow() {
|
|
|
|
return isShowOnlineWidgetRepoPane();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断是否可触达
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static boolean hasTouched() {
|
|
|
|
String sharePath = ComponentPath.SHARE_PATH.path();
|
|
|
|
String[] components = WorkContext.getWorkResource().list(sharePath, new ReuFilter());
|
|
|
|
return components != null && components.length > 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断当前模板是否是新建模板
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static boolean isCurrentTplNewCreate() {
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
|
|
|
|
return jTemplate.isNewCreateTpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断是否在需要展示组件库界面
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static boolean needShowEmbedFilterPane() {
|
|
|
|
return !ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter() && !hasTouched() && isCurrentTplNewCreate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean needShowComponentLib() {
|
|
|
|
return !ComponentReuseNotificationInfo.getInstance().isCompleteFirstShowComponentLib() && !hasTouched() && isCurrentTplNewCreate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断是否需要展示首次拖拽动效
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static boolean needShowFirstDragAnimate() {
|
|
|
|
return ComponentReuseNotificationInfo.getInstance().isFirstDrag();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 完成嵌入式筛选
|
|
|
|
*/
|
|
|
|
public static void completeEmbedFilter() {
|
|
|
|
boolean changed = false;
|
|
|
|
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
|
|
|
|
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (!ComponentReuseNotificationInfo.getInstance().isCompleteEmbedFilter()) {
|
|
|
|
ComponentReuseNotificationInfo.getInstance().setCompleteEmbedFilter(true);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
DesignerEnvManager.getEnvManager().saveXMLFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 记录组件库刷新
|
|
|
|
*/
|
|
|
|
public static void recordWidgetLibHasRefreshed() {
|
|
|
|
if (!ComponentReuseNotificationInfo.getInstance().isWidgetLibHasRefreshed()) {
|
|
|
|
ComponentReuseNotificationInfo.getInstance().setWidgetLibHasRefreshed(true);
|
|
|
|
DesignerEnvManager.getEnvManager().saveXMLFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|