kerry
8 years ago
35 changed files with 393 additions and 1234 deletions
@ -1,60 +0,0 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.stable.EncodeConstants; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.net.URLDecoder; |
||||
import java.util.HashMap; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/5/25. |
||||
*/ |
||||
public class PluginReaderForDesigner { |
||||
private static Set<String> pluginsToUpdate = new HashSet<String>(); |
||||
|
||||
/** |
||||
* 从插件商店服务器读取插件信息,以JSON形式返回 |
||||
* |
||||
* @return 插件信息 |
||||
*/ |
||||
public static String[] readPluginsForUpdate() throws Exception { |
||||
String resText = null; |
||||
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.update"); |
||||
if (StringUtils.isNotEmpty(url)) { |
||||
HashMap<String, String> para = new HashMap<String, String>(); |
||||
para.put("plugins", PluginUtils.transPluginsToString(PluginManager.getContexts())); |
||||
//只有当前设计器的jar高于插件新版本需要的jarTime时, 才提示更新该插件.
|
||||
para.put("jarTime", GeneralUtils.readBuildNO()); |
||||
HttpClient httpClient = new HttpClient(url, para); |
||||
resText = httpClient.getResponseText(); |
||||
String charSet = EncodeConstants.ENCODING_UTF_8; |
||||
resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); |
||||
} |
||||
if (StringUtils.isNotEmpty(resText)) { |
||||
try { |
||||
pluginsToUpdate.clear(); |
||||
JSONArray jsonArray = new JSONArray(resText); |
||||
for (int i = 0, size = jsonArray.length(); i < size; i++) { |
||||
JSONObject jo = jsonArray.optJSONObject(i); |
||||
String id = jo.optString("id"); |
||||
if(StringUtils.isNotEmpty(id)){ |
||||
pluginsToUpdate.add(jo.optString("id", "")); |
||||
} |
||||
} |
||||
} catch (JSONException e) { |
||||
throw new Exception(Inter.getLocText("FS-Web-Plugin_Read_Plugin_List_Error")); |
||||
} |
||||
} |
||||
return pluginsToUpdate.toArray(new String[pluginsToUpdate.size()]); |
||||
} |
||||
} |
@ -1,41 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.plugin.manage.bbs.BBSPluginLogin; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by lp on 2016/8/16. |
||||
*/ |
||||
public class GetLoginInfoExecutor implements Executor { |
||||
private String result = "[]"; |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
String username = BBSPluginLogin.getInstance().getUserInfo().getUserName(); |
||||
String inShowUsername = DesignerEnvManager.getEnvManager().getInShowBBsName(); |
||||
if (StringUtils.isEmpty(username) && StringUtils.isEmpty(inShowUsername)) { |
||||
return; |
||||
}else { |
||||
result = StringUtils.isEmpty(inShowUsername) ? username : inShowUsername; |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,41 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginConstants; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
|
||||
/** |
||||
* Created by vito on 16/5/16. |
||||
*/ |
||||
public class GetPluginCategoriesExecutor implements Executor { |
||||
private String result = "[]"; |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category"); |
||||
if (url != null) { |
||||
HttpClient httpClient = new HttpClient(url); |
||||
result = httpClient.getResponseText(); |
||||
} else { |
||||
result = PluginConstants.CONNECTION_404; |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,68 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginConstants; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by vito on 16/4/18. |
||||
* 获取插件分类信息 |
||||
*/ |
||||
public class GetPluginFromStoreExecutor implements Executor { |
||||
private String result = "[]"; |
||||
private String category; |
||||
private String seller; |
||||
private String fee; |
||||
|
||||
public GetPluginFromStoreExecutor(String category, String seller, String fee) { |
||||
this.category = category; |
||||
this.seller = seller; |
||||
this.fee = fee; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist"); |
||||
if (StringUtils.isNotBlank(plistUrl)) { |
||||
StringBuilder url = new StringBuilder(); |
||||
url.append(plistUrl); |
||||
if (StringUtils.isNotBlank(category)) { |
||||
url.append("&cid=").append(category.split("-")[1]); |
||||
} |
||||
if (StringUtils.isNotBlank(seller)) { |
||||
url.append("&seller=").append(seller.split("-")[1]); |
||||
} |
||||
if (StringUtils.isNotBlank(fee)) { |
||||
url.append("&fee=").append(fee.split("-")[1]); |
||||
} |
||||
try { |
||||
HttpClient httpClient = new HttpClient(url.toString()); |
||||
result = httpClient.getResponseText(); |
||||
} catch (Exception e) { |
||||
FRLogger.getLogger().error(e.getMessage()); |
||||
} |
||||
} else { |
||||
result = PluginConstants.CONNECTION_404; |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,103 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
|
||||
import javax.swing.*; |
||||
import java.io.File; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class InstallFromDiskExecutor implements Executor { |
||||
private String filePath; |
||||
|
||||
public InstallFromDiskExecutor(String filePath) { |
||||
this.filePath = filePath; |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Success_Install"); |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Unzipping") + filePath; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<java.lang.String> process) { |
||||
|
||||
} |
||||
}, |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Installing"); |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
PluginManager.getController().install(new File(filePath), new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
} |
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); |
||||
} else if(result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()){ |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
null, |
||||
null |
||||
); |
||||
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { |
||||
return; |
||||
} |
||||
installWithDependence(); |
||||
}else{ |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void installWithDependence(){ |
||||
PluginManager.getController().install(new File(filePath), new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
} |
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else{ |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,124 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.LoginCheckContext; |
||||
import com.fr.design.extra.PluginUtils; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.bbs.BBSPluginLogin; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class InstallOnlineExecutor implements Executor { |
||||
|
||||
private String pluginInfo; |
||||
|
||||
public InstallOnlineExecutor(String pluginInfo) { |
||||
this.pluginInfo = pluginInfo; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return "task succeed"; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Downloading") + ":" + pluginInfo.split("_")[0]; |
||||
} |
||||
|
||||
@Override |
||||
public void run(final Process<String> process) { |
||||
//下载插件
|
||||
if (!BBSPluginLogin.getInstance().hasLogin()) { |
||||
LoginCheckContext.fireLoginCheckListener(); |
||||
} |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); |
||||
if (BBSPluginLogin.getInstance().hasLogin()) { |
||||
PluginManager.getController().download(pluginMarker, new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double aProgress) { |
||||
// process.process(Math.round(aProgress * 100) + "%");
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
installPlugin(pluginMarker); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void installPlugin(PluginMarker pluginMarker) { |
||||
PluginManager.getController().install(pluginMarker, new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Success")), |
||||
Inter.getLocText("FR-Designer-Plugin_Install_Dependence"), |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
null, |
||||
null |
||||
); |
||||
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { |
||||
return; |
||||
} |
||||
installPluginWithDependence(pluginMarker); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public void installPluginWithDependence(PluginMarker pluginMarker) { |
||||
PluginManager.getController().install(pluginMarker, new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Failed")); |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,74 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginUtils; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTaskCallback; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class ModifyStatusExecutor implements Executor { |
||||
|
||||
private String pluginInfo; |
||||
private boolean active; |
||||
private PluginContext plugin; |
||||
|
||||
public ModifyStatusExecutor(String pluginInfo) { |
||||
this.pluginInfo = pluginInfo; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return plugin.isActive() ? Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived") : Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled"); |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); |
||||
plugin = PluginManager.getContext(pluginMarker); |
||||
active = !plugin.isActive(); |
||||
if (active) { |
||||
PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() { |
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Has_Been_Disabled")); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} else { |
||||
PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() { |
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Has_Been_Actived")); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,49 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.LoginWebBridge; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/11/7. |
||||
*/ |
||||
public class PluginLoginExecutor implements Executor { |
||||
|
||||
private String result = "[]"; |
||||
|
||||
private String username; |
||||
private String password; |
||||
private UILabel uiLabel; |
||||
|
||||
public PluginLoginExecutor(String username, String password, UILabel uiLabel) { |
||||
this.username = username; |
||||
this.password = password; |
||||
this.uiLabel = uiLabel; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[] { |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel); |
||||
if (Integer.valueOf(loginResult) == 0) { |
||||
LoginWebBridge.getHelper().updateMessageCount(); |
||||
} |
||||
result = loginResult; |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,49 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginReaderForDesigner; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.stable.StringUtils; |
||||
import org.json.JSONArray; |
||||
import org.json.JSONObject; |
||||
|
||||
/** |
||||
* Created by vito on 16/4/19. |
||||
*/ |
||||
public class ReadUpdateOnlineExecutor implements Executor { |
||||
private String[] plugins; |
||||
private String result; |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
try { |
||||
plugins = PluginReaderForDesigner.readPluginsForUpdate(); |
||||
JSONArray jsonArray = new JSONArray(); |
||||
for (String plugin : plugins) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("pluginid", plugin); |
||||
jsonArray.put(jsonObject); |
||||
} |
||||
result = jsonArray.toString(); |
||||
} catch (Exception e) { |
||||
FRLogger.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,47 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.SiteCenter; |
||||
import com.fr.general.http.HttpClient; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by vito on 16/4/18. |
||||
*/ |
||||
public class SearchOnlineExecutor implements Executor { |
||||
private String result; |
||||
private String keyword; |
||||
|
||||
public SearchOnlineExecutor(String keyword) { |
||||
this.keyword = keyword; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
try { |
||||
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.plist") + "&keyword=" + keyword); |
||||
result = httpClient.getResponseText(); |
||||
|
||||
} catch (Exception e) { |
||||
FRLogger.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,62 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginUtils; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTaskCallback; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class UninstallExecutor implements Executor { |
||||
|
||||
private String pluginInfo; |
||||
private boolean isForce; |
||||
private String result = "undo"; |
||||
|
||||
public UninstallExecutor(String pluginInfo, boolean isForce) { |
||||
this.pluginInfo = pluginInfo; |
||||
this.isForce = isForce; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); |
||||
PluginManager.getController().uninstall(pluginMarker, isForce, new PluginTaskCallback() { |
||||
@Override |
||||
public void done(PluginTaskResult pluginTaskResult) { |
||||
if (pluginTaskResult.isSuccess()) { |
||||
result = "done"; |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); |
||||
JOptionPane.showMessageDialog(null, pluginTaskResult.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,81 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
|
||||
import javax.swing.*; |
||||
import java.io.File; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class UpdateFromDiskExecutor implements Executor { |
||||
|
||||
private String filePath; |
||||
|
||||
public UpdateFromDiskExecutor(String filePath) { |
||||
this.filePath = filePath; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return Inter.getLocText("FR-Designer-Plugin_Update_End"); |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
PluginManager.getController().update(new File(filePath), new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { |
||||
updatePluginWithDependence(); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void updatePluginWithDependence() { |
||||
PluginManager.getController().update(new File(filePath), new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,118 +0,0 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.extra.*; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.bbs.BBSPluginLogin; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class UpdateOnlineExecutor implements Executor { |
||||
|
||||
private String[] pluginInfos; |
||||
private static final int PERCENT_100 = 100; |
||||
|
||||
public UpdateOnlineExecutor(String[] pluginInfos) { |
||||
this.pluginInfos = pluginInfos; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return "task succeed"; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
if (!(BBSPluginLogin.getInstance().hasLogin())){ |
||||
LoginCheckContext.fireLoginCheckListener(); |
||||
} |
||||
if (BBSPluginLogin.getInstance().hasLogin()) { |
||||
List<PluginMarker> pluginMarkerList = new ArrayList<PluginMarker>(); |
||||
for (int i = 0; i < pluginInfos.length; i++) { |
||||
pluginMarkerList.add(PluginUtils.createPluginMarker(pluginInfos[i])); |
||||
} |
||||
updatePlugins(pluginMarkerList, process); } |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void updatePluginWithDependence(PluginMarker pluginMarker, PluginMarker toMarker) { |
||||
PluginManager.getController().update(pluginMarker, toMarker, new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public void updatePlugins(List<PluginMarker> pluginMarkerList, Process<String> process) { |
||||
for (int i = 0; i < pluginMarkerList.size(); i++) { |
||||
try { |
||||
int a = i; |
||||
//todo check下此插件的最新版本
|
||||
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"); |
||||
PluginManager.getController().update(pluginMarkerList.get(i), PluginMarker.create(pluginMarkerList.get(i).getPluginID(), latestPluginVersion), new ProgressCallback() { |
||||
@Override |
||||
public void updateProgress(String description, double progress) { |
||||
process.process(PERCENT_100 / pluginMarkerList.size() * (a + 1) + "%"); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void done(PluginTaskResult result) { |
||||
if (result.isSuccess()) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { |
||||
updatePluginWithDependence(pluginMarkerList.get(a), PluginMarker.create(pluginMarkerList.get(a).getPluginID(), latestPluginVersion)); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fr.design.extra.exe.extratask; |
||||
|
||||
import com.fr.design.extra.exe.callback.JSCallback; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/5/27. |
||||
*/ |
||||
public abstract class AbstractExtraPluginTask implements ExtraPluginTask { |
||||
protected PluginMarker pluginMarker; |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.extra.tradition.callback; |
||||
|
||||
import com.fr.design.extra.PluginStatusCheckCompletePane; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
import com.fr.plugin.manage.control.ProgressCallback; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by ibm on 2017/5/31. |
||||
*/ |
||||
public class UpdateOnlineCallback implements ProgressCallback { |
||||
private PluginStatusCheckCompletePane pane; |
||||
private PluginMarker pluginMarker; |
||||
private PluginMarker toPluginMarker; |
||||
|
||||
public UpdateOnlineCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, PluginStatusCheckCompletePane pane){ |
||||
this.pluginMarker = pluginMarker; |
||||
this.toPluginMarker = toPluginMarker; |
||||
this.pane = pane; |
||||
} |
||||
public void updateProgress(String description, double progress){ |
||||
pane.setProgress(progress); |
||||
} |
||||
|
||||
public void done(PluginTaskResult result){ |
||||
if (result.isSuccess()) { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success")); |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Successful")); |
||||
} else if (result.errorCode() == PluginErrorCode.OperationNotSupport.getCode()) { |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")), |
||||
Inter.getLocText("FR-Designer-Plugin_Install_Success"), |
||||
JOptionPane.YES_NO_CANCEL_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
null, |
||||
null |
||||
); |
||||
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { |
||||
return; |
||||
} |
||||
PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); |
||||
} else { |
||||
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Delete_Failed")); |
||||
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue