|
|
@ -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,27 +83,39 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void readUpdateOnline(JSCallback jsCallback) { |
|
|
|
public static void readUpdateOnline(JSCallback jsCallback) { |
|
|
|
try { |
|
|
|
|
|
|
|
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); |
|
|
|
new Thread(new Runnable() { |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
@Override |
|
|
|
for (PluginView plugin : plugins) { |
|
|
|
public void run() { |
|
|
|
org.json.JSONObject jsonObject = new org.json.JSONObject(); |
|
|
|
try { |
|
|
|
jsonObject.put("pluginid", plugin.getID()); |
|
|
|
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); |
|
|
|
jsonArray.put(jsonObject); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
|
|
|
|
for (PluginView plugin : plugins) { |
|
|
|
|
|
|
|
org.json.JSONObject jsonObject = new org.json.JSONObject(); |
|
|
|
|
|
|
|
jsonObject.put("pluginid", plugin.getID()); |
|
|
|
|
|
|
|
jsonArray.put(jsonObject); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String result = jsonArray.toString(); |
|
|
|
|
|
|
|
jsCallback.execute(result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String result = jsonArray.toString(); |
|
|
|
}).start(); |
|
|
|
jsCallback.execute(result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void searchPlugin(String keyword, JSCallback jsCallback) { |
|
|
|
public static void searchPlugin(String keyword, JSCallback jsCallback) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); |
|
|
|
new Thread(new Runnable() { |
|
|
|
String result = httpClient.getResponseText(); |
|
|
|
@Override |
|
|
|
jsCallback.execute(result); |
|
|
|
public void run() { |
|
|
|
|
|
|
|
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); |
|
|
|
|
|
|
|
String result = httpClient.getResponseText(); |
|
|
|
|
|
|
|
jsCallback.execute(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
@ -150,19 +155,25 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void getPluginCategories(JSCallback jsCallback) { |
|
|
|
public static void getPluginCategories(JSCallback jsCallback) { |
|
|
|
String result; |
|
|
|
new Thread(new Runnable() { |
|
|
|
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
|
|
|
@Override |
|
|
|
if (url != null) { |
|
|
|
public void run() { |
|
|
|
HttpClient httpClient = new HttpClient(url); |
|
|
|
String result; |
|
|
|
result = httpClient.getResponseText(); |
|
|
|
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
|
|
|
} else { |
|
|
|
if (url != null) { |
|
|
|
result = PluginConstants.CONNECTION_404; |
|
|
|
HttpClient httpClient = new HttpClient(url); |
|
|
|
} |
|
|
|
result = httpClient.getResponseText(); |
|
|
|
jsCallback.execute(result); |
|
|
|
} else { |
|
|
|
|
|
|
|
result = PluginConstants.CONNECTION_404; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
@ -172,11 +183,11 @@ public class PluginOperateUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean pluginValidate(PluginView pluginView){ |
|
|
|
public static boolean pluginValidate(PluginView pluginView) { |
|
|
|
return StringUtils.isNotEmpty(pluginView.getID()) |
|
|
|
return StringUtils.isNotEmpty(pluginView.getID()) |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getName()) |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getName()) |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getVersion()) |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getVersion()) |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getEnvVersion()); |
|
|
|
&& StringUtils.isNotEmpty(pluginView.getEnvVersion()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|