Browse Source

Merge remote-tracking branch 'origin/bugfix/10.0' into bugfix/10.0

bugfix/10.0
Yyming 4 years ago
parent
commit
92601c59c0
  1. 19
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 50
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  3. 1
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  4. 11
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java
  5. 32
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  6. 24
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  7. 14
      designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java
  8. 27
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java
  9. 37
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  10. 12
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  11. 3
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  12. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  13. 71
      designer-base/src/main/java/com/fr/design/file/TemplateResource.java
  14. 66
      designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java
  15. 21
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  16. 19
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java
  17. 52
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java
  18. 34
      designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java
  19. 19
      designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java
  20. 23
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java
  21. 24
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java
  22. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  23. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  24. 108
      designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java
  25. 18
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  26. 62
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  27. 155
      designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java
  28. 23
      designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java
  29. 2
      designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java
  30. 4
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  31. 45
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  32. 33
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java
  33. 3
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  34. 331
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  35. 1
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
  36. 25
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java

19
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -1,6 +1,7 @@
package com.fr.design;
import com.fr.common.report.ReportState;
import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
@ -35,6 +36,7 @@ import com.fr.process.engine.core.FineProcessContext;
import com.fr.rpc.Result;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import com.fr.env.PluginErrorRemindDialog;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
@ -144,6 +146,7 @@ public class EnvChangeEntrance {
template.refreshToolArea();
}
showServiceDialog(selectedEnv);
pluginErrorRemind(selectedEnv);
} catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
@ -297,6 +300,22 @@ public class EnvChangeEntrance {
}
}
/**
* 插件启动错误信息提示
* @param selectedEnv 选择的工作环境
*/
public void pluginErrorRemind(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
return;
}
String content = PluginErrorRemindHandler.pluginErrorContent();
if (StringUtils.isNotEmpty(content)) {
PluginErrorRemindDialog dialog = new PluginErrorRemindDialog(DesignerContext.getDesignerFrame(), content);
dialog.setVisible(true);
}
}
/**
* 判断是否需要做版本验证判断依据为
* 1选择的环境为远程环境

50
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -18,6 +18,7 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.context.PluginMarkerAdapter;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginControllerHelper;
import com.fr.plugin.manage.control.PluginTask;
@ -26,7 +27,8 @@ import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.io.File;
import java.net.HttpURLConnection;
import java.util.List;
@ -38,11 +40,23 @@ import java.util.List;
public class PluginOperateUtils {
public static void installPluginOnline(final PluginMarker pluginMarker, JSCallback jsCallback) {
PluginMarker marker = updateMarker2Online(pluginMarker);
//下载插件
PluginTask pluginTask = PluginTask.installTask(pluginMarker);
PluginTask pluginTask = PluginTask.installTask(marker);
PluginControllerHelper.installOnline(pluginMarker, new InstallOnlineCallback(pluginTask, jsCallback));
}
public static PluginMarker updateMarker2Online(PluginMarker pluginMarker) {
try {
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String pluginName = latestPluginInfo.getString("name");
return PluginMarkerAdapter.create(pluginMarker, pluginName);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return pluginMarker;
}
public static void installPluginFromDisk(File zipFile, JSCallback jsCallback) {
PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
}
@ -57,10 +71,11 @@ public class PluginOperateUtils {
public static void updatePluginOnline(PluginMarker pluginMarker, JSCallback jsCallback) {
try {
JSONObject latestPluginInfo = PluginUtils.getLatestPluginInfo(pluginMarker.getPluginID());
String latestPluginVersion = (String) latestPluginInfo.get("version");
PluginMarker toPluginMarker = PluginMarker.create(pluginMarker.getPluginID(), latestPluginVersion);
String latestPluginVersion = latestPluginInfo.getString("version");
String pluginName = latestPluginInfo.getString("name");
PluginMarker toPluginMarker = PluginMarkerAdapter.create(pluginMarker.getPluginID(), latestPluginVersion, pluginName);
//当前已经安装的相同ID插件marker
PluginMarker currentMarker = PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID());
PluginMarker currentMarker = PluginMarkerAdapter.create(PluginUtils.getInstalledPluginMarkerByID(pluginMarker.getPluginID()), pluginName);
PluginTask pluginTask = PluginTask.updateTask(currentMarker, toPluginMarker);
PluginControllerHelper.updateOnline(currentMarker, toPluginMarker, new UpdateOnlineCallback(pluginTask, jsCallback));
} catch (Exception e) {
@ -128,6 +143,10 @@ public class PluginOperateUtils {
}
public static void dealParams(StringBuilder url, String category, String seller, String fee, String scope) {
dealParams(url, category, seller, fee, StringUtils.EMPTY);
}
public static void dealParams(StringBuilder url, String category, String seller, String fee, String scope, String language) {
if (StringUtils.isNotBlank(category)) {
url.append("cid=").append(category.split("-")[1]);
} else {
@ -169,6 +188,9 @@ public class PluginOperateUtils {
url.append("&scope=").append(StringUtils.EMPTY);
}
}
if (StringUtils.isNotBlank(language)) {
url.append("&language=").append(language.split("-")[1]);
}
}
public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) {
@ -203,16 +225,22 @@ public class PluginOperateUtils {
continue;
}
PluginMarker pluginMarker = pluginTask.getToMarker();
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
if (pluginContext != null) {
pluginInfo.append(pluginContext.getName()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode()));
} else {
pluginInfo.append(pluginMarker.getPluginID()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode()));
}
PluginContext pluginContext = PluginManager.getContext(pluginMarker.getPluginID());
pluginInfo.append(getPluginName(pluginContext, pluginMarker)).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode()));
}
return pluginInfo.toString();
}
private static String getPluginName(PluginContext pluginContext, PluginMarker pluginMarker) {
if (pluginContext != null) {
return pluginContext.getName();
}
else if (pluginMarker instanceof PluginMarkerAdapter) {
return ((PluginMarkerAdapter) pluginMarker).getPluginName();
}
return pluginMarker == null ? StringUtils.EMPTY : pluginMarker.getPluginID();
}
public static String getSwitchedInfo(PluginTaskResult result) {
StringBuilder pluginInfo = new StringBuilder();
List<PluginTaskResult> pluginTaskResults = result.asList();

1
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -10,6 +10,7 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginVerifyException;
import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalType;
import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;

11
designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java

@ -21,19 +21,26 @@ public class GetPluginFromStoreExecutor implements Executor {
private String seller;
private String fee;
private String scope;
private String language;
public GetPluginFromStoreExecutor(JSONObject info) {
this.category = info.optString("categories");
this.fee = info.optString("fee");
this.seller = info.optString("seller");
this.scope = info.optString("scope");
this.language = info.optString("language");
}
public GetPluginFromStoreExecutor(String category, String seller, String fee, String scope) {
this(category, seller, fee, scope, StringUtils.EMPTY);
}
public GetPluginFromStoreExecutor(String category, String seller, String fee, String scope, String language) {
this.category = category;
this.seller = seller;
this.fee = fee;
this.scope = scope;
this.language = language;
}
@Override
@ -53,7 +60,7 @@ public class GetPluginFromStoreExecutor implements Executor {
@Override
public void run(Process<String> process) {
String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist");
boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope);
boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope) & StringUtils.isEmpty(language);
if (getRecommend) {
result = PluginOperateUtils.getRecommendPlugins();
return;
@ -62,7 +69,7 @@ public class GetPluginFromStoreExecutor implements Executor {
if (StringUtils.isNotBlank(plistUrl)) {
StringBuilder url = new StringBuilder();
url.append(plistUrl).append("?");
PluginOperateUtils.dealParams(url, category, seller, fee, scope);
PluginOperateUtils.dealParams(url, category, seller, fee, scope, language);
try {
HttpClient httpClient = new HttpClient(url.toString());
httpClient.asGet();

32
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java

@ -3,7 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
import java.io.File;
import java.util.List;
@ -41,20 +40,21 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
if (result.isSuccess()) {
String switchedInfo = PluginOperateUtils.getSwitchedInfo(result);
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo;
FineLoggerFactory.getLogger().info(successInfo);
FineJOptionPane.showMessageDialog(null, successInfo);
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Dependence"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
return;
}
List<PluginTask> pluginTasks = result.getPreTasks();
@ -64,24 +64,24 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
}
PluginManager.getController().install(zipFile, new InstallFromDiskCallback(zipFile, jsCallback));
} else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"),
Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
return;
}
PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback);
}else {
jsCallback.execute("failed");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"));
FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE);
}
}
}

24
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
@ -11,8 +12,6 @@ import com.fr.plugin.manage.control.AbstractDealPreTaskCallback;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
/**
* Created by ibm on 2017/5/26.
@ -38,20 +37,21 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback {
if (result.isSuccess()) {
String switchedInfo = PluginOperateUtils.getSwitchedInfo(result);
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo;
FineLoggerFactory.getLogger().info(successInfo);
FineJOptionPane.showMessageDialog(null, successInfo);
} else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"),
Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
jsCallback.execute("success");
return;
}
@ -59,8 +59,8 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback {
PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback);
} else {
jsCallback.execute("failed");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE);
}
}

14
designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java

@ -2,12 +2,14 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginUtils;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
import javax.swing.JOptionPane;
/**
* Created by ibm on 2017/5/27.
@ -22,12 +24,16 @@ public class ModifyStatusCallback implements PluginTaskCallback{
}
@Override
public void done(PluginTaskResult result) {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
jsCallback.execute("success");
String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate");
String modifyMessage = isActive ?
pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") :
pluginInfo + Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate");
FineLoggerFactory.getLogger().info(modifyMessage);
FineJOptionPane.showMessageDialog(null, modifyMessage);
} else {
FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
}
}

27
designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java

@ -2,7 +2,8 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginUtils;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
@ -10,8 +11,6 @@ import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
/**
* Created by ibm on 2017/5/27.
*/
@ -25,29 +24,31 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success"));
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success"));
String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success");
FineLoggerFactory.getLogger().info(successInfo);
FineJOptionPane.showMessageDialog(null, successInfo);
}else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) {
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Dependence"),
Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
return;
}
PluginManager.getController().uninstall(pluginMarker, true, new UninstallPluginCallback(pluginMarker, jsCallback));
} else {
jsCallback.execute("failed");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed"));
FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE);
}
}
}

