Browse Source

Merge pull request #26 in PF/design from ~KERRY/design-pf:9.0 to 9.0

* commit '0caa8c6a46dbc70ebdbd58317219d44ac195c425':
  REPORT-2354 将平台的插件管理和设计器的插件管理统一起来
master
superman 8 years ago
parent
commit
977a354a84
  1. 3
      designer_base/src/com/fr/design/extra/LoginWebBridge.java
  2. 6
      designer_base/src/com/fr/design/extra/PluginFromStorePane.java
  3. 33
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  4. 9
      designer_base/src/com/fr/design/extra/PluginUpdatePane.java
  5. 9
      designer_base/src/com/fr/design/extra/PluginUtils.java
  6. 11
      designer_base/src/com/fr/design/extra/PluginWebBridge.java

3
designer_base/src/com/fr/design/extra/LoginWebBridge.java

@ -9,6 +9,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.plugin.manage.bbs.BBSPluginLogin;
import com.fr.plugin.manage.bbs.BBSUserInfo;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
@ -320,6 +322,7 @@ public class LoginWebBridge {
DesignerEnvManager.getEnvManager().setBBSName(username); DesignerEnvManager.getEnvManager().setBBSName(username);
DesignerEnvManager.getEnvManager().setInShowBBsName(username); DesignerEnvManager.getEnvManager().setInShowBBsName(username);
DesignerEnvManager.getEnvManager().setBBSPassword(password); DesignerEnvManager.getEnvManager().setBBSPassword(password);
BBSPluginLogin.getInstance().login(new BBSUserInfo(username, password));
return LOGININ;//登录成功,0 return LOGININ;//登录成功,0
} else if ($uid == -1) { } else if ($uid == -1) {
return USERNAME_NOT_EXSIT;//用户名不存在,-1 return USERNAME_NOT_EXSIT;//用户名不存在,-1

6
designer_base/src/com/fr/design/extra/PluginFromStorePane.java

@ -6,6 +6,7 @@ import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.bbs.BBSPluginLogin; import com.fr.plugin.manage.bbs.BBSPluginLogin;
@ -199,8 +200,9 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
try { try {
PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion());
String latestPluginInfo = PluginUtils.getLatestPluginInfo(id); JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(id);
PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginInfo); String latestPluginVersion = (String)latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(id, latestPluginVersion);
PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane));
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e); FRContext.getLogger().error(e.getMessage(), e);

33
designer_base/src/com/fr/design/extra/PluginOperateUtils.java

@ -6,7 +6,6 @@ import com.fr.design.extra.exe.callback.*;
import com.fr.design.extra.exe.extratask.InstallPluginTask; import com.fr.design.extra.exe.extratask.InstallPluginTask;
import com.fr.design.extra.exe.extratask.UpdatePluginTask; import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -14,12 +13,11 @@ import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.bbs.BBSPluginLogin; import com.fr.plugin.manage.bbs.BBSPluginLogin;
import com.fr.plugin.manage.bbs.BBSUserInfo;
import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import javax.swing.*;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -51,13 +49,8 @@ public class PluginOperateUtils {
if (BBSPluginLogin.getInstance().hasLogin()) { if (BBSPluginLogin.getInstance().hasLogin()) {
for (int i = 0; i < pluginMarkerList.size(); i++) { for (int i = 0; i < pluginMarkerList.size(); i++) {
try { try {
String latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID());
if (StringUtils.isEmpty(latestPluginInfo) || PluginConstants.CONNECTION_404.equals(latestPluginInfo)) { String latestPluginVersion = (String) latestPluginInfo.get("version");
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Connect_Failed"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return;
}
JSONObject resultArr = new JSONObject(latestPluginInfo);
String latestPluginVersion = (String) resultArr.get("version");
PluginMarker pluginMarker = pluginMarkerList.get(i); PluginMarker pluginMarker = pluginMarkerList.get(i);
PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion); PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion);
PluginManager.getController().download(pluginMarkerList.get(i), new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback)); PluginManager.getController().download(pluginMarkerList.get(i), new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback));
@ -90,6 +83,10 @@ public class PluginOperateUtils {
} }
public static void readUpdateOnline(JSCallback jsCallback) { public static void readUpdateOnline(JSCallback jsCallback) {
new Thread(new Runnable() {
@Override
public void run() {
try { try {
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate();
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
@ -103,14 +100,22 @@ public class PluginOperateUtils {
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
}
}).start();
} }
public static void searchPlugin(String keyword, JSCallback jsCallback) { public static void searchPlugin(String keyword, JSCallback jsCallback) {
try { try {
new Thread(new Runnable() {
@Override
public void run() {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword);
String result = httpClient.getResponseText(); String result = httpClient.getResponseText();
jsCallback.execute(result); jsCallback.execute(result);
}
}).start();
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
@ -150,6 +155,9 @@ public class PluginOperateUtils {
} }
public static void getPluginCategories(JSCallback jsCallback) { public static void getPluginCategories(JSCallback jsCallback) {
new Thread(new Runnable() {
@Override
public void run() {
String result; String result;
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category");
if (url != null) { if (url != null) {
@ -160,9 +168,12 @@ public class PluginOperateUtils {
} }
jsCallback.execute(result); jsCallback.execute(result);
} }
}).start();
}
public static void getLoginInfo(JSCallback jsCallback) { public static void getLoginInfo(JSCallback jsCallback) {
String username = BBSPluginLogin.getInstance().getUserInfo().getUserName(); BBSUserInfo bbsUserInfo = BBSPluginLogin.getInstance().getUserInfo();
String username = bbsUserInfo == null ? "" : bbsUserInfo.getUserName();
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName();
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) {
return; return;

9
designer_base/src/com/fr/design/extra/PluginUpdatePane.java

@ -8,6 +8,7 @@ import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
@ -179,11 +180,15 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginV
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
if (BBSPluginLogin.getInstance().hasLogin()) { if (BBSPluginLogin.getInstance().hasLogin()) {
try{
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());
String latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID()); JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginInfo); String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); PluginManager.getController().download(pluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane));
}catch (Exception e){}
} }
} }

9
designer_base/src/com/fr/design/extra/PluginUtils.java

@ -38,7 +38,7 @@ public class PluginUtils {
return pluginMarker; return pluginMarker;
} }
public static String getLatestPluginInfo(String pluginID){ public static JSONObject getLatestPluginInfo(String pluginID) throws Exception {
String result = ""; String result = "";
String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI"); String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.searchAPI");
if (StringUtils.isNotEmpty(plistUrl)) { if (StringUtils.isNotEmpty(plistUrl)) {
@ -48,6 +48,7 @@ public class PluginUtils {
} }
try { try {
HttpClient httpClient = new HttpClient(url.toString()); HttpClient httpClient = new HttpClient(url.toString());
httpClient.asGet();
result = httpClient.getResponseText(); result = httpClient.getResponseText();
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
@ -55,7 +56,11 @@ public class PluginUtils {
} else { } else {
result = PluginConstants.CONNECTION_404; result = PluginConstants.CONNECTION_404;
} }
return result; JSONObject resultJSONObject = new JSONObject(result);
JSONArray resultArr = resultJSONObject.getJSONArray("result");
JSONObject latestPluginInfo = JSONObject.create();
latestPluginInfo = (JSONObject) resultArr.get(0);
return latestPluginInfo;
} }
public static String transPluginsToString(List<PluginContext> plugins) throws Exception { public static String transPluginsToString(List<PluginContext> plugins) throws Exception {

11
designer_base/src/com/fr/design/extra/PluginWebBridge.java

@ -4,10 +4,7 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.*;
import com.fr.design.extra.exe.callback.JSCallback; import com.fr.design.extra.exe.callback.JSCallback;
import com.fr.design.extra.exe.extratask.ExtraPluginTask;
import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -19,7 +16,6 @@ import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.concurrent.Task;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -488,8 +484,11 @@ public class PluginWebBridge {
* @param password * @param password
* @return * @return
*/ */
public String defaultLogin(String username, String password) { public void defaultLogin(String username, String password, final JSObject callback) {
return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); JSCallback jsCallback = new JSCallback(webEngine, callback);
String result = LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel);
jsCallback.execute(result);
} }
/** /**

Loading…
Cancel
Save