Browse Source

Merge pull request #950 in BA/design from ~KERRY/design:9.0 to 9.0

* commit '31afffc78f0d1fada76b48d316834a6e5231292b':
  PMD
  PMD
  REPORT-2354 将平台的插件管理和设计器的插件管理统一起来
  REPORT-2354 将平台的插件管理和设计器的插件管理统一起来
master
superman 8 years ago
parent
commit
e675403d14
  1. 16
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 38
      designer_base/src/com/fr/design/extra/exe/callback/InstallDependenceCallback.java
  3. 9
      designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  4. 10
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  5. 19
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java
  6. 8
      designer_base/src/com/fr/design/extra/exe/callback/JSExecutor.java
  7. 39
      designer_base/src/com/fr/design/extra/exe/callback/UpdateDependenceCallback.java
  8. 9
      designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  9. 9
      designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  10. 24
      designer_base/src/com/fr/design/extra/exe/extratask/InstallDependenceTask.java
  11. 26
      designer_base/src/com/fr/design/extra/exe/extratask/UpdateDependenceTask.java
  12. 4
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties

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

@ -3,9 +3,7 @@ package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.extra.exe.callback.*;
import com.fr.design.extra.exe.extratask.InstallDependenceTask;
import com.fr.design.extra.exe.extratask.InstallPluginTask;
import com.fr.design.extra.exe.extratask.UpdateDependenceTask;
import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
@ -46,9 +44,6 @@ public class PluginOperateUtils {
PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
}
public static void installPluginDependence(PluginMarker pluginMarker, JSCallback jsCallback){
PluginManager.getController().download(pluginMarker, new DownloadCallback(new InstallDependenceTask(pluginMarker, jsCallback), jsCallback));
}
public static void updatePluginOnline(List<PluginMarker> pluginMarkerList, JSCallback jsCallback) {
if (!(BBSPluginLogin.getInstance().hasLogin())) {
@ -78,17 +73,6 @@ public class PluginOperateUtils {
PluginManager.getController().update(new File(filePath), new UpdateFromDiskCallback(new File(filePath), jsCallback));
}
public static void updatePluginDependence(PluginMarker pluginMarker, JSCallback jsCallback){
try {
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
PluginManager.getController().download(pluginMarker, new DownloadCallback(new UpdateDependenceTask(pluginMarker, toPluginMarker, jsCallback), jsCallback));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
public static void setPluginActive(String pluginInfo, JSCallback jsCallback) {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);

38
designer_base/src/com/fr/design/extra/exe/callback/InstallDependenceCallback.java

@ -1,38 +0,0 @@
package com.fr.design.extra.exe.callback;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
/**
* Created by ibm on 2017/6/21.
*/
public class InstallDependenceCallback extends AbstractPluginTaskCallback {
protected JSCallback jsCallback;
private static int HUNDRED_PERCENT = 100;
public InstallDependenceCallback(PluginMarker pluginMarker, JSCallback jsCallback){
this.pluginMarker = pluginMarker;
this.jsCallback = jsCallback;
}
@Override
public void updateProgress(String description, double aProgress) {
jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%"));
}
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin-Install_Dependence_Success"));
}else {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin-Install_Dependence_Failed"));
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
}

9
designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java

@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager;
@ -35,9 +36,11 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
String pluginName = pluginContext.getName();
jsCallback.execute("success");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Success"));
FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
null,
@ -55,7 +58,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.installPluginDependence(marker, jsCallback);
PluginOperateUtils.installPluginOnline(marker, jsCallback);
}
PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
} else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){

10
designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

@ -3,8 +3,10 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
@ -32,9 +34,11 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
String pluginName = pluginContext.getName();
jsCallback.execute("success");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Install_Success"));
FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, pluginName + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
null,
@ -52,7 +56,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.installPluginDependence(marker, jsCallback );
PluginOperateUtils.installPluginOnline(marker, jsCallback );
}
//执行JS回调
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);

19
designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java

@ -2,9 +2,6 @@ package com.fr.design.extra.exe.callback;
import com.fr.stable.StringUtils;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
@ -14,17 +11,18 @@ import java.util.regex.Pattern;
/**
* Created by ibm on 2017/5/27.
*/
public class JSCallback<T> extends Task<T> {
public class JSCallback {
private JSExecutor executeScript;
public JSCallback(final WebEngine webEngine, final JSObject callback) {
init(webEngine, callback);
}
public void init(final WebEngine webEngine, final JSObject callback){
messageProperty().addListener(new ChangeListener<String>() {
executeScript = new JSExecutor() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) {
public void executor(String newValue) {
Platform.runLater(new Runnable() {
@Override
public void run() {
@ -37,15 +35,11 @@ public class JSCallback<T> extends Task<T> {
}
});
}
});
}
@Override
protected T call() throws Exception {
return null;
};
}
public void execute(String newValue) {
updateMessage(newValue);
executeScript.executor(newValue);
}
@ -88,5 +82,6 @@ public class JSCallback<T> extends Task<T> {
}
}

8
designer_base/src/com/fr/design/extra/exe/callback/JSExecutor.java

@ -0,0 +1,8 @@
package com.fr.design.extra.exe.callback;
/**
* Created by ibm on 2017/6/21.
*/
public interface JSExecutor {
void executor(String newValue);
}

39
designer_base/src/com/fr/design/extra/exe/callback/UpdateDependenceCallback.java

@ -1,39 +0,0 @@
package com.fr.design.extra.exe.callback;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
/**
* Created by ibm on 2017/6/21.
*/
public class UpdateDependenceCallback extends AbstractPluginTaskCallback {
public PluginMarker toPluginMarker;
protected JSCallback jsCallback;
private static int HUNDRED_PERCENT = 100;
public UpdateDependenceCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback){
this.pluginMarker = pluginMarker;
this.toPluginMarker = toPluginMarker;
this.jsCallback = jsCallback;
}
@Override
public void updateProgress(String description, double aProgress) {
jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%"));
}
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin-Update_Dependence_Success"));
}else {
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin-Update_Dependence_Failed"));
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
}

