Browse Source

Merge pull request #106 in BA/design from ~VITO/design:dev to dev

* commit 'c573179143ccb976891ccc146515bcf492df359a':
  catch更改
  1、删除插件返回一个成功消息,供界面显示 2、更新过期插件弹出两个对话框的问题
master
superman 9 years ago
parent
commit
de804eb17c
  1. 1
      designer_base/src/com/fr/design/extra/PluginWebBridge.java
  2. 6
      designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java
  3. 111
      designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java

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

@ -153,6 +153,7 @@ public class PluginWebBridge {
* @param des 过滤文件描述
* @param filter 文件的后缀
* @return 选择的文件的路径
* 这里换用JFileChooser会卡死,不知道为什么
*/
public String showFileChooserWithFilter(String des, String filter) {
FileChooser fileChooser = new FileChooser();

6
designer_base/src/com/fr/design/extra/exe/UninstallExecutor.java

@ -16,6 +16,7 @@ import javax.swing.*;
public class UninstallExecutor implements Executor {
private String[] pluginIDs;
private String result = "undo";
public UninstallExecutor(String[] pluginIDs) {
this.pluginIDs = pluginIDs;
@ -23,7 +24,7 @@ public class UninstallExecutor implements Executor {
@Override
public String getTaskFinishMessage() {
return "插件已卸载完毕,重启后生效";
return result;
}
@Override
@ -32,7 +33,7 @@ public class UninstallExecutor implements Executor {
new Command() {
@Override
public String getExecuteMessage() {
return "删除成功";
return null;
}
@Override
@ -62,6 +63,7 @@ public class UninstallExecutor implements Executor {
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
result = "done";
if (rv == JOptionPane.OK_OPTION) {
RestartHelper.restart();
}

111
designer_base/src/com/fr/design/extra/exe/UpdateOnlineExecutor.java

@ -10,6 +10,7 @@ import com.fr.design.extra.Process;
import com.fr.general.Inter;
import com.fr.plugin.Plugin;
import com.fr.plugin.PluginLoader;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.StringUtils;
import javax.swing.*;
@ -43,44 +44,50 @@ public class UpdateOnlineExecutor implements Executor {
@Override
public void run(Process<String> process) {
if(StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())){
if (StringUtils.isBlank(DesignerEnvManager.getEnvManager().getBBSName())) {
LoginCheckContext.fireLoginCheckListener();
}
if(StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())){
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) {
if (StringUtils.isNotBlank(DesignerEnvManager.getEnvManager().getBBSName())) {
try {
for (int i = 0; i < pluginIDs.length; i++) {
try {
Plugin plugin = PluginLoader.getLoader().getPluginById(pluginIDs[i]);
String id = null;
if (plugin != null) {
id = plugin.getId();
}
});
updateFileFromDisk(PluginHelper.getDownloadTempFile());
process.process(PERCENT_100 / pluginIDs.length * (i + 1) + "%");
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
String username = DesignerEnvManager.getEnvManager().getBBSName();
String password = DesignerEnvManager.getEnvManager().getBBSPassword();
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 (PluginVerifyException e) {
throw e;
} 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();
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();
}
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
}
@ -88,26 +95,22 @@ public class UpdateOnlineExecutor implements Executor {
};
}
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);
private void updateFileFromDisk(File fileOnDisk) throws Exception {
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);
}
}
}

Loading…
Cancel
Save