37
designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java

@ -3,7 +3,7 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
@ -12,7 +12,6 @@ import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
import java.io.File;
import java.util.List;
@ -37,22 +36,24 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"));
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"));
String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success");
FineLoggerFactory.getLogger().info(successInfo);
FineJOptionPane.showMessageDialog(null, successInfo);
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Dependence"),
Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
return;
}
List<PluginTask> pluginTasks = result.getPreTasks();
@ -62,24 +63,24 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
}
PluginManager.getController().update(zipFile, new UpdateFromDiskCallback(zipFile, jsCallback));
} else if(result.errorCode() == PluginErrorCode.NoPluginToUpdate){
int rv = JOptionPane.showOptionDialog(
int rv = FineJOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE,
Toolkit.i18nText("Fine-Design_Basic_Plugin_No_Plugin_Update"),
Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
FineJOptionPane.YES_NO_CANCEL_OPTION,
FineJOptionPane.INFORMATION_MESSAGE,
null,
FineJOptionPane.OPTION_YES_NO_CANCEL,
null
);
if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
if (rv == FineJOptionPane.NO_OPTION || rv == FineJOptionPane.CANCEL_OPTION || rv == FineJOptionPane.CLOSED_OPTION) {
return;
}
PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback);
}else {
jsCallback.execute("failed");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed"));
FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE);
}
}
}

12
designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java

@ -3,14 +3,13 @@ package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.manage.control.AbstractDealPreTaskCallback;
import com.fr.plugin.manage.control.PluginTask;
import com.fr.plugin.manage.control.PluginTaskResult;
import javax.swing.*;
/**
* Created by ibm on 2017/5/26.
*/
@ -33,12 +32,13 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"));
FineJOptionPane.showMessageDialog(null,pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success"));
String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success");
FineLoggerFactory.getLogger().info(successInfo);
FineJOptionPane.showMessageDialog(null, successInfo);
} else {
jsCallback.execute("failed");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed"));
FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE);
}
}
}

3
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -2,7 +2,6 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.io.BaseBook;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager;
@ -23,7 +22,6 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import javax.swing.SwingUtilities;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collections;
@ -441,4 +439,5 @@ public class HistoryTemplateListCache implements CallbackEvent {
}
});
}
}

4
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -18,8 +18,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.third.javax.annotation.Nonnull;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.ButtonModel;
@ -707,7 +705,7 @@ public class MutilTempalteTabPane extends JComponent {
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
TemplateResourceManager.getResource().closeTemplate(file.getPath());
}
}

71
designer-base/src/main/java/com/fr/design/file/TemplateResource.java

@ -0,0 +1,71 @@
package com.fr.design.file;
import com.fr.common.annotations.Open;
import com.fr.file.FILE;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 模板资源操作可操作模板及模板目录
*
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
@Open
public interface TemplateResource {
/**
* 读取模板
* @param path
* @return
* @throws Exception
*/
InputStream readTemplate(String path) throws Exception;
/**
* 保存模板
* @param file
* @return
* @throws Exception
*/
OutputStream saveTemplate(FILE file) throws Exception;
/**
* 删除某个目录/某个模板
* @param file
* @return
*/
boolean delete(FILE file);
/**
* 关闭模板
* @param path
* @return
*/
boolean closeTemplate(String path);
/**
* 重命名模板/目录
* @param from
* @param to
* @return
*/
boolean rename(String from, String to);
/**
* 模板/目录是否存在
* @param path
* @return
*/
boolean exist(String path);
/**
* 创建目录
* @param path
* @return
*/
boolean mkdir(String path);
}

66
designer-base/src/main/java/com/fr/design/file/TemplateResourceManager.java

@ -0,0 +1,66 @@
package com.fr.design.file;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.file.impl.DefaultTemplateResource;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.file.filetree.FileNodes;
import com.fr.file.filetree.LocalFileNodes;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.plugin.observer.PluginListenerRegistration;
import com.fr.workspace.WorkContext;
import com.fr.workspace.engine.base.FineObjectPool;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public class TemplateResourceManager {
private static final TemplateResource DEFAULT_OPERATION = new DefaultTemplateResource();
private static TemplateResource OPERATION = DEFAULT_OPERATION;
static {
PluginFilter filter = pluginContext -> pluginContext.contain(PluginModule.ExtraDesign, LocalResourceProvider.XML_TAG);
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterStop, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
registerOperation(new DefaultTemplateResource());
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, new LocalFileNodes());
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh());
}
}, filter);
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
LocalResourceProvider provider = ExtraDesignClassManager.getInstance().getSingle(LocalResourceProvider.XML_TAG);
if (provider != null && WorkContext.getCurrent().isLocal()) {
registerOperation(provider.createResourceOperation());
FineObjectPool.getInstance().getLocalPool().put(FileNodes.class, provider.createFileNodes());
UIUtil.invokeLaterIfNeeded(() -> DesignerFrameFileDealerPane.getInstance().refresh());
}
}
}, filter);
}
private static void registerOperation(TemplateResource operation) {
OPERATION = operation;
}
public static TemplateResource getResource() {
if (OPERATION == null) {
return DEFAULT_OPERATION;
}
return OPERATION;
}
}

21
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -4,7 +4,9 @@
package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.TemplateTreeDefineProcessor;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
@ -23,12 +25,11 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
@ -87,6 +88,16 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
TemplateTreeDefineProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TemplateTreeDefineProcessor.XML_TAG);
if (processor != null) {
processor.rightClickAction(e);
}
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (toolBarStateChangeListener != null) {
@ -182,7 +193,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
return TemplateResourceManager.getResource().mkdir(path);
}
/**
@ -325,7 +336,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
if (WorkContext.getCurrent().get(TplOperator.class).delete(nodeFILE.getPath())) {
if (TemplateResourceManager.getResource().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {
success = false;
@ -427,7 +438,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
try {
// 接收的是WEB-INF下的路径
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
return TemplateResourceManager.getResource().rename(from, to);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

19
designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateResource.java

@ -0,0 +1,19 @@
package com.fr.design.file.impl;
import com.fr.design.file.TemplateResource;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public abstract class AbstractTemplateResource implements TemplateResource {
}

52
designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateResource.java

@ -0,0 +1,52 @@
package com.fr.design.file.impl;
import com.fr.file.FILE;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/23
*/
public class DefaultTemplateResource extends AbstractTemplateResource {
@Override
public InputStream readTemplate(String path) throws Exception {
return new ByteArrayInputStream(WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(path));
}
@Override
public OutputStream saveTemplate(FILE file) throws Exception {
return file.asOutputStream();
}
@Override
public boolean closeTemplate(String path) {
return WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(path);
}
@Override
public boolean delete(FILE file) {
return WorkContext.getCurrent().get(TplOperator.class).delete(file.getPath());
}
@Override
public boolean rename(String from, String to) {
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
}
@Override
public boolean exist(String path) {
return WorkContext.getWorkResource().exist(path);
}
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
}

34
designer-base/src/main/java/com/fr/design/fun/LocalResourceProvider.java

@ -0,0 +1,34 @@
package com.fr.design.fun;
import com.fr.design.file.TemplateResource;
import com.fr.file.filetree.FileNodes;
import com.fr.stable.fun.mark.Immutable;
/**
* 本地资源操作插件接口
*
* @author hades
* @version 10.0
* Created by hades on 2020/12/22
*/
public interface LocalResourceProvider extends Immutable {
String XML_TAG = "LocalResourceProvider";
int CURRENT_LEVEL = 1;
/**
* eg: DefaultResourceOperation
*
* @return 目录/模板的各种操作
*/
TemplateResource createResourceOperation();
/**
* eg: LocalFileNodes
*
* @return 构建目录树的方式
*/
FileNodes createFileNodes();
}

19
designer-base/src/main/java/com/fr/design/fun/TemplateTreeDefineProcessor.java

@ -0,0 +1,19 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Immutable;
import java.awt.event.MouseEvent;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/14
*/
public interface TemplateTreeDefineProcessor extends Immutable {
String XML_TAG = "TemplateTreeDefineProcessor";
int CURRENT_LEVEL = 1;
void rightClickAction(MouseEvent mouseEvent);
}

23
designer-base/src/main/java/com/fr/design/fun/impl/AbstractLocalResourceProvider.java

@ -0,0 +1,23 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.LocalResourceProvider;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/22
*/
@API(level = LocalResourceProvider.CURRENT_LEVEL)
public abstract class AbstractLocalResourceProvider implements LocalResourceProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

24
designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateTreeDefineProcessor.java

@ -0,0 +1,24 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.TemplateTreeDefineProcessor;
import com.fr.stable.fun.mark.API;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/12/21
*/
@API(level = TemplateTreeDefineProcessor.CURRENT_LEVEL)
public abstract class AbstractTemplateTreeDefineProcessor implements TemplateTreeDefineProcessor {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -17,7 +17,6 @@ import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
@ -58,7 +57,6 @@ import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;

4
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -3,7 +3,6 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
@ -24,6 +23,7 @@ import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateResourceManager;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler;
@ -813,7 +813,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
try {
this.getTarget().export(editingFILE.asOutputStream());
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);

108
designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java vendored

@ -0,0 +1,108 @@
package com.fr.env;
import com.fr.design.actions.server.PluginManagerAction;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
/**
* 插件启动失败提示窗
*/
public class PluginErrorRemindDialog extends JDialog implements ActionListener {
public PluginErrorRemindDialog(Frame parent, String areaText) {
super(parent, true);
//上面的标签面板
JPanel topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel imagePanel = new JPanel();
Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png");
JLabel imageLabel = new JLabel();
imageLabel.setIcon(icon);
imagePanel.add(imageLabel);
imagePanel.setPreferredSize(new Dimension(130, 100));
JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Title"));
label.setFont(FRFont.getInstance().applySize(18).applyStyle(1));
label.setPreferredSize(new Dimension(650, 100));
verticalPanel.add(label);
topPanel.add(imagePanel, BorderLayout.WEST);
topPanel.add(verticalPanel, BorderLayout.CENTER);
topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
//中间的文本域面板
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
centerPanel.setPreferredSize(new Dimension(480, 320));
JTextArea checkArea = new JTextArea(areaText);
checkArea.setEnabled(false);
centerPanel.add(checkArea, BorderLayout.CENTER);
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Not_Deal_With"));
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With"));
cancelButton.addActionListener(this);
okButton.addActionListener(new PluginManagerActionAdapter(this));
// 按钮
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPanel.add(cancelButton);
buttonPanel.add(okButton);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"));
this.setResizable(false);
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(buttonPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500));
GUICoreUtils.centerWindow(this);
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
private static class PluginManagerActionAdapter extends PluginManagerAction {
private JDialog jDialog;
public PluginManagerActionAdapter(JDialog jDialog) {
this.jDialog = jDialog;
}
@Override
public void actionPerformed(ActionEvent e) {
this.jDialog.dispose();
super.actionPerformed(e);
}
}
}

18
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -2,6 +2,7 @@ package com.fr.file;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.file.TemplateResourceManager;
import com.fr.io.FineEncryptUtils;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor;
@ -22,10 +23,8 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.resource.WorkResourceTempRenameStream;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.*;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
@ -324,7 +323,7 @@ public class FileNodeFILE implements FILE {
}
try {
return WorkContext.getWorkResource().exist(node.getEnvPath());
return TemplateResourceManager.getResource().exist(node.getEnvPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
@ -379,14 +378,11 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null;
}
InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)
)
)
);
InputStream in = TemplateResourceManager.getResource().readTemplate(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)
));
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in;

62
designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

