Browse Source

Fixed merge conflict

research/11.0
Yvan 4 years ago
parent
commit
6fa068ad33
  1. 7
      build.gradle
  2. 59
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 78
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 4
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  5. 9
      designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java
  6. 2
      designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java
  7. 2
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  8. 5
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  9. 12
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java
  10. 4
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java
  11. 58
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  12. 28
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java
  13. 11
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  14. 65
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  15. 56
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  16. 50
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  17. 5
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  18. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java
  19. 18
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  20. 38
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java
  21. 67
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  22. 2
      designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java
  23. 5
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  24. 55
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  25. 38
      designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java
  26. 8
      designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java
  27. 62
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  28. 2
      designer-base/src/main/java/com/fr/design/extra/LoginDialog.java
  29. 43
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  30. 1
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  31. 16
      designer-base/src/main/java/com/fr/design/extra/ShopDialog.java
  32. 32
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  33. 27
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  34. 14
      designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java
  35. 27
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java
  36. 37
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  37. 12
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  38. 14
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  39. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  40. 2
      designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java
  41. 23
      designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java
  42. 17
      designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java
  43. 1
      designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java
  44. 47
      designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java
  45. 10
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  46. 23
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  47. 7
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java
  48. 10
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  49. 29
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  50. 12
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  51. 2
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java
  52. 2
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java
  53. 8
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java
  54. 25
      designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java
  55. 17
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java
  56. 38
      designer-base/src/main/java/com/fr/design/jdk/JdkVersion.java
  57. 46
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  58. 17
      designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java
  59. 11
      designer-base/src/main/java/com/fr/design/mainframe/App.java
  60. 38
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  61. 4
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  62. 95
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  63. 27
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  64. 22
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListenerAdapter.java
  65. 19
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateEvent.java
  66. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java
  67. 3
      designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java
  68. 20
      designer-base/src/main/java/com/fr/design/mainframe/PromptWindow.java
  69. 54
      designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java
  70. 14
      designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java
  71. 103
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java
  72. 29
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java
  73. 40
      designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java
  74. 143
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java
  75. 374
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  76. 102
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java
  77. 159
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java
  78. 51
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java
  79. 218
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java
  80. 308
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java
  81. 94
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ChartStyleSettingPane.java
  82. 292
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java
  83. 63
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java
  84. 81
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java
  85. 51
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/AbstractBackgroundDetailPane.java
  86. 135
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java
  87. 76
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java
  88. 105
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java
  89. 34
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java
  90. 48
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/FormBackgroundSettingPane.java
  91. 159
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java
  92. 215
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java
  93. 119
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java
  94. 97
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java
  95. 223
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java
  96. 49
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/AbstractChartStylePane.java
  97. 69
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartAxisStylePane.java
  98. 113
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartBackgroundStylePane.java
  99. 58
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartDataSheetStylePane.java
  100. 160
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartFontPane.java
  101. Some files were not shown because too many files have changed in this diff Show More

7
build.gradle

@ -64,7 +64,7 @@ allprojects {
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'
implementation 'net.java.dev.jna:jna:5.4.0' implementation 'net.java.dev.jna:jna:5.4.0'
implementation 'org.apache.tomcat:tomcat-catalina:8.5.32' implementation 'org.apache.tomcat:tomcat-catalina:8.5.57'
implementation 'io.socket:socket.io-client:0.7.0' implementation 'io.socket:socket.io-client:0.7.0'
implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.third:fine-third:' + frVersion
implementation 'com.fr.core:fine-core:' + frDevVersion implementation 'com.fr.core:fine-core:' + frDevVersion
@ -72,7 +72,10 @@ allprojects {
implementation 'com.fr.datasource:fine-datasource:' + frVersion implementation 'com.fr.datasource:fine-datasource:' + frVersion
implementation 'com.fr.decision:fine-decision:' + frVersion implementation 'com.fr.decision:fine-decision:' + frVersion
implementation 'com.fr.schedule:fine-schedule:' + frVersion implementation 'com.fr.schedule:fine-schedule:' + frVersion
implementation 'com.fr.report:fine-report-engine:' + frDevVersion implementation 'com.fr.report:engine-report:' + frDevVersion
implementation 'com.fr.report:engine-chart:' + frDevVersion
implementation 'com.fr.report:engine-i18n:' + frDevVersion
implementation 'com.fr.design:design-i18n:' + frDevVersion
testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.easymock:easymock:3.5.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-easymock:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1'

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

@ -163,7 +163,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* alphafine * alphafine
*/ */
private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance();
/** /**
* 阅后即焚的配置项 * 阅后即焚的配置项
*/ */
@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (needCheckEnv) { if (needCheckEnv) {
checkNameEnvMap(); checkNameEnvMap();
} }
GeneralContext.addEnvChangedListener(() -> {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
@Override designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
public void envChanged() {
designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX);
designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME);
}
}); });
} }
@ -245,7 +240,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
//这里不判断路径是.的情况,放在checkValid方法里面,重新选 //这里不判断路径是.的情况,放在checkValid方法里面,重新选
if (installHome != null) { if (installHome != null) {
String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT"); String name = Toolkit.i18nText("Fine-Design_Basic_Engine_DEFAULT");
String envPath = designerEnvManager.getDefaultenvPath(installHome); String envPath = designerEnvManager.getDefaultenvPath(installHome);
designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath)); designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath));
designerEnvManager.setCurEnvName(name); designerEnvManager.setCurEnvName(name);
@ -309,8 +304,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
String today = calender.get(Calendar.YEAR) + "-" + (calender.get(Calendar.MONTH) + 1) + "-" + calender.get(Calendar.DAY_OF_MONTH); String today = calender.get(Calendar.YEAR) + "-" + (calender.get(Calendar.MONTH) + 1) + "-" + calender.get(Calendar.DAY_OF_MONTH);
String fileName = StableUtils.pathJoin(logLocation, "fr_" + today + "_%g.log"); String fileName = StableUtils.pathJoin(logLocation, "fr_" + today + "_%g.log");
if (!new java.io.File(fileName).exists()) { if (!new File(fileName).exists()) {
StableUtils.makesureFileExist(new java.io.File(fileName)); StableUtils.makesureFileExist(new File(fileName));
} }
Handler handler = new FileHandler(fileName, true); Handler handler = new FileHandler(fileName, true);
@ -423,21 +418,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.isHttps = isHttps; this.isHttps = isHttps;
} }
public String getCertificatePath() {
return certificatePath;
}
public void setCertificatePath(String certificatePath) { public void setCertificatePath(String certificatePath) {
this.certificatePath = certificatePath; this.certificatePath = certificatePath;
} }
public String getCertificatePass() {
return certificatePass;
}
public void setCertificatePass(String certificatePass) { public void setCertificatePass(String certificatePass) {
this.certificatePass = certificatePass; this.certificatePass = certificatePass;
} }
@ -545,7 +529,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
return env; return env;
} }
} }
String name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); String name = Toolkit.i18nText("Fine-Design_Basic_Workspace_Default");
LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath); LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath);
this.putEnv(name, newDefaultEnv); this.putEnv(name, newDefaultEnv);
return newDefaultEnv; return newDefaultEnv;
@ -568,7 +552,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
} }
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Default"); return Toolkit.i18nText("Fine-Design_Basic_Workspace_Default");
} }
@ -1424,7 +1408,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return * @return
*/ */
private Locale checkLocale(Locale locale) { private Locale checkLocale(Locale locale) {
return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US; // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN这种,需要找到项目中最匹配的Locale
return SupportLocale.getInstance().isSupport(locale) ?
locale : SupportLocale.getInstance().getSuitableLocale(locale);
} }
private void readReportLengthUnit(XMLableReader reader) { private void readReportLengthUnit(XMLableReader reader) {
@ -1475,7 +1461,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
public String getUUID() { public String getUUID() {
return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid; if (StringUtils.isEmpty(uuid)) {
uuid = UUID.randomUUID().toString();
}
return uuid;
} }
public int getActiveKeyStatus() { public int getActiveKeyStatus() {
@ -1578,7 +1567,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
} }
} }
private void readSnapChatConfig(XMLableReader reader) { private void readSnapChatConfig(XMLableReader reader) {
reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance()); reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance());
} }
@ -1654,7 +1643,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) { if ((tmpVal = reader.getAttrAsString("webinfLocation", null)) != null) {
// marks:兼容6.1的 // marks:兼容6.1的
// marks:设置默认的目录. // marks:设置默认的目录.
String curReportServerName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server"); String curReportServerName = Toolkit.i18nText("Fine-Design_Basic_Server_Embedded_Server");
LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal); LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal);
this.putEnv(curReportServerName, reportServer); this.putEnv(curReportServerName, reportServer);
@ -1801,14 +1790,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
writeSnapChatConfig(writer); writeSnapChatConfig(writer);
writer.end(); writer.end();
} }
private void writeSnapChatConfig(XMLPrintWriter writer) { private void writeSnapChatConfig(XMLPrintWriter writer) {
if (this.snapChatConfig != null) { if (this.snapChatConfig != null) {
this.snapChatConfig.writeXML(writer); this.snapChatConfig.writeXML(writer);
} }
} }
private void writeAlphaFineAttr(XMLPrintWriter writer) { private void writeAlphaFineAttr(XMLPrintWriter writer) {
if (this.alphaFineConfigManager != null) { if (this.alphaFineConfigManager != null) {
this.alphaFineConfigManager.writeXML(writer); this.alphaFineConfigManager.writeXML(writer);
@ -2015,11 +2004,13 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private void writeHttpsParas(XMLPrintWriter writer) { private void writeHttpsParas(XMLPrintWriter writer) {
writer.startTAG(CAS_PARAS); writer.startTAG(CAS_PARAS);
// 这边的密钥path和password没有用处了 当前已经全部储存在对应的WorkspaceConnectionInfo中
// 把历史遗留保存的全部置为空 防止显示明文密钥 后面删除 todo
if (StringUtils.isNotBlank(certificatePath)) { if (StringUtils.isNotBlank(certificatePath)) {
writer.attr(CAS_CERTIFICATE_PATH, certificatePath); writer.attr(CAS_CERTIFICATE_PATH, StringUtils.EMPTY);
} }
if (StringUtils.isNotBlank(certificatePass)) { if (StringUtils.isNotBlank(certificatePass)) {
writer.attr(CAS_CERTIFICATE_PASSWORD, certificatePass); writer.attr(CAS_CERTIFICATE_PASSWORD, StringUtils.EMPTY);
} }
if (isHttps) { if (isHttps) {
writer.attr("enable", true); writer.attr("enable", true);

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

@ -1,10 +1,12 @@
package com.fr.design; package com.fr.design;
import com.fr.common.report.ReportState; import com.fr.common.report.ReportState;
import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
@ -18,7 +20,10 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.TestConnectionResult;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
@ -31,6 +36,7 @@ import com.fr.process.engine.core.FineProcessContext;
import com.fr.rpc.Result; import com.fr.rpc.Result;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.env.PluginErrorRemindDialog;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
@ -40,6 +46,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException; import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
@ -139,27 +146,35 @@ public class EnvChangeEntrance {
template.refreshToolArea(); template.refreshToolArea();
} }
showServiceDialog(selectedEnv); showServiceDialog(selectedEnv);
pluginErrorRemind(selectedEnv);
} 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");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
strategy.showTip(new PopTip() { strategy.showTip(new PopTip() {
@Override @Override
public void show() { public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
} }
}); });
return false; return false;
} catch (WorkspaceCheckException e) {
handleWorkspaceCheckException(e, strategy, connectionInfo);
return false;
} catch (Exception exception) { } catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); if (exception.getCause() instanceof WorkspaceCheckException) {
strategy.showTip(new PopTip() { handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo);
@Override } else {
public void show() { FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
} Toolkit.i18nText("Fine-Design_Basic_Error"),
}); ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
return false; return false;
} }
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
@ -170,6 +185,29 @@ public class EnvChangeEntrance {
return true; return true;
} }
public void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) {
TestConnectionResult result = TestConnectionResult.parseByException(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) {
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
} else {
if (result.isVerifyResult()) {
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
}
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
result.isVerifyResult()
? new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH)
: result.getText(),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
}
/** /**
* 这个功能留着可能会加回来先做注释处理 * 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示 * 切换远程环境之前进行版本检测当版本不一致的时候提示
@ -262,6 +300,22 @@ public class EnvChangeEntrance {
} }
} }
/**
* 插件启动错误信息提示
* @param selectedEnv 选择的工作环境
*/
public void pluginErrorRemind(DesignerWorkspaceInfo selectedEnv) {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
return;
}
String content = PluginErrorRemindHandler.pluginErrorContent();
if (StringUtils.isNotEmpty(content)) {
PluginErrorRemindDialog dialog = new PluginErrorRemindDialog(DesignerContext.getDesignerFrame(), content);
dialog.setVisible(true);
}
}
/** /**
* 判断是否需要做版本验证判断依据为 * 判断是否需要做版本验证判断依据为
* 1选择的环境为远程环境 * 1选择的环境为远程环境
@ -461,7 +515,7 @@ public class EnvChangeEntrance {
/** /**
* 提示显示策略 * 提示显示策略
*/ */
enum PopTipStrategy { public enum PopTipStrategy {
/** /**
* 切换失败就马上提示失败不关闭选择列表对话框 * 切换失败就马上提示失败不关闭选择列表对话框

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

@ -20,6 +20,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI; import com.fr.design.gui.iprogressbar.UIProgressBarUI;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.jdk.JdkVersion;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -39,6 +40,7 @@ import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StableUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
@ -216,7 +218,7 @@ public class PreferencePane extends BasicPane {
oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
oraclePane.add(oracleSpace); oraclePane.add(oracleSpace);
if (!OperatingSystem.isLinux()) { if (!OperatingSystem.isLinux() && JdkVersion.LE_8.support()) {
JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager"));
useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager"));
upmSelectorPane.add(useOptimizedUPMCheckbox); upmSelectorPane.add(useOptimizedUPMCheckbox);

9
designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java

@ -14,10 +14,10 @@ import javax.swing.BoxLayout;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import java.awt.Dimension;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
import java.awt.Dimension;
@Open @Open
public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> { public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
@ -69,7 +69,12 @@ public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
selectedItemScrollPane.setViewportView(selectedItemPane); selectedItemScrollPane.setViewportView(selectedItemPane);
selectedItemScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); selectedItemScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
selectedItemScrollPane.setMinimumSize(new Dimension((int) selectedItemScrollPane.getPreferredSize().getWidth(), MIN_HEIGHT)); selectedItemScrollPane.setMinimumSize(new Dimension((int) selectedItemScrollPane.getPreferredSize().getWidth(), MIN_HEIGHT));
dealScrollPane(selectedItemScrollPane);
propertyChangePane.add(selectedItemScrollPane); propertyChangePane.add(selectedItemScrollPane);
}
protected void dealScrollPane(JScrollPane scrollPane){
} }
public void updateBean(T ob) { public void updateBean(T ob) {

2
designer-base/src/main/java/com/fr/design/condition/ObjectLiteConditionPane.java

@ -77,7 +77,7 @@ public class ObjectLiteConditionPane extends LiteConditionPane<ObjectCondition>
} }
}); });
conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPane(); conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPaneWithGlobalListener();
Component[][] components = { { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConditionB_Operator") + ":"), new UILabel() }, Component[][] components = { { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConditionB_Operator") + ":"), new UILabel() },
{ conditionOPComboBox, conditionValuePane } }; { conditionOPComboBox, conditionValuePane } };

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

@ -38,7 +38,7 @@ public interface UIConstants {
public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png"); public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png");
public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png"); public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png");
public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 1, 0, 0);
public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0); public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0);
public static final Border CELL_ATTR_PRESENTBORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0); public static final Border CELL_ATTR_PRESENTBORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0);
public static final Border CELL_ATTR_NORMALBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 15); public static final Border CELL_ATTR_NORMALBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 15);

5
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -97,7 +97,7 @@ public abstract class DesignTableDataManager {
*/ */
private static void fireDsChanged() { private static void fireDsChanged() {
fireDsChanged(globalDsListeners); fireDsChanged(globalDsListeners);
for (Iterator<Entry<String, List<ChangeListener>>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext();) { for (Iterator<Entry<String, List<ChangeListener>>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext(); ) {
List<ChangeListener> dsListeners = entryIterator.next().getValue(); List<ChangeListener> dsListeners = entryIterator.next().getValue();
fireDsChanged(dsListeners); fireDsChanged(dsListeners);
} }
@ -190,6 +190,7 @@ public abstract class DesignTableDataManager {
} }
dsListeners.add(l); dsListeners.add(l);
} }
/** /**
* 获取数据源source中dsName的所有字段 * 获取数据源source中dsName的所有字段
* *
@ -280,7 +281,7 @@ public abstract class DesignTableDataManager {
Entry<String, TableDataWrapper> entry = entryIt.next(); Entry<String, TableDataWrapper> entry = entryIt.next();
list.add(entry.getKey()); list.add(entry.getKey());
} }
return list.toArray(new String[list.size()]); return list.toArray(new String[0]);
} }
/** /**

12
designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java

@ -72,24 +72,18 @@ public class TableDataCreatorProducer {
public TableDataNameObjectCreator[] createServerTableDataCreator() { public TableDataNameObjectCreator[] createServerTableDataCreator() {
TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"),
"ds",
"/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class,
DBTableDataPane.class); DBTableDataPane.class);
TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"),
"Class",
"/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class,
ClassTableDataPane.class); ClassTableDataPane.class);
TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"),
"Embedded",
"/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class,
EmbeddedTableDataPane.class); EmbeddedTableDataPane.class);
TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"),
"File",
"/com/fr/design/images/data/file.png", FileTableData.class, "/com/fr/design/images/data/file.png", FileTableData.class,
FileTableDataSmallPane.class); FileTableDataSmallPane.class);
TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"),
"Tree",
"/com/fr/design/images/data/tree.png", "/com/fr/design/images/data/tree.png",
RecursionTableData.class, GlobalTreeTableDataPane.class) { RecursionTableData.class, GlobalTreeTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() { public boolean isNeedParameterWhenPopulateJControlPane() {
@ -97,7 +91,6 @@ public class TableDataCreatorProducer {
} }
}; };
TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"),
"Multi",
"/com/fr/design/images/data/multi.png", "/com/fr/design/images/data/multi.png",
ConditionTableData.class, GlobalMultiTDTableDataPane.class) { ConditionTableData.class, GlobalMultiTDTableDataPane.class) {
public boolean isNeedParameterWhenPopulateJControlPane() { public boolean isNeedParameterWhenPopulateJControlPane() {
@ -105,7 +98,6 @@ public class TableDataCreatorProducer {
} }
}; };
TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"),
"Proc",
"/com/fr/design/images/data/store_procedure.png", "/com/fr/design/images/data/store_procedure.png",
StoreProcedure.class, ProcedureDataPane.class) { StoreProcedure.class, ProcedureDataPane.class) {
@Override @Override
@ -113,9 +105,7 @@ public class TableDataCreatorProducer {
return true; return true;
} }
}; };
TableDataNameObjectCreator[] creators = new TableDataNameObjectCreator[]{dataBase, ds_Class, table, fileTable, storeProcedure, multiTable, treeTable}; TableDataNameObjectCreator[] creators = new TableDataNameObjectCreator[]{dataBase, ds_Class, table, fileTable, storeProcedure, multiTable, treeTable};
return merge(creators, ExtraDesignClassManager.getInstance().getServerTableDataCreators()); return merge(creators, ExtraDesignClassManager.getInstance().getServerTableDataCreators());
} }
@ -141,6 +131,6 @@ public class TableDataCreatorProducer {
for (int i = 0; i < coverIndexList.size(); i ++) { for (int i = 0; i < coverIndexList.size(); i ++) {
creators[coverIndexList.get(i)] = coverCreators.get(i); creators[coverIndexList.get(i)] = coverCreators.get(i);
} }
return (TableDataNameObjectCreator[])ArrayUtils.addAll(creators, list.toArray(new TableDataNameObjectCreator[list.size()])); return ArrayUtils.addAll(creators, list.toArray(new TableDataNameObjectCreator[0]));
} }
} }

4
designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java

@ -157,7 +157,9 @@ public class TableDataNameObjectCreator extends NameObjectCreator {
* @param names 名字 * @param names 名字
*/ */
public void addNames(String names) { public void addNames(String names) {
this.names.add(names); if (names != null) {
this.names.add(names);
}
} }
/** /**

58
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -7,6 +7,7 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
@ -23,18 +24,20 @@ import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* TableDataList Pane. * TableDataList Pane.
*/ */
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController {
private boolean isNamePermitted = true; private boolean isNamePermitted = true;
private Map<String, String> dsNameChangedMap = new HashMap<String, String>(); private Map<String, String> dsNameChangedMap = new HashMap<>();
public TableDataPaneListPane() { public TableDataPaneListPane() {
super(); super();
@ -43,11 +46,15 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override @Override
public void propertyChange() { public void propertyChange() {
isNamePermitted = true; isNamePermitted = true;
TableDataSource source = DesignTableDataManager.getEditingTableDataSource();
String[] allDSNames = DesignTableDataManager.getAllDSNames(source);
String[] allListNames = nameableList.getAllNames();
allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY;
String tempName = getEditingName(); String tempName = getEditingName();
if (ComparatorUtils.equals(tempName, selectedName)) {
//说明双击之后又取消了,啥也不用做
return;
}
Set<String> allDSNames = DesignTableDataManager.getGlobalDataSet().keySet();
String[] allListNames = nameableList.getAllNames();
allListNames[editingIndex] = StringUtils.EMPTY;
Object editingType = getEditingType(); Object editingType = getEditingType();
if (!BasicTableDataUtils.checkName(tempName)) { if (!BasicTableDataUtils.checkName(tempName)) {
@ -61,15 +68,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this),
Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"),
Toolkit.i18nText("Fine-Design_Report_Alert"), Toolkit.i18nText("Fine-Design_Report_Alert"),
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
setIllegalIndex(editingIndex); setIllegalIndex(editingIndex);
return; return;
} }
boolean isRepeated = isNameRepeated(new Collection[]{allDSNames, Arrays.asList(allListNames)}, tempName);
if (!ComparatorUtils.equals(tempName, selectedName) if (isRepeated) {
&& isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
isNamePermitted = false; isNamePermitted = false;
nameableList.stopEditing(); nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName)); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName));
@ -81,11 +87,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
setIllegalIndex(editingIndex); setIllegalIndex(editingIndex);
} }
if (nameableList.getSelectedValue() instanceof ListModelElement) { if (nameableList.getSelectedValue() instanceof ListModelElement) {
Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; rename(selectedName, isRepeated ? NameInspector.ILLEGAL_NAME_HOLDER : tempName);
if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) {
rename(selected.getName(), tempName);
}
} }
} }
}); });
@ -93,7 +95,19 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override @Override
public void rename(String oldName, String newName) { public void rename(String oldName, String newName) {
dsNameChangedMap.put(oldName, newName); //如果a改成了b,b又被改成了c,就认为是a改成了c
for (Map.Entry<String, String> entry : dsNameChangedMap.entrySet()) {
if (StringUtils.equals(oldName, entry.getValue())) {
oldName = entry.getKey();
break;
}
}
if (StringUtils.equals(oldName, newName)) {
//a -> b;b -> a,说明没改
dsNameChangedMap.remove(oldName);
} else {
dsNameChangedMap.put(oldName, newName);
}
} }
/** /**
@ -148,7 +162,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
String[] allDsNames = DesignTableDataManager.getAllDSNames(source); String[] allDsNames = DesignTableDataManager.getAllDSNames(source);
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始. // richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = 1; int count = 1;
while (isDsNameRepeated(prefix + count, allDsNames)) { while (isDsNameRepeated(prefix + count, allDsNames)) {
count++; count++;
} }
@ -192,7 +206,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
} }
} }
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); populate(nameObjectList.toArray(new NameObject[0]));
} }
/** /**
@ -209,10 +223,10 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
} }
while (procedurenameIt.hasNext()) { while (procedurenameIt.hasNext()) {
String name = procedurenameIt.next(); String name = procedurenameIt.next();
nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name))); nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name)));
} }
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); populate(nameObjectList.toArray(new NameObject[0]));
} }
@Override @Override
@ -220,7 +234,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
tableDataConfig.removeAllTableData(); tableDataConfig.removeAllTableData();
ProcedureConfig.getInstance().removeAllProcedure(); ProcedureConfig.getInstance().removeAllProcedure();
Nameable[] tableDataArray = this.update(); Nameable[] tableDataArray = this.update();
Map<String,TableData> tableDataMap = new LinkedHashMap<String,TableData>(); Map<String, TableData> tableDataMap = new LinkedHashMap<String, TableData>();
for (int i = 0; i < tableDataArray.length; i++) { for (int i = 0; i < tableDataArray.length; i++) {
NameObject nameObject = (NameObject) tableDataArray[i]; NameObject nameObject = (NameObject) tableDataArray[i];
tableDataMap.put(nameObject.getName(), (TableData) nameObject.getObject()); tableDataMap.put(nameObject.getName(), (TableData) nameObject.getObject());

28
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java

@ -1,21 +1,22 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.*; import java.awt.Color;
import java.awt.Component;
/** /**
* TableData Tree * TableData Tree
@ -31,6 +32,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setCellRenderer(tableDataTreeCellRenderer); this.setCellRenderer(tableDataTreeCellRenderer);
this.setEditable(false); this.setEditable(false);
} }
// CellRenderer // CellRenderer
private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -66,14 +68,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
this.setIcon(null); this.setIcon(null);
this.setText(PENDING.toString()); this.setText(PENDING.toString());
} }
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setSize(dim);
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE); this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);
@ -118,6 +113,11 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
break; break;
} }
new_nodes[ci].setExpanded(cTreeNode.isExpanded()); new_nodes[ci].setExpanded(cTreeNode.isExpanded());
// REPORT-41299 如果建立的是错误的数据集(没有Child的情况)且这个错误数据集处于isExpanded状态,会在后面的if语句中调用getFirstChild()产生异常,因此这里判断一下
if (cTreeNode.isExpanded() && cTreeNode.getChildCount() == 0) {
new_nodes[ci].setExpanded(false);
break;
}
if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) { if (cTreeNode.getFirstChild() instanceof ExpandMutableTreeNode && cTreeNode.isExpanded()) {
checkChildNodes(cTreeNode, new_nodes[ci]); checkChildNodes(cTreeNode, new_nodes[ci]);
} }
@ -152,7 +152,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
/* /*
* p:获得选中的NameObject = name + tabledata. * p:获得选中的NameObject = name + tabledata.
*/ */
public NameObject getSelectedNameObject() { public NameObject getSelectedNameObject() {
TreePath selectedTreePath = this.getSelectionPath(); TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) { if (selectedTreePath == null) {
@ -247,4 +247,4 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
treeModel.reload(root); treeModel.reload(root);
} }
} }

11
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java

@ -69,7 +69,16 @@ public class TreeTableDataComboBox extends UIComboBox {
} }
} }
} }
/**
* 带参刷新方法
* @param source 数据源数据集
*/
public void refresh(TableDataSource source) {
this.source = source;
refresh();
}
public void setSelectedTableDataByName(String name) { public void setSelectedTableDataByName(String name) {
TableDataWrapper tableDataWrapper; TableDataWrapper tableDataWrapper;
if (res_map.get(name) != null) { if (res_map.get(name) != null) {

65
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
@ -10,6 +11,7 @@ import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.scrollruler.ModLineBorder; import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
@ -19,12 +21,24 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/** /**
* Database Connection pane. * Database Connection pane.
@ -48,9 +62,9 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected void initComponents() { protected void initComponents() {
message = new UILabel(); message = new UILabel();
uiLabel = new UILabel(); uiLabel = new UILabel();
okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto")}; String[] defaultEncode = new String[] {Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY)); charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
@ -59,7 +73,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// 按钮. // 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
northPane.add(testPane, BorderLayout.NORTH); northPane.add(testPane, BorderLayout.NORTH);
UIButton testButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection")); UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"));
testPane.add(testButton); testPane.add(testButton);
testButton.addActionListener(testConnectionActionListener); testButton.addActionListener(testConnectionActionListener);
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4)); testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
@ -71,9 +85,9 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
northPane.add(chartSetPane); northPane.add(chartSetPane);
chartSetPane.setBorder(BorderFactory.createTitledBorder( chartSetPane.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP), new ModLineBorder(ModLineBorder.TOP),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced") Toolkit.i18nText("Fine-Design_Basic_Advanced")
)); ));
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":")); chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
} }
protected abstract JPanel mainPanel(); protected abstract JPanel mainPanel();
@ -84,7 +98,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public void populateBean(com.fr.data.impl.Connection ob) { public void populateBean(com.fr.data.impl.Connection ob) {
this.originalCharSet = ob.getOriginalCharsetName(); this.originalCharSet = ob.getOriginalCharsetName();
if (StringUtils.isBlank(originalCharSet)) { if (StringUtils.isBlank(originalCharSet)) {
this.charSetComboBox.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto")); this.charSetComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Encode_Auto"));
} else { } else {
this.charSetComboBox.setSelectedItem(ob.getOriginalCharsetName()); this.charSetComboBox.setSelectedItem(ob.getOriginalCharsetName());
} }
@ -117,24 +131,29 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// Try the java connection. // Try the java connection.
final SwingWorker connectionThread = new SwingWorker() { final SwingWorker<Boolean, Void> connectionThread = new SwingWorker<Boolean, Void>() {
protected Object doInBackground() throws Exception { @Override
protected Boolean doInBackground() throws Exception {
Connection database = DatabaseConnectionPane.this.updateBean();
// 返回连接结果
return DataOperator.getInstance().testConnection(database);
}
@Override
protected void done() {
try { try {
com.fr.data.impl.Connection database = DatabaseConnectionPane.this.updateBean(); boolean connect = get();
boolean connect = DataOperator.getInstance().testConnection(database);
okButton.setEnabled(true); okButton.setEnabled(true);
message.setText(database.connectMessage(connect));
if (connect) { if (connect) {
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully"));
}else{ }else{
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed"));
} }
} catch (Exception exp) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return null;
} }
}; };
@ -158,18 +177,18 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
} }
}); });
dialog.show(); dialog.setVisible(true);
dialog.dispose(); dialog.dispose();
} }
}; };
private void initDialogPane() { private void initDialogPane() {
message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection") + "..."); message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection") + "...");
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false); okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(DatabaseConnectionPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true); dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(DatabaseConnectionPane.this), Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true);
dialog.setSize(new Dimension(268, 118)); dialog.setSize(new Dimension(268, 118));
okButton.setEnabled(false); okButton.setEnabled(false);
JPanel jp = new JPanel(); JPanel jp = new JPanel();
@ -250,4 +269,4 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
} }
} }
} }

56
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -11,6 +11,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -90,9 +91,9 @@ public class JDBCDefPane extends JPanel {
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor(); private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField(); private UITextField DBCP_VALIDATION_QUERY = new UITextField();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")}); private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")}); private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes")}); private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor(); private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor();
private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor(); private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor();
@ -120,13 +121,13 @@ public class JDBCDefPane extends JPanel {
userNameTextField.setName(USER_NAME); userNameTextField.setName(USER_NAME);
passwordTextField = new UIPasswordFieldWithFixedLength(15); passwordTextField = new UIPasswordFieldWithFixedLength(15);
dbtypeButton = new UIButton("."); dbtypeButton = new UIButton(".");
dbtypeButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL")); dbtypeButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Click_Get_Default_URL"));
dbtypeButton.addActionListener(dbtypeButtonActionListener); dbtypeButton.addActionListener(dbtypeButtonActionListener);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
dbtypePane.add(new UILabel((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database") + ":"))); dbtypePane.add(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Database") + ":")));
JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] dbtypeComComponents = {{dbtypeComboBox}}; Component[][] dbtypeComComponents = {{dbtypeComboBox}};
double[] dbtypeRowSize = {p}; double[] dbtypeRowSize = {p};
@ -134,10 +135,10 @@ public class JDBCDefPane extends JPanel {
dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize); dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize);
JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
driverPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Driver") + ":")); driverPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Driver") + ":"));
// 选择ODBC数据源的时候的提示链接 // 选择ODBC数据源的时候的提示链接
JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel odbcTipsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
odbcTipsLink = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) { odbcTipsLink = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")) {
@Override @Override
public void paintComponent(Graphics _gfx) { public void paintComponent(Graphics _gfx) {
super.paintComponent(_gfx); super.paintComponent(_gfx);
@ -146,7 +147,7 @@ public class JDBCDefPane extends JPanel {
} }
}; };
odbcTipsPane.add(odbcTipsLink); odbcTipsPane.add(odbcTipsLink);
odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height)); odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height));
odbcTipsLink.addActionListener(new ActionListener() { odbcTipsLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
@ -167,26 +168,27 @@ public class JDBCDefPane extends JPanel {
urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4); urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
userPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_UserName") + ":")); userPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":"));
JPanel userComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel userComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] userComComponents = {{userNameTextField, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}}; Component[][] userComComponents = {{userNameTextField, new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}};
double[] userRowSize = {p}; double[] userRowSize = {p};
double[] userColumnSize = {f, p, f}; double[] userColumnSize = {f, p, f};
userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4); userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4);
JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
passwordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Password") + ":")); passwordPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":"));
Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},}; Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},};
double[] rowSize = {p, p, p, p}; double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f, 22}; double[] columnSize = {p, f, 22};
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); // REPORT-41450 Windows环境的jdk11下dpi为125%时会因为缩放导致显示问题,因此加个水平gap值
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 6, 6);
innerthis.add(centerPanel); innerthis.add(centerPanel);
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
innerthis.add(southPanel); innerthis.add(southPanel);
southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20)); southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20));
ActionLabel actionLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr")); ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
southPanel.add(actionLabel, BorderLayout.EAST); southPanel.add(actionLabel, BorderLayout.EAST);
actionLabel.addActionListener(new ActionListener() { actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
@ -331,7 +333,7 @@ public class JDBCDefPane extends JPanel {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) { if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
// ben:这个能不能换种处理方案- - // ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser(); JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open")); filechooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false); filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access")); filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame()); int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
@ -373,19 +375,19 @@ public class JDBCDefPane extends JPanel {
double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f}; double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f};
double[] columnSize = {f, f}; double[] columnSize = {f, f};
Component[][] comps = { Component[][] comps = {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT), {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT),
DBCP_TIMEBETWEENEVICTIONRUNSMILLS}, DBCP_TIMEBETWEENEVICTIONRUNSMILLS},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN}, {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT), {new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}}; DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4); JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
@ -395,7 +397,7 @@ public class JDBCDefPane extends JPanel {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"); return Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr");
} }
} }

50
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -15,20 +15,31 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.gui.itable.SortableJTable; import com.fr.design.gui.itable.SortableJTable;
import com.fr.design.gui.itable.TableSorter; import com.fr.design.gui.itable.TableSorter;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
@ -81,7 +92,7 @@ public class PreviewTablePane extends BasicPane {
JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
previewNumberPanel.add(currentPreviewPanel); previewNumberPanel.add(currentPreviewPanel);
currentPreviewPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":")); currentPreviewPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":"));
currentRowsField = new UINumberField(); currentRowsField = new UINumberField();
currentPreviewPanel.add(currentRowsField); currentPreviewPanel.add(currentRowsField);
@ -91,7 +102,7 @@ public class PreviewTablePane extends BasicPane {
JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
previewNumberPanel.add(maxPanel); previewNumberPanel.add(maxPanel);
maxPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":")); maxPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":"));
maxPreviewNumberField = new UINumberField(); maxPreviewNumberField = new UINumberField();
maxPanel.add(maxPreviewNumberField); maxPanel.add(maxPreviewNumberField);
@ -158,7 +169,7 @@ public class PreviewTablePane extends BasicPane {
if (this.dialog == null) { if (this.dialog == null) {
this.dialog = this.showWindow(new JFrame()); this.dialog = this.showWindow(new JFrame());
} }
progressBar = new AutoProgressBar(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
if (getWorker() != null) { if (getWorker() != null) {
getWorker().cancel(true); getWorker().cancel(true);
@ -174,7 +185,7 @@ public class PreviewTablePane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); return Toolkit.i18nText("Fine-Design_Basic_Preview");
} }
private void addLoadedListener(LoadedEventListener l) { private void addLoadedListener(LoadedEventListener l) {
@ -268,7 +279,7 @@ public class PreviewTablePane extends BasicPane {
*/ */
public static EmbeddedTableData previewTableData(TableData tableData, final int keyIndex, final int valueIndex) { public static EmbeddedTableData previewTableData(TableData tableData, final int keyIndex, final int valueIndex) {
PreviewTablePane previewTablePane = new PreviewTablePane(); PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populate(tableData); previewTablePane.populate(tableData);
previewTablePane.resetPreviewTableColumnColor(); previewTablePane.resetPreviewTableColumnColor();
@ -298,13 +309,13 @@ public class PreviewTablePane extends BasicPane {
try { try {
int choiceColumn = Integer.parseInt(columnErrMessage.trim()); int choiceColumn = Integer.parseInt(columnErrMessage.trim());
int tatalColumn = Integer.parseInt(tatolColumnErrMessage.trim()); int tatalColumn = Integer.parseInt(tatolColumnErrMessage.trim());
columnErrMessage = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Preview_Warn_Text", choiceColumn + 1, tatalColumn); columnErrMessage = Toolkit.i18nText("Fine-Design_Basic_Tabledata_Preview_Warn_Text", choiceColumn + 1, tatalColumn);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return; return;
} }
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
} }
private void populate(TableData tableData) throws Exception { private void populate(TableData tableData) throws Exception {
@ -317,7 +328,7 @@ public class PreviewTablePane extends BasicPane {
} }
private void previewTableDataSQL() throws Exception { private void previewTableDataSQL() throws Exception {
connectionBar = new AutoProgressBar(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
getWorker().cancel(true); getWorker().cancel(true);
getDialog().setVisible(false); getDialog().setVisible(false);
@ -365,13 +376,14 @@ public class PreviewTablePane extends BasicPane {
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase());
if (!status) { if (!status) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
} }
} finally { } finally {
connectionBar.close(); // 将close操作放到EDT线程中
UIUtil.invokeLaterIfNeeded(() -> connectionBar.close());
} }
TableDataSource dataSource = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getTarget(); TableDataSource dataSource = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget();
previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true, progressBar); previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true, progressBar);
// parameterInputDialog // parameterInputDialog
// update之后的parameters,转成一个parameterMap,用于预览TableData // update之后的parameters,转成一个parameterMap,用于预览TableData
@ -396,7 +408,7 @@ public class PreviewTablePane extends BasicPane {
if (!(e instanceof CancellationException)) { if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
} }
dialog.setVisible(false); dialog.setVisible(false);
} finally { } finally {
@ -425,7 +437,7 @@ public class PreviewTablePane extends BasicPane {
public static void previewStoreData(final ProcedureDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) { public static void previewStoreData(final ProcedureDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) {
final PreviewTablePane previewTablePane = new PreviewTablePane(); final PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.storeProcedureDataModel = storeProcedureDataModel; previewTablePane.storeProcedureDataModel = storeProcedureDataModel;
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populateStoreDataSQL(); previewTablePane.populateStoreDataSQL();
@ -442,7 +454,7 @@ public class PreviewTablePane extends BasicPane {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
previewTablePane.fireLoadedListener(); previewTablePane.fireLoadedListener();
previewTablePane.showWindow(DesignerContext.getDesignerFrame()).setVisible(true); previewTablePane.showWindow(new JFrame()).setVisible(true);
} }
/** /**
@ -456,7 +468,7 @@ public class PreviewTablePane extends BasicPane {
for (int i = 0; i < tableSize; i++) { for (int i = 0; i < tableSize; i++) {
PreviewTablePane previewTablePane = new PreviewTablePane(); PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.storeProcedureDataModel = storeProcedureDataModels[i]; previewTablePane.storeProcedureDataModel = storeProcedureDataModels[i];
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populateStoreDataSQL(); previewTablePane.populateStoreDataSQL();
} catch (Exception e) { } catch (Exception e) {
@ -469,13 +481,13 @@ public class PreviewTablePane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); return Toolkit.i18nText("Fine-Design_Basic_Preview");
} }
}; };
prieviewPane.setLayout(FRGUIPaneFactory.createBorderLayout()); prieviewPane.setLayout(FRGUIPaneFactory.createBorderLayout());
prieviewPane.add(tabPreviewpane, BorderLayout.CENTER); prieviewPane.add(tabPreviewpane, BorderLayout.CENTER);
prieviewPane.showWindow(DesignerContext.getDesignerFrame()).setVisible(true); prieviewPane.showWindow(new JFrame()).setVisible(true);
} }
private void populateStoreDataSQL() throws Exception { private void populateStoreDataSQL() throws Exception {

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

@ -185,7 +185,8 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
box.setMinimumSize(new Dimension(300, 400)); box.setMinimumSize(new Dimension(300, 400));
// 防止数据连接名过长时影响 split pane 分割效果 // 防止数据连接名过长时影响 split pane 分割效果
connectionTableProcedurePane.setMinimumSize(new Dimension(250, 400)); // 本界面中给MaxMemRowCountPanel留的空间太小,造成MaxMemRowCountPanel显示异常,这边减小一点最小宽度,拉长MaxMemRowCountPanel
connectionTableProcedurePane.setMinimumSize(new Dimension(230, 400));
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400)); connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
// 使用SplitPane // 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane); JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);
@ -218,7 +219,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update(); List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]);
editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps));
} }

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java

@ -21,7 +21,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
private static final int MAX_IN_MEMORY = 1; private static final int MAX_IN_MEMORY = 1;
private static final String[] CACHE_LIST = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"), private static final String[] CACHE_LIST = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") }; com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") };
private static final int MAX_WIDTH = getMaxComBoBoxWidth() > 200 ? 350 : 250; private static final int MAX_WIDTH = getMaxComBoBoxWidth() > 200 ? 350 : 280;
private static final int MAX_COMPONENT_COUNT_OF_MAX_MEMORY = 4; private static final int MAX_COMPONENT_COUNT_OF_MAX_MEMORY = 4;
private static int getMaxComBoBoxWidth() { private static int getMaxComBoBoxWidth() {
int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]); int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]);
@ -73,6 +73,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
switchCache = new UIComboBox(CACHE_LIST); switchCache = new UIComboBox(CACHE_LIST);
switchCache.addActionListener(switchStateL); switchCache.addActionListener(switchStateL);
numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1); numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1);
numberSpinner.setNumberFieldColumns(3);
} }
private void showAllPanel() { private void showAllPanel() {

18
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -5,6 +5,7 @@ import com.fr.base.StoreProcedureParameter;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection; import com.fr.data.impl.NameDatabaseConnection;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -29,13 +30,19 @@ import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionConfig;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
@ -273,7 +280,8 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
sp.setCalculating(true); sp.setCalculating(true);
sp.creatDataModel(Calculator.createCalculator()); ProcedureDataModel[] dataModels = DesignTableDataManager.createLazyDataModel(sp, false);
sp.refreshDataModelListAndResultNames(dataModels);
return null; return null;
} }

38
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java

@ -35,18 +35,18 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 获取数据集的所有列名list * 获取数据集的所有列名list
* *
* @return 数据集的所有列名list * @return 数据集的所有列名list
* *
* *
* @date 2014-11-24-下午3:51:41 * @date 2014-11-24-下午3:51:41
* *
*/ */
public List<String> calculateColumnNameList() { public List<String> calculateColumnNameList() {
if(columnNameList != null){ if(columnNameList != null){
return columnNameList; return columnNameList;
} }
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter();
TableDataSource tds = adapter == null ? null : adapter.getBook(); TableDataSource tds = adapter == null ? null : adapter.getBook();
String[] colNames = tabledata.getColumnNames(tds); String[] colNames = tabledata.getColumnNames(tds);
@ -56,13 +56,13 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
} else if (ArrayUtils.isNotEmpty(colNamesInCache)) { } else if (ArrayUtils.isNotEmpty(colNamesInCache)) {
return toColumnNameList(colNamesInCache); return toColumnNameList(colNamesInCache);
} }
EmbeddedTableData embeddedTableData = null; EmbeddedTableData embeddedTableData = null;
try { try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false); embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false);
} catch (Exception e) { } catch (Exception e) {
if (e.getMessage()!=null) { if (e.getMessage()!=null) {
DesignUtils.errorMessage(e.getMessage()); DesignUtils.errorMessage(e.getMessage());
} }
} }
columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData);
@ -78,12 +78,12 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 生成子节点 * 生成子节点
* *
* @return 生成子节点 * @return 生成子节点
* *
* *
* @date 2014-11-24-下午3:51:17 * @date 2014-11-24-下午3:51:17
* *
*/ */
public ExpandMutableTreeNode[] load() { public ExpandMutableTreeNode[] load() {
List<String> namelist = calculateColumnNameList(); List<String> namelist = calculateColumnNameList();
@ -97,10 +97,10 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 预览数据集 * 预览数据集
* *
* *
* @date 2014-11-24-下午3:50:20 * @date 2014-11-24-下午3:50:20
* *
*/ */
public void previewData() { public void previewData() {
PreviewTablePane.previewTableData(tabledata); PreviewTablePane.previewTableData(tabledata);
@ -108,30 +108,30 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
/** /**
* 预览数据集,带有显示值和实际值的标记结果 * 预览数据集,带有显示值和实际值的标记结果
* *
* @param keyIndex 实际值 * @param keyIndex 实际值
* @param valueIndex 显示值 * @param valueIndex 显示值
* *
* *
* @date 2014-11-24-下午3:50:20 * @date 2014-11-24-下午3:50:20
* *
*/ */
public void previewData(final int keyIndex,final int valueIndex){ public void previewData(final int keyIndex,final int valueIndex){
PreviewTablePane.previewTableData(tabledata, keyIndex, valueIndex); PreviewTablePane.previewTableData(tabledata, keyIndex, valueIndex);
} }
@Override @Override
public String getTableDataName(){ public String getTableDataName(){
return name; return name;
} }
/** /**
* 获取数据集的面板 * 获取数据集的面板
* *
* @return 数据集面板 * @return 数据集面板
* *
* *
* @date 2014-11-24-下午3:50:00 * @date 2014-11-24-下午3:50:00
* *
*/ */
public AbstractTableDataPane<?> creatTableDataPane() { public AbstractTableDataPane<?> creatTableDataPane() {
return TableDataFactory.creatTableDataPane(tabledata, name); return TableDataFactory.creatTableDataPane(tabledata, name);
@ -143,4 +143,4 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
&& ComparatorUtils.equals(this.tabledata, ((AbstractTableDataWrapper) obj).getTableData()); && ComparatorUtils.equals(this.tabledata, ((AbstractTableDataWrapper) obj).getTableData());
} }
} }

67
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -7,17 +7,16 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JOptionPane; import javax.swing.JFrame;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -50,7 +49,6 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
private AutoProgressBar connectionBar; private AutoProgressBar connectionBar;
private ProcedureDataModel[] dataModels; private ProcedureDataModel[] dataModels;
private SwingWorker worker; private SwingWorker worker;
private BasicDialog dialog;
private int previewModel; private int previewModel;
public StoreProcedureDataWrapper(StoreProcedure storeProcedure, String storeprocedureName, String dsName) { public StoreProcedureDataWrapper(StoreProcedure storeProcedure, String storeprocedureName, String dsName) {
@ -71,19 +69,8 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
if (needLoad) { if (needLoad) {
setWorker(); setWorker();
} }
dialog = PreviewTablePane.getInstance().getDialog(); loadingBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
dialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
getWorker().cancel(true);
}
public void doCancel() {
getWorker().cancel(true);
}
});
loadingBar = new AutoProgressBar(dialog, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
getDialog().setVisible(false);
getWorker().cancel(true); getWorker().cancel(true);
} }
}; };
@ -93,17 +80,17 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 数据集执行结果返回的所有字段 * 数据集执行结果返回的所有字段
* *
* @return 数据集执行结果返回的所有字段 * @return 数据集执行结果返回的所有字段
* *
* *
* @date 2014-12-3-下午7:43:17 * @date 2014-12-3-下午7:43:17
* *
*/ */
public List<String> calculateColumnNameList() { public List<String> calculateColumnNameList() {
if (columnNameList != null) { if (columnNameList != null) {
return columnNameList; return columnNameList;
} }
if (!createStore(false)) { if (!createStore(false)) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData")); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData"));
return new ArrayList<String>(); return new ArrayList<String>();
} }
columnNameList = Arrays.asList(procedureDataModel.getColumnName()); columnNameList = Arrays.asList(procedureDataModel.getColumnName());
@ -114,10 +101,10 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 生成子节点 * 生成子节点
* *
* @return 节点数组 * @return 节点数组
* *
* *
* @date 2014-12-3-下午7:06:47 * @date 2014-12-3-下午7:06:47
* *
*/ */
public ExpandMutableTreeNode[] load() { public ExpandMutableTreeNode[] load() {
List<String> namelist; List<String> namelist;
@ -160,25 +147,16 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/** /**
* 预览数据 * 预览数据
* *
* @param previewModel 预览模式, 全部还是一个 * @param previewModel 预览模式, 全部还是一个
* *
* *
* @date 2014-12-3-下午7:05:50 * @date 2014-12-3-下午7:05:50
* *
*/ */
public void previewData(final int previewModel) { public void previewData(final int previewModel) {
this.previewModel = previewModel; this.previewModel = previewModel;
new SwingWorker() { connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
protected Object doInBackground() throws Exception {
loadingBar.close();
PreviewTablePane.resetPreviewTable();
dialog.setVisible(true);
return null;
}
}.execute();
connectionBar = new AutoProgressBar(dialog, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
connectionBar.close(); connectionBar.close();
worker.cancel(true); worker.cancel(true);
@ -190,13 +168,13 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
private void setWorker() { private void setWorker() {
worker = new SwingWorker<Void, Void>() { worker = new SwingWorker<Void, Void>() {
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
loadingBar.close();
PreviewTablePane.resetPreviewTable();
connectionBar.start(); connectionBar.start();
boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection());
if (!status) { if (!status) {
connectionBar.close(); connectionBar.close();
// bug 61345 预览失败时,关闭窗口 throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
dialog.setVisible(false);
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
connectionBar.close(); connectionBar.close();
storeProcedure.resetDataModelList(); storeProcedure.resetDataModelList();
@ -208,7 +186,6 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
try { try {
get(); get();
loadingBar.close(); loadingBar.close();
dialog.setVisible(false);
switch (previewModel) { switch (previewModel) {
case StoreProcedureDataWrapper.PREVIEW_ALL: case StoreProcedureDataWrapper.PREVIEW_ALL:
PreviewTablePane.previewStoreDataWithAllDs(dataModels); PreviewTablePane.previewStoreDataWithAllDs(dataModels);
@ -228,10 +205,6 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
}; };
} }
private BasicDialog getDialog() {
return this.dialog;
}
private SwingWorker getWorker() { private SwingWorker getWorker() {
return this.worker; return this.worker;
} }
@ -240,10 +213,10 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/** /**
* 预览返回的一个数据集 * 预览返回的一个数据集
* *
* *
* @date 2014-12-3-下午7:42:53 * @date 2014-12-3-下午7:42:53
* *
*/ */
public void previewData() { public void previewData() {
previewData(-1, -1); previewData(-1, -1);
@ -253,13 +226,13 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/** /**
* 预览返回的一个数据集带有显示值和实际值的标记结果 * 预览返回的一个数据集带有显示值和实际值的标记结果
* *
* @param keyIndex 实际值 * @param keyIndex 实际值
* @param valueIndex 显示值 * @param valueIndex 显示值
* *
* *
* @date 2014-12-3-下午7:42:27 * @date 2014-12-3-下午7:42:27
* *
*/ */
public void previewData(final int keyIndex, final int valueIndex) { public void previewData(final int keyIndex, final int valueIndex) {
PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex); PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex);

2
designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java

@ -35,7 +35,7 @@ public abstract class ErrorDialog extends JDialog implements ActionListener {
JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
UILabel boldFontLabel = new UILabel(message); UILabel boldFontLabel = new UILabel(message);
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us"));
Font font = FRFont.getInstance("Dialog", Font.BOLD, 20); Font font = FRFont.getInstance(label.getFont().getFontName(), Font.BOLD, 20);
boldFontLabel.setFont(font); boldFontLabel.setFont(font);
messagePane.add(boldFontLabel); messagePane.add(boldFontLabel);
messagePane.add(label); messagePane.add(label);

5
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -116,6 +116,11 @@ public abstract class UIDialog extends JDialog {
doCancel(); doCancel();
} }
}); });
applyEnterAction();
}
protected void applyEnterAction() {
JPanel defaultPane = (JPanel) this.getContentPane(); JPanel defaultPane = (JPanel) this.getContentPane();
InputMap inputMapAncestor = defaultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); InputMap inputMapAncestor = defaultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = defaultPane.getActionMap(); ActionMap actionMap = defaultPane.getActionMap();

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

@ -0,0 +1,55 @@
package com.fr.design.dialog.link;
import com.fr.design.gui.ilable.UILabel;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.net.URI;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
/**
* 用来构建JOptionPane带超链的消息提示
*
* @author hades
* @version 10.0
* Created by hades on 2020/10/23
*/
public class MessageWithLink extends JEditorPane {
public MessageWithLink(String message, String linkName, String link) {
super("text/html", "<html><body style=\"" + getStyle() + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>");
addHyperlinkListener(e -> {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(URI.create(link));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
});
setEditable(false);
setBorder(null);
}
public MessageWithLink(String linkName, String link ) {
this(StringUtils.EMPTY, linkName, link);
}
private static StringBuilder getStyle() {
// 构建和相同风格样式
UILabel label = new UILabel();
Font font = label.getFont();
Color color = label.getBackground();
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("background-color: rgb(").append(color.getRed()).append(",").append(color.getGreen()).append(",").append(color.getBlue()).append(");");
return style;
}
}

38
designer-base/src/main/java/com/fr/design/editor/ValueEditorPaneFactory.java

@ -19,17 +19,18 @@ import com.fr.design.editor.editor.TextEditor;
import com.fr.design.editor.editor.WidgetNameEditor; import com.fr.design.editor.editor.WidgetNameEditor;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import java.awt.BorderLayout;
import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JPanel;
public class ValueEditorPaneFactory { public class ValueEditorPaneFactory {
@ -155,6 +156,16 @@ public class ValueEditorPaneFactory {
return createValueEditorPane(allEditors(), StringUtils.EMPTY, StringUtils.EMPTY); return createValueEditorPane(allEditors(), StringUtils.EMPTY, StringUtils.EMPTY);
} }
/**
* 带有所有编辑器的ValueEditorPane
* 同时需要注册全局监听的编辑器注册下监听
*
* @return 值编辑器面板
*/
public static ValueEditorPane createAllValueEditorPaneWithGlobalListener() {
return createValueEditorPane(allEditorsWithGlobalListener(), StringUtils.EMPTY, StringUtils.EMPTY);
}
/** /**
* 创建不带公式面板的pane * 创建不带公式面板的pane
* *
@ -359,6 +370,29 @@ public class ValueEditorPaneFactory {
}; };
} }
/**
* 所有类型的编辑器
* 同时注册需要的监听
*
* @return 值编辑器
*/
public static Editor<?>[] allEditorsWithGlobalListener() {
FormulaEditor formulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Basic_Parameter_Formula"));
ColumnSelectedEditor columnSelectedEditor = new ColumnSelectedEditor();
columnSelectedEditor.registerDSChangeListener();
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, Toolkit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new ParameterEditor(),
new ColumnRowEditor(Toolkit.i18nText("Fine-Design_Basic_Cell")),
columnSelectedEditor,
};
}
/** /**
* 不带公式编辑器 * 不带公式编辑器
* *

8
designer-base/src/main/java/com/fr/design/editor/editor/ColumnSelectedEditor.java

@ -3,6 +3,7 @@ package com.fr.design.editor.editor;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.data.SimpleDSColumn; import com.fr.data.SimpleDSColumn;
import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
@ -22,7 +23,7 @@ import java.util.regex.Pattern;
* @author zhou * @author zhou
* @since 2012-3-29下午6:05:08 * @since 2012-3-29下午6:05:08
*/ */
public class ColumnSelectedEditor extends Editor<SimpleDSColumn> { public class ColumnSelectedEditor extends Editor<SimpleDSColumn> implements Prepare4DataSourceChange {
TableDataComboBox tableDataComboBox; TableDataComboBox tableDataComboBox;
private UIComboBox columnNameComboBox; private UIComboBox columnNameComboBox;
protected String[] columnNames; protected String[] columnNames;
@ -107,4 +108,9 @@ public class ColumnSelectedEditor extends Editor<SimpleDSColumn> {
tableDataComboBox.setSelectedItem(null); tableDataComboBox.setSelectedItem(null);
columnNameComboBox.setSelectedItem(null); columnNameComboBox.setSelectedItem(null);
} }
@Override
public void registerDSChangeListener() {
tableDataComboBox.registerGlobalDSChangeListener();
}
} }

62
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -25,13 +25,19 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private static final String HOST_NAME = "127.0.0.1"; private static final String HOST_NAME = "127.0.0.1";
private static final String LOCAL_HOTS_NAME = "localhost"; private static final String LOCAL_HOTS_NAME = "localhost";
private static final String QUOTATION = ":"; private static final String QUOTATION = ":";
private static final String PORT = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort()); private static String port = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
static { static {
FILTER_SET.add(HTTP + HOST_NAME + QUOTATION + PORT + PATH); initFilerSet(port);
FILTER_SET.add(HTTPS + HOST_NAME + QUOTATION + PORT + PATH); }
FILTER_SET.add(HTTP + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTPS + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH); private static void initFilerSet(String newPort) {
FILTER_SET.clear();
FILTER_SET.add(HTTP + HOST_NAME + QUOTATION + newPort + PATH);
FILTER_SET.add(HTTPS + HOST_NAME + QUOTATION + newPort + PATH);
FILTER_SET.add(HTTP + LOCAL_HOTS_NAME + QUOTATION + newPort + PATH);
FILTER_SET.add(HTTPS + LOCAL_HOTS_NAME + QUOTATION + newPort + PATH);
port = newPort;
} }
private String name; private String name;
@ -40,6 +46,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private WorkspaceConnectionInfo connection; private WorkspaceConnectionInfo connection;
/**
* 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文
* 仅保证当前新增是加密的
*/
private boolean newCreated;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) {
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
info.connection = connection; info.connection = connection;
@ -79,12 +91,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
return remindTime; return remindTime;
} }
public boolean isNewCreated() {
return newCreated;
}
public void setNewCreated(boolean newCreated) {
this.newCreated = newCreated;
}
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY);
this.newCreated = reader.getAttrAsBoolean("newCreated", false);
} }
if (reader.isChildNode()) { if (reader.isChildNode()) {
String tagName = reader.getTagName(); String tagName = reader.getTagName();
@ -92,32 +113,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String url = reader.getAttrAsString("url", StringUtils.EMPTY); String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY);
//密码解密 //密码解密
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); String certSecretKey = readCertSecretKey(reader);
boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd); this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd);
} }
} }
} }
private String readCertSecretKey(XMLableReader reader) {
if (isNewCreated()) {
return SecurityToolbox.defaultDecrypt(reader.getAttrAsString("certSecretKey", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n"));
} else {
return reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
}
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name); writer.attr("name", name);
writer.attr("remindTime", remindTime); writer.attr("remindTime", remindTime);
writer.attr("newCreated", isNewCreated());
if (this.connection != null) { if (this.connection != null) {
writer.startTAG("Connection"); writer.startTAG("Connection");
writer.attr("url", connection.getUrl()); writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName()); writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath()); writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey()); writeCertSecretKey(writer);
writer.attr("rememberPwd", connection.isRememberPwd()); writer.attr("rememberPwd", connection.isRememberPwd());
writer.end(); writer.end();
} }
} }
private void writeCertSecretKey(XMLPrintWriter writer) {
if (isNewCreated()) {
writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey()));
} else {
writer.attr("certSecretKey", connection.getCertSecretKey());
}
}
@Override @Override
@SuppressWarnings("squid:S2975") @SuppressWarnings("squid:S2975")
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
@ -132,12 +170,18 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public boolean checkValid() { public boolean checkValid() {
boolean result = false; boolean result = false;
String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
if (!ComparatorUtils.equals(port, newPort)) {
// 使用过程中 更改了内置服务器端口 重新初始化下
initFilerSet(newPort);
}
if (FILTER_SET.contains(connection.getUrl())) { if (FILTER_SET.contains(connection.getUrl())) {
FineLoggerFactory.getLogger().error("url is same with local designer"); FineLoggerFactory.getLogger().error("url is same with local designer");
return result; return result;
} }
try { try {
result = WorkContext.getConnector().testConnection(connection); WorkContext.getConnector().validateVT(connection);
result = true;
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return result; return result;

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

@ -24,7 +24,7 @@ public class LoginDialog extends UIDialog {
} }
private void init(Component pane) { private void init(Component pane) {
if (StableUtils.getMajorJavaVersion() == 8) { if (StableUtils.getMajorJavaVersion() >= 8) {
setUndecorated(true); setUndecorated(true);
} }
JPanel panel = (JPanel) getContentPane(); JPanel panel = (JPanel) getContentPane();

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

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

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

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

16
designer-base/src/main/java/com/fr/design/extra/ShopDialog.java

@ -2,6 +2,7 @@ package com.fr.design.extra;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.jdk.JdkVersion;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -12,21 +13,30 @@ import java.awt.*;
* Created by vito on 16/4/18. * Created by vito on 16/4/18.
*/ */
public class ShopDialog extends UIDialog { public class ShopDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(900, 700);
public ShopDialog(Frame frame, BasicPane pane) { public ShopDialog(Frame frame, BasicPane pane) {
super(frame); super(frame);
if (StableUtils.getMajorJavaVersion() == 8) { if (StableUtils.getMajorJavaVersion() >= 8) {
setUndecorated(true); setUndecorated(true);
} }
JPanel panel = (JPanel) getContentPane(); JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout()); panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER); add(pane, BorderLayout.CENTER);
setSize(DEFAULT_SHOP); setSize(createDefaultDimension());
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
setResizable(false); setResizable(false);
} }
private Dimension createDefaultDimension() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// jdk11 分辨率较低 缩放较大时 屏幕高度小于或接近设定的高度 需要调整下
if (JdkVersion.GE_9.support() && screenSize.height - 700 < 50) {
return new Dimension(900, screenSize.height - 100);
} else {
return new Dimension(900, 700);
}
}
@Override @Override
public void checkValid() throws Exception { public void checkValid() throws Exception {
// do nothing // do nothing

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -13,6 +13,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateFactory; import com.fr.design.mainframe.JTemplateFactory;
import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.ui.util.UIUtil;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.StashedFILE; import com.fr.file.StashedFILE;
@ -22,6 +23,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import javax.swing.SwingUtilities;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -427,4 +429,16 @@ public class HistoryTemplateListCache implements CallbackEvent {
jt.refreshResource(); jt.refreshResource();
} }
} }
/**
* 重绘当前模板
*/
public void repaintCurrentEditingTemplate(){
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
getCurrentEditingTemplate().repaint();
}
});
}
} }

7
designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java

@ -27,6 +27,7 @@ import java.awt.Component;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.Collection;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider { public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List"; private static final String LIST_NAME = "JControl_List";
@ -190,9 +191,9 @@ public abstract class JListControlPane extends JControlPane implements ListContr
return getHelper().getSelectedName(); return getHelper().getSelectedName();
} }
protected boolean isNameRepeated(java.util.List[] list, String name) { protected boolean isNameRepeated(Collection[] collections, String name) {
for (int i = 0; i < list.length; i++) { for (int i = 0; i < collections.length; i++) {
if (list[i].contains(name)) { if (collections[i].contains(name)) {
isNameRepeated = true; isNameRepeated = true;
return true; return true;
} }

2
designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java

@ -65,7 +65,7 @@ class ListControlPaneHelper {
res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); res.add(((ListModelElement) listModel.getElementAt(i)).wrapper);
} }
return res.toArray(new Nameable[res.size()]); return res.toArray(new Nameable[0]);
} }
/** /**

23
designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java

@ -26,14 +26,14 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.List; import java.util.List;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable { public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable {
private TreeTableDataComboBox treeTableDataComboBox; private TreeTableDataComboBox treeTableDataComboBox;
@ -61,6 +61,23 @@ public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previe
tdChange(); tdChange();
} }
}); });
// REPORT-38762 加一个展开监听事件,下拉框展开时刷新一下数据集
treeTableDataComboBox.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
treeTableDataComboBox.refresh(DesignTableDataManager.getEditingTableDataSource());
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
selectTreeDataPanel.add(treeTableDataComboBox); selectTreeDataPanel.add(treeTableDataComboBox);
treeTableDataComboBox.setPreferredSize(new Dimension(200, 25)); treeTableDataComboBox.setPreferredSize(new Dimension(200, 25));
treeTableDataComboBox.setSelectedIndex(-1); treeTableDataComboBox.setSelectedIndex(-1);

17
designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java

@ -1,17 +1,16 @@
package com.fr.design.gui.frpane; package com.fr.design.gui.frpane;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.NumberDragBar; import com.fr.design.gui.style.NumberDragBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Dimension;
public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNameObserver { public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNameObserver {
private static final long serialVersionUID = -8681716725163358249L; private static final long serialVersionUID = -8681716725163358249L;
@ -35,7 +34,7 @@ public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNam
public UINumberDragPane(double minValue, double maxValue, double dierta) { public UINumberDragPane(double minValue, double maxValue, double dierta) {
dragBar = new NumberDragBar((int) minValue, (int) maxValue); dragBar = new NumberDragBar((int) minValue, (int) maxValue);
spinner = new UISpinner(minValue, maxValue, dierta, minValue); spinner = createUISpinner(minValue, maxValue, dierta);
spinner.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Text_Rotation")); spinner.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Text_Rotation"));
this.setLayout(new BorderLayout(4, 0)); this.setLayout(new BorderLayout(4, 0));
this.add(spinner, BorderLayout.EAST); this.add(spinner, BorderLayout.EAST);
@ -66,6 +65,10 @@ public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNam
}); });
} }
protected UISpinner createUISpinner(double minValue, double maxValue, double dierta) {
return new UISpinner(minValue, maxValue, dierta, minValue);
}
/** /**
* 添加事件 * 添加事件
* @param l 事件 * @param l 事件

1
designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java

@ -142,6 +142,7 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener {
this.model.clear(); this.model.clear();
this.model.addAll(dependenceList); this.model.addAll(dependenceList);
this.model.fireTableDataChanged();
} }

47
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java → designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java

@ -1,11 +1,9 @@
package com.fr.design.chartx.component.combobox; package com.fr.design.gui.icombobox;
import com.fr.base.ChartColorMatching; import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig; import com.fr.base.ChartPreStyleConfig;
import com.fr.cert.token.lang.Collections; import com.fr.cert.token.lang.Collections;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
@ -36,11 +34,18 @@ public class ColorSchemeComboBox extends UIComboBox {
private Map<String, ColorInfo> colorSchemes; private Map<String, ColorInfo> colorSchemes;
private boolean preDefined;
public ColorSchemeComboBox() { public ColorSchemeComboBox() {
this(null); this(null, false);
} }
public ColorSchemeComboBox(Map<String, ColorInfo> colorSchemes) { public ColorSchemeComboBox(Map<String, ColorInfo> colorSchemes) {
this(colorSchemes, false);
}
public ColorSchemeComboBox(Map<String, ColorInfo> colorSchemes, boolean preDefined) {
this.preDefined = preDefined;
//通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。 //通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。
if (colorSchemes == null) { if (colorSchemes == null) {
colorSchemes = getColorSchemesFromConfig(); colorSchemes = getColorSchemesFromConfig();
@ -59,22 +64,26 @@ public class ColorSchemeComboBox extends UIComboBox {
//所有的样式名称 //所有的样式名称
Iterator names = config.names(); Iterator names = config.names();
//添加默认的方案和第一个方案 if (preDefined) {
String defaultName = config.getCurrentStyle(); colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Predefined"), null);
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
if (names.hasNext()) {
Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) {
defaultStyle = firstStyle;
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
} else { } else {
ColorInfo colorInfo = new ColorInfo(); //添加默认的方案和第一个方案
colorInfo.setGradient(false); String defaultName = config.getCurrentStyle();
colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY)); ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo); if (names.hasNext()) {
Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) {
defaultStyle = firstStyle;
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
} else {
ColorInfo colorInfo = new ColorInfo();
colorInfo.setGradient(false);
colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY));
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo);
}
} }
//添加其他的配色方案 //添加其他的配色方案

10
designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -19,7 +19,7 @@ import java.awt.event.MouseMotionListener;
public class UIEastResizableContainer extends JPanel { public class UIEastResizableContainer extends JPanel {
private static final long serialVersionUID = 1854340560790476907L; private static final long serialVersionUID = 1854340560790476907L;
public static final int MAX_CONTAINER_WIDTH = 500; public static final int MAX_CONTAINER_WIDTH = 340;
public static final int MIN_CONTAINER_WIDTH = 286; public static final int MIN_CONTAINER_WIDTH = 286;
private int containerWidth = 240; private int containerWidth = 240;
@ -266,13 +266,7 @@ public class UIEastResizableContainer extends JPanel {
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
containerWidth = UIEastResizableContainer.this.getWidth() + (UIEastResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); // do noting
containerWidth = Math.min(containerWidth, MAX_CONTAINER_WIDTH);
containerWidth = Math.max(containerWidth, MIN_CONTAINER_WIDTH);
refreshContainer();
if ( DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize();
}
} }
}); });
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {

23
designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -1,12 +1,10 @@
package com.fr.design.gui.icontainer; package com.fr.design.gui.icontainer;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.collections.utils.MathUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -45,6 +43,7 @@ public class UIResizableContainer extends JPanel {
private boolean isLeftRightDragEnabled = true; private boolean isLeftRightDragEnabled = true;
private boolean isDownPaneVisible = true ; private boolean isDownPaneVisible = true ;
private int paraHeight; private int paraHeight;
private int parentHeight = -1;
public UIResizableContainer(int direction) { public UIResizableContainer(int direction) {
this(new JPanel(), new JPanel(), direction); this(new JPanel(), new JPanel(), direction);
@ -158,8 +157,7 @@ public class UIResizableContainer extends JPanel {
} }
/** /**
* 设置关闭设计器前最后一次上下子面板的高度 * 设置关闭设计器前最新的上子面板的高度比例
*
* @param toolPaneY * @param toolPaneY
*/ */
public void setLastToolPaneY(int toolPaneY) { public void setLastToolPaneY(int toolPaneY) {
@ -207,7 +205,8 @@ public class UIResizableContainer extends JPanel {
if (verticalToolPane == null || downPane == null) { if (verticalToolPane == null || downPane == null) {
return; return;
} }
// REPORT-42913 如果用户修改了分辨率或者dpi,可能造成toolPaneY大于parent.getHeight,整个downPane将丢失,因此这里调整下toolPaneY
adjustToolPaneY(parent);
if (direction == Constants.RIGHT) { if (direction == Constants.RIGHT) {
if(isDownPaneVisible){ if(isDownPaneVisible){
upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY); upPane.setBounds(0, 0, containerWidth - toolPaneHeight, toolPaneY);
@ -236,6 +235,18 @@ public class UIResizableContainer extends JPanel {
} }
} }
private void adjustToolPaneY(Container parent) {
if (parentHeight == -1) {
// 初始化下parentheight,存一下当前的父容器height
parentHeight = parent.getHeight();
}
if (parentHeight != parent.getHeight() && (parent.getHeight() - toolPaneHeight) >= 0) {
// 调整toolPaneY,保证至少水平的拖拽条horizontToolPane不丢失
toolPaneY = Math.min(toolPaneY, parent.getHeight() - toolPaneHeight);
parentHeight = parent.getHeight();
}
}
@Override @Override
public void addLayoutComponent(String name, Component comp) { public void addLayoutComponent(String name, Component comp) {
} }
@ -540,4 +551,4 @@ public class UIResizableContainer extends JPanel {
jf.setSize(500, 500); jf.setSize(500, 500);
jf.setVisible(true); jf.setVisible(true);
} }
} }

7
designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

@ -106,6 +106,13 @@ public class TableViewList extends UIList {
if (!status) { if (!status) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
String[] schemas = DataCoreUtils.getDatabaseSchema(datasource);
schemas = (schemas == null || schemas.length == 0) ? new String[]{null} : schemas;
for (String schema : schemas) {
DataCoreUtils.refreshTables(datasource, TableProcedure.TABLE, schema);
DataCoreUtils.refreshTables(datasource, TableProcedure.VIEW, schema);
DataCoreUtils.refreshTables(datasource, TableProcedure.PROCEDURE, schema);
}
return processDataInAnotherThread(databaseName, searchFilter, typesFilter); return processDataInAnotherThread(databaseName, searchFilter, typesFilter);
} }

10
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -3,11 +3,12 @@ package com.fr.design.gui.iprogressbar;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -57,7 +58,10 @@ public class ProgressDialog extends UIDialog {
progressBar.setMaximum(1000); progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER); panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER); text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); FRFont font = DesignUtils
.getDefaultGUIFont()
.applySize(14)
.applyForeground(new ColorUIResource(333334));
text.setFont(font); text.setFont(font);
panel.add(text, BorderLayout.SOUTH); panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true); panel.setVisible(true);

29
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -30,6 +30,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
private static final int LEN = 13; private static final int LEN = 13;
private static final int WIDTH = 13; private static final int WIDTH = 13;
private static final int HEIGHT = 10; private static final int HEIGHT = 10;
private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2;
private UINumberField textField; private UINumberField textField;
private UIButton preButton; private UIButton preButton;
private UIButton nextButton; private UIButton nextButton;
@ -40,9 +41,22 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
private boolean lessMinValue = false; private boolean lessMinValue = false;
/**
* Spinner内的数字文本框长度
*/
private int numberFieldColumns;
public UISpinner(double minValue, double maxValue, double dierta) { public UISpinner(double minValue, double maxValue, double dierta) {
init(minValue, maxValue, dierta);
}
public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
init(minValue, maxValue, dierta);
textField.setValue(defaultValue);
}
private void init(double minValue, double maxValue, double dierta) {
this.minValue = minValue; this.minValue = minValue;
this.maxValue = maxValue; this.maxValue = maxValue;
this.dierta = dierta; this.dierta = dierta;
@ -50,11 +64,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
iniListener(); iniListener();
} }
public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
this(minValue, maxValue, dierta);
textField.setValue(defaultValue);
}
private void iniListener() { private void iniListener() {
if (shouldResponseChangeListener()) { if (shouldResponseChangeListener()) {
this.addChangeListener(new ChangeListener() { this.addChangeListener(new ChangeListener() {
@ -156,6 +165,13 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
fireStateChanged(); fireStateChanged();
} }
/**
* 设置Spinner内的数字输入框列数
* @param numberFieldColumns 输入框列数
*/
public void setNumberFieldColumns(int numberFieldColumns) {
textField.setColumns(numberFieldColumns);
}
public void setEnabled(boolean flag) { public void setEnabled(boolean flag) {
super.setEnabled(flag); super.setEnabled(flag);
@ -308,7 +324,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
} }
protected UINumberField initNumberField() { protected UINumberField initNumberField() {
return new UINumberField(2) { int columns = this.numberFieldColumns == 0 ? DEFAULT_NUMBERFIELD_COLUMNS : this.numberFieldColumns;
return new UINumberField(columns) {
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return false; return false;
} }

12
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -2,7 +2,6 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.RefreshableJTree; import com.fr.design.gui.itree.refreshabletree.RefreshableJTree;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -14,13 +13,13 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -79,14 +78,7 @@ public class EnvFileTree extends RefreshableJTree {
this.setIcon(null); this.setIcon(null);
this.setText(PENDING.toString()); this.setText(PENDING.toString());
} }
// 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
UILabel label = new UILabel();
label.setText(getText());
label.setIcon(getIcon());
this.setSize(label.getPreferredSize());
Dimension dim = label.getPreferredSize();
dim.height += 2;
this.setPreferredSize(dim);
this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND);
this.setTextSelectionColor(Color.WHITE); this.setTextSelectionColor(Color.WHITE);
this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE);

2
designer-base/src/main/java/com/fr/design/gui/style/BackgroundNoImagePane.java

@ -42,4 +42,4 @@ public class BackgroundNoImagePane extends BackgroundPane{
gradientPane gradientPane
}; };
} }
} }

2
designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java

@ -172,4 +172,4 @@ public class BackgroundPane extends AbstractBasicStylePane {
return style.deriveBackground(this.update()); return style.deriveBackground(this.update());
} }
} }

8
designer-base/src/main/java/com/fr/design/gui/style/BackgroundSpecialPane.java

@ -48,12 +48,12 @@ public class BackgroundSpecialPane extends BackgroundPane{
}); });
//hugh:表单支持背景接口 //hugh:表单支持背景接口
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>(); List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>();
kinds.add(new NullBackgroundQuickPane()); kinds.add(new NullBackgroundQuickPane());
kinds.add(colorBackgroundPane); kinds.add(colorBackgroundPane);
kinds.add(imageBackgroundPane); kinds.add(imageBackgroundPane);
kinds.add(gradientPane); kinds.add(gradientPane);
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING);
for (BackgroundQuickUIProvider provider : providers) { for (BackgroundQuickUIProvider provider : providers) {
BackgroundQuickPane newTypePane = provider.appearanceForBackground(); BackgroundQuickPane newTypePane = provider.appearanceForBackground();
@ -65,7 +65,7 @@ public class BackgroundSpecialPane extends BackgroundPane{
}); });
kinds.add(newTypePane); kinds.add(newTypePane);
} }
return kinds.toArray(new BackgroundQuickPane[kinds.size()]); return kinds.toArray(new BackgroundQuickPane[kinds.size()]);
} }
} }

25
designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java

@ -25,10 +25,20 @@ import com.fr.general.FRFont;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
@ -67,11 +77,20 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private UIToggleButton subPane; private UIToggleButton subPane;
private JPanel linePane; private JPanel linePane;
private int italic_bold; private int italic_bold;
/**
* LeftPane和RightPane之间的间隙也是fontSizeStyleComboBox与fontSizeComboBox之间的间隙之前的默认值为VGAP_LARGE
*/
private int hGapBetweenLeftPaneAndRightPane = LayoutConstants.VGAP_LARGE;
public FRFontPane() { public FRFontPane() {
this.initComponents(); this.initComponents();
} }
public FRFontPane(int hGapBetweenLeftPaneAndRightPane) {
this.hGapBetweenLeftPaneAndRightPane = hGapBetweenLeftPaneAndRightPane;
this.initComponents();
}
public static void main(String[] args) { public static void main(String[] args) {
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -345,7 +364,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse
private JPanel createPane() { private JPanel createPane() {
JPanel createPane = new JPanel(new BorderLayout()); JPanel createPane = new JPanel(new BorderLayout());
createPane.add(fontNameComboBox, BorderLayout.NORTH); createPane.add(fontNameComboBox, BorderLayout.NORTH);
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, hGapBetweenLeftPaneAndRightPane, LayoutConstants.VGAP_LARGE);
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
createPane.add(jPanel, BorderLayout.CENTER); createPane.add(jPanel, BorderLayout.CENTER);
return createPane; return createPane;

17
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java

@ -2,7 +2,7 @@
* 12/21/2004 * 12/21/2004
* *
* ConfigurableCaret.java - The caret used by RTextArea. * ConfigurableCaret.java - The caret used by RTextArea.
* *
* This library is distributed under a modified BSD license. See the included * This library is distributed under a modified BSD license. See the included
* RSyntaxTextArea.License.txt file for details. * RSyntaxTextArea.License.txt file for details.
*/ */
@ -12,6 +12,7 @@ import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.datatransfer.*; import java.awt.datatransfer.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.geom.Line2D;
import java.io.*; import java.io.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.*; import javax.swing.plaf.*;
@ -158,7 +159,7 @@ public class ConfigurableCaret extends DefaultCaret {
textArea.isRequestFocusEnabled()) { textArea.isRequestFocusEnabled()) {
if (inWindow) if (inWindow)
textArea.requestFocusInWindow(); textArea.requestFocusInWindow();
else else
textArea.requestFocus(); textArea.requestFocus();
} }
} }
@ -454,9 +455,11 @@ public class ConfigurableCaret extends DefaultCaret {
// A thicker vertical line. // A thicker vertical line.
case THICK_VERTICAL_LINE_STYLE: case THICK_VERTICAL_LINE_STYLE:
g.drawLine(r.x,r.y, r.x,r.y+r.height); Graphics2D g2 = (Graphics2D) g;
r.x++; g2.setStroke(new BasicStroke(2));
g.drawLine(r.x,r.y, r.x,r.y+r.height); // 向右再移动一个位置 避免光标太接近文字内容
// REPORT-41895 光标上方超出背景高亮的部分不会闪烁,会形成一个停留的小点,因此将光标的超出部分截去
g2.draw(new Line2D.Float(r.x + 1, r.y + 1, r.x + 1, r.y + r.height));
break; break;
} // End of switch (style). } // End of switch (style).
@ -674,7 +677,7 @@ public class ConfigurableCaret extends DefaultCaret {
if (line<lineCount) { if (line<lineCount) {
dot = textArea.getLineStartOffset(line); dot = textArea.getLineStartOffset(line);
} }
else { // No lower lines visible else { // No lower lines visible
UIManager.getLookAndFeel(). UIManager.getLookAndFeel().
provideErrorFeedback(textArea); provideErrorFeedback(textArea);
return; return;
@ -709,4 +712,4 @@ public class ConfigurableCaret extends DefaultCaret {
} }
} }

38
designer-base/src/main/java/com/fr/design/jdk/JdkVersion.java

@ -0,0 +1,38 @@
package com.fr.design.jdk;
import com.fr.stable.StableUtils;
/**
* 设计器运行jdk版本
*
* @author hades
* @version 10.0
* Created by hades on 2020/9/27
*/
public enum JdkVersion {
/**
* 小于或等于jdk 8
*/
LE_8 {
@Override
public boolean support() {
return StableUtils.getMajorJavaVersion() <= 8;
}
},
/**
* 大于或等于jdk 9
*/
GE_9 {
@Override
public boolean support() {
return StableUtils.getMajorJavaVersion() >= 9;
}
};
abstract public boolean support();
}

46
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -152,6 +152,20 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/**
* 创建一个无间隔带标题边框面板
*
* @param string 边框标题
* @return JPanel对象
*/
public static JPanel createTitledBorderNoGapPane(String string) {
JPanel jp = new JPanel();
UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string);
jp.setBorder(explainBorder);
jp.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
return jp;
}
/** /**
* 创建一个带标题边框面板垂直居左布局 * 创建一个带标题边框面板垂直居左布局
* *
@ -304,6 +318,21 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/**
* 创建一个靠左的水平流式布局
* @param firstGap 首元素和边框间距
* @param hgap 水平间距
* @param vgap 竖直间距
* @return JPanel对象
*/
public static JPanel createBoxFlowInnerContainer_S_Pane(int firstGap, int hgap, int vgap) {
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
jp.setLayout(new FRLeftFlowLayout(firstGap, hgap, vgap));
return jp;
}
/** /**
* 创建一个靠左流式布局流式内嵌首元素距离左边0 * 创建一个靠左流式布局流式内嵌首元素距离左边0
* *
@ -315,6 +344,21 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/**
* 创建一个靠左的水平流式布局
* @param hgap 水平间距
* @param vgap 竖直间距
* @return JPanel对象
*/
public static JPanel createBoxFlowInnerContainer_S_Pane(int hgap, int vgap) {
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
jp.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
return jp;
}
/** /**
* 创建一个靠右面板 * 创建一个靠右面板
* *
@ -469,6 +513,8 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/** /**
* 创建垂直流布局面板 * 创建垂直流布局面板
* *

17
designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java

@ -156,7 +156,20 @@ public enum SupportLocaleImpl implements SupportLocale {
set.add(Locale.TAIWAN); set.add(Locale.TAIWAN);
return set; return set;
} }
} },
/**
* 更新升级-帮助菜单下
*/
UPDATE_HELP {
@Override
public Set<Locale> support() {
Set<Locale> set = new HashSet<>();
set.add(Locale.US);
set.add(Locale.KOREA);
set.add(Locale.CHINA);
set.add(Locale.TAIWAN);
return set;
}
}
} }

11
designer-base/src/main/java/com/fr/design/mainframe/App.java

@ -41,4 +41,15 @@ public interface App<T extends BaseBook> extends Mutable, Aftermath {
* @return 报表 * @return 报表
*/ */
T asIOFile(FILE tplFile); T asIOFile(FILE tplFile);
/**
* 输出workbook等对象
* @param tplFile 文件
* @param needCheck 是否需要check
* @return
*/
default T asIOFile(FILE tplFile, boolean needCheck) {
return asIOFile(tplFile);
}
} }

38
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -257,8 +257,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
}; };
private ProgressDialog progressDialog;
public DesignerFrame(ToolBarMenuDock ad) { public DesignerFrame(ToolBarMenuDock ad) {
setName(DESIGNER_FRAME_NAME); setName(DESIGNER_FRAME_NAME);
@ -338,7 +336,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true)); this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true));
closeMode = UIConstants.CLOSE_OF_AUTHORITY; closeMode = UIConstants.CLOSE_OF_AUTHORITY;
initMenuPane(); initMenuPane();
this.progressDialog = new ProgressDialog(this);
} }
public void resizeFrame() { public void resizeFrame() {
@ -551,10 +548,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
contentHeight = layeredPane.getHeight(); contentHeight = layeredPane.getHeight();
contentWidth = layeredPane.getWidth(); contentWidth = layeredPane.getWidth();
layeredPane.remove(basePane); // 这个地方remove和add都是一个对象 完全没有必要remove再add 改变了窗口大小重新设置下 然后有repaint即可
basePane.setBounds(0, 0, contentWidth, contentHeight); basePane.setBounds(0, 0, contentWidth, contentHeight);
layeredPane.add(basePane);
layeredPane.repaint(); layeredPane.repaint();
layeredPane.revalidate();
} }
/** /**
@ -749,10 +746,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void checkCombineUp(boolean flag, ArrayList<String> al) { public void checkCombineUp(boolean flag, ArrayList<String> al) {
//Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的
if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getMenuState() == DesignState.WORK_SHEET) { JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return; if (jTemplate != null) {
// 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return
if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) {
return;
}
combineUp.checkComponentsByNames(flag, al);
} }
combineUp.checkComponentsByNames(flag, al);
} }
/** /**
@ -1264,23 +1265,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
@Deprecated
public ProgressDialog getProgressDialog() { public ProgressDialog getProgressDialog() {
return progressDialog; return new ProgressDialog(this);
}
public void showProgressDialog() {
progressDialog.setVisible(true);
} }
/** @Deprecated
* 隐藏进度框 public void openProgressDialog() {
*/
public void hideProgressDialog() {
progressDialog.setVisible(false);
} }
/** /**
@ -1288,17 +1281,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
* *
* @param progress 进度值 * @param progress 进度值
*/ */
@Deprecated
public void updateProgress(int progress) { public void updateProgress(int progress) {
progressDialog.setProgressValue(progress);
} }
/** /**
* 释放进度框 * 释放进度框
*/ */
@Deprecated
public void disposeProgressDialog() { public void disposeProgressDialog() {
progressDialog.dispose();
} }
/** /**
@ -1309,4 +1302,5 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public boolean isDesignerOpened() { public boolean isDesignerOpened() {
return designerOpened; return designerOpened;
} }
} }

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

@ -554,7 +554,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
); );
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
newNameLabel.setPreferredSize(new Dimension(118, 15)); //newNameLabel.setPreferredSize(new Dimension(118, 15));
// 重命名输入框 // 重命名输入框
nameField = new UITextField(oldName); nameField = new UITextField(oldName);
@ -576,7 +576,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
}); });
nameField.selectAll(); nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20)); nameField.setPreferredSize(new Dimension(170, 20));
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5)); JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15)); topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));

95
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -13,10 +13,13 @@ import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.icontainer.UIEastResizableContainer; import com.fr.design.gui.icontainer.UIEastResizableContainer;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.menu.SnapChatUtil;
import com.fr.design.notification.SnapChat;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.context.PluginRuntime;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
@ -99,14 +102,29 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
REPORT, // 报表 REPORT, // 报表
REPORT_PARA, // 报表参数面板 REPORT_PARA, // 报表参数面板
REPORT_FLOAT, // 报表悬浮元素 REPORT_FLOAT, // 报表悬浮元素
FORM, // 表单 FORM(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 表单
FORM_REPORT, // 表单报表块 FORM_REPORT, // 表单报表块
POLY, // 聚合报表 POLY, // 聚合报表
POLY_REPORT, // 聚合报表-报表块 POLY_REPORT, // 聚合报表-报表块
POLY_CHART, // 聚合报表-图表块 POLY_CHART(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 聚合报表-图表块
AUTHORITY_EDITION, // 权限编辑 AUTHORITY_EDITION, // 权限编辑
AUTHORITY_EDITION_DISABLED // 权限编辑 AUTHORITY_EDITION_DISABLED; // 权限编辑
private String title;
PropertyMode() {
this.title = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Settings");
}
PropertyMode(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
} }
private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板) private PropertyMode currentMode; // 当前模式(根据不同模式,显示不同的可用面板)
@ -172,7 +190,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
updateAllPropertyPane(); updateAllPropertyPane();
} }
}); } });
}
}, filter); }, filter);
PluginListenerRegistration.getInstance().listen( PluginListenerRegistration.getInstance().listen(
PluginEventType.BeforeStop, PluginEventType.BeforeStop,
@ -222,11 +241,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
String key = provider.key(); String key = provider.key();
PropertyItemBean itemBean = provider.getItem(); PropertyItemBean itemBean = provider.getItem();
PropertyItem propertyItem = new PropertyItem(itemBean.getName(), PropertyItem propertyItem = new PropertyItem(itemBean.getName(),
itemBean.getTitle(), itemBean.getTitle(),
itemBean.getBtnIconName(), itemBean.getBtnIconName(),
itemBean.getBtnIconBaseDir(), itemBean.getBtnIconBaseDir(),
itemBean.getVisibleModes(), itemBean.getVisibleModes(),
itemBean.getEnableModes()); itemBean.getEnableModes(),
itemBean.getSnapChat(),
itemBean.getPromptWindow());
UIButton button = propertyItem.getButton(); UIButton button = propertyItem.getButton();
List<ActionListener> buttonListeners = itemBean.getButtonListeners(); List<ActionListener> buttonListeners = itemBean.getButtonListeners();
if (buttonListeners != null) { if (buttonListeners != null) {
@ -325,6 +346,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
cellElement.popupDialog.showDefaultPane(); cellElement.popupDialog.showDefaultPane();
} }
} }
// 禁用单元格元素tab // 禁用单元格元素tab
private void enableCellElementPane(PropertyItem cellElement) { private void enableCellElementPane(PropertyItem cellElement) {
cellElement.setEnabled(true); cellElement.setEnabled(true);
@ -382,7 +404,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
/** /**
* 可通过此方法判断当前的编辑模式 * 可通过此方法判断当前的编辑模式
* */ */
public PropertyMode getCurrentMode() { public PropertyMode getCurrentMode() {
return currentMode; return currentMode;
} }
@ -395,6 +417,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private void updatePropertyItemMap() { private void updatePropertyItemMap() {
for (PropertyItem item : propertyItemMap.values()) { for (PropertyItem item : propertyItemMap.values()) {
item.updateStatus(); item.updateStatus();
item.updateTitle();
} }
} }
@ -512,7 +535,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
UIUtil.invokeLaterIfNeeded(new Runnable() { UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override @Override
public void run() { public void run() {
propertyItemMap.get(key).replaceContentPane(pane); PropertyItem item = propertyItemMap.get(key);
if (item != null) {
item.replaceContentPane(pane);
}
} }
}); });
} }
@ -525,7 +551,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane); propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane);
} }
public static void main(String[] args){ public static void main(String[] args) {
JFrame jf = new JFrame("test"); JFrame jf = new JFrame("test");
// jf = new JFrame("test"); // jf = new JFrame("test");
@ -547,7 +573,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// leftPane.add(b2); // leftPane.add(b2);
// leftPane.setLayout(new BoxLayout(leftPane, BoxLayout.Y_AXIS)); // leftPane.setLayout(new BoxLayout(leftPane, BoxLayout.Y_AXIS));
JPanel content = (JPanel)jf.getContentPane(); JPanel content = (JPanel) jf.getContentPane();
// content.setLayout(null); // content.setLayout(null);
content.add(cc, BorderLayout.CENTER); content.add(cc, BorderLayout.CENTER);
content.add(new EastRegionContainerPane(), BorderLayout.EAST); content.add(new EastRegionContainerPane(), BorderLayout.EAST);
@ -655,6 +681,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
class PropertyItem { class PropertyItem {
private SnapChat snapChat;
private UIButton button; private UIButton button;
private String name; // 用于 card 切换 private String name; // 用于 card 切换
private String title; // 用于显示 private String title; // 用于显示
@ -665,6 +692,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private FixedPopupPane popupPane; // 左侧固定弹出框 private FixedPopupPane popupPane; // 左侧固定弹出框
private PopupToolPane popupToolPane; // 弹出工具条 private PopupToolPane popupToolPane; // 弹出工具条
private PopupDialog popupDialog; // 弹出框 private PopupDialog popupDialog; // 弹出框
private PromptWindow promptWindow; //提示窗
private boolean isPoppedOut = false; // 是否弹出 private boolean isPoppedOut = false; // 是否弹出
private boolean isVisible = true; // 是否可见 private boolean isVisible = true; // 是否可见
private boolean replace = false; // 是否被替代 private boolean replace = false; // 是否被替代
@ -687,14 +715,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes) { public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes); this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, null, null);
} }
public PropertyItem(String name, String title, String btnIconName, String iconBaseDir, PropertyMode[] visibleModes, PropertyMode[] enableModes) { public PropertyItem(String name, String title, String btnIconName, String iconBaseDir, PropertyMode[] visibleModes, PropertyMode[] enableModes, SnapChat snapChat, PromptWindow promptWindow) {
this.name = name; this.name = name;
this.title = title; this.title = title;
this.btnIconName = btnIconName; this.btnIconName = btnIconName;
this.iconBaseDir = iconBaseDir; this.iconBaseDir = iconBaseDir;
this.snapChat = snapChat;
this.promptWindow = promptWindow;
initButton(); initButton();
initPropertyPanel(); initPropertyPanel();
initModes(visibleModes, enableModes); initModes(visibleModes, enableModes);
@ -724,6 +754,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
} }
public void updateTitle() {
try {
if (StringUtils.equals(KEY_WIDGET_SETTINGS, name)) {
title = currentMode.getTitle();
button.setToolTipText(title);
UILabel uiLabel = (UILabel) ((BorderLayout) popupToolPane.contentPane.getLayout()).getLayoutComponent(BorderLayout.WEST);
uiLabel.setText(title);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
public void reAddContentArea() { public void reAddContentArea() {
propertyPanel.add(contentArea, BorderLayout.CENTER); propertyPanel.add(contentArea, BorderLayout.CENTER);
} }
@ -835,7 +878,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (isRightPaneVisible()) { if (isRightPaneVisible()) {
hideCurrentPopupPane(); hideCurrentPopupPane();
replaceContentPane(contentPane); replaceContentPane(contentPane);
} else if(popupPane != null && popupPane.isVisible()) { } else if (popupPane != null && popupPane.isVisible()) {
popupPane.replaceContentPane(contentArea); popupPane.replaceContentPane(contentArea);
} }
} }
@ -872,9 +915,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(TAB_BUTTON_WIDTH, TAB_BUTTON_HEIGHT); return new Dimension(TAB_BUTTON_WIDTH, TAB_BUTTON_HEIGHT);
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
if (snapChat != null && !snapChat.hasRead()) {
SnapChatUtil.paintPropertyItemPoint(g, getBounds());
}
} }
}; };
button.setDisabledIcon(SVGIconUtils.readIcon(getIconBaseDir() + btnIconName + ICON_SUFFIX_DISABLED)); button.setDisabledIcon(SVGIconUtils.readIcon(getIconBaseDir() + btnIconName + ICON_SUFFIX_DISABLED));
@ -903,6 +950,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
popupFixedPane(); popupFixedPane();
} }
setTabButtonSelected(); setTabButtonSelected();
if (snapChat != null && !snapChat.hasRead()) {
snapChat.markRead();
if (promptWindow != null) {
promptWindow.showWindow();
}
}
} }
}); });
button.setToolTipText(title); button.setToolTipText(title);
@ -1016,8 +1069,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
/** /**
* @Description:刷新currentPopupPane面板位置当设计器缩放时会调用这个函数
* @param * @param
* @Description:刷新currentPopupPane面板位置当设计器缩放时会调用这个函数
* @return: * @return:
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/7/30 11:39 * @date: 2020/7/30 11:39
@ -1032,8 +1085,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
/** /**
* @Description:清空currentPopupPane数据当切换模板时会调用这个函数
* @param * @param
* @Description:清空currentPopupPane数据当切换模板时会调用这个函数
* @return: * @return:
* @Author: Henry.Wang * @Author: Henry.Wang
* @date: 2020/7/30 11:42 * @date: 2020/7/30 11:42
@ -1072,12 +1125,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
repaint(); repaint();
} }
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (e.getX() >= ARROW_RANGE_START) { if (e.getX() >= ARROW_RANGE_START) {
onPop(); onPop();
} }
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
mouseDownCompCoords = null; mouseDownCompCoords = null;
@ -1085,6 +1140,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
contentPane.setBackground(originColor); contentPane.setBackground(originColor);
} }
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getX() < ARROW_RANGE_START) { if (e.getX() < ARROW_RANGE_START) {
@ -1106,6 +1162,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
repaint(); repaint();
} }
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
if (isMovable && mouseDownCompCoords != null) { if (isMovable && mouseDownCompCoords != null) {
@ -1218,6 +1275,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private Container contentPane; private Container contentPane;
private JPanel defaultPane; // 无可用配置项 private JPanel defaultPane; // 无可用配置项
private PropertyItem propertyItem; private PropertyItem propertyItem;
public PopupDialog(PropertyItem propertyItem) { public PopupDialog(PropertyItem propertyItem) {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
container = getContentPane(); container = getContentPane();
@ -1320,6 +1378,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
mouseDownCompCoords = e.getLocationOnScreen(); mouseDownCompCoords = e.getLocationOnScreen();
} }
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
mouseDownCompCoords = null; mouseDownCompCoords = null;

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

@ -49,6 +49,7 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.preview.PagePreview; import com.fr.design.preview.PagePreview;
import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationInWidgetEventPane;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.event.EventDispatcher;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
@ -107,7 +108,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
public int resolution = ScreenResolution.getScreenResolution();
private PluginEventListener pluginListener; private PluginEventListener pluginListener;
@ -125,6 +125,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public JTemplate(T t, FILE file, boolean isNewFile) { public JTemplate(T t, FILE file, boolean isNewFile) {
super(t); super(t);
beforeInit();
// 判断是否切换设计器状态到禁止拷贝剪切 // 判断是否切换设计器状态到禁止拷贝剪切
if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT);
@ -136,9 +137,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.editingFILE = file; this.editingFILE = file;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
designModel = createDesignModel();
addCenterPane(); addCenterPane();
this.undoState = createUndoState(); this.undoState = createUndoState();
designModel = createDesignModel();
consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile));
initAndStartPlugin(); initAndStartPlugin();
@ -301,6 +302,20 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
/**
* 模板初始化之前
*/
private void beforeInit() {
EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_INIT, this);
}
/**
* 模板激活之前之前
*/
protected void beforeActive() {
EventDispatcher.fire(JTemplateEvent.BEFORE_TEMPLATE_ACTIVE, this);
}
/** /**
* 模板关闭时 * 模板关闭时
*/ */
@ -309,6 +324,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
PluginListenerRegistration.getInstance().stopListen(this.pluginListener); PluginListenerRegistration.getInstance().stopListen(this.pluginListener);
} }
/** /**
* 刷新内部资源 * 刷新内部资源
* *
@ -1076,6 +1092,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* 激活指定的template * 激活指定的template
*/ */
public void activeJTemplate(int index, JTemplate jt) { public void activeJTemplate(int index, JTemplate jt) {
beforeActive();
DesignerContext.getDesignerFrame().activateJTemplate(this); DesignerContext.getDesignerFrame().activateJTemplate(this);
} }
@ -1083,6 +1100,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* 激活已存在的模板 * 激活已存在的模板
*/ */
public void activeOldJTemplate() { public void activeOldJTemplate() {
beforeActive();
DesignerContext.getDesignerFrame().activateJTemplate(this); DesignerContext.getDesignerFrame().activateJTemplate(this);
} }
@ -1090,6 +1108,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* 激活新的模板 * 激活新的模板
*/ */
public void activeNewJTemplate() { public void activeNewJTemplate() {
beforeActive();
DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); DesignerContext.getDesignerFrame().addAndActivateJTemplate(this);
} }
@ -1323,4 +1342,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return getEditingFILE().getName(); return getEditingFILE().getName();
} }
public String getTemplatePredefinedStyle(){
return StringUtils.EMPTY;
}
} }

22
designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListenerAdapter.java

@ -0,0 +1,22 @@
package com.fr.design.mainframe;
/**
* @Author: Yuan.Wang
* @Date: 2020/10/27
*/
public class JTemplateActionListenerAdapter implements JTemplateActionListener {
@Override
public void templateOpened(JTemplate<?, ?> jt) {
}
@Override
public void templateSaved(JTemplate<?, ?> jt) {
}
@Override
public void templateClosed(JTemplate<?, ?> jt) {
}
}

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

@ -0,0 +1,19 @@
package com.fr.design.mainframe;
import com.fr.event.Event;
/**
* Created by kerry on 2020-12-11
*/
public enum JTemplateEvent implements Event<JTemplate> {
/**
* 模板初始化之前
*/
BEFORE_TEMPLATE_INIT,
/**
* 模板激活之前
*/
BEFORE_TEMPLATE_ACTIVE
}

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

@ -56,7 +56,7 @@ public final class JTemplateFactory {
String[] defaultAppExtensions = app.defaultExtensions(); String[] defaultAppExtensions = app.defaultExtensions();
for (String defaultAppExtension : defaultAppExtensions) { for (String defaultAppExtension : defaultAppExtensions) {
if (defaultAppExtension.equalsIgnoreCase(fileExtension)) { if (defaultAppExtension.equalsIgnoreCase(fileExtension)) {
BaseBook bb = app.asIOFile(file); BaseBook bb = app.asIOFile(file, false);
if (bb != null) { if (bb != null) {
return (T) bb; return (T) bb;
} }

3
designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java

@ -208,6 +208,7 @@ public class JVirtualTemplate extends JTemplate {
@Override @Override
public void activeJTemplate(int index, JTemplate jt) { public void activeJTemplate(int index, JTemplate jt) {
beforeActive();
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
historyList.set(index, jt); historyList.set(index, jt);
DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt); DesignerContext.getDesignerFrame().addAndActivateJTemplate(jt);
@ -217,11 +218,13 @@ public class JVirtualTemplate extends JTemplate {
@Override @Override
public void activeOldJTemplate() { public void activeOldJTemplate() {
beforeActive();
DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE());
} }
@Override @Override
public void activeNewJTemplate() { public void activeNewJTemplate() {
beforeActive();
DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE()); DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE());
} }

20
designer-base/src/main/java/com/fr/design/mainframe/PromptWindow.java

@ -0,0 +1,20 @@
package com.fr.design.mainframe;
import javax.swing.JWindow;
/**
* @Author: Yuan.Wang
* @Date: 2020/10/9
* 只关心Window的显示和隐藏操作时可以实现该接口
*/
public interface PromptWindow {
/**
* 显示弹窗
*/
void showWindow();
/**
* 隐藏弹窗
*/
void hideWindow();
}

54
designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.notification.SnapChat;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.List; import java.util.List;
@ -7,71 +9,89 @@ import java.util.List;
* created by Harrison on 2020/03/23 * created by Harrison on 2020/03/23
**/ **/
public class PropertyItemBean { public class PropertyItemBean {
private String name; private String name;
private String title; private String title;
private String btnIconName; private String btnIconName;
private String btnIconBaseDir; private String btnIconBaseDir;
private SnapChat snapChat;
private PromptWindow promptWindow;
private EastRegionContainerPane.PropertyMode[] visibleModes; private EastRegionContainerPane.PropertyMode[] visibleModes;
private EastRegionContainerPane.PropertyMode[] enableModes; private EastRegionContainerPane.PropertyMode[] enableModes;
private List<ActionListener> buttonListeners; private List<ActionListener> buttonListeners;
public PropertyItemBean() { public PropertyItemBean() {
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getTitle() { public String getTitle() {
return title; return title;
} }
public void setTitle(String title) { public void setTitle(String title) {
this.title = title; this.title = title;
} }
public String getBtnIconName() { public String getBtnIconName() {
return btnIconName; return btnIconName;
} }
public void setBtnIconName(String btnIconName) { public void setBtnIconName(String btnIconName) {
this.btnIconName = btnIconName; this.btnIconName = btnIconName;
} }
public String getBtnIconBaseDir() { public String getBtnIconBaseDir() {
return btnIconBaseDir; return btnIconBaseDir;
} }
public void setBtnIconBaseDir(String btnIconBaseDir) { public void setBtnIconBaseDir(String btnIconBaseDir) {
this.btnIconBaseDir = btnIconBaseDir; this.btnIconBaseDir = btnIconBaseDir;
} }
public SnapChat getSnapChat() {
return snapChat;
}
public void setSnapChat(SnapChat snapChat) {
this.snapChat = snapChat;
}
public PromptWindow getPromptWindow() {
return promptWindow;
}
public void setPromptWindow(PromptWindow promptWindow) {
this.promptWindow = promptWindow;
}
public EastRegionContainerPane.PropertyMode[] getVisibleModes() { public EastRegionContainerPane.PropertyMode[] getVisibleModes() {
return visibleModes; return visibleModes;
} }
public void setVisibleModes(EastRegionContainerPane.PropertyMode[] visibleModes) { public void setVisibleModes(EastRegionContainerPane.PropertyMode[] visibleModes) {
this.visibleModes = visibleModes; this.visibleModes = visibleModes;
} }
public EastRegionContainerPane.PropertyMode[] getEnableModes() { public EastRegionContainerPane.PropertyMode[] getEnableModes() {
return enableModes; return enableModes;
} }
public void setEnableModes(EastRegionContainerPane.PropertyMode[] enableModes) { public void setEnableModes(EastRegionContainerPane.PropertyMode[] enableModes) {
this.enableModes = enableModes; this.enableModes = enableModes;
} }
public List<ActionListener> getButtonListeners() { public List<ActionListener> getButtonListeners() {
return buttonListeners; return buttonListeners;
} }
public void setButtonListeners(List<ActionListener> buttonListeners) { public void setButtonListeners(List<ActionListener> buttonListeners) {
this.buttonListeners = buttonListeners; this.buttonListeners = buttonListeners;
} }

14
designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java

@ -32,11 +32,11 @@ public class WestRegionContainerPane extends UIResizableContainer {
public WestRegionContainerPane() { public WestRegionContainerPane() {
super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT);
setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) { GeneralContext.listenPluginRunningChanged(new PluginEventListener(TableDataTreePane.PLUGIN_LISTENER_PRIORITY - 1) {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
@ -47,15 +47,15 @@ public class WestRegionContainerPane extends UIResizableContainer {
} }
} }
}, new PluginFilter() { }, new PluginFilter() {
@Override @Override
public boolean accept(PluginContext context) { public boolean accept(PluginContext context) {
return context.contain(PluginModule.ExtraDesign); return context.contain(PluginModule.ExtraDesign);
} }
}); });
setContainerWidth(165); setContainerWidth(165);
setBackground(UIConstants.TREE_BACKGROUND); setBackground(UIConstants.TREE_BACKGROUND);
} }
} }

103
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/VanChartGradientPane.java

@ -0,0 +1,103 @@
package com.fr.design.mainframe.backgroundpane;
import com.fr.base.background.GradientBackground;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.general.Background;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* 渐变色设置界面bar无法拖拽
*/
public class VanChartGradientPane extends GradientBackgroundQuickPane {
protected static final int CHART_GRADIENT_WIDTH = 150;
private static final long serialVersionUID = 256594362341221087L;
private FixedGradientBar gradientBar;
private UIButtonGroup<Integer> directionPane;
public VanChartGradientPane() {
constructPane();
}
protected void constructPane(){
String[] textArray = {com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom")};
Integer[] valueArray = {GradientBackground.LEFT2RIGHT, GradientBackground.TOP2BOTTOM};
directionPane = new UIButtonGroup<Integer>(textArray, valueArray);
directionPane.setSelectedIndex(0);
gradientBar = new FixedGradientBar(4, CHART_GRADIENT_WIDTH);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{gradientBar, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Direction")),directionPane},
};
JPanel Gradient = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(Gradient, BorderLayout.CENTER);
}
public void populateBean(Background background) {
GradientBackground bg = (GradientBackground) background;
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor());
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor());
directionPane.setSelectedItem(bg.getDirection());
this.gradientBar.repaint();
}
public GradientBackground updateBean() {
GradientBackground gb = new GradientBackground(gradientBar.getSelectColorPointBtnP1().getColorInner(), gradientBar.getSelectColorPointBtnP2().getColorInner());
gb.setDirection(directionPane.getSelectedItem());
return gb;
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerChangeListener(final UIObserverListener listener) {
gradientBar.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
directionPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
}
/**
* 是否接受
* @param background 背景
* @return 是则返回true
*/
public boolean accept(Background background) {
return background instanceof GradientBackground;
}
/**
* 名称
* @return 名称
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color");
}
}

29
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java

@ -44,6 +44,7 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
private JPanel centerPane; private JPanel centerPane;
protected MobileTemplatePreviewPane previewPane; protected MobileTemplatePreviewPane previewPane;
private WCardTagLayout tagLayout; private WCardTagLayout tagLayout;
private MobileTemplateStyle customTempStyle;
public MobileTemplatePreviewPane getPreviewPane() { public MobileTemplatePreviewPane getPreviewPane() {
@ -87,6 +88,14 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
custom.addItemListener(new ItemListener() { custom.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
// 自定义 -> 标准
if (custom.getSelectedIndex() == 0) {
customTempStyle = getCustomMobileTemplateStyle();
}
// 标准 -> 自定义
if (custom.getSelectedIndex() == 1 && customTempStyle != null) {
populateBean(customTempStyle);
}
boolean isCustom = custom.getSelectedIndex() == 1; boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom); centerPane.setVisible(isCustom);
updatePreviewPane(); updatePreviewPane();
@ -182,8 +191,24 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
protected abstract MobileTemplatePreviewPane createPreviewPane(); protected abstract MobileTemplatePreviewPane createPreviewPane();
public MobileTemplateStyle getCustomMobileTemplateStyle() {
MobileTemplateStyle ob = updateSubStyle();
ob.setCustom(true);
if (initialColorBox != null) {
ob.setInitialColor(initialColorBox.getSelectObject());
}
if (fontConfPane != null) {
TabFontConfig config = new TabFontConfig();
config.setSelectColor(ob.getTabFontConfig().getSelectColor());
config.setFont(fontConfPane.update());
ob.setTabFontConfig(config);
}
return ob;
}
@Override @Override
public void populateBean(MobileTemplateStyle ob) { public void populateBean(MobileTemplateStyle ob) {
customTempStyle = ob.getCustomTemplateStyle();
centerPane.setVisible(ob.isCustom()); centerPane.setVisible(ob.isCustom());
populateSubStyle(ob); populateSubStyle(ob);
custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") : custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") :
@ -211,7 +236,9 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<Mobile
public MobileTemplateStyle updateConfig(){ public MobileTemplateStyle updateConfig(){
if (custom.getSelectedIndex() == 0) { if (custom.getSelectedIndex() == 0) {
return getDefaultTemplateStyle(); MobileTemplateStyle mobileTemplateStyle = getDefaultTemplateStyle();
mobileTemplateStyle.setCustomTemplateStyle(customTempStyle);
return mobileTemplateStyle;
} }
MobileTemplateStyle ob = updateSubStyle(); MobileTemplateStyle ob = updateSubStyle();
ob.setCustom(custom.getSelectedIndex() == 1); ob.setCustom(custom.getSelectedIndex() == 1);

40
designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java

@ -0,0 +1,40 @@
package com.fr.design.mainframe.predefined;
import com.fr.config.predefined.PredefinedStyle;
//import com.fr.predefined.PredefinedPatternStyleManager;
/**
* Created by kerry on 2020-08-31
*/
public enum PatternStyle {
DARK_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Dark_Pattern")) {
@Override
public PredefinedStyle getPredefinedStyle() {
// return PredefinedPatternStyleManager.INSTANCE.getDarkMode();
return new PredefinedStyle();
}
},
LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) {
@Override
public PredefinedStyle getPredefinedStyle() {
// return PredefinedPatternStyleManager.INSTANCE.getLightMode();
return new PredefinedStyle();
}
};
private String name;
PatternStyle(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public abstract PredefinedStyle getPredefinedStyle();
}

143
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java

@ -0,0 +1,143 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* Created by kerry on 2020-08-25
*/
public class PredefinedStyleBlock extends JPanel {
private PredefinedStyle previewObject;
private PredefinedStyleSelectPane parentPane;
private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png");
private static final Color BORDER_COLOR = new Color(141, 194, 249);
private boolean mouseOver = false;
private MouseListener mouseListener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
setSelect();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
mouseOver = true;
PredefinedStyleBlock.this.repaint();
}
@Override
public void mouseExited(MouseEvent e) {
mouseOver = false;
PredefinedStyleBlock.this.repaint();
}
};
public PredefinedStyleBlock(PredefinedStyle previewObject, PredefinedStyleSelectPane selectPane, boolean supportEdit) {
this.previewObject = previewObject;
this.parentPane = selectPane;
initPane(supportEdit);
this.addMouseListener(mouseListener);
}
private void setSelect() {
this.parentPane.setSelectedPreviewPane(this);
}
@Override
public void paint(Graphics g) {
super.paint(g);
boolean isSelected = ComparatorUtils.equals(this, this.parentPane.getSelectedPreviewPane());
if (ComparatorUtils.equals(this.parentPane.getCurrentApplicateStyle(), this.previewObject.getStyleName())) {
markedMode.paintIcon(this, g, 176, 0);
}
if (isSelected || this.mouseOver) {
g.setColor(BORDER_COLOR);
Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2);
GraphHelper.draw(g, rectangle, Constants.LINE_MEDIUM);
}
}
private void initPane(boolean supportEdit) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384);
content.setParent(this);
content.setPreferredSize(new Dimension(200, 180));
UILabel label = new UILabel(previewObject.getStyleName());
label.setToolTipText(previewObject.getStyleName());
label.setPreferredSize(new Dimension(167, 25));
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(0,9,2,5));
panel.add(label, BorderLayout.WEST);
if (supportEdit) {
addEditButton(panel);
}
this.add(content, BorderLayout.CENTER);
this.add(panel, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(200, 210));
panel.setBackground(Color.WHITE);
this.setBackground(Color.WHITE);
content.refresh(this.previewObject);
}
private void addEditButton(JPanel panel) {
UIButton editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_edit.png"));
editButton.setPreferredSize(new Dimension(24, 24));
editButton.setBorderPainted(false);
editButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createEditPane(parentPane);
PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog(
SwingUtilities.getWindowAncestor(PredefinedStyleBlock.this), editPane, previewObject.isBuiltIn());
editPane.populate(PredefinedStyleBlock.this.previewObject);
editDialog.setVisible(true);
}
});
panel.add(editButton, BorderLayout.EAST);
}
public PredefinedStyle update() {
return this.previewObject;
}
}

