Browse Source

PFC-607 插件安装删除更新不重启支持

修复主线程弹窗死锁的问题
master
juhaoyu 8 years ago
parent
commit
266511537a
  1. 44
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java

44
designer_base/src/com/fr/design/extra/PluginOperateUtils.java

@ -24,16 +24,12 @@ import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/** /**
* Created by ibm on 2017/5/26. * Created by ibm on 2017/5/26.
*/ */
public class PluginOperateUtils { public class PluginOperateUtils {
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
public static void installPluginOnline(final PluginMarker pluginMarker, JSCallback jsCallback) { public static void installPluginOnline(final PluginMarker pluginMarker, JSCallback jsCallback) {
//下载插件 //下载插件
@ -92,14 +88,13 @@ public class PluginOperateUtils {
PluginManager.getController().enable(pluginMarker, modifyStatusCallback); PluginManager.getController().enable(pluginMarker, modifyStatusCallback);
} }
} }
public static void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSCallback jsCallback) { public static void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
int rv = JOptionPane.showConfirmDialog( int rv = JOptionPane.showConfirmDialog(
null, null,
Inter.getLocText("FR-Designer-Plugin_Delete_Confirmed"), Inter.getLocText("FR-Designer-Plugin_Delete_Confirmed"),
@ -112,13 +107,12 @@ public class PluginOperateUtils {
PluginManager.getController().uninstall(pluginMarker, isForce, new UninstallPluginCallback(pluginMarker, jsCallback)); PluginManager.getController().uninstall(pluginMarker, isForce, new UninstallPluginCallback(pluginMarker, jsCallback));
} }
} }
}); }).start();
} }
public static void readUpdateOnline(final JSCallback jsCallback) { public static void readUpdateOnline(final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@ -135,13 +129,14 @@ public class PluginOperateUtils {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
}); }).start();
} }
public static void searchPlugin(final String keyword, final JSCallback jsCallback) { public static void searchPlugin(final String keyword, final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() {
new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@ -159,12 +154,13 @@ public class PluginOperateUtils {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }
} }
}); }).start();
} }
public static void getPluginFromStore(final String category, final String seller, final String fee, final JSCallback jsCallback) { public static void getPluginFromStore(final String category, final String seller, final String fee, final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() {
new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?";
@ -193,8 +189,8 @@ public class PluginOperateUtils {
jsCallback.execute(result); jsCallback.execute(result);
} }
} }
}); }).start();
} }
@ -243,7 +239,8 @@ public class PluginOperateUtils {
} }
public static void getPluginCategories(final JSCallback jsCallback) { public static void getPluginCategories(final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() {
new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String result; String result;
@ -256,17 +253,18 @@ public class PluginOperateUtils {
} }
jsCallback.execute(result); jsCallback.execute(result);
} }
}); }).start();
} }
public static void getPluginPrefix(final JSCallback jsCallback) { public static void getPluginPrefix(final JSCallback jsCallback) {
EXECUTOR.execute(new Runnable() {
new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
String result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix"); String result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix");
jsCallback.execute(result); jsCallback.execute(result);
} }
}); }).start();
} }
public static void getLoginInfo(JSCallback jsCallback) { public static void getLoginInfo(JSCallback jsCallback) {

Loading…
Cancel
Save