Browse Source

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

* commit 'f70a24d40b3ed25e766c0aa42e4863c30a753f17':
  import修改
  代码修改
  无jira任务,添加final
  代码修改
  代码修改
  REPORT-2354 依赖部分修改
master
superman 7 years ago
parent
commit
59c3754459
  1. 31
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 45
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  3. 2
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java
  4. 43
      designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  5. 26
      designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java
  6. 26
      designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java

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

@ -3,8 +3,6 @@ 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.InstallPluginTask;
import com.fr.design.extra.exe.extratask.UpdatePluginTask;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
@ -16,7 +14,10 @@ import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.bbs.BBSPluginLogin;
import com.fr.plugin.manage.bbs.BBSUserInfo;
import com.fr.plugin.manage.control.PluginControllerHelper;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils;
@ -36,7 +37,8 @@ public class PluginOperateUtils {
LoginCheckContext.fireLoginCheckListener();
}
if (BBSPluginLogin.getInstance().hasLogin()) {
PluginManager.getController().download(pluginMarker, new DownloadCallback(new InstallPluginTask(pluginMarker, jsCallback), jsCallback));
PluginTask pluginTask = PluginTask.installTask(pluginMarker);
PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback));
}
}
@ -61,7 +63,8 @@ public class PluginOperateUtils {
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
PluginManager.getController().download(toPluginMarker, new DownloadCallback(new UpdatePluginTask(pluginMarker, toPluginMarker, jsCallback), jsCallback));
PluginTask pluginTask = PluginTask.updateTask(pluginMarker, toPluginMarker);
PluginControllerHelper.updateOnline(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback));
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
@ -280,4 +283,24 @@ public class PluginOperateUtils {
&& StringUtils.isNotEmpty(pluginView.getEnvVersion());
}
public static String getSuccessInfo(PluginTaskResult result){
StringBuilder pluginInfo = new StringBuilder();
PluginTask currentTask = result.getCurrentTask();
PluginContext context = PluginManager.getContext(currentTask.getMarker());
if(context != null){
pluginInfo.append(context.getName());
}
List<PluginTaskResult> pluginTaskResults = result.asList();
for(PluginTaskResult pluginTaskResult : pluginTaskResults){
List<PluginTask> pluginTasks = pluginTaskResult.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginContext pluginContext = PluginManager.getContext(pluginTask.getMarker());
if(pluginContext != null){
pluginInfo.append(pluginContext.getName());
}
}
}
return pluginInfo.toString();
}
}

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

@ -4,25 +4,24 @@ import com.fr.design.extra.PluginUtils;
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.AbstractDealPreTaskCallback;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
import java.util.List;
/**
* Created by ibm on 2017/5/26.
*/
public class InstallOnlineCallback extends AbstractPluginTaskCallback {
public class InstallOnlineCallback extends AbstractDealPreTaskCallback {
protected JSCallback jsCallback;
private static int HUNDRED_PERCENT = 100;
public InstallOnlineCallback(PluginMarker pluginMarker, JSCallback jsCallback){
this.pluginMarker = pluginMarker;
public InstallOnlineCallback(PluginTask pluginTask, JSCallback jsCallback){
super(pluginTask);
this.jsCallback = jsCallback;
}
@ -33,34 +32,12 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
protected void allDone(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
String pluginName = pluginContext.getName();
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
jsCallback.execute("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,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Install_Dependence")),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
null,
null
);
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return;
}
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.installPluginOnline(marker, jsCallback );
}
//执行JS回调
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);
FRLogger.getLogger().info(pluginInfo + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, pluginInfo + Inter.getLocText("FR-Designer-Plugin_Install_Success"));
} else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){
int rv = JOptionPane.showOptionDialog(
null,
@ -75,6 +52,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return;
}
PluginMarker pluginMarker = result.getCurrentTask().getMarker();
PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback);
}else {
jsCallback.execute("failed");
@ -82,4 +60,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
}

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

@ -22,7 +22,7 @@ public class JSCallback {
public void init(final WebEngine webEngine, final JSObject callback){
executeScript = new JSExecutor() {
@Override
public void executor(String newValue) {
public void executor(final String newValue) {
Platform.runLater(new Runnable() {
@Override
public void run() {

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

@ -4,27 +4,21 @@ import com.fr.design.extra.PluginUtils;
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.AbstractDealPreTaskCallback;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
import java.util.List;
/**
* Created by ibm on 2017/5/26.
*/
public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
public PluginMarker toPluginMarker;
public class UpdateOnlineCallback extends AbstractDealPreTaskCallback {
protected JSCallback jsCallback;
private static int HUNDRED_PERCENT = 100;
public UpdateOnlineCallback(PluginMarker pluginMarker, PluginMarker toPluginMarker, JSCallback jsCallback) {
this.pluginMarker = pluginMarker;
this.toPluginMarker = toPluginMarker;
public UpdateOnlineCallback(PluginTask pluginTask, JSCallback jsCallback) {
super(pluginTask);
this.jsCallback = jsCallback;
}
@ -34,33 +28,12 @@ public class UpdateOnlineCallback extends AbstractPluginTaskCallback {
}
@Override
public void done(PluginTaskResult result) {
public void allDone(PluginTaskResult result) {
if (result.isSuccess()) {
PluginContext pluginContext = PluginManager.getContext(toPluginMarker);
String pluginName = pluginContext.getName();
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
jsCallback.execute("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,
Inter.getLocText(Inter.getLocText("FR-Designer-Plugin_Update_Dependence")),
Inter.getLocText("FR-Designer-Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
null,
null
);
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return;
}
List<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginMarker marker = pluginTask.getMarker();
PluginOperateUtils.updatePluginOnline(marker, jsCallback);
}
PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback));
FRLogger.getLogger().info(pluginInfo + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
JOptionPane.showMessageDialog(null,pluginInfo + Inter.getLocText("FR-Designer-Plugin_Update_Success"));
} else {
jsCallback.execute("failed");
FRLogger.getLogger().info(Inter.getLocText("FR-Designer-Plugin_Update_Failed"));

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

@ -1,26 +0,0 @@
package com.fr.design.extra.exe.extratask;
import com.fr.design.extra.exe.callback.InstallOnlineCallback;
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/5/27.
*/
public class InstallPluginTask extends AbstractExtraPluginTask {
protected JSCallback jsCallback;
public InstallPluginTask(PluginMarker pluginMarker, JSCallback jsCallback) {
this.pluginMarker = pluginMarker;
this.jsCallback = jsCallback;
}
@Override
public void doExtraPluginTask() {
PluginManager.getController().install(pluginMarker, new InstallOnlineCallback(pluginMarker, jsCallback));
}
}

26
designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.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.UpdateOnlineCallback;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
/**
* Created by ibm on 2017/5/27.
*/
public class UpdatePluginTask extends AbstractExtraPluginTask {
public PluginMarker toPluginMarker;
protected JSCallback jsCallback;
public UpdatePluginTask(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 UpdateOnlineCallback(pluginMarker, toPluginMarker, jsCallback));
}
}
Loading…
Cancel
Save