Browse Source
* commit '603b881e05926a00f132b5200dbc8e8b8448f181': (76 commits) 无jira任务,修复打包 修改图标-标签-边框布局&修改行高列宽弹窗布局 fix: 调整规范问题 newui fix: 视觉修复 无jira任务 代码质量 REPORT-131077 【迭代】【FR血缘】服务器数据集新建 程序/内置数据集/存储过程/关联数据集,保存后再次为空消失 REPORT-133276 fbp设计器完全删除jxbrowser 6.x REPORT-133286 fbp设计器获取云中心网址为空 代码质量 REPORT-133286 fbp设计器获取云中心网址为空 无jira任务 子类方法添加注解 REPORT-133275 fbp设计器清理存在javafx webview替代页面 REPORT-132799 & REPORT-131838 & REPORT-132389 & REPORT-132382 & REPORT-132380 & REPORT-132375 & REPORT-132357 & REPORT-132231 & REPORT-132227【newUI】fix:国际化布局调整及Tab统一修复/fbp回归问题修复 REPORT-132799 & REPORT-131838 & REPORT-132389 & REPORT-132382 & REPORT-132380 & REPORT-132375 & REPORT-132357 & REPORT-132231 & REPORT-132227【newUI】fix:国际化布局调整及Tab统一修复/fbp回归问题修复 REPORT-133167 & REPORT-133157 fix:细节缩放问题修复 REPORT-133198 fix:List面板背景逻辑调整 模板解密对话框修改 REPORT-133037 fix:自动刷新面板修复&参数面板移动端显示效果优化 REPORT-132601 fix:图表标题面板问题修复 REPORT-132916 fix:仪表盘、气泡图漏翻新面板补充 REPORT-133106 fix:参数面板遮罩层修复 ...fbp/feature
Zongyu.Wang-王宗雨
3 months ago
275 changed files with 2164 additions and 4347 deletions
@ -1,42 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by vito on 2017/5/5. |
||||
*/ |
||||
public class LoginDialog extends UIDialog { |
||||
private static final Dimension DEFAULT_SHOP = new Dimension(401, 301); |
||||
|
||||
public LoginDialog(Frame frame, Component pane) { |
||||
super(frame); |
||||
init(pane); |
||||
} |
||||
|
||||
public LoginDialog(Dialog dialog, Component pane) { |
||||
super(dialog); |
||||
init(pane); |
||||
} |
||||
|
||||
private void init(Component pane) { |
||||
if (StableUtils.getMajorJavaVersion() >= 8) { |
||||
setUndecorated(true); |
||||
} |
||||
JPanel panel = (JPanel) getContentPane(); |
||||
panel.setLayout(new BorderLayout()); |
||||
add(pane, BorderLayout.CENTER); |
||||
setSize(DEFAULT_SHOP); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
// do nothing
|
||||
} |
||||
} |
@ -1,200 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.cloud.FanruanCloud; |
||||
import com.fanruan.config.bbs.FineBBSConfigProvider; |
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.extra.exe.PluginLoginExecutor; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.locale.impl.BbsRegisterMark; |
||||
import com.fr.design.locale.impl.BbsResetMark; |
||||
import com.fr.design.login.service.DesignerLoginClient; |
||||
import com.fr.design.login.service.DesignerLoginResult; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.general.locale.LocaleCenter; |
||||
import com.fr.general.locale.LocaleMark; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import javafx.concurrent.Task; |
||||
import javafx.scene.web.WebEngine; |
||||
import netscape.javascript.JSObject; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.net.URI; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* @author vito |
||||
*/ |
||||
public class LoginWebBridge { |
||||
|
||||
//最低消息的条数
|
||||
private static final int MIN_MESSAGE_COUNT = 0; |
||||
//网络连接失败
|
||||
private static final String NET_FAILED = "-4"; |
||||
//用户名,密码为空
|
||||
private static final String LOGIN_INFO_EMPTY = "-5"; |
||||
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); |
||||
private static LoginWebBridge helper; |
||||
//消息条数
|
||||
private int messageCount; |
||||
private UIDialog uiDialog; |
||||
private UIDialog qqDialog; |
||||
private UILabel uiLabel; |
||||
private WebEngine webEngine; |
||||
|
||||
private LoginWebBridge() { |
||||
} |
||||
|
||||
public static LoginWebBridge getHelper() { |
||||
if (helper != null) { |
||||
return helper; |
||||
} |
||||
synchronized (LoginWebBridge.class) { |
||||
if (helper == null) { |
||||
helper = new LoginWebBridge(); |
||||
} |
||||
return helper; |
||||
} |
||||
} |
||||
|
||||
public static LoginWebBridge getHelper(WebEngine webEngine) { |
||||
getHelper(); |
||||
helper.setWebEngine(webEngine); |
||||
return helper; |
||||
} |
||||
|
||||
public void setWebEngine(WebEngine webEngine) { |
||||
this.webEngine = webEngine; |
||||
} |
||||
|
||||
public int getMessageCount() { |
||||
return messageCount; |
||||
} |
||||
|
||||
/** |
||||
* 设置获取的消息长度,并设置显示 |
||||
* |
||||
* @param count |
||||
*/ |
||||
public void setMessageCount(int count) { |
||||
if (count == MIN_MESSAGE_COUNT) { |
||||
Carina.config(FineBBSConfigProvider.class).setBbsUsername(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()); |
||||
return; |
||||
} |
||||
this.messageCount = count; |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()) |
||||
.append("(").append(this.messageCount) |
||||
.append(")").append(StringUtils.BLANK); |
||||
Carina.config(FineBBSConfigProvider.class).setBbsUsername(sb.toString()); |
||||
} |
||||
|
||||
public void setQQDialog(UIDialog qqDialog) { |
||||
closeQQWindow(); |
||||
this.qqDialog = qqDialog; |
||||
} |
||||
|
||||
public void setDialogHandle(UIDialog uiDialog) { |
||||
closeWindow(); |
||||
this.uiDialog = uiDialog; |
||||
} |
||||
|
||||
public void setUILabel(UILabel uiLabel) { |
||||
this.uiLabel = uiLabel; |
||||
} |
||||
|
||||
/** |
||||
* 测试论坛网络连接 |
||||
* |
||||
* @return |
||||
*/ |
||||
private boolean testConnection() { |
||||
HttpClient client = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("bbs.test")); |
||||
return client.isServerAlive(); |
||||
} |
||||
|
||||
/** |
||||
* 注册页面 |
||||
*/ |
||||
public void registerHref() { |
||||
try { |
||||
LocaleMark<String> registerMark = LocaleCenter.getMark(BbsRegisterMark.class); |
||||
Desktop.getDesktop().browse(new URI(registerMark.getValue())); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 忘记密码 |
||||
*/ |
||||
public void forgetHref() { |
||||
try { |
||||
LocaleMark<String> resetMark = LocaleCenter.getMark(BbsResetMark.class); |
||||
Desktop.getDesktop().browse(new URI(resetMark.getValue())); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设计器端的用户登录 |
||||
* |
||||
* @param username 用户名 |
||||
* @param password 密码 |
||||
* @return 登录信息标志 |
||||
*/ |
||||
public void defaultLogin(String username, String password, final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password)); |
||||
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("bbsDefaultLogin")); |
||||
es.submit(task); |
||||
es.shutdown(); |
||||
} |
||||
|
||||
/** |
||||
* 登录操作 |
||||
* |
||||
* @param userInfo 登录信息 |
||||
* @param password 密码 |
||||
* @return 登录信息标志 |
||||
*/ |
||||
public String login(String userInfo, String password) { |
||||
DesignerLoginClient client = new DesignerLoginClient(); |
||||
DesignerLoginResult result = client.login(userInfo, password); |
||||
int uid = result.getUid(); |
||||
if (uid > 0) { |
||||
closeWindow(); |
||||
} |
||||
return String.valueOf(uid); |
||||
} |
||||
|
||||
/** |
||||
* 关闭窗口 |
||||
*/ |
||||
public void closeWindow() { |
||||
if (uiDialog != null) { |
||||
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
||||
uiDialog.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 关闭QQ授权窗口 |
||||
*/ |
||||
public void closeQQWindow() { |
||||
if (qqDialog != null) { |
||||
qqDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
||||
qqDialog.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { |
||||
// do nothing
|
||||
} |
||||
} |
@ -1,54 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import javafx.application.Platform; |
||||
import javafx.embed.swing.JFXPanel; |
||||
import javafx.event.EventHandler; |
||||
import javafx.scene.Scene; |
||||
import javafx.scene.layout.BorderPane; |
||||
import javafx.scene.web.WebEngine; |
||||
import javafx.scene.web.WebEvent; |
||||
import javafx.scene.web.WebView; |
||||
import netscape.javascript.JSObject; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by zhaohehe on 16/7/26. |
||||
*/ |
||||
public class LoginWebPane extends JFXPanel { |
||||
|
||||
public LoginWebPane(final String installHome) { |
||||
Platform.setImplicitExit(false); |
||||
Platform.runLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
BorderPane root = new BorderPane(); |
||||
Scene scene = new Scene(root); |
||||
LoginWebPane.this.setScene(scene); |
||||
WebView webView = new WebView(); |
||||
WebEngine webEngine = webView.getEngine(); |
||||
webEngine.load("file:///" + installHome + "/scripts/login.html"); |
||||
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { |
||||
@Override |
||||
public void handle(WebEvent<String> event) { |
||||
showAlert(event.getData()); |
||||
} |
||||
}); |
||||
JSObject obj = (JSObject) webEngine.executeScript("window"); |
||||
obj.setMember("LoginHelper", LoginWebBridge.getHelper(webEngine)); |
||||
webView.setContextMenuEnabled(false);//屏蔽右键
|
||||
root.setCenter(webView); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void showAlert(final String message) { |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
FineJOptionPane.showMessageDialog(LoginWebPane.this, message); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,601 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fanruan.carina.Carina; |
||||
import com.fanruan.cloud.FanruanCloud; |
||||
import com.fanruan.config.bbs.FineBBSConfigProvider; |
||||
import com.fr.config.MarketConfig; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.RestartHelper; |
||||
import com.fr.design.bridge.exec.JSCallback; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.extra.exe.GetInstalledPluginsExecutor; |
||||
import com.fr.design.extra.exe.GetPluginCategoriesExecutor; |
||||
import com.fr.design.extra.exe.GetPluginFromStoreExecutor; |
||||
import com.fr.design.extra.exe.GetPluginPrefixExecutor; |
||||
import com.fr.design.extra.exe.PluginLoginExecutor; |
||||
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; |
||||
import com.fr.design.extra.exe.SearchOnlineExecutor; |
||||
import com.fr.design.locale.impl.BbsRegisterMark; |
||||
import com.fr.design.locale.impl.BbsResetMark; |
||||
import com.fr.design.locale.impl.BbsSpaceMark; |
||||
import com.fr.design.login.DesignerLoginSource; |
||||
import com.fr.design.plugin.DesignerPluginContext; |
||||
import com.fr.design.utils.concurrent.ThreadFactoryBuilder; |
||||
import com.fr.general.locale.LocaleCenter; |
||||
import com.fr.general.locale.LocaleMark; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import javafx.concurrent.Task; |
||||
import javafx.scene.web.WebEngine; |
||||
import javafx.stage.FileChooser; |
||||
import javafx.stage.Stage; |
||||
import netscape.javascript.JSObject; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.net.URI; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.LinkedBlockingQueue; |
||||
import java.util.concurrent.ThreadPoolExecutor; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* 开放给Web组件的接口,用于安装,卸载,更新以及更改插件可用状态 |
||||
*/ |
||||
public class PluginWebBridge { |
||||
private static final String THREAD_NAME_TEMPLATE = "pluginbridge-thread-%s"; |
||||
private static final String ACTION = "action"; |
||||
private static final String KEYWORD = "keyword"; |
||||
private static final String PLUGIN_INFO = "pluginInfo"; |
||||
private static final int COREPOOLSIZE = 3; |
||||
private static final int MAXPOOLSIZE = 5; |
||||
|
||||
private static PluginWebBridge helper; |
||||
|
||||
private UIDialog uiDialog; |
||||
private ACTIONS actions; |
||||
|
||||
private Map<String, Object> config; |
||||
private WebEngine webEngine; |
||||
|
||||
private ExecutorService threadPoolExecutor = new ThreadPoolExecutor(COREPOOLSIZE, MAXPOOLSIZE, |
||||
0L, TimeUnit.MILLISECONDS, |
||||
new LinkedBlockingQueue<Runnable>(COREPOOLSIZE), |
||||
new ThreadFactoryBuilder().setNameFormat(THREAD_NAME_TEMPLATE).build()); |
||||
|
||||
private PluginWebBridge() { |
||||
} |
||||
|
||||
public static PluginWebBridge getHelper() { |
||||
if (helper != null) { |
||||
return helper; |
||||
} |
||||
synchronized (PluginWebBridge.class) { |
||||
if (helper == null) { |
||||
helper = new PluginWebBridge(); |
||||
} |
||||
return helper; |
||||
} |
||||
} |
||||
|
||||
public static PluginWebBridge getHelper(WebEngine webEngine) { |
||||
getHelper(); |
||||
helper.setEngine(webEngine); |
||||
return helper; |
||||
} |
||||
|
||||
/** |
||||
* 获取打开动作配置 |
||||
* |
||||
* @return 配置信息 |
||||
*/ |
||||
public String getRunConfig() { |
||||
if (actions != null) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
try { |
||||
jsonObject.put(ACTION, actions.getContext()); |
||||
Set<String> keySet = config.keySet(); |
||||
for (String key : keySet) { |
||||
jsonObject.put(key, config.get(key).toString()); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return jsonObject.toString(); |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
/** |
||||
* 配置打开动作 |
||||
* |
||||
* @param action 动作 |
||||
* @param config 参数 |
||||
*/ |
||||
public void setRunConfig(ACTIONS action, Map<String, Object> config) { |
||||
this.actions = action; |
||||
this.config = config; |
||||
} |
||||
|
||||
/** |
||||
* 清楚打开动作 |
||||
*/ |
||||
public void clearRunConfig() { |
||||
this.actions = null; |
||||
this.config = null; |
||||
} |
||||
|
||||
/** |
||||
* 打开时搜索 |
||||
* |
||||
* @param keyword 关键词 |
||||
*/ |
||||
|
||||
public void openWithSearch(String keyword) { |
||||
HashMap<String, Object> map = new HashMap<String, Object>(2); |
||||
map.put(KEYWORD, keyword); |
||||
setRunConfig(ACTIONS.SEARCH, map); |
||||
} |
||||
|
||||
/** |
||||
* 根据插件信息跳转到应用中心 |
||||
* |
||||
* @param keyword |
||||
* @param pluginInfo |
||||
*/ |
||||
public void showResultInStore(String keyword, String pluginInfo) { |
||||
HashMap<String, Object> map = new HashMap<>(); |
||||
map.put(KEYWORD, keyword); |
||||
map.put(PLUGIN_INFO, pluginInfo); |
||||
setRunConfig(ACTIONS.SHOW_RESULT, map); |
||||
} |
||||
|
||||
public void setEngine(WebEngine webEngine) { |
||||
this.webEngine = webEngine; |
||||
} |
||||
|
||||
public void setDialogHandle(UIDialog uiDialog) { |
||||
closeWindow(); |
||||
this.uiDialog = uiDialog; |
||||
} |
||||
|
||||
/** |
||||
* 从插件服务器上安装插件 |
||||
* |
||||
* @param pluginInfo 插件的ID |
||||
* @param callback 回调函数 |
||||
*/ |
||||
public void installPluginOnline(final String pluginInfo, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); |
||||
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 从磁盘上选择插件安装包进行安装 |
||||
* |
||||
* @param filePath 插件包的路径 |
||||
*/ |
||||
public void installPluginFromDisk(final String filePath, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
File file = new File(filePath); |
||||
PluginOperateUtils.installPluginFromDisk(file, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 卸载当前选中的插件 |
||||
* |
||||
* @param pluginInfo 插件信息 |
||||
*/ |
||||
public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 从插件服务器上更新选中的插件 |
||||
* |
||||
* @param pluginIDs 插件集合 |
||||
*/ |
||||
public void updatePluginOnline(JSObject pluginIDs, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
String[] pluginInfos = jsObjectToStringArray(pluginIDs); |
||||
List<PluginMarker> pluginMarkerList = new ArrayList<PluginMarker>(); |
||||
for (int i = 0; i < pluginInfos.length; i++) { |
||||
pluginMarkerList.add(PluginUtils.createPluginMarker(pluginInfos[i])); |
||||
} |
||||
PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 从磁盘上选择插件安装包进行插件升级 |
||||
* |
||||
* @param filePath 插件包的路径 |
||||
*/ |
||||
public void updatePluginFromDisk(String filePath, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
File file = new File(filePath); |
||||
PluginOperateUtils.updatePluginFromDisk(file, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 修改选中的插件的活跃状态 |
||||
* |
||||
* @param pluginID 插件ID |
||||
*/ |
||||
public void setPluginActive(String pluginID, final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
PluginOperateUtils.setPluginActive(pluginID, jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 已安装插件检查更新 |
||||
*/ |
||||
public void readUpdateOnline(final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @return 选择的文件的路径 |
||||
*/ |
||||
public String showFileChooser() { |
||||
return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @param des 过滤文件描述 |
||||
* @param filter 文件的后缀 |
||||
* @return 选择的文件的路径 |
||||
* 这里换用JFileChooser会卡死,不知道为什么 |
||||
*/ |
||||
public String showFileChooserWithFilter(String des, String filter) { |
||||
FileChooser fileChooser = new FileChooser(); |
||||
|
||||
if (StringUtils.isNotEmpty(filter)) { |
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(des, filter)); |
||||
} |
||||
|
||||
File selectedFile = fileChooser.showOpenDialog(new Stage()); |
||||
if (selectedFile == null) { |
||||
return null; |
||||
} |
||||
return selectedFile.getAbsolutePath(); |
||||
} |
||||
|
||||
/** |
||||
* 选择文件对话框 |
||||
* |
||||
* @param des 过滤文件描述 |
||||
* @param args 文件的后缀 |
||||
* @return 选择的文件的路径 |
||||
*/ |
||||
public String showFileChooserWithFilters(String des, JSObject args) { |
||||
FileChooser fileChooser = new FileChooser(); |
||||
String[] filters = jsObjectToStringArray(args); |
||||
if (ArrayUtils.isNotEmpty(filters)) { |
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(des, filters)); |
||||
} |
||||
|
||||
File selectedFile = fileChooser.showOpenDialog(new Stage()); |
||||
if (selectedFile == null) { |
||||
return null; |
||||
} |
||||
return selectedFile.getAbsolutePath(); |
||||
} |
||||
|
||||
/** |
||||
* 获取已经安装的插件的数组 |
||||
* |
||||
* @return 已安装的插件组成的数组 |
||||
*/ |
||||
public void getInstalledPlugins(final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new GetInstalledPluginsExecutor()); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
private String[] jsObjectToStringArray(JSObject obj) { |
||||
if (obj == null) { |
||||
return ArrayUtils.EMPTY_STRING_ARRAY; |
||||
} |
||||
int len = (int) obj.getMember("length"); |
||||
List<String> list = new ArrayList<>(); |
||||
for (int i = 0; i < len; i++) { |
||||
list.add(obj.getSlot(i).toString()); |
||||
} |
||||
return list.toArray(new String[len]); |
||||
} |
||||
|
||||
/** |
||||
* 搜索在线插件 |
||||
* |
||||
* @param keyword 关键字 |
||||
*/ |
||||
public void searchPlugin(String keyword, final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new SearchOnlineExecutor(keyword)); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 根据条件获取在线插件的 |
||||
* |
||||
* @param category 分类 |
||||
* @param seller 卖家性质 |
||||
* @param fee 收费类型 |
||||
* @param callback 回调函数 |
||||
*/ |
||||
public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee, "")); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 根据条件获取在线插件 |
||||
* |
||||
* @param info 插件信息 |
||||
* @param callback 回调函数 |
||||
*/ |
||||
public void getPluginFromStoreNew(String info, final JSObject callback) { |
||||
try { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info))); |
||||
threadPoolExecutor.submit(task); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
|
||||
public void getPluginPrefix(final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginPrefixExecutor()); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 在线获取插件分类 |
||||
* |
||||
* @param callback 回调函数 |
||||
*/ |
||||
public void getPluginCategories(final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 展示一个重启的对话框(少用,莫名其妙会有bug) |
||||
* |
||||
* @param message 展示的消息 |
||||
*/ |
||||
public void showRestartMessage(String message) { |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
message, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), |
||||
JOptionPane.YES_NO_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer_Later")}, |
||||
null |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
RestartHelper.restart(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 关闭窗口 |
||||
*/ |
||||
public void closeWindow() { |
||||
if (uiDialog != null) { |
||||
uiDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
||||
uiDialog.setVisible(false); |
||||
} |
||||
if (uiDialog == DesignerPluginContext.getPluginDialog()) { |
||||
DesignerPluginContext.setPluginDialog(null); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 窗口是否无装饰(判断是否使用系统标题栏) |
||||
*/ |
||||
public boolean isCustomTitleBar() { |
||||
if (uiDialog != null) { |
||||
return uiDialog.isUndecorated(); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/** |
||||
* 获取系统登录的用户名 |
||||
* |
||||
* @param callback |
||||
*/ |
||||
public String getLoginInfo(final JSObject callback) { |
||||
registerLoginInfo(callback); |
||||
return DesignerEnvManager.getEnvManager().getDesignerLoginUsername(); |
||||
} |
||||
|
||||
/** |
||||
* 系统登录注册 |
||||
* |
||||
* @param callback |
||||
*/ |
||||
public void registerLoginInfo(final JSObject callback) { |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
PluginOperateUtils.getLoginInfo(jsCallback); |
||||
} |
||||
|
||||
/** |
||||
* 打开论坛消息界面 |
||||
*/ |
||||
public void getPriviteMessage() { |
||||
try { |
||||
LocaleMark<String> spaceMark = LocaleCenter.getMark(BbsSpaceMark.class); |
||||
Desktop.getDesktop().browse(new URI(spaceMark.getValue())); |
||||
} catch (Exception exp) { |
||||
FineLoggerFactory.getLogger().info(exp.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 打开登录页面 |
||||
*/ |
||||
public void loginContent() { |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
UserLoginContext.fireLoginContextListener(DesignerLoginSource.NORMAL); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 在本地浏览器里打开url |
||||
* tips:重载的时候,需要给js调用的方法需要放在前面,否则可能不会被调用(此乃坑) |
||||
* 所以最好的是不要重载在js可以访问的接口文件中 |
||||
* |
||||
* @param url 要打开的地址 |
||||
*/ |
||||
public void openShopUrlAtWebBrowser(String url) { |
||||
openUrlAtLocalWebBrowser(webEngine, url); |
||||
} |
||||
|
||||
/** |
||||
* 在本地浏览器里打开url |
||||
* |
||||
* @param eng web引擎 |
||||
* @param url 要打开的地址 |
||||
*/ |
||||
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { |
||||
if (Desktop.isDesktopSupported()) { |
||||
try { |
||||
//创建一个URI实例,注意不是URL
|
||||
URI uri = URI.create(url); |
||||
//获取当前系统桌面扩展
|
||||
Desktop desktop = Desktop.getDesktop(); |
||||
//判断系统桌面是否支持要执行的功能
|
||||
if (desktop.isSupported(Desktop.Action.BROWSE)) { |
||||
//获取系统默认浏览器打开链接
|
||||
desktop.browse(uri); |
||||
} |
||||
} catch (NullPointerException e) { |
||||
//此为uri为空时抛出异常
|
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} catch (IOException e) { |
||||
//此为无法获取系统默认浏览器
|
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 注册页面 |
||||
*/ |
||||
public void registerHref() { |
||||
try { |
||||
LocaleMark<String> registerMark = LocaleCenter.getMark(BbsRegisterMark.class); |
||||
Desktop.getDesktop().browse(new URI(registerMark.getValue())); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
|
||||
/*-------------------------------登录部分的处理----------------------------------*/ |
||||
|
||||
/** |
||||
* 忘记密码 |
||||
*/ |
||||
public void forgetHref() { |
||||
try { |
||||
LocaleMark<String> resetMark = LocaleCenter.getMark(BbsResetMark.class); |
||||
Desktop.getDesktop().browse(new URI(resetMark.getValue())); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().info(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设计器端的用户登录 |
||||
* |
||||
* @param username 用户名 |
||||
* @param password 密码 |
||||
* @return 登录信息标志 |
||||
*/ |
||||
public void defaultLogin(String username, String password, final JSObject callback) { |
||||
Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password)); |
||||
threadPoolExecutor.submit(task); |
||||
} |
||||
|
||||
/** |
||||
* 通过QQ登录后通知登录 |
||||
*/ |
||||
public void ucsynLogin(long uid, String username, String password, final JSONObject callback) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 清除用户信息 |
||||
*/ |
||||
public void clearUserInfo() { |
||||
Carina.config(FineBBSConfigProvider.class).setBbsUsername(StringUtils.EMPTY); |
||||
} |
||||
|
||||
public void getPackInfo(final JSObject callback){ |
||||
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); |
||||
jsCallback.execute(StringUtils.EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* 初始化设计器部分 |
||||
*/ |
||||
public void initExtraDiff(final JSObject callback) { |
||||
//todo 初始化设计器其他部分
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 国际化(用来做兼容,暂时不删) |
||||
*/ |
||||
public String parseI18(final String key) { |
||||
return com.fr.design.i18n.Toolkit.i18nText(key); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 是否是在设计器中操作 |
||||
*/ |
||||
public boolean isDesigner() { |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 动作枚举 |
||||
*/ |
||||
public enum ACTIONS { |
||||
SEARCH("search"), SHOW_RESULT("showResult"); |
||||
private String context; |
||||
|
||||
ACTIONS(String context) { |
||||
this.context = context; |
||||
} |
||||
|
||||
public String getContext() { |
||||
return context; |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,112 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.EncodeConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import javafx.application.Platform; |
||||
import javafx.embed.swing.JFXPanel; |
||||
import javafx.event.EventHandler; |
||||
import javafx.scene.Scene; |
||||
import javafx.scene.layout.BorderPane; |
||||
import javafx.scene.web.WebEngine; |
||||
import javafx.scene.web.WebEvent; |
||||
import javafx.scene.web.WebView; |
||||
import netscape.javascript.JSObject; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingUtilities; |
||||
import java.io.BufferedReader; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.io.InputStreamReader; |
||||
import java.net.URLEncoder; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class PluginWebPane extends JFXPanel { |
||||
private static final String RESOURCE_URL = "resourceURL"; |
||||
private static final String LANGUAGE = "language"; |
||||
private static final String URL_PLUS = "+"; |
||||
private static final String URL_SPACING = "%20"; |
||||
private static final String URL_PREFIX = "file:///"; |
||||
private WebEngine webEngine; |
||||
|
||||
public PluginWebPane(final String installHome, final String mainJs) { |
||||
Platform.setImplicitExit(false); |
||||
Platform.runLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
BorderPane root = new BorderPane(); |
||||
Scene scene = new Scene(root); |
||||
PluginWebPane.this.setScene(scene); |
||||
WebView webView = new WebView(); |
||||
webEngine = webView.getEngine(); |
||||
try{ |
||||
String htmlString = getRenderedHtml(installHome, mainJs); |
||||
webEngine.loadContent(htmlString); |
||||
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { |
||||
@Override |
||||
public void handle(WebEvent<String> event) { |
||||
showAlert(event.getData()); |
||||
} |
||||
}); |
||||
JSObject obj = (JSObject) webEngine.executeScript("window"); |
||||
obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine)); |
||||
webView.setContextMenuEnabled(false);//屏蔽右键
|
||||
root.setCenter(webView); |
||||
}catch (Exception e){ |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
}); |
||||
} |
||||
|
||||
private String getRenderedHtml(String installHome, String mainJs) throws IOException { |
||||
InputStream inp = IOUtils.readResource(StableUtils.pathJoin(installHome, mainJs)); |
||||
if (inp == null) { |
||||
throw new IOException("Not found template: " + mainJs); |
||||
} |
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inp, StableUtils.RESOURCE_ENCODER)); |
||||
BufferedReader read = new BufferedReader(reader); |
||||
StringBuffer sb = new StringBuffer(); |
||||
String line; |
||||
Map<String, Object> map4Tpl = new HashMap<String, Object>(); |
||||
//URL中关于空格的编码与空格所在位置相关:空格被编码成+的情况只能在查询字符串部分出现,而被编码成%20则可以出现在路径和查询字符串中
|
||||
//URLEncoder会将空格转成+,这边需要+转成%20
|
||||
map4Tpl.put(RESOURCE_URL, URL_PREFIX + URLEncoder.encode(installHome, EncodeConstants.ENCODING_UTF_8).replace(URL_PLUS, URL_SPACING)); |
||||
map4Tpl.put(LANGUAGE, GeneralContext.getLocale().toString()); |
||||
while ((line = read.readLine()) != null) { |
||||
if (sb.length() > 0) { |
||||
sb.append('\n'); |
||||
} |
||||
sb.append(line); |
||||
} |
||||
String htmlString = StringUtils.EMPTY; |
||||
try{ |
||||
htmlString = TemplateUtils.renderParameter4Tpl(sb.toString(), map4Tpl); |
||||
}catch (Exception e){ |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
reader.close(); |
||||
inp.close(); |
||||
return htmlString; |
||||
} |
||||
|
||||
private void showAlert(final String message) { |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
FineJOptionPane.showMessageDialog(PluginWebPane.this, message); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,32 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by zhaohehe on 16/7/28. |
||||
*/ |
||||
public class QQLoginDialog extends UIDialog { |
||||
private static final Dimension DEFAULT_SHOP = new Dimension(700, 500); |
||||
|
||||
public QQLoginDialog(Frame frame, Component pane) { |
||||
super(frame); |
||||
setUndecorated(true); |
||||
JPanel panel = (JPanel) getContentPane(); |
||||
panel.setLayout(new BorderLayout()); |
||||
add(pane, BorderLayout.CENTER); |
||||
setSize(DEFAULT_SHOP); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager")); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
// do nothing
|
||||
} |
||||
|
||||
} |
@ -1,46 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.jdk.JdkVersion; |
||||
import com.fr.design.plugin.DesignerPluginContext; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by vito on 16/4/18. |
||||
*/ |
||||
public class ShopDialog extends UIDialog { |
||||
|
||||
public ShopDialog(Frame frame, BasicPane pane) { |
||||
super(frame); |
||||
if (StableUtils.getMajorJavaVersion() >= 8) { |
||||
setUndecorated(true); |
||||
} |
||||
JPanel panel = (JPanel) getContentPane(); |
||||
panel.setLayout(new BorderLayout()); |
||||
add(pane, BorderLayout.CENTER); |
||||
setSize(createDefaultDimension()); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
DesignerPluginContext.setPluginDialog(this); |
||||
} |
||||
|
||||
private Dimension createDefaultDimension() { |
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
||||
// jdk11 分辨率较低 缩放较大时 屏幕高度小于或接近设定的高度 需要调整下
|
||||
if (JdkVersion.GE_9.support() && screenSize.height - 700 < 50) { |
||||
return new Dimension(900, screenSize.height - 100); |
||||
} else { |
||||
return new Dimension(900, 700); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
// do nothing
|
||||
} |
||||
} |
@ -1,31 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
|
||||
|
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-09 |
||||
* @since 8.0 |
||||
* 应用中心的构建采用JavaScript代码来动态实现,但是不总是依赖于服务器端的HTML |
||||
* 采用JDK提供的JavaScript引擎,实际是用JavaScript语法实现Java端的功能,并通过JavaScript引擎动态调用 |
||||
* JavaScript放在安装目录下的scripts/store目录下,检测到新版本的时候,可以通过更新这个目录下的文件实现热更新 |
||||
* 不直接嵌入WebView组件的原因是什么呢? |
||||
* 因为如果直接嵌入WebView,和设计器的交互就需要预先设定好,这样灵活性会差很多,而如果使用JavaScript引擎, |
||||
* 就可以直接在JavaScript中和WebView组件做交互,而同时JavaScript中可以调用任何的设计器API. |
||||
*/ |
||||
public class ShopManagerPane extends BasicPane { |
||||
|
||||
public ShopManagerPane(Component webPane) { |
||||
setLayout(new BorderLayout()); |
||||
add(webPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager"); |
||||
} |
||||
} |
@ -1,36 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import javafx.embed.swing.JFXPanel; |
||||
|
||||
/** |
||||
* Created by vito on 2016/9/28. |
||||
*/ |
||||
public abstract class ShopPaneConfig { |
||||
private String mainJS; |
||||
private String scriptsId; |
||||
private JFXPanel webPane; |
||||
|
||||
public ShopPaneConfig() { |
||||
this.mainJS = setMainJS(); |
||||
this.scriptsId = setScriptsId(); |
||||
this.webPane = setWebPane(); |
||||
} |
||||
|
||||
abstract String setMainJS(); |
||||
|
||||
abstract String setScriptsId(); |
||||
|
||||
abstract JFXPanel setWebPane(); |
||||
|
||||
public String getMainJS() { |
||||
return mainJS; |
||||
} |
||||
|
||||
public String getScriptsId() { |
||||
return scriptsId; |
||||
} |
||||
|
||||
public JFXPanel getWebPane() { |
||||
return webPane; |
||||
} |
||||
} |
@ -1,307 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.gui.frpane.UITabbedPane; |
||||
import com.fr.design.login.utils.DesignerLoginUtils; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.CommonIOUtils; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.http.HttpToolbox; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.PluginStoreConfig; |
||||
import com.fr.plugin.PluginStoreConstants; |
||||
import com.fr.stable.CommonUtils; |
||||
import com.fr.stable.EnvChangedListener; |
||||
import com.fanruan.product.ProductConstants; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingWorker; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dialog; |
||||
import java.awt.Frame; |
||||
import java.awt.Window; |
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.lang.reflect.Constructor; |
||||
import java.util.concurrent.ExecutionException; |
||||
|
||||
/** |
||||
* 在合适的 jre 环境下创建带有 WebView 的窗口 |
||||
* |
||||
* @author vito |
||||
* @date 2016/9/28 |
||||
*/ |
||||
public class WebViewDlgHelper { |
||||
private static final String LATEST = "latest"; |
||||
private static final String SHOP_SCRIPTS = "shop_scripts"; |
||||
private static final int VERSION_8 = 8; |
||||
private static String installHome = PluginStoreConstants.getLocalInstallHome(); |
||||
private static final String MAIN_JS_PATH = "/scripts/plugin.html"; |
||||
|
||||
static { |
||||
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
||||
@Override |
||||
public void envChanged() { |
||||
installHome = PluginStoreConstants.getLocalInstallHome(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void createPluginDialog() { |
||||
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
||||
String mainJsPath = StableUtils.pathJoin(installHome, MAIN_JS_PATH); |
||||
File file = new File(mainJsPath); |
||||
if (!file.exists()) { |
||||
int rv = FineJOptionPane.showConfirmDialog( |
||||
null, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
return; |
||||
} |
||||
// 检测更新前先刷新一下版本号
|
||||
PluginStoreConstants.refreshProps(); |
||||
|
||||
String jarVersion = PluginStoreConfig.getInstance().getEnvVersion(); |
||||
if (ComparatorUtils.equals(jarVersion, ProductConstants.VERSION)) { |
||||
updateShopScripts(SHOP_SCRIPTS); |
||||
showPluginDlg(); |
||||
} else { |
||||
int rv = FineJOptionPane.showConfirmDialog( |
||||
null, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install_Version"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(SHOP_SCRIPTS); |
||||
deleteExtraFile(StableUtils.pathJoin(installHome, "plugin.html")); |
||||
} |
||||
} |
||||
|
||||
} else { |
||||
BasicPane traditionalStorePane = new BasicPane() { |
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Manager"); |
||||
} |
||||
}; |
||||
traditionalStorePane.setLayout(new BorderLayout()); |
||||
traditionalStorePane.add(initTraditionalStore(), BorderLayout.CENTER); |
||||
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), traditionalStorePane); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检查script文件夹中的plugin.html文件 |
||||
*/ |
||||
public static void checkAndCopyMainFile(String indexPath, String mainJsPath) { |
||||
File file = new File(indexPath); |
||||
if (!file.exists()) { |
||||
copyMainFile(mainJsPath); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 將script文件夹中的plugin.html文件复制到webreport下 |
||||
*/ |
||||
private static void copyMainFile(String mainJsPath) { |
||||
try { |
||||
CommonIOUtils.copy(new File(mainJsPath), new File(installHome)); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除9.0工程下无用的plugin.html文件 |
||||
* |
||||
* @param filePath 待删除文件路径 |
||||
*/ |
||||
private static void deleteExtraFile(String filePath) { |
||||
CommonIOUtils.deleteFile(new File(filePath)); |
||||
} |
||||
|
||||
/** |
||||
* 以关键词打开设计器商店 |
||||
* |
||||
* @param keyword 关键词 |
||||
*/ |
||||
public static void createPluginDialog(String keyword) { |
||||
PluginWebBridge.getHelper().openWithSearch(keyword); |
||||
createPluginDialog(); |
||||
} |
||||
|
||||
/** |
||||
* 以关键词打开设计器商店显示搜索结果 |
||||
* |
||||
* @param keyword |
||||
* @param data |
||||
*/ |
||||
@Deprecated |
||||
public static void showPluginInStore(String keyword, String data) { |
||||
PluginWebBridge.getHelper().showResultInStore(keyword, data); |
||||
createPluginDialog(); |
||||
} |
||||
|
||||
public static void createLoginDialog() { |
||||
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
||||
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
||||
if (!file.exists()) { |
||||
confirmDownLoadShopJS(); |
||||
} else { |
||||
showLoginDlg(DesignerContext.getDesignerFrame()); |
||||
updateShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
public static void createLoginDialog(Window parent) { |
||||
if (StableUtils.getMajorJavaVersion() >= VERSION_8) { |
||||
File file = new File(StableUtils.pathJoin(installHome, "scripts")); |
||||
if (!file.exists()) { |
||||
confirmDownLoadShopJS(); |
||||
} else { |
||||
showLoginDlg(parent); |
||||
updateShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void confirmDownLoadShopJS() { |
||||
int rv = FineJOptionPane.showConfirmDialog( |
||||
null, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(SHOP_SCRIPTS); |
||||
} |
||||
} |
||||
|
||||
private static void showPluginDlg() { |
||||
try { |
||||
Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane"); |
||||
Constructor constructor = clazz.getConstructor(String.class, String.class); |
||||
Component webPane = (Component) constructor.newInstance(installHome, MAIN_JS_PATH); |
||||
|
||||
BasicPane managerPane = new ShopManagerPane(webPane); |
||||
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); |
||||
PluginWebBridge.getHelper().setDialogHandle(dlg); |
||||
dlg.setVisible(true); |
||||
DesignerLoginUtils.showPluginRemindOnFirstLaunch(dlg); |
||||
} catch (Exception e) { |
||||
// ignored
|
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
private static void showLoginDlg(Window window) { |
||||
try { |
||||
Class<?> clazz = Class.forName("com.fr.design.extra.LoginWebPane"); |
||||
Constructor constructor = clazz.getConstructor(String.class); |
||||
Component webPane = (Component) constructor.newInstance(installHome); |
||||
UIDialog qqdlg; |
||||
if (window instanceof Dialog) { |
||||
qqdlg = new LoginDialog((Dialog) window, webPane); |
||||
} else { |
||||
qqdlg = new LoginDialog((Frame) window, webPane); |
||||
} |
||||
LoginWebBridge.getHelper().setDialogHandle(qqdlg); |
||||
qqdlg.setVisible(true); |
||||
} catch (Throwable ignored) { |
||||
// ignored
|
||||
} |
||||
} |
||||
|
||||
private static Component initTraditionalStore() { |
||||
UITabbedPane tabbedPane = new UITabbedPane(); |
||||
PluginInstalledPane installedPane = new PluginInstalledPane(); |
||||
tabbedPane.addTab(installedPane.tabTitle(), installedPane); |
||||
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update"), new PluginUpdatePane(tabbedPane)); |
||||
tabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_All_Plugins"), new PluginFromStorePane(tabbedPane)); |
||||
return tabbedPane; |
||||
} |
||||
|
||||
private static void downloadShopScripts(final String scriptsId) { |
||||
new SwingWorker<Boolean, Void>() { |
||||
@Override |
||||
protected Boolean doInBackground() throws Exception { |
||||
return PluginUtils.downloadShopScripts(scriptsId, new Process<Double>() { |
||||
@Override |
||||
public void process(Double integer) { |
||||
// 这个注释毫无意义,就是为了通过SonarQube
|
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
|
||||
try { |
||||
if (get()) { |
||||
File scriptZip = new File(StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE)); |
||||
if (scriptZip.exists()) { |
||||
IOUtils.unzip(scriptZip, installHome); |
||||
CommonUtils.deleteFile(scriptZip); |
||||
} |
||||
PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等
|
||||
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); |
||||
} |
||||
} catch (InterruptedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
Thread.currentThread().interrupt(); |
||||
} catch (ExecutionException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
}.execute(); |
||||
} |
||||
|
||||
private static void updateShopScripts(final String scriptsId) { |
||||
new SwingWorker<Void, Void>() { |
||||
@Override |
||||
protected Void doInBackground() throws Exception { |
||||
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update"); |
||||
if (url != null) { |
||||
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConfig.getInstance().getVersion()); |
||||
JSONObject resultJSONObject = new JSONObject(text); |
||||
String isLatest = resultJSONObject.optString("result"); |
||||
if (!ComparatorUtils.equals(isLatest, LATEST)) { |
||||
int rv = FineJOptionPane.showConfirmDialog( |
||||
null, |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Update"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), |
||||
JOptionPane.OK_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
downloadShopScripts(scriptsId); |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
}.execute(); |
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import com.fine.swing.ui.layout.Row; |
||||
|
||||
import java.util.List; |
||||
|
||||
import static com.fine.theme.utils.FineClientProperties.BUTTON_GROUP_POSITION; |
||||
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_GROUP_FIT; |
||||
import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE; |
||||
|
||||
|
||||
/** |
||||
* 自适应文案宽度的ButtonGroup |
||||
* |
||||
* @author Levy.Xie |
||||
* @since 11.0 |
||||
* Created on 2024/08/28 |
||||
*/ |
||||
public class FitUIButtonGroup<T> extends UIButtonGroup<T> { |
||||
|
||||
public FitUIButtonGroup(String[] textArray) { |
||||
super(textArray); |
||||
} |
||||
|
||||
public FitUIButtonGroup(String[] textArray, T[] objects) { |
||||
super(textArray, objects); |
||||
} |
||||
|
||||
public FitUIButtonGroup(String[] textArray, T[] objects, int[] customCols) { |
||||
super(textArray, objects, customCols); |
||||
} |
||||
|
||||
@Override |
||||
protected void initLayout(int[] cols, boolean inToolbar) { |
||||
Row row = new Row(); |
||||
List<UIToggleButton> buttonList = getLabelButtonList(); |
||||
for (int i = 0; i < buttonList.size(); i++) { |
||||
row.add(buttonList.get(i)); |
||||
if (i != buttonList.size() - 1 && !inToolbar) { |
||||
row.add(createDivider()); |
||||
} |
||||
} |
||||
add(row); |
||||
} |
||||
|
||||
@Override |
||||
protected void initButton(UIToggleButton labelButton, int index) { |
||||
labelButton.setBorderPainted(false); |
||||
labelButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_GROUP_FIT); |
||||
labelButton.putClientProperty(BUTTON_GROUP_POSITION, getGroupButtonPosition(index)); |
||||
labelButtonList.add(labelButton); |
||||
} |
||||
} |
@ -1,10 +1,11 @@
|
||||
package com.fr.design.gui.itooltip; |
||||
|
||||
import com.fine.theme.light.ui.FineTooltipUI; |
||||
import javax.swing.JToolTip; |
||||
|
||||
public class MultiLineToolTip extends JToolTip { |
||||
|
||||
public MultiLineToolTip() { |
||||
setUI(new MultiLineToolTipUI()); |
||||
setUI(new FineTooltipUI()); |
||||
} |
||||
} |
@ -1,30 +0,0 @@
|
||||
package com.fr.design.login.executor; |
||||
|
||||
import com.fr.design.bridge.exec.JSExecutor; |
||||
import com.teamdev.jxbrowser.chromium.JSFunction; |
||||
import com.teamdev.jxbrowser.chromium.JSObject; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-04-18 |
||||
*/ |
||||
public class DesignerLoginBrowserExecutor implements JSExecutor { |
||||
|
||||
public static DesignerLoginBrowserExecutor create(JSObject window, JSFunction callback) { |
||||
return new DesignerLoginBrowserExecutor(window, callback); |
||||
} |
||||
|
||||
private JSObject window; |
||||
private JSFunction callback; |
||||
|
||||
private DesignerLoginBrowserExecutor(JSObject window, JSFunction callback) { |
||||
this.window = window; |
||||
this.callback = callback; |
||||
} |
||||
|
||||
@Override |
||||
public void executor(String newValue) { |
||||
callback.invoke(window, newValue); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue