Browse Source

合代码冲突

research/11.0
neil 5 years ago
parent
commit
b3ab7ae773
  1. 30
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

30
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -66,7 +66,8 @@ import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.NotNull;
import com.fr.third.javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable;
import javax.swing.Icon;
import java.awt.Container;
@ -176,6 +177,29 @@ public class XCreatorUtils {
}
}
/**
* 对于继承的子组件来说可能并没有对应的 XCreator
* 这个时候就需要递归的找父类
*
* @param clazz 组件类
* @return 创建类
*/
@SuppressWarnings("unchecked")
@Nullable
private static Class<? extends XCreator> similarXCreatorClass(Class<? extends Widget> clazz) {
Class<?> target = clazz;
Class<? extends XCreator> xClazz = null;
//判断条件有两个
//1.还没找到对应的 xClazz
//2.一直到 终极父类-Widget 都找不到
while (xClazz == null && Widget.class.isAssignableFrom(target)) {
xClazz = searchXCreatorClass((Class<? extends Widget>) target);
target = target.getSuperclass();
}
return xClazz;
}
@SuppressWarnings("unchecked")
private static Class<? extends XCreator> searchXCreatorClass(Class<? extends Widget> clazz) {
@ -214,7 +238,7 @@ public class XCreatorUtils {
clazz = NullCreator.class;
} else {
widgetClass = widget.getClass();
clazz = XCreatorUtils.searchXCreatorClass(widgetClass);
clazz = XCreatorUtils.similarXCreatorClass(widgetClass);
if (clazz == null) {
FineLoggerFactory.getLogger().error(widget + "'s" + " xcreator doesn't exsit!");
clazz = NullCreator.class;
@ -286,7 +310,7 @@ public class XCreatorUtils {
* @param creator 组件
* @return 返回顶层容器
*/
public static XLayoutContainer getHotspotContainer(@NotNull XCreator creator) {
public static XLayoutContainer getHotspotContainer(@Nonnull XCreator creator) {
if (creator.isDedicateContainer()) {
return (XLayoutContainer) creator.getParent();
}

Loading…
Cancel
Save