|
|
|
@ -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.UpdatePluginTask; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.general.SiteCenter; |
|
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
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.manage.PluginManager; |
|
|
|
|
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.view.PluginView; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import org.json.JSONArray; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -51,13 +49,8 @@ public class PluginOperateUtils {
|
|
|
|
|
if (BBSPluginLogin.getInstance().hasLogin()) { |
|
|
|
|
for (int i = 0; i < pluginMarkerList.size(); i++) { |
|
|
|
|
try { |
|
|
|
|
String latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); |
|
|
|
|
if (StringUtils.isEmpty(latestPluginInfo) || PluginConstants.CONNECTION_404.equals(latestPluginInfo)) { |
|
|
|
|
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"); |
|
|
|
|
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarkerList.get(i).getPluginID()); |
|
|
|
|
String latestPluginVersion = (String) latestPluginInfo.get("version"); |
|
|
|
|
PluginMarker pluginMarker = pluginMarkerList.get(i); |
|
|
|
|
PluginMarker toPluginMarker = PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion); |
|
|
|
|
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) { |
|
|
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
try { |
|
|
|
|
List<PluginView> plugins = PluginsReaderFromStore.readPluginsForUpdate(); |
|
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
@ -103,14 +100,22 @@ public class PluginOperateUtils {
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void searchPlugin(String keyword, JSCallback jsCallback) { |
|
|
|
|
try { |
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
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) { |
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
} |
|
|
|
@ -150,6 +155,9 @@ public class PluginOperateUtils {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void getPluginCategories(JSCallback jsCallback) { |
|
|
|
|
new Thread(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
String result; |
|
|
|
|
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
|
|
|
|
if (url != null) { |
|
|
|
@ -160,9 +168,12 @@ public class PluginOperateUtils {
|
|
|
|
|
} |
|
|
|
|
jsCallback.execute(result); |
|
|
|
|
} |
|
|
|
|
}).start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { |
|
|
|
|
return; |
|
|
|
|