Browse Source

Merge branch 'feature/big-screen' of ssh://code.fineres.com:7999/~zheng/C-design into feature/big-screen

feature/big-screen
shine 3 years ago
parent
commit
1d8923241d
  1. 27
      build.gradle
  2. 122
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 6
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 339
      designer-base/src/main/java/com/fr/design/VersionCheckUtils.java
  5. 65
      designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java
  6. 60
      designer-base/src/main/java/com/fr/design/actions/community/BugAction.java
  7. 17
      designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java
  8. 72
      designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java
  9. 13
      designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java
  10. 70
      designer-base/src/main/java/com/fr/design/actions/community/SignAction.java
  11. 21
      designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java
  12. 80
      designer-base/src/main/java/com/fr/design/actions/community/UpAction.java
  13. 60
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  14. 9
      designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java
  15. 31
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  16. 3
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  17. 277
      designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java
  18. 17
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  19. 17
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  20. 4
      designer-base/src/main/java/com/fr/design/extra/LoginContextListener.java
  21. 38
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  22. 6
      designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java
  23. 12
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  24. 6
      designer-base/src/main/java/com/fr/design/extra/PluginUpdatePane.java
  25. 21
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  26. 5
      designer-base/src/main/java/com/fr/design/extra/UserLoginContext.java
  27. 2
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  28. 7
      designer-base/src/main/java/com/fr/design/extra/exe/PluginLoginExecutor.java
  29. 1
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  30. 19
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java
  31. 92
      designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java
  32. 280
      designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java
  33. 104
      designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java
  34. 42
      designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java
  35. 45
      designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java
  36. 29
      designer-base/src/main/java/com/fr/design/login/DesignerLoginSource.java
  37. 29
      designer-base/src/main/java/com/fr/design/login/DesignerLoginType.java
  38. 49
      designer-base/src/main/java/com/fr/design/login/bean/BBSAccountLogin.java
  39. 226
      designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java
  40. 30
      designer-base/src/main/java/com/fr/design/login/executor/DesignerLoginBrowserExecutor.java
  41. 45
      designer-base/src/main/java/com/fr/design/login/executor/DesignerLoginExecutor.java
  42. 45
      designer-base/src/main/java/com/fr/design/login/executor/DesignerSendCaptchaExecutor.java
  43. 47
      designer-base/src/main/java/com/fr/design/login/executor/DesignerSmsLoginExecutor.java
  44. 49
      designer-base/src/main/java/com/fr/design/login/executor/DesignerSmsRegisterExecutor.java
  45. 83
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java
  46. 114
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  47. 37
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java
  48. 35
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideShowDialog.java
  49. 19
      designer-base/src/main/java/com/fr/design/login/guide/utils/DesignerGuideUtils.java
  50. 167
      designer-base/src/main/java/com/fr/design/login/service/DesignerLoginClient.java
  51. 82
      designer-base/src/main/java/com/fr/design/login/service/DesignerLoginResult.java
  52. 114
      designer-base/src/main/java/com/fr/design/login/service/DesignerPassportManager.java
  53. 87
      designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java
  54. 51
      designer-base/src/main/java/com/fr/design/login/task/DesignerLoginTaskWorker.java
  55. 35
      designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java
  56. 5
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  57. 18
      designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java
  58. 12
      designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java
  59. 2
      designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java
  60. 5
      designer-base/src/main/java/com/fr/design/mod/ModClassFilter.java
  61. 10
      designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java
  62. 5
      designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java
  63. 10
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  64. 87
      designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java
  65. 134
      designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java
  66. 50
      designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java
  67. 16
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  68. 2
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  69. 4
      designer-base/src/main/java/com/fr/design/upm/event/CertificateEvent.java
  70. 424
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  71. 73
      designer-base/src/main/java/com/fr/env/ErrorDialog.java
  72. 119
      designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java
  73. 105
      designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java
  74. 4
      designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties
  75. 4
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties
  76. 4
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties
  77. 4
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties
  78. 4
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties
  79. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/arrowright.png
  80. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/bigfail.png
  81. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/fail.png
  82. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/question.png
  83. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/success.png
  84. BIN
      designer-base/src/main/resources/com/fr/design/icon/versioncheck/warning.png
  85. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/TipIcon.png
  86. BIN
      designer-base/src/main/resources/com/fr/design/images/m_file/preview_sql.png
  87. 2
      designer-base/src/main/resources/com/fr/design/login/designer_login.properties
  88. 52
      designer-base/src/main/resources/com/fr/design/login/guide.css
  89. 25
      designer-base/src/main/resources/com/fr/design/login/guide.html
  90. 1
      designer-base/src/main/resources/com/fr/design/login/guide.js
  91. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_cantuse.png
  92. 23
      designer-base/src/main/resources/com/fr/design/login/img/icon_close40x40_normal.svg
  93. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_close9x9_hover.png
  94. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_close9x9_normal.png
  95. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_close_normal.png
  96. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_disable-new.png
  97. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_disable.png
  98. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_marked.png
  99. BIN
      designer-base/src/main/resources/com/fr/design/login/img/icon_new.png
  100. BIN
      designer-base/src/main/resources/com/fr/design/login/img/login_guide.png
  101. Some files were not shown because too many files have changed in this diff Show More

27
build.gradle

@ -28,6 +28,17 @@ dependencies {
api project(':designer-realize') api project(':designer-realize')
} }
configurations.all {
resolutionStrategy {
force 'com.fr.third:jxbrowser:6.23'
force 'com.fr.third:jxbrowser-mac:6.23'
force 'com.fr.third:jxbrowser-win64:6.23'
force 'com.fr.third:jxbrowser:7.5'
force 'com.fr.third:jxbrowser-mac:7.5'
force 'com.fr.third:jxbrowser-win64:7.5'
}
}
allprojects { allprojects {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'java-library' apply plugin: 'java-library'
@ -57,9 +68,19 @@ allprojects {
} }
dependencies { dependencies {
implementation 'com.fr.third:jxbrowser:6.23' implementation ('com.fr.third:jxbrowser:6.23') {
implementation 'com.fr.third:jxbrowser-mac:6.23' force = true
implementation 'com.fr.third:jxbrowser-win64:6.23' }
implementation ('com.fr.third:jxbrowser-mac:6.23') {
force = true
}
implementation ('com.fr.third:jxbrowser-win64:6.23') {
force = true
}
implementation 'com.fr.third:jxbrowser:7.5'
implementation 'com.fr.third:jxbrowser-mac:7.5'
implementation 'com.fr.third:jxbrowser-win64:7.5'
implementation 'com.fr.third:jxbrowser-swing:7.5'
implementation 'com.fr.third.server:servlet-api:3.0' implementation 'com.fr.third.server:servlet-api:3.0'
implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swexpl:2.0.1'
implementation 'org.swingexplorer:swag:1.0' implementation 'org.swingexplorer:swag:1.0'

122
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -18,6 +18,8 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.config.DesignerLoginConfigManager;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.notification.SnapChatConfig; import com.fr.design.notification.SnapChatConfig;
import com.fr.design.port.DesignerPortContext; import com.fr.design.port.DesignerPortContext;
@ -195,6 +197,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private ComponentReuseNotificationInfo notificationInfo = ComponentReuseNotificationInfo.getInstance(); private ComponentReuseNotificationInfo notificationInfo = ComponentReuseNotificationInfo.getInstance();
private DesignerLoginConfigManager designerLoginConfigManager = DesignerLoginConfigManager.getInstance();
/** /**
* DesignerEnvManager. * DesignerEnvManager.
*/ */
@ -738,6 +742,113 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
designerPushUpdateConfigManager.setAutoPushUpdateEnabled(autoPushUpdateEnabled); designerPushUpdateConfigManager.setAutoPushUpdateEnabled(autoPushUpdateEnabled);
} }
/**
* 设计器登录相关配置
*/
public void setDesignerLoginUid(int uid) {
designerLoginConfigManager.setUid(uid);
}
public int getDesignerLoginUid() {
return designerLoginConfigManager.getUid();
}
public void setDesignerLoginUsername(String username) {
designerLoginConfigManager.setUsername(username);
}
public String getDesignerLoginUsername() {
return designerLoginConfigManager.getUsername();
}
public void setDesignerLoginAppId(String appId) {
designerLoginConfigManager.setAppId(appId);
}
public String getDesignerLoginAppId() {
return designerLoginConfigManager.getAppId();
}
public void setDesignerLoginRefreshToken(String refreshToken) {
designerLoginConfigManager.setRefreshToken(refreshToken);
}
public String getDesignerLoginRefreshToken() {
return designerLoginConfigManager.getRefreshToken();
}
public void setDesignerLoginDoNotRemind(boolean doNotRemind) {
designerLoginConfigManager.setDoNotRemind(doNotRemind);
}
public boolean isDesignerLoginDoNotRemind() {
return designerLoginConfigManager.isDoNotRemind();
}
public void setDesignerLoginDoNotRemindSelectedTime(long doNotRemindSelectedTime) {
designerLoginConfigManager.setDoNotRemindSelectedTime(doNotRemindSelectedTime);
}
public long getDesignerLoginDoNotRemindSelectedTime() {
return designerLoginConfigManager.getDoNotRemindSelectedTime();
}
public void setDesignerActivatedTime(long designerActivatedTime) {
designerLoginConfigManager.setDesignerActivatedTime(designerActivatedTime);
}
public long getDesignerActivatedTime() {
return designerLoginConfigManager.getDesignerActivatedTime();
}
public void setDesignerLastLoginTime(long lastLoginTime) {
designerLoginConfigManager.setLastLoginTime(lastLoginTime);
}
public long getDesignerLastLoginTime() {
return designerLoginConfigManager.getLastLoginTime();
}
public void setCurrentVersionFirstLaunch(boolean currentVersionFirstLaunch) {
designerLoginConfigManager.setCurrentVersionFirstLaunch(currentVersionFirstLaunch);
}
public boolean isCurrentVersionFirstLaunch() {
return designerLoginConfigManager.isCurrentVersionFirstLaunch();
}
public DesignerLoginType getLastLoginType() {
return designerLoginConfigManager.getLastLoginType();
}
public void setLastLoginType(DesignerLoginType lastLoginType) {
designerLoginConfigManager.setLastLoginType(lastLoginType);
}
public String getLastLoginAccount() {
return designerLoginConfigManager.getLastLoginAccount();
}
public void setLastLoginAccount(String lastLoginAccount) {
designerLoginConfigManager.setLastLoginAccount(lastLoginAccount);
}
public boolean isLoginRemindBeforeJumpBBS() {
return designerLoginConfigManager.isLoginRemindBeforeJumpBBS();
}
public void setLoginRemindBeforeJumpBBS(boolean loginRemindBeforeJumpBBS) {
designerLoginConfigManager.setLoginRemindBeforeJumpBBS(loginRemindBeforeJumpBBS);
}
public boolean isPluginRemindOnFirstLaunch() {
return designerLoginConfigManager.isPluginRemindOnFirstLaunch();
}
public void setPluginRemindOnFirstLaunch(boolean pluginRemindOnFirstLaunch) {
designerLoginConfigManager.setPluginRemindOnFirstLaunch(pluginRemindOnFirstLaunch);
}
/** /**
* 内置服务器是否使用时启动 * 内置服务器是否使用时启动
* *
@ -1579,6 +1690,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
readDesignerPort(reader); readDesignerPort(reader);
} else if (name.equals(SnapChatConfig.XML_TAG)) { } else if (name.equals(SnapChatConfig.XML_TAG)) {
readSnapChatConfig(reader); readSnapChatConfig(reader);
} else if (name.equals(DesignerLoginConfigManager.XML_TAG)) {
readDesignerLoginAttr(reader);
} else { } else {
readLayout(reader, name); readLayout(reader, name);
} }
@ -1811,6 +1924,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeDesignerPort(writer); writeDesignerPort(writer);
writeSnapChatConfig(writer); writeSnapChatConfig(writer);
writeComponentReuseNotificationInfo(writer); writeComponentReuseNotificationInfo(writer);
writeDesignerLoginAttr(writer);
writer.end(); writer.end();
} }
@ -2088,6 +2202,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.vcsConfigManager = vcsConfigManager; this.vcsConfigManager = vcsConfigManager;
} }
private void readDesignerLoginAttr(XMLableReader reader) {
reader.readXMLObject(designerLoginConfigManager);
}
private void writeDesignerLoginAttr(XMLPrintWriter writer) {
this.designerLoginConfigManager.writeXML(writer);
}
enum XmlHandler { enum XmlHandler {
Self; Self;
public void handle(Throwable throwable) { public void handle(Throwable throwable) {

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

@ -22,6 +22,7 @@ import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL; import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.TestConnectionResult; import com.fr.env.TestConnectionResult;
import com.fr.env.VersionCheckMessageDialog;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -96,6 +97,7 @@ public class EnvChangeEntrance {
*/ */
public void switch2Env(final String envName) { public void switch2Env(final String envName) {
switch2Env(envName, PopTipStrategy.LATER); switch2Env(envName, PopTipStrategy.LATER);
VersionCheckUtils.showVersionCheckDialog(envName);
} }
/** /**
@ -145,7 +147,6 @@ public class EnvChangeEntrance {
if (template != null) { if (template != null) {
template.refreshToolArea(); template.refreshToolArea();
} }
showServiceDialog(selectedEnv);
pluginErrorRemind(); pluginErrorRemind();
} catch (WorkspaceAuthException | RegistEditionException e) { } catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
@ -294,8 +295,7 @@ public class EnvChangeEntrance {
if(StringUtils.isEmpty(areaText)){ if(StringUtils.isEmpty(areaText)){
return; return;
} }
CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch);
dialog.setVisible(true);
} }
} }
} }

339
designer-base/src/main/java/com/fr/design/VersionCheckUtils.java

@ -0,0 +1,339 @@
package com.fr.design;
import com.fr.base.FRContext;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.VersionCheckMessageDialog;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.manage.control.PluginControllerHelper;
import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.manage.control.ProgressCallback;
import com.fr.rpc.Result;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.base.WorkspaceAPI;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import java.lang.reflect.Method;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/**
* @author pengda
* @version 10.0
* Created on 2021-06-02
*/
public class VersionCheckUtils {
public static final String INCONSISTENCY = "inconsistency";
public static final String MISSING = "missing";
private static final String ID = "id";
private static final String VERSION = "version";
private static final String NAME = "name";
public static boolean versionCheck(String envName) {
return checkLocalAndRemoteJartime(envName) && checkLocalAndRemotePlugin().size() == 0;
}
public static boolean versionCheck(DesignerWorkspaceInfo selectedEnv) {
return checkLocalAndRemoteJartime(selectedEnv) && checkLocalAndRemotePlugin().size() == 0;
}
public static void showVersionCheckDialog(String envName) {
if (!VersionCheckUtils.versionCheck(envName)) {
VersionCheckMessageDialog versionCheckMessageDialog = new VersionCheckMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), envName);
versionCheckMessageDialog.setVisible(true);
}
}
public static boolean checkLocalAndRemoteJartime(String envName) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
return checkLocalAndRemoteJartime(selectedEnv);
}
public static boolean checkLocalAndRemoteJartime(DesignerWorkspaceInfo selectedEnv) {
//是否需要做服务校验
if (needCheckBranch(selectedEnv)) {
String localBranch;
String remoteBranch = getRemoteBranch(selectedEnv);
localBranch = GeneralUtils.readFullBuildNO();
//通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本)
if (localBranch.contains("#") && ComparatorUtils.equals(localBranch, remoteBranch)) {
//说明版本一致,仅做日志记录
FineLoggerFactory.getLogger().info("Remote Designer version consistency");
return true;
} else {
return false;
}
}
return true;
}
public static List<String> getNoExistServiceDescription(String envName) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
List<String> noExistServiceDescription = new ArrayList<>();
Set<Class> noExistServiceSet = getNoExistServiceSet(connectionInfo);
for (Class clazz : noExistServiceSet) {
WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class);
if (workspaceAPI == null) {
FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz);
continue;
}
if (workspaceAPI.ignore()) {
continue;
}
String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description());
noExistServiceDescription.add(descriptionOfCN);
}
return noExistServiceDescription;
}
public static String getRemoteBranch(String envName) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
return getRemoteBranch(selectedEnv);
}
public static String getRemoteBranch(DesignerWorkspaceInfo selectedEnv) {
String remoteBranch = StringUtils.EMPTY;
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
try {
remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch();
} catch (WorkspaceConnectionException e) {
remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(GeneralUtils.readFullBuildNO());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return remoteBranch;
}
/**
* 获取不存在的服务列表
*
* @param info 环境连接信息
* @return 以Set形式返回不存在的服务
*/
public static Set<Class> getNoExistServiceSet(WorkspaceConnectionInfo info) {
Set<Class> noExistServiceSet = new HashSet<Class>();
Set<Class> remoteServiceSet = new HashSet<Class>();
Set<Class> localServiceSet = FineObjectPool.getInstance().getServerPool().keySet();
try {
JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList();
for (int i = 0; i < serviceArray.size(); i++) {
try {
Class clazz = Class.forName((String) serviceArray.get(i));
remoteServiceSet.add(clazz);
} catch (Exception e) {
continue;
}
}
noExistServiceSet.addAll(localServiceSet);
noExistServiceSet.removeAll(remoteServiceSet);
return noExistServiceSet;
} catch (WorkspaceConnectionException e) {
FineLoggerFactory.getLogger().info(e.getMessage());
//根据本地的服务列表做逐一检测
for (Class clazz : localServiceSet) {
Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get();
WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool();
Result result = proxyPool.testInvoker(testMethod);
Exception invokeException = (Exception) result.getException();
if (invokeException != null) {
Exception cause = (Exception) invokeException.getCause();
//获取被包装最底层的异常
while (cause != null) {
invokeException = cause;
cause = (Exception) invokeException.getCause();
}
//该异常表示服务不存在
if (invokeException instanceof ClassNotFoundException) {
noExistServiceSet.add(clazz);
}
}
}
return noExistServiceSet;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return noExistServiceSet;
}
}
/**
* 格式化分支版本号
*
* @param buildNO 初始的分支版本号
* @return 格式化后的版本号
*/
private static String formatBranch(String buildNO) {
Date jarDate = (new SimpleDateFormat("yyyy.MM.dd")).parse(buildNO, new ParsePosition(buildNO.indexOf("-") + 1));
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(jarDate);
}
private static boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
return true;
}
return false;
}
public static JSONArray checkLocalAndRemotePlugin() {
JSONArray differentPlugins = new JSONArray();
JSONArray remotePlugins = FRContext.getCommonOperator().getPluginStatus();
Map<String, PluginContext> localPluginsMap = new HashMap<>();
List<PluginContext> localPlugins = PluginManager.getContexts();
for (PluginContext pluginContext : localPlugins) {
localPluginsMap.put(pluginContext.getID(), pluginContext);
}
JSONObject remotePlugin;
for (int i = 0; i < remotePlugins.size(); i++) {
remotePlugin = remotePlugins.getJSONObject(i);
if (localPluginsMap.containsKey(remotePlugin.getString(ID))) {
if (ComparatorUtils.equals(localPluginsMap.get(remotePlugin.getString(ID)).getVersion(), remotePlugin.getString(VERSION))) {
continue;
} else {
if (remotePlugin.getString(NAME) == null) {
remotePlugin.put(NAME, localPluginsMap.get(remotePlugin.getString(ID)).getName());
}
remotePlugin.put("type", INCONSISTENCY);
}
}
remotePlugin.put("type", MISSING);
if (remotePlugin.getString(NAME) == null) {
remotePlugin.put(NAME, remotePlugin.getString("id"));
}
differentPlugins.put(remotePlugin);
}
return differentPlugins;
}
public static JSONArray syncPlugins(JSONArray differentPlugins) {
Set<String> uninstallFailed = uninstallPlugins(differentPlugins);
List<PluginMarker> plugins = getSyncPlugins(differentPlugins, uninstallFailed);
installPlugins(plugins);
return getPluginsSyncFailed(differentPlugins);
}
private static List<PluginMarker> getSyncPlugins(JSONArray differentPlugins, Set<String> uninstallFailed) {
JSONObject differentPlugin;
String id;
String version;
List<PluginMarker> plugins = new ArrayList<>();
if (differentPlugins != null) {
for (int i = 0; i < differentPlugins.size(); i++) {
differentPlugin = differentPlugins.getJSONObject(i);
id = differentPlugin.getString(ID);
if (uninstallFailed.contains(id)) {
continue;
}
version = differentPlugin.getString(VERSION);
plugins.add(PluginMarker.create(id, version));
}
}
return plugins;
}
private static Set<String> uninstallPlugins(JSONArray differentPlugins) {
Set<PluginMarker> pluginsNeedUninstall = new HashSet<>();
Map<String, PluginContext> localPluginsMap = new HashMap<>();
List<PluginContext> localPlugins = PluginManager.getContexts();
for (PluginContext pluginContext : localPlugins) {
localPluginsMap.put(pluginContext.getID(), pluginContext);
}
for (int i = 0; i < differentPlugins.size(); i++) {
String id = differentPlugins.getJSONObject(i).getString(ID);
if (localPluginsMap.containsKey(id)) {
pluginsNeedUninstall.add(localPluginsMap.get(id).getMarker());
}
}
Set<String> uninstallFailedID = new HashSet<>();
CountDownLatch latch = new CountDownLatch(pluginsNeedUninstall.size());
for (PluginMarker pluginMarker : pluginsNeedUninstall) {
PluginManager.getController().uninstall(pluginMarker, true, new PluginTaskCallback() {
@Override
public void done(PluginTaskResult result) {
latch.countDown();
if (!result.isSuccess()) {
uninstallFailedID.add(pluginMarker.getPluginID());
}
}
});
}
try {
latch.await(5000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return uninstallFailedID;
}
private static JSONArray getPluginsSyncFailed(JSONArray differentPlugins){
JSONArray pluginsNeedSync = JSONArray.create();
List<PluginContext> localPlugins = PluginManager.getContexts();
Map<String, String> localPluginsInfo = new HashMap<>();
for (int i = 0; i < localPlugins.size(); i++) {
localPluginsInfo.put(localPlugins.get(i).getID(), localPlugins.get(i).getVersion());
}
for (int i = 0; i < differentPlugins.size(); i++) {
JSONObject plugin = differentPlugins.getJSONObject(i);
String id = plugin.getString(ID);
if (localPluginsInfo.containsKey(id) && ComparatorUtils.equals(plugin.getString(VERSION), localPluginsInfo.get(id))) {
continue;
}
pluginsNeedSync.add(plugin);
}
return pluginsNeedSync;
}
private static void installPlugins(List<PluginMarker> plugins) {
CountDownLatch latch = new CountDownLatch(plugins.size());
for (int i = 0; i < plugins.size(); i++) {
PluginControllerHelper.installOnline(plugins.get(i), new ProgressCallback() {
@Override
public void updateProgress(String description, double progress) {
}
@Override
public void done(PluginTaskResult result) {
latch.countDown();
}
});
}
try {
latch.await();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

65
designer-base/src/main/java/com/fr/design/actions/community/BBSAction.java

@ -1,54 +1,43 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; public class BBSAction extends AbstractDesignerSSO {
public class BBSAction extends UpdateAction
{
public BBSAction() {
this.setMenuKeySet(BBS);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/bbs");
public BBSAction() }
{
this.setMenuKeySet(BBS);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/bbs");
}
/**
* 动作
* @param arg0 事件
*/
@Override @Override
public void actionPerformed(ActionEvent arg0) public String getJumpUrl() {
{ return CloudCenter.getInstance().acquireUrlByKind("bbs");
String url = CloudCenter.getInstance().acquireUrlByKind("bbs");
BrowseUtils.browser(url);
} }
public static final MenuKeySet BBS = new MenuKeySet() {
@Override public static final MenuKeySet BBS = new MenuKeySet() {
public char getMnemonic() { @Override
return 'B'; public char getMnemonic() {
} return 'B';
}
@Override
public String getMenuName() { @Override
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Bbs"); public String getMenuName() {
} return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Bbs");
}
@Override
public KeyStroke getKeyStroke() { @Override
return null; public KeyStroke getKeyStroke() {
} return null;
}; }
};
} }

60
designer-base/src/main/java/com/fr/design/actions/community/BugAction.java

@ -1,50 +1,42 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; public class BugAction extends AbstractDesignerSSO {
public class BugAction extends UpdateAction public BugAction() {
{ this.setMenuKeySet(BUG);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/bug");
}
public BugAction() @Override
{ this.setMenuKeySet(BUG); public String getJumpUrl() {
this.setName(getMenuKeySet().getMenuName()); return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs");
this.setMnemonic(getMenuKeySet().getMnemonic()); }
this.setSmallIcon("/com/fr/design/images/bbs/bug");
}
@Override
public void actionPerformed(ActionEvent arg0)
{
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.bugs");
BrowseUtils.browser(url);
} public static final MenuKeySet BUG = new MenuKeySet() {
public static final MenuKeySet BUG = new MenuKeySet() {
@Override @Override
public String getMenuName() { public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Bug"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Bug");
} }
@Override @Override
public KeyStroke getKeyStroke() { public KeyStroke getKeyStroke() {
return null; return null;
} }
@Override @Override
public char getMnemonic() public char getMnemonic() {
{
return 'U'; return 'U';
} }
}; };
} }

17
designer-base/src/main/java/com/fr/design/actions/community/CenterAction.java

@ -1,33 +1,26 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/** /**
* Created by XINZAI on 2018/8/23. * Created by XINZAI on 2018/8/23.
*/ */
public class CenterAction extends UpAction{ public class CenterAction extends UpAction {
public CenterAction() public CenterAction() {
{
this.setMenuKeySet(CENTER); this.setMenuKeySet(CENTER);
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/center"); this.setSmallIcon("/com/fr/design/images/bbs/center");
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) public String getJumpUrl() {
{ return CloudCenter.getInstance().acquireUrlByKind("bbs.center");
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.center");
BrowseUtils.browser(url);
} }
public static final MenuKeySet CENTER = new MenuKeySet() { public static final MenuKeySet CENTER = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {

72
designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java

@ -1,49 +1,41 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; public class NeedAction extends AbstractDesignerSSO {
public class NeedAction extends UpdateAction public NeedAction() {
{ this.setMenuKeySet(NEED);
this.setName(getMenuKeySet().getMenuName());
public NeedAction() this.setMnemonic(getMenuKeySet().getMnemonic());
{ this.setSmallIcon("/com/fr/design/images/bbs/need");
this.setMenuKeySet(NEED);
this.setName(getMenuKeySet().getMenuName()); }
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/need"); @Override
public String getJumpUrl() {
} return CloudCenter.getInstance().acquireUrlByKind("bbs.needs");
}
@Override
public void actionPerformed(ActionEvent arg0) public static final MenuKeySet NEED = new MenuKeySet() {
{ @Override
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.needs"); public char getMnemonic() {
BrowseUtils.browser(url); return 'N';
}
}
public static final MenuKeySet NEED = new MenuKeySet() { @Override
@Override public String getMenuName() {
public char getMnemonic() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Commuinity_Need");
return 'N'; }
}
@Override
@Override public KeyStroke getKeyStroke() {
public String getMenuName() { return null;
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Commuinity_Need"); }
} };
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
} }

13
designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java

@ -1,16 +1,12 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; public class QuestionAction extends AbstractDesignerSSO {
public class QuestionAction extends UpdateAction {
public QuestionAction() { public QuestionAction() {
this.setMenuKeySet(QUESTIONS); this.setMenuKeySet(QUESTIONS);
@ -21,9 +17,8 @@ public class QuestionAction extends UpdateAction {
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) { public String getJumpUrl() {
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions"); return CloudCenter.getInstance().acquireUrlByKind("bbs.questions");
BrowseUtils.browser(url);
} }
public static final MenuKeySet QUESTIONS = new MenuKeySet() { public static final MenuKeySet QUESTIONS = new MenuKeySet() {

70
designer-base/src/main/java/com/fr/design/actions/community/SignAction.java

@ -1,49 +1,41 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; public class SignAction extends AbstractDesignerSSO {
public class SignAction extends UpdateAction public SignAction() {
{ this.setMenuKeySet(SIGN);
this.setName(getMenuKeySet().getMenuName());
public SignAction() this.setMnemonic(getMenuKeySet().getMnemonic());
{ this.setSmallIcon("/com/fr/design/images/bbs/sign");
this.setMenuKeySet(SIGN); }
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); @Override
this.setSmallIcon("/com/fr/design/images/bbs/sign"); public String getJumpUrl() {
} return CloudCenter.getInstance().acquireUrlByKind("bbs.aut");
}
@Override
public void actionPerformed(ActionEvent arg0) public static final MenuKeySet SIGN = new MenuKeySet() {
{ @Override
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.aut"); public char getMnemonic() {
BrowseUtils.browser(url); return 'S';
}
}
public static final MenuKeySet SIGN = new MenuKeySet() { @Override
@Override public String getMenuName() {
public char getMnemonic() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_sign");
return 'S'; }
}
@Override
@Override public KeyStroke getKeyStroke() {
public String getMenuName() { return null;
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_sign"); }
} };
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
} }

21
designer-base/src/main/java/com/fr/design/actions/community/TechSolutionAction.java

@ -1,23 +1,16 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/** /**
* Created by XINZAI on 2018/8/23. * Created by XINZAI on 2018/8/23.
*/ */
public class TechSolutionAction extends UpdateAction{ public class TechSolutionAction extends AbstractDesignerSSO {
public TechSolutionAction() public TechSolutionAction() {
{
this.setMenuKeySet(TSO); this.setMenuKeySet(TSO);
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
@ -26,12 +19,10 @@ public class TechSolutionAction extends UpdateAction{
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) public String getJumpUrl() {
{ return CloudCenter.getInstance().acquireUrlByKind("bbs.solution");
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.solution");
BrowseUtils.browser(url);
} }
public static final MenuKeySet TSO = new MenuKeySet() { public static final MenuKeySet TSO = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {

80
designer-base/src/main/java/com/fr/design/actions/community/UpAction.java

@ -1,69 +1,41 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class UpAction extends UpdateAction public class UpAction extends AbstractDesignerSSO {
{
public UpAction() public UpAction() {
{ this.setMenuKeySet(UPDATE);
this.setMenuKeySet(UPDATE); this.setName(getMenuKeySet().getMenuName());
this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/update.png"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/update.png")); }
}
@Override @Override
public void actionPerformed(ActionEvent arg0) public String getJumpUrl() {
{ return CloudCenter.getInstance().acquireUrlByKind("bbs.update");
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.update");
if (StringUtils.isEmpty(url)) {
FineLoggerFactory.getLogger().info("The URL is empty!");
return;
}
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException exp) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser"));
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
} catch (URISyntaxException exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
} catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + url);
}
} }
public static final MenuKeySet UPDATE = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'U';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Update");
}
@Override public static final MenuKeySet UPDATE = new MenuKeySet() {
public KeyStroke getKeyStroke() { @Override
return null; public char getMnemonic() {
} return 'U';
}; }
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Update");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
} }

60
designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java

@ -1,49 +1,43 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.base.svg.IconUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.locale.impl.VideoMark; import com.fr.design.locale.impl.VideoMark;
import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.LocaleMark;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent;
public class VideoAction extends AbstractDesignerSSO {
public class VideoAction extends UpdateAction public VideoAction() {
{ this.setMenuKeySet(VIDEO);
this.setName(getMenuKeySet().getMenuName());
public VideoAction() this.setMnemonic(getMenuKeySet().getMnemonic());
{ this.setSmallIcon("/com/fr/design/images/bbs/video");
this.setMenuKeySet(VIDEO); }
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/bbs/video");
}
@Override @Override
public void actionPerformed(ActionEvent arg0) public String getJumpUrl() {
{
LocaleMark<String> localeMark = LocaleCenter.getMark(VideoMark.class); LocaleMark<String> localeMark = LocaleCenter.getMark(VideoMark.class);
BrowseUtils.browser(localeMark.getValue()); return localeMark.getValue();
} }
public static final MenuKeySet VIDEO = new MenuKeySet() {
@Override public static final MenuKeySet VIDEO = new MenuKeySet() {
public char getMnemonic() { @Override
return 'V'; public char getMnemonic() {
} return 'V';
}
@Override
public String getMenuName() { @Override
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Video"); public String getMenuName() {
} return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Video");
}
@Override
public KeyStroke getKeyStroke() { @Override
return null; public KeyStroke getKeyStroke() {
} return null;
}; }
};
} }

9
designer-base/src/main/java/com/fr/design/actions/community/WorkOrderCenterAction.java

@ -1,12 +1,8 @@
package com.fr.design.actions.community; package com.fr.design.actions.community;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import java.awt.event.ActionEvent;
/** /**
* @Description 工单中心 * @Description 工单中心
* @Author Henry.Wang * @Author Henry.Wang
@ -19,8 +15,7 @@ public class WorkOrderCenterAction extends UpAction {
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) { public String getJumpUrl() {
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.work.order.center"); return CloudCenter.getInstance().acquireUrlByKind("bbs.work.order.center");
BrowseUtils.browser(url);
} }
} }

31
designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java

@ -1,12 +1,10 @@
package com.fr.design.actions.help; package com.fr.design.actions.help;
import com.fr.base.svg.IconUtils; import com.fr.design.login.AbstractDesignerSSO;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -15,14 +13,9 @@ import com.fr.third.org.apache.http.StatusLine;
import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.client.methods.HttpGet;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.net.URI;
public class TutorialAction extends UpdateAction { public class TutorialAction extends AbstractDesignerSSO {
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
public TutorialAction() { public TutorialAction() {
this.setMenuKeySet(HELP_TUTORIAL); this.setMenuKeySet(HELP_TUTORIAL);
@ -32,29 +25,15 @@ public class TutorialAction extends UpdateAction {
this.setAccelerator(getMenuKeySet().getKeyStroke()); this.setAccelerator(getMenuKeySet().getKeyStroke());
} }
/**
* 动作
* @param evt 事件
*/
@Override @Override
public void actionPerformed(ActionEvent evt) { public String getJumpUrl() {
String helpURL = CloudCenter.getInstance().acquireUrlByKind(createDocKey()); return CloudCenter.getInstance().acquireUrlByKind(createDocKey());
// 用第三方网址去判断是否处在离线状态
if (isServerOnline(URL_FOR_TEST_NETWORK)) {
try {
Desktop.getDesktop().browse(new URI(helpURL));
return;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
FineLoggerFactory.getLogger().warn(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg"));
} }
// 生成帮助文档 sitecenter key, help.zh_CN.10 // 生成帮助文档 sitecenter key, help.zh_CN.10
protected String createDocKey() { protected String createDocKey() {
String locale = GeneralContext.getLocale().toString(); String locale = GeneralContext.getLocale().toString();
return CommonUtils.join(new String[]{ "help", locale, ProductConstants.MAIN_VERSION }, "."); return CommonUtils.join(new String[]{"help", locale, ProductConstants.MAIN_VERSION}, ".");
} }
// 判断是否可以访问在线文档 // 判断是否可以访问在线文档

3
designer-base/src/main/java/com/fr/design/constants/UIConstants.java

@ -148,7 +148,8 @@ public interface UIConstants {
public static final Color TAB_BUTTON_PRESS_SELECTED = new Color(236, 236, 238); public static final Color TAB_BUTTON_PRESS_SELECTED = new Color(236, 236, 238);
public static final Color POPUP_TITLE_BACKGROUND = new Color(0xd8f2fd); public static final Color POPUP_TITLE_BACKGROUND = new Color(0xd8f2fd);
public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3);
public static final Color DESIGNER_LOGIN_BACKGROUND = new Color(0xf1ad14);
public static final Color DESIGNER_LOGIN_BACKGROUND_ONCLICK = new Color(0xd89600);
public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png");

277
designer-base/src/main/java/com/fr/design/data/datapane/preview/sql/PreviewPerformedSqlPane.java

@ -0,0 +1,277 @@
package com.fr.design.data.datapane.preview.sql;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper;
import com.fr.base.ParameterMapNameSpace;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.EscapeSqlHelper;
import com.fr.data.operator.DataOperator;
import com.fr.decision.webservice.v10.config.ConfigService;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.injectable.PluginModule;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.TableDataProvider;
import com.fr.stable.plugin.ExtraClassManagerProvider;
import com.fr.stable.script.NameSpace;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Frame;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class PreviewPerformedSqlPane extends JDialog implements ActionListener {
private JPanel topPanel;
private JPanel centerPanel;
private JPanel bottomPanel;
private UILabel imageLabel;
public PreviewPerformedSqlPane(Frame frame, String sql) {
this(frame, sql, null, null, false);
}
public PreviewPerformedSqlPane(Frame frame, String sql, List<int[]> selectedSpecialCharIndex, String[] selectedSpecialChar, boolean highlight) {
super(frame, true);
// 提示信息
topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel imagePanel = new JPanel();
JPanel messagePanel;
if (isShowSpecialCharSqlPane(selectedSpecialCharIndex)) {
imageLabel = new UILabel(UIManager.getIcon("OptionPane.warningIcon"));
messagePanel = new JPanel();
messagePanel.setLayout(FRGUIPaneFactory.createBorderLayout());
messagePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0));
// 日韩取消超链,直接显示文字
if (isNotShowLink()) {
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message") + Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention") + Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message"));
messagePanel.add(label);
} else {
MessageWithLink message = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Front_Message"), Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention"), CloudCenter.getInstance().acquireConf(Toolkit.i18nText("Fine-Design_Basic_Sql_Injection_Prevention_Help"), "https://help.fanruan.com/finereport/doc-view-2219.html"), Toolkit.i18nText("Fine-Design_Basic_Preview_Special_Char_Sql_Back_Message"));
messagePanel.add(message);
}
// 提示图标
JPanel tipPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
UILabel tipLabel = new UILabel(UIManager.getIcon("OptionPane.tipIcon"));
StringBuilder textBuilder = new StringBuilder();
textBuilder.append("<html>").append(Toolkit.i18nText("Fine-Design_Basic_Processed_Special_Char")).append("<br/>");
for (String sChar : selectedSpecialChar) {
textBuilder.append(sChar).append("<br/>");
}
textBuilder.append("</html>");
tipLabel.setToolTipText(textBuilder.toString());
tipPanel.add(tipLabel, BorderLayout.SOUTH);
topPanel.add(tipPanel, BorderLayout.EAST);
} else {
imageLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql_Message"));
messagePanel.add(label);
}
imagePanel.add(imageLabel);
topPanel.add(imagePanel, BorderLayout.WEST);
topPanel.add(messagePanel, BorderLayout.CENTER);
topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10));
//中间的SQL面板
centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10));
JScrollPane scrollPane = new JScrollPane();
JTextArea checkArea = new JTextArea(sql);
checkArea.setEditable(false);
checkArea.setCursor(new Cursor(Cursor.TEXT_CURSOR));
if (highlight) {
Highlighter highLighter = checkArea.getHighlighter();
DefaultHighlighter.DefaultHighlightPainter p = new DefaultHighlighter.DefaultHighlightPainter(Color.ORANGE);
for (int[] specialCharIndex : selectedSpecialCharIndex) {
try {
highLighter.addHighlight(specialCharIndex[0], specialCharIndex[1], p);
} catch (BadLocationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
scrollPane.setViewportView(checkArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
centerPanel.add(scrollPane);
//底部的按钮面板
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
okButton.addActionListener(this);
bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
bottomPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
bottomPanel.add(okButton, BorderLayout.EAST);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql"));
this.setResizable(false);
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(bottomPanel, BorderLayout.SOUTH);
this.setSize(600, 400);
GUICoreUtils.centerWindow(this);
}
private boolean isNotShowLink() {
return GeneralContext.getLocale().equals(Locale.JAPAN) || GeneralContext.getLocale().equals(Locale.KOREA);
}
public static void previewPerformedSql(DBTableData tableData) {
Calculator calculator = Calculator.createCalculator();
//参数
ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tableData);
if (ArrayUtils.isEmpty(parameters)) {
parameters = tableData.getParameters(calculator);
}
Map<String, Object> parameterMap = new HashMap<>();
if (needInputParams(parameters)) {
showParaWindow(parameterMap, parameters);
} else {
for (ParameterProvider parameter : parameters) {
parameterMap.put(parameter.getName(), parameter.getValue());
}
}
boolean showOriginSql = true;
for (ParameterProvider parameter : DataOperator.getInstance().getTableDataParameters(tableData)) {
if (parameterMap.containsKey(parameter.getName())) {
Object value = parameterMap.get(parameter.getName());
if (value != null && !StringUtils.EMPTY.equals(value)) {
showOriginSql = false;
}
parameter.setValue(value);
}
}
String sql;
// 计算高亮文本位置
List<int[]> specialCharParamIndex = null;
boolean highlight = true;
if (showOriginSql) {
sql = tableData.getQuery();
} else {
NameSpace ns = ParameterMapNameSpace.create(parameterMap);
calculator.pushNameSpace(ns);
Parameter[] paras = processParameters(tableData, calculator);
// 所有被转义参数的集合
Set<String> specialCharParam = EscapeSqlHelper.getInstance().getSpecialCharParam(paras);
// 将参数转义等
Set<TableDataProvider> tableDataProviders = getTableDataProviders();
for (TableDataProvider provider : tableDataProviders) {
provider.processParametersBeforeAnalyzeSQL(paras, calculator);
}
if (!specialCharParam.isEmpty()) {
specialCharParamIndex = ParameterHelper.analyzeCurrentContextTableData4Template(tableData.getQuery(), paras, specialCharParam);
}
String oldSql = ParameterHelper.analyzeCurrentContextTableData4Templatee(tableData.getQuery(), paras);
sql = processExtraSQL(paras, oldSql, calculator, tableDataProviders);
if (!StringUtils.equals(oldSql, sql)) {
highlight = false;
}
}
// sql内容复制到剪切板
StringSelection selection = new StringSelection(sql);
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
// 弹窗
PreviewPerformedSqlPane pane;
if (isShowSpecialCharSqlPane(specialCharParamIndex)) {
pane = new PreviewPerformedSqlPane(DesignerContext.getDesignerFrame(), sql, specialCharParamIndex, ConfigService.getInstance().getPSIConfig().getSelectedSpecialChar(), highlight);
} else {
pane = new PreviewPerformedSqlPane(DesignerContext.getDesignerFrame(), sql);
}
pane.setVisible(true);
}
private static boolean isShowSpecialCharSqlPane(List<int[]> specialCharParamIndex) {
return specialCharParamIndex != null && !specialCharParamIndex.isEmpty();
}
private static Parameter[] processParameters(DBTableData tableData, Calculator calculator) {
ParameterProvider[] parameters = tableData.getParameters();
if (parameters == null || parameters.length == 0) {
tableData.setParameters(ParameterHelper.analyze4Parameters(tableData.getQuery(), false));
return new Parameter[0];
}
return Parameter.providers2Parameter(Calculator.processParameters(calculator, parameters));
}
private static String processExtraSQL(Parameter[] ps, String sql, Calculator ca, Set<TableDataProvider> tableDataProviders) {
for (TableDataProvider provider : tableDataProviders) {
String newSql = provider.processTableDataSQL(ps, sql, ca);
if (StringUtils.isNotEmpty(newSql)) {
sql = newSql;
}
}
return sql;
}
private static boolean needInputParams(ParameterProvider[] parameters) {
if (ArrayUtils.isNotEmpty(parameters)) {
return true;
}
for (ParameterProvider parameter : parameters) {
if (parameter.getValue() == null || StringUtils.EMPTY.equals(parameter.getValue())) {
return true;
}
}
return false;
}
private static void showParaWindow(final Map<String, Object> parameterMap, ParameterProvider[] inParameters) {
final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
}
private static Set<TableDataProvider> getTableDataProviders() {
ExtraClassManagerProvider classManagerProvider = PluginModule.getAgent(PluginModule.ExtraCore);
if (classManagerProvider == null) {
return new HashSet<>();
}
return classManagerProvider.getArray(TableDataProvider.XML_TAG, EscapeSqlHelper.getInstance());
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
}

17
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -16,6 +16,7 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.datapane.preview.sql.PreviewPerformedSqlPane;
import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -35,6 +36,7 @@ import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.ParameterUtils; import com.fr.design.utils.ParameterUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.sql.SqlUtils; import com.fr.general.sql.SqlUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator; import com.fr.script.Calculator;
@ -227,6 +229,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
// p:工具栏. // p:工具栏.
ToolBarDef toolBarDef = new ToolBarDef(); ToolBarDef toolBarDef = new ToolBarDef();
toolBarDef.addShortCut(new PreviewAction()); toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(new PreviewPerformedSQLAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT); toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction()); toolBarDef.addShortCut(new EditPageQueryAction());
dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING); dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING);
@ -368,6 +371,20 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
} }
} }
private class PreviewPerformedSQLAction extends UpdateAction {
public PreviewPerformedSQLAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview_Performed_Sql"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_file/preview_sql.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
checkParameter();
PreviewPerformedSqlPane.previewPerformedSql(DBTableDataPane.this.updateBean());
}
}
private class EditPageQueryAction extends UpdateAction { private class EditPageQueryAction extends UpdateAction {
public EditPageQueryAction() { public EditPageQueryAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query"));

17
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -3,13 +3,14 @@ package com.fr.design.dialog.link;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.Color; import java.awt.Color;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Font; import java.awt.Font;
import java.net.URI; import java.net.URI;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/** /**
* 用来构建JOptionPane带超链的消息提示 * 用来构建JOptionPane带超链的消息提示
@ -35,8 +36,16 @@ public class MessageWithLink extends JEditorPane {
this(message, linkName, link, color, LABEL.getFont()); this(message, linkName, link, color, LABEL.getFont());
} }
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage) {
this(frontMessage, linkName, link, backMessage, LABEL.getBackground(), LABEL.getFont());
}
public MessageWithLink(String message, String linkName, String link, Color color, Font font) { public MessageWithLink(String message, String linkName, String link, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>"); this(message, linkName, link, StringUtils.EMPTY, color, font);
}
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + frontMessage + "<a href=\"" + link + "\">" + linkName + "</a>" + backMessage + "</body></html>");
initListener(link); initListener(link);
setEditable(false); setEditable(false);
setBorder(null); setBorder(null);

4
designer-base/src/main/java/com/fr/design/extra/LoginContextListener.java

@ -1,8 +1,10 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.design.login.DesignerLoginSource;
/** /**
* Created by lp on 2016/8/16. * Created by lp on 2016/8/16.
*/ */
public interface LoginContextListener { public interface LoginContextListener {
void showLoginContext(); void showLoginContext(DesignerLoginSource source);
} }

38
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -1,13 +1,15 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsRegisterMark;
import com.fr.design.locale.impl.BbsResetMark; import com.fr.design.locale.impl.BbsResetMark;
import com.fr.design.login.service.DesignerLoginClient;
import com.fr.design.login.service.DesignerLoginResult;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
@ -80,17 +82,15 @@ public class LoginWebBridge {
*/ */
public void setMessageCount(int count) { public void setMessageCount(int count) {
if (count == MIN_MESSAGE_COUNT) { if (count == MIN_MESSAGE_COUNT) {
uiLabel.setText(MarketConfig.getInstance().getBbsUsername()); MarketConfig.getInstance().setInShowBBsName(DesignerEnvManager.getEnvManager().getDesignerLoginUsername());
MarketConfig.getInstance().setInShowBBsName(MarketConfig.getInstance().getBbsUsername());
return; return;
} }
this.messageCount = count; this.messageCount = count;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(StringUtils.BLANK).append(MarketConfig.getInstance().getBbsUsername()) sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getDesignerLoginUsername())
.append("(").append(this.messageCount) .append("(").append(this.messageCount)
.append(")").append(StringUtils.BLANK); .append(")").append(StringUtils.BLANK);
MarketConfig.getInstance().setInShowBBsName(sb.toString()); MarketConfig.getInstance().setInShowBBsName(sb.toString());
uiLabel.setText(sb.toString());
} }
public void setQQDialog(UIDialog qqDialog) { public void setQQDialog(UIDialog qqDialog) {
@ -163,20 +163,11 @@ public class LoginWebBridge {
* @return 登录信息标志 * @return 登录信息标志
*/ */
public String login(String userInfo, String password) { public String login(String userInfo, String password) {
if (!StringUtils.isNotBlank(userInfo) && !StringUtils.isNotBlank(password)) { DesignerLoginClient client = new DesignerLoginClient();
return LOGIN_INFO_EMPTY; DesignerLoginResult result = client.login(userInfo, password);
} int uid = result.getUid();
if (!testConnection()) {
return NET_FAILED;
}
int uid = 0;
try {
uid = FinePassportManager.getInstance().login(userInfo, password);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (uid > 0) { if (uid > 0) {
loginSuccess(MarketConfig.getInstance().getBbsUsername()); closeWindow();
} }
return String.valueOf(uid); return String.valueOf(uid);
} }
@ -191,17 +182,6 @@ public class LoginWebBridge {
} }
} }
/**
* 关闭窗口并且重新赋值
*
* @param username 用户名
*/
private void loginSuccess(String username) {
closeWindow();
uiLabel.setText(username);
uiLabel.setBackground(LOGIN_BACKGROUND);
}
/** /**
* 关闭QQ授权窗口 * 关闭QQ授权窗口
*/ */

6
designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java

@ -1,6 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
@ -190,10 +190,10 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
} }
private void doUpdateOnline(final PluginStatusCheckCompletePane pane) { private void doUpdateOnline(final PluginStatusCheckCompletePane pane) {
if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) { if (!StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getDesignerLoginUsername())) {
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) { if (StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getDesignerLoginUsername())) {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
if (plugin == null) { if (plugin == null) {
FineLoggerFactory.getLogger().error("selected plugin is null"); FineLoggerFactory.getLogger().error("selected plugin is null");

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

@ -1,6 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager;
import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback;
@ -9,7 +9,6 @@ import com.fr.design.extra.exe.callback.ModifyStatusCallback;
import com.fr.design.extra.exe.callback.UninstallPluginCallback; import com.fr.design.extra.exe.callback.UninstallPluginCallback;
import com.fr.design.extra.exe.callback.UpdateFromDiskCallback; import com.fr.design.extra.exe.callback.UpdateFromDiskCallback;
import com.fr.design.extra.exe.callback.UpdateOnlineCallback; import com.fr.design.extra.exe.callback.UpdateOnlineCallback;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
@ -193,15 +192,12 @@ public class PluginOperateUtils {
} }
} }
public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { public static void getLoginInfo(JSCallback jsCallback) {
String username = MarketConfig.getInstance().getBbsUsername(); String username = DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
if (StringUtils.isEmpty(username)) { if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY); jsCallback.execute(StringUtils.EMPTY);
uiLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn"));
} else { } else {
uiLabel.setText(username); jsCallback.execute(username);
String result = username;
jsCallback.execute(result);
} }
} }

6
designer-base/src/main/java/com/fr/design/extra/PluginUpdatePane.java

@ -1,6 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
@ -170,10 +170,10 @@ public class PluginUpdatePane extends PluginAbstractLoadingViewPane<List<PluginV
} }
private void doUpdateOnline(final PluginStatusCheckCompletePane pane) { private void doUpdateOnline(final PluginStatusCheckCompletePane pane) {
if (!StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) { if (!StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getDesignerLoginUsername())) {
LoginCheckContext.fireLoginCheckListener(); LoginCheckContext.fireLoginCheckListener();
} }
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) { if (StringUtils.isNotEmpty(DesignerEnvManager.getEnvManager().getDesignerLoginUsername())) {
try { try {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());

21
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -1,7 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
@ -12,13 +12,12 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor;
import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor;
import com.fr.design.extra.exe.SearchOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsRegisterMark;
import com.fr.design.locale.impl.BbsResetMark; import com.fr.design.locale.impl.BbsResetMark;
import com.fr.design.locale.impl.BbsSpaceMark; import com.fr.design.locale.impl.BbsSpaceMark;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.general.CloudCenter;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.LocaleMark;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -66,8 +65,6 @@ public class PluginWebBridge {
private Map<String, Object> config; private Map<String, Object> config;
private WebEngine webEngine; private WebEngine webEngine;
private UILabel uiLabel;
private ExecutorService threadPoolExecutor = new ThreadPoolExecutor(COREPOOLSIZE, MAXPOOLSIZE, private ExecutorService threadPoolExecutor = new ThreadPoolExecutor(COREPOOLSIZE, MAXPOOLSIZE,
0L, TimeUnit.MILLISECONDS, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(COREPOOLSIZE), new LinkedBlockingQueue<Runnable>(COREPOOLSIZE),
@ -423,7 +420,7 @@ public class PluginWebBridge {
*/ */
public String getLoginInfo(final JSObject callback) { public String getLoginInfo(final JSObject callback) {
registerLoginInfo(callback); registerLoginInfo(callback);
return MarketConfig.getInstance().getBbsUsername(); return DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
} }
/** /**
@ -433,7 +430,7 @@ public class PluginWebBridge {
*/ */
public void registerLoginInfo(final JSObject callback) { public void registerLoginInfo(final JSObject callback) {
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
PluginOperateUtils.getLoginInfo(jsCallback, uiLabel); PluginOperateUtils.getLoginInfo(jsCallback);
} }
/** /**
@ -455,7 +452,7 @@ public class PluginWebBridge {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
UserLoginContext.fireLoginContextListener(); UserLoginContext.fireLoginContextListener(DesignerLoginSource.NORMAL);
} }
}); });
} }
@ -526,10 +523,6 @@ public class PluginWebBridge {
} }
} }
public void setUILabel(UILabel uiLabel) {
this.uiLabel = uiLabel;
}
/** /**
* 设计器端的用户登录 * 设计器端的用户登录
* *
@ -546,7 +539,7 @@ public class PluginWebBridge {
* 通过QQ登录后通知登录 * 通过QQ登录后通知登录
*/ */
public void ucsynLogin(long uid, String username, String password, final JSONObject callback) { public void ucsynLogin(long uid, String username, String password, final JSONObject callback) {
uiLabel.setText(username);
} }
/** /**
@ -554,8 +547,6 @@ public class PluginWebBridge {
*/ */
public void clearUserInfo() { public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
FinePassportManager.getInstance().logout();
uiLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn"));
} }
public void getPackInfo(final JSObject callback){ public void getPackInfo(final JSObject callback){

5
designer-base/src/main/java/com/fr/design/extra/UserLoginContext.java

@ -1,5 +1,6 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.design.login.DesignerLoginSource;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -11,9 +12,9 @@ public class UserLoginContext {
/** /**
* 触发登录框弹出的监听器 * 触发登录框弹出的监听器
*/ */
public static void fireLoginContextListener() { public static void fireLoginContextListener(DesignerLoginSource source) {
for (LoginContextListener l : fireLoginContextListener) { for (LoginContextListener l : fireLoginContextListener) {
l.showLoginContext(); l.showLoginContext(source);
} }
} }

2
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
@ -206,6 +207,7 @@ public class WebViewDlgHelper {
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);
PluginWebBridge.getHelper().setDialogHandle(dlg); PluginWebBridge.getHelper().setDialogHandle(dlg);
dlg.setVisible(true); dlg.setVisible(true);
DesignerLoginUtils.showPluginRemindOnFirstLaunch();
} catch (Exception e) { } catch (Exception e) {
// ignored // ignored
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

7
designer-base/src/main/java/com/fr/design/extra/exe/PluginLoginExecutor.java

@ -2,6 +2,7 @@ package com.fr.design.extra.exe;
import com.fr.design.extra.LoginWebBridge; import com.fr.design.extra.LoginWebBridge;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.design.login.service.DesignerPassportManager;
/** /**
* @author vito * @author vito
@ -34,7 +35,11 @@ public class PluginLoginExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
result = LoginWebBridge.getHelper().login(username, password); int uid = DesignerPassportManager.getInstance().login(username, password);
if (uid > 0) {
LoginWebBridge.getHelper().closeWindow();
}
result = String.valueOf(uid);
} }
} }
}; };

1
designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java

@ -177,6 +177,7 @@ public class UILookAndFeel extends MetalLookAndFeel {
table.put("OptionPane.narrow.down", loadIcon("Icon_Narrow_Down_16x16.png", this)); table.put("OptionPane.narrow.down", loadIcon("Icon_Narrow_Down_16x16.png", this));
table.put("OptionPane.warningIcon", loadIcon("WarningIcon.png", this)); table.put("OptionPane.warningIcon", loadIcon("WarningIcon.png", this));
table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this)); table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this));
table.put("OptionPane.tipIcon", loadIcon("TipIcon.png", this));
table.put("ScrollPane.border", new UIScrollPaneBorder()); table.put("ScrollPane.border", new UIScrollPaneBorder());
table.put("ProgressBar.border", new UIProgressBarBorder()); table.put("ProgressBar.border", new UIProgressBarBorder());
table.put("Spinner.border", new UITextFieldBorder(new Insets(2, 2, 2, 2))); table.put("Spinner.border", new UITextFieldBorder(new Insets(2, 2, 2, 2)));

19
designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java

@ -12,6 +12,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.widget.EventCreator; import com.fr.design.widget.EventCreator;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.FRFont;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.report.web.util.ReportEngineEventMapping; import com.fr.report.web.util.ReportEngineEventMapping;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -26,10 +27,13 @@ import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.AlphaComposite;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -456,7 +460,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
getHelper().popupEditDialog(null, this.selectNameEdList, this); getHelper().popupEditDialog(null, this.selectNameEdList, this);
} }
protected String getWrapperLabelText(){ protected String getWrapperLabelText() {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@ -466,9 +470,18 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
public ListWrapperPane(String labelText, UINameEdList nameEdList) { public ListWrapperPane(String labelText, UINameEdList nameEdList) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel label = new UILabel(labelText + getWrapperLabelText()); UILabel label = new UILabel(labelText + getWrapperLabelText()) {
@Override
public void paint(Graphics g) {
((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
super.paint(g);
}
};
label.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); label.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));
label.setBackground(Color.decode("#FFFFFF")); label.setOpaque(true);
label.setBackground(Color.WHITE);
label.setForeground(Color.decode("#333334"));
label.setFont(label.getFont().deriveFont(10F));
label.setPreferredSize(new Dimension(224, 26)); label.setPreferredSize(new Dimension(224, 26));
this.nameEdList = nameEdList; this.nameEdList = nameEdList;
this.add(label, BorderLayout.NORTH); this.add(label, BorderLayout.NORTH);

92
designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java

@ -0,0 +1,92 @@
package com.fr.design.login;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.general.log.MessageFormatter;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.org.bouncycastle.util.encoders.Hex;
import java.awt.event.ActionEvent;
import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/7
*/
public abstract class AbstractDesignerSSO extends UpdateAction {
private static final String PRODUCT_FINEREPORT = "product-finereport";
private static final String KEY = "i7hP48WAcuTrmxfN";
@Override
public void actionPerformed(ActionEvent event) {
String url = getJumpUrl();
if (!SupportOSImpl.DESIGNER_LOGIN.support()) {
BrowseUtils.browser(url);
return;
}
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
int uid = manager.getDesignerLoginUid();
if (uid > 0) {
String ssoUrl = CloudCenter.getInstance().acquireUrlByKind("designer.sso.api", "https://id.fanruan.com/api/app/?code={}&referrer={}");
try {
String code = generateLoginCode();
MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(ssoUrl, new String[]{code, url});
BrowseUtils.browser(tuple.getMessage());
} catch (Exception e) {
BrowseUtils.browser(url);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
boolean loginRemindBeforeJumpBBS = manager.isLoginRemindBeforeJumpBBS();
if (loginRemindBeforeJumpBBS) {
Map<String, String> params = new HashMap<>();
params.put("bbsJumpUrl", url);
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.BBS_JUMP, params);
manager.setLoginRemindBeforeJumpBBS(false);
} else {
BrowseUtils.browser(url);
}
}
}
private String generateLoginCode() throws Exception {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
JSONObject jo = JSONObject.create();
jo.put("uid", manager.getDesignerLoginUid());
jo.put("username", manager.getDesignerLoginUsername());
jo.put("source", PRODUCT_FINEREPORT);
byte[] iv = randomIv();
return new String(Hex.encode(iv)) + encrypt(jo.toString(), KEY.getBytes(), iv);
}
private static byte[] randomIv() {
byte[] salt = new byte[16];
SecureRandom secureRandom = new SecureRandom();
secureRandom.setSeed(System.currentTimeMillis());
secureRandom.nextBytes(salt);
return salt;
}
public static String encrypt(String content, byte[] key, byte[] iv) throws Exception {
SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/CTR/PKCS5Padding");
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
byte[] resultBytes = cipher.doFinal(content.getBytes());
return new String(Hex.encode(resultBytes));
}
public abstract String getJumpUrl();
}

280
designer-base/src/main/java/com/fr/design/login/DesignerLoginBridge.java

@ -0,0 +1,280 @@
package com.fr.design.login;
import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.locale.impl.BbsResetMark;
import com.fr.design.login.executor.DesignerLoginBrowserExecutor;
import com.fr.design.login.executor.DesignerLoginExecutor;
import com.fr.design.login.executor.DesignerSendCaptchaExecutor;
import com.fr.design.login.executor.DesignerSmsLoginExecutor;
import com.fr.design.login.executor.DesignerSmsRegisterExecutor;
import com.fr.design.login.task.DesignerLoginTaskWorker;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.log.FineLoggerFactory;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerLoginBridge {
private Map<String, String> params;
public static DesignerLoginBridge getBridge(Browser browser, Map<String, String> params) {
return new DesignerLoginBridge(browser, params);
}
private JSObject window;
private DesignerLoginBridge(Browser browser, Map<String, String> params) {
this.params = params;
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
Set<Map.Entry<String, String>> entries = params.entrySet();
for (Map.Entry<String, String> entry : entries) {
this.window.setProperty(entry.getKey(), entry.getValue());
}
}
@JSBridge
public String i18nText(String key) {
return Toolkit.i18nText(key);
}
@JSBridge
public void closeWindow(boolean loginSuccess) {
DesignerLoginSource source = DesignerLoginSource.valueOf(Integer.parseInt(params.get("designerLoginSource")));
if (loginSuccess) {
if (source == DesignerLoginSource.GUIDE) {
DesignerToastMsgUtil.toastPrompt(
getHyperlinkPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Title"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Guide_Login_Success_Hyperlink_Text"),
CloudCenter.getInstance().acquireUrlByKind("designer.premium.template", "https://market.fanruan.com/template")
)
);
} else if (source == DesignerLoginSource.BBS_JUMP) {
String bbsJumpUrl = params.get("bbsJumpUrl");
BrowseUtils.browser(bbsJumpUrl);
}
DesignerLoginHelper.closeWindow();
return;
}
if (source == DesignerLoginSource.SWITCH_ACCOUNT) {
DesignerLoginHelper.closeWindow();
return;
}
if (source == DesignerLoginSource.BBS_JUMP) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String bbsJumpUrl = params.get("bbsJumpUrl");
String[] options = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_BBS_Go_Directly"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Return_Login")
};
int rv = FineJOptionPane.showConfirmDialog(
DesignerLoginHelper.getDialog(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_BBS_Quit_Tip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[1]
);
if (rv == JOptionPane.YES_OPTION) {
BrowseUtils.browser(bbsJumpUrl);
DesignerLoginHelper.closeWindow();
}
}
});
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String[] options = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Return_Login")
};
int rv = FineJOptionPane.showConfirmDialog(
DesignerLoginHelper.getDialog(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[1]
);
if (rv == JOptionPane.OK_OPTION) {
DesignerLoginHelper.closeWindow();
}
}
});
}
}
/**
* 服务条款
*/
@JSBridge
public void serviceHref() {
try {
String url = CloudCenter.getInstance().acquireUrlByKind("designer.bbs.service.terms", "https://bbs.fanruan.com/thread-102821-1-1.html");
Desktop.getDesktop().browse(new URI(url));
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
}
}
/**
* 忘记密码
*/
@JSBridge
public void forgetHref() {
try {
LocaleMark<String> resetMark = LocaleCenter.getMark(BbsResetMark.class);
Desktop.getDesktop().browse(new URI(resetMark.getValue()));
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
}
}
/**
* 设计器端的用户登录
*
* @param username 用户名
* @param password 密码
* @param callback 回调函数
*/
@JSBridge
public void normalLogin(String username, String password, final JSFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)),
new DesignerLoginExecutor(username, password));
worker.execute();
}
/**
* 发送短信验证码
*
* @param regionCode 区号
* @param phone 手机
* @param callback 回调函数
*/
@JSBridge
public void sendCaptcha(String regionCode, String phone, final JSFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)),
new DesignerSendCaptchaExecutor(regionCode, phone));
worker.execute();
}
/**
* 设计器端的短信登录
*
* @param regionCode 区号
* @param phone 手机
* @param code 验证码
* @param callback 回调函数
*/
@JSBridge
public void smsLogin(String regionCode, String phone, String code, final JSFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)),
new DesignerSmsLoginExecutor(regionCode, phone, code));
worker.execute();
}
/**
* 设计器端的用户注册
*
* @param regionCode 区号
* @param phone 手机
* @param password 密码
* @param regToken 注册令牌
* @param callback 回调函数
*/
@JSBridge
public void smsRegister(String regionCode, String phone, String password, String regToken, final JSFunction callback) {
DesignerLoginTaskWorker<Void> worker = new DesignerLoginTaskWorker<>(
new JSCallback(DesignerLoginBrowserExecutor.create(window, callback)),
new DesignerSmsRegisterExecutor(regionCode, phone, password, regToken));
worker.execute();
}
/**
* 使用系统浏览器打开网页
*
* @param url 要打开的网页
*/
@JSBridge
public void openShopUrlAtWebBrowser(String url) {
if (Desktop.isDesktopSupported()) {
try {
//创建一个URI实例,注意不是URL
URI uri = URI.create(url);
//获取当前系统桌面扩展
Desktop desktop = Desktop.getDesktop();
//判断系统桌面是否支持要执行的功能
if (desktop.isSupported(Desktop.Action.BROWSE)) {
//获取系统默认浏览器打开链接
desktop.browse(uri);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 调整面板大小
*
* @param width
* @param height
*/
@JSBridge
public void resize(int width, int height) {
DesignerLoginHelper.getDialog().setSize(width, height);
}
private JPanel getHyperlinkPane(String title, String hyperlinkText, String hyperlink) {
ActionLabel actionLabel = new ActionLabel(hyperlinkText);
actionLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(new URI(hyperlink));
} catch (Exception ignore) {
}
}
});
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(new UILabel(title));
panel.add(actionLabel);
return panel;
}
}

104
designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java

@ -0,0 +1,104 @@
package com.fr.design.login;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.general.GeneralContext;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerLoginHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser";
private static UIDialog dialog = null;
public static String getMainResourcePath() {
return MAIN_RESOURCE_PATH;
}
public static UIDialog getDialog() {
return dialog;
}
public static void showLoginDialog(DesignerLoginSource source) {
showLoginDialog(source, new HashMap<>());
}
public static void showLoginDialog(DesignerLoginSource source, Map<String, String> params) {
showLoginDialog(source, params, DesignerContext.getDesignerFrame());
}
public static void showLoginDialog(DesignerLoginSource source, Map<String, String> params, Window window) {
if (!SupportOSImpl.DESIGNER_LOGIN.support()) {
WebViewDlgHelper.createLoginDialog(window);
return;
}
boolean hasJxBrowser = true;
try {
Class.forName(JXBROWSER);
} catch (ClassNotFoundException e) {
hasJxBrowser = false;
}
if (hasJxBrowser) {
showLoginPane(source, params, window);
} else {
showUpdatePane();
}
}
private static void showLoginPane(DesignerLoginSource source, Map<String, String> params, Window window) {
DesignerLoginPane designerLoginPane = new DesignerLoginPane(source, params);
if (dialog == null) {
if (window instanceof Dialog) {
dialog = new DesignerLoginShowDialog((Dialog) window, designerLoginPane);
} else if (window instanceof Frame) {
dialog = new DesignerLoginShowDialog((Frame) window, designerLoginPane);
} else {
return;
}
}
dialog.setVisible(true);
}
private static void showUpdatePane() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Login_Message"));
if (!GeneralContext.getLocale().equals(Locale.JAPANESE) && !GeneralContext.getLocale().equals(Locale.JAPAN)
&& !Locale.getDefault().equals(Locale.JAPAN) && !Locale.getDefault().equals(Locale.JAPANESE)) {
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
}
}
public static void closeWindow() {
if (dialog != null) {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false);
dialog = null;
}
}
public static void main(String[] args) {
DesignerEnvManager.getEnvManager().setOpenDebug(true);
showLoginDialog(DesignerLoginSource.NORMAL);
}
}

42
designer-base/src/main/java/com/fr/design/login/DesignerLoginPane.java

@ -0,0 +1,42 @@
package com.fr.design.login;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.BorderLayout;
import java.util.Map;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerLoginPane extends BasicPane {
@Override
protected String title4PopupWindow() {
return "DESIGNER_LOGIN";
}
public DesignerLoginPane(DesignerLoginSource source, Map<String, String> params) {
params.put("designerLoginSource", String.valueOf(source.getSource()));
params.put("lastLoginType", String.valueOf(DesignerEnvManager.getEnvManager().getLastLoginType().getType()));
params.put("lastLoginAccount", DesignerEnvManager.getEnvManager().getLastLoginAccount());
setLayout(new BorderLayout());
ModernUIPane<Object> modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DesignerLoginHelper", DesignerLoginBridge.getBridge(event.getBrowser(), params));
}
})
.withEMB(DesignerLoginHelper.getMainResourcePath(), DesignerLoginUtils.renderMap())
.build();
add(modernUIPane, BorderLayout.CENTER);
}
}

45
designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java

@ -0,0 +1,45 @@
package com.fr.design.login;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.JPanel;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerLoginShowDialog extends UIDialog {
private static final Dimension DEFAULT = new Dimension(422, 478);
public DesignerLoginShowDialog(Frame frame, Component pane) {
super(frame);
init(pane);
}
public DesignerLoginShowDialog(Dialog dialog, Component pane) {
super(dialog);
init(pane);
}
private void init(Component pane) {
setUndecorated(true);
JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER);
setSize(DEFAULT);
GUICoreUtils.centerWindow(this);
setResizable(false);
}
@Override
public void checkValid() throws Exception {
}
}

29
designer-base/src/main/java/com/fr/design/login/DesignerLoginSource.java

@ -0,0 +1,29 @@
package com.fr.design.login;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/7
*/
public enum DesignerLoginSource {
NORMAL(0), GUIDE(1), SWITCH_ACCOUNT(2), BBS_JUMP(3), UNKNOWN(-1);
private int source;
DesignerLoginSource(int source) {
this.source = source;
}
public int getSource() {
return source;
}
public static DesignerLoginSource valueOf(int source) {
for(DesignerLoginSource value : DesignerLoginSource.values()) {
if(value.getSource() == source) {
return value;
}
}
return UNKNOWN;
}
}

29
designer-base/src/main/java/com/fr/design/login/DesignerLoginType.java

@ -0,0 +1,29 @@
package com.fr.design.login;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/4
*/
public enum DesignerLoginType {
NORMAL_LOGIN(0), SMS_LOGIN(1), UNKNOWN(-1);
private int type;
DesignerLoginType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public static DesignerLoginType valueOf(int type) {
for(DesignerLoginType value : DesignerLoginType.values()) {
if(value.getType() == type) {
return value;
}
}
return UNKNOWN;
}
}

49
designer-base/src/main/java/com/fr/design/login/bean/BBSAccountLogin.java

@ -0,0 +1,49 @@
package com.fr.design.login.bean;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/3
*/
public class BBSAccountLogin {
private int uid;
private String username;
private String appId;
private String refreshToken;
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
}

226
designer-base/src/main/java/com/fr/design/login/config/DesignerLoginConfigManager.java

@ -0,0 +1,226 @@
package com.fr.design.login.config;
import com.fr.design.login.DesignerLoginType;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/2
*/
public class DesignerLoginConfigManager implements XMLReadable, XMLWriter {
public static final String XML_TAG = "DesignerLoginConfigManager";
private static DesignerLoginConfigManager singleton;
/**
* bbs uid
*/
private int uid = -1;
/**
* bbs 用户名
*/
private String username = StringUtils.EMPTY;
/**
* bbs 应用Id
*/
private String appId = StringUtils.EMPTY;
/**
* bbs refreshToken
*/
private String refreshToken = StringUtils.EMPTY;
/**
* 登录引导页一个月内不再提醒
*/
private boolean doNotRemind = false;
/**
* 登录引导页一个月内不再提醒
*/
private long doNotRemindSelectedTime = -1L;
/**
* 设计器激活时间
*/
private long designerActivatedTime = -1L;
/**
* bbs 上次登录时间
*/
private long lastLoginTime = -1L;
/**
* bbs 上次登录方式
*/
private DesignerLoginType lastLoginType = DesignerLoginType.UNKNOWN;
/**
* bbs 上次登录账号
*/
private String lastLoginAccount = StringUtils.EMPTY;
/**
* 当前版本第一次启动
*/
private boolean currentVersionFirstLaunch = true;
/**
* bbs跳转前的登录提醒
*/
private boolean loginRemindBeforeJumpBBS = true;
/**
* 插件管理第一次启动时的提醒
*/
private boolean pluginRemindOnFirstLaunch = true;
private DesignerLoginConfigManager() {
}
public static DesignerLoginConfigManager getInstance() {
if (singleton == null) {
singleton = new DesignerLoginConfigManager();
}
return singleton;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.setUid(reader.getAttrAsInt("uid", -1));
this.setUsername(reader.getAttrAsString("username", StringUtils.EMPTY));
this.setAppId(reader.getAttrAsString("appId", StringUtils.EMPTY));
this.setRefreshToken(reader.getAttrAsString("refreshToken", StringUtils.EMPTY));
this.setDoNotRemind(reader.getAttrAsBoolean("doNotRemind", false));
this.setDoNotRemindSelectedTime(reader.getAttrAsLong("doNotRemindSelectedTime", -1L));
this.setDesignerActivatedTime(reader.getAttrAsLong("designerActivatedTime", -1L));
this.setLastLoginTime(reader.getAttrAsLong("lastLoginTime", -1L));
this.setCurrentVersionFirstLaunch(reader.getAttrAsBoolean("currentVersionFirstLaunch", true));
this.setLastLoginType(DesignerLoginType.valueOf(reader.getAttrAsInt("lastLoginType", -1)));
this.setLastLoginAccount(reader.getAttrAsString("lastLoginAccount", StringUtils.EMPTY));
this.setLoginRemindBeforeJumpBBS(reader.getAttrAsBoolean("loginRemindBeforeJumpBBS", true));
this.setPluginRemindOnFirstLaunch(reader.getAttrAsBoolean("pluginRemindOnFirstLaunch", true));
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
writer.attr("uid", uid);
writer.attr("username", username);
writer.attr("appId", appId);
writer.attr("refreshToken", refreshToken);
writer.attr("doNotRemind", doNotRemind);
writer.attr("doNotRemindSelectedTime", doNotRemindSelectedTime);
writer.attr("designerActivatedTime", designerActivatedTime);
writer.attr("lastLoginTime", lastLoginTime);
writer.attr("currentVersionFirstLaunch", currentVersionFirstLaunch);
writer.attr("lastLoginType", lastLoginType.getType());
writer.attr("lastLoginAccount", lastLoginAccount);
writer.attr("loginRemindBeforeJumpBBS", loginRemindBeforeJumpBBS);
writer.attr("pluginRemindOnFirstLaunch", pluginRemindOnFirstLaunch);
writer.end();
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public long getDoNotRemindSelectedTime() {
return doNotRemindSelectedTime;
}
public void setDoNotRemindSelectedTime(long doNotRemindSelectedTime) {
this.doNotRemindSelectedTime = doNotRemindSelectedTime;
}
public boolean isDoNotRemind() {
return doNotRemind;
}
public void setDoNotRemind(boolean doNotRemind) {
this.doNotRemind = doNotRemind;
}
public long getDesignerActivatedTime() {
return designerActivatedTime;
}
public void setDesignerActivatedTime(long designerActivatedTime) {
this.designerActivatedTime = designerActivatedTime;
}
public long getLastLoginTime() {
return lastLoginTime;
}
public void setLastLoginTime(long lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
public boolean isCurrentVersionFirstLaunch() {
return currentVersionFirstLaunch;
}
public void setCurrentVersionFirstLaunch(boolean currentVersionFirstLaunch) {
this.currentVersionFirstLaunch = currentVersionFirstLaunch;
}
public DesignerLoginType getLastLoginType() {
return lastLoginType;
}
public void setLastLoginType(DesignerLoginType lastLoginType) {
this.lastLoginType = lastLoginType;
}
public String getLastLoginAccount() {
return lastLoginAccount;
}
public void setLastLoginAccount(String lastLoginAccount) {
this.lastLoginAccount = lastLoginAccount;
}
public boolean isLoginRemindBeforeJumpBBS() {
return loginRemindBeforeJumpBBS;
}
public void setLoginRemindBeforeJumpBBS(boolean loginRemindBeforeJumpBBS) {
this.loginRemindBeforeJumpBBS = loginRemindBeforeJumpBBS;
}
public boolean isPluginRemindOnFirstLaunch() {
return pluginRemindOnFirstLaunch;
}
public void setPluginRemindOnFirstLaunch(boolean pluginRemindOnFirstLaunch) {
this.pluginRemindOnFirstLaunch = pluginRemindOnFirstLaunch;
}
}

30
designer-base/src/main/java/com/fr/design/login/executor/DesignerLoginBrowserExecutor.java

@ -0,0 +1,30 @@
package com.fr.design.login.executor;
import com.fr.design.bridge.exec.JSExecutor;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-18
*/
public class DesignerLoginBrowserExecutor implements JSExecutor {
public static DesignerLoginBrowserExecutor create(JSObject window, JSFunction callback) {
return new DesignerLoginBrowserExecutor(window, callback);
}
private JSObject window;
private JSFunction callback;
private DesignerLoginBrowserExecutor(JSObject window, JSFunction callback) {
this.window = window;
this.callback = callback;
}
@Override
public void executor(String newValue) {
callback.invoke(window, newValue);
}
}

45
designer-base/src/main/java/com/fr/design/login/executor/DesignerLoginExecutor.java

@ -0,0 +1,45 @@
package com.fr.design.login.executor;
import com.fr.design.extra.Process;
import com.fr.design.extra.exe.Command;
import com.fr.design.extra.exe.Executor;
import com.fr.design.login.service.DesignerPassportManager;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerLoginExecutor implements Executor {
private String result = "[]";
private String username;
private String password;
public DesignerLoginExecutor(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return null;
}
@Override
public void run(Process<String> process) {
result = String.valueOf(DesignerPassportManager.getInstance().login(username, password));
}
}
};
}
}

45
designer-base/src/main/java/com/fr/design/login/executor/DesignerSendCaptchaExecutor.java

@ -0,0 +1,45 @@
package com.fr.design.login.executor;
import com.fr.design.extra.Process;
import com.fr.design.extra.exe.Command;
import com.fr.design.extra.exe.Executor;
import com.fr.design.login.service.DesignerPassportManager;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerSendCaptchaExecutor implements Executor {
private String result = "[]";
private String regionCode;
private String phone;
public DesignerSendCaptchaExecutor(String regionCode, String phone) {
this.regionCode = regionCode;
this.phone = phone;
}
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return null;
}
@Override
public void run(Process<String> process) {
result = String.valueOf(DesignerPassportManager.getInstance().sendCaptcha(regionCode, phone));
}
}
};
}
}

47
designer-base/src/main/java/com/fr/design/login/executor/DesignerSmsLoginExecutor.java

@ -0,0 +1,47 @@
package com.fr.design.login.executor;
import com.fr.design.extra.Process;
import com.fr.design.extra.exe.Command;
import com.fr.design.extra.exe.Executor;
import com.fr.design.login.service.DesignerPassportManager;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerSmsLoginExecutor implements Executor {
private String result = "[]";
private String regionCode;
private String phone;
private String code;
public DesignerSmsLoginExecutor(String regionCode, String phone, String code) {
this.regionCode = regionCode;
this.phone = phone;
this.code = code;
}
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return null;
}
@Override
public void run(Process<String> process) {
result = DesignerPassportManager.getInstance().smsLogin(regionCode, phone, code);
}
}
};
}
}

49
designer-base/src/main/java/com/fr/design/login/executor/DesignerSmsRegisterExecutor.java

@ -0,0 +1,49 @@
package com.fr.design.login.executor;
import com.fr.design.extra.Process;
import com.fr.design.extra.exe.Command;
import com.fr.design.extra.exe.Executor;
import com.fr.design.login.service.DesignerPassportManager;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerSmsRegisterExecutor implements Executor {
private String result = "[]";
private String regionCode;
private String phone;
private String password;
private String regToken;
public DesignerSmsRegisterExecutor(String regionCode, String phone, String password, String regToken) {
this.regionCode = regionCode;
this.phone = phone;
this.password = password;
this.regToken = regToken;
}
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return null;
}
@Override
public void run(Process<String> process) {
result = String.valueOf(DesignerPassportManager.getInstance().smsRegister(regionCode, phone, password, regToken));
}
}
};
}
}

83
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideBridge.java

@ -0,0 +1,83 @@
package com.fr.design.login.guide;
import com.fr.design.DesignerEnvManager;
import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSObject;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerGuideBridge {
public static DesignerGuideBridge getBridge(Browser browser) {
return new DesignerGuideBridge(browser);
}
private JSObject window;
private DesignerGuideBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
}
@JSBridge
public String i18nText(String key) {
return Toolkit.i18nText(key);
}
@JSBridge
public void closeWindow(boolean doNotRemind, boolean login) {
if (login) {
DesignerGuideHelper.closeWindow();
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE);
checkDoNotRemind(doNotRemind);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String[] options = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Return_Login")
};
int rv = FineJOptionPane.showConfirmDialog(
DesignerGuideHelper.getDialog(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Login_Quit_Tip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
options,
options[1]
);
if (rv == JOptionPane.YES_OPTION) {
DesignerGuideHelper.closeWindow();
checkDoNotRemind(doNotRemind);
} else if (rv == JOptionPane.NO_OPTION) {
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.GUIDE);
DesignerGuideHelper.closeWindow();
checkDoNotRemind(doNotRemind);
}
}
});
}
}
/**
* 用户勾选了一个月内不再提醒
*/
private void checkDoNotRemind(boolean doNotRemind) {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setDesignerLoginDoNotRemind(doNotRemind);
if (doNotRemind) {
manager.setDesignerLoginDoNotRemindSelectedTime(System.currentTimeMillis());
}
}
}

114
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java

@ -0,0 +1,114 @@
package com.fr.design.login.guide;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl;
import javax.swing.WindowConstants;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerGuideHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser";
private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L;
private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L;
private static final long SIX_MONTH = 6 * ONE_MONTH;
private static UIDialog dialog = null;
public static String getMainResourcePath() {
return MAIN_RESOURCE_PATH;
}
public static UIDialog getDialog() {
return dialog;
}
public static void prepareShowGuideDialog() {
if (!SupportOSImpl.DESIGNER_LOGIN.support()) {
return;
}
if (isActivatedForOneWeek()) {
if (isLogin() && !isLoginForSixMonths()) {
return;
}
if (selectedDoNotRemindInOneMonth()) {
return;
}
DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
showGuideDialog();
}
});
}
}
/**
* 激活满一周
*/
private static boolean isActivatedForOneWeek() {
return (System.currentTimeMillis() - DesignerEnvManager.getEnvManager().getDesignerActivatedTime()) > ONE_WEEK;
}
/**
* 已经登录
*/
private static boolean isLogin() {
return DesignerEnvManager.getEnvManager().getDesignerLoginUid() > 0;
}
/**
* 已经登录满六个月
*/
private static boolean isLoginForSixMonths() {
return isLogin() && (System.currentTimeMillis() - DesignerEnvManager.getEnvManager().getDesignerLastLoginTime()) > SIX_MONTH;
}
/**
* 一个月内不再提醒
*/
private static boolean selectedDoNotRemindInOneMonth() {
return DesignerEnvManager.getEnvManager().isDesignerLoginDoNotRemind()
&& (System.currentTimeMillis() - DesignerEnvManager.getEnvManager().getDesignerLoginDoNotRemindSelectedTime()) <= ONE_MONTH;
}
private static void showGuideDialog() {
boolean hasJxBrowser = true;
try {
Class.forName(JXBROWSER);
} catch (ClassNotFoundException e) {
hasJxBrowser = false;
}
if (hasJxBrowser) {
showGuidePane();
}
}
private static void showGuidePane() {
DesignerGuidePane designerGuidePane = new DesignerGuidePane();
if (dialog == null) {
dialog = new DesignerGuideShowDialog(DesignerContext.getDesignerFrame(), designerGuidePane);
}
dialog.setVisible(true);
}
public static void closeWindow() {
if (dialog != null) {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false);
dialog = null;
}
}
public static void main(String[] args) {
DesignerEnvManager.getEnvManager().setOpenDebug(true);
showGuideDialog();
}
}

37
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuidePane.java

@ -0,0 +1,37 @@
package com.fr.design.login.guide;
import com.fr.design.dialog.BasicPane;
import com.fr.design.login.guide.utils.DesignerGuideUtils;
import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.BorderLayout;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerGuidePane extends BasicPane {
@Override
protected String title4PopupWindow() {
return "DESIGNER_GUIDE";
}
public DesignerGuidePane() {
setLayout(new BorderLayout());
ModernUIPane<Object> modernUIPane = new ModernUIPane.Builder<>()
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DesignerGuideHelper", DesignerGuideBridge.getBridge(event.getBrowser()));
}
})
.withEMB(DesignerGuideHelper.getMainResourcePath(), DesignerGuideUtils.renderMap())
.build();
add(modernUIPane, BorderLayout.CENTER);
}
}

35
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideShowDialog.java

@ -0,0 +1,35 @@
package com.fr.design.login.guide;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.JPanel;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerGuideShowDialog extends UIDialog {
private static final Dimension DEFAULT = new Dimension(700, 577);
public DesignerGuideShowDialog(Frame frame, BasicPane pane) {
super(frame);
setUndecorated(true);
JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER);
setSize(DEFAULT);
GUICoreUtils.centerWindow(this);
setResizable(false);
}
@Override
public void checkValid() throws Exception {
}
}

19
designer-base/src/main/java/com/fr/design/login/guide/utils/DesignerGuideUtils.java

@ -0,0 +1,19 @@
package com.fr.design.login.guide.utils;
import com.fr.general.GeneralContext;
import java.util.HashMap;
import java.util.Map;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerGuideUtils {
public static Map<String, String> renderMap() {
Map<String, String> map4Tpl = new HashMap<>();
map4Tpl.put("language", GeneralContext.getLocale().toString());
return map4Tpl;
}
}

167
designer-base/src/main/java/com/fr/design/login/service/DesignerLoginClient.java

@ -0,0 +1,167 @@
package com.fr.design.login.service;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.general.log.MessageFormatter;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.lang3.RandomStringUtils;
import java.util.HashMap;
import java.util.UUID;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerLoginClient {
private static final String LOGIN_API = CloudCenter.getInstance().acquireUrlByKind("designer.login.api", "http://api.shequ.fanruan.com/v1/user/login/");
private static final String SEND_CAPTCHA_API = CloudCenter.getInstance().acquireUrlByKind("designer.send.captcha.api", "http://api.shequ.fanruan.com/v1/code/getsmscaptcha/?location={}&phone={}&smstype={}");
private static final String SMS_LOGIN_API = CloudCenter.getInstance().acquireUrlByKind("designer.sms.login.api", "http://api.shequ.fanruan.com/v1/user/smslogin/");
private static final String SMS_REGISTER_API = CloudCenter.getInstance().acquireUrlByKind("designer.sms.register.api", "http://api.shequ.fanruan.com/v1/user/register/");
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
private static final String SMS_TYPE_LOGIN_AND_REGISTER = "1";
private static final String LOCATION = "location";
private static final String PHONE = "phone";
private static final String CODE = "code";
private static final String STATUS = "status";
private static final String DATA = "data";
private static final String CLIENT = "client";
private static final String UID = "uid";
private static final String APP_ID = "appid";
private static final String REFRESH_TOKEN = "refresh_token";
private static final String REGISTER = "register";
private static final String REG_TOKEN = "regtoken";
private static final String REG_PHONE = "regphone";
private static final String DEVICE = "device";
private static final String REG_FROM = "reg_from";
private static final String PRODUCT_FINEREPORT = "product-finereport";
/**
* 服务器内部错误
*/
private static final int INTERNAL_ERROR = 0;
/**
* 未知错误
*/
private static final int UNKNOWN_ERROR = -3;
/**
* 网络连接失败
*/
private static final int NETWORK_CONNECTED_FAILED = -4;
public DesignerLoginResult login(String username, String password) {
try {
HashMap<String, Object> params = new HashMap<>();
params.put(USERNAME, username);
params.put(PASSWORD, password);
String result = HttpToolbox.post(LOGIN_API, params);
JSONObject response = JSONFactory.createJSON(JSON.OBJECT, result);
int status = response.optInt(STATUS);
if (status < 0) {
return DesignerLoginResult.create(status, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
JSONObject data = response.optJSONObject(DATA);
if (data != null) {
JSONObject client = data.optJSONObject(CLIENT);
if (client != null) {
int uid = client.optInt(UID);
if (uid > 0) {
return DesignerLoginResult.create(uid, client.optString(USERNAME), client.optString(APP_ID), data.optString(REFRESH_TOKEN), false, StringUtils.EMPTY);
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return DesignerLoginResult.create(NETWORK_CONNECTED_FAILED, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
return DesignerLoginResult.create(UNKNOWN_ERROR, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
public int sendCaptcha(String regionCode, String phone) {
try {
String url = MessageFormatter.arrayFormat(SEND_CAPTCHA_API, new String[]{regionCode, phone, SMS_TYPE_LOGIN_AND_REGISTER}).getMessage();
String result = HttpToolbox.get(url);
JSONObject response = JSONFactory.createJSON(JSON.OBJECT, result);
return response.optInt(STATUS);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return INTERNAL_ERROR;
}
public DesignerLoginResult smsLogin(String regionCode, String phone, String code) {
try {
HashMap<String, Object> params = new HashMap<>();
params.put(LOCATION, regionCode);
params.put(PHONE, phone);
params.put(CODE, code);
String result = HttpToolbox.post(SMS_LOGIN_API, params);
JSONObject response = JSONFactory.createJSON(JSON.OBJECT, result);
int status = response.optInt(STATUS);
if (status < 0) {
return DesignerLoginResult.create(status, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
JSONObject data = response.optJSONObject(DATA);
if (data != null) {
boolean register = data.optBoolean(REGISTER);
if (register) {
String regToken = data.optString(REG_TOKEN);
if (regToken != null) {
return DesignerLoginResult.create(status, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, true, regToken);
}
} else {
JSONObject client = data.optJSONObject(CLIENT);
if (client != null) {
int uid = client.optInt(UID);
if (uid > 0) {
return DesignerLoginResult.create(uid, client.optString(USERNAME), client.optString(APP_ID), data.optString(REFRESH_TOKEN), false, StringUtils.EMPTY);
}
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return DesignerLoginResult.create(INTERNAL_ERROR, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
public DesignerLoginResult smsRegister(String regionCode, String phone, String password, String regToken) {
try {
HashMap<String, Object> params = new HashMap<>();
params.put(USERNAME, RandomStringUtils.randomAlphabetic(8));
params.put(PASSWORD, password);
params.put(REG_TOKEN, regToken);
params.put(LOCATION, regionCode);
params.put(REG_PHONE, phone);
params.put(DEVICE, PRODUCT_FINEREPORT);
params.put(REG_FROM, PRODUCT_FINEREPORT);
String result = HttpToolbox.post(SMS_REGISTER_API, params);
JSONObject response = JSONFactory.createJSON(JSON.OBJECT, result);
int status = response.optInt(STATUS);
if (status < 0) {
return DesignerLoginResult.create(status, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
JSONObject data = response.optJSONObject(DATA);
if (data != null) {
JSONObject client = data.optJSONObject(CLIENT);
if (client != null) {
int uid = client.optInt(UID);
if (uid > 0) {
return DesignerLoginResult.create(uid, client.optString(USERNAME), client.optString(APP_ID), data.optString(REFRESH_TOKEN), false, StringUtils.EMPTY);
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return DesignerLoginResult.create(INTERNAL_ERROR, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, StringUtils.EMPTY);
}
}

82
designer-base/src/main/java/com/fr/design/login/service/DesignerLoginResult.java

@ -0,0 +1,82 @@
package com.fr.design.login.service;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerLoginResult {
private int uid;
private String username;
private String appId;
private String refreshToken;
private boolean register;
private String regToken;
private DesignerLoginResult(int uid, String username, String appId, String refreshToken, boolean register, String regToken) {
this.uid = uid;
this.username = username;
this.appId = appId;
this.refreshToken = refreshToken;
this.regToken = regToken;
this.register = register;
}
public static DesignerLoginResult create(int uid, String username, String appId, String refreshToken, boolean register, String regToken) {
return new DesignerLoginResult(uid, username, appId, refreshToken, register, regToken);
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getRefreshToken() {
return refreshToken;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
}
public boolean isRegister() {
return register;
}
public void setRegister(boolean register) {
this.register = register;
}
public String getRegToken() {
return regToken;
}
public void setRegToken(String regToken) {
this.regToken = regToken;
}
}

114
designer-base/src/main/java/com/fr/design/login/service/DesignerPassportManager.java

@ -0,0 +1,114 @@
package com.fr.design.login.service;
import com.fr.design.DesignerEnvManager;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.upm.event.CertificateEvent;
import com.fr.event.EventDispatcher;
import com.fr.json.JSONObject;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/28
*/
public class DesignerPassportManager {
private static final String STATUS = "status";
private static final String REGISTER = "register";
private static final String REG_TOKEN = "regtoken";
private static volatile DesignerPassportManager instance = null;
public static DesignerPassportManager getInstance() {
if (instance == null) {
synchronized (DesignerPassportManager.class) {
if (instance == null) {
instance = new DesignerPassportManager();
}
}
}
return instance;
}
/**
* 账号密码登录帆软通行证
*
* @param username 论坛账号
* @param password 密码
*/
public int login(String username, String password) {
DesignerLoginClient client = new DesignerLoginClient();
DesignerLoginResult result = client.login(username, password);
int uid = result.getUid();
if (uid > 0) {
saveUserInfo(uid, result.getUsername(), result.getAppId(), result.getRefreshToken(), DesignerLoginType.NORMAL_LOGIN, username);
}
return uid;
}
/**
* 发送短信验证码
*
* @param regionCode 区号
* @param phone 手机
*/
public int sendCaptcha(String regionCode, String phone) {
DesignerLoginClient client = new DesignerLoginClient();
return client.sendCaptcha(regionCode, phone);
}
/**
* 短信登录帆软通行证
*
* @param regionCode 区号
* @param phone 手机
* @param code 验证码
*/
public String smsLogin(String regionCode, String phone, String code) {
DesignerLoginClient client = new DesignerLoginClient();
DesignerLoginResult result = client.smsLogin(regionCode, phone, code);
int uid = result.getUid();
if (uid > 0) {
saveUserInfo(uid, result.getUsername(), result.getAppId(), result.getRefreshToken(), DesignerLoginType.SMS_LOGIN, regionCode + "-" + phone);
}
JSONObject jo = new JSONObject();
jo.put(STATUS, result.getUid());
jo.put(REGISTER, result.isRegister());
jo.put(REG_TOKEN, result.getRegToken());
return jo.toString();
}
/**
* 注册帆软通行证
*
* @param regionCode 区号
* @param phone 手机
* @param password 密码
* @param regToken 注册令牌
*/
public int smsRegister(String regionCode, String phone, String password, String regToken) {
DesignerLoginClient client = new DesignerLoginClient();
DesignerLoginResult result = client.smsRegister(regionCode, phone, password, regToken);
int uid = result.getUid();
if (uid > 0) {
saveUserInfo(uid, result.getUsername(), result.getAppId(), result.getRefreshToken(), DesignerLoginType.SMS_LOGIN, regionCode + "-" + phone);
}
return uid;
}
/**
* 保存登录信息
*/
private void saveUserInfo(int uid, String username, String appId, String refreshToken, DesignerLoginType type, String account) {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setDesignerLoginUid(uid);
manager.setDesignerLoginUsername(username);
manager.setDesignerLoginAppId(appId);
manager.setDesignerLoginRefreshToken(refreshToken);
manager.setDesignerLastLoginTime(System.currentTimeMillis());
manager.setLastLoginType(type);
manager.setLastLoginAccount(account);
DesignerEnvManager.getEnvManager().saveXMLFile();
EventDispatcher.fire(CertificateEvent.LOGIN, username);
}
}

87
designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java

@ -0,0 +1,87 @@
package com.fr.design.login.socketio;
import com.fr.design.DesignerEnvManager;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.bean.BBSAccountLogin;
import com.fr.design.upm.event.CertificateEvent;
import com.fr.event.EventDispatcher;
import com.fr.log.FineLoggerFactory;
import com.fr.third.socketio.AckRequest;
import com.fr.third.socketio.Configuration;
import com.fr.third.socketio.SocketIOClient;
import com.fr.third.socketio.SocketIOServer;
import com.fr.third.socketio.listener.DataListener;
import java.net.URLDecoder;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/6/3
*/
public class LoginAuthServer {
private SocketIOServer server;
private static final String HOSTNAME = "localhost";
private static final int PORT = 41925;
private static volatile LoginAuthServer instance = null;
public static LoginAuthServer getInstance() {
if (instance == null) {
synchronized (LoginAuthServer.class) {
if (instance == null) {
instance = new LoginAuthServer();
}
}
}
return instance;
}
private LoginAuthServer() {
Configuration config = new Configuration();
config.setHostname(HOSTNAME);
config.setPort(PORT);
server = new SocketIOServer(config);
initEventListener();
}
public void start() {
try {
server.start();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public void stop() {
try {
server.stop();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private void initEventListener() {
server.addEventListener("bbsAccountLogin", BBSAccountLogin.class, new DataListener<BBSAccountLogin>() {
@Override
public void onData(SocketIOClient client, BBSAccountLogin data, AckRequest ackRequest) throws Exception {
// 保存登录信息到.FineReport100配置中
int uid = data.getUid();
if (uid > 0) {
String username = URLDecoder.decode(data.getUsername(), "UTF-8");
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
manager.setDesignerLoginUid(data.getUid());
manager.setDesignerLoginUsername(username);
manager.setDesignerLoginAppId(data.getAppId());
manager.setDesignerLoginRefreshToken(data.getRefreshToken());
manager.setDesignerLastLoginTime(System.currentTimeMillis());
manager.setLastLoginType(DesignerLoginType.NORMAL_LOGIN);
manager.setLastLoginAccount(username);
DesignerEnvManager.getEnvManager().saveXMLFile();
EventDispatcher.fire(CertificateEvent.LOGIN, username);
}
}
});
}
}

51
designer-base/src/main/java/com/fr/design/login/task/DesignerLoginTaskWorker.java

@ -0,0 +1,51 @@
package com.fr.design.login.task;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.bridge.exec.JSUtils;
import com.fr.design.extra.Process;
import com.fr.design.extra.exe.Command;
import com.fr.design.extra.exe.Executor;
import com.fr.stable.StringUtils;
import javax.swing.SwingWorker;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/27
*/
public class DesignerLoginTaskWorker<V> extends SwingWorker<V, String> {
private Executor executor;
private JSCallback callback;
public DesignerLoginTaskWorker(final JSCallback callback, final Executor executor) {
this.executor = executor;
this.callback = callback;
}
@Override
protected V doInBackground() throws Exception {
Command[] commands = executor.getCommands();
for (Command command : commands) {
String message = command.getExecuteMessage();
if (StringUtils.isNotBlank(message)) {
publish(message);
}
command.run(new Process<String>() {
@Override
public void process(String s) {
if (StringUtils.isNotBlank(s)) {
publish(JSUtils.trimText(s));
}
}
});
}
return null;
}
@Override
protected void done() {
String result = executor.getTaskFinishMessage();
callback.execute(result);
}
}

35
designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java

@ -0,0 +1,35 @@
package com.fr.design.login.utils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.general.GeneralContext;
import java.util.HashMap;
import java.util.Map;
/**
* @author Lanlan
* @version 10.0
* Created by Lanlan on 2021/5/21
*/
public class DesignerLoginUtils {
public static Map<String, String> renderMap() {
Map<String, String> map4Tpl = new HashMap<>();
map4Tpl.put("language", GeneralContext.getLocale().toString());
return map4Tpl;
}
public static void showPluginRemindOnFirstLaunch() {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
int uid = manager.getDesignerLoginUid();
if (uid > 0) {
boolean pluginRemindOnFirstLaunch = manager.isPluginRemindOnFirstLaunch();
if (pluginRemindOnFirstLaunch) {
DesignerToastMsgUtil.toastWarning(
com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Plugin_Tip")
);
manager.setPluginRemindOnFirstLaunch(false);
}
}
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -5,7 +5,6 @@ import com.fr.chartx.attr.ChartProvider;
import com.fr.chartx.config.info.AbstractConfig; import com.fr.chartx.config.info.AbstractConfig;
import com.fr.chartx.config.info.ChartConfigInfo; import com.fr.chartx.config.info.ChartConfigInfo;
import com.fr.chartx.config.info.constant.ConfigType; import com.fr.chartx.config.info.constant.ConfigType;
import com.fr.config.MarketConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -132,8 +131,8 @@ public class ChartInfo extends AbstractPointInfo implements Comparable<ChartInfo
public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse, boolean isAutoChart) { public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse, boolean isAutoChart) {
HashMap<String, String> chartConsumingMap = new HashMap<>(); HashMap<String, String> chartConsumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername(); String username = DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
String userId = String.valueOf(MarketConfig.getInstance().getBbsUid()); String userId = String.valueOf(DesignerEnvManager.getEnvManager().getDesignerLoginUid());
String uuid = DesignerEnvManager.getEnvManager().getUUID(); String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey();
String chartId = chartProvider.getChartUuid(); String chartId = chartProvider.getChartUuid();

18
designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java

@ -4,12 +4,14 @@ import com.fr.base.BaseUtils;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler; import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.rpc.RPCInvokerExceptionInfo;
@ -21,7 +23,6 @@ import javax.swing.JDialog;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -40,7 +41,7 @@ public class CheckButton extends UIButton {
private UILabel message; private UILabel message;
private UIButton okButton; private UIButton okButton;
private JDialog dialog; private JDialog dialog;
private UILabel uiLabel; private UILabel imageLabel;
public CheckButton() { public CheckButton() {
this.setIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/check.png")); this.setIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/check.png"));
@ -71,7 +72,7 @@ public class CheckButton extends UIButton {
} }
if (set.isEmpty()) { if (set.isEmpty()) {
okButton.setEnabled(true); okButton.setEnabled(true);
uiLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/correct.png")); imageLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/correct.png"));
message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Success") + "</html>"); message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Success") + "</html>");
} else { } else {
if (dialog != null) { if (dialog != null) {
@ -161,7 +162,6 @@ public class CheckButton extends UIButton {
}); });
checkThread.execute(); checkThread.execute();
dialog.setVisible(true); dialog.setVisible(true);
dialog.dispose();
} }
}; };
@ -171,7 +171,7 @@ public class CheckButton extends UIButton {
@Override @Override
public Void callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { public Void callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
uiLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/error.png")); imageLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/error.png"));
message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Upgrade") + "</html>"); message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Upgrade") + "</html>");
okButton.setEnabled(true); okButton.setEnabled(true);
return null; return null;
@ -183,7 +183,7 @@ public class CheckButton extends UIButton {
private void initDialogPane() { private void initDialogPane() {
message = new UILabel(); message = new UILabel();
message.setText(Toolkit.i18nText("Fine-Designer_Check_Font_Checking") + "..."); message.setText(Toolkit.i18nText("Fine-Designer_Check_Font_Checking") + "...");
uiLabel = new UILabel(); imageLabel = new UILabel();
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
okButton.setEnabled(false); okButton.setEnabled(false);
okButton.addActionListener(new ActionListener() { okButton.addActionListener(new ActionListener() {
@ -194,13 +194,13 @@ public class CheckButton extends UIButton {
dialog = new JDialog(); dialog = new JDialog();
dialog.setTitle(Toolkit.i18nText("Fine_Designer_Check_Font")); dialog.setTitle(Toolkit.i18nText("Fine_Designer_Check_Font"));
dialog.setModal(true); dialog.setModal(true);
dialog.setSize(new Dimension(268, 118)); dialog.setSize(DesignSizeI18nManager.getInstance().i18nDimension(this.getClass().getName()));
JPanel jp = new JPanel(); JPanel jp = new JPanel();
JPanel upPane = new JPanel(); JPanel upPane = new JPanel();
JPanel downPane = new JPanel(); JPanel downPane = new JPanel();
uiLabel = new UILabel(BaseUtils.readIcon("com/fr/design/images/waiting.png")); imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/waiting.png"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel); upPane.add(imageLabel);
upPane.add(message); upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
downPane.add(okButton); downPane.add(okButton);

12
designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java

@ -3,11 +3,11 @@ package com.fr.design.mainframe.check;
import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -17,13 +17,11 @@ import javax.swing.JScrollPane;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame; import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Locale;
/** /**
* 字体缺失检测的具体结果对话框 * 字体缺失检测的具体结果对话框
@ -52,7 +50,7 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener {
MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"), MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"),
Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"), Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"),
CloudCenter.getInstance().acquireUrlByKind("help.install.font", "https://help.fanruan.com/finereport/doc-view-3999.html")); CloudCenter.getInstance().acquireUrlByKind("help.install.font", "https://help.fanruan.com/finereport/doc-view-3999.html"));
linkMessage.setPreferredSize(new Dimension(380, 31)); linkMessage.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink"));
messagePanel.add(linkMessage); messagePanel.add(linkMessage);
// 查看详情按钮 // 查看详情按钮
@ -89,11 +87,11 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (hiddenPanel.isVisible()) { if (hiddenPanel.isVisible()) {
hiddenPanel.setVisible(false); hiddenPanel.setVisible(false);
CheckFontInfoDialog.this.setSize(new Dimension(380, 185)); CheckFontInfoDialog.this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.collapse"));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right")); directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
} else { } else {
CheckFontInfoDialog.this.setSize(new Dimension(380, 280)); CheckFontInfoDialog.this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.unfold"));
hiddenPanel.setVisible(true); hiddenPanel.setVisible(true);
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down")); directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
@ -114,7 +112,7 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener {
this.add(topPanel, BorderLayout.NORTH); this.add(topPanel, BorderLayout.NORTH);
this.add(hiddenPanel, BorderLayout.CENTER); this.add(hiddenPanel, BorderLayout.CENTER);
this.add(bottomPanel, BorderLayout.SOUTH); this.add(bottomPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US)? 400:380, 185)); this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.collapse"));
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }

2
designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java

@ -83,7 +83,7 @@ public class ContentReplaceUtil {
private static String replaceFormulaContent4TableDataName0(String content, String oldName, String newName) { private static String replaceFormulaContent4TableDataName0(String content, String oldName, String newName) {
content = getFormulaPureContent(content); content = getFormulaPureContent(content);
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer(); FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName); frFormulaTransformer.addRenamedDataset(oldName, newName);
return EQ_STRING + frFormulaTransformer.transform(content); return EQ_STRING + frFormulaTransformer.transform(content);
} }

5
designer-base/src/main/java/com/fr/design/mod/ModClassFilter.java

@ -17,6 +17,8 @@ public class ModClassFilter implements Filter<String> {
private static final Filter<String> INSTANCE = new ModClassFilter(); private static final Filter<String> INSTANCE = new ModClassFilter();
private static final String DESIGN_PREFIX = "com.fr.design";
public static Filter<String> getInstance() { public static Filter<String> getInstance() {
return INSTANCE; return INSTANCE;
} }
@ -27,10 +29,11 @@ public class ModClassFilter implements Filter<String> {
FILTER_SET.add("com.fr.poly.creator.ECBlockCreator"); FILTER_SET.add("com.fr.poly.creator.ECBlockCreator");
FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet"); FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet");
FILTER_SET.add("com.fr.form.ui.ElementCaseImage"); FILTER_SET.add("com.fr.form.ui.ElementCaseImage");
FILTER_SET.add("this$0");
} }
@Override @Override
public boolean accept(String s) { public boolean accept(String s) {
return FILTER_SET.contains(s); return FILTER_SET.contains(s) || s.startsWith(DESIGN_PREFIX);
} }
} }

10
designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java

@ -140,6 +140,16 @@ public enum SupportOSImpl implements SupportOS {
public boolean support() { public boolean support() {
return JdkVersion.GE_9.support() && OperatingSystem.isMacos() && getMacOsVersion() >= BIG_SUR_VERSION_NUMBER; return JdkVersion.GE_9.support() && OperatingSystem.isMacos() && getMacOsVersion() >= BIG_SUR_VERSION_NUMBER;
} }
},
DESIGNER_LOGIN {
@Override
public boolean support() {
if (OperatingSystem.isLinux()) {
return false;
}
return !OperatingSystem.isMacos() || getMacOsVersion() < BIG_SUR_VERSION_NUMBER;
}
}; };
private static final int BIG_SUR_VERSION_NUMBER = 16; private static final int BIG_SUR_VERSION_NUMBER = 16;

5
designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java

@ -80,6 +80,11 @@ public class EmbProtocolHandler implements ProtocolHandler {
path = path.substring(4); path = path.substring(4);
} }
inputStream = IOUtils.readResource(path); inputStream = IOUtils.readResource(path);
if (path.endsWith(".html")) {
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, map);
return Assistant.inputStream2Response(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), path);
}
return Assistant.inputStream2Response(inputStream, path); return Assistant.inputStream2Response(inputStream, path);
} }
} catch (Exception e) { } catch (Exception e) {

10
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -174,6 +174,16 @@ public class ModernUIPane<T> extends BasicPane {
return this; return this;
} }
/**
* 加载jar包中的资源
* @param path 资源路径
*/
public Builder<T> withEMB(final String path, Map<String, String> map) {
Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(map));
pane.browser.loadURL("emb:" + path);
return this;
}
/** /**
* 加载url指向的资源 * 加载url指向的资源
* @param url 文件的地址 * @param url 文件的地址

87
designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java

@ -0,0 +1,87 @@
package com.fr.design.ui.compatible;
import com.fr.design.ui.ModernRequestClient;
import com.fr.design.ui.ModernUIConstants;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/3/25
*/
public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallback {
private AssembleComponent component;
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) {
super(network);
this.component = component;
}
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map<String, String> map) {
super(network, map);
this.component = component;
}
@Override
protected Response next(UrlRequest urlRequest, String path) {
if (path.startsWith("emb:dynamic")) {
String text = htmlText(map);
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8)));
} else {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
} else {
path = path.substring(4);
}
InputStream inputStream = IOUtils.readResource(path);
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream)));
}
}
private String htmlText(Map<String, String> map) {
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component);
StylePath[] stylePaths = pathGroup.toStylePathGroup();
StringBuilder styleText = new StringBuilder();
for (StylePath path : stylePaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
styleText.append("<link rel=\"stylesheet\" href=\"emb:");
styleText.append(path.toFilePath());
styleText.append("\"/>");
}
}
String result = ModernUIConstants.HTML_TPL.replaceAll("##style##", styleText.toString());
ScriptPath[] scriptPaths = pathGroup.toScriptPathGroup();
StringBuilder scriptText = new StringBuilder();
for (ScriptPath path : scriptPaths) {
if (StringUtils.isNotBlank(path.toFilePath())) {
scriptText.append("<script src=\"emb:");
scriptText.append(path.toFilePath());
scriptText.append("\"></script>");
}
}
result = result.replaceAll("##script##", scriptText.toString());
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
result = result.replaceAll("\\$\\{" + key + "}", value);
}
}
return result;
}
}

134
designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java

@ -0,0 +1,134 @@
package com.fr.design.ui.compatible;
import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.teamdev.jxbrowser.net.HttpHeader;
import com.teamdev.jxbrowser.net.HttpStatus;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.UrlRequestJob;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
/**
* @author richie
* @version 10.0
* Created by richie on 2020/3/25
*/
public class NxInterceptRequestCallback implements InterceptRequestCallback {
Network network;
Map<String, String> map;
public NxInterceptRequestCallback(Network network) {
this.network = network;
}
public NxInterceptRequestCallback(Network network, Map<String, String> map) {
this.network = network;
this.map = map;
}
@Override
public Response on(Params params) {
UrlRequest urlRequest = params.urlRequest();
String path = urlRequest.url();
if (path.startsWith("file:")) {
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(urlRequest, path);
if (optional.isPresent()) {
return InterceptRequestCallback.Response.intercept(optional.get());
}
} else {
return next(urlRequest, path);
}
return Response.proceed();
}
Response next(UrlRequest urlRequest, String path) {
return Response.proceed();
}
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) {
try {
String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map);
File file = new File(URI.create(filePath).getPath());
InputStream inputStream = IOUtils.readResource(file.getAbsolutePath());
String mimeType = getMimeType(path);
byte[] bytes;
if (isPlainText(mimeType)) {
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, map);
bytes = text.getBytes(StandardCharsets.UTF_8);
} else {
bytes = IOUtils.inputStream2Bytes(inputStream);
}
return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return Optional.empty();
}
private boolean isPlainText(String mimeType) {
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType);
}
UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) {
UrlRequestJob.Options options = UrlRequestJob.Options
.newBuilder(urlRequest.id(), HttpStatus.OK)
.addHttpHeader(HttpHeader.of("Content-Type", mimeType))
.build();
UrlRequestJob urlRequestJob = network.newUrlRequestJob(options);
urlRequestJob.write(bytes);
urlRequestJob.complete();
return urlRequestJob;
}
String getMimeType(String path) {
if (StringUtils.isBlank(path)) {
return "text/html";
}
if (path.endsWith(".html")) {
return "text/html";
}
if (path.endsWith(".css")) {
return "text/css";
}
if (path.endsWith(".js")) {
return "text/javascript";
}
if (path.endsWith(".svg")) {
return "image/svg+xml";
}
if (path.endsWith(".png")) {
return "image/png";
}
if (path.endsWith(".jpeg")) {
return "image/jpeg";
}
if (path.endsWith(".gif")) {
return "image/gif";
}
Path file = new File("D:\\Fanruan\\FR10.0\\final_05_27\\FineReport_10.0\\webapps\\webroot\\upm\\lib\\locale\\plugin_zh_CN.js").toPath();
try {
return Files.probeContentType(file);
} catch (IOException e) {
return "text/html";
}
}
}

50
designer-base/src/main/java/com/fr/design/update/actions/SyncFileProcess.java

@ -0,0 +1,50 @@
package com.fr.design.update.actions;
import com.fr.decision.update.SyncExecutor;
import com.fr.decision.update.info.UpdateCallBack;
import com.fr.log.FineLoggerFactory;
import java.util.concurrent.ExecutionException;
import javax.swing.SwingWorker;
public abstract class SyncFileProcess extends SwingWorker<Boolean, Void> {
private UpdateCallBack callBack;
private String buildNo;
public SyncFileProcess(UpdateCallBack callBack,String buildNo) {
this.callBack = callBack;
this.buildNo = buildNo;
}
@Override
protected Boolean doInBackground() throws Exception {
return SyncExecutor.getInstance().execute(callBack,buildNo);
}
@Override
protected void done() {
boolean success = false;
try {
success = get();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success) {
onDownloadSuccess();
} else {
onDownloadFailed();
}
}
/**
* 下载成功
*/
public abstract void onDownloadSuccess();
/**
* 下载失败
*/
public abstract void onDownloadFailed();
}

16
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -1,9 +1,8 @@
package com.fr.design.upm; package com.fr.design.upm;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.DesignerEnvManager;
import com.fr.design.bridge.exec.JSBridge; import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginOperateUtils;
@ -19,12 +18,10 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsRegisterMark;
import com.fr.design.locale.impl.BbsResetMark; import com.fr.design.locale.impl.BbsResetMark;
import com.fr.design.locale.impl.BbsSpaceMark; import com.fr.design.locale.impl.BbsSpaceMark;
import com.fr.design.upm.event.CertificateEvent;
import com.fr.design.upm.event.DownloadEvent; import com.fr.design.upm.event.DownloadEvent;
import com.fr.design.upm.exec.UpmBrowserExecutor; import com.fr.design.upm.exec.UpmBrowserExecutor;
import com.fr.design.upm.task.UpmTaskWorker; import com.fr.design.upm.task.UpmTaskWorker;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.LocaleMark;
@ -379,7 +376,7 @@ public class UpmBridge {
@JSBridge @JSBridge
public String getLoginInfo(final JSFunction callback) { public String getLoginInfo(final JSFunction callback) {
registerLoginInfo(callback); registerLoginInfo(callback);
return MarketConfig.getInstance().getBbsUsername(); return DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
} }
/** /**
@ -390,13 +387,11 @@ public class UpmBridge {
@JSBridge @JSBridge
public void registerLoginInfo(final JSFunction callback) { public void registerLoginInfo(final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
String username = MarketConfig.getInstance().getBbsUsername(); String username = DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
if (StringUtils.isEmpty(username)) { if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY); jsCallback.execute(StringUtils.EMPTY);
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY);
} else { } else {
jsCallback.execute(username); jsCallback.execute(username);
EventDispatcher.fire(CertificateEvent.LOGIN, username);
} }
} }
@ -417,10 +412,9 @@ public class UpmBridge {
/** /**
* 清除用户信息 * 清除用户信息
*/ */
@JSBridge
public void clearUserInfo() { public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
FinePassportManager.getInstance().logout();
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY);
} }
/** /**

2
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -5,6 +5,7 @@ import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoa
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.update.ui.dialog.UpdateMainDialog;
@ -97,6 +98,7 @@ public class UpmFinder {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane); dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
} }
dialog.setVisible(true); dialog.setVisible(true);
DesignerLoginUtils.showPluginRemindOnFirstLaunch();
} }
} }

4
designer-base/src/main/java/com/fr/design/upm/event/CertificateEvent.java

@ -7,6 +7,6 @@ import com.fr.event.Event;
* @version 10.0 * @version 10.0
* Created by richie on 2019-04-18 * Created by richie on 2019-04-18
*/ */
public enum CertificateEvent implements Event<String> { public enum CertificateEvent implements Event<String> {
LOGIN,LOGOUT LOGIN, LOGOUT
} }

424
designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -1,32 +1,67 @@
package com.fr.env; package com.fr.env;
import com.fr.design.DesignerEnvManager; import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.info.UpdateProgressCallBack;
import com.fr.design.RestartHelper;
import com.fr.design.VersionCheckUtils;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.actions.SyncFileProcess;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.env.utils.DisplayUtils; import com.fr.general.CloudCenter;
import com.fr.general.CloudCenterConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent;
import com.fr.stable.CommonUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.sun.java.swing.plaf.motif.MotifProgressBarUI;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JProgressBar;
import javax.swing.JTextPane; import javax.swing.JScrollPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Frame; import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale; import java.util.Locale;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
/** /**
* @author: Maksim * @author: Maksim
@ -36,11 +71,34 @@ import java.util.Locale;
public class CheckServiceDialog extends JDialog implements ActionListener { public class CheckServiceDialog extends JDialog implements ActionListener {
private JPanel topPanel; private JPanel topPanel;
private JPanel centerPanel; private JPanel centerPanel;
private JPanel bottomPanel; private UIButton ignoreButton;
private UICheckBox remindBox; private UIButton syncButton;
private JProgressBar progressBar;
private String remoteBuildNo;
private static final Dimension PROGRESSBAR = new Dimension(120, 15);
private JSONArray differentPlugins;
private UILabel affectedFunctionsLabel;
private UILabel jarCheckResultLabel;
private UILabel jarCheckTitleLabel;
private UILabel pluginCheckTitleLabel;
private JPanel affectedFunctionsDetailsPane;
private JPanel pluginsCheckResultPanel;
private JPanel detailsInnerPane;
private JPanel detailsPane;
private JScrollPane jScrollPane;
private Component[][] detailsComponents;
private Component[][] hideAffectedFunctionsComponents;
private boolean showAffectedFunctions = true;
private boolean jarConsistency;
private double p = TableLayout.PREFERRED;
private double f = TableLayout.FILL;
public CheckServiceDialog(Frame parent, String areaText, String localBranch, String remoteBranch){ public CheckServiceDialog(Frame parent, String localBranch, String remoteBranch, List<String> noExistServiceDescription) {
super(parent,true); super(parent, true);
this.remoteBuildNo = remoteBranch;
this.differentPlugins = VersionCheckUtils.checkLocalAndRemotePlugin();
this.jarConsistency = ComparatorUtils.equals(localBranch, remoteBranch);
//上面的标签面板 //上面的标签面板
topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel imagePanel = new JPanel(); JPanel imagePanel = new JPanel();
@ -49,90 +107,318 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
JLabel imageLabel = new JLabel(); JLabel imageLabel = new JLabel();
imageLabel.setIcon(icon); imageLabel.setIcon(icon);
imagePanel.add(imageLabel); imagePanel.add(imageLabel);
imagePanel.setPreferredSize(new Dimension(110,100)); imagePanel.setPreferredSize(new Dimension(110, 100));
JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
FRFont font = FRFont.getInstance(); FRFont font = FRFont.getInstance();
font = font.applySize(15).applyStyle(1); font = font.applySize(15).applyStyle(1);
JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency")); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Branch_Inconsistency"));
label.setFont(font); label.setFont(font);
label.setPreferredSize(new Dimension(650,30)); label.setPreferredSize(new Dimension(650, 30));
String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch
+ Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") +
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") +
localBranch;
String delimiter = DisplayUtils.getDisplayLength(text) > 70? "<br>":"/";
JLabel label2 = new JLabel("<html>"+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer")
+ localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") +
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old")+ localBranch +"</html>");
label2.setPreferredSize(new Dimension(600,30));
JTextPane tipsPane = new JTextPane();
tipsPane.setEditable(false);
tipsPane.setBackground(verticalPanel.getBackground());
tipsPane.setPreferredSize(new Dimension(500,40));
tipsPane.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update"));
UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Inconsistency_Risk"));
label2.setPreferredSize(new Dimension(600, 30));
verticalPanel.add(label); verticalPanel.add(label);
verticalPanel.add(label2); verticalPanel.add(label2);
verticalPanel.add(tipsPane);
topPanel.add(imagePanel,BorderLayout.WEST); topPanel.add(imagePanel, BorderLayout.WEST);
topPanel.add(verticalPanel,BorderLayout.CENTER); topPanel.add(verticalPanel, BorderLayout.CENTER);
topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10)); topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
//中间的文本域面板 //中间的文本域面板
centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); centerPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
centerPanel.setPreferredSize(new Dimension(480,320)); centerPanel.setPreferredSize(new Dimension(480, 320));
JLabel titleLabel = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Affected_Function")); UILabel titleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Details"));
titleLabel.setPreferredSize(new Dimension(400,40)); titleLabel.setPreferredSize(new Dimension(400, 40));
JTextArea checkArea = new JTextArea(areaText); //详情面板
checkArea.setEnabled(false); detailsPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
centerPanel.add(titleLabel,BorderLayout.NORTH); detailsPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 0));
centerPanel.add(checkArea,BorderLayout.CENTER); detailsPane.setBackground(Color.WHITE);
//下面的按钮面板 jarCheckTitleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_JAR_Check_title"));
remindBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remind_Show")); jarCheckTitleLabel.setBackground(Color.WHITE);
remindBox.addActionListener(remindCheckboxListener);
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm"));
JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); //插件的检测结果相关面板
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); pluginCheckTitleLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Check_title"));
buttonPanel.add(remindBox, BorderLayout.WEST); pluginCheckTitleLabel.setBackground(Color.WHITE);
buttonPanel.add(okButton,BorderLayout.EAST); initPluginsCheckResultPanel(differentPlugins);
okButton.addActionListener(this );
bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); //jar包检测结果相关面板
bottomPanel.add(buttonPanel); initJarCheckResultPanel(remoteBranch, noExistServiceDescription);
double[] detailsRowSize;
double[] detailsColumnSize = {f};
detailsComponents = new Component[][]{{jarCheckTitleLabel}, {jarCheckResultLabel}, {affectedFunctionsLabel}, {affectedFunctionsDetailsPane}, {pluginCheckTitleLabel}, {pluginsCheckResultPanel}};
hideAffectedFunctionsComponents = new Component[][]{{jarCheckTitleLabel}, {jarCheckResultLabel}, {affectedFunctionsLabel}, {pluginCheckTitleLabel}, {pluginsCheckResultPanel}};
if (noExistServiceDescription.size() > 0 && !ComparatorUtils.equals(remoteBranch, localBranch)) {
detailsRowSize = new double[]{p, p, p, p,p,p};
detailsInnerPane = TableLayoutHelper.createTableLayoutPane(detailsComponents, detailsRowSize, detailsColumnSize);
} else {
detailsRowSize = new double[]{p, p, 0, 0, p, p};
detailsInnerPane = TableLayoutHelper.createTableLayoutPane(detailsComponents, detailsRowSize, detailsColumnSize);
}
detailsInnerPane.setBackground(Color.WHITE);
jScrollPane = new JScrollPane(detailsInnerPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
detailsPane.add(jScrollPane);
centerPanel.add(titleLabel, BorderLayout.NORTH);
centerPanel.add(detailsPane, BorderLayout.CENTER);
JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_M_Pane();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
if (isOnline()) {
ignoreButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_Ignore"));
ignoreButton.addActionListener(this);
syncButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local"));
syncButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local_Tip"));
syncButton.addMouseListener(syncButtonClickListener);
progressBar = new JProgressBar();
progressBar.setUI(new MotifProgressBarUI());
progressBar.setForeground(UpdateConstants.BAR_COLOR);
progressBar.setVisible(false);
progressBar.setStringPainted(true);
progressBar.setPreferredSize(PROGRESSBAR);
buttonPanel.add(ignoreButton, BorderLayout.WEST);
buttonPanel.add(progressBar, BorderLayout.CENTER);
buttonPanel.add(syncButton, BorderLayout.EAST);
} else {
UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Suggestion"));
centerPanel.add(adviceLabel, BorderLayout.SOUTH);
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm"));
okButton.addActionListener(this);
buttonPanel.add(okButton, BorderLayout.EAST);
}
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint")); this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint"));
this.setResizable(false); this.setResizable(false);
this.add(topPanel, BorderLayout.NORTH);
this.add(topPanel,BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER); this.add(centerPanel, BorderLayout.CENTER);
this.add(buttonPanel,BorderLayout.SOUTH); this.add(buttonPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US)? 750:600, 500)); this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500));
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }
/**
* 插件检测的结果
*/
private void initPluginsCheckResultPanel(JSONArray differentPlugins) {
if (differentPlugins.size() > 0) {
int size = differentPlugins.size();
Component[][] pluginCheckResultComponents = new Component[size][1];
double[] pluginCheckResultColumnSize = new double[size];
for (int i = 0; i < size; i++) {
JSONObject plugin = differentPlugins.getJSONObject(i);
JLabel pluginLabel;
if (ComparatorUtils.equals(VersionCheckUtils.INCONSISTENCY, plugin.getString("type"))) {
pluginLabel = new JLabel("\"" + plugin.getString("name") + "\"" + Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Inconsistency_Info") + plugin.getString("version"));
} else if (ComparatorUtils.equals(VersionCheckUtils.MISSING, plugin.getString("type"))) {
pluginLabel = new JLabel("\"" + plugin.getString("name") + "\"" + Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Missing_Info") + plugin.getString("version"));
} else {
continue;
}
pluginLabel.setIcon(IOUtils.readIcon("com/fr/design/icon/versioncheck/fail.png"));
pluginCheckResultComponents[i][0] = pluginLabel;
pluginCheckResultColumnSize[i] = p;
}
double[] pluginCheckResultRowSize = {f};
pluginsCheckResultPanel = TableLayoutHelper.createTableLayoutPane(pluginCheckResultComponents, pluginCheckResultColumnSize, pluginCheckResultRowSize);
} else {
UILabel pluginCheckResultLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Consistency"));
pluginCheckResultLabel.setIcon(IOUtils.readIcon("com/fr/design/icon/versioncheck/success.png"));
pluginsCheckResultPanel = TableLayoutHelper.createTableLayoutPane(new Component[][]{{pluginCheckResultLabel}}, new double[]{p}, new double[]{f});
}
pluginsCheckResultPanel.setBackground(Color.WHITE);
}
/**
* jar包检测的结果
*/
private void initJarCheckResultPanel(String remoteBranch, List<String> noExistServiceDescription) {
jarCheckResultLabel = new UILabel();
jarCheckResultLabel.setBackground(Color.WHITE);
if (jarConsistency) {
jarCheckResultLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Sync_JAR_Consistency"));
jarCheckResultLabel.setIcon(IOUtils.readIcon("com/fr/design/icon/versioncheck/success.png"));
} else {
jarCheckResultLabel.setText(Toolkit.i18nText("Fine-Design_Basic_Sync_JAR_Inconsistency_Info") + remoteBranch);
jarCheckResultLabel.setIcon(IOUtils.readIcon("com/fr/design/icon/versioncheck/fail.png"));
Component[][] noExistServiceComponents;
int noExistService = noExistServiceDescription.size();
if (noExistService > 0) {
affectedFunctionsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Affected_Function"));
affectedFunctionsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
affectedFunctionsLabel.setBackground(Color.WHITE);
affectedFunctionsLabel.addMouseListener(affectedFunctionsClickListener);
noExistServiceComponents = new Component[noExistServiceDescription.size()][1];
double[] noExistServiceColumnSize = new double[noExistService];
for (int i = 0; i < noExistService; i++) {
JLabel noExitServiceLabel = new JLabel(" " + noExistServiceDescription.get(i));
noExistServiceComponents[i][0] = noExitServiceLabel;
noExistServiceColumnSize[i] = p;
}
double[] noExistServiceRowSize = {f};
affectedFunctionsDetailsPane = TableLayoutHelper.createTableLayoutPane(noExistServiceComponents, noExistServiceColumnSize, noExistServiceRowSize);
affectedFunctionsDetailsPane.setBackground(Color.WHITE);
}
}
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
this.dispose(); this.dispose();
} }
private boolean isOnline() {
if (CloudCenterConfig.getInstance().isOnline()) {
String ping = CloudCenter.getInstance().acquireConf("ping", StringUtils.EMPTY);
if (StringUtils.isNotEmpty(ping)) {
try {
return StringUtils.isEmpty(HttpToolbox.get(ping));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
}
return false;
}
private ActionListener remindCheckboxListener = new ActionListener() { private MouseListener affectedFunctionsClickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (showAffectedFunctions) {
showAffectedFunctions = false;
detailsInnerPane.removeAll();
affectedFunctionsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
TableLayoutHelper.addComponent2ResultPane(hideAffectedFunctionsComponents, new double[]{p, p, p, p, p}, new double[]{f}, detailsInnerPane);
jScrollPane.validate();
jScrollPane.repaint();
} else {
showAffectedFunctions = true;
detailsInnerPane.removeAll();
affectedFunctionsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
TableLayoutHelper.addComponent2ResultPane(detailsComponents, new double[]{p, p, p, p, p, p}, new double[]{f}, detailsInnerPane);
jScrollPane.validate();
jScrollPane.repaint();
}
}
};
private MouseListener syncButtonClickListener = new MouseAdapter() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void mouseClicked(MouseEvent e) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
String remindTime = format.format(new Date()); int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"),
//环境已切换,通过当前环境获取,一定是远程环境 Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, IOUtils.readIcon("com/fr/design/icon/versioncheck/question.png"), option, 1);
String currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); if (0 == a) {
RemoteDesignerWorkspaceInfo currentEnv = (RemoteDesignerWorkspaceInfo)DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentEnvName); //jar包一致的话只更新插件
currentEnv.setRemindTime(remindBox.isSelected()? remindTime : ""); UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
syncButton.setEnabled(false);
if (!jarConsistency) {
deletePreviousPropertyFile();
final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB);
final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper();
FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY);
new SyncFileProcess(callBack, remoteBuildNo) {
@Override
public void onDownloadSuccess() {
deleteForDesignerUpdate(installLib);
//主jar下载成功之后再卸载安装插件
progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
progressBar.setValue(0);
new SwingWorker<JSONArray, Void>() {
@Override
protected JSONArray doInBackground() {
return VersionCheckUtils.syncPlugins(differentPlugins);
}
@Override
protected void done() {
progressBar.setVisible(false);
JSONArray syncFailedPlugins = null;
try {
syncFailedPlugins = get();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) {
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
}
helper.restartForUpdate(frame);
}
}.execute();
}
@Override
public void onDownloadFailed() {
progressBar.setVisible(false);
deleteForDesignerUpdate(installLib);
ErrorDialog errorDialog = new ErrorDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Fail"));
errorDialog.setVisible(true);
helper.restartForUpdate(frame);
}
}.execute();
} else {
//到这边说明主jar是一致的,就只尝试同步插件
progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
progressBar.setValue(0);
new SwingWorker<JSONArray, Void>() {
@Override
protected JSONArray doInBackground() {
return VersionCheckUtils.syncPlugins(differentPlugins);
}
@Override
protected void done() {
progressBar.setVisible(false);
JSONArray syncFailedPlugins = null;
try {
syncFailedPlugins = get();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (syncFailedPlugins != null && syncFailedPlugins.size() > 0) {
SyncFailedPluginsDialog syncFailedPluginsDialog = new SyncFailedPluginsDialog(DesignerContext.getDesignerFrame(), syncFailedPlugins);
syncFailedPluginsDialog.setVisible(true);
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Sync_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
close();
}
}.execute();
}
}
} }
}; };
private boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE);
if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
return StableUtils.deleteFile(moveFile) && StableUtils.deleteFile(delFile);
}
return false;
}
private void close() {
this.dispose();
}
private void deleteForDesignerUpdate(String installLib) {
File dir = new File(installLib);
CommonUtils.deleteFile(dir);
}
} }

73
designer-base/src/main/java/com/fr/env/ErrorDialog.java vendored

@ -0,0 +1,73 @@
package com.fr.env;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
* 主jar下载失败的弹出框
*
* */
public class ErrorDialog extends JDialog implements ActionListener {
public ErrorDialog(Frame parent, String message) {
super(parent, true);
init(message);
}
private void init(String message){
//主体内容
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
//带超链的提示信息
JPanel messagePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
messagePanel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
MessageWithLink messageWithLink = new MessageWithLink(message + ",", Toolkit.i18nText("Fine-Design_Basic_Sync_Help"), CloudCenter.getInstance().acquireUrlByKind("help.replacejars", "https://help.fanruan.com/finereport/doc-view-3268.html"));
messageWithLink.setPreferredSize(new Dimension(108, 20));
JPanel messageLinkPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
messageLinkPane.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0));
messageLinkPane.add(messageWithLink);
//错误提示图标
UILabel imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/icon/versioncheck/bigfail.png"));
messagePanel.add(imageLabel);
messagePanel.add(messageLinkPane);
//确定按钮
UIButton ok = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_OK"));
ok.addActionListener(this);
ok.setSize(new Dimension(44, 20));
JPanel okPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
okPanel.add(ok);
centerPanel.add(messagePanel, BorderLayout.CENTER);
centerPanel.add(okPanel, BorderLayout.SOUTH);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"));
this.setResizable(false);
this.add(centerPanel, BorderLayout.CENTER);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 282 : 262, 118));
GUICoreUtils.centerWindow(this);
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
}

119
designer-base/src/main/java/com/fr/env/SyncFailedPluginsDialog.java vendored

@ -0,0 +1,119 @@
package com.fr.env;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
/**
* @author pengda
* @version 10.0
* Created on 2021-06-02
*/
public class SyncFailedPluginsDialog extends JDialog {
private UILabel detailsLabel;
private JScrollPane scrollPane;
public SyncFailedPluginsDialog(Frame parent, JSONArray syncFailedPlugins) {
super(parent, true);
JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
northPane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
JPanel imagePanel = new JPanel();
Icon icon = IOUtils.readIcon("com/fr/design/icon/versioncheck/warning.png");
JLabel imageLabel = new JLabel();
imageLabel.setIcon(icon);
imagePanel.add(imageLabel);
imagePanel.setPreferredSize(new Dimension(20, 20));
JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
MessageWithLink messageWithLink = new MessageWithLink(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugin_Fail_Suggestion"),Toolkit.i18nText("Fine-Design_Basic_Sync_Deal_Immediately"),
CloudCenter.getInstance().acquireUrlByKind("help.installplugins", "https://help.fanruan.com/finereport/doc-view-2198.html"));
messageWithLink.setPreferredSize(new Dimension(316, 20));
messagePane.add(messageWithLink);
messagePane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
northPane.add(imageLabel, BorderLayout.WEST);
northPane.add(messagePane, BorderLayout.CENTER);
JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
detailsLabel = new UILabel(Toolkit.i18nText("Fine_Designer_Look_Detail"));
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
detailsLabel.addMouseListener(detailsLabelClickListener);
JPanel detailsTitlePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
detailsTitlePanel.add(detailsLabel);
detailsTitlePanel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
UITextArea detailsTextArea = new UITextArea();
StringBuilder detailsText = new StringBuilder(StringUtils.EMPTY);
for (int i = 0; i < syncFailedPlugins.size(); i++) {
JSONObject plugin = syncFailedPlugins.getJSONObject(i);
detailsText.append(plugin.getString("name")).append(",").append(Toolkit.i18nText("Fine-Design_Basic_Sync_Server_Version")).append(plugin.getString("version")).append("\n");
}
detailsTextArea.setText(detailsText.toString());
scrollPane = new JScrollPane(detailsTextArea);
centerPanel.add(detailsTitlePanel,BorderLayout.NORTH);
centerPanel.add(scrollPane,BorderLayout.CENTER);
JPanel southPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
UIButton restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Updater_Restart_Designer"));
restartButton.addMouseListener(restartButtonClickListener);
southPane.add(restartButton);
body.add(northPane,BorderLayout.NORTH);
body.add(centerPanel,BorderLayout.CENTER);
body.add(southPane,BorderLayout.SOUTH);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"));
this.setResizable(false);
this.add(body, BorderLayout.CENTER);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 400 : 380, 225));
GUICoreUtils.centerWindow(this);
}
private MouseListener detailsLabelClickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(scrollPane.isVisible()){
scrollPane.setVisible(false);
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
}else{
scrollPane.setVisible(true);
detailsLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
}
}
};
private MouseListener restartButtonClickListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
RestartHelper.restartForUpdate(DesignerContext.getDesignerFrame());
}
};
}

105
designer-base/src/main/java/com/fr/env/VersionCheckMessageDialog.java vendored

@ -0,0 +1,105 @@
package com.fr.env;
import com.fr.design.VersionCheckUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
* @author pengda
* @version 10.0
* Created on 2021-06-02
*/
public class VersionCheckMessageDialog extends JDialog implements ActionListener {
private UILabel imageLabel;
private UILabel detailLabel;
private JPanel centerPanel;
private JPanel detailPanel;
private JPanel body;
private String envName;
public VersionCheckMessageDialog(Frame parent, String message, String envName) {
super(parent, true);
this.envName = envName;
init(message);
}
private void init(String message) {
JPanel imagePanel = new JPanel();
imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png"));
imagePanel.add(imageLabel);
JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
UILabel messageText = new UILabel();
messageText.setText("<html>" + message + "</html>");
messagePanel.add(messageText);
centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPanel.setBorder(BorderFactory.createEmptyBorder(15, 10, 10, 10));
centerPanel.add(imagePanel, BorderLayout.WEST);
centerPanel.add(messagePanel, BorderLayout.CENTER);
detailLabel = new UILabel();
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
detailLabel.setForeground(Color.BLUE);
detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
detailPanel.add(detailLabel, BorderLayout.EAST);
String localBranch = GeneralUtils.readFullBuildNO();
String remoteBranch = VersionCheckUtils.getRemoteBranch(envName);
List<String> noExistServiceDescription;
if(ComparatorUtils.equals(localBranch,remoteBranch)) {
noExistServiceDescription = new ArrayList<>();
}else{
noExistServiceDescription = VersionCheckUtils.getNoExistServiceDescription(this.envName);
}
detailPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
hideDialog();
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), localBranch, remoteBranch, noExistServiceDescription);
checkServiceDialog.setVisible(true);
}
});
body = FRGUIPaneFactory.createBorderLayout_S_Pane();
body.add(centerPanel, BorderLayout.CENTER);
body.add(detailPanel, BorderLayout.SOUTH);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"));
this.setResizable(false);
this.add(body, BorderLayout.NORTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 300 : 280, 135));
GUICoreUtils.centerWindow(this);
}
private void hideDialog(){
this.dispose();
}
@Override
public void actionPerformed(ActionEvent e) {
hideDialog();
}
}

4
designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties

@ -1 +1,5 @@
com.fr.design.mainframe.check.CheckButton=305*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=630*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280
com.fr.design.report.ReportColumnsPane=800*600 com.fr.design.report.ReportColumnsPane=800*600

4
designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties

@ -0,0 +1,4 @@
com.fr.design.mainframe.check.CheckButton=280*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280

4
designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties

@ -0,0 +1,4 @@
com.fr.design.mainframe.check.CheckButton=230*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280

4
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties

@ -1 +1,5 @@
# \u9ED8\u8BA4\u4E3A\u7C7B\u7684\u5168\u9650\u5B9A\u540D\uFF08\u53EF\u81EA\u5B9A\u4E49key\uFF09= width * height # \u9ED8\u8BA4\u4E3A\u7C7B\u7684\u5168\u9650\u5B9A\u540D\uFF08\u53EF\u81EA\u5B9A\u4E49key\uFF09= width * height
com.fr.design.mainframe.check.CheckButton=250*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280

4
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties

@ -0,0 +1,4 @@
com.fr.design.mainframe.check.CheckButton=250*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/arrowright.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/bigfail.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/fail.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/question.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/success.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

BIN
designer-base/src/main/resources/com/fr/design/icon/versioncheck/warning.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/TipIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

BIN
designer-base/src/main/resources/com/fr/design/images/m_file/preview_sql.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

2
designer-base/src/main/resources/com/fr/design/login/designer_login.properties

@ -0,0 +1,2 @@
VERSION=1.0
ENV_VERSION=10.0

52
designer-base/src/main/resources/com/fr/design/login/guide.css

@ -0,0 +1,52 @@
.background-login-close {
color: white !important;
font-weight: bold;
font-size: 14px;
}
.background-guide-close {
color: black !important;
font-weight: bold;
font-size: 16px;
}
.background-login-loading {
background: url(./img/login_loading.gif) no-repeat center center;
}
.background-plugin-need-update {
background: url(./img/icon_new.png) no-repeat center center;
}
.background-plugin-cant-use {
background: url(./img/icon_cantuse.png) no-repeat center center;
}
.background-plugin-is-disable {
background: url(./img/icon_disable.png) no-repeat center center;
}
.background-plugin-is-disable-new {
background: url(./img/icon_disable-new.png) no-repeat center center;
}
.background-plugin-selected {
background: url(./img/icon_marked.png) no-repeat center center;
}
.background-shop-title-close {
background: url(./img/icon_close40x40_normal.svg) no-repeat center center;
}
.background-dialog-confirm {
background: url(./img/warning.png) no-repeat center center;
background-size: contain;
}
.background-close-button {
background: url(./img/icon_close9x9_normal.png) no-repeat center center;
}
.background-close-button:hover {
background: url(./img/icon_close9x9_hover.png) no-repeat center center;
}
.designer-login-guide {
background: url(./img/login_guide.png) no-repeat center center;
background-size: cover;
}
.designer-guide-login-button {
font-size: 14px;
color: white;
border-radius: 4px;
background-color: #3685F2;
}

25
designer-base/src/main/resources/com/fr/design/login/guide.html

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>title</title>
<style>
@font-face {
font-family: "fineui";
src: url('../lib/font/iconfont.eot');
src: url('../lib/font/iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('../lib/font/iconfont.woff') format('woff'), /* chrome、firefox */ url('../lib/font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('../lib/font/iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="lib/bundle.css"/>
<script type="text/javascript" charset="UTF-8" src="lib/locale/login_zh_CN.js?_=compatible"></script>
<script type="text/javascript" charset="UTF-8" src="lib/locale/login_${language}.js"></script><script type="text/javascript" charset="UTF-8" src="lib/fineui.min.js"></script><script type="text/javascript"></script>
<style>
body {
overflow-y: auto;
}
</style>
<link href="guide.css" rel="stylesheet"></head>
</html>
<script type="text/javascript" src="guide.js"></script>

1
designer-base/src/main/resources/com/fr/design/login/guide.js

File diff suppressed because one or more lines are too long

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_cantuse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

23
designer-base/src/main/resources/com/fr/design/login/img/icon_close40x40_normal.svg

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve">
<g>
<g>
<defs>
<rect id="SVGID_1_" width="40" height="40"/>
</defs>
<use xlink:href="#SVGID_1_" overflow="visible" fill="#417BE2"/>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" overflow="visible"/>
</clipPath>
<rect clip-path="url(#SVGID_2_)" fill="#417BE2" width="40" height="40"/>
</g>
</g>
<path fill="#FFFFFF" d="M21.414,20l3.793-3.793c0.195-0.195,0.293-0.451,0.293-0.707s-0.098-0.512-0.293-0.707
c-0.391-0.391-1.023-0.391-1.414,0L20,18.586l-3.793-3.793c-0.391-0.391-1.023-0.391-1.414,0C14.598,14.988,14.5,15.244,14.5,15.5
s0.098,0.512,0.293,0.707L18.586,20l-3.793,3.793C14.598,23.988,14.5,24.244,14.5,24.5s0.098,0.512,0.293,0.707
S15.244,25.5,15.5,25.5s0.512-0.098,0.707-0.293L20,21.414l3.793,3.793c0.195,0.195,0.451,0.293,0.707,0.293
s0.512-0.098,0.707-0.293S25.5,24.756,25.5,24.5s-0.098-0.512-0.293-0.707L21.414,20z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_close9x9_hover.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_close9x9_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_close_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_disable-new.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_disable.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_marked.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/icon_new.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
designer-base/src/main/resources/com/fr/design/login/img/login_guide.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save