9
designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java

@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager;
@ -35,9 +36,11 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
String pluginName = pluginContext.getName();
jsCallback.execute("success");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success"));
FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null, pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
null,
@ -55,7 +58,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.updatePluginDependence(marker, jsCallback);
PluginOperateUtils.updatePluginOnline(marker, jsCallback);
}
PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback));
} else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){

9
designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java

@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager;
@ -34,9 +35,11 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
String pluginName = pluginContext.getName();
jsCallback.execute("success");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Plugin_Update_Success"));
FRLogger.getLogger().info(pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null,pluginName + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
null,
@ -54,7 +57,7 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.updatePluginDependence(marker, jsCallback);
PluginOperateUtils.updatePluginOnline(marker, jsCallback);
}
PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback));
} else {

24
designer_base/src/com/fr/design/extra/exe/extratask/InstallDependenceTask.java

@ -1,24 +0,0 @@
package com.fr.design.extra.exe.extratask;
import com.fr.design.extra.exe.callback.InstallDependenceCallback;
import com.fr.design.extra.exe.callback.JSCallback;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
/**
* Created by ibm on 2017/6/21.
*/
public class InstallDependenceTask extends AbstractExtraPluginTask {
protected JSCallback jsCallback;
public InstallDependenceTask(PluginMarker pluginMarker, JSCallback jsCallback) {
this.pluginMarker = pluginMarker;
this.jsCallback = jsCallback;
}
@Override
public void doExtraPluginTask() {
PluginManager.getController().install(pluginMarker, new InstallDependenceCallback(pluginMarker, jsCallback));
}
}

26
designer_base/src/com/fr/design/extra/exe/extratask/UpdateDependenceTask.java

@ -1,26 +0,0 @@
package com.fr.design.extra.exe.extratask;
import com.fr.design.extra.exe.callback.JSCallback;
import com.fr.design.extra.exe.callback.UpdateDependenceCallback;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
/**
* Created by ibm on 2017/6/21.
*/
public class UpdateDependenceTask extends AbstractExtraPluginTask {
public PluginMarker toPluginMarker;
protected JSCallback jsCallback;
public UpdateDependenceTask(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) {
this.pluginMarker = pluginMarker;
this.toPluginMarker = toPluginMarker;
this.jsCallback = jsCallback;
}
@Override
public void doExtraPluginTask() {
PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateDependenceCallback(pluginMarker, toPluginMarker, jsCallback));
}
}

4
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -2001,7 +2001,7 @@ FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer-Alphafine_No_Remind=\u4E0D\u518D\u63D0\u793A
FR-Designer-Plugin_Install_Success=\u63D2\u4EF6\u5B89\u88C5\u6210\u529F
FR-Designer-Plugin_Install_Failed=\u63D2\u4EF6\u5B89\u88C5\u5931\u8D25
FR-Designer-Plugin_Install_Dependence=\u662F\u5426\u5B89\u88C5\u4F9D\u8D56\u73AF\u5883
FR-Designer-Plugin_Install_Dependence=\u662F\u5426\u5B89\u88C5\u4F9D\u8D56\u63D2\u4EF6
FR-Designer-Plugin_Has_Install_Lower=\u5DF2\u7ECF\u5B89\u88C5\u4F4E\u7248\u672C\u63D2\u4EF6\uFF0C\u662F\u5426\u8FDB\u884C\u66F4\u65B0\uFF1F
FR-Designer-Plugin_No_Plugin_Update=\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u63D2\u4EF6\uFF0C\u662F\u5426\u5B89\u88C5\uFF1F
FR-Designer-Plugin-Install_Package=\u63D2\u4EF6\u5B89\u88C5\u5305
@ -2013,7 +2013,7 @@ FR-Designer-Plugin_Delete_Confirmed=\u786E\u5B9A\u5220\u9664\u6B64\u63D2\u4EF6\u
FR-Designer-Plugin_Delete_Dependence=\u662F\u5426\u5220\u9664\u4F9D\u8D56\u73AF\u5883
FR-Designer-Plugin_Delete_Success=\u63D2\u4EF6\u5220\u9664\u6210\u529F
FR-Designer-Plugin_Delete_Failed=\u63D2\u4EF6\u5220\u9664\u5931\u8D25
FR-Designer-Plugin_Update_Dependence=\u662F\u5426\u66F4\u65B0\u4F9D\u8D56\u73AF\u5883
FR-Designer-Plugin_Update_Dependence=\u662F\u5426\u66F4\u65B0\u4F9D\u8D56\u63D2\u4EF6
FR-Designer-Plugin_Update_Success=\u63D2\u4EF6\u66F4\u65B0\u6210\u529F
FR-Designer-Plugin_Update_Failed=\u63D2\u4EF6\u66F4\u65B0\u5931\u8D25
FR-Designer-Plugin_Actived=\u63D2\u4EF6\u5DF2\u88AB\u542F\u7528

Loading…
Cancel
Save