@ -1,10 +1,12 @@
package com.fr.design;
import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog;
import com.fr.env.PluginErrorRemindDialog;
import com.fr.invoke.Reflect;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
@ -16,13 +18,19 @@ import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.awt.Frame;
/**
* @author: Maksim
* @Date: Created in 2020/3/5
* @Description:
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class})
@PrepareForTest({FunctionalHttpRequest.class,
EnvChangeEntrance.class,
CheckServiceDialog.class,
DesignerEnvManager.class,
PluginErrorRemindHandler.class})
public class EnvChangeEntranceTest {
@Test
@ -44,17 +52,15 @@ public class EnvChangeEntranceTest {
EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch);
CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class);
PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog);
PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog);
EasyMock.replay(request);
EasyMock.replay(selectedEnv);
EasyMock.replay(connectionInfo);
EasyMock.replay(request, selectedEnv, connectionInfo);
PowerMock.replayAll();
entrance.showServiceDialog(selectedEnv);
Assert.assertTrue(true);
}catch (Exception e){
Assert.assertTrue(false);
Assert.fail();
}
}
@ -94,10 +100,44 @@ public class EnvChangeEntranceTest {
DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path");
DesignerWorkspaceInfo info4 = null;
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info1).get());
Assert.assertTrue((boolean) Reflect.on(entrance).call("isNotRememberPwd", info2).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info3).get());
Assert.assertFalse((boolean) Reflect.on(entrance).call("isNotRememberPwd", info4).get());
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get());
Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).get());
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get());
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get());
}
@Test
public void testPluginErrorRemind() throws Exception {
try {
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once();
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2);
PowerMock.mockStatic(PluginErrorRemindHandler.class);
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once();
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once();
PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class);
PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once();
dialog.setVisible(true);
EasyMock.expectLastCall();
EasyMock.replay(selectedEnv, dialog);
PowerMock.replayAll();
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
entrance.pluginErrorRemind(selectedEnv);
entrance.pluginErrorRemind(selectedEnv);
entrance.pluginErrorRemind(selectedEnv);
EasyMock.verify(selectedEnv, dialog);
PowerMock.verifyAll();
} catch (Exception e) {
Assert.fail();
}
}
}

155
designer-base/src/test/java/com/fr/design/extra/PluginOperateUtilsTest.java

@ -0,0 +1,155 @@
package com.fr.design.extra;
import com.fr.invoke.Reflect;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.context.PluginMarkerAdapter;
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 org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
import java.util.List;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/12/17
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({PluginManager.class, PluginUtils.class})
public class PluginOperateUtilsTest {
@Test
public void testGetSuccessInfo() {
PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class);
PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class);
PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class);
List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>();
pluginTaskResults1.add(pluginTaskResult1);
List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>();
pluginTaskResults2.add(pluginTaskResult1);
pluginTaskResults2.add(pluginTaskResult2);
PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0");
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2");
PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1);
PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2);
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2);
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2);
EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes();
EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes();
EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes();
EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes();
PluginContext plugin1 = EasyMock.mock(PluginContext.class);
PluginContext plugin2 = EasyMock.mock(PluginContext.class);
EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes();
EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes();
PowerMock.mockStatic(PluginManager.class);
EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID()))
.andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once();
EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID()))
.andReturn(plugin2).once().andReturn(null).once();
EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
PowerMock.replayAll();
// 1个
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem");
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem");
// 2个
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem");
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem");
EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
PowerMock.verifyAll();
}
@Test
public void testGetPluginName() {
PluginContext pluginContext = EasyMock.mock(PluginContext.class);
EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once();
PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1");
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2");
EasyMock.replay(pluginContext);
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), "");
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext");
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1");
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2");
EasyMock.verify(pluginContext);
}
@Test
public void testUpdateMarker2Online() {
try {
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
JSONObject object = new JSONObject(pluginJson);
PowerMock.mockStatic(PluginUtils.class);
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once();
PowerMock.replayAll();
PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker);
PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker);
Assert.assertTrue(marker1 instanceof PluginMarkerAdapter);
Assert.assertEquals(marker1.getPluginID(), "plugin-1");
Assert.assertEquals(marker1.getVersion(), "1.0");
Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)");
Assert.assertEquals(marker2, pluginMarker);
PowerMock.verifyAll();
} catch (Exception e) {
Assert.fail();
}
}
@Test
public void testUpdatePluginOnline() {
try {
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
JSONObject object = new JSONObject(pluginJson);
PowerMock.mockStatic(PluginUtils.class);
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once();
PowerMock.replayAll();
PluginOperateUtils.updatePluginOnline(pluginMarker, null);
PowerMock.verifyAll();
} catch (Exception e) {
Assert.fail();
}
}
}

23
designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java

@ -0,0 +1,23 @@
package com.fr.design.extra;
import com.fr.invoke.Reflect;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/12/18
*/
public class PluginUtilsTest {
@Test
public void testIsCompatibleCurrentEnv() {
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "~9.0").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get());
}
}

2
designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapAnchorMarkerPane.java

@ -19,7 +19,7 @@ public class VanChartMapAnchorMarkerPane extends BasicBeanPane<VanChartAttrMarke
private UISpinner anchorSize;
public VanChartMapAnchorMarkerPane() {
anchorSize = new UISpinner(0, Double.MAX_VALUE, 0.1, 12);
anchorSize = new UISpinner(0, Double.MAX_VALUE, 0.5, 28);
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Size")), anchorSize}

4
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -180,12 +180,12 @@ public class FormDesignerUI extends ComponentUI {
x1 = 0;
x2 = 6;
y2 = y1 = bounds.y - designer.getVerticalScaleValue() + (k == 1 ? 0 : bounds.height);
text = Utils.objectToString(bounds.y);
text = Utils.objectToString(y1 + designer.getVerticalScaleValue());
} else {
y1 = 0;
y2 = 6;
x1 = x2 = bounds.x - designer.getHorizontalScaleValue()+ (k == 3 ? 0 : bounds.width);
text = Utils.objectToString(bounds.x);
text = Utils.objectToString(x1 + designer.getHorizontalScaleValue());
}
text += com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel");
g2d.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR);

45
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -10,7 +10,10 @@ import com.fr.form.main.WidgetUtil;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout;
@ -18,7 +21,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.report.cell.DefaultTemplateCellElement;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -94,23 +96,40 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private boolean hasTestECReport() {
ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases();
for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) {
FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase();
Iterator it = elementCase.cellIterator();
if (!it.hasNext()) {
if (isTestECReport(elementCaseEditorProvider)) {
return true;
}
while (it.hasNext()) {
DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next();
Object value = ce.getValue();
if (isTestCell(value, ce.getStyle())) {
return true;
}
}
}
return false;
}
private boolean isTestECReport(ElementCaseEditorProvider elementCaseEditorProvider) {
FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase();
if (!isTestElementCaseEditor((ElementCaseEditor) elementCaseEditorProvider)) {
return false;
}
Iterator it = elementCase.cellIterator();
if (!it.hasNext()) {
return true;
}
while (it.hasNext()) {
DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next();
Object value = ce.getValue();
if (!isTestCell(value, ce.getStyle())) {
return false;
}
}
return true;
}
private boolean isTestElementCaseEditor(ElementCaseEditor editor) {
return editor.getToolBars().length == 0 && editor.getListenerSize() == 0
&& ComparatorUtils.equals(editor.getBorderStyle(), new LayoutBorderStyle())
&& ComparatorUtils.equals(editor.getMargin(), new PaddingMargin())
&& editor.getBackground() == null;
}
private boolean hasTestChart() {
final boolean[] hasTestChart = {false};
Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
@ -226,7 +245,7 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
if (componentID == null){
if (componentID == null) {
return;
}
JSONObject info = componentProcessInfoMap.get(componentID);

33
designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.template.info;
import com.fr.base.background.ColorBackground;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.form.main.Form;
import com.fr.form.ui.CardSwitchButton;
@ -21,6 +22,8 @@ import com.fr.report.worksheet.FormElementCase;
import org.junit.Assert;
import org.junit.Test;
import java.awt.Color;
/**
* Created by kerry on 2020-05-08
*/
@ -35,14 +38,36 @@ public class JFormProcessInfoTest {
wFitLayout.addWidget(editor);
form.setContainer(wFitLayout);
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form);
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result1);
boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result);
elementCase.addCellElement(new DefaultTemplateCellElement());
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result2);
result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result);
DefaultTemplateCellElement templateCellElement = new DefaultTemplateCellElement();
templateCellElement.setValue(123);
elementCase.addCellElement(templateCellElement);
result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertFalse(result);
elementCase.removeCellElement(templateCellElement);
result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result);
editor.setBackground(ColorBackground.getInstance(Color.WHITE));
result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertFalse(result);
editor.setBackground(null);
result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result);
}
@Test
public void testHasTestChart() {
Form form = new Form();

3
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -11,15 +11,14 @@ import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvi
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalType;
import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

331
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -49,6 +49,7 @@ import com.fr.stable.script.CalculatorUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.AssistUtils;
import com.fr.third.antlr.ANTLRException;
import com.fr.third.guava.collect.HashMultimap;
import javax.swing.JComponent;
import javax.swing.UIManager;
@ -73,6 +74,7 @@ import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class GridUI extends ComponentUI {
@ -91,6 +93,7 @@ public class GridUI extends ComponentUI {
protected List paintCellElementList = new ArrayList();
protected List paintCellElementRectangleList = new ArrayList();
protected List paginateLineList = new ArrayList(); // 分页线
protected HashMultimap<CellPosition, Integer> mergeCellElementTable = HashMultimap.create();
// 为了画白色的背景.
protected static Background WHITE_Backgorund = ColorBackground.getInstance(Color.WHITE);
// CellElementPainter
@ -247,7 +250,7 @@ public class GridUI extends ComponentUI {
- reportSettings.getFooterHeight().toPixD(resolution);
}
private void paintGridLine(Graphics g, Grid grid, double realWidth, double realHeight,
private void paintGridLine(Graphics g, Grid grid, TemplateElementCase report, double realWidth, double realHeight,
int resolution) {
Graphics2D g2d = (Graphics2D) g;
@ -257,22 +260,51 @@ public class GridUI extends ComponentUI {
// 分页线
paginateLineList.clear();
// 合并单元格
mergeCellElementTable.clear();
boolean isShowVerticalPaginateLine = grid.getPaginateLineShowType() == Grid.MULTIPLE_PAGINATE_LINE;
boolean isShowHorizontalPaginateLine = grid.getPaginateLineShowType() != Grid.NO_PAGINATE_LINE;
new DrawVerticalLineHelper(grid.getVerticalBeginValue(), verticalEndValue,
grid.isShowGridLine(), isShowVerticalPaginateLine, rowHeightList, paperPaintHeight,
paginateLineList, realWidth, resolution).iterateStart2End(g2d);
Iterator cells = report.intersect(grid.getHorizontalBeginValue(), grid.getVerticalBeginValue(),
horizontalEndValue - grid.getHorizontalBeginValue(), verticalEndValue - grid.getVerticalBeginValue());
while (cells.hasNext()) {
TemplateCellElement cellElement = (TemplateCellElement) cells.next();
if (cellElement == null) {
continue;
}
int columnSpan = cellElement.getColumnSpan();
int rowSpan = cellElement.getRowSpan();
if (columnSpan > 1 || rowSpan > 1) {
for (int c = 0; c < columnSpan - 1; c++) {
for (int r = 0; r < rowSpan; r++) {
mergeCellElementTable.put(CellPosition.value(cellElement.getRow() + r, cellElement.getColumn() + c), CellPosition.RIGHT);
}
}
for (int r = 0; r < rowSpan - 1; r++) {
for (int c = 0; c < columnSpan; c++) {
mergeCellElementTable.put(CellPosition.value(cellElement.getRow() + r, cellElement.getColumn() + c), CellPosition.BOTTOM);
}
}
}
}
GridRange gridRange = GridRange.range(grid.getHorizontalBeginValue(), horizontalEndValue, grid.getVerticalBeginValue(), verticalEndValue)
.rangeList(rowHeightList, columnWidthList)
.realSize(realWidth, realHeight);
new DrawVerticalLineHelper(gridRange, grid.isShowGridLine(),
isShowVerticalPaginateLine, paperPaintHeight,
paginateLineList, resolution).iterateStart2End(g2d);
new DrawHorizontalLineHelper(grid.getHorizontalBeginValue(), horizontalEndValue,
grid.isShowGridLine(), isShowHorizontalPaginateLine, columnWidthList, paperPaintWidth,
paginateLineList, realHeight, resolution).iterateStart2End(g2d);
new DrawHorizontalLineHelper(gridRange, grid.isShowGridLine(),
isShowHorizontalPaginateLine, paperPaintWidth,
paginateLineList, resolution).iterateStart2End(g2d);
}
/**
* 最后处理
*/
@Override
public void finalize() {
try {
super.finalize();
@ -285,80 +317,34 @@ public class GridUI extends ComponentUI {
}
private static abstract class DrawLineHelper {
private int startIndex;
private int endIndex;
protected GridRange gridRange;
private boolean showGridLine;
private boolean showPaginateLine;
protected boolean showGridLine;
protected boolean showPaginateLine;
private DynamicUnitList sizeList;
private double paperPaintSize;
protected double paperPaintSize;
private List paginateLineList;
protected List paginateLineList;
Line2D tmpLine2D = new Line2D.Double(0, 0, 0, 0);
private int resolution;
protected int resolution;
private static final double THRESHOLD = 1.0E-4D;
protected static final double THRESHOLD = 1.0E-4D;
DrawLineHelper(int startIndex, int endIndex, boolean showGridLine,
boolean showPaginateLine, DynamicUnitList sizeList, double paperPaintSize,
DrawLineHelper(GridRange gridRange, boolean showGridLine,
boolean showPaginateLine, double paperPaintSize,
List paginateLineList, int resolution) {
this.startIndex = startIndex;
this.endIndex = endIndex;
this.gridRange = gridRange;
this.showGridLine = showGridLine;
this.showPaginateLine = showPaginateLine;
this.sizeList = sizeList;
this.paperPaintSize = paperPaintSize;
this.paginateLineList = paginateLineList;
this.resolution = resolution;
}
protected void iterateStart2End(Graphics2D g2d) {
float tmpSize = 0, paperSumSize = 0, sumSize = 0;
for (int i = 0; i <= endIndex; i++) {
// denny: 开始
if (i == 0) {
i = startIndex;
// denny: 增加从0到Grid左边被hide的列宽
for (int k = 0; k < startIndex; k++) {
tmpSize = sizeList.get(k).toPixF(resolution);
paperSumSize += tmpSize;
if (paperSumSize >= paperPaintSize) {
paperSumSize = tmpSize;
}
}
}
// adjust height.
tmpSize = sizeList.get(i).toPixF(resolution);
paperSumSize += tmpSize;
if (showGridLine) {// paint line.
setLine2D((int) sumSize);
g2d.draw(tmpLine2D);
}
// paint paper margin line.
if (showPaginateLine && paperSumSize - paperPaintSize > THRESHOLD) {
paginateLineList.add(getPaginateLine2D((int) sumSize));
paperSumSize = tmpSize;
}
sumSize += tmpSize;
}
// paint 最后一个横线..
if (showGridLine) {
drawLastLine(g2d, (int) sumSize);
}
}
protected abstract void setLine2D(int sumSize);
protected abstract void iterateStart2End(Graphics2D g2d);
protected abstract Line2D.Double getPaginateLine2D(int sumSize);
@ -366,14 +352,12 @@ public class GridUI extends ComponentUI {
}
private class DrawVerticalLineHelper extends DrawLineHelper {
private double realWidth;
DrawVerticalLineHelper(int startIndex, int endIndex, boolean showGridLine,
boolean showPaginateLine, DynamicUnitList unitSizeList, double paperPaintSize,
List paginateLineList, double realWidth, int resolution) {
super(startIndex, endIndex, showGridLine, showPaginateLine, unitSizeList,
DrawVerticalLineHelper(GridRange gridRange, boolean showGridLine,
boolean showPaginateLine, double paperPaintSize,
List paginateLineList, int resolution) {
super(gridRange, showGridLine, showPaginateLine,
paperPaintSize, paginateLineList, resolution);
this.realWidth = realWidth;
}
@Override
@ -382,25 +366,58 @@ public class GridUI extends ComponentUI {
}
@Override
protected void setLine2D(int sumHeight) {
tmpLine2D.setLine(0, sumHeight, realWidth, sumHeight);
protected void drawLastLine(Graphics2D g2d, int sumHeight) {
GraphHelper.drawLine(g2d, 0, sumHeight, gridRange.realWidth, sumHeight);
}
@Override
protected void drawLastLine(Graphics2D g2d, int sumHeight) {
GraphHelper.drawLine(g2d, 0, sumHeight, realWidth, sumHeight);
protected void iterateStart2End(Graphics2D g2d) {
float rowHeight, paperYAxisSumSize = 0, yAxisSumSize = 0;
for (int i = 0; i <= gridRange.yEndIndex; i++) {
if (i == 0) {
i = gridRange.yBeginIndex;
for (int k = 0; k < gridRange.yBeginIndex; k++) {
rowHeight = gridRange.rowHeightList.get(k).toPixF(resolution);
paperYAxisSumSize += rowHeight;
if (paperYAxisSumSize >= paperPaintSize) {
paperYAxisSumSize = rowHeight;
}
}
}
rowHeight = gridRange.rowHeightList.get(i).toPixF(resolution);
paperYAxisSumSize += rowHeight;
if (showGridLine) {
float columnWidth, xAxisSumSize = 0;
for (int j = gridRange.xBeginIndex; j <= gridRange.xEndIndex; j++) {
columnWidth = gridRange.columnWidthList.get(j).toPixF(resolution);
if (!mergeCellElementTable.get(CellPosition.value(i - 1, j)).contains(CellPosition.BOTTOM)) {
tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize + columnWidth, yAxisSumSize);
g2d.draw(tmpLine2D);
}
xAxisSumSize += columnWidth;
}
}
if (showPaginateLine && paperYAxisSumSize - paperPaintSize > THRESHOLD) {
paginateLineList.add(getPaginateLine2D((int) yAxisSumSize));
paperYAxisSumSize = rowHeight;
}
yAxisSumSize += rowHeight;
}
// paint 最后一个横线..
if (showGridLine) {
drawLastLine(g2d, (int) yAxisSumSize);
}
}
}
private class DrawHorizontalLineHelper extends DrawLineHelper {
private double realHeight;
DrawHorizontalLineHelper(int startIndex, int endIndex, boolean showGridLine,
boolean showPaginateLine, DynamicUnitList unitSizeList, double paperPaintSize,
List paginateLineList, double realHeight, int resolution) {
super(startIndex, endIndex, showGridLine, showPaginateLine, unitSizeList,
DrawHorizontalLineHelper(GridRange gridRange, boolean showGridLine,
boolean showPaginateLine, double paperPaintSize,
List paginateLineList, int resolution) {
super(gridRange, showGridLine, showPaginateLine,
paperPaintSize, paginateLineList, resolution);
this.realHeight = realHeight;
}
@Override
@ -409,13 +426,47 @@ public class GridUI extends ComponentUI {
}
@Override
protected void setLine2D(int sumWidth) {
tmpLine2D.setLine(sumWidth, 0, sumWidth, realHeight);
protected void drawLastLine(Graphics2D g2d, int sumWidth) {
GraphHelper.drawLine(g2d, sumWidth, 0, sumWidth, gridRange.realHeight);
}
@Override
protected void drawLastLine(Graphics2D g2d, int sumWidth) {
GraphHelper.drawLine(g2d, sumWidth, 0, sumWidth, realHeight);
protected void iterateStart2End(Graphics2D g2d) {
float columnWidth, paperXAxisSumSize = 0, xAxisSumSize = 0;
for (int i = 0; i <= gridRange.xEndIndex; i++) {
if (i == 0) {
i = gridRange.xBeginIndex;
for (int k = 0; k < gridRange.xBeginIndex; k++) {
columnWidth = gridRange.columnWidthList.get(k).toPixF(resolution);
paperXAxisSumSize += columnWidth;
if (paperXAxisSumSize >= paperPaintSize) {
paperXAxisSumSize = columnWidth;
}
}
}
columnWidth = gridRange.columnWidthList.get(i).toPixF(resolution);
paperXAxisSumSize += columnWidth;
if (showGridLine) {
float rowHeight, yAxisSumSize = 0;
for (int j = gridRange.yBeginIndex; j <= gridRange.yEndIndex; j++) {
rowHeight = gridRange.rowHeightList.get(j).toPixF(resolution);
if (!mergeCellElementTable.get(CellPosition.value(j, i - 1)).contains(CellPosition.RIGHT)) {
tmpLine2D.setLine(xAxisSumSize, yAxisSumSize, xAxisSumSize, yAxisSumSize + rowHeight);
g2d.draw(tmpLine2D);
}
yAxisSumSize += rowHeight;
}
}
if (showPaginateLine && paperXAxisSumSize - paperPaintSize > THRESHOLD) {
paginateLineList.add(getPaginateLine2D((int) xAxisSumSize));
paperXAxisSumSize = columnWidth;
}
xAxisSumSize += columnWidth;
}
// paint 最后一个横线..
if (showGridLine) {
drawLastLine(g2d, (int) xAxisSumSize);
}
}
}
@ -482,18 +533,6 @@ public class GridUI extends ComponentUI {
// peter:tmpRectangle2D_3只是一个临时的Rectangle2D,由于后面不少地方需要用到这个矩形
this.cell_back_rect.setRect(0, 0, this.tmpRectangle.getWidth() - 1,
this.tmpRectangle.getHeight() - 1.5);
// peter:对于合并的单元格,需要先白色的背景来清除背景.
if (tmpCellElement.getColumnSpan() > 1 || tmpCellElement.getRowSpan() > 1) {
// REPORT-23492 要看下是否设置了纸张背景 如果设置了按照背景来画
ReportSettingsProvider reportSettings = getReportSettings(report);
Background currentBackground = reportSettings.getBackground();
if (currentBackground != null) {
currentBackground.paint(g2d, this.cell_back_rect);
} else {
WHITE_Backgorund.paint(g2d, this.cell_back_rect);
}
//daniel:上面这里就有问题了啊....报表的背景在这个之前画的 会覆盖报表背景....不过只是设计器中看到预览浏览没问题
}
// peter:将这个元素添加到需要paint的元素列表当中去,留着画边框线..
paintCellElementList.add(tmpCellElement);
paintCellElementRectangleList.add(this.tmpRectangle.clone());
@ -1093,8 +1132,7 @@ public class GridUI extends ComponentUI {
this.paintBackground(g2d, grid, elementCase, resolution);
// 画Grid Line
this.paintGridLine(g2d, grid, realWidth, realHeight, resolution);
this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution);
// peter:添上线程的支持,有时候,paint元素的时候,可能会有元素被删除了.
// 需要先清除画Border需要的元素.
paintCellElementList.clear();
@ -1277,4 +1315,101 @@ public class GridUI extends ComponentUI {
paginateLineList.add(new Line2D.Double(0, sumHeight, width, sumHeight));
}
}
/**
* 描述单元格位置的POJO
*/
private static class CellPosition {
public final static int TOP = 0;
public static final int LEFT = 1;
public final static int BOTTOM = 2;
public static final int RIGHT = 4;
public int x;
public int y;
public CellPosition(int x, int y) {
this.x = x;
this.y = y;
}
public static CellPosition value(int x, int y) {
return new CellPosition(x, y);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CellPosition that = (CellPosition) o;
return x == that.x && y == that.y;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
}
/**
* 描述表格范围的POJO
* x轴为水平方向对应的宽度表为列宽列表
* y轴为垂直方向对应的宽度表为行高列表
*/
private static class GridRange {
public int xBeginIndex;
public int xEndIndex;
public int yBeginIndex;
public int yEndIndex;
double realWidth;
double realHeight;
/**
* 行高列表对应y方向线段
*/
public DynamicUnitList rowHeightList;
/**
* 列宽列表对应x方向线段
*/
public DynamicUnitList columnWidthList;
public GridRange(int xBeginIndex, int xEndIndex, int yBeginIndex, int yEndIndex) {
this.xBeginIndex = xBeginIndex;
this.xEndIndex = xEndIndex;
this.yBeginIndex = yBeginIndex;
this.yEndIndex = yEndIndex;
}
/**
* 设置行高列宽列表
*
* @param rowHeightList 行高列表
* @param columnWidthList 列宽列表
*/
public GridRange rangeList(DynamicUnitList rowHeightList, DynamicUnitList columnWidthList) {
this.rowHeightList = rowHeightList;
this.columnWidthList = columnWidthList;
return this;
}
/**
* 设置表格真实宽高
*
* @param realWidth 宽度
* @param realHeight 高度
*/
public GridRange realSize(double realWidth, double realHeight) {
this.realWidth = realWidth;
this.realHeight = realHeight;
return this;
}
public static GridRange range(int xBeginIndex, int xEndIndex, int yBeginIndex, int yEndIndex) {
return new GridRange(xBeginIndex, xEndIndex, yBeginIndex, yEndIndex);
}
}
}

1
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -71,6 +71,7 @@ public class DesignerWorkspaceProvider extends Activator {
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("Check Service Failed");
}
EnvChangeEntrance.getInstance().pluginErrorRemind(selectEnv);
}
});
}

25
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java

@ -0,0 +1,25 @@
package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.invoke.Reflect;
import org.junit.Assert;
import org.junit.Test;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/12/17
*/
public class PluginSearchManagerTest {
@Test
public void testIsCompatibleCurrentEnv() {
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "~9.0").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get());
}
}
Loading…
Cancel
Save