374
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java

@ -0,0 +1,374 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.config.predefined.ColorFillStyle;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.config.predefined.PredefinedColorStyle;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.ChartStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.ColorFillStylePane;
import com.fr.design.mainframe.predefined.ui.detail.PredefinedBackgroundSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.CellStyleListControlPane;
import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Created by kerry on 2020-08-26
*/
public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
private static final Color TIP_COLOR = Color.decode("#8F8F92");
private PredefinedStylePreviewPane previewPane;
private UITextField styleNameField;
private PredefinedBackgroundSettingPane backgroundSettingPane;
private CellStyleListControlPane cellStyleSettingPane;
private ComponentStyleSettingPane componentStyleSettingPane;
private ChartStyleSettingPane chartStyleSettingPane;
private PredefinedStyleSelectPane selectPane;
private ColorFillStylePane colorFillStylePane;
private boolean isPopulating = false;
private UITabbedPane uiTabbedPane;
private boolean isLightMode = true;
@Override
protected JPanel createContentPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(createLeftPane(), BorderLayout.WEST);
jPanel.add(createRightPane(), BorderLayout.CENTER);
this.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (!isPopulating) {
valueChangeAction();
}
}
});
return jPanel;
}
public void valueChangeAction() {
boolean displayFormBackground = backgroundSettingPane.currentFormBackground() || uiTabbedPane.getSelectedIndex() == 3;
previewPane.refresh(this.update(), displayFormBackground);
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Edit");
}
private PredefinedStyleEditPane(PredefinedStyleSelectPane selectPane, boolean newEditPane) {
this.selectPane = selectPane;
this.styleNameField.setEnabled(newEditPane);
}
public static PredefinedStyleEditPane createEditPane(PredefinedStyleSelectPane selectPane) {
return new PredefinedStyleEditPane(selectPane, false);
}
public static PredefinedStyleEditPane createNewEditPane(PredefinedStyleSelectPane selectPane) {
return new PredefinedStyleEditPane(selectPane, true);
}
private JPanel createLeftPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Overall_Preview"));
previewPane = new PredefinedStylePreviewPane();
previewPane.setPreferredSize(new Dimension(517, 500));
titlePane.add(previewPane);
jPanel.add(titlePane, BorderLayout.CENTER);
return jPanel;
}
private JPanel createRightPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel styleNamePane = createStyleNamePane();
jPanel.add(styleNamePane, BorderLayout.NORTH);
JPanel basicSettingPane = createBasicSettingPane();
jPanel.add(basicSettingPane, BorderLayout.CENTER);
JPanel customDetailPane = createCustomDetailPane();
jPanel.add(customDetailPane, BorderLayout.SOUTH);
return jPanel;
}
private JPanel createStyleNamePane() {
JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 26, 8);
jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Name")));
this.styleNameField = new UITextField();
this.styleNameField.setPreferredSize(new Dimension(160, 20));
jPanel.add(this.styleNameField);
return jPanel;
}
private JPanel createBasicSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Basic_Setting"));
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
colorFillStylePane = new ColorFillStylePane();
contentPane.add(colorFillStylePane);
titlePane.add(contentPane);
jPanel.add(titlePane, BorderLayout.CENTER);
titlePane.setSize(new Dimension(348, 157));
return jPanel;
}
private JPanel createCustomDetailPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Custom_Detail"));
titlePane.setLayout(FRGUIPaneFactory.createLeftZeroLayout());
jPanel.add(titlePane, BorderLayout.CENTER);
uiTabbedPane = new UITabbedPane();
uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), createTemplateBackgroundSettingPane());
uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane());
uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane());
uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Component_Style"), createComponentStyleSettingPane());
uiTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueChangeAction();
}
});
titlePane.add(uiTabbedPane);
uiTabbedPane.setPreferredSize(new Dimension(323, 298));
titlePane.setPreferredSize(new Dimension(333, 320));
return jPanel;
}
private JPanel createTemplateBackgroundSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
this.backgroundSettingPane = new PredefinedBackgroundSettingPane();
jPanel.setPreferredSize(new Dimension(309, 248));
UIScrollPane scrollPane = new UIScrollPane(this.backgroundSettingPane);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
jPanel.add(new UIScrollPane(this.backgroundSettingPane));
return jPanel;
}
private JPanel createCellStyleSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
this.cellStyleSettingPane = new CellStyleListControlPane();
this.cellStyleSettingPane.registerAttrChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
valueChangeAction();
}
});
jPanel.add(this.cellStyleSettingPane);
return jPanel;
}
private JPanel createChartStyleSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
this.chartStyleSettingPane = new ChartStyleSettingPane();
jPanel.add(this.chartStyleSettingPane);
return jPanel;
}
private JPanel createComponentStyleSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setLayout(new BorderLayout(0, 5));
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
this.componentStyleSettingPane = new ComponentStyleSettingPane();
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_ComponentStyle_Setting_Tip"));
label.setForeground(TIP_COLOR);
jPanel.add(label, BorderLayout.NORTH);
jPanel.add(this.componentStyleSettingPane, BorderLayout.CENTER);
return jPanel;
}
public void populate(PredefinedStyle previewObject) {
isPopulating = true;
isLightMode = previewObject.isLightMode();
styleNameField.setText(previewObject.getStyleName());
this.backgroundSettingPane.populateBean(previewObject.getPredefinedBackground());
this.cellStyleSettingPane.populateBean(previewObject.getCellStyleConfig());
this.componentStyleSettingPane.populateBean(previewObject.getComponentStyle());
this.colorFillStylePane.populateBean(previewObject.getPredefinedColorStyle());
this.chartStyleSettingPane.populateBean(previewObject.getPredefinedChartStyle());
previewPane.refresh(previewObject);
isPopulating = false;
}
public PredefinedStyle update() {
PredefinedStyle predefinedStyle = new PredefinedStyle();
predefinedStyle.setLightMode(isLightMode);
predefinedStyle.setStyleName(this.styleNameField.getText());
PredefinedCellStyleConfig cellStyleConfig = this.cellStyleSettingPane.updateBean();
predefinedStyle.setCellStyleConfig(cellStyleConfig);
predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean());
predefinedStyle.setComponentStyle(this.componentStyleSettingPane.updateBean());
PredefinedColorStyle colorStyle = this.colorFillStylePane.update();
updateCellStyleByColorStyle(colorStyle, cellStyleConfig);
predefinedStyle.setPredefinedColorStyle(colorStyle);
predefinedStyle.setPredefinedChartStyle(this.chartStyleSettingPane.updateBean());
return predefinedStyle;
}
private void updateCellStyleByColorStyle(PredefinedColorStyle colorStyle, PredefinedCellStyleConfig cellStyleConfig) {
PredefinedCellStyle headerStyle = cellStyleConfig.getStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
PredefinedCellStyle highlightStyle = cellStyleConfig.getStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text"));
ColorFillStyle colorFillStyle = colorStyle.getColorFillStyle();
List<Color> colorList = new ArrayList<>();
if (colorFillStyle == null || colorFillStyle.getColorList().size() == 0){
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance();
String defaultName = config.getCurrentStyle();
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
if (defaultStyle != null) {
colorList = defaultStyle.getColorList();
}
} else {
colorList = colorFillStyle.getColorList();
}
if (colorList.size() < 2) {
return;
}
if (headerStyle != null) {
Style style = headerStyle.getStyle();
Color color = colorList.get(0);
headerStyle.setStyle(style.deriveBackground(ColorBackground.getInstance(color)));
}
if (highlightStyle != null) {
Style style = highlightStyle.getStyle();
Color color = colorList.get(1);
FRFont font = style.getFRFont();
font.setForeground(color);
highlightStyle.setStyle(style.deriveFRFont(font));
}
}
public boolean saveStyle() {
PredefinedStyle previewObject;
try {
previewObject = update();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
if (this.styleNameField.isEnabled() && !validateRepeat(previewObject.getStyleName())) {
return false;
}
if (!saveStyle(previewObject)) {
return false;
}
HistoryTemplateListCache.getInstance().repaintCurrentEditingTemplate();
return true;
}
private boolean saveStyle(PredefinedStyle previewObject) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
if (StringUtils.isEmpty(previewObject.getStyleName())) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Name_Cannot_Empty"));
return false;
}
config.add(previewObject);
PredefinedStyleConfig sortedConfig = resortConfigStyles(previewObject, config);
// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
// @Override
// public void run() {
// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(sortedConfig);
// }
// });
selectPane.refreshPane();
return true;
}
public void saveAsNewStyle(String styleName) {
PredefinedStyle previewObject;
try {
previewObject = update();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
}
previewObject.setStyleName(styleName);
if (validateRepeat(styleName)) {
saveStyle(previewObject);
}
}
private boolean validateRepeat(String styleName) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
if (config.getStyle(styleName) != null) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(PredefinedStyleEditPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Name_Repeat"));
return false;
}
return true;
}
private PredefinedStyleConfig resortConfigStyles(PredefinedStyle priorityStyle, PredefinedStyleConfig config){
PredefinedStyleConfig sortedConfig = new PredefinedStyleConfig();
PredefinedStyle defaultStyle = config.getDefaultPredefinedStyle();
if (defaultStyle != null) {
sortedConfig.add(defaultStyle);
config.removeStyle(defaultStyle.getStyleName());
sortedConfig.setDefaultPredefinedStyle(defaultStyle.getStyleName());
}
if (priorityStyle != null && !priorityStyle.isDefaultStyle()) {
sortedConfig.add(priorityStyle);
config.removeStyle(priorityStyle.getStyleName());
}
Iterator<PredefinedStyle> iterator = config.getPredefinedStyleIterator();
while (iterator.hasNext()) {
PredefinedStyle entry = iterator.next();
sortedConfig.add(entry);
}
sortedConfig.setCompatibleStyleName(config.getCompatibleStyleName());
return sortedConfig;
}
}

102
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java

@ -0,0 +1,102 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.ChangeListener;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.util.Iterator;
import java.awt.BorderLayout;
import java.awt.Dimension;
/**
* Created by kerry on 2020-08-26
*/
public class PredefinedStyleSelectPane extends BasicPane {
private PredefinedStyleBlock selectedBlock;
private boolean editable;
private JPanel contentPane;
private String currentApplicateStyle;
private ChangeListener changeListener;
public PredefinedStyleSelectPane(String currentApplicateStyle, boolean editable) {
this.editable = editable;
this.currentApplicateStyle = currentApplicateStyle;
initPane();
}
public void registerChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
contentPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 8);
createContentPane();
UIScrollPane scrollPane = new UIScrollPane(contentPane);
scrollPane.setPreferredSize(new Dimension(630, 480));
scrollPane.setBorder(BorderFactory.createEmptyBorder());
this.add(scrollPane, BorderLayout.CENTER);
}
public void createContentPane() {
contentPane.removeAll();
Iterator<PredefinedStyle> iterator = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedStyleIterator();
int rowCount = (ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedSize() +2)/ 3;
contentPane.setPreferredSize(new Dimension(618, 220 * rowCount));
while (iterator.hasNext()) {
PredefinedStyle tmpStyle = iterator.next();
if (tmpStyle != null) {
PredefinedStyleBlock tmpPanel =
new PredefinedStyleBlock(tmpStyle, this, this.editable);
contentPane.add(tmpPanel);
}
}
}
public String getCurrentApplicateStyle() {
return currentApplicateStyle;
}
public void refreshPane() {
createContentPane();
this.validate();
this.repaint();
}
@Override
protected String title4PopupWindow() {
return null;
}
public void setSelectedPreviewPane(PredefinedStyleBlock selectedPreviewPane) {
this.selectedBlock = selectedPreviewPane;
if (changeListener != null) {
changeListener.fireChanged(null);
}
this.repaint();
}
public PredefinedStyleBlock getSelectedPreviewPane() {
return selectedBlock;
}
public PredefinedStyle update() {
if (this.selectedBlock == null){
return null;
}
return this.selectedBlock.update();
}
}

159
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java

@ -0,0 +1,159 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.config.predefined.PredefinedNameStyleProvider;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by kerry on 2020-09-02
*/
public abstract class PredefinedStyleSettingPane<T> extends AbstractAttrNoScrollPane {
protected StyleSettingPreviewPane previewPane;
protected UIRadioButton predefinedRadioBtn;
private UIRadioButton customRadioBtn;
private JPanel customDetailPane;
private JPanel predefinedSettingPane;
private CardLayout tabbedPane;
private JPanel center;
private boolean isPopulating = false;
public void setPopulating(boolean populating) {
isPopulating = populating;
}
protected void initContentPane() {
leftContentPane = createContentPane();
this.add(leftContentPane, BorderLayout.CENTER);
}
@Override
protected JPanel createContentPane() {
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewPane = createPreviewPane();
JPanel previewTitlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"));
if (previewPane != null) {
previewTitlePane.setPreferredSize(new Dimension(407, 527));
previewTitlePane.add(previewPane);
contentPane.add(previewTitlePane, BorderLayout.WEST);
}
customDetailPane = createCustomDetailPane();
predefinedSettingPane = createPredefinedSettingPane();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 20, 10);
jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style")));
predefinedRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined"));
customRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"));
tabbedPane = new CardLayout();
center = new JPanel(tabbedPane);
center.add(predefinedSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined"));
center.add(customDetailPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"));
predefinedRadioBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
populateCustomPane();
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined"));
}
});
customRadioBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"));
}
});
jPanel.add(predefinedRadioBtn);
jPanel.add(customRadioBtn);
ButtonGroup layoutBG = new ButtonGroup();
layoutBG.add(predefinedRadioBtn);
layoutBG.add(customRadioBtn);
centerPane.add(jPanel, BorderLayout.NORTH);
centerPane.add(center, BorderLayout.CENTER);
contentPane.add(centerPane, BorderLayout.CENTER);
this.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (isPopulating) {
return;
}
if (previewPane != null) {
previewPane.refresh();
}
}
});
return contentPane;
}
protected abstract StyleSettingPreviewPane createPreviewPane();
protected abstract JPanel createCustomDetailPane();
protected JPanel createPredefinedSettingPane() {
return new JPanel();
}
protected void populate(PredefinedNameStyleProvider nameStyle) {
this.predefinedRadioBtn.setSelected(nameStyle.usePredefinedStyle());
this.customRadioBtn.setSelected(!nameStyle.usePredefinedStyle());
if (nameStyle.usePredefinedStyle()) {
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined"));
} else {
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"));
}
}
protected String getPredefinedStyleName() {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return template.getTemplatePredefinedStyle();
}
/**
* 用于在切换到预定义样式后重置自定义样式的设置
*/
protected abstract void populateCustomPane();
/**
* 展示数据
*
* @param ob 待展示的对象
*/
public abstract void populateBean(T ob);
/**
* 保存数据
*
* @return 待保存的对象
*/
public abstract T updateBean();
/**
* 保存数据
*
* @param ob 待保存的对象
*/
public void updateBean(T ob) {
}
}

51
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java

@ -0,0 +1,51 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JTemplate;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
/**
* Created by kerry on 2020-08-28
*/
public class ReportPredefinedStylePane extends BasicPane {
private PredefinedStyleSelectPane selectPane;
private JTemplate currentTemplate;
public ReportPredefinedStylePane(JTemplate jTemplate) {
this.currentTemplate = jTemplate;
initPane();
}
private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Select"));
jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.selectPane = new PredefinedStyleSelectPane(currentTemplate.getTemplatePredefinedStyle(), false);
subPanel.add(this.selectPane, BorderLayout.CENTER);
jPanel.add(subPanel, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.CENTER);
}
public void update() {
PredefinedStyle style = selectPane.update();
if (style != null) {
// currentTemplate.resetPredefinedStyle(style.getStyleName());
}
}
public void refresh() {
this.selectPane.refreshPane();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style");
}
}

218
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java

@ -0,0 +1,218 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.base.BaseUtils;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.actions.UpdateAction;
import com.fr.design.event.ChangeEvent;
import com.fr.design.event.ChangeListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.predefined.PatternStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.DesignUtils;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* Created by kerry on 2020-08-25
*/
public class ServerPredefinedStylePane extends BasicPane {
private static final Color TIP_COLOR = Color.decode("#8F8F92");
private RemoveAction removeAction;
private PredefinedStyleSelectPane selectPane;
public ServerPredefinedStylePane() {
initPane();
}
private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager"));
jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
jPanel.setLayout(FRGUIPaneFactory.createLeftZeroLayout());
JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
subPanel.add(createControlPane(), BorderLayout.NORTH);
PredefinedStyle style = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getDefaultPredefinedStyle();
this.selectPane = new PredefinedStyleSelectPane(style == null ? StringUtils.EMPTY : style.getStyleName(), true);
this.selectPane.registerChangeListener(new ChangeListener() {
@Override
public void fireChanged(ChangeEvent event) {
PredefinedStyle selectStyle = selectPane.getSelectedPreviewPane().update();
removeAction.setEnabled(!selectStyle.isBuiltIn());
}
});
this.selectPane.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
if (selectPane.getSelectedPreviewPane() != null) {
removeAction.setEnabled(true);
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
JSeparator jSeparator = new JSeparator();
subPanel.add(jSeparator, BorderLayout.CENTER);
subPanel.add(this.selectPane, BorderLayout.SOUTH);
jPanel.add(subPanel);
this.add(jPanel, BorderLayout.CENTER);
this.repaint();
}
private JPanel createControlPane() {
MenuDef addMenuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
createAddMenuDef(addMenuDef);
ToolBarDef toolbarDef = new ToolBarDef();
removeAction = new RemoveAction();
removeAction.setEnabled(false);
toolbarDef.addShortCut(addMenuDef, removeAction);
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
toolbarDef.updateToolBar(toolBar);
JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
toolbarPane.add(toolBar, BorderLayout.CENTER);
UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager_Tip"));
tipLabel.setForeground(TIP_COLOR);
tipLabel.setHorizontalTextPosition(UILabel.RIGHT);
toolbarPane.add(tipLabel, BorderLayout.EAST);
toolbarPane.setPreferredSize(new Dimension(620, 30));
return toolbarPane;
}
private void createAddMenuDef(MenuDef addMenuDef) {
addMenuDef.setRePaint(true);
addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.DARK_STYLE));
addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.LIGHT_STYLE));
}
public void update() {
PredefinedStyle style = selectPane.update();
if (style != null) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
config.setDefaultPredefinedStyle(style.getStyleName());
// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
// @Override
// public void run() {
// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config);
// }
// });
}
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style");
}
private class RemoveAction extends UpdateAction {
public RemoveAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));
}
@Override
public void actionPerformed(ActionEvent e) {
PredefinedStyle previewObject = ServerPredefinedStylePane.this.selectPane.update();
int selVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this),
Toolkit.i18nText("Fine-Design_Predefined_Remove_Style_Confirm", previewObject.getStyleName()),
Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (selVal == JOptionPane.YES_OPTION) {
removeStyle(previewObject.getStyleName());
ServerPredefinedStylePane.this.selectPane.refreshPane();
}
}
}
private class CreateStyleAction extends UpdateAction {
private PatternStyle style;
public CreateStyleAction(PatternStyle style) {
this.style = style;
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Create_Parttern_Style") + style.getName());
this.setMnemonic('R');
}
@Override
public void actionPerformed(ActionEvent e) {
createNewPatternStylePane();
}
private void createNewPatternStylePane() {
PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createNewEditPane(selectPane);
PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog(
SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this), editPane);
PredefinedStyle predefinedStyle = style.getPredefinedStyle();
predefinedStyle.setStyleName(StringUtils.EMPTY);
editPane.populate(predefinedStyle);
editDialog.setVisible(true);
}
}
private void removeStyle(String name) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
config.removeStyle(name);
// Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) {
// @Override
// public void run() {
// ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config);
// }
// });
}
}

308
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleListControlPane.java

@ -0,0 +1,308 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.config.predefined.PredefinedCellStyleConfig;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane;
import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Created by kerry on 2020-09-27
*/
public class CellStyleListControlPane extends JListControlPane {
private boolean namePermitted = true;
private AttributeChangeListener attributeChangeListener;
public CellStyleListControlPane() {
super();
this.addModNameActionListener(new ModNameActionListener() {
public void nameModed(int index, String oldName, String newName) {
if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) {
return;
}
namePermitted = true;
String[] allNames = nameableList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index);
return;
}
if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index);
return;
}
populateSelectedValue();
}
});
}
public void registerAttrChangeListener(AttributeChangeListener listener){
this.attributeChangeListener = listener;
}
private void showTipDialogAndReset(String content, int index) {
nameableList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(CellStyleListControlPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
setIllegalIndex(index);
namePermitted = false;
}
@Override
public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePaneNoBorder.class) {
@Override
public boolean acceptDefaultNameObject(Object ob) {
return ((PredefinedCellStyle) ob).isDefaultStyle();
}
},
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)};
}
@Override
public BasicBeanPane createPaneByCreators(NameableCreator creator) {
CustomPredefinedStylePane stylePane = (CustomPredefinedStylePane) super.createPaneByCreators(creator);
stylePane.registerAttrChangeListener(attributeChangeListener);
return stylePane;
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
protected void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setCreators(this.createNameableCreators());
initCardPane();
JPanel leftPane = getLeftPane();
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
leftPane.setPreferredSize(new Dimension(70, 0));
jSeparator.setPreferredSize(new Dimension(2, 0));
cardPane.setPreferredSize(new Dimension(238, 0));
cardPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
JPanel mainSplitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
mainSplitPane.add(leftPane, BorderLayout.WEST);
mainSplitPane.add(jSeparator, BorderLayout.CENTER);
mainSplitPane.add(cardPane, BorderLayout.EAST);
this.add(mainSplitPane, BorderLayout.CENTER);
this.checkButtonEnabled();
}
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
createAddItemShortCut4JControlPane(),
new RemoveItemShortCut4JControlPane(new RemoveItemAction())
};
}
private static class CustomPredefinedStylePaneNoBorder extends CustomPredefinedStylePane {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new AlignmentPane());
return paneList;
}
}
private ShortCut4JControlPane createAddItemShortCut4JControlPane (){
ShortCut shortCut = shortCutFactory.createAddItemUpdateAction(new NameableCreator[]{
new CellStyleNameObjectCreator(Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"),
PredefinedCellStyle.class, CustomPredefinedStylePane.class)});
return new AddItemShortCut4JControlPane(shortCut);
}
private class AddItemShortCut4JControlPane extends ShortCut4JControlPane{
AddItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
}
@Override
public void checkEnable() {
this.shortCut.setEnabled(true);
}
}
private class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane {
RemoveItemShortCut4JControlPane(ShortCut shortCut) {
this.shortCut = shortCut;
}
@Override
public void checkEnable() {
ListModelElement selectModel = CellStyleListControlPane.this.getSelectedValue();
if (selectModel != null) {
NameObject selectNameObject = (NameObject) selectModel.wrapper;
PredefinedCellStyle cellStyle = (PredefinedCellStyle) (selectNameObject.getObject());
this.shortCut.setEnabled(!cellStyle.isBuiltIn() && !cellStyle.isDefaultStyle());
} else {
this.shortCut.setEnabled(false);
}
}
}
private class RemoveItemAction extends UpdateAction {
RemoveItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText(("Fine-Design_Basic_Action_Remove")));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
CellStyleListControlPane.this.onRemoveItem();
}
}
class CellStyleNameObjectCreator extends NameObjectCreator {
public CellStyleNameObjectCreator(String menuName, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, clazz, updatePane);
}
public Nameable createNameable(UnrepeatedNameHelper helper) {
Constructor<? extends PredefinedCellStyle> constructor = null;
try {
constructor = clazzOfInitCase.getConstructor();
PredefinedCellStyle cellStyle = constructor.newInstance();
cellStyle.setName(menuName);
cellStyle.setStyle(Style.getInstance());
return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle);
} catch (NoSuchMethodException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (InstantiationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (InvocationTargetException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/**
*
* @param ob
* @return
*/
public Object acceptObject2Populate(Object ob) {
if (ob instanceof NameObject) {
ob = ((NameObject) ob).getObject();
}
if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptDefaultNameObject(ob)) {
doSthChanged4Icon(ob);
return ob;
}
return null;
}
public boolean acceptDefaultNameObject(Object ob) {
return !((PredefinedCellStyle) ob).isDefaultStyle();
}
}
/**
* Populate
*/
public void populateBean(PredefinedCellStyleConfig ob) {
if (ob == null) {
return;
}
List nameStyleList = new ArrayList();
Iterator styleNameIterator = ob.getStyleNameIterator();
while (styleNameIterator.hasNext()) {
String name = (String) styleNameIterator.next();
PredefinedCellStyle tmpStyle = ob.getStyle(name);
if (tmpStyle != null) {
nameStyleList.add(new NameObject(name, tmpStyle));
}
}
NameObject[] nameObjects = new NameObject[nameStyleList.size()];
nameStyleList.toArray(nameObjects);
populate(nameObjects);
}
public PredefinedCellStyleConfig updateBean() {
Nameable[] nameables = this.update();
PredefinedCellStyleConfig styleConfig = new PredefinedCellStyleConfig();
for (int i = 0; i < nameables.length; i++) {
PredefinedCellStyle tmpStyle = (PredefinedCellStyle) ((NameObject) nameables[i]).getObject();
tmpStyle.setName(nameables[i].getName());
styleConfig.addStyle(tmpStyle);
}
return styleConfig;
}
}

94
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ChartStyleSettingPane.java

@ -0,0 +1,94 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.config.predefined.PredefinedChartStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartAxisStylePane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartBackgroundStylePane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartDataSheetStylePane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartLabelStylePane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartLegendStylePane;
import com.fr.design.mainframe.predefined.ui.detail.chart.ChartTitleStylePane;
import java.util.ArrayList;
import java.util.List;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-16
*/
public class ChartStyleSettingPane extends MultiTabPane<PredefinedChartStyle> {
private ChartTitleStylePane chartTitleStylePane;
private ChartLegendStylePane chartLegendStylePane;
private ChartLabelStylePane chartLabelPane;
private ChartAxisStylePane chartAxisStylePane;
private ChartDataSheetStylePane chartDataSheetStylePane;
private ChartBackgroundStylePane chartBackgroundStylePane;
public ChartStyleSettingPane() {
}
@Override
protected void initLayout() {
super.initLayout();
}
@Override
protected List<BasicPane> initPaneList() {
this.chartTitleStylePane = new ChartTitleStylePane();
this.chartLegendStylePane = new ChartLegendStylePane();
this.chartLabelPane = new ChartLabelStylePane();
this.chartAxisStylePane = new ChartAxisStylePane();
this.chartDataSheetStylePane = new ChartDataSheetStylePane();
this.chartBackgroundStylePane = new ChartBackgroundStylePane();
paneList = new ArrayList<>();
paneList.add(this.chartTitleStylePane);
paneList.add(this.chartLegendStylePane);
paneList.add(this.chartLabelPane);
paneList.add(this.chartAxisStylePane);
paneList.add(this.chartDataSheetStylePane);
paneList.add(this.chartBackgroundStylePane);
return paneList;
}
@Override
public void populateBean(PredefinedChartStyle ob) {
chartTitleStylePane.populate(ob);
chartLegendStylePane.populate(ob);
chartLabelPane.populate(ob);
chartAxisStylePane.populate(ob);
chartDataSheetStylePane.populate(ob);
chartBackgroundStylePane.populate(ob);
}
@Override
public void updateBean(PredefinedChartStyle ob) {
}
@Override
public PredefinedChartStyle updateBean() {
PredefinedChartStyle chartStyle = new PredefinedChartStyle();
chartTitleStylePane.update(chartStyle);
chartLegendStylePane.update(chartStyle);
chartLabelPane.update(chartStyle);
chartAxisStylePane.update(chartStyle);
chartDataSheetStylePane.update(chartStyle);
chartBackgroundStylePane.update(chartStyle);
return chartStyle;
}
@Override
public boolean accept(Object ob) {
return false;
}
@Override
public void reset() {
}
}

292
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java

@ -0,0 +1,292 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils;
import com.fr.chart.base.ChartConstants;
import com.fr.config.predefined.ColorFillStyle;
import com.fr.config.predefined.PredefinedColorStyle;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.icombobox.ColorSchemeComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.design.style.color.ColorAdjustPane;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.util.Arrays;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-15
*/
public class ColorFillStylePane extends BasicBeanPane<ColorFillStyle> {
private ColorSchemeComboBox styleSelectBox;
private JPanel customPane;
private JPanel changeColorSetPane;
private FixedGradientBar colorGradient;
private CardLayout cardLayout;
private ColorAdjustPane colorAdjustPane;
private Color[] gradientColors;
private Color[] accColors;
private boolean gradientSelect = false;
public ColorFillStylePane() {
this.setLayout(new BorderLayout());
styleSelectBox = createColorSchemeComboBox();
customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) {
@Override
public Dimension getPreferredSize() {
if (!customPane.isVisible()) {
return new Dimension(0, 0);
}
if (!gradientSelect) {
return colorAdjustPane.getPreferredSize();
}
return colorGradient.getPreferredSize();
}
};
changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER};
changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc");
accColors = ColorAdjustPane.DEFAULT_COLORS;
cardLayout.show(changeColorSetPane, "acc");
customPane.add(changeColorSetPane, BorderLayout.CENTER);
initListener();
initLayout();
}
public ColorSchemeComboBox getStyleSelectBox() {
return styleSelectBox;
}
public JPanel getCustomPane() {
return customPane;
}
protected ColorSchemeComboBox createColorSchemeComboBox() {
return new ColorSchemeComboBox();
}
private void initListener() {
colorAdjustPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
accColors = colorAdjustPane.getColors();
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR);
}
ColorFillStylePane.this.revalidate();
}
});
colorGradient.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner();
gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner();
if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR);
}
}
});
styleSelectBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
styleSelectBoxChange();
}
});
}
protected void styleSelectBoxChange() {
switch (styleSelectBox.getSelectType()) {
case COMBINATION_COLOR:
colorAdjustPane.updateColor(accColors);
cardLayout.show(changeColorSetPane, "acc");
gradientSelect = false;
break;
case GRADATION_COLOR:
colorGradient.updateColor(gradientColors[0], gradientColors[1]);
cardLayout.show(changeColorSetPane, "gradient");
gradientSelect = true;
break;
default:
ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo();
if (selectColorInfo == null) {
return;
}
if (selectColorInfo.isGradient()) {
colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1));
cardLayout.show(changeColorSetPane, "gradient");
gradientSelect = true;
} else {
colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{}));
cardLayout.show(changeColorSetPane, "acc");
gradientSelect = false;
}
break;
}
ColorFillStylePane.this.revalidate();
}
protected void initLayout() {
this.setLayout(new BorderLayout());
this.add(getContentPane(), BorderLayout.CENTER);
}
protected JPanel getContentPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = 155;
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(contentPaneComponents(), rowSize, columnSize, 12, LayoutConstants.VGAP_LARGE);
return panel;
}
protected Component[][] contentPaneComponents() {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Template_Color")), styleSelectBox},
new Component[]{null, customPane},
};
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Chart_Color");
}
public void populateBean(PredefinedColorStyle predefinedColorStyle) {
populateBean(predefinedColorStyle.getColorFillStyle());
}
@Override
public void populateBean(ColorFillStyle colorFillStyle) {
String fillStyleName = colorFillStyle == null ? "" : colorFillStyle.getFillStyleName();
if (StringUtils.isBlank(fillStyleName) || !styleSelectBox.getItems().contains(fillStyleName)) {
if (colorFillStyle == null || colorFillStyle.getColorStyle() == ChartConstants.COLOR_DEFAULT) {
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认
} else {
int colorStyle = colorFillStyle.getColorStyle();
if (colorStyle == ChartConstants.COLOR_GRADIENT) {
gradientColors[0] = colorFillStyle.getColorList().get(0);
gradientColors[1] = colorFillStyle.getColorList().get(1);
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR);
} else {
int colorSize = colorFillStyle.getColorList().size();
accColors = new Color[colorSize];
for (int i = 0; i < colorSize; i++) {
accColors[i] = colorFillStyle.getColorList().get(i);
}
styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR);
}
}
} else {
styleSelectBox.setSelectedItem(fillStyleName);
}
}
public PredefinedColorStyle update() {
PredefinedColorStyle predefinedColorStyle = new PredefinedColorStyle();
predefinedColorStyle.setColorFillStyle(updateBean());
return predefinedColorStyle;
}
@Override
public ColorFillStyle updateBean() {
switch (styleSelectBox.getSelectType()) {
case COMBINATION_COLOR:
return updateCombinationColor();
case GRADATION_COLOR:
return updateGradationColor();
case DEFAULT:
return updateDefaultColor();
default:
return updateNormalColor();
}
}
private ColorFillStyle updateCombinationColor() {
ColorFillStyle colorFillStyle = new ColorFillStyle();
List<Color> colorList = colorFillStyle.getColorList();
colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC);
for (int i = 0, length = accColors.length; i < length; i++) {
colorList.add(accColors[i]);
}
colorFillStyle.setCustomFillStyle(true);
return colorFillStyle;
}
private ColorFillStyle updateGradationColor() {
ColorFillStyle colorFillStyle = new ColorFillStyle();
List<Color> colorList = colorFillStyle.getColorList();
colorFillStyle.setColorStyle(ChartConstants.COLOR_GRADIENT);
Color start = gradientColors[0];
Color end = gradientColors[1];
colorList.add(start);
colorList.add(end);
colorFillStyle.setCustomFillStyle(true);
return colorFillStyle;
}
private ColorFillStyle updateDefaultColor() {
ColorFillStyle colorFillStyle = new ColorFillStyle();
colorFillStyle.setColorStyle(ChartConstants.COLOR_DEFAULT);
return colorFillStyle;
}
private ColorFillStyle updateNormalColor() {
ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance();
Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem());
if (preStyle instanceof ChartColorMatching) {
ColorFillStyle colorFillStyle = new ColorFillStyle();
ChartColorMatching chartColorMatching = (ChartColorMatching) preStyle;
colorFillStyle.setColorStyle(chartColorMatching.getGradient() ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC);
List<Color> colorList = chartColorMatching.getColorList();
if (colorList == null || colorList.size() == 0) {
colorList = Arrays.asList(ChartConstants.CHART_COLOR_ARRAY);
}
colorFillStyle.setColorList(colorList);
colorFillStyle.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem()));
return colorFillStyle;
} else {
return updateModifyColor();
}
}
private ColorFillStyle updateModifyColor() {
ColorFillStyle colorFillStyle = new ColorFillStyle();
ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo();
boolean isGradient = selectColorInfo.isGradient();
List<Color> colors = selectColorInfo.getColors();
colorFillStyle.setColorList(colors);
colorFillStyle.setCustomFillStyle(true);
colorFillStyle.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC);
return colorFillStyle;
}
}

63
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java

@ -0,0 +1,63 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.mainframe.predefined.ui.detail.component.ComponentFrameStylePane;
import com.fr.design.mainframe.predefined.ui.detail.component.ComponentTitleStylePane;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-09-01
*/
public class ComponentStyleSettingPane extends MultiTabPane<PredefinedComponentStyle> {
private ComponentFrameStylePane frameStylePane;
private ComponentTitleStylePane titleStylePane;
public ComponentStyleSettingPane() {
}
@Override
protected List<BasicPane> initPaneList() {
this.frameStylePane = new ComponentFrameStylePane();
this.titleStylePane = ComponentTitleStylePane.createPredefinedSettingPane();
paneList = new ArrayList<BasicPane>();
paneList.add(this.frameStylePane);
paneList.add(this.titleStylePane);
return paneList;
}
@Override
public void populateBean(PredefinedComponentStyle ob) {
this.frameStylePane.populate(ob);
this.titleStylePane.populate(ob);
}
@Override
public void updateBean(PredefinedComponentStyle ob) {
}
@Override
public PredefinedComponentStyle updateBean() {
PredefinedComponentStyle componentStyle = new PredefinedComponentStyle();
this.frameStylePane.update(componentStyle);
this.titleStylePane.update(componentStyle);
return componentStyle;
}
@Override
public boolean accept(Object ob) {
return false;
}
@Override
public void reset() {
}
}

81
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java

@ -0,0 +1,81 @@
package com.fr.design.mainframe.predefined.ui.detail;
import com.fr.config.predefined.PredefinedBackground;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundWithAlphaSettingPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by kerry on 2020-08-31
*/
public class PredefinedBackgroundSettingPane extends BasicBeanPane<PredefinedBackground> {
private UIButtonGroup buttonGroup;
private BackgroundSettingPane reportBackgroundSettingPane;
private BackgroundWithAlphaSettingPane formBackgroundSettingPane;
public PredefinedBackgroundSettingPane() {
initPane();
}
private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
reportBackgroundSettingPane = new BackgroundSettingPane();
formBackgroundSettingPane = new BackgroundWithAlphaSettingPane();
CardLayout tabbedPane = new CardLayout();
JPanel center = new JPanel(tabbedPane);
center.add(reportBackgroundSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report"));
center.add(formBackgroundSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report"));
this.buttonGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report")});
buttonGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (buttonGroup.getSelectedIndex() == 0) {
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plain_Report"));
} else {
tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Decision_Report"));
}
}
});
this.add(buttonGroup, BorderLayout.NORTH);
this.add(center, BorderLayout.CENTER);
this.buttonGroup.setSelectedIndex(0);
}
public boolean currentFormBackground() {
return buttonGroup.getSelectedIndex() == 1;
}
@Override
public void populateBean(PredefinedBackground predefinedBackground) {
reportBackgroundSettingPane.populateBean(predefinedBackground.getReportBackground());
formBackgroundSettingPane.populateBean(predefinedBackground.getFormBackground());
}
@Override
public PredefinedBackground updateBean() {
PredefinedBackground predefinedBackground = new PredefinedBackground();
predefinedBackground.setReportBackground(reportBackgroundSettingPane.updateBean());
predefinedBackground.setFormBackground(formBackgroundSettingPane.updateBean());
return predefinedBackground;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Predefined_Background_Setting");
}
}

51
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/AbstractBackgroundDetailPane.java

@ -0,0 +1,51 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.design.event.UIObserverListener;
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane;
import com.fr.general.Background;
import javax.swing.event.ChangeListener;
/**
* Created by kerry on 2020-09-14
*/
public abstract class AbstractBackgroundDetailPane<T extends Background> extends BackgroundQuickPane {
@Override
public boolean accept(Background background) {
return false;
}
@Override
public void populateBean(Background background) {
this.populate((T) background);
}
@Override
public Background updateBean() {
return this.update();
}
@Override
public String title4PopupWindow() {
return null;
}
@Override
public void reset() {
}
@Override
public void registerChangeListener(UIObserverListener listener) {
}
public abstract void populate(T background);
public abstract T update();
public void addChangeListener(ChangeListener changeListener) {
}
}

135
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java

@ -0,0 +1,135 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
/**
* Created by kerry on 2020-09-02
*/
public class BackgroundSettingPane extends BasicBeanPane<Background> {
private ChangeListener changeListener = null;
private UIComboBox headCombobox;
private BackgroundQuickPane[] paneList;
public BackgroundSettingPane() {
init();
}
private void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(createComboHeadPane(), BorderLayout.NORTH);
CardLayout cardlayout = new CardLayout();
paneList = supportKindsOfBackgroundUI();
final JPanel centerPane = new JPanel(cardlayout) {
@Override
public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度
int index = headCombobox.getSelectedIndex();
return new Dimension(super.getPreferredSize().width, paneList[index].getPreferredSize().height);
}
};
centerPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
for (BackgroundQuickPane pane : paneList) {
headCombobox.addItem(pane.title4PopupWindow());
centerPane.add(pane, pane.title4PopupWindow());
}
headCombobox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
cardlayout.show(centerPane, (String) headCombobox.getSelectedItem());
}
});
this.add(centerPane, BorderLayout.CENTER);
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private JPanel createComboHeadPane() {
headCombobox = new UIComboBox();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill")), headCombobox}},
TableLayoutHelper.FILL_NONE, 33, 5);
headCombobox.setPreferredSize(new Dimension(160, 20));
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
return jPanel;
}
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() {
java.util.List<BackgroundQuickPane> kinds = new ArrayList<>();
kinds.add(new EmptyBackgroundPane());
kinds.add(new ColorDetailPane());
kinds.add(new TextureDetailObservePane());
kinds.add(new PatternDetailPane());
kinds.add(createImageSelectPane());
kinds.add(new GradientDetailPane());
return kinds.toArray(new BackgroundQuickPane[kinds.size()]);
}
protected ImageDetailPane createImageSelectPane() {
ImageDetailPane imageDetailPane = new ImageDetailPane();
imageDetailPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireChangeListener();
}
});
return imageDetailPane;
}
protected void fireChangeListener() {
if (changeListener != null) {
changeListener.stateChanged(null);
}
}
@Override
public void populateBean(Background background) {
for (int i = 0; i < paneList.length; i++) {
BackgroundQuickPane pane = paneList[i];
if (pane.accept(background)) {
pane.populateBean(background);
headCombobox.setSelectedIndex(i);
return;
}
}
}
@Override
public Background updateBean() {
int selectIndex = this.headCombobox.getSelectedIndex();
try {
return paneList[selectIndex].updateBean();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

76
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java

@ -0,0 +1,76 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.config.predefined.BackgroundWithAlpha;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by kerry on 2020-09-04
*/
public class BackgroundWithAlphaSettingPane extends BasicBeanPane<BackgroundWithAlpha> {
private BackgroundSettingPane backgroundSettingPane;
//透明度
private UINumberDragPane numberDragPane;
private double maxNumber = 100;
public BackgroundWithAlphaSettingPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
backgroundSettingPane = new FormBackgroundSettingPane();
JPanel eastpane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(2, 0);
this.numberDragPane = new UINumberDragPane(0, 100);
this.numberDragPane.setPreferredSize(new Dimension(148, 20));
eastpane.add(numberDragPane);
eastpane.add(new UILabel("%"));
JPanel transparencyPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha")),
eastpane}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 5);
transparencyPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
Component[][] components = new Component[][]{
new Component[]{backgroundSettingPane},
new Component[]{transparencyPane}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_NONE, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1);
this.add(panel, BorderLayout.CENTER);
}
public void addChangeListener(ChangeListener changeListener) {
this.backgroundSettingPane.addChangeListener(changeListener);
}
@Override
public void populateBean(BackgroundWithAlpha ob) {
backgroundSettingPane.populateBean(ob.getBackground());
numberDragPane.populateBean(ob.getAlpha() * maxNumber);
}
@Override
public BackgroundWithAlpha updateBean() {
BackgroundWithAlpha backgroundWithAlpha = new BackgroundWithAlpha();
backgroundWithAlpha.setBackground(backgroundSettingPane.updateBean());
backgroundWithAlpha.setAlpha((float) (numberDragPane.updateBean() / maxNumber));
return backgroundWithAlpha;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

105
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java

@ -0,0 +1,105 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.base.background.ColorBackground;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectPane;
import com.fr.general.Background;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by kerry on 2020-08-31
*/
public class ColorDetailPane extends AbstractBackgroundDetailPane<ColorBackground> {
private ColorBackgroundSelectPane selectPane;
public ColorDetailPane() {
this.selectPane = new ColorBackgroundSelectPane();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(this.selectPane, BorderLayout.CENTER);
}
@Override
public void populate(ColorBackground background) {
this.selectPane.setColor(background.getColor());
}
@Override
public ColorBackground update() {
return ColorBackground.getInstance(selectPane.getColor());
}
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Color");
}
@Override
public boolean accept(Background background) {
return background instanceof ColorBackground;
}
class ColorBackgroundSelectPane extends ColorSelectPane implements UIObserver {
protected UIObserverListener uiObserverListener;
protected void initialCompents(boolean isSupportTransparent) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
if (isSupportTransparent) {
this.add(createNorthPane(), BorderLayout.NORTH);
}
JPanel centerPane = createCenterPane();
this.add(centerPane, BorderLayout.CENTER);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
}
});
}
private JPanel createNorthPane() {
// UIButton transpanrentBtn = createTranspanrentButton();
UIButton transpanrentBtn = new UIButton();
transpanrentBtn.setPreferredSize(new Dimension(160, 20));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Color")),
transpanrentBtn}}, TableLayoutHelper.FILL_NONE, 33, 5);
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
return jPanel;
}
protected JPanel createCenterPane() {
// JPanel centerPane = super.createCenterPane();
JPanel centerPane = new JPanel();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(" "), centerPane}}, TableLayoutHelper.FILL_NONE, 33, 5);
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
return jPanel;
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
}
}

34
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java

@ -0,0 +1,34 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.general.Background;
/**
* Created by kerry on 2020-09-01
*/
public class EmptyBackgroundPane extends AbstractBackgroundDetailPane {
@Override
public void populate(Background background) {
}
@Override
public Background update() {
return null;
}
/**
* 名称
*
* @return 名称
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Null");
}
public boolean accept(Background background) {
return background == null;
}
}

48
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/FormBackgroundSettingPane.java

@ -0,0 +1,48 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.event.UIObserverListener;
import com.fr.design.fun.BackgroundQuickUIProvider;
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* Created by kerry on 2020-09-14
*/
public class FormBackgroundSettingPane extends BackgroundSettingPane {
public FormBackgroundSettingPane() {
super();
}
@Override
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() {
ColorDetailPane colorDetailPane = new ColorDetailPane();
ImageDetailPane imageDetailPane = createImageSelectPane();
GradientDetailPane gradientPane = new GradientDetailPane();
//hugh:表单支持背景接口
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>();
kinds.add(new EmptyBackgroundPane());
kinds.add(colorDetailPane);
kinds.add(imageDetailPane);
kinds.add(gradientPane);
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING);
for (BackgroundQuickUIProvider provider : providers) {
BackgroundQuickPane newTypePane = provider.appearanceForBackground();
newTypePane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireChangeListener();
}
});
kinds.add(newTypePane);
}
return kinds.toArray(new BackgroundQuickPane[kinds.size()]);
}
}

159
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java

@ -0,0 +1,159 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.base.background.GradientBackground;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.gradient.GradientBar;
import com.fr.general.Background;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* 渐变色的面板不是很pp面板应用显得繁琐有写可以写成控件类型比如色彩选择的可以做得花哨点
*
* @author ben
*/
public class GradientDetailPane extends AbstractBackgroundDetailPane<GradientBackground> implements UIObserver {
private static final long serialVersionUID = -6854603990673031897L;
private UIObserverListener listener;
private UIRadioButton left2right, top2bottom;
private GradientBar gradientBar;
private ChangeListener changeListener = null;
public GradientDetailPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel blankJp = new JPanel();
gradientBar = new GradientBar(4, 140);
blankJp.add(gradientBar);
gradientPanel.add(gradientBar, BorderLayout.SOUTH);
JPanel jp = new JPanel(new GridLayout(2, 1, 15, 10));
left2right = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Horizontal"));
jp.add(left2right);
left2right.setSelected(true);
left2right.addActionListener(reviewListener);
top2bottom = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Vertical"));
jp.add(top2bottom);
top2bottom.addActionListener(reviewListener);
ButtonGroup toggle = new ButtonGroup();
toggle.add(left2right);
toggle.add(top2bottom);
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Setting")), gradientPanel},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Color")), jp}
};
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN,
IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listener != null) {
listener.doChange();
}
}
});
this.add(contentPane);
}
@Override
public boolean accept(Background background) {
return background instanceof GradientBackground;
}
public void populate(GradientBackground bg) {
this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor());
this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor());
if (bg.getDirection() == GradientBackground.LEFT2RIGHT) {
left2right.setSelected(true);
} else {
top2bottom.setSelected(true);
}
if (bg.isUseCell()) {
return;
}
double startValue = (double) bg.getBeginPlace();
double endValue = (double) bg.getFinishPlace();
gradientBar.setStartValue(startValue);
gradientBar.setEndValue(endValue);
this.gradientBar.repaint();
}
public GradientBackground update() {
GradientBackground gb = new GradientBackground(
gradientBar.getSelectColorPointBtnP1().getColorInner(),
gradientBar.getSelectColorPointBtnP2().getColorInner());
if (left2right.isSelected()) {
gb.setDirection(GradientBackground.LEFT2RIGHT);
} else {
gb.setDirection(GradientBackground.TOP2BOTTOM);
}
if (gradientBar.isOriginalPlace()) {
gb.setUseCell(true);
} else {
gb.setUseCell(false);
gb.setBeginPlace((float) gradientBar.getStartValue());
gb.setFinishPlace((float) gradientBar.getEndValue());
}
return gb;
}
ActionListener reviewListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
fireChagneListener();
}
};
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
gradientBar.addChangeListener(changeListener);
}
public void fireChagneListener() {
if (this.changeListener != null) {
ChangeEvent evt = new ChangeEvent(this);
this.changeListener.stateChanged(evt);
}
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Gradient_Color");
}
}

215
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java

@ -0,0 +1,215 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane;
import com.fr.general.Background;
import com.fr.stable.Constants;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Image background pane.
*/
public class ImageDetailPane extends AbstractBackgroundDetailPane<ImageBackground> implements UIObserver {
private UIObserverListener listener;
protected ImagePreviewPane previewPane = null;
private Style imageStyle = null;
private ChangeListener changeListener = null;
private ImageFileChooser imageFileChooser = null;
private UIRadioButton defaultRadioButton = null;
private UIRadioButton tiledRadioButton = null;
private UIRadioButton extendRadioButton = null;
private UIRadioButton adjustRadioButton = null;
public ImageDetailPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(initSelectFilePane(), BorderLayout.CENTER);
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
previewPane = new ImagePreviewPane();
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listener != null) {
listener.doChange();
}
}
});
}
public JPanel initSelectFilePane() {
JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane();
selectFilePane.setBorder(BorderFactory.createEmptyBorder());
UIButton selectPictureButton = new UIButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select"));
selectPictureButton.setMnemonic('S');
selectPictureButton.addActionListener(selectPictureActionListener);
selectPictureButton.setPreferredSize(new Dimension(160, 20));
//布局
defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Default"));
tiledRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Titled"));
extendRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Extend"));
adjustRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Adjust"));
defaultRadioButton.addActionListener(layoutActionListener);
tiledRadioButton.addActionListener(layoutActionListener);
extendRadioButton.addActionListener(layoutActionListener);
adjustRadioButton.addActionListener(layoutActionListener);
JPanel jp = new JPanel(new GridLayout(4, 1, 15, 10));
for (UIRadioButton button : imageLayoutButtons()) {
jp.add(button);
}
ButtonGroup layoutBG = new ButtonGroup();
layoutBG.add(defaultRadioButton);
layoutBG.add(tiledRadioButton);
layoutBG.add(extendRadioButton);
layoutBG.add(adjustRadioButton);
defaultRadioButton.setSelected(true);
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image")), selectPictureButton},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Fill_Mode")), jp}
};
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_NONE,
IntervalConstants.INTERVAL_L4, IntervalConstants.INTERVAL_L1);
selectFilePane.add(centerPane, BorderLayout.CENTER);
return selectFilePane;
}
protected UIRadioButton[] imageLayoutButtons() {
return new UIRadioButton[]{
defaultRadioButton,
tiledRadioButton,
extendRadioButton,
adjustRadioButton
};
}
@Override
public boolean accept(Background background) {
return background instanceof ImageBackground;
}
/**
* Select picture.
*/
ActionListener selectPictureActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int returnVal = imageFileChooser.showOpenDialog(ImageDetailPane.this);
setImageStyle();
ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal);
}
};
protected void setImageStyle() {
if (tiledRadioButton.isSelected()) {
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED);
} else if (adjustRadioButton.isSelected()) {
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST);
} else if (extendRadioButton.isSelected()) {
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND);
} else {
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER);
}
}
ActionListener layoutActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
setImageStyle();
changeImageStyle();
}
private void changeImageStyle() {
previewPane.setImageStyle(ImageDetailPane.this.imageStyle);
previewPane.repaint();
}
};
@Override
public void populate(ImageBackground imageBackground) {
if (imageBackground.getLayout() == Constants.IMAGE_CENTER) {
defaultRadioButton.setSelected(true);
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER);
} else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) {
extendRadioButton.setSelected(true);
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND);
} else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) {
adjustRadioButton.setSelected(true);
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST);
} else {
tiledRadioButton.setSelected(true);
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED);
}
previewPane.setImageStyle(ImageDetailPane.this.imageStyle);
if (imageBackground.getImage() != null) {
previewPane.setImageWithSuffix(imageBackground.getImageWithSuffix());
previewPane.setImage(imageBackground.getImage());
}
fireChagneListener();
}
@Override
public ImageBackground update() {
ImageBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix());
setImageStyle();
imageBackground.setLayout(imageStyle.getImageLayout());
return imageBackground;
}
@Override
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void fireChagneListener() {
if (this.changeListener != null) {
ChangeEvent evt = new ChangeEvent(this);
this.changeListener.stateChanged(evt);
}
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image");
}
}

119
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java

@ -0,0 +1,119 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.base.background.PatternBackground;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.impl.PatternBackgroundPane;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.LayoutManager;
/**
* Created by kerry on 2020-08-31
*/
public class PatternDetailPane extends AbstractBackgroundDetailPane<PatternBackground> implements UIObserver {
private UIObserverListener listener;
private PatternNewBackgroundPane patternNewBackgroundPane;
public PatternDetailPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
patternNewBackgroundPane = new PatternNewBackgroundPane(6);
this.add(patternNewBackgroundPane, BorderLayout.CENTER);
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
}
@Override
public void populate(PatternBackground background) {
this.patternNewBackgroundPane.populate(background);
}
@Override
public PatternBackground update() {
try {
return (PatternBackground) this.patternNewBackgroundPane.update();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern");
}
@Override
public boolean accept(Background background) {
return background instanceof PatternBackground;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
class PatternNewBackgroundPane extends PatternBackgroundPane {
private PatternNewBackgroundPane(int nColumn) {
super(nColumn);
}
protected LayoutManager layoutOfTypePane(int nColumn) {
return new GridLayout(0, nColumn, 2, 2);
}
protected void initComponents(int nColumn) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
JPanel jPanel = new JPanel();
jPanel.setLayout(layoutOfTypePane(nColumn));
setChildrenOfTypePane(jPanel);
foregroundColorPane = new ColorSelectBox(80);
backgroundColorPane = new ColorSelectBox(80);
foregroundColorPane.setSelectObject(Color.lightGray);
backgroundColorPane.setSelectObject(Color.black);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern"));
label.setVerticalAlignment(SwingConstants.TOP);
Component[][] components = new Component[][]{
new Component[]{label, jPanel},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_ForeBackground_Color")), foregroundColorPane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern_Color")), backgroundColorPane}
};
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN,
IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1);
JPanel jPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
jPanel1.add(centerPane);
jPanel1.setBorder(BorderFactory.createEmptyBorder());
this.add(jPanel1, BorderLayout.NORTH);
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listener != null) {
listener.doChange();
}
}
});
}
}
}

97
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java

@ -0,0 +1,97 @@
package com.fr.design.mainframe.predefined.ui.detail.background;
import com.fr.base.background.TextureBackground;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.texture.TextureDetailPane;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/**
* Created by kerry on 2020-09-02
*/
public class TextureDetailObservePane extends AbstractBackgroundDetailPane<TextureBackground> implements UIObserver {
private TextureDetailPane detailPane;
private UIObserverListener listener;
public TextureDetailObservePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
detailPane = TextureDetailPane.createMiniTextureDetailPane(6);
detailPane.setPreferredSize(new Dimension(160, 108));
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture"));
label.setPreferredSize(new Dimension(24, 108));
label.setVerticalAlignment(SwingConstants.TOP);
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{label, detailPane}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5);
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
detailPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (listener != null) {
listener.doChange();
}
}
});
this.add(jPanel, BorderLayout.CENTER);
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.listener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
@Override
public void populate(TextureBackground background) {
this.detailPane.populate(background);
}
@Override
public TextureBackground update() {
try {
return (TextureBackground) this.detailPane.update();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture");
}
@Override
public boolean accept(Background background) {
return background instanceof TextureBackground;
}
@Override
public void addChangeListener(ChangeListener changeListener) {
}
}

223
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java

@ -0,0 +1,223 @@
package com.fr.design.mainframe.predefined.ui.detail.cell;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedCellStyle;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.style.AbstractBasicStylePane;
import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
/**
* 复杂的原型图导致复杂的画法非我所愿也
*
* @author zhou
* @since 2012-5-24上午10:36:10
*/
public class CustomPredefinedStylePane extends MultiTabPane<PredefinedCellStyle> {
private PredefinedCellStyle cellStyle;
private PreviewArea previewArea;
private boolean populating;
private AttributeChangeListener attributeChangeListener;
public CustomPredefinedStylePane() {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY));
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
public void registerAttrChangeListener(AttributeChangeListener listener){
this.attributeChangeListener = listener;
}
private void fireAttrChangeListener() {
if (this.attributeChangeListener != null) {
this.attributeChangeListener.attributeChange();
}
}
/**
* @return
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Style");
}
/**
*
*/
public void reset() {
populateBean(null);
}
@Override
/**
*
*/
public void populateBean(PredefinedCellStyle ob) {
this.populating = true;
this.cellStyle = ob;
for (int i = 0; i < paneList.size(); i++) {
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob.getStyle());
previewArea.preview(ob.getStyle());
}
this.populating = false;
}
@Override
/**
*
*/
public PredefinedCellStyle updateBean() {
AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex());
this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle()));
return this.cellStyle;
}
/**
* @param ob
* @return
*/
public boolean accept(Object ob) {
return ob instanceof PredefinedCellStyle;
}
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new BorderPane());
paneList.add(new AlignmentPane());
return paneList;
}
protected void initLayout() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel jPanel = new JPanel();
jPanel.setLayout(new BorderLayout(0, 4));
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
previewArea = new PreviewArea();
previewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null));
previewPane.add(previewArea, BorderLayout.CENTER);
this.add(previewPane, BorderLayout.NORTH);
this.add(jPanel, BorderLayout.CENTER);
jPanel.add(tabPane, BorderLayout.NORTH);
JPanel attrListenerPane = new AbstractAttrNoScrollPane() {
@Override
protected void initContentPane() {
leftContentPane = createContentPane();
this.add(leftContentPane, BorderLayout.CENTER);
}
@Override
protected JPanel createContentPane() {
this.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (populating) {
return;
}
PredefinedCellStyle cellStyle = updateBean();
if (cellStyle != null) {
previewArea.preview(cellStyle.getStyle());
}
fireAttrChangeListener();
}
});
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return centerPane;
}
};
return basicScrollPane;
}
};
jPanel.add(attrListenerPane, BorderLayout.CENTER);
}
@Override
/**
*
*/
public void updateBean(PredefinedCellStyle ob) {
return;
}
/**
* 预览Style的面板
*
* @author richer
*/
private static class PreviewArea extends JComponent {
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public PreviewArea() {
setPreferredSize(new Dimension(40, 30));
}
public void preview(Style style) {
this.style = style;
repaint();
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
return;
}
Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3);
Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution);
Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}
}

49
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/AbstractChartStylePane.java

@ -0,0 +1,49 @@
package com.fr.design.mainframe.predefined.ui.detail.chart;
import com.fr.config.predefined.PredefinedChartStyle;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-17
*/
public abstract class AbstractChartStylePane extends BasicPane {
public AbstractChartStylePane() {
initComponents();
initPane();
}
protected abstract void initComponents();
protected void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
double e = 155;
double p = TableLayout.PREFERRED;
double[] columnSize = {p, e};
JPanel gapTableLayoutPane = TableLayoutHelper.createGapTableLayoutPane(getComponent(), getRows(p), columnSize, 20, LayoutConstants.VGAP_LARGE);
gapTableLayoutPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
UIScrollPane rightTopPane = new UIScrollPane(gapTableLayoutPane);
rightTopPane.setBorder(BorderFactory.createEmptyBorder());
this.add(rightTopPane, BorderLayout.CENTER);
}
protected abstract Component[][] getComponent();
protected abstract double[] getRows(double p);
public abstract void populate(PredefinedChartStyle chartStyle);
public abstract void update(PredefinedChartStyle chartStyle);
}

69
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartAxisStylePane.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe.predefined.ui.detail.chart;
import com.fr.config.predefined.PredefinedChartStyle;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.style.color.ColorSelectBox;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-16
*/
public class ChartAxisStylePane extends AbstractChartStylePane {
//轴标题字体样式
private ChartFontPane titleFontPane;
//轴标签字体样式
private ChartFontPane labelFontPane;
//轴线颜色
private ColorSelectBox axisLineColor;
protected void initComponents() {
titleFontPane = new ChartFontPane() {
public String getUILabelText() {
return Toolkit.i18nText("Fine-Design_Chart_Axis_Title_Character");
}
};
labelFontPane = new ChartFontPane() {
public String getUILabelText() {
return Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Character");
}
};
axisLineColor = new ColorSelectBox(100);
}
protected Component[][] getComponent() {
return new Component[][]{
new Component[]{titleFontPane, null},
new Component[]{labelFontPane, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Axis_Line_Color")), axisLineColor}
};
}
protected double[] getRows(double p) {
return new double[]{p, p, p};
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis");
}
public void populate(PredefinedChartStyle chartStyle) {
titleFontPane.populate(chartStyle.getAxisTitleFont());
labelFontPane.populate(chartStyle.getAxisLabelFont());
axisLineColor.setSelectObject(chartStyle.getAxisLineColor());
}
public void update(PredefinedChartStyle chartStyle) {
chartStyle.setAxisTitleFont(titleFontPane.update());
chartStyle.setAxisLabelFont(labelFontPane.update());
chartStyle.setAxisLineColor(axisLineColor.getSelectObject());
}
}

113
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartBackgroundStylePane.java

@ -0,0 +1,113 @@
package com.fr.design.mainframe.predefined.ui.detail.chart;
import com.fr.base.background.ImageBackground;
import com.fr.config.predefined.PredefinedChartStyle;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.VanChartGradientPane;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.general.Background;
import com.fr.stable.Constants;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-17
*/
public class ChartBackgroundStylePane extends AbstractChartStylePane {
private UIComboBox typeComboBox;
private List<BackgroundQuickPane> paneList;
private JPanel centerPane;
//网格线颜色
private ColorSelectBox mainGridColor;
protected void initComponents() {
mainGridColor = new ColorSelectBox(100);
typeComboBox = new UIComboBox();
final CardLayout cardlayout = new CardLayout();
initList();
centerPane = new JPanel(cardlayout) {
@Override
public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度
int index = typeComboBox.getSelectedIndex();
return new Dimension(super.getPreferredSize().width, paneList.get(index).getPreferredSize().height);
}
};
for (int i = 0; i < paneList.size(); i++) {
BackgroundQuickPane pane = paneList.get(i);
typeComboBox.addItem(pane.title4PopupWindow());
centerPane.add(pane, pane.title4PopupWindow());
}
typeComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem());
}
});
}
protected Component[][] getComponent() {
return new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Background_Color")), typeComboBox},
new Component[]{null, centerPane},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Grid_Line_Color")), mainGridColor}
};
}
protected double[] getRows(double p) {
return new double[]{p, p, p, p};
}
private void initList() {
paneList = new ArrayList<>();
paneList.add(new NullBackgroundQuickPane());
paneList.add(new ColorBackgroundQuickPane());
paneList.add(new ImageBackgroundQuickPane(false));
paneList.add(new VanChartGradientPane());
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background");
}
public void populate(PredefinedChartStyle chartStyle) {
Background background = chartStyle.getChartBackground();
for (int i = 0; i < paneList.size(); i++) {
BackgroundQuickPane pane = paneList.get(i);
if (pane.accept(background)) {
pane.populateBean(background);
typeComboBox.setSelectedIndex(i);
break;
}
}
mainGridColor.setSelectObject(chartStyle.getGridMainLineColor());
}
public void update(PredefinedChartStyle chartStyle) {
chartStyle.setChartBackground(paneList.get(typeComboBox.getSelectedIndex()).updateBean());
if (chartStyle.getChartBackground() instanceof ImageBackground) {
((ImageBackground) chartStyle.getChartBackground()).setLayout(Constants.IMAGE_EXTEND);
}
chartStyle.setGridMainLineColor(mainGridColor.getSelectObject());
}
}

58
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartDataSheetStylePane.java

@ -0,0 +1,58 @@
package com.fr.design.mainframe.predefined.ui.detail.chart;
import com.fr.config.predefined.PredefinedChartStyle;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.style.color.ColorSelectBox;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-17
*/
public class ChartDataSheetStylePane extends AbstractChartStylePane {
//字体样式
private ChartFontPane fontPane;
//边框颜色
private ColorSelectBox borderColor;
protected void initComponents() {
fontPane = new ChartFontPane() {
public String getUILabelText() {
return Toolkit.i18nText("Fine-Design_Chart_DataSheet_Character");
}
};
borderColor = new ColorSelectBox(100);
}
protected Component[][] getComponent() {
return new Component[][]{
new Component[]{fontPane, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Border_Color")), borderColor}
};
}
protected double[] getRows(double p) {
return new double[]{p, p, p};
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Sheet");
}
public void populate(PredefinedChartStyle chartStyle) {
fontPane.populate(chartStyle.getDataSheetFont());
borderColor.setSelectObject(chartStyle.getDataSheetBorderColor());
}
public void update(PredefinedChartStyle chartStyle) {
chartStyle.setDataSheetFont(fontPane.update());
chartStyle.setDataSheetBorderColor(borderColor.getSelectObject());
}
}

160
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/chart/ChartFontPane.java

@ -0,0 +1,160 @@
package com.fr.design.mainframe.predefined.ui.detail.chart;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralUtils;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-16
*/
public class ChartFontPane extends BasicPane {
public static final int FONT_START = 6;
public static final int FONT_END = 72;
private UIComboBox fontNameComboBox;
private UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
private UIColorButton fontColor;
private static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1];
static {
for (int i = FONT_START; i <= FONT_END; i++) {
FONT_SIZES[i - FONT_START] = i;
}
}
public ChartFontPane() {
initState();
initComponents();
}
private void initState() {
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontSizeComboBox = new UIComboBox(FONT_SIZES);
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
fontColor = new UIColorButton();
}
protected void initComponents() {
Component[] components = new Component[]{
fontColor, italic, bold
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(fontSizeComboBox, BorderLayout.CENTER);
buttonPane.add(GUICoreUtils.createFlowPane(components, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST);
this.setLayout(new BorderLayout());
this.add(getContentPane(buttonPane), BorderLayout.CENTER);
populate(FRContext.getDefaultValues().getFRFont());
}
protected JPanel getContentPane(JPanel buttonPane) {
double e = 155;
double p = TableLayout.PREFERRED;
double[] rows = {p, p, p};
double[] columnSize = {p, e};
UILabel text = new UILabel(getUILabelText(), SwingConstants.LEFT);
Component[][] components = {
new Component[]{null, null},
new Component[]{text, fontNameComboBox},
new Component[]{null, buttonPane}
};
return TableLayoutHelper.createGapTableLayoutPane(components, rows, columnSize, 20, LayoutConstants.VGAP_LARGE);
}
public String getUILabelText() {
return Toolkit.i18nText("Fine-Design_Chart_Character");
}
public String title4PopupWindow() {
return null;
}
public void populate(FRFont frFont) {
UIObserverListener listener = fontNameComboBox == null ? null : fontNameComboBox.getUiObserverListener();
removeAllComboBoxListener();
if (frFont != null) {
fontNameComboBox.setSelectedItem(frFont.getFamily());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
populateFontSize(frFont);
if (fontColor != null) {
fontColor.setColor(frFont.getForeground());
}
}
//更新结束后,注册监听器
registerAllComboBoxListener(listener);
}
private void populateFontSize(FRFont frFont) {
if (fontSizeComboBox != null) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
}
}
private void removeAllComboBoxListener() {
fontNameComboBox.removeChangeListener();
fontSizeComboBox.removeChangeListener();
}
private void registerAllComboBoxListener(UIObserverListener listener) {
fontNameComboBox.registerChangeListener(listener);
fontSizeComboBox.registerChangeListener(listener);
}
/**
* 更新字
*
* @return 更新字
*/
public FRFont update() {
String name = GeneralUtils.objectToString(fontNameComboBox.getSelectedItem());
return FRFont.getInstance(name, updateFontStyle(), updateFontSize(), fontColor.getColor());
}
private int updateFontStyle() {
int style = Font.PLAIN;
if (bold.isSelected() && !italic.isSelected()) {
style = Font.BOLD;
} else if (!bold.isSelected() && italic.isSelected()) {
style = Font.ITALIC;
} else if (bold.isSelected() && italic.isSelected()) {
style = 3;
}
return style;
}
private float updateFontSize() {
return Float.parseFloat(GeneralUtils.objectToString(fontSizeComboBox.getSelectedItem()));
}
}

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

Loading…
Cancel
Save