forked from fanruan/design
Browse Source
* commit '2a0c239ad137dea2977b7dde3d0b5ca60edea64c': 重命名文件 漏掉一个 dubug去掉 jdk1.8打开新插件管理 设计器插件商店更新和搜索API改动 插件商店搜索 插件商店的一些java数据API 插件商店API 切换分支 添加删除 1、更改插件窗口以适配插件商店布局设计 2、添加获取插件新的请求master
richie
9 years ago
20 changed files with 1030 additions and 496 deletions
@ -0,0 +1,25 @@
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.UIDialog; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by vito on 16/4/18. |
||||
*/ |
||||
public class PluginShopDialog extends UIDialog { |
||||
private static final Dimension DEFAULT_SHOP = new Dimension(900, 710); |
||||
|
||||
public PluginShopDialog(Frame frame, BasicPane pane) { |
||||
super(frame, pane, false); |
||||
setSize(DEFAULT_SHOP); |
||||
GUICoreUtils.centerWindow(this); |
||||
setResizable(false); |
||||
} |
||||
|
||||
@Override |
||||
public void checkValid() throws Exception { |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginWebBridge; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
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) { |
||||
StringBuilder url = new StringBuilder(PluginWebBridge.PLUGIN_SHOP); |
||||
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()); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.PluginWebBridge; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.FRLogger; |
||||
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(PluginWebBridge.PLUGIN_SHOP + "&keyword=" + keyword); |
||||
result = httpClient.getResponseText(); |
||||
|
||||
} catch (Exception e) { |
||||
FRLogger.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -1,23 +1,106 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.RestartHelper; |
||||
import com.fr.design.extra.After; |
||||
import com.fr.design.extra.PluginHelper; |
||||
import com.fr.design.extra.Process; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.Plugin; |
||||
import com.fr.plugin.PluginLoader; |
||||
|
||||
import javax.swing.*; |
||||
import java.io.File; |
||||
|
||||
/** |
||||
* Created by richie on 16/3/19. |
||||
*/ |
||||
public class UpdateOnlineExecutor implements Executor { |
||||
|
||||
private String pluginID; |
||||
|
||||
public UpdateOnlineExecutor(String pluginID) { |
||||
this.pluginID = pluginID; |
||||
private String[] pluginIDs; |
||||
private static final int PERCENT_100 = 100; |
||||
|
||||
public UpdateOnlineExecutor(String[] pluginIDs) { |
||||
this.pluginIDs = pluginIDs; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return "插件已更新完毕:" + pluginID; |
||||
return "task succeed"; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[0]; |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
for (int i = 0; i < pluginIDs.length; i++) { |
||||
Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]); |
||||
String id = null; |
||||
if (plugin != null) { |
||||
id = plugin.getId(); |
||||
} |
||||
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
||||
String password = DesignerEnvManager.getEnvManager().getBBSPassword(); |
||||
try { |
||||
PluginHelper.downloadPluginFile(id, username, password, new Process<Double>() { |
||||
@Override |
||||
public void process(Double integer) { |
||||
} |
||||
}); |
||||
updateFileFromDisk(PluginHelper.getDownloadTempFile()); |
||||
process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%"); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
int rv = JOptionPane.showOptionDialog( |
||||
null, |
||||
Inter.getLocText("FR-Designer-Plugin_Update_Successful"), |
||||
Inter.getLocText("FR-Designer-Plugin_Warning"), |
||||
JOptionPane.YES_NO_OPTION, |
||||
JOptionPane.INFORMATION_MESSAGE, |
||||
null, |
||||
new String[]{Inter.getLocText("FR-Designer-Basic_Restart_Designer"), |
||||
Inter.getLocText("FR-Designer-Basic_Restart_Designer_Later") |
||||
}, |
||||
null |
||||
); |
||||
if (rv == JOptionPane.OK_OPTION) { |
||||
RestartHelper.restart(); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void updateFileFromDisk(File fileOnDisk) { |
||||
try { |
||||
Plugin plugin = PluginHelper.readPlugin(fileOnDisk); |
||||
if (plugin == null) { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Illegal_Plugin_Zip"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
return; |
||||
} |
||||
Plugin oldPlugin = PluginLoader.getLoader().getPluginById(plugin.getId()); |
||||
if (oldPlugin != null) { |
||||
String[] files = PluginHelper.uninstallPlugin(FRContext.getCurrentEnv(), oldPlugin); |
||||
PluginHelper.installPluginFromUnzippedTempDir(FRContext.getCurrentEnv(), plugin, new After() { |
||||
@Override |
||||
public void done() { |
||||
} |
||||
}); |
||||
} else { |
||||
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Cannot_Update_Not_Install"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} catch (Exception e1) { |
||||
JOptionPane.showMessageDialog(null, e1.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue