Browse Source

REPORT-2354 将平台的插件管理和设计器的插件管理统一起来

master
kerry 7 years ago
parent
commit
cb41e8098c
  1. 38
      designer_base/src/com/fr/design/extra/exe/callback/InstallDependenceCallback.java
  2. 9
      designer_base/src/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  3. 10
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  4. 22
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java
  5. 8
      designer_base/src/com/fr/design/extra/exe/callback/JSExecutor.java
  6. 39
      designer_base/src/com/fr/design/extra/exe/callback/UpdateDependenceCallback.java
  7. 9
      designer_base/src/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  8. 9
      designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  9. 24
      designer_base/src/com/fr/design/extra/exe/extratask/InstallDependenceTask.java
  10. 26
      designer_base/src/com/fr/design/extra/exe/extratask/UpdateDependenceTask.java

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);

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

@ -1,10 +1,7 @@
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.application.Platform;;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
@ -14,22 +11,24 @@ 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() {
String fun = "(" + callback + ")(\"" + trimText(newValue) + "\")";
try {
System.out.print("###"+newValue);
webEngine.executeScript(fun);
} catch (Exception e) {
webEngine.executeScript("alert(\"" + e.getMessage() + "\")");
@ -37,15 +36,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 +83,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));
}
}
Loading…
Cancel
Save