Browse Source

REPORT-2354 依赖部分修改

master
kerry 8 years ago
parent
commit
111b87f08b
  1. 28
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 46
      designer_base/src/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  3. 43
      designer_base/src/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  4. 26
      designer_base/src/com/fr/design/extra/exe/extratask/InstallPluginTask.java
  5. 26
      designer_base/src/com/fr/design/extra/exe/extratask/UpdatePluginTask.java

28
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,8 @@ 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.PluginTaskCallback;
import com.fr.plugin.manage.control.*;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils;
@ -36,7 +35,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, pluginMarker);
PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback));
}
}
@ -61,7 +61,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 +281,21 @@ 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<PluginTask> pluginTasks = result.getPreTasks();
for(PluginTask pluginTask : pluginTasks){
PluginContext pluginContext = PluginManager.getContext(pluginTask.getMarker());
if(pluginContext != null){
pluginInfo.append(pluginContext.getName());
}
}
return pluginInfo.toString();
}
}

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

@ -3,25 +3,21 @@ 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;
import com.fr.plugin.manage.control.*;
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;
}
@ -32,34 +28,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,
@ -74,6 +48,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");
@ -81,4 +56,7 @@ public class InstallOnlineCallback extends AbstractPluginTaskCallback {
JOptionPane.showMessageDialog(null, result.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}
}

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

@ -3,27 +3,21 @@ 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.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;
}
@ -33,33 +27,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