5 changed files with 131 additions and 4 deletions
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.design.ui.compatible; |
||||||
|
|
||||||
|
import com.fr.design.jxbrowser.JxUIPane; |
||||||
|
import com.fr.design.ui.ModernUIPane; |
||||||
|
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback; |
||||||
|
import com.teamdev.jxbrowser.chromium.events.LoadListener; |
||||||
|
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; |
||||||
|
import com.teamdev.jxbrowser.event.Observer; |
||||||
|
|
||||||
|
/** |
||||||
|
* 封装jxbrwoser v6/v7的构建方式的差异 |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2021/6/13 |
||||||
|
* @see {@link JxUIPane} |
||||||
|
* @deprecated 6在下个版本弃用 |
||||||
|
*/ |
||||||
|
@Deprecated |
||||||
|
public interface BuilderDiff<T> { |
||||||
|
|
||||||
|
ModernUIPane.Builder<T> prepareForV6(ScriptContextListener contextListener); |
||||||
|
|
||||||
|
ModernUIPane.Builder<T> prepareForV6(LoadListener loadListener); |
||||||
|
|
||||||
|
ModernUIPane.Builder<T> prepareForV7(InjectJsCallback callback); |
||||||
|
|
||||||
|
ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package com.fr.design.ui.compatible; |
||||||
|
|
||||||
|
import com.fr.design.jxbrowser.JxUIPane; |
||||||
|
import com.fr.design.ui.ModernUIPane; |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据版本选择构造器 |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2021/6/13 |
||||||
|
* @see {@link JxUIPane} |
||||||
|
* @deprecated 6在下个版本弃用 |
||||||
|
*/ |
||||||
|
public class ModernUIPaneFactory { |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取一个 JxBrowser pane 的构造器 |
||||||
|
* |
||||||
|
* @param <T> 参数 |
||||||
|
* @return 构造器 |
||||||
|
*/ |
||||||
|
public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() { |
||||||
|
if (isV7()) { |
||||||
|
return new JxUIPane.Builder<>(); |
||||||
|
} else { |
||||||
|
return new ModernUIPane.Builder<>(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断 JxBrowser 版本是否在7或之上 |
||||||
|
* |
||||||
|
* @return 是否7或之上 |
||||||
|
*/ |
||||||
|
public static boolean isV7() { |
||||||
|
boolean hasJxBrowserV7 = true; |
||||||
|
try { |
||||||
|
Class.forName("com.teamdev.jxbrowser.net.Scheme"); |
||||||
|
} catch (ClassNotFoundException e) { |
||||||
|
hasJxBrowserV7 = false; |
||||||
|
} |
||||||
|
return hasJxBrowserV